store.js 2.41 KB
import { getCreateShowTime, dealRepeatModal } from '../../utils/utils';
import { updateMeetingTask } from '../../api/request';
import { fixSeperateIndex } from './meetingDetail';
class Store {
    data = {
        affairList: [],
        separateIndex: -1,
        currentTask: {}, // 任务  endTime, excutor, title, excutorId
        notes: null, //{meetingNotes: '', commentId: ''}
        parentCommentId: '', // 评论的动态Id
        remark: null,   //{remark: '', commentId: ''}
        files: [],
        tasks: [],
        fileInfos: null,
        description: '',
        oldFileInfos: '',
        oldDescription: '',
        scheduleId: '',
        groupId: '',
        isNeedReloadList: false,
        isNeedReloadIndexList: false,
        logId: '',
        relatedAppPlatform: null,
        modifyDynamicId: ''
    }
    changeStatus(meetingId, taskModifyModel, callBack) {

        const data = {
            meetingId: meetingId,
            platform: 'dingTalk',
            taskModifyModel
        };
        // 修改详情列表
        const index = this.data.affairList.findIndex(it => it.commentId === taskModifyModel.commentId);
        if (index !== -1) {
            const changeData = this.data.affairList[index];
            changeData.meetingTaskSimpleViewModel.processState = taskModifyModel.processState;
            changeData.updateTime = getCreateShowTime(new Date());

            this.data.affairList.splice(index, 1);
            this.data.affairList.unshift(changeData);


            if (index > this.data.separateIndex && this.data.separateIndex !== -1) {
                this.data.separateIndex += 1;
                this.data.separateIndex = fixSeperateIndex(this.data.separateIndex, this.data.affairList)
            }

            this.update();

            // 页面定位到最上面
            if (callBack) {
                callBack()
            }
        }

        // 修改任务列表页面
        const tasksIndex = this.data.tasks.findIndex(it => it.commentId === taskModifyModel.commentId);
        if (tasksIndex !== -1) {
            this.data.tasks[tasksIndex].processState = taskModifyModel.processState;
            this.data.tasks[tasksIndex].updateTime = getCreateShowTime(new Date());
        }


        updateMeetingTask(data).then(res => {
            if (res.data.code !== 0) {
                dd.alert('操作失败,请重试')
            }
        });
    }
}
export default new Store()