riku
5 天以前 f19e5267cc23b1c714dc746239864f33ed715dd9
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
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('#')
    };
  }
};