Browse Source

安全检查下发修改为统一下发

liuzhuo 3 days ago
parent
commit
f1a996b85e

+ 3
- 2
src/view/dati/examCheck/index.vue View File

@@ -152,8 +152,8 @@ const goaddPeo = async (item) => {
152 152
   currentExamItem.value = item;
153 153
 
154 154
   //
155
-  const baseUrl = window.location.origin + '/sgsafeh5/fcbkdatistart';
156
-
155
+  const baseUrl = import.meta.env.VITE_BASE_API + '/sgsafeh5/fcbkdatistart';
156
+console.log(baseUrl);
157 157
   const url = new URL(baseUrl);
158 158
   url.searchParams.set('examId', item.id);           // 考试ID
159 159
   url.searchParams.set('testRole', item.testRole); //规则id
@@ -642,6 +642,7 @@ const bm = (val) => {
642 642
 
643 643
 //提交审批流程
644 644
 import { workflowSubmit, workflowCancel } from '@/tools/workflow.js';
645
+import { log } from 'console';
645 646
 
646 647
 const flowId = ref('');
647 648
 flowId.value = 'hazardManagementFlowId';

+ 97
- 0
src/view/safeCheck/checkDispatch.js View File

@@ -0,0 +1,97 @@
1
+import { toRaw } from 'vue'
2
+
3
+/** 检查任务下发隐患工作流(对齐 Web sgexp) */
4
+export const FLOW_ID_XF = 'copy_hazardImmediatelyCM'
5
+
6
+export async function fetchTaskResultItems(axios, taskId, userId) {
7
+  const param = {
8
+    page: 1,
9
+    rows: 5000,
10
+    params: JSON.stringify({
11
+      taskId,
12
+      userId,
13
+    }),
14
+  }
15
+  const response = await axios.get('sgsafe/CheckResultItem/query', param)
16
+  if (response.data.code !== 0) {
17
+    throw new Error(response.data.msg || '查询检查项失败')
18
+  }
19
+  return response.data.data.records || []
20
+}
21
+
22
+export function validateBatchXF(items) {
23
+  const unfinished = items.filter((item) => !item.ifFlag || item.ifFlag === '')
24
+  if (unfinished.length > 0) {
25
+    return {
26
+      ok: false,
27
+      message: `还有 ${unfinished.length} 项未选择是否符合(请先在检查记录中填写并暂存),无法一键下发`,
28
+    }
29
+  }
30
+  const notSavedNo = items.filter((item) => item.ifFlag === '否' && item.state === '未知')
31
+  if (notSavedNo.length > 0) {
32
+    return {
33
+      ok: false,
34
+      message: `有 ${notSavedNo.length} 条不符合项未暂存,请先保存后再一键下发`,
35
+    }
36
+  }
37
+  const pending = items.filter((item) => item.ifFlag === '否' && item.state === '待下发')
38
+  if (pending.length === 0) {
39
+    return {
40
+      ok: false,
41
+      message: '没有待下发的不符合项',
42
+    }
43
+  }
44
+  return { ok: true, pending }
45
+}
46
+
47
+export async function resolveHdConfirmVar(axios, hdConfirmUserCode) {
48
+  const r = await axios.post('sgsafe/Hiddendanger/qqId', { params: hdConfirmUserCode })
49
+  if (r.data.code === 0 && r.data.data) {
50
+    return 'U_' + String(r.data.data).trim()
51
+  }
52
+  return ''
53
+}
54
+
55
+export async function dispatchSingleXF(
56
+  axios,
57
+  workflowSubmit,
58
+  item,
59
+  hdConfirmUserCode,
60
+  hdConfirmUserDesc,
61
+  hdConfirmVar,
62
+) {
63
+  const submitData = {
64
+    ...item,
65
+    hdConfirm: hdConfirmUserCode,
66
+    hdConfirmDesc: hdConfirmUserDesc,
67
+  }
68
+  const response = await axios.post('sgsafe/CheckResultItem/saveXF', {
69
+    json: JSON.stringify(submitData),
70
+  })
71
+  if (response.data.code !== 0) {
72
+    throw new Error(response.data.msg || '下发失败')
73
+  }
74
+  const hiddendangerId = response.data.data?.hiddendangerId
75
+  if (!hiddendangerId) {
76
+    throw new Error('未获取到隐患id')
77
+  }
78
+  const variables = { id: hiddendangerId, hdConfirm: hdConfirmVar }
79
+  const result = await workflowSubmit(
80
+    FLOW_ID_XF,
81
+    '隐患排查治理',
82
+    '初始化提交',
83
+    JSON.stringify(toRaw(variables)),
84
+    undefined,
85
+    undefined,
86
+  )
87
+  if (result.status !== 'success') {
88
+    throw new Error(result.msg || '提交审批失败')
89
+  }
90
+  await axios.post('sgsafe/Hiddendanger/saveProcessInfo', {
91
+    json: JSON.stringify({
92
+      id: hiddendangerId,
93
+      workId: result.workId,
94
+      trackId: result.trackId,
95
+    }),
96
+  })
97
+}

+ 215
- 47
src/view/safeCheck/safeCheckTask.vue View File

@@ -24,14 +24,19 @@
24 24
               </template>
25 25
               <template #label>
26 26
                 <div class="label-content">
27
-<!--                  <div>检查类型:{{ item.checkType }}</div>-->
28 27
                   <div>受检单位:{{ item.checkedDept }}</div>
29
-<!--                  <div>检查事由:{{ item.checkThing }}</div>-->
30
-<!--                  <div>检查人:{{ item.checkPersonName }}</div>-->
31 28
                   <div>检查时间:{{ item.checkTime }}</div>
32
-<!--                  <div>备注:{{ item.notes }}</div>-->
33 29
                 </div>
34 30
               </template>
31
+              <template #right-icon>
32
+                <van-button
33
+                  type="warning"
34
+                  size="mini"
35
+                  @click.stop="handleBatchXF(item)"
36
+                >
37
+                  一键下发
38
+                </van-button>
39
+              </template>
35 40
             </van-cell>
36 41
           </div>
37 42
       </van-list>
@@ -48,12 +53,69 @@
48 53
       <div>确定要删除该项目吗?</div>
49 54
     </van-dialog>
50 55
 
56
+    <!-- 一键下发弹窗 -->
57
+    <van-dialog
58
+      v-model:show="dialogBatchXFVisible"
59
+      title="一键下发隐患"
60
+      :show-confirm-button="false"
61
+      :close-on-click-overlay="false"
62
+    >
63
+      <div class="batch-xf-body">
64
+        <van-field
65
+          readonly
66
+          label="待下发"
67
+          :model-value="`${batchPendingItems.length} 条不符合项`"
68
+        />
69
+        <van-field
70
+          readonly
71
+          is-link
72
+          required
73
+          label="隐患确认人"
74
+          :model-value="xfConfirmDisplay"
75
+          placeholder="请选择隐患确认人"
76
+          @click="openXfConfirmPicker"
77
+        />
78
+        <div class="batch-xf-actions">
79
+          <van-button
80
+            block
81
+            type="primary"
82
+            :loading="batchSubmitting"
83
+            @click="confirmBatchXF"
84
+          >
85
+            确定
86
+          </van-button>
87
+          <van-button
88
+            block
89
+            plain
90
+            :disabled="batchSubmitting"
91
+            @click="cancelBatchXF"
92
+          >
93
+            取消
94
+          </van-button>
95
+        </div>
96
+      </div>
97
+    </van-dialog>
98
+
99
+    <OrganizationalWithLeafUserOne
100
+      ref="PopupDepartmentUserRefXfConfirm"
101
+      :main-key="xfConfirmSessionKey"
102
+      @receive-from-child="getXfConfirmUser"
103
+    />
51 104
   </div>
52 105
 </template>
53 106
 
54 107
 <script setup>
55
-import { ref, reactive, onMounted, getCurrentInstance, nextTick, toRaw } from 'vue';
56
-import { Dialog, showDialog, showSuccessToast, showToast, Toast } from 'vant';
108
+import { ref, computed, getCurrentInstance } from 'vue';
109
+import { showConfirmDialog, showSuccessToast, showToast } from 'vant';
110
+import OrganizationalWithLeafUserOne from '@/components/OrganizationalWithLeafUserOne.vue';
111
+import { workflowSubmit } from '@/tools/workflow.js';
112
+import { guid } from '@/utils/commonMethod.js';
113
+import {
114
+  dispatchSingleXF,
115
+  fetchTaskResultItems,
116
+  resolveHdConfirmVar,
117
+  validateBatchXF,
118
+} from '@/view/safeCheck/checkDispatch.js';
57 119
 
58 120
 const { proxy } = getCurrentInstance();
59 121
 
@@ -66,42 +128,19 @@ const headers = ref({
66 128
   dept: JSON.parse(localStorage.getItem('dept'))[0].deptCode
67 129
 });
68 130
 
69
-
70
-function formatDate(date, format) {
71
-  const year = date.getFullYear();
72
-  const month = date.getMonth() + 1;
73
-  const day = date.getDate();
74
-  const hours = date.getHours();
75
-  const minutes = date.getMinutes();
76
-  const seconds = date.getSeconds();
77
-
78
-  return format
79
-    .replace('yyyy', year)
80
-    .replace('MM', month.toString().padStart(2, '0'))
81
-    .replace('dd', day.toString().padStart(2, '0'))
82
-    .replace('HH', hours.toString().padStart(2, '0'))
83
-    .replace('mm', minutes.toString().padStart(2, '0'))
84
-    .replace('ss', seconds.toString().padStart(2, '0'));
85
-}
86
-
87 131
 const tableData = ref([]);
88
-const selectedRows = ref([]);
89 132
 const deleteDialogVisible = ref(false);
90 133
 const currentDeleteItem = ref([]);
91
-const date = ref(null);
92 134
 
93 135
 const kz = ref(true);
94 136
 const handAdd = async () => {
95
-  // 将表单数据置空
96 137
   kz.value = false;
97 138
   resetForma();
98
-
99 139
   proxy.$router.push({
100 140
     path: '/safeCheck/safeCheckTaskEdit'
101 141
   });
102
-
103 142
 };
104
-// 定义表单数据
143
+
105 144
 const form = ref({
106 145
   taskTemplateId: '',
107 146
   checkType: '',
@@ -179,7 +218,7 @@ const getTableData = async () => {
179 218
     });
180 219
   } else {
181 220
     showToast({
182
-      type: 'error',
221
+      type: 'fail',
183 222
       message: '操作失败!' + response.data.msg
184 223
     });
185 224
   }
@@ -201,7 +240,6 @@ const onLoad = async () => {
201 240
     if (pageSize.value * currentPage.value < totalRows.value) {
202 241
       resultData.value = [...resultData.value, ...tableData.value];
203 242
       currentPage.value++;
204
-
205 243
     } else {
206 244
       resultData.value = [...resultData.value, ...tableData.value];
207 245
       isFinished.value = true;
@@ -213,7 +251,7 @@ const onLoad = async () => {
213 251
     isLoading.value = false;
214 252
   }
215 253
 };
216
-/* 通用方法: 重置list数据 */
254
+
217 255
 const basicReset = () => {
218 256
   isFinished.value = false;
219 257
   isLoading.value = true;
@@ -221,11 +259,6 @@ const basicReset = () => {
221 259
   resultData.value = [];
222 260
 };
223 261
 
224
-const handleDelete = (item) => {
225
-  currentDeleteItem.value.push(item);
226
-  deleteDialogVisible.value = true;
227
-};
228
-
229 262
 const confirmDelete = () => {
230 263
   var url = '/sgsafe/CheckTask/remove';
231 264
   var param = {
@@ -260,6 +293,130 @@ const edits = (row) => {
260 293
   });
261 294
 };
262 295
 
296
+/** 一键下发 */
297
+const dialogBatchXFVisible = ref(false);
298
+const batchPendingItems = ref([]);
299
+const batchSubmitting = ref(false);
300
+const xfConfirmUserCode = ref('');
301
+const xfConfirmUserDesc = ref('');
302
+const xfConfirmSessionKey = ref(guid());
303
+const PopupDepartmentUserRefXfConfirm = ref(null);
304
+
305
+const xfConfirmDisplay = computed(() => {
306
+  if (xfConfirmUserDesc.value && xfConfirmUserCode.value) {
307
+    return `${xfConfirmUserDesc.value}(${xfConfirmUserCode.value})`;
308
+  }
309
+  return xfConfirmUserDesc.value || xfConfirmUserCode.value || '';
310
+});
311
+
312
+const resetXfConfirm = () => {
313
+  xfConfirmUserCode.value = '';
314
+  xfConfirmUserDesc.value = '';
315
+};
316
+
317
+const openXfConfirmPicker = () => {
318
+  PopupDepartmentUserRefXfConfirm.value?.open();
319
+};
320
+
321
+const getXfConfirmUser = (item) => {
322
+  if (!item?.user?.userCode) {
323
+    showToast({ type: 'fail', message: '请选择有效的隐患确认人' });
324
+    return;
325
+  }
326
+  xfConfirmUserCode.value = item.user.userCode;
327
+  xfConfirmUserDesc.value = item.user.userDesc || item.user.userName || '';
328
+};
329
+
330
+const handleBatchXF = async (row) => {
331
+  try {
332
+    const items = await fetchTaskResultItems(proxy.$axios, row.id, headers.value.userId);
333
+    if (!items.length) {
334
+      showToast({ type: 'fail', message: '该任务下没有检查项' });
335
+      return;
336
+    }
337
+    const validation = validateBatchXF(items);
338
+    if (!validation.ok) {
339
+      showToast({ type: 'fail', message: validation.message });
340
+      return;
341
+    }
342
+    batchPendingItems.value = validation.pending;
343
+    xfConfirmSessionKey.value = guid();
344
+    resetXfConfirm();
345
+    dialogBatchXFVisible.value = true;
346
+  } catch (error) {
347
+    showToast({
348
+      type: 'fail',
349
+      message: '加载检查项失败:' + (error.message || '未知错误'),
350
+    });
351
+  }
352
+};
353
+
354
+const confirmBatchXF = async () => {
355
+  if (!xfConfirmUserCode.value) {
356
+    showToast({ type: 'fail', message: '请选择隐患确认人' });
357
+    return;
358
+  }
359
+  const items = batchPendingItems.value;
360
+  if (!items.length) {
361
+    showToast({ type: 'fail', message: '没有待下发的不符合项' });
362
+    return;
363
+  }
364
+  try {
365
+    await showConfirmDialog({
366
+      title: '一键下发',
367
+      message: `将为该任务下发 ${items.length} 条不符合项,隐患确认人:${xfConfirmDisplay.value},确定继续吗?`,
368
+    });
369
+  } catch {
370
+    return;
371
+  }
372
+
373
+  const hdConfirmVar = await resolveHdConfirmVar(proxy.$axios, xfConfirmUserCode.value);
374
+  if (!hdConfirmVar) {
375
+    showToast({ type: 'fail', message: '未能解析隐患确认人,无法提交审批' });
376
+    return;
377
+  }
378
+
379
+  batchSubmitting.value = true;
380
+  let successCount = 0;
381
+  let failCount = 0;
382
+  for (const item of items) {
383
+    try {
384
+      await dispatchSingleXF(
385
+        proxy.$axios,
386
+        workflowSubmit,
387
+        item,
388
+        xfConfirmUserCode.value,
389
+        xfConfirmUserDesc.value,
390
+        hdConfirmVar,
391
+      );
392
+      successCount++;
393
+    } catch (error) {
394
+      failCount++;
395
+      console.error('单条下发失败:', item.id, error);
396
+    }
397
+  }
398
+  batchSubmitting.value = false;
399
+  dialogBatchXFVisible.value = false;
400
+  resetXfConfirm();
401
+
402
+  if (failCount === 0) {
403
+    showSuccessToast(`一键下发完成,共 ${successCount} 条`);
404
+  } else {
405
+    showToast({
406
+      type: 'fail',
407
+      message: `下发结束:成功 ${successCount} 条,失败 ${failCount} 条`,
408
+    });
409
+  }
410
+};
411
+
412
+const cancelBatchXF = () => {
413
+  if (batchSubmitting.value) {
414
+    return;
415
+  }
416
+  dialogBatchXFVisible.value = false;
417
+  resetXfConfirm();
418
+};
419
+
263 420
 </script>
264 421
 
265 422
 <style scoped>
@@ -284,15 +441,26 @@ const edits = (row) => {
284 441
 }
285 442
 
286 443
 .cell-title {
287
-  display: -webkit-box;                     /* 旧版弹性盒子模型 */
288
-  -webkit-box-orient: vertical;             /* 内容垂直排列 */
289
-  -webkit-line-clamp: 2;                    /* 限制显示行数 */
290
-  overflow: hidden;                         /* 超出隐藏 */
291
-  text-overflow: ellipsis;                  /* 省略号 */
292
-  line-height: 1.5;                         /* 可选:设置行高 */
293
-  max-height: calc(1.5em * 2);              /* 可选:根据行高限制最大高度 */
444
+  display: -webkit-box;
445
+  -webkit-box-orient: vertical;
446
+  -webkit-line-clamp: 2;
447
+  overflow: hidden;
448
+  text-overflow: ellipsis;
449
+  line-height: 1.5;
450
+  max-height: calc(1.5em * 2);
294 451
   font-size: 16px;
295 452
   font-weight: bold;
296
-  color: #333;/* 字号 */
453
+  color: #333;
454
+}
455
+
456
+.batch-xf-body {
457
+  padding: 8px 0 4px;
458
+}
459
+
460
+.batch-xf-actions {
461
+  display: flex;
462
+  flex-direction: column;
463
+  gap: 8px;
464
+  padding: 12px 16px 4px;
297 465
 }
298
-</style>
466
+</style>

+ 21
- 585
src/view/safeCheck/safeCheck_item/index.vue View File

@@ -25,25 +25,11 @@
25 25
               </template>
26 26
               <template #label>
27 27
                 <div class="label-content">
28
-<!--                  <div>检查类型:{{ item.checkType }}</div>-->
29
-<!--                  <div>受检单位:{{ item.checkedDept }}</div>-->
30
-<!--                  <div>类别:{{ item.type }}</div>-->
31
-<!--                  <div>检查人:{{ item.checkPersonName }}</div>-->
32
-<!--                  <div>检查时间:{{ item.checkTime }}</div>-->
33 28
                   <div>项目:{{ item.item }}</div>
34 29
                   <div>状态:{{ item.state }}</div>
35 30
                 </div>
36 31
               </template>
37
-              <template #right-icon>
38
-                <van-button
39
-                  v-if="item.state === '待下发'"
40
-                  type="success"
41
-                  size="mini"
42
-                  @click.stop="handleSubmitXF(item)"
43
-                >
44
-                  下发
45
-                </van-button>
46
-              </template>
32
+              <!-- 【已废弃】单条下发改为一键下发(safeCheckTask.vue 任务列表) -->
47 33
             </van-cell>
48 34
         </div>
49 35
       </van-list>
@@ -60,100 +46,13 @@
60 46
       <div>确定要删除该项目吗?</div>
61 47
     </van-dialog>
62 48
 
63
-    <!-- 下发隐患弹窗 -->
64
-    <van-dialog
65
-      v-model:show="submitXFDialogVisible"
66
-      title="下发隐患"
67
-      :show-cancel-button="true"
68
-      :close-on-click-overlay="false"
69
-      @confirm="confirmSubmitXF"
70
-      @cancel="cancelSubmitXF"
71
-    >
72
-      <van-form ref="submitXFFormRef" @submit="confirmSubmitXF">
73
-        <van-field
74
-          v-model="submitXFForm.repairSuggest"
75
-          name="repairSuggest"
76
-          label="整改建议"
77
-          type="textarea"
78
-          placeholder="请输入整改建议"
79
-          rows="4"
80
-          :rules="[{ required: true, message: '请输入整改建议' }]"
81
-        />
82
-        <van-field
83
-          v-model="submitXFForm.repairDdlText"
84
-          name="repairDdl"
85
-          label="整改时限"
86
-          placeholder="请选择整改时限"
87
-          readonly
88
-          is-link
89
-          @click="showDateTimePicker = true"
90
-          :rules="[{ required: true, message: '请选择整改时限' }]"
91
-        />
92
-        <van-field
93
-          readonly
94
-          :model-value="xfRepairDisplaySummary"
95
-          :title="xfRepairDisplaySummary"
96
-          label="整改责任人"
97
-          placeholder=""
98
-          is-link
99
-          @click="openXfRepairPicker"
100
-        />
101
-        <div style="padding: 0 16px 12px;">
102
-          <van-button size="small" type="primary" plain block @click="resetXfRepairToDefault">恢复系统默认</van-button>
103
-        </div>
104
-      </van-form>
105
-    </van-dialog>
106
-
107
-    <!-- 日期时间选择器 -->
108
-    <van-popup v-model:show="showDateTimePicker" position="bottom" round style="max-height: 50vh;">
109
-      <van-date-picker
110
-        v-if="!dateOrTime"
111
-        v-model="currentDate"
112
-        title="选择日期"
113
-        :min-date="minDate"
114
-        @confirm="onDateConfirm"
115
-        @cancel="cancelDatePicker"
116
-      >
117
-        <template #confirm>
118
-          <van-button type="primary" @click="onDateConfirm">下一步</van-button>
119
-        </template>
120
-        <template #cancel>
121
-          <van-button type="danger" @click="cancelDatePicker">取消</van-button>
122
-        </template>
123
-      </van-date-picker>
124
-
125
-      <van-time-picker
126
-        v-if="dateOrTime"
127
-        v-model="currentTime"
128
-        title="选择时间"
129
-        :columns-type="['hour', 'minute', 'second']"
130
-        @confirm="onConfirmDateTime"
131
-        @cancel="cancelTimePicker"
132
-      >
133
-        <template #confirm>
134
-          <van-button type="primary" @click="onConfirmDateTime">确定</van-button>
135
-        </template>
136
-        <template #cancel>
137
-          <van-button type="danger" @click="cancelTimePicker">取消</van-button>
138
-        </template>
139
-      </van-time-picker>
140
-    </van-popup>
141
-
142
-    <OrganizationalWithLeafUser
143
-        :key="xfRepairSessionKey"
144
-        ref="PopupDepartmentLeaderNameRefXfRepair"
145
-        :main-key="xfRepairSessionKey"
146
-        @receive-from-child="handleTableDataUpdateXfRepair"
147
-    />
148
-
49
+    <!-- 【已废弃】原单条下发弹窗(hazardImmediatelyCM + 整改建议/时限/责任人),已改任务列表一键下发 copy_hazardImmediatelyCM + hdConfirm -->
149 50
   </div>
150 51
 </template>
151 52
 
152 53
 <script setup>
153
-import { ref, computed, onMounted, getCurrentInstance, toRaw } from 'vue';
154
-import { showConfirmDialog, showSuccessToast, showToast } from 'vant';
155
-import OrganizationalWithLeafUser from '@/components/OrganizationalWithLeafUser.vue';
156
-import { workflowSubmit } from '@/tools/workflow.js';
54
+import { ref, onMounted, getCurrentInstance } from 'vue';
55
+import { showToast } from 'vant';
157 56
 
158 57
 const { proxy } = getCurrentInstance();
159 58
 
@@ -173,46 +72,23 @@ const query2 = ref({
173 72
   checkContent: '',
174 73
 })
175 74
 
176
-onMounted(()=>{
75
+onMounted(() => {
177 76
   
178 77
 })
179 78
 
180
-
181
-
182
-function formatDate(date, format) {
183
-  const year = date.getFullYear();
184
-  const month = date.getMonth() + 1;
185
-  const day = date.getDate();
186
-  const hours = date.getHours();
187
-  const minutes = date.getMinutes();
188
-  const seconds = date.getSeconds();
189
-
190
-  return format
191
-    .replace('yyyy', year)
192
-    .replace('MM', month.toString().padStart(2, '0'))
193
-    .replace('dd', day.toString().padStart(2, '0'))
194
-    .replace('HH', hours.toString().padStart(2, '0'))
195
-    .replace('mm', minutes.toString().padStart(2, '0'))
196
-    .replace('ss', seconds.toString().padStart(2, '0'));
197
-}
198
-
199 79
 const tableData = ref([]);
200
-const selectedRows = ref([]);
201 80
 const deleteDialogVisible = ref(false);
202 81
 const currentDeleteItem = ref([]);
203
-const date = ref(null);
204 82
 
205 83
 const kz = ref(true);
206 84
 const handAdd = async () => {
207
-  // 将表单数据置空
208 85
   kz.value = false;
209 86
   resetForma();
210
-  
211 87
   proxy.$router.push({
212 88
     path: '/safeCheck/safeCheckTaskEdit',
213 89
   })
214 90
 };
215
-// 定义表单数据
91
+
216 92
 const form = ref({
217 93
   taskTemplateId: '',
218 94
   checkType: '',
@@ -243,19 +119,10 @@ const currentPage = ref(1);
243 119
 const pageSize = ref(10);
244 120
 const totalRows = ref(0);
245 121
 const resultData = ref([]);
246
-const query = ref({
247
-  taskTemplateId: '',
248
-  checkedDept: '',
249
-  checkPerson:'',
250
-  checkedDeptCode: '',
251
-  checkThing:'',
252
-  checkPersonName:'',
253
-})
254 122
 
255 123
 const getTableData = async () => {
256 124
   query2.value.userId = headers.value.userId
257 125
   query2.value.taskId = proxy.$route.query.id
258
-  console.log('夸瑞2',query2.value)
259 126
   const url = 'sgsafe/CheckResultItem/query';
260 127
   const param = {
261 128
     page: currentPage.value,
@@ -293,7 +160,7 @@ const getTableData = async () => {
293 160
     });
294 161
   } else {
295 162
     showToast({
296
-      type: 'error',
163
+      type: 'fail',
297 164
       message: '操作失败!' + response.data.msg
298 165
     });
299 166
   }
@@ -311,13 +178,12 @@ const onLoad = async () => {
311 178
     isRefreshing.value = false;
312 179
   }
313 180
   try {
314
-    await  getTableData();
181
+    await getTableData();
315 182
     if (pageSize.value * currentPage.value < totalRows.value) {
316
-      resultData.value = [...resultData.value,...tableData.value ]
183
+      resultData.value = [...resultData.value, ...tableData.value]
317 184
       currentPage.value++;
318
-      
319 185
     } else {
320
-      resultData.value = [...resultData.value,...tableData.value ]
186
+      resultData.value = [...resultData.value, ...tableData.value]
321 187
       isFinished.value = true;
322 188
     }
323 189
   } catch (error) {
@@ -327,7 +193,7 @@ const onLoad = async () => {
327 193
     isLoading.value = false;
328 194
   }
329 195
 };
330
-/* 通用方法: 重置list数据 */
196
+
331 197
 const basicReset = () => {
332 198
   isFinished.value = false;
333 199
   isLoading.value = true;
@@ -335,11 +201,6 @@ const basicReset = () => {
335 201
   resultData.value = []
336 202
 }
337 203
 
338
-const handleDelete = (item) => {
339
-  currentDeleteItem.value.push(item);
340
-  deleteDialogVisible.value = true;
341
-};
342
-
343 204
 const confirmDelete = () => {
344 205
   var url = '/sgsafe/CheckTask/remove';
345 206
   var param = {
@@ -374,431 +235,6 @@ const edits = (row) => {
374 235
   });
375 236
 };
376 237
 
377
-// 下发隐患相关变量
378
-const submitXFDialogVisible = ref(false);
379
-const submitXFFormRef = ref(null);
380
-const currentSubmitRow = ref(null);
381
-const showDateTimePicker = ref(false);
382
-const minDate = ref(new Date());
383
-const maxDate = ref(new Date(2099, 11, 31));
384
-const dateOrTime = ref(false);
385
-const currentDate = ref();
386
-const currentTime = ref();
387
-
388
-const submitXFForm = ref({
389
-  repairSuggest: '',
390
-  repairDdl: '',
391
-  repairDdlText: ''
392
-});
393
-
394
-const guid = () => {
395
-  function S4() {
396
-    return (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1);
397
-  }
398
-  return S4() + S4() + S4() + S4() + S4() + S4() + S4() + S4();
399
-};
400
-
401
-/** 下发隐患:整改责任人(默认岗位匹配,可选手工) */
402
-const PopupDepartmentLeaderNameRefXfRepair = ref(null);
403
-const xfRepairSessionKey = ref(guid());
404
-const xfRepairUseCustom = ref(false);
405
-const xfRepairUserCodes = ref('');
406
-const xfRepairUserNames = ref('');
407
-const defaultRepairL = ref('');
408
-/** 岗位默认匹配到的用户姓名(由 U_id 列表解析),与 web 端 inspectionTask 一致 */
409
-const defaultRepairUserNamesDisplay = ref('');
410
-const defaultRepairNamesLoading = ref(false);
411
-
412
-function parseRepairLUserIds(repairLStr) {
413
-  if (!repairLStr || !String(repairLStr).trim()) {
414
-    return [];
415
-  }
416
-  return String(repairLStr)
417
-    .split(';')
418
-    .map((x) => x.trim())
419
-    .filter(Boolean)
420
-    .map((x) => (x.startsWith('U_') ? x.slice(2) : x))
421
-    .filter(Boolean);
422
-}
423
-
424
-/** 根据 queryUserIdByPostWithDeptCode 返回的 U_id 串,拉取人员姓名用于展示 */
425
-async function loadDefaultRepairUserDisplayNames(repairLStr) {
426
-  defaultRepairUserNamesDisplay.value = '';
427
-  const ids = parseRepairLUserIds(repairLStr);
428
-  if (!ids.length) {
429
-    return;
430
-  }
431
-  defaultRepairNamesLoading.value = true;
432
-  try {
433
-    const results = await Promise.all(
434
-      ids.map((id) => proxy.$axios.get('framework/SysUser/queryByPK', { id }))
435
-    );
436
-    const names = [];
437
-    for (const res of results) {
438
-      const d = res?.data;
439
-      const ok = d && (String(d.code) === '0' || d.code === 0);
440
-      if (ok && d.data) {
441
-        const label = d.data.userDesc || d.data.userName || '';
442
-        if (label) {
443
-          names.push(label);
444
-        }
445
-      }
446
-    }
447
-    defaultRepairUserNamesDisplay.value = names.join('、');
448
-  } catch (e) {
449
-    console.error('加载默认整改人姓名失败', e);
450
-    defaultRepairUserNamesDisplay.value = '';
451
-  } finally {
452
-    defaultRepairNamesLoading.value = false;
453
-  }
454
-}
455
-
456
-const xfRepairDisplaySummary = computed(() => {
457
-  if (xfRepairUseCustom.value && xfRepairUserNames.value) {
458
-    return xfRepairUserNames.value;
459
-  }
460
-  const s = defaultRepairL.value || '';
461
-  const n = s ? s.split(';').filter(Boolean).length : 0;
462
-  if (defaultRepairNamesLoading.value) {
463
-    return '系统默认:正在加载人员姓名…';
464
-  }
465
-  if (defaultRepairUserNamesDisplay.value) {
466
-    return `系统默认:${defaultRepairUserNamesDisplay.value}`;
467
-  }
468
-  if (n > 0) {
469
-    return '系统默认(已匹配岗位人员,姓名加载失败请关闭重试或点本行「选择」指定责任人)';
470
-  }
471
-  return '系统默认(尚未匹配到岗位人员,可点本行「选择」指定整改人)';
472
-});
473
-
474
-const buildXfRepairSessionUsers = () => {
475
-  if (!xfRepairUseCustom.value || !xfRepairUserCodes.value) {
476
-    return [];
477
-  }
478
-  const codes = xfRepairUserCodes.value.split(',').map((c) => c.trim()).filter(Boolean);
479
-  const descs = xfRepairUserNames.value.split('、');
480
-  return codes.map((userCode, i) => ({
481
-    userCode,
482
-    userDesc: descs[i] != null ? descs[i] : ''
483
-  }));
484
-};
485
-
486
-const openXfRepairPicker = () => {
487
-  sessionStorage.setItem(xfRepairSessionKey.value, JSON.stringify(buildXfRepairSessionUsers()));
488
-  PopupDepartmentLeaderNameRefXfRepair.value?.open();
489
-};
490
-
491
-const handleTableDataUpdateXfRepair = (users) => {
492
-  if (!users || !users.length) {
493
-    resetXfRepairToDefault();
494
-    return;
495
-  }
496
-  const codes = [];
497
-  const descs = [];
498
-  for (const u of users) {
499
-    if (u && u.userCode) {
500
-      codes.push(u.userCode);
501
-      descs.push(u.userDesc || '');
502
-    }
503
-  }
504
-  if (!codes.length) {
505
-    showToast({ type: 'fail', message: '未解析到有效的整改人员' });
506
-    return;
507
-  }
508
-  xfRepairUserCodes.value = codes.join(',');
509
-  xfRepairUserNames.value = descs.join('、');
510
-  xfRepairUseCustom.value = true;
511
-};
512
-
513
-const resetXfRepairToDefault = () => {
514
-  xfRepairUseCustom.value = false;
515
-  xfRepairUserCodes.value = '';
516
-  xfRepairUserNames.value = '';
517
-  defaultRepairUserNamesDisplay.value = '';
518
-  defaultRepairNamesLoading.value = false;
519
-  if (defaultRepairL.value) {
520
-    void loadDefaultRepairUserDisplayNames(defaultRepairL.value);
521
-  }
522
-};
523
-
524
-// 打开下发弹窗
525
-const handleSubmitXF = (row) => {
526
-  currentSubmitRow.value = row;
527
-  xfRepairSessionKey.value = guid();
528
-  defaultRepairL.value = '';
529
-  defaultRepairUserNamesDisplay.value = '';
530
-  defaultRepairNamesLoading.value = false;
531
-  resetXfRepairToDefault();
532
-  const repairDeptCode =
533
-    row.checkedDeptCode || query2.value?.checkedDeptCode || '';
534
-  if (repairDeptCode) {
535
-    proxy.$axios
536
-      .get('/sgsafe/Hiddendanger/queryUserIdByPostWithDeptCode', { deptCode: repairDeptCode })
537
-      .then((r) => {
538
-        if (r.data.code === 0 && r.data.data) {
539
-          defaultRepairL.value = r.data.data;
540
-          void loadDefaultRepairUserDisplayNames(r.data.data);
541
-        }
542
-      })
543
-      .catch(() => {});
544
-  }
545
-  // 重置表单
546
-  submitXFForm.value = {
547
-    repairSuggest: '',
548
-    repairDdl: '',
549
-    repairDdlText: ''
550
-  };
551
-  dateOrTime.value = false;
552
-  // 初始化日期和时间
553
-  const now = new Date();
554
-  currentDate.value = [now.getFullYear(), now.getMonth() + 1, now.getDate()];
555
-  currentTime.value = [
556
-    String(now.getHours()).padStart(2, '0'),
557
-    String(now.getMinutes()).padStart(2, '0'),
558
-    String(now.getSeconds()).padStart(2, '0')
559
-  ];
560
-  submitXFDialogVisible.value = true;
561
-};
562
-
563
-// 日期选择确认
564
-const onDateConfirm = () => {
565
-  dateOrTime.value = true;
566
-};
567
-
568
-// 取消日期选择
569
-const cancelDatePicker = () => {
570
-  showDateTimePicker.value = false;
571
-  dateOrTime.value = false;
572
-};
573
-
574
-// 取消时间选择
575
-const cancelTimePicker = () => {
576
-  showDateTimePicker.value = false;
577
-  dateOrTime.value = false;
578
-};
579
-
580
-// 确认日期时间选择
581
-const onConfirmDateTime = () => {
582
-  const year = currentDate.value[0];
583
-  const month = currentDate.value[1].toString().padStart(2, '0');
584
-  const day = currentDate.value[2].toString().padStart(2, '0');
585
-  const hours = currentTime.value[0].toString().padStart(2, '0');
586
-  const minutes = currentTime.value[1].toString().padStart(2, '0');
587
-  const seconds = currentTime.value[2].toString().padStart(2, '0');
588
-
589
-  const dateTimeStr = `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
590
-  submitXFForm.value.repairDdl = dateTimeStr;
591
-  submitXFForm.value.repairDdlText = dateTimeStr;
592
-  showDateTimePicker.value = false;
593
-  dateOrTime.value = false;
594
-};
595
-
596
-// 确认下发
597
-const confirmSubmitXF = async () => {
598
-  try {
599
-    // 验证表单
600
-    if (submitXFFormRef.value) {
601
-      try {
602
-        await submitXFFormRef.value.validate();
603
-      } catch (validateError) {
604
-        // 表单验证失败,不继续执行
605
-        return;
606
-      }
607
-    }
608
-    
609
-    // 检查必填项
610
-    if (!submitXFForm.value.repairSuggest || !submitXFForm.value.repairDdl) {
611
-      showToast({
612
-        type: 'fail',
613
-        message: '请填写完整信息'
614
-      });
615
-      return;
616
-    }
617
-
618
-    // 将整改建议和整改时限添加到row数据中
619
-    const submitData = {
620
-      ...currentSubmitRow.value,
621
-      repairSuggest: submitXFForm.value.repairSuggest,
622
-      repairDdl: submitXFForm.value.repairDdl
623
-    };
624
-    
625
-    const url = 'sgsafe/CheckResultItem/saveXF';
626
-    const param = {
627
-      json: JSON.stringify(submitData)
628
-    };
629
-
630
-    const response = await proxy.$axios.post(url, param);
631
-    if (response.data.code !== 0) {
632
-      showToast({
633
-        type: 'fail',
634
-        message: '操作失败!' + response.data.msg
635
-      });
636
-      return;
637
-    }
638
-
639
-    const data = response.data.data || {};
640
-    const hiddendangerId = data.hiddendangerId;
641
-    if (!hiddendangerId) {
642
-      showToast({
643
-        type: 'success',
644
-        message: '保存成功'
645
-      });
646
-      submitXFDialogVisible.value = false;
647
-      resetXfRepairToDefault();
648
-      defaultRepairL.value = '';
649
-      basicReset();
650
-      onLoad();
651
-      return;
652
-    }
653
-
654
-    const row = currentSubmitRow.value;
655
-    const repairDeptCode =
656
-      row.checkedDeptCode || query2.value?.checkedDeptCode || '';
657
-
658
-    let repairL = '';
659
-    if (xfRepairUseCustom.value && xfRepairUserCodes.value) {
660
-      try {
661
-        const r = await proxy.$axios.post('sgsafe/Hiddendanger/qqId', {
662
-          params: xfRepairUserCodes.value
663
-        });
664
-        if (r.data.code === 0 && r.data.data) {
665
-          repairL = String(r.data.data)
666
-            .split(',')
667
-            .map((id) => 'U_' + id.trim())
668
-            .filter((x) => x.length > 2)
669
-            .join(';');
670
-        }
671
-      } catch (e) {
672
-        console.error('自定义整改人解析失败:', e);
673
-      }
674
-    }
675
-    if (!repairL && repairDeptCode) {
676
-      try {
677
-        const r = await proxy.$axios.get('/sgsafe/Hiddendanger/queryUserIdByPostWithDeptCode', {
678
-          deptCode: repairDeptCode
679
-        });
680
-        if (r.data.code === 0 && r.data.data) {
681
-          repairL = r.data.data;
682
-        }
683
-      } catch (e) {
684
-        console.error('获取整改人失败:', e);
685
-      }
686
-    }
687
-    if (!repairL) {
688
-      if (!repairDeptCode && !xfRepairUseCustom.value) {
689
-        showToast({
690
-          type: 'fail',
691
-          message: '受检部门代码为空,无法确定整改人,请点「选择」指定整改责任人'
692
-        });
693
-      } else if (xfRepairUseCustom.value) {
694
-        showToast({
695
-          type: 'fail',
696
-          message: '未能根据所选人员解析整改人,请重新选择或恢复系统默认'
697
-        });
698
-      } else {
699
-        showToast({
700
-          type: 'fail',
701
-          message: '未获取到整改人,请配置岗位人员或点「选择」手动指定'
702
-        });
703
-      }
704
-      submitXFDialogVisible.value = false;
705
-      resetXfRepairToDefault();
706
-      defaultRepairL.value = '';
707
-      basicReset();
708
-      onLoad();
709
-      return;
710
-    }
711
-
712
-    let acceptL = '';
713
-    if (row.checkPerson) {
714
-      try {
715
-        const r = await proxy.$axios.post('sgsafe/Hiddendanger/qqId', { params: row.checkPerson });
716
-        if (r.data.code === 0 && r.data.data) {
717
-          acceptL = String(r.data.data)
718
-            .split(',')
719
-            .map((id) => 'U_' + id.trim())
720
-            .join(';');
721
-        }
722
-      } catch (e) {
723
-        console.error('获取验收人失败:', e);
724
-      }
725
-    }
726
-    if (!acceptL) {
727
-      showToast({ type: 'fail', message: '验收人信息为空,无法提交审批' });
728
-      submitXFDialogVisible.value = false;
729
-      resetXfRepairToDefault();
730
-      defaultRepairL.value = '';
731
-      basicReset();
732
-      onLoad();
733
-      return;
734
-    }
735
-
736
-    try {
737
-      await showConfirmDialog({
738
-        title: '提示',
739
-        message: '确定提交审批?'
740
-      });
741
-    } catch {
742
-      showToast({ type: 'info', message: '已取消提交审批' });
743
-      submitXFDialogVisible.value = false;
744
-      resetXfRepairToDefault();
745
-      defaultRepairL.value = '';
746
-      basicReset();
747
-      onLoad();
748
-      return;
749
-    }
750
-
751
-    const variables = { id: hiddendangerId, repairL, acceptL };
752
-    const result = await workflowSubmit(
753
-      'hazardImmediatelyCM',
754
-      '隐患排查治理',
755
-      '初始化提交',
756
-      JSON.stringify(toRaw(variables)),
757
-      undefined,
758
-      undefined
759
-    );
760
-    if (result.status === 'success') {
761
-      await proxy.$axios.post('sgsafe/Hiddendanger/saveProcessInfo', {
762
-        json: JSON.stringify({
763
-          id: hiddendangerId,
764
-          workId: result.workId,
765
-          trackId: result.trackId
766
-        })
767
-      });
768
-      showSuccessToast('下发并提交审批成功');
769
-    } else {
770
-      showToast({
771
-        type: 'fail',
772
-        message: '提交审批失败,' + (result.msg || '')
773
-      });
774
-    }
775
-    submitXFDialogVisible.value = false;
776
-    resetXfRepairToDefault();
777
-    defaultRepairL.value = '';
778
-    basicReset();
779
-    onLoad();
780
-  } catch (error) {
781
-    console.error('下发失败:', error);
782
-    showToast({
783
-      type: 'fail',
784
-      message: '操作失败: ' + (error.message || '未知错误')
785
-    });
786
-  }
787
-};
788
-
789
-// 取消下发
790
-const cancelSubmitXF = () => {
791
-  submitXFDialogVisible.value = false;
792
-  submitXFForm.value = {
793
-    repairSuggest: '',
794
-    repairDdl: '',
795
-    repairDdlText: ''
796
-  };
797
-  dateOrTime.value = false;
798
-  resetXfRepairToDefault();
799
-  defaultRepairL.value = '';
800
-};
801
-
802 238
 </script>
803 239
 
804 240
 <style scoped>
@@ -823,16 +259,16 @@ const cancelSubmitXF = () => {
823 259
 }
824 260
 
825 261
 .cell-title {
826
-  display: -webkit-box;                     /* 旧版弹性盒子模型 */
827
-  -webkit-box-orient: vertical;             /* 内容垂直排列 */
828
-  -webkit-line-clamp: 2;                    /* 限制显示行数 */
829
-  line-clamp: 2;                            /* 标准属性 */
830
-  overflow: hidden;                         /* 超出隐藏 */
831
-  text-overflow: ellipsis;                  /* 省略号 */
832
-  line-height: 1.5;                         /* 可选:设置行高 */
833
-  max-height: calc(1.5em * 2);              /* 可选:根据行高限制最大高度 */
262
+  display: -webkit-box;
263
+  -webkit-box-orient: vertical;
264
+  -webkit-line-clamp: 2;
265
+  line-clamp: 2;
266
+  overflow: hidden;
267
+  text-overflow: ellipsis;
268
+  line-height: 1.5;
269
+  max-height: calc(1.5em * 2);
834 270
   font-size: 16px;
835 271
   font-weight: bold;
836
-  color: #333;/* 字号 */
272
+  color: #333;
837 273
 }
838
-</style>
274
+</style>

Loading…
Cancel
Save