import { unref } from 'vue';
|
import dayjs from 'dayjs';
|
import taskApi from '@/api/fysp/taskApi';
|
import subtaskApi from '@/api/fysp/subtaskApi';
|
|
export default {
|
/**
|
* 生成巡查子任务对象
|
*/
|
createSubtasks(dayTask, sceneList, executors) {
|
const seletedSceneList = unref(sceneList);
|
const subtasks = seletedSceneList.map((_) => {
|
const s = _.scene;
|
return {
|
// 主键由服务端创建
|
stguid: undefined,
|
tguid: dayTask.tsGuid,
|
tsguid: dayTask.guid,
|
name: `${s.name}巡查`,
|
typeno: 1,
|
type: '巡查',
|
provincecode: s.provincecode,
|
provincename: s.provincename,
|
citycode: s.citycode,
|
cityname: s.cityname,
|
districtcode: s.districtcode,
|
districtname: s.districtname,
|
scensename: s.name,
|
scenseid: s.guid,
|
scenseaddress: s.location,
|
planstarttime: dayTask.date,
|
planendtime: dayjs(dayTask.date)
|
.endOf('day')
|
.set('millisecond', 0)
|
.toDate(),
|
deployerguid: 'rAR0A4gJdlOZEqZs',
|
deployerusername: 'ccheck',
|
deployerrealname: '整改审核',
|
executorguids: executors.ids,
|
executorusernames: executors.uName,
|
executorrealtimes: executors.rName,
|
status: '未执行',
|
remark: undefined
|
};
|
});
|
|
// 更新场景监管次数
|
seletedSceneList.forEach((s) => {
|
s.extension1 = s.extension1 ? parseInt(s.extension1) + 1 + '' : '1';
|
});
|
taskApi.updateMonitorObject(seletedSceneList);
|
return subtaskApi.putSubtasks(subtasks);
|
},
|
|
/**
|
* 根据多选下拉框的选项值,返回任务执行人对象
|
* @returns
|
*/
|
getExecutors(data, executorOptions) {
|
const ids = [];
|
const uNames = [];
|
const rNames = [];
|
executorOptions.forEach((e) => {
|
const index = data.indexOf(e.value);
|
if (index != -1) {
|
ids.push(e.data.id);
|
uNames.push(e.data.userName);
|
rNames.push(e.data.realName);
|
}
|
});
|
return {
|
ids: ids.join('#'),
|
uName: uNames.join('#'),
|
rName: rNames.join('#')
|
};
|
}
|
};
|