riku
2024-11-13 94ada33570ee530dea1d7567671bbb804a75458e
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
<template>
  <BaseContentLayout>
    <template #header>
      <!-- <FYSearchBar @search="search">
        <template #options>
          <FYOptionLocation
            :allOption="true"
            :level="3"
            :checkStrictly="false"
            v-model:value="formSearch.locations"
          ></FYOptionLocation>
        </template>
      </FYSearchBar> -->
    </template>
    <template #aside>
      <SideList
        :items="tasks"
        :loading="sideLoading"
        @item-click="chooseTask"
      ></SideList>
    </template>
    <template #main>
      <ToolBar
        :title="curTask.title"
        :descriptions="taskStatus"
        :buttons="buttons"
        :loading="mainLoading"
      ></ToolBar>
      <el-scrollbar
        v-if="curMonitorObjList.length > 0"
        class="el-scrollbar"
        v-loading="mainLoading"
      >
        <el-row justify="space-between">
          <!-- <div><el-text>监管计划</el-text></div>
          <el-button type="warning" size="small" @click="editPlan"
            >计划调整</el-button
          > -->
          <el-tabs model-value="first">
            <el-tab-pane label="监管计划" name="first">
              <el-row>
                <el-col :span="curSubTaskList ? 16 : 24">
                  <CompMonitorPlan
                    ref="planRef"
                    :task="curTask.data"
                    @date-change="onDateChange"
                  ></CompMonitorPlan>
                </el-col>
                <el-col v-if="curSubTaskList" :span="8">
                  <CompSubTaskList
                    create
                    v-model="curSubTaskList"
                    :loading="subTaskLoading"
                    height="56vh"
                    @add="subTaskDrawer = true"
                    @submit="handleSubtaskSubmit"
                  ></CompSubTaskList>
                </el-col>
              </el-row>
            </el-tab-pane>
            <!-- <el-tab-pane label="监管地图" name="second">
              <CompTaskMap></CompTaskMap>
            </el-tab-pane> -->
          </el-tabs>
        </el-row>
        <el-divider></el-divider>
        <el-row justify="space-between">
          <div><el-text>监管场景</el-text></div>
          <el-button type="warning" size="small" @click="editTask"
            >场景调整</el-button
          >
        </el-row>
        <CompMonitorObj :data="curMonitorObjList"></CompMonitorObj>
      </el-scrollbar>
      <div v-else>
        <el-empty description="暂无记录" v-loading="mainLoading" />
        <el-row v-if="!mainLoading" justify="center">
          <el-button
            type="primary"
            size="default"
            @click="navToTaskCreate(curTask.data)"
            >添加监管场景</el-button
          >
        </el-row>
      </div>
    </template>
  </BaseContentLayout>
  <el-drawer
    v-model="subTaskDrawer"
    title="日计划管理"
    direction="btt"
    size="96%"
    destroy-on-close
  >
    <CompDayTask
      :day-task="curDayTask"
      :mObjList="curMonitorObjList"
      @submit="handleSubtaskSubmit"
    ></CompDayTask>
  </el-drawer>
  <el-dialog
    v-model="topTaskAddVisible"
    width="600"
    title="一键创建总任务"
    destroy-on-close
    :close-on-click-modal="false"
    :close-on-press-escape="false"
    :show-close="false"
  >
    <CompTaskEdit
      @submit="navToTaskCreate"
      @cancel="topTaskAddVisible = false"
    ></CompTaskEdit>
  </el-dialog>
</template>
 
