|
@@ -1,8 +1,16 @@
|
|
|
<script setup>
|
|
|
-import { ref } from 'vue';
|
|
|
-import { Icon } from 'vant';
|
|
|
+import { ref, reactive } from 'vue';
|
|
|
+import { useRoute } from 'vue-router';
|
|
|
+import { researcherList } from '@/api/ssbg/api';
|
|
|
+import { Icon, Toast,TreeSelect,Popup } from 'vant';
|
|
|
+import { isWxprogram } from '../utils';
|
|
|
+import { findParentByid } from './common-calendar';
|
|
|
import Calendar from '../components/calendar.vue';
|
|
|
|
|
|
+
|
|
|
+const route = useRoute();
|
|
|
+localStorage.setItem('ssbg-token',route.query.token || '5e532bc5fa7281aebaa6d89960b54c4ab22f1ab18e969258c634a7940fdb0922');
|
|
|
+
|
|
|
const actionsList = ref([
|
|
|
{ label: '添加活动', key: 'add', icon: 'add-o' },
|
|
|
{
|
|
@@ -17,32 +25,144 @@ const actionsList = ref([
|
|
|
},
|
|
|
]);
|
|
|
|
|
|
+const calendarRef = ref(null);
|
|
|
+
|
|
|
+const state = reactive({
|
|
|
+ selectResearcher: '', // 选中的研究员
|
|
|
+});
|
|
|
+
|
|
|
/* 获取日历日程列表 */
|
|
|
const getEventList = (date) => {
|
|
|
console.log(date, '日程');
|
|
|
};
|
|
|
|
|
|
+/* 点击日历表格添加活动 */
|
|
|
+const cellClickHandle = (date) => {
|
|
|
+ console.log(date);
|
|
|
+ console.log(state.selectResearcher)
|
|
|
+
|
|
|
+ if (!state.selectResearcher) return Toast.fail('请先选择研究员');
|
|
|
+
|
|
|
+ const endDate = new Date(date.getTime() + 1000 * 60 * 60);
|
|
|
+ const selectResearchers = [
|
|
|
+ {
|
|
|
+ researcherId: this.selectResearcher.ResearcherId,
|
|
|
+ startDate: startDate,
|
|
|
+ startTime: startDate,
|
|
|
+ endDate: endDate,
|
|
|
+ endTime: endDate,
|
|
|
+ }
|
|
|
+ ]
|
|
|
+
|
|
|
+ uni.navigateTo({
|
|
|
+ url: `/pages-roadshow/addActivity/cellAdd?defaultOpt=${JSON.stringify(selectResearchers)}`,
|
|
|
+ });
|
|
|
+};
|
|
|
+
|
|
|
+/* 底部操作 */
|
|
|
+const dealActionHandler = (type) => {
|
|
|
+ const deal_methods_handles = {
|
|
|
+ add: addActivityHandleByBtn,
|
|
|
+ weeknow: toogeCurrentWeek,
|
|
|
+ choose: slectResearcherHandle,
|
|
|
+ };
|
|
|
+ deal_methods_handles[type]();
|
|
|
+};
|
|
|
+
|
|
|
+/* 点击按钮添加活动 */
|
|
|
+const addActivityHandleByBtn = () => {
|
|
|
+ uni.navigateTo({
|
|
|
+ url: '/pages-roadshow/addActivity/index',
|
|
|
+ });
|
|
|
+};
|
|
|
+
|
|
|
+/* 切换为本周 */
|
|
|
+const toogeCurrentWeek = () => {
|
|
|
+ calendarRef.value.toogeCurrentWeek();
|
|
|
+};
|
|
|
+
|
|
|
+/* ==========选择研究员picker============ */
|
|
|
+const researcherArr = ref([]);
|
|
|
+const isResearcherPicker = ref(false);
|
|
|
+
|
|
|
+const rs_picker = ref({
|
|
|
+ firstindex: 0,
|
|
|
+ id: ''
|
|
|
+})
|
|
|
+
|
|
|
+/* 获取研究员列表 */
|
|
|
+const getResearcherList = async() => {
|
|
|
+ const { code,data } = await researcherList();
|
|
|
+ if(code !== 200) return;
|
|
|
+ researcherArr.value = data.map(group => ({
|
|
|
+ ...group,
|
|
|
+ text: group.GroupName,
|
|
|
+ children: group.ResearcherList ? group.ResearcherList.map(child => ({
|
|
|
+ ...child,
|
|
|
+ text: child.RealName,
|
|
|
+ id: child.AdminId
|
|
|
+ })) : []
|
|
|
+ }));
|
|
|
+}
|
|
|
+getResearcherList();
|
|
|
+
|
|
|
+/* 选择研究员 */
|
|
|
+const slectResearcherHandle = () => {
|
|
|
+ // console.log('slect');
|
|
|
+ if(state.selectResearcher) {
|
|
|
+ rs_picker.value = {
|
|
|
+ firstindex: findParentByid(state.selectResearcher,researcherArr.value),
|
|
|
+ id: state.selectResearcher
|
|
|
+ }
|
|
|
+ }
|
|
|
+ isResearcherPicker.value = true;
|
|
|
+};
|
|
|
+
|
|
|
+/* 点击第一项索引 */
|
|
|
+const clickFirstHandle = (index) => {
|
|
|
+ rs_picker.value.firstindex = index;
|
|
|
+}
|
|
|
+/* 点击选择研究员 */
|
|
|
+const clickItemHandle = ({AdminId}) => {
|
|
|
+ rs_picker.value.id = AdminId;
|
|
|
+}
|
|
|
+/* 取消 */
|
|
|
+const cancelResearcher = () => {
|
|
|
|
|
|
+ isResearcherPicker.value = false;
|
|
|
+}
|
|
|
+/* 确认 */
|
|
|
+const confirmResearcher = () => {
|
|
|
+ state.selectResearcher = rs_picker.value.id;
|
|
|
+
|
|
|
+ isResearcherPicker.value = false;
|
|
|
+}
|
|
|
|
|
|
+
|
|
|
+document.title = '研究员日历';
|
|
|
</script>
|
|
|
|
|
|
<!-- -->
|
|
|
<template>
|
|
|
<div class="rs-container">
|
|
|
- <Calendar @dateChange="getEventList" />
|
|
|
-
|
|
|
+ <Calendar @dateChange="getEventList" @cellClick="cellClickHandle" ref="calendarRef"/>
|
|
|
+<!-- v-if="isWxprogram()" -->
|
|
|
<div class="fix-action">
|
|
|
<ul class="action-ul">
|
|
|
- <li v-for="item in actionsList" key="item.key">
|
|
|
+ <li
|
|
|
+ v-for="item in actionsList"
|
|
|
+ key="item.key"
|
|
|
+ @click="dealActionHandler(item.key)"
|
|
|
+ >
|
|
|
<Icon :name="item.icon" class="item-icon" v-if="item.icon" />
|
|
|
<img
|
|
|
- class="item-img"
|
|
|
+ class="item-img"
|
|
|
src="@/assets/ssbg/calendar_ico.png"
|
|
|
alt=""
|
|
|
v-else-if="item.key === 'weeknow'"
|
|
|
/>
|
|
|
<img
|
|
|
- class="item-img"
|
|
|
+ class="item-img"
|
|
|
src="@/assets/ssbg/choose_ico.png"
|
|
|
alt=""
|
|
|
v-else-if="item.key === 'choose'"
|
|
@@ -51,6 +171,23 @@ const getEventList = (date) => {
|
|
|
</li>
|
|
|
</ul>
|
|
|
</div>
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ <!-- 选择研究员picker -->
|
|
|
+ <Popup v-model:show="isResearcherPicker" position="bottom">
|
|
|
+ <view class="select-rs-header">
|
|
|
+ <text class="cancel" @click="cancelResearcher">取消</text>
|
|
|
+ <text class="ensure" @click="confirmResearcher">确认</text>
|
|
|
+ </view>
|
|
|
+ <TreeSelect
|
|
|
+ :items="researcherArr"
|
|
|
+ :main-active-index="rs_picker.firstindex"
|
|
|
+ :active-id="rs_picker.id"
|
|
|
+ @click-nav="clickFirstHandle"
|
|
|
+ @click-item="clickItemHandle"
|
|
|
+ />
|
|
|
+ </Popup>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
@@ -65,25 +202,57 @@ const getEventList = (date) => {
|
|
|
z-index: 99;
|
|
|
background-color: #fff;
|
|
|
box-shadow: 0px -3px 6px rgba(172, 172, 172, 0.16);
|
|
|
+ padding-top: 20px;
|
|
|
+ padding-bottom: constant(safe-area-inset-bottom);
|
|
|
+ padding-bottom: env(safe-area-inset-bottom);
|
|
|
.action-ul {
|
|
|
height: 100%;
|
|
|
display: flex;
|
|
|
align-items: center;
|
|
|
justify-content: space-around;
|
|
|
color: #3385ff;
|
|
|
+ li:hover {
|
|
|
+ opacity: 0.8;
|
|
|
+ }
|
|
|
.item-icon {
|
|
|
font-size: 52px;
|
|
|
display: block;
|
|
|
text-align: center;
|
|
|
margin: 0 auto 10px;
|
|
|
}
|
|
|
- .item-img {
|
|
|
- display: block;
|
|
|
- width: 46px;
|
|
|
- height: 46px;
|
|
|
- margin: 0 auto 10px;
|
|
|
- }
|
|
|
+ .item-img {
|
|
|
+ display: block;
|
|
|
+ width: 46px;
|
|
|
+ height: 46px;
|
|
|
+ margin: 0 auto 10px;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ .select-rs-header {
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ justify-content: space-between;
|
|
|
+ padding: 30px 20px;
|
|
|
+
|
|
|
+ .cancel {
|
|
|
+ color: #969799;
|
|
|
+ }
|
|
|
+
|
|
|
+ .ensure {
|
|
|
+ color: #576b95;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ .van-tree-select {
|
|
|
+ ::v-deep(.van-sidebar-item--select:before) {
|
|
|
+ background-color: #1989fa;
|
|
|
+ }
|
|
|
+
|
|
|
+ ::v-deep(.van-tree-select__item--active) {
|
|
|
+ color: #1989fa;
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
}
|
|
|
</style>
|