<script>
import taskApi from '@/api/fysp/taskApi';
import CompMonitorObj from './components/CompMonitorObj.vue';
import CompMonitorPlan from './components/CompMonitorPlan.vue';
import CompDayTask from './components/CompDayTask.vue';
import CompTaskMap from './components/CompTaskMap.vue';
import CompTaskEdit from './components/CompTaskEdit.vue';
import CompSubTaskList from './components/CompSubTaskList.vue';
export default {
  beforeRouteEnter(to, from, next) {
    // 在渲染该组件的对应路由被验证前调用
    // 不能获取组件实例 `this` !
    // 因为当守卫执行时,组件实例还没被创建!
    next((vm) => {
      if (from.name == 'monitorObjEdit' && vm.task) {
        vm.chooseTask(vm.task);
      } else if (from.name == 'monitorTaskCreate') {
        vm.search();
      }
    });
  },
  components: {
    CompMonitorObj,
    CompMonitorPlan,
    CompDayTask,
    CompTaskMap,
    CompTaskEdit,
    CompSubTaskList
  },
  data() {
    return {
      formSearch: {
        _locations: {},
        searchText: '',
        _scenetype: {},
        online: {}
      },
      // 左侧菜单栏加载状态
      sideLoading: false,
      // 右侧内容栏加载状态
      mainLoading: false,
      // 任务列表
      tasks: [],
      // 当前任务的监管对象
      curMonitorObjList: [],
      // 当前任务的展示中的监管对象
      showMonitorObjList: [],
      //当前选中的任务
      curTask: {},
      //操作按钮
      buttons: [
        {
          name: '一键创建总任务',
          color: 'success',
          click: () => {
            this.topTaskAddVisible = true;
          }
        }
        // {
        //   name: '场景调整',
        //   color: 'warning'
        // }
      ],
      // 子任务编辑弹出框
      subTaskDrawer: false,
      // 当前选择的日任务
      curDayTask: {},
      // 当前选择的日任务下的子任务
      curSubTaskList: undefined,
      subTaskLoading: false,
      // 总任务新增弹出框
      topTaskAddVisible: false
    };
  },
  computed: {
    // 总任务状态统计
    taskStatus() {
      return [
        { name: '场景数', value: 100 },
        { name: '未巡查', value: 0 },
        { name: '已巡查', value: 0 }
      ];
    }
  },
  methods: {
    search(formSearch) {
      this.sideLoading = true;
      this.mainLoading = true;
      this.curMonitorObjList = [];
      this.curTask = {};
      taskApi.getTopTask().then((res) => {
        const list = res.map((r) => {
          const t = this.getTaskType(r);
          return {
            type: t,
            title: r.name,
            categoly: this.$fm.formatYM(r.starttime),
            data: r
          };
        });
        this.tasks = list;
        if (list.length == 0) {
          this.sideLoading = false;
          this.mainLoading = false;
        }
      });
    },
    //获取任务的完成情况
    getTaskType(s) {
      let type = 0;
      switch (s.runingstatus) {
        case '未执行':
          type = 0;
          break;
        case '正在执行':
          type = 1;
          break;
        case '已结束':
          type = 2;
          break;
        default:
          type = 0;
          break;
      }
      return type;
    },
    chooseTask(task) {
      this.task = task;
      this.sideLoading = false;
      this.mainLoading = true;
      this.curSubTaskList = undefined;
      this.curTask = task;
      taskApi
        .fetchMonitorObjectVersion(task.data.tguid)
        .then((res) => {
          this.curMonitorObjList = res;
        })
        .finally(() => {
          this.mainLoading = false;
        });
    },
    editTask() {
      this.$router.push({
        name: 'monitorObjEdit',
        query: {
          data: encodeURIComponent(JSON.stringify(this.curMonitorObjList)),
          task: encodeURIComponent(JSON.stringify(this.curTask.data))
        }
      });
    },
    editPlan() {
      this.$router.push({
        name: 'monitorPlanEdit',
        query: {
          data: encodeURIComponent(JSON.stringify(this.curMonitorObjList)),
          task: encodeURIComponent(JSON.stringify(this.curTask.data))
        }
      });
    },
    onDateChange(dayTask) {
      if (dayTask) {
        this.subTaskLoading = true;
        // this.subTaskDrawer = true;
        this.curDayTask = dayTask;
        taskApi
          .fetchSubtaskByDayTask(dayTask.guid)
          .then((res) => {
            this.curSubTaskList = res;
          })
          .finally(() => (this.subTaskLoading = false));
      } else {
        this.curSubTaskList = [];
      }
    },
    navToTaskCreate(value) {
      this.topTaskAddVisible = false;
      this.$router.push({
        name: 'monitorTaskCreate',
        query: {
          task: encodeURIComponent(JSON.stringify(value))
        }
      });
    },
    handleSubtaskSubmit() {
      this.subTaskLoading = true;
      this.$refs.planRef
        .fetchDayTasks()
        .finally(() => (this.subTaskLoading = false));
    }
  },
  mounted() {
    this.search();
  }
};
</script>
 
<style scoped>
.select-box {
  /* border: 1px solid var(--el-border-color);
  border-radius: var(--el-border-radius-base);
  padding: 0 8px; */
}
 
.el-scrollbar {
  height: calc((100vh - 60px - 20px * 2 - var(--height-toolbar)));
}
</style>