Procházet zdrojové kódy

Merge branch 'develop' of http://123.206.9.27:3000/ShinSoft_Xxhsyb/Proj_SafePlat_Vue_Sgh5 into develop

# Conflicts:
#	src/router/index.ts
wangqi před 2 týdny
rodič
revize
18699b9386

+ 15
- 0
.env.liuzhuo Zobrazit soubor

@@ -0,0 +1,15 @@
1
+VITE_BASE_API = 'http://127.0.0.1:8003'
2
+VITE_PREVIEW_API= 'http://172.16.7.51:10023'
3
+VITE_RAQ_API= 'http://172.16.2.78:8080'
4
+VITE_UREPORT_API= 'http://172.16.2.78:8001'
5
+VITE_FINEREPORT_API= 'http://localhost/fr'
6
+VITE_IMAGE_API= 'http://192.168.31.23/image'
7
+# jflow-vue-core 包运行地址
8
+VITE_JFLOW_CORE_ADDR = 'http://192.168.31.196:3000'
9
+VITE_WORKFLOW_ADDR = 'http://10.19.13.206'
10
+VITE_QW_APP_CODE='com.shansteelgroup.sxaqxt'
11
+#VITE_QW_APP_ID='ww0a57c5a416cc3df3'
12
+
13
+VITE_QW_APP_ID='ww9263769246e752c9'
14
+VITE_BUCKET = 'common'
15
+VITE_USER_ID = '78EC80A6EE4311B2A492AD3372E35D35'

+ 1
- 0
package.json Zobrazit soubor

@@ -9,6 +9,7 @@
9 9
 		"preview": "vite preview",
10 10
 		"zhenghao": "vite --mode zhenghao",
11 11
 		"huangluya": "vite --mode huangluya",
12
+		"liuzhuo": "vite --mode liuzhuo",
12 13
 		"hanluo": "vite --mode hanluo",
13 14
 		"jiajunchen": "vite --mode jiajunchen",
14 15
 		"wangqi": "vite --mode wangqi",

binární
public/images/sgbgtz.png Zobrazit soubor


binární
public/images/sgjb.png Zobrazit soubor


binární
public/images/sgjbtz.png Zobrazit soubor


binární
src/assets/img/edit.png Zobrazit soubor


+ 26
- 0
src/router/index.ts Zobrazit soubor

@@ -569,6 +569,32 @@ const router = createRouter({
569 569
 			name: '任务清单汇报',
570 570
 			component: () => import('@/view/planManagement/manifestReport.vue')
571 571
 		},
572
+		},
573
+		{
574
+			path: '/accidentManager/accidentBaoGaoLedger/index',
575
+			name: 'accidentBaoGaoLedger',
576
+			component: () => import('@/view/accidentManager/accidentBaoGaoLedger/index.vue')
577
+		},
578
+		{
579
+			path: '/accidentManager/accidentJuBao/index',
580
+			name: 'accidentJuBao',
581
+			component: () => import('@/view/accidentManager/accidentJuBao/index.vue')
582
+		},
583
+		{
584
+			path: '/accidentManager/accidentBaoGaoLedger/accidentBaoGaoLedger_edit/index',
585
+			name: 'accidentBaoGaoLedger_edit',
586
+			component: () => import('@/view/accidentManager/accidentBaoGaoLedger/accidentBaoGaoLedger_edit/index.vue')
587
+		},
588
+		{
589
+			path: '/accidentManager/accidentJuBao/accidentJuBao_edit/index',
590
+			name: 'accidentJuBao_edit',
591
+			component: () => import('@/view/accidentManager/accidentJuBao/accidentJuBao_edit/index.vue')
592
+		},
593
+		{
594
+			path: '/accidentManager/accidentJuBaoLedger/index',
595
+			name: 'accidentJuBaoLedger',
596
+			component: () => import('@/view/accidentManager/accidentJuBaoLedger/index.vue')
597
+		},
572 598
 	]
573 599
 })
574 600
 

+ 17
- 0
src/view/Home2.vue Zobrazit soubor

@@ -96,6 +96,23 @@
96 96
         </van-grid-item>
97 97
       </van-grid>
98 98
     </div>
99
+    <div class="card">
100
+      <div class="title">事故管理</div>
101
+      <van-grid :border="false" :column-num="4">
102
+        <van-grid-item to="/accidentManager/accidentBaoGaoLedger/index">
103
+          <img src="../../public/images/sgbgtz.png" width="45rpx" />
104
+          <span class="vanicon_text">事故报告台账</span>
105
+        </van-grid-item>
106
+        <van-grid-item to="/accidentManager/accidentJuBao/index">
107
+          <img src="../../public/images/sgjb.png" width="45rpx" />
108
+          <span class="vanicon_text">事故举报</span>
109
+        </van-grid-item>
110
+        <van-grid-item v-if="true" to="/accidentManager/accidentJuBaoLedger/index">
111
+          <img src="../../public/images/sgjbtz.png" width="45rpx" />
112
+          <span class="vanicon_text">事故举报台账</span>
113
+        </van-grid-item>
114
+      </van-grid>
115
+    </div>
99 116
     <div class="card">
100 117
       <div class="title">教育培训</div>
101 118
       <van-grid :border="false" :column-num="4">

+ 754
- 0
src/view/accidentManager/accidentBaoGaoLedger/accidentBaoGaoLedger_edit/index.vue Zobrazit soubor

@@ -0,0 +1,754 @@
1
+<template>
2
+  <div class="h5-container">
3
+    <van-nav-bar :title @click-left="onClickLeft">
4
+    </van-nav-bar>
5
+    <van-form @submit="baocun" ref="formRef">
6
+      <van-field :readonly="ifElseReadonly" border v-model="form.accidentDept" name="报送单位" label="报送单位"
7
+                 :colon="true" placeholder="报送单位"
8
+      />
9
+      <van-field :readonly="ifElseReadonly" border v-model="form.accidentLocation" name="事故地点" label="事故地点"
10
+                 :colon="true" placeholder="事故地点"
11
+                 required
12
+                 :rules="[{ required:true, message: '请填充内容' }]"
13
+      />
14
+      <van-field
15
+        v-model="form.accidentTime"
16
+        is-link
17
+        readonly
18
+        name="datetime"
19
+        label="发生时间"
20
+        :colon="true"
21
+        placeholder="点击选择日期和时间"
22
+        @click="showDatetimePicker = !ifElseReadonly"
23
+        required
24
+        :rules="[{ required:true, message: '请选择内容' }]"
25
+      />
26
+      <!-- 日期时间选择器部分 -->
27
+      <van-popup
28
+        v-model:show="showDatetimePicker"
29
+        position="bottom"
30
+        round
31
+        style="max-height: 50vh;"
32
+      >
33
+        <van-date-picker
34
+          v-if="!dateOrTime"
35
+          v-model="currentDate"
36
+          title="选择日期"
37
+          :min-date="minDate"
38
+          :max-date="maxDate"
39
+          @confirm="onDateConfirm"
40
+          @cancel="cancelDatePicker"
41
+        >
42
+          <template #confirm>
43
+            <van-button type="primary" @click="onDateConfirm">下一步</van-button>
44
+          </template>
45
+          <template #cancel>
46
+            <van-button type="danger" @click="cancelDatePicker">取消</van-button>
47
+          </template>
48
+        </van-date-picker>
49
+
50
+        <van-time-picker
51
+          v-if="dateOrTime"
52
+          v-model="currentTime"
53
+          title="选择时间"
54
+          :columns-type="['hour', 'minute', 'second']"
55
+          @confirm="onConfirmDatetime"
56
+          @cancel="cancelTimePicker"
57
+        >
58
+          <template #confirm>
59
+            <van-button type="primary" @click="onConfirmDatetime">确定</van-button>
60
+          </template>
61
+          <template #cancel>
62
+            <van-button type="danger" @click="cancelTimePicker">取消</van-button>
63
+          </template>
64
+        </van-time-picker>
65
+      </van-popup>
66
+
67
+      <van-field  :readonly="ifElseReadonly" border v-model="form.sceneConditions" name="事故现场情况" label="事故现场情况"
68
+                 type="textarea"
69
+                 autosize
70
+                 :colon="true" placeholder="事故现场情况"
71
+                 required
72
+                 :rules="[{ required:true, message: '请填充内容' }]"
73
+      />
74
+      <van-field  :readonly="ifElseReadonly" border v-model="form.accidentSummary" name="事故简要经过" label="事故简要经过"
75
+                 type="textarea"
76
+                 autosize
77
+                 :colon="true" placeholder="事故简要经过"
78
+                 required
79
+                 :rules="[{ required:true, message: '请填充内容' }]"
80
+      />
81
+      
82
+      
83
+      <van-field is-link :colon="true" readonly v-model="form.accidentType" required label="事故类型"
84
+                 placeholder="选择事故类型"
85
+                 @click="showPicker = !ifElseReadonly" :rules="[{ required: true, message: '请选择内容' }]" />
86
+      <van-popup :readonly="ifElseReadonly" v-model:show="showPicker" round position="bottom">
87
+        <van-picker :columns="yhlxs" @cancel="showPicker = false" @confirm="onConfirmYhlx" />
88
+      </van-popup>
89
+      <van-field v-model="form.seriousInjuryCount" name="重伤人数" label="重伤人数" :colon="true" readonly clickable @touchstart.stop="showSeriousInjuryCount = !ifElseReadonly"
90
+      required :rules="[{ required: true, message: '请输入重伤人数' }]"/>
91
+      <van-number-keyboard
92
+        :readonly="ifElseReadonly"
93
+        v-model="form.seriousInjuryCount"
94
+        :show="showSeriousInjuryCount"
95
+        @blur="showSeriousInjuryCount = false"
96
+      />
97
+      <van-field v-model="form.deathCount" name="死亡人数" label="死亡人数" :colon="true" readonly clickable @touchstart.stop="showDeathCount = !ifElseReadonly"
98
+                 required :rules="[{ required: true, message: '请输入死亡人数' }]"/>
99
+      <van-number-keyboard
100
+        :readonly="ifElseReadonly"
101
+        v-model="form.deathCount"
102
+        :show="showDeathCount"
103
+        @blur="showDeathCount = false"
104
+      />
105
+      <van-field v-model="form.economicLoss" name="事故经济损失" label="事故经济损失(万元)" :colon="true" readonly clickable @touchstart.stop="showEconomicLoss = !ifElseReadonly"
106
+                 required :rules="[{ required: true, message: '请输入事故经济损失并确认是否最多只有小数',pattern: /^\d+(\.\d{1,3})?$/ }]"/>
107
+      <van-number-keyboard
108
+        :readonly="ifElseReadonly"
109
+        v-model="form.economicLoss"
110
+        :show="showEconomicLoss"
111
+        theme="custom"
112
+        extra-key="."
113
+        close-button-text="完成"
114
+        @blur="showEconomicLoss = false"
115
+        @input="onInput"
116
+        @delete="cKeyDelete"
117
+      />
118
+      <van-field readonly border v-model="accidentLevel" name="事故等级" label="事故等级"
119
+                 :colon="true" placeholder="事故等级"
120
+      />
121
+
122
+      <van-field v-if="false" border v-model="form.unlawfulAct" name="可能存在的违法行为" label="可能存在的违法行为"
123
+                 type="textarea"
124
+                 autosize
125
+                 :colon="true" placeholder="可能存在的违法行为"
126
+                 required
127
+                 :rules="[{ required:true, message: '请填充内容' }]"
128
+      />
129
+      <van-field v-if="false" border v-model="form.unlawfulAct" name="可能存在的违法行为" label="可能存在的违法行为"
130
+                 type="textarea"
131
+                 :readonly="ifElseReadonly"
132
+                 autosize
133
+                 :colon="true" placeholder="可能存在的违法行为"
134
+      />
135
+
136
+      <van-field border v-model="form.measuresTaken" name="已采取的措施" label="已采取的措施"
137
+                 type="textarea"
138
+                 autosize
139
+                 :readonly="ifElseReadonly"
140
+                 :colon="true" placeholder="已采取的措施"
141
+                 required
142
+                 :rules="[{ required:true, message: '请填充内容' }]"
143
+      />
144
+
145
+      <van-field border v-model="form.otherConditions" name="其他应当报告的情况" label="其他应当报告的情况"
146
+                 type="textarea"
147
+                 autosize
148
+                 :readonly="ifElseReadonly"
149
+                 :colon="true" placeholder="其他应当报告的情况"
150
+      />
151
+
152
+      <van-field border v-model="form.accountability" name="责任追究" label="责任追究"
153
+                 type="textarea"
154
+                 autosize
155
+                 :readonly="ifElseReadonly"
156
+                 :colon="true" placeholder="责任追究"
157
+      />
158
+
159
+      <van-field border name="事故文件" label="事故文件"
160
+                 type="textarea"
161
+                 autosize
162
+                 :readonly="ifElseReadonly"
163
+                 :colon="true"
164
+      />
165
+      <AttachmentS3 :f-id="form.accidentFile"></AttachmentS3>
166
+      
167
+      <van-button v-if="!ifElseReadonly" block round type="primary" native-type="submit" style="margin-bottom: 5px;">
168
+        保存
169
+      </van-button>
170
+      <van-button v-if="!ifElseReadonly" block round plain type="default" @click="qvxiao">
171
+        取消
172
+      </van-button>
173
+      <div style="height: 10px;"></div>
174
+    </van-form>
175
+  </div>
176
+
177
+
178
+  <van-dialog v-model:show="showDialogVisible" title="删除文件" show-cancel-button
179
+              confirm-button-color="#ee0124" message="确定删除该文件吗?" @confirm="onDelete" />
180
+</template>
181
+
182
+<script setup>
183
+import { ref, reactive, onMounted, getCurrentInstance, nextTick, computed } from 'vue';
184
+import { closeToast, Dialog, showFailToast, showLoadingToast, showSuccessToast, showToast } from 'vant';
185
+import AttachmentS3Image from '@/components/AttachmentS3Image.vue';
186
+import AttachmentS3 from '@/components/AttachmentS3.vue';
187
+import OrganizationalWithLeafUserOne from '@/components/OrganizationalWithLeafUserOne.vue';
188
+import OrganizationalWithLeafUser from '@/components/OrganizationalWithLeafUser.vue';
189
+import OrganizationalWithLeaf from '@/components/JuBaoOrganizationalWithLeaf.vue';
190
+
191
+const { proxy } = getCurrentInstance();
192
+
193
+const onClickLeft = () => {
194
+  history.back();
195
+};
196
+
197
+/* 风险隐患排查发现隐患,进行登记代码 */
198
+const checklistForm = ref({
199
+  evaluationId: '',
200
+  checklistType: '',
201
+  hiddenDangerId: ''
202
+});
203
+const saveCheckInfo = async () => {
204
+  let url = '/safe/ActivityRecords/save';
205
+  if (checklistForm.value.checklistType === 'equipment') {
206
+    url = '/safe/EquipmentRecords/save';
207
+  }
208
+  const param = {
209
+    json: JSON.stringify(checklistForm.value)
210
+  };
211
+  const res = await proxy.$axios.post(url, param);
212
+  if (res.data.code === 0) {
213
+    showSuccessToast('新增排查记录成功!');
214
+    sessionStorage.setItem('inspectionResult', '已排查');
215
+  } else {
216
+    showFailToast('操作失败!' + res.data.msg);
217
+  }
218
+};
219
+
220
+const ifElseReadonly = ref(false)
221
+const title = ref('')
222
+onMounted(async () => {
223
+  const id = proxy.$route.query.id
224
+  const flag = proxy.$route.query.flag
225
+  if('add'===flag){
226
+    title.value='新增事故信息'
227
+  }else if ('edit'===flag){
228
+    title.value='修改事故信息'
229
+  }else {
230
+    title.value='查看事故信息'
231
+  }
232
+  if(id){
233
+    const res = await proxy.$axios.get('/sgsafe/AccidentReport/queryFormById', {
234
+      id
235
+    });
236
+    if(res.data.code === 0){
237
+      form.value = res.data.data
238
+    }else {
239
+      showToast({
240
+        type: 'fail',
241
+        message: '操作失败'+res.data.msg
242
+      })
243
+    }
244
+    if(flag === 'look'){
245
+      ifElseReadonly.value = true
246
+    }
247
+  }
248
+});
249
+
250
+const getTimeFormatter = (date) => {
251
+  const year = date.getFullYear();
252
+  const month = String(date.getMonth() + 1).padStart(2, '0'); // 月份从 0 开始,需加 1
253
+  const day = String(date.getDate()).padStart(2, '0');
254
+  const hours = String(date.getHours()).padStart(2, '0');
255
+  const minutes = String(date.getMinutes()).padStart(2, '0');
256
+  const seconds = String(date.getSeconds()).padStart(2, '0');
257
+  return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
258
+};
259
+
260
+/**表单*/
261
+const form = ref({
262
+  seriousInjuryCount:'',//重伤人数
263
+  deathCount:'',//死亡人数
264
+  economicLoss:'',//经济损失
265
+  accidentLevel:'',//事故等级
266
+});
267
+
268
+const showPicker = ref(false);
269
+
270
+const onConfirmYhlx = ({ selectedOptions }) => {
271
+  showPicker.value = false;
272
+  form.value.accidentType = selectedOptions[0].value;
273
+  console.log('选择的内容', form.value);
274
+};
275
+
276
+const yhlxs = ref([{text: '泄露', value: '泄露'},
277
+  {text: '坍塌', value: '坍塌'},
278
+  {text: '灼烫', value: '灼烫'},
279
+  {text: '触电', value: '触电'},
280
+  {text: '机械伤害', value: '机械伤害'},
281
+  {text: '高处坠落', value: '高处坠落'},
282
+  {text: '中毒窒息', value: '中毒窒息'},
283
+  {text: '容器爆炸', value: '容器爆炸'},
284
+  {text: '爆炸', value: '爆炸'},
285
+  {text: '火灾', value: '火灾'}]
286
+);
287
+
288
+const showDatetimePicker = ref(false);
289
+const currentDate = ref();
290
+const currentTime = ref();
291
+const minDate = ref();
292
+const maxDate = ref();
293
+
294
+const dateOrTime = ref(false);
295
+const onDateConfirm = () => {
296
+  // 日期选择确认后的处理
297
+  dateOrTime.value = true;
298
+};
299
+
300
+const onTimeConfirm = () => {
301
+  // 时间选择确认后的处理
302
+};
303
+
304
+const resetDatetime = () => {
305
+  dateOrTime.value = false;
306
+
307
+  // 初始化日期和时间
308
+  if (form.value.accidentTime) {
309
+    const dt = new Date(form.value.accidentTime);
310
+    currentDate.value = [dt.getFullYear(), dt.getMonth() + 1, dt.getDate()];
311
+    currentTime.value = [
312
+      String(dt.getHours()).padStart(2, '0'),
313
+      String(dt.getMinutes()).padStart(2, '0'),
314
+      String(dt.getSeconds()).padStart(2, '0')
315
+    ];
316
+  } else {
317
+    const now = new Date();
318
+    currentDate.value = [now.getFullYear(), now.getMonth() + 1, now.getDate()];
319
+    currentTime.value = [
320
+      String(now.getHours()).padStart(2, '0'),
321
+      String(now.getMinutes()).padStart(2, '0'),
322
+      String(now.getSeconds()).padStart(2, '0')
323
+    ];
324
+  }
325
+};
326
+
327
+const onConfirmDatetime = () => {
328
+  const year = currentDate.value[0];
329
+  const month = currentDate.value[1].toString().padStart(2, '0');
330
+  const day = currentDate.value[2].toString().padStart(2, '0');
331
+  const hours = currentTime.value[0].toString().padStart(2, '0');
332
+  const minutes = currentTime.value[1].toString().padStart(2, '0');
333
+  const seconds = currentTime.value[2].toString().padStart(2, '0');
334
+
335
+  form.value.accidentTime = `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
336
+  showDatetimePicker.value = false;
337
+  dateOrTime.value = false;
338
+};
339
+
340
+const showPicker2 = ref(false);
341
+
342
+const onConfirmYhdj = ({ selectedOptions }) => {
343
+  showPicker2.value = false;
344
+  form.value.hdLevel = selectedOptions[0].value;
345
+  console.log('选择的内容', form.value);
346
+};
347
+
348
+const yhdjs = ref([{ text: '一般隐患', value: '一般隐患' },
349
+  { text: '重大隐患', value: '重大隐患' }]
350
+);
351
+
352
+const formRef = ref(null);
353
+const qvxiao = () => {
354
+  showToast({
355
+    type: 'fail',
356
+    message: '操作取消!'
357
+  });
358
+  onClickLeft();
359
+};
360
+const baocun = async () => {
361
+  form.value.accidentLevel = accidentLevel
362
+  // 原有保存逻辑保持不变
363
+  var url = 'safe/AccidentDirect/save';
364
+  var param = {
365
+    json: JSON.stringify(form.value)
366
+  };
367
+  const response = await proxy.$axios.post(url, param);
368
+  if (response.data.code === 0) {
369
+    showToast({
370
+      type: 'success',
371
+      message: '保存成功!'
372
+    });
373
+    onClickLeft();
374
+  } else {
375
+    showToast({
376
+      type: 'fail',
377
+      message: '操作失败!'
378
+    });
379
+  }
380
+};
381
+
382
+const handleChangeHdSelect = (value) => {
383
+  form.value.hdSelect = value;
384
+  if (value === '隐患举报') {
385
+    isStandardFlow.value = true;
386
+  } else if (value === '即查即改') {
387
+    isStandardFlow.value = false;
388
+  }
389
+  getYHID();
390
+};
391
+
392
+const guid = () => {
393
+  function S4() {
394
+    return (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1);
395
+  }
396
+
397
+  return (S4() + S4() + S4() + S4() + S4() + S4() + S4() + S4());
398
+};
399
+/* 发现人 */
400
+const leaderKey = guid();
401
+const PopupDepartmentLeaderNameRef = ref();
402
+const handleDepartmentLeaderName = () => {
403
+  PopupDepartmentLeaderNameRef.value.open();
404
+};
405
+
406
+const codeAndDesc = ref([]);
407
+const getDepartmentLeaderName = (item) => {
408
+  form.value.discoverer = item.user.userCode;
409
+  form.value.discovererDesc = item.user.userDesc;
410
+  form.value.discovererDeptCode = item.dept.deptCode;
411
+  form.value.discovererDept = item.dept.deptName;
412
+};
413
+
414
+/* 其他发现人 */
415
+const leaderKey2 = guid();
416
+const PopupDepartmentLeaderNameRef2 = ref();
417
+const handleDepartmentLeaderName2 = () => {
418
+  PopupDepartmentLeaderNameRef2.value.open();
419
+};
420
+
421
+const codeAndDesc2 = ref([]);
422
+const getDepartmentLeaderName2 = (items) => {
423
+  console.log('人员数据', items);
424
+  let codeList = [];
425
+  let descList = [];
426
+  for (let item of items) {
427
+    codeAndDesc2.value.push(item.userCode + '-' + item.userDesc);
428
+    codeList.push(item.userCode);
429
+    descList.push(item.userDesc);
430
+  }
431
+  form.value.discovererOther = codeList.join(',');
432
+  form.value.discovererOtherDesc = descList.join(',');
433
+};
434
+
435
+//定义一个变量切换即查即改还是标准流程
436
+const isStandardFlow = ref(true);
437
+
438
+//当是即查即改时得到隐患编号并赋值
439
+const getYHID = () => {
440
+  //直接请求后端返回一个隐患编号
441
+  console.log('getYHID');
442
+  if (form.value.hdSelect === '即查即改') {
443
+    var url = 'safe/JuBaoHiddendanger/getYhbhTemp';
444
+    var param = {};
445
+    proxy.$axios.get(url, param).then(response => {
446
+      if (response.data.code == '0') {
447
+        form.value.hdId = response.data.data;
448
+      } else {
449
+        ElMessage.error('操作失败!' + response.data.msg);
450
+      }
451
+    });
452
+  } else {
453
+    form.value.hdId = '';
454
+  }
455
+};
456
+
457
+/* 整改人 */
458
+const leaderKeyzgr = guid();
459
+const PopupDepartmentLeaderNameRefzgr = ref();
460
+const handleDepartmentLeaderNamezgr = () => {
461
+  PopupDepartmentLeaderNameRefzgr.value.open();
462
+};
463
+
464
+const codeAndDesczgr = ref([]);
465
+const getDepartmentLeaderNamezgr = (item) => {
466
+  form.value.repairLeader = item.user.userCode;
467
+  form.value.repairLeaderDesc = item.user.userDesc;
468
+  form.value.repairDept = item.dept.deptName;
469
+};
470
+
471
+/* 其他整改人 */
472
+const leaderKey2qtzgr = guid();
473
+const PopupDepartmentLeaderNameRef2qtzgr = ref();
474
+const handleDepartmentLeaderName2qtzgr = () => {
475
+  PopupDepartmentLeaderNameRef2qtzgr.value.open();
476
+};
477
+
478
+const codeAndDesc2qtzgr = ref([]);
479
+const getDepartmentLeaderName2qtzgr = (items) => {
480
+  console.log('人员数据', items);
481
+  let codeList = [];
482
+  let descList = [];
483
+  for (let item of items) {
484
+    codeAndDesc2qtzgr.value.push(item.userCode + '-' + item.userDesc);
485
+    codeList.push(item.userCode);
486
+    descList.push(item.userDesc);
487
+  }
488
+  form.value.repairOther = codeList.join(',');
489
+  form.value.repairOtherDesc = descList.join(',');
490
+};
491
+
492
+/* 组织树选择 */
493
+const showBottom = ref(false);
494
+const handleTableDataUserDeptUpdate = async (nodeData) => {
495
+  let temp = nodeData.split('-');
496
+  if(temp[0].length<9){
497
+    showFailToast('请选择四级及以下部门')
498
+    return
499
+  }
500
+  form.value.hdLocation = temp[1];
501
+  form.value.hdLocationCode = temp[0];
502
+  form.value.hdConfirm = temp[2]
503
+  // form.value.repairDept = nodeData.deptCode + '-' + nodeData.deptName
504
+  showBottom.value = false;
505
+};
506
+const showPickerHandle = () => {
507
+  showBottom.value = true;
508
+};
509
+
510
+/**表单*/
511
+
512
+/***********************新图******************************/
513
+//公共区
514
+import { atob } from 'js-base64';
515
+
516
+const bucket = ref(import.meta.env.VITE_BUCKET);
517
+
518
+function base64ToBlob(base64) {
519
+  const contentType = base64.substring(base64.indexOf(':') + 1, base64.indexOf(';'));
520
+  const byteCharacters = atob(base64);
521
+  const byteArrays = [];
522
+
523
+  for (let i = 0; i < byteCharacters.length; i++) {
524
+    byteArrays.push(byteCharacters.charCodeAt(i));
525
+  }
526
+
527
+  const byteArray = new Uint8Array(byteArrays);
528
+  return new Blob([byteArray], { type: contentType });
529
+}
530
+
531
+const headers = ref({
532
+  token: localStorage.getItem('token'),
533
+  userId: localStorage.getItem('userId')
534
+});
535
+
536
+//整改前
537
+const fileList = ref([]);
538
+const afterRead = (file) => {
539
+  const content = base64ToBlob(file.content);
540
+  const formData = new FormData();
541
+  formData.append('fId', form.value.hdPicId);
542
+  formData.append('bucket', bucket.value);
543
+  formData.append('value1', null);
544
+  formData.append('value2', null);
545
+  formData.append('value3', null);
546
+  formData.append('value4', null);
547
+  formData.append('value5', null);
548
+  formData.append('file', content, file.file.name);
549
+  let url = import.meta.env.VITE_BASE_API + '/framework/Common/uploadFileS3';
550
+  proxy.$axios.post(url, formData, { headers: headers.value }).then(res => {
551
+    if (res.data.code === 0) {
552
+      showSuccessToast('上传成功');
553
+      getTableData();
554
+    } else {
555
+      showFailToast('上传失败' + res.data.msg);
556
+    }
557
+  }).catch(error => {
558
+    console.log(error);
559
+  });
560
+};
561
+const getTableData = () => {
562
+  //携带自定义参数
563
+  var url = 'framework/Common/queryFileWithValues';
564
+  var param = {
565
+    fId: form.value.hdPicId, //必填
566
+    value1: null, //非必填
567
+    value2: null, //非必填
568
+    value3: null, //非必填
569
+    value4: null, //非必填
570
+    value5: null //非必填
571
+  };
572
+  proxy.$axios.get(url, param).then(response => {
573
+    if (response.data.code === 0) {
574
+      for (var item of response.data.data) {
575
+        fileList.value.push({
576
+          id: item.id,
577
+          uploadFile: item.fileName,
578
+          url: import.meta.env.VITE_BASE_API +
579
+            '/framework/Common/downloadFileS3?bucket=' + bucket.value +
580
+            '&id=' + item.id
581
+        });
582
+        form.value.picBefore = fileList.value[0].url;
583
+      }
584
+    } else {
585
+      showFailToast('失败!' + response.data.msg);
586
+    }
587
+  });
588
+};
589
+/* 在线删除 */
590
+const showDialogVisible = ref(false);
591
+const deleteInfo = ref();
592
+const handleDelete = (row) => {
593
+  showDialogVisible.value = true;
594
+  deleteInfo.value = row;
595
+};
596
+const onDelete = () => {
597
+  let url = 'framework/Common/removeFile';
598
+  let param = {
599
+    id: deleteInfo.value.id
600
+  };
601
+  proxy.$axios.post(url, param).then(response => {
602
+    if (response.data.code === 0) {
603
+      showSuccessToast('删除成功!');
604
+      getTableData();
605
+    } else {
606
+      showFailToast('删除失败;' + response.data.msg);
607
+    }
608
+  });
609
+};
610
+
611
+//隐患选择
612
+const selectOption = (option) => {
613
+  if (form.value.workId.length > 0) {
614
+    return;
615
+  }
616
+  form.value.hdSelect = option;
617
+  if (option === '隐患举报') {
618
+    isStandardFlow.value = true;
619
+  } else if (option === '即查即改') {
620
+    isStandardFlow.value = false;
621
+  }
622
+  getYHID();
623
+};
624
+
625
+/**修改发现时间**/
626
+// 日期选择器取消
627
+const cancelDatePicker = () => {
628
+  showDatetimePicker.value = false;
629
+  resetDatetime();
630
+};
631
+
632
+// 时间选择器取消
633
+const cancelTimePicker = () => {
634
+  resetDatetime();
635
+  // 重置为当前时间或从表单获取时间
636
+  if (form.value.accidentTime) {
637
+    const dt = new Date(form.value.accidentTime);
638
+    currentTime.value = [
639
+      String(dt.getHours()).padStart(2, '0'),
640
+      String(dt.getMinutes()).padStart(2, '0'),
641
+      String(dt.getSeconds()).padStart(2, '0')
642
+    ];
643
+  } else {
644
+    const now = new Date();
645
+    currentTime.value = [
646
+      String(now.getHours()).padStart(2, '0'),
647
+      String(now.getMinutes()).padStart(2, '0'),
648
+      String(now.getSeconds()).padStart(2, '0')
649
+    ];
650
+  }
651
+};
652
+/**修改发现时间**/
653
+
654
+/**控制显示**/
655
+const showSeriousInjuryCount = ref(false)
656
+const showDeathCount = ref(false)
657
+const showEconomicLoss = ref(false)
658
+
659
+/**控制输入**//*
660
+const onInput = (value) =>{
661
+  console.log('输入的值', value)
662
+  // 1. 过滤所有非数字和非小数点的字符(只保留数字和一个小数点)
663
+  // let value = val.replace(/[^\d.]/g, '');
664
+
665
+  // 2. 处理多个小数点:只保留第一个小数点,后续的小数点删除
666
+  // const dotIndex = value.indexOf('.');
667
+  if (value !== -1) {
668
+    // 从第一个小数点后开始,删除所有其他小数点
669
+    value = value.slice(0, dotIndex + 1) + value.slice(dotIndex + 1).replace(/\./g, '');
670
+  }
671
+
672
+  // 3. 处理开头为小数点的情况:自动补0(如 .123 → 0.123)
673
+  if (value.startsWith('.')) {
674
+    value = '0' + value;
675
+  }
676
+
677
+  // 4. 限制小数位最多3位:如果有小数点,截取小数点后前3位
678
+  if (value.includes('.')) {
679
+    const parts = value.split('.');
680
+    // 整数部分 + 小数点 + 小数部分前3位
681
+    value = parts[0] + '.' + (parts[1] || '').slice(0, 3);
682
+  }
683
+
684
+  // 5. 赋值给表单(避免空值时显示undefined)
685
+  form.value.economicLoss = value || '';
686
+}*/
687
+
688
+/**控制键盘删除**/
689
+const cKeyDelete = () => {
690
+  if (!form.value.economicLoss) return; // 为空时不操作
691
+
692
+  // 截取掉最后一个字符
693
+  let value = form.value.economicLoss.slice(0, -1);
694
+
695
+  // 处理删除后可能出现的不合理格式(比如只剩小数点)
696
+  if (value === '.') {
697
+    value = ''; // 如果删除后只剩小数点,清空
698
+  }
699
+
700
+  form.value.economicLoss = value;
701
+}
702
+
703
+/**计算属性**/
704
+//计算属性
705
+const accidentLevel = computed(()=>{
706
+  if(form.value.deathCount>=30 || form.value.economicLoss>=100000 || form.value.seriousInjuryCount>=100){
707
+    return '特别重大事故'
708
+  }else if(form.value.deathCount>=10 || form.value.economicLoss>=5000 || form.value.seriousInjuryCount>=50){
709
+    return '重大事故'
710
+  }else if(form.value.deathCount>=3 || form.value.economicLoss>=1000 || form.value.seriousInjuryCount>=10){
711
+    return '较大事故'
712
+  }else{
713
+    return '一般事故'
714
+  }
715
+})
716
+
717
+</script>
718
+
719
+<style scoped>
720
+.h5-container {
721
+  width: 100%;
722
+  box-sizing: border-box;
723
+  height: 100vh;
724
+  background-color: white;
725
+  padding: 10px;
726
+  padding-bottom: 20px;
727
+}
728
+
729
+.radio-group {
730
+  display: flex;
731
+  background-color: white;
732
+  padding: 10px;
733
+  border-radius: 5px;
734
+  margin: 10px 0;
735
+  gap: 10px;
736
+}
737
+
738
+.radio-item {
739
+  padding: 8px 12px;
740
+  border: 1px solid #222;
741
+  border-radius: 4px;
742
+  background-color: white;
743
+  cursor: pointer;
744
+  transition: background-color 0.3s ease;
745
+  /* 添加过渡效果 */
746
+}
747
+
748
+.radio-item.active {
749
+  background-color: #4285f4;
750
+  /* 选中时的蓝色 */
751
+  color: white;
752
+  border-color: #4285f4;
753
+}
754
+</style>

+ 397
- 0
src/view/accidentManager/accidentBaoGaoLedger/index.vue Zobrazit soubor

@@ -0,0 +1,397 @@
1
+<template>
2
+  <div class="page-container">
3
+    <van-sticky>
4
+      <van-nav-bar
5
+        title="事故报告台账"
6
+        @click-left="onClickLeft" >
7
+      </van-nav-bar>
8
+    </van-sticky>
9
+
10
+    <div class="scroll-container">
11
+      <van-pull-refresh
12
+        v-model="refreshing"
13
+        success-text="刷新成功"
14
+        @refresh="onRefresh"
15
+      >
16
+        <van-list
17
+          class="listDiv"
18
+          :immediate-check="false"
19
+          v-model:loading="loading"
20
+          :finished="finished"
21
+          finished-text="没有更多了"
22
+          @load="onLoad"
23
+        >
24
+          <div v-for="item in list" :key="item.id" class="card">
25
+            <van-cell @click="handleLookRow(item)">
26
+              <template #title>
27
+                <span v-if="false" class="cell-title">{{ item.hdDescription }}</span>
28
+              </template>
29
+              <template #label>
30
+                <div class="label-content">
31
+                  <div>事故地点:{{ item.accidentLocation }}</div>
32
+                  <div>发生时间:{{ item.accidentTime }}</div>
33
+                  <div>事故类型:{{ item.accidentType }}</div>
34
+                </div>
35
+              </template>
36
+            </van-cell>
37
+          </div>
38
+        </van-list>
39
+      </van-pull-refresh>
40
+    </div>
41
+
42
+    <van-popup :close-on-click-overlay="false" :lazy-render="false" v-model:show="showBottom" position="bottom">
43
+      <OrganizationalWithLeaf :cached-dept-code="cachedDeptCode" @init="getDeptInfo" @close="showBottom = false" @update:selected-node="handleTableDataUserDeptUpdate" />
44
+    </van-popup>
45
+
46
+    <van-dialog v-model:show="showDialogVisible" title="提示" show-cancel-button
47
+                confirm-button-color="#ee0124" message="确定删除本条数据吗" @confirm="onDelete"/>
48
+  </div>
49
+</template>
50
+<script setup>
51
+import { getCurrentInstance, onMounted, ref } from 'vue';
52
+import { onBeforeRouteLeave, useRouter } from 'vue-router';
53
+import { showConfirmDialog, showDialog, showFailToast, showSuccessToast } from 'vant';
54
+import { useEmergencyStore } from '@/stores/emergencyManager.js';
55
+const emergencyInfo =  useEmergencyStore()
56
+const {
57
+  proxy
58
+} = getCurrentInstance()
59
+
60
+
61
+/**
62
+ * 组织树组件初始化返回方法
63
+ * @param currentDeptInfo 用户部门信息(userCode-userName)
64
+ */
65
+const cachedDeptCode = ref('')
66
+const getDeptInfo = (currentDeptInfo) => {
67
+  postBackRegimeScope.value = currentDeptInfo
68
+  currentDeptName.value = currentDeptInfo.split('-')[1]
69
+
70
+  /* Pinia初始化属性 */
71
+  if (emergencyInfo.currentDeptCode) {
72
+    postBackRegimeScope.value = emergencyInfo.currentDeptCode + '-' + emergencyInfo.currentDeptName
73
+    currentDeptName.value = emergencyInfo.currentDeptName
74
+    fetchData.value.regimeName = emergencyInfo.conditionalQueryAttributes
75
+  }
76
+  basicReset()
77
+  onLoad()
78
+}
79
+/**
80
+ * 数据传回组织树组件
81
+ */
82
+if (emergencyInfo.currentDeptCode) {
83
+  cachedDeptCode.value = emergencyInfo.currentDeptCode
84
+}
85
+
86
+/**
87
+ * 路由跳转前,pinia中缓存数据
88
+ */
89
+onBeforeRouteLeave((to, from, next) => {
90
+  /* 跳转子页面赋值 */
91
+  if (to.path === '/yinhuan/hdLedger_detail') {
92
+    emergencyInfo.$patch({
93
+      currentDeptCode: postBackRegimeScope.value.split('-')[0],
94
+      currentDeptName: postBackRegimeScope.value.split('-')[1],
95
+      conditionalQueryAttributes: fetchData.value.regimeName
96
+    })
97
+  } else {
98
+    /* 跳转其他页面均清空,避免混乱赋值 */
99
+    emergencyInfo.clearMainDeptInfo()
100
+  }
101
+  next()
102
+})
103
+
104
+/* 通用方法: 重置list数据 */
105
+const basicReset = () => {
106
+  finished.value = false;
107
+  loading.value = true;
108
+  pageNum.value = 1
109
+  list.value = []
110
+}
111
+
112
+/* 返回上一级页面 */
113
+const router = useRouter()
114
+const onClickLeft = () => {
115
+  router.go(-1)
116
+}
117
+
118
+/* 查询数据 */
119
+const pageNum = ref(1)
120
+const pageSize = ref(10)
121
+const total = ref(0)
122
+const resultData = ref([])
123
+const fetchData = ref({
124
+  regimeName: '',
125
+  regimeScope: '',
126
+})
127
+
128
+const onSearch = () => {
129
+  basicReset()
130
+  onLoad()
131
+}
132
+
133
+const resetCondition = () => {
134
+  basicReset()
135
+  fetchData.value = {
136
+    regimeName:'',
137
+    regimeScope: ''
138
+  }
139
+  onLoad()
140
+}
141
+
142
+/* 查询请求 */
143
+const queryFetch = async () => {
144
+  fetchData.value.regimeScope = postBackRegimeScope.value
145
+  const url = '/sgsafe/AccidentReport/query'
146
+  const param = {
147
+    page: pageNum.value,
148
+    rows: pageSize.value,
149
+    params: JSON.stringify(fetchData.value)
150
+  }
151
+  try {
152
+    const res = await proxy.$axios.post(url,param);
153
+    if (res.data.code === 0) {
154
+      total.value = res.data.data.total
155
+      resultData.value = res.data.data.records
156
+    } else {
157
+      console.log('操作失败!' + res.data.msg)
158
+    }
159
+  } catch (error) {
160
+    console.error('请求出错:', error);
161
+  }
162
+};
163
+
164
+/* 列表加载与下拉刷新 */
165
+const list = ref([]);
166
+const refreshing = ref(false)
167
+const loading = ref(false)
168
+const finished = ref(false)
169
+
170
+const onRefresh = () => {
171
+  basicReset()
172
+  onLoad();
173
+};
174
+
175
+const onLoad = async () => {
176
+  if (refreshing.value) {
177
+    list.value = [];
178
+    pageNum.value = 1;
179
+    refreshing.value = false;
180
+  }
181
+  try {
182
+    await  queryFetch();
183
+    if (pageSize.value * pageNum.value < total.value) {
184
+      list.value = [...list.value,...resultData.value ]
185
+      pageNum.value++;
186
+    } else {
187
+      list.value = [...list.value,...resultData.value ]
188
+      finished.value = true;
189
+    }
190
+  } catch (error) {
191
+    console.log(error);
192
+    finished.value = true;
193
+  } finally {
194
+    loading.value = false;
195
+  }
196
+};
197
+
198
+/* 组织树选择 */
199
+const showBottom = ref(false)
200
+const currentDeptName = ref('')
201
+const postBackRegimeScope = ref()
202
+import OrganizationalWithLeaf from '@/components/OrganizationalWithLeaf.vue';
203
+const showPickerHandle = () => {
204
+  showBottom.value = true
205
+}
206
+
207
+const handleTableDataUserDeptUpdate = async (nodeData) => {
208
+  console.log('你哦的Date',nodeData)
209
+  currentDeptName.value = nodeData.split('-')[1]
210
+  postBackRegimeScope.value = nodeData
211
+  basicReset()
212
+  await onLoad()
213
+  showBottom.value = false
214
+}
215
+
216
+const getTypeState = (state) => {
217
+  const typeMap = {
218
+    '0': 'danger',
219
+    '1': 'success'
220
+  }
221
+  return typeMap[state] || ''
222
+}
223
+
224
+const getPlanState = (state) => {
225
+  const typeMap = {
226
+    '0': '未完成',
227
+    '1': '已完成'
228
+  }
229
+  return typeMap[state] || ''
230
+}
231
+
232
+const showDialogVisible = ref(false)
233
+const deleteInfo = ref()
234
+const handleDelete = (item) => {
235
+  showDialogVisible.value = true
236
+  deleteInfo.value = item
237
+}
238
+
239
+/* 数据删除 */
240
+const onDelete = () => {
241
+  const item = deleteInfo.value
242
+  const url = '/safe/EmergencyDrillPlan/delete'
243
+  const param = {
244
+    json: JSON.stringify(item)
245
+  }
246
+  proxy.$axios.post(url,param).then(res=>{
247
+    if (res.data.code === 0) {
248
+      showSuccessToast('删除成功')
249
+      basicReset()
250
+      onLoad()
251
+    } else {
252
+      showFailToast('操作失败!' + res.data.msg)
253
+    }
254
+  })
255
+}
256
+
257
+//点击详情跳转
258
+const handleLookRow = (row) =>{
259
+  proxy.$router.push({
260
+    path: '/accidentManager/accidentBaoGaoLedger/accidentBaoGaoLedger_edit/index',
261
+    query: {
262
+      id:row.id,
263
+      flag:'look'
264
+    }
265
+  })
266
+}
267
+
268
+//颜色事件
269
+const getStatusClass = (status) => {
270
+  switch (status) {
271
+    case '-1':
272
+      return 'status-pending';
273
+    case '0':
274
+      return 'status-registered';
275
+    case '1':
276
+      return 'status-analyzing';
277
+    case '2':
278
+      return 'status-rectifying';
279
+    case '3':
280
+      return 'status-accepting';
281
+    case '4':
282
+      return 'status-closed';
283
+    case '5':
284
+      return 'status-finished';
285
+    default:
286
+      return 'status-unknown';
287
+  }
288
+};
289
+
290
+</script>
291
+
292
+<style scoped>
293
+.page-container {
294
+  height: 100vh; /* 关键:外层容器高度设为视口高度 */
295
+  display: flex;
296
+  flex-direction: column;
297
+
298
+}
299
+/*  overflow-y: auto; !* 启用垂直滚动 *!*/
300
+
301
+
302
+.scroll-container {
303
+  flex: 1;
304
+  overflow: auto;
305
+  -webkit-overflow-scrolling: touch; /* iOS 平滑滚动 */
306
+}
307
+
308
+/* 可选:隐藏滚动条(视觉优化) */
309
+.scroll-container::-webkit-scrollbar {
310
+  display: none;
311
+}
312
+
313
+.card {
314
+  margin: 10px;
315
+  border-radius: 8px;
316
+  overflow: hidden;
317
+  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
318
+  background-color: #fff;
319
+}
320
+.label-content {
321
+  display: flex;
322
+  flex-direction: column;
323
+  gap: 4px;
324
+}
325
+
326
+.cell-title {
327
+  display: -webkit-box;                     /* 旧版弹性盒子模型 */
328
+  -webkit-box-orient: vertical;             /* 内容垂直排列 */
329
+  -webkit-line-clamp: 2;                    /* 限制显示行数 */
330
+  overflow: hidden;                         /* 超出隐藏 */
331
+  text-overflow: ellipsis;                  /* 省略号 */
332
+  line-height: 1.5;                         /* 可选:设置行高 */
333
+  max-height: calc(1.5em * 2);              /* 可选:根据行高限制最大高度 */
334
+  font-size: 16px;
335
+  font-weight: bold;
336
+  color: #333;/* 字号 */
337
+}
338
+
339
+
340
+.status-pending {
341
+  background-color: #fff3cd;
342
+  color: #856404;
343
+  padding: 2px 4px;
344
+  border-radius: 4px;
345
+}
346
+
347
+.status-registered {
348
+  background-color: #d1ecf1;
349
+  color: #0c5460;
350
+  padding: 2px 4px;
351
+  border-radius: 4px;
352
+}
353
+
354
+.status-analyzing {
355
+  background-color: #fff8e1;
356
+  color: #ff8f00;
357
+  padding: 2px 4px;
358
+  border-radius: 4px;
359
+}
360
+
361
+.status-rectifying {
362
+  background-color: #e8f5e9;
363
+  color: #2e7d32;
364
+  padding: 2px 4px;
365
+  border-radius: 4px;
366
+}
367
+
368
+.status-accepting {
369
+  background-color: #e3f2fd;
370
+  color: #1565c0;
371
+  padding: 2px 4px;
372
+  border-radius: 4px;
373
+}
374
+
375
+.status-closed {
376
+  background-color: #f8bbd0;
377
+  color: #b71c1c;
378
+  padding: 2px 4px;
379
+  border-radius: 4px;
380
+}
381
+
382
+.status-finished {
383
+  background-color: #e8eaf6;
384
+  color: #311b92;
385
+  padding: 2px 4px;
386
+  border-radius: 4px;
387
+}
388
+
389
+.status-unknown {
390
+  background-color: #efebe9;
391
+  color: #424242;
392
+  padding: 2px 4px;
393
+  border-radius: 4px;
394
+}
395
+
396
+
397
+</style>

+ 735
- 0
src/view/accidentManager/accidentJuBao/accidentJuBao_edit/index.vue Zobrazit soubor

@@ -0,0 +1,735 @@
1
+<template>
2
+  <div class="h5-container">
3
+    <van-nav-bar :title @click-left="onClickLeft">
4
+    </van-nav-bar>
5
+    <van-form @submit="baocun" ref="formRef">
6
+      <van-field :readonly="ifElseReadonly" border v-model="form.accidentLocation" name="事故地点" label="事故地点"
7
+                 :colon="true" placeholder="事故地点"
8
+                 required
9
+                 :rules="[{ required:true, message: '请填充内容' }]"
10
+      />
11
+      <van-field
12
+        v-model="form.accidentTime"
13
+        is-link
14
+        readonly
15
+        name="datetime"
16
+        label="发生时间"
17
+        :colon="true"
18
+        placeholder="点击选择日期和时间"
19
+        @click="showDatetimePicker = !ifElseReadonly"
20
+        required
21
+        :rules="[{ required:true, message: '请选择内容' }]"
22
+      />
23
+      <!-- 日期时间选择器部分 -->
24
+      <van-popup
25
+        v-model:show="showDatetimePicker"
26
+        position="bottom"
27
+        round
28
+        style="max-height: 50vh;"
29
+      >
30
+        <van-date-picker
31
+          v-if="!dateOrTime"
32
+          v-model="currentDate"
33
+          title="选择日期"
34
+          :min-date="minDate"
35
+          :max-date="maxDate"
36
+          @confirm="onDateConfirm"
37
+          @cancel="cancelDatePicker"
38
+        >
39
+          <template #confirm>
40
+            <van-button type="primary" @click="onDateConfirm">下一步</van-button>
41
+          </template>
42
+          <template #cancel>
43
+            <van-button type="danger" @click="cancelDatePicker">取消</van-button>
44
+          </template>
45
+        </van-date-picker>
46
+
47
+        <van-time-picker
48
+          v-if="dateOrTime"
49
+          v-model="currentTime"
50
+          title="选择时间"
51
+          :columns-type="['hour', 'minute', 'second']"
52
+          @confirm="onConfirmDatetime"
53
+          @cancel="cancelTimePicker"
54
+        >
55
+          <template #confirm>
56
+            <van-button type="primary" @click="onConfirmDatetime">确定</van-button>
57
+          </template>
58
+          <template #cancel>
59
+            <van-button type="danger" @click="cancelTimePicker">取消</van-button>
60
+          </template>
61
+        </van-time-picker>
62
+      </van-popup>
63
+
64
+      <van-field  :readonly="ifElseReadonly" border v-model="form.sceneConditions" name="事故现场情况" label="事故现场情况"
65
+                 type="textarea"
66
+                 autosize
67
+                 :colon="true" placeholder="事故现场情况"
68
+                 required
69
+                 :rules="[{ required:true, message: '请填充内容' }]"
70
+      />
71
+      <van-field  :readonly="ifElseReadonly" border v-model="form.accidentSummary" name="事故简要经过" label="事故简要经过"
72
+                 type="textarea"
73
+                 autosize
74
+                 :colon="true" placeholder="事故简要经过"
75
+                 required
76
+                 :rules="[{ required:true, message: '请填充内容' }]"
77
+      />
78
+      
79
+      <van-field is-link :colon="true" readonly v-model="form.accidentType" required label="事故类型"
80
+                 placeholder="选择事故类型"
81
+                 @click="showPicker = !ifElseReadonly" :rules="[{ required: true, message: '请选择内容' }]" />
82
+      <van-popup :readonly="ifElseReadonly" v-model:show="showPicker" round position="bottom">
83
+        <van-picker :columns="yhlxs" @cancel="showPicker = false" @confirm="onConfirmYhlx" />
84
+      </van-popup>
85
+      <van-field v-model="form.seriousInjuryCount" name="重伤人数" label="重伤人数" :colon="true" readonly clickable @touchstart.stop="showSeriousInjuryCount = !ifElseReadonly"
86
+      required :rules="[{ required: true, message: '请输入重伤人数' }]"/>
87
+      <van-number-keyboard
88
+        :readonly="ifElseReadonly"
89
+        v-model="form.seriousInjuryCount"
90
+        :show="showSeriousInjuryCount"
91
+        @blur="showSeriousInjuryCount = false"
92
+      />
93
+      <van-field v-model="form.deathCount" name="死亡人数" label="死亡人数" :colon="true" readonly clickable @touchstart.stop="showDeathCount = !ifElseReadonly"
94
+                 required :rules="[{ required: true, message: '请输入死亡人数' }]"/>
95
+      <van-number-keyboard
96
+        :readonly="ifElseReadonly"
97
+        v-model="form.deathCount"
98
+        :show="showDeathCount"
99
+        @blur="showDeathCount = false"
100
+      />
101
+      <van-field v-model="form.economicLoss" name="事故经济损失" label="事故经济损失(万元)" :colon="true" readonly clickable @touchstart.stop="showEconomicLoss = !ifElseReadonly"
102
+                 required :rules="[{ required: true, message: '请输入事故经济损失并确认是否最多只有小数',pattern: /^\d+(\.\d{1,3})?$/ }]"/>
103
+      <van-number-keyboard
104
+        :readonly="ifElseReadonly"
105
+        v-model="form.economicLoss"
106
+        :show="showEconomicLoss"
107
+        theme="custom"
108
+        extra-key="."
109
+        close-button-text="完成"
110
+        @blur="showEconomicLoss = false"
111
+        @input="onInput"
112
+        @delete="cKeyDelete"
113
+      />
114
+      <van-field readonly border v-model="accidentLevel" name="事故等级" label="事故等级"
115
+                 :colon="true" placeholder="事故等级"
116
+      />
117
+
118
+      <van-field v-if="false" border v-model="form.unlawfulAct" name="可能存在的违法行为" label="可能存在的违法行为"
119
+                 type="textarea"
120
+                 autosize
121
+                 :colon="true" placeholder="可能存在的违法行为"
122
+                 required
123
+                 :rules="[{ required:true, message: '请填充内容' }]"
124
+      />
125
+      <van-field v-if="true" border v-model="form.unlawfulAct" name="可能存在的违法行为" label="可能存在的违法行为"
126
+                 type="textarea"
127
+                 :readonly="ifElseReadonly"
128
+                 autosize
129
+                 :colon="true" placeholder="可能存在的违法行为"
130
+      />
131
+
132
+      <van-field border v-model="form.measuresTaken" name="已采取的措施" label="已采取的措施"
133
+                 type="textarea"
134
+                 autosize
135
+                 :readonly="ifElseReadonly"
136
+                 :colon="true" placeholder="已采取的措施"
137
+                 required
138
+                 :rules="[{ required:true, message: '请填充内容' }]"
139
+      />
140
+
141
+      <van-field border v-model="form.otherConditions" name="其他应当报告的情况" label="其他应当报告的情况"
142
+                 type="textarea"
143
+                 autosize
144
+                 :readonly="ifElseReadonly"
145
+                 :colon="true" placeholder="其他应当报告的情况"
146
+      />
147
+      
148
+      <van-button v-if="!ifElseReadonly" block round type="primary" native-type="submit" style="margin-bottom: 5px;">
149
+        保存
150
+      </van-button>
151
+      <van-button v-if="!ifElseReadonly" block round plain type="default" @click="qvxiao">
152
+        取消
153
+      </van-button>
154
+      <div style="height: 10px;"></div>
155
+    </van-form>
156
+  </div>
157
+
158
+
159
+  <van-dialog v-model:show="showDialogVisible" title="删除文件" show-cancel-button
160
+              confirm-button-color="#ee0124" message="确定删除该文件吗?" @confirm="onDelete" />
161
+</template>
162
+
163
+<script setup>
164
+import { ref, reactive, onMounted, getCurrentInstance, nextTick, computed } from 'vue';
165
+import { closeToast, Dialog, showFailToast, showLoadingToast, showSuccessToast, showToast } from 'vant';
166
+import AttachmentS3Image from '@/components/AttachmentS3Image.vue';
167
+import AttachmentS3 from '@/components/AttachmentS3.vue';
168
+import OrganizationalWithLeafUserOne from '@/components/OrganizationalWithLeafUserOne.vue';
169
+import OrganizationalWithLeafUser from '@/components/OrganizationalWithLeafUser.vue';
170
+import OrganizationalWithLeaf from '@/components/JuBaoOrganizationalWithLeaf.vue';
171
+
172
+const { proxy } = getCurrentInstance();
173
+
174
+const onClickLeft = () => {
175
+  history.back();
176
+};
177
+
178
+/* 风险隐患排查发现隐患,进行登记代码 */
179
+const checklistForm = ref({
180
+  evaluationId: '',
181
+  checklistType: '',
182
+  hiddenDangerId: ''
183
+});
184
+const saveCheckInfo = async () => {
185
+  let url = '/safe/ActivityRecords/save';
186
+  if (checklistForm.value.checklistType === 'equipment') {
187
+    url = '/safe/EquipmentRecords/save';
188
+  }
189
+  const param = {
190
+    json: JSON.stringify(checklistForm.value)
191
+  };
192
+  const res = await proxy.$axios.post(url, param);
193
+  if (res.data.code === 0) {
194
+    showSuccessToast('新增排查记录成功!');
195
+    sessionStorage.setItem('inspectionResult', '已排查');
196
+  } else {
197
+    showFailToast('操作失败!' + res.data.msg);
198
+  }
199
+};
200
+
201
+const ifElseReadonly = ref(false)
202
+const title = ref('')
203
+onMounted(async () => {
204
+  const id = proxy.$route.query.id
205
+  const flag = proxy.$route.query.flag
206
+  if('add'===flag){
207
+    title.value='新增事故信息'
208
+  }else if ('edit'===flag){
209
+    title.value='修改事故信息'
210
+  }else {
211
+    title.value='查看事故信息'
212
+  }
213
+  if(id){
214
+    const res = await proxy.$axios.get('/sgsafe/AccidentDirect/queryFormById', {
215
+      id
216
+    });
217
+    if(res.data.code === 0){
218
+      form.value = res.data.data
219
+    }else {
220
+      showToast({
221
+        type: 'fail',
222
+        message: '操作失败'+res.data.msg
223
+      })
224
+    }
225
+    if(flag === 'look'){
226
+      ifElseReadonly.value = true
227
+    }
228
+  }
229
+});
230
+
231
+const getTimeFormatter = (date) => {
232
+  const year = date.getFullYear();
233
+  const month = String(date.getMonth() + 1).padStart(2, '0'); // 月份从 0 开始,需加 1
234
+  const day = String(date.getDate()).padStart(2, '0');
235
+  const hours = String(date.getHours()).padStart(2, '0');
236
+  const minutes = String(date.getMinutes()).padStart(2, '0');
237
+  const seconds = String(date.getSeconds()).padStart(2, '0');
238
+  return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
239
+};
240
+
241
+/**表单*/
242
+const form = ref({
243
+  seriousInjuryCount:'',//重伤人数
244
+  deathCount:'',//死亡人数
245
+  economicLoss:'',//经济损失
246
+  accidentLevel:'',//事故等级
247
+});
248
+
249
+const showPicker = ref(false);
250
+
251
+const onConfirmYhlx = ({ selectedOptions }) => {
252
+  showPicker.value = false;
253
+  form.value.accidentType = selectedOptions[0].value;
254
+  console.log('选择的内容', form.value);
255
+};
256
+
257
+const yhlxs = ref([{text: '泄露', value: '泄露'},
258
+  {text: '坍塌', value: '坍塌'},
259
+  {text: '灼烫', value: '灼烫'},
260
+  {text: '触电', value: '触电'},
261
+  {text: '机械伤害', value: '机械伤害'},
262
+  {text: '高处坠落', value: '高处坠落'},
263
+  {text: '中毒窒息', value: '中毒窒息'},
264
+  {text: '容器爆炸', value: '容器爆炸'},
265
+  {text: '爆炸', value: '爆炸'},
266
+  {text: '火灾', value: '火灾'}]
267
+);
268
+
269
+const showDatetimePicker = ref(false);
270
+const currentDate = ref();
271
+const currentTime = ref();
272
+const minDate = ref();
273
+const maxDate = ref();
274
+
275
+const dateOrTime = ref(false);
276
+const onDateConfirm = () => {
277
+  // 日期选择确认后的处理
278
+  dateOrTime.value = true;
279
+};
280
+
281
+const onTimeConfirm = () => {
282
+  // 时间选择确认后的处理
283
+};
284
+
285
+const resetDatetime = () => {
286
+  dateOrTime.value = false;
287
+
288
+  // 初始化日期和时间
289
+  if (form.value.accidentTime) {
290
+    const dt = new Date(form.value.accidentTime);
291
+    currentDate.value = [dt.getFullYear(), dt.getMonth() + 1, dt.getDate()];
292
+    currentTime.value = [
293
+      String(dt.getHours()).padStart(2, '0'),
294
+      String(dt.getMinutes()).padStart(2, '0'),
295
+      String(dt.getSeconds()).padStart(2, '0')
296
+    ];
297
+  } else {
298
+    const now = new Date();
299
+    currentDate.value = [now.getFullYear(), now.getMonth() + 1, now.getDate()];
300
+    currentTime.value = [
301
+      String(now.getHours()).padStart(2, '0'),
302
+      String(now.getMinutes()).padStart(2, '0'),
303
+      String(now.getSeconds()).padStart(2, '0')
304
+    ];
305
+  }
306
+};
307
+
308
+const onConfirmDatetime = () => {
309
+  const year = currentDate.value[0];
310
+  const month = currentDate.value[1].toString().padStart(2, '0');
311
+  const day = currentDate.value[2].toString().padStart(2, '0');
312
+  const hours = currentTime.value[0].toString().padStart(2, '0');
313
+  const minutes = currentTime.value[1].toString().padStart(2, '0');
314
+  const seconds = currentTime.value[2].toString().padStart(2, '0');
315
+
316
+  form.value.accidentTime = `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
317
+  showDatetimePicker.value = false;
318
+  dateOrTime.value = false;
319
+};
320
+
321
+const showPicker2 = ref(false);
322
+
323
+const onConfirmYhdj = ({ selectedOptions }) => {
324
+  showPicker2.value = false;
325
+  form.value.hdLevel = selectedOptions[0].value;
326
+  console.log('选择的内容', form.value);
327
+};
328
+
329
+const yhdjs = ref([{ text: '一般隐患', value: '一般隐患' },
330
+  { text: '重大隐患', value: '重大隐患' }]
331
+);
332
+
333
+const formRef = ref(null);
334
+const qvxiao = () => {
335
+  showToast({
336
+    type: 'fail',
337
+    message: '操作取消!'
338
+  });
339
+  onClickLeft();
340
+};
341
+const baocun = async () => {
342
+  form.value.accidentLevel = accidentLevel
343
+  // 原有保存逻辑保持不变
344
+  var url = 'sgsafe/AccidentDirect/save';
345
+  var param = {
346
+    json: JSON.stringify(form.value)
347
+  };
348
+  const response = await proxy.$axios.post(url, param);
349
+  if (response.data.code === 0) {
350
+    showToast({
351
+      type: 'success',
352
+      message: '保存成功!'
353
+    });
354
+    onClickLeft();
355
+  } else {
356
+    showToast({
357
+      type: 'fail',
358
+      message: '操作失败!'
359
+    });
360
+  }
361
+};
362
+
363
+const handleChangeHdSelect = (value) => {
364
+  form.value.hdSelect = value;
365
+  if (value === '隐患举报') {
366
+    isStandardFlow.value = true;
367
+  } else if (value === '即查即改') {
368
+    isStandardFlow.value = false;
369
+  }
370
+  getYHID();
371
+};
372
+
373
+const guid = () => {
374
+  function S4() {
375
+    return (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1);
376
+  }
377
+
378
+  return (S4() + S4() + S4() + S4() + S4() + S4() + S4() + S4());
379
+};
380
+/* 发现人 */
381
+const leaderKey = guid();
382
+const PopupDepartmentLeaderNameRef = ref();
383
+const handleDepartmentLeaderName = () => {
384
+  PopupDepartmentLeaderNameRef.value.open();
385
+};
386
+
387
+const codeAndDesc = ref([]);
388
+const getDepartmentLeaderName = (item) => {
389
+  form.value.discoverer = item.user.userCode;
390
+  form.value.discovererDesc = item.user.userDesc;
391
+  form.value.discovererDeptCode = item.dept.deptCode;
392
+  form.value.discovererDept = item.dept.deptName;
393
+};
394
+
395
+/* 其他发现人 */
396
+const leaderKey2 = guid();
397
+const PopupDepartmentLeaderNameRef2 = ref();
398
+const handleDepartmentLeaderName2 = () => {
399
+  PopupDepartmentLeaderNameRef2.value.open();
400
+};
401
+
402
+const codeAndDesc2 = ref([]);
403
+const getDepartmentLeaderName2 = (items) => {
404
+  console.log('人员数据', items);
405
+  let codeList = [];
406
+  let descList = [];
407
+  for (let item of items) {
408
+    codeAndDesc2.value.push(item.userCode + '-' + item.userDesc);
409
+    codeList.push(item.userCode);
410
+    descList.push(item.userDesc);
411
+  }
412
+  form.value.discovererOther = codeList.join(',');
413
+  form.value.discovererOtherDesc = descList.join(',');
414
+};
415
+
416
+//定义一个变量切换即查即改还是标准流程
417
+const isStandardFlow = ref(true);
418
+
419
+//当是即查即改时得到隐患编号并赋值
420
+const getYHID = () => {
421
+  //直接请求后端返回一个隐患编号
422
+  console.log('getYHID');
423
+  if (form.value.hdSelect === '即查即改') {
424
+    var url = 'safe/JuBaoHiddendanger/getYhbhTemp';
425
+    var param = {};
426
+    proxy.$axios.get(url, param).then(response => {
427
+      if (response.data.code == '0') {
428
+        form.value.hdId = response.data.data;
429
+      } else {
430
+        ElMessage.error('操作失败!' + response.data.msg);
431
+      }
432
+    });
433
+  } else {
434
+    form.value.hdId = '';
435
+  }
436
+};
437
+
438
+/* 整改人 */
439
+const leaderKeyzgr = guid();
440
+const PopupDepartmentLeaderNameRefzgr = ref();
441
+const handleDepartmentLeaderNamezgr = () => {
442
+  PopupDepartmentLeaderNameRefzgr.value.open();
443
+};
444
+
445
+const codeAndDesczgr = ref([]);
446
+const getDepartmentLeaderNamezgr = (item) => {
447
+  form.value.repairLeader = item.user.userCode;
448
+  form.value.repairLeaderDesc = item.user.userDesc;
449
+  form.value.repairDept = item.dept.deptName;
450
+};
451
+
452
+/* 其他整改人 */
453
+const leaderKey2qtzgr = guid();
454
+const PopupDepartmentLeaderNameRef2qtzgr = ref();
455
+const handleDepartmentLeaderName2qtzgr = () => {
456
+  PopupDepartmentLeaderNameRef2qtzgr.value.open();
457
+};
458
+
459
+const codeAndDesc2qtzgr = ref([]);
460
+const getDepartmentLeaderName2qtzgr = (items) => {
461
+  console.log('人员数据', items);
462
+  let codeList = [];
463
+  let descList = [];
464
+  for (let item of items) {
465
+    codeAndDesc2qtzgr.value.push(item.userCode + '-' + item.userDesc);
466
+    codeList.push(item.userCode);
467
+    descList.push(item.userDesc);
468
+  }
469
+  form.value.repairOther = codeList.join(',');
470
+  form.value.repairOtherDesc = descList.join(',');
471
+};
472
+
473
+/* 组织树选择 */
474
+const showBottom = ref(false);
475
+const handleTableDataUserDeptUpdate = async (nodeData) => {
476
+  let temp = nodeData.split('-');
477
+  if(temp[0].length<9){
478
+    showFailToast('请选择四级及以下部门')
479
+    return
480
+  }
481
+  form.value.hdLocation = temp[1];
482
+  form.value.hdLocationCode = temp[0];
483
+  form.value.hdConfirm = temp[2]
484
+  // form.value.repairDept = nodeData.deptCode + '-' + nodeData.deptName
485
+  showBottom.value = false;
486
+};
487
+const showPickerHandle = () => {
488
+  showBottom.value = true;
489
+};
490
+
491
+/**表单*/
492
+
493
+/***********************新图******************************/
494
+//公共区
495
+import { atob } from 'js-base64';
496
+
497
+const bucket = ref(import.meta.env.VITE_BUCKET);
498
+
499
+function base64ToBlob(base64) {
500
+  const contentType = base64.substring(base64.indexOf(':') + 1, base64.indexOf(';'));
501
+  const byteCharacters = atob(base64);
502
+  const byteArrays = [];
503
+
504
+  for (let i = 0; i < byteCharacters.length; i++) {
505
+    byteArrays.push(byteCharacters.charCodeAt(i));
506
+  }
507
+
508
+  const byteArray = new Uint8Array(byteArrays);
509
+  return new Blob([byteArray], { type: contentType });
510
+}
511
+
512
+const headers = ref({
513
+  token: localStorage.getItem('token'),
514
+  userId: localStorage.getItem('userId')
515
+});
516
+
517
+//整改前
518
+const fileList = ref([]);
519
+const afterRead = (file) => {
520
+  const content = base64ToBlob(file.content);
521
+  const formData = new FormData();
522
+  formData.append('fId', form.value.hdPicId);
523
+  formData.append('bucket', bucket.value);
524
+  formData.append('value1', null);
525
+  formData.append('value2', null);
526
+  formData.append('value3', null);
527
+  formData.append('value4', null);
528
+  formData.append('value5', null);
529
+  formData.append('file', content, file.file.name);
530
+  let url = import.meta.env.VITE_BASE_API + '/framework/Common/uploadFileS3';
531
+  proxy.$axios.post(url, formData, { headers: headers.value }).then(res => {
532
+    if (res.data.code === 0) {
533
+      showSuccessToast('上传成功');
534
+      getTableData();
535
+    } else {
536
+      showFailToast('上传失败' + res.data.msg);
537
+    }
538
+  }).catch(error => {
539
+    console.log(error);
540
+  });
541
+};
542
+const getTableData = () => {
543
+  //携带自定义参数
544
+  var url = 'framework/Common/queryFileWithValues';
545
+  var param = {
546
+    fId: form.value.hdPicId, //必填
547
+    value1: null, //非必填
548
+    value2: null, //非必填
549
+    value3: null, //非必填
550
+    value4: null, //非必填
551
+    value5: null //非必填
552
+  };
553
+  proxy.$axios.get(url, param).then(response => {
554
+    if (response.data.code === 0) {
555
+      for (var item of response.data.data) {
556
+        fileList.value.push({
557
+          id: item.id,
558
+          uploadFile: item.fileName,
559
+          url: import.meta.env.VITE_BASE_API +
560
+            '/framework/Common/downloadFileS3?bucket=' + bucket.value +
561
+            '&id=' + item.id
562
+        });
563
+        form.value.picBefore = fileList.value[0].url;
564
+      }
565
+    } else {
566
+      showFailToast('失败!' + response.data.msg);
567
+    }
568
+  });
569
+};
570
+/* 在线删除 */
571
+const showDialogVisible = ref(false);
572
+const deleteInfo = ref();
573
+const handleDelete = (row) => {
574
+  showDialogVisible.value = true;
575
+  deleteInfo.value = row;
576
+};
577
+const onDelete = () => {
578
+  let url = 'framework/Common/removeFile';
579
+  let param = {
580
+    id: deleteInfo.value.id
581
+  };
582
+  proxy.$axios.post(url, param).then(response => {
583
+    if (response.data.code === 0) {
584
+      showSuccessToast('删除成功!');
585
+      getTableData();
586
+    } else {
587
+      showFailToast('删除失败;' + response.data.msg);
588
+    }
589
+  });
590
+};
591
+
592
+//隐患选择
593
+const selectOption = (option) => {
594
+  if (form.value.workId.length > 0) {
595
+    return;
596
+  }
597
+  form.value.hdSelect = option;
598
+  if (option === '隐患举报') {
599
+    isStandardFlow.value = true;
600
+  } else if (option === '即查即改') {
601
+    isStandardFlow.value = false;
602
+  }
603
+  getYHID();
604
+};
605
+
606
+/**修改发现时间**/
607
+// 日期选择器取消
608
+const cancelDatePicker = () => {
609
+  showDatetimePicker.value = false;
610
+  resetDatetime();
611
+};
612
+
613
+// 时间选择器取消
614
+const cancelTimePicker = () => {
615
+  resetDatetime();
616
+  // 重置为当前时间或从表单获取时间
617
+  if (form.value.accidentTime) {
618
+    const dt = new Date(form.value.accidentTime);
619
+    currentTime.value = [
620
+      String(dt.getHours()).padStart(2, '0'),
621
+      String(dt.getMinutes()).padStart(2, '0'),
622
+      String(dt.getSeconds()).padStart(2, '0')
623
+    ];
624
+  } else {
625
+    const now = new Date();
626
+    currentTime.value = [
627
+      String(now.getHours()).padStart(2, '0'),
628
+      String(now.getMinutes()).padStart(2, '0'),
629
+      String(now.getSeconds()).padStart(2, '0')
630
+    ];
631
+  }
632
+};
633
+/**修改发现时间**/
634
+
635
+/**控制显示**/
636
+const showSeriousInjuryCount = ref(false)
637
+const showDeathCount = ref(false)
638
+const showEconomicLoss = ref(false)
639
+
640
+/**控制输入**//*
641
+const onInput = (value) =>{
642
+  console.log('输入的值', value)
643
+  // 1. 过滤所有非数字和非小数点的字符(只保留数字和一个小数点)
644
+  // let value = val.replace(/[^\d.]/g, '');
645
+
646
+  // 2. 处理多个小数点:只保留第一个小数点,后续的小数点删除
647
+  // const dotIndex = value.indexOf('.');
648
+  if (value !== -1) {
649
+    // 从第一个小数点后开始,删除所有其他小数点
650
+    value = value.slice(0, dotIndex + 1) + value.slice(dotIndex + 1).replace(/\./g, '');
651
+  }
652
+
653
+  // 3. 处理开头为小数点的情况:自动补0(如 .123 → 0.123)
654
+  if (value.startsWith('.')) {
655
+    value = '0' + value;
656
+  }
657
+
658
+  // 4. 限制小数位最多3位:如果有小数点,截取小数点后前3位
659
+  if (value.includes('.')) {
660
+    const parts = value.split('.');
661
+    // 整数部分 + 小数点 + 小数部分前3位
662
+    value = parts[0] + '.' + (parts[1] || '').slice(0, 3);
663
+  }
664
+
665
+  // 5. 赋值给表单(避免空值时显示undefined)
666
+  form.value.economicLoss = value || '';
667
+}*/
668
+
669
+/**控制键盘删除**/
670
+const cKeyDelete = () => {
671
+  if (!form.value.economicLoss) return; // 为空时不操作
672
+
673
+  // 截取掉最后一个字符
674
+  let value = form.value.economicLoss.slice(0, -1);
675
+
676
+  // 处理删除后可能出现的不合理格式(比如只剩小数点)
677
+  if (value === '.') {
678
+    value = ''; // 如果删除后只剩小数点,清空
679
+  }
680
+
681
+  form.value.economicLoss = value;
682
+}
683
+
684
+/**计算属性**/
685
+//计算属性
686
+const accidentLevel = computed(()=>{
687
+  if(form.value.deathCount>=30 || form.value.economicLoss>=100000 || form.value.seriousInjuryCount>=100){
688
+    return '特别重大事故'
689
+  }else if(form.value.deathCount>=10 || form.value.economicLoss>=5000 || form.value.seriousInjuryCount>=50){
690
+    return '重大事故'
691
+  }else if(form.value.deathCount>=3 || form.value.economicLoss>=1000 || form.value.seriousInjuryCount>=10){
692
+    return '较大事故'
693
+  }else{
694
+    return '一般事故'
695
+  }
696
+})
697
+
698
+</script>
699
+
700
+<style scoped>
701
+.h5-container {
702
+  width: 100%;
703
+  box-sizing: border-box;
704
+  height: 100vh;
705
+  background-color: white;
706
+  padding: 10px;
707
+  padding-bottom: 20px;
708
+}
709
+
710
+.radio-group {
711
+  display: flex;
712
+  background-color: white;
713
+  padding: 10px;
714
+  border-radius: 5px;
715
+  margin: 10px 0;
716
+  gap: 10px;
717
+}
718
+
719
+.radio-item {
720
+  padding: 8px 12px;
721
+  border: 1px solid #222;
722
+  border-radius: 4px;
723
+  background-color: white;
724
+  cursor: pointer;
725
+  transition: background-color 0.3s ease;
726
+  /* 添加过渡效果 */
727
+}
728
+
729
+.radio-item.active {
730
+  background-color: #4285f4;
731
+  /* 选中时的蓝色 */
732
+  color: white;
733
+  border-color: #4285f4;
734
+}
735
+</style>

+ 867
- 0
src/view/accidentManager/accidentJuBao/index.vue Zobrazit soubor

@@ -0,0 +1,867 @@
1
+<template>
2
+  <div class="h5-container">
3
+    <van-nav-bar title="事故举报" @click-left="onClickLeft" @click-right="handAdd('add','XY')">
4
+      <template #right>
5
+        <van-icon name="add" size="25" color="#000" />
6
+      </template>
7
+    </van-nav-bar>
8
+    <van-search v-if="false" v-model="query.discovererDesc" show-action placeholder="请输入发现人" @search="onRefresh"
9
+      @cancel="handdelect" />
10
+
11
+    <!-- 项目列表 -->
12
+    <van-pull-refresh v-model="isRefreshing" success-text="刷新成功" @refresh="onRefresh">
13
+      <van-list v-model:loading="isLoading" :finished="isFinished" finished-text="没有更多了" offset="200" @load="onLoad">
14
+        <div v-for="(item, idx) in resultData" :key="item.id">
15
+          <van-swipe-cell @open="handleSwipeOpen(item,idx)" @close="handleSwipeClose(item,idx)" title-style="color: #007aff" style="height: 80px;" :ref="el => getSwipeCellRef(el, idx)">
16
+            <template #default>
17
+              <div class="swipe-cell-default">
18
+                <van-cell style="min-height: 100px; padding: 0 0 0 0; display: flex; align-items: flex-start;" @click="handAdd('look',item)">
19
+                  <template #title>
20
+                    <div class="cell-title">
21
+                      {{ item.hdDescription }}
22
+                    </div>
23
+                  </template>
24
+                  <template #label>
25
+                    <div>事故地点:{{ item.accidentLocation }}</div>
26
+                    <div>发生时间:{{ item.accidentTime }}</div>
27
+                    <div>事故类型:{{ item.accidentType }}</div>
28
+                    <div>事故等级:{{ item.accidentLevel }}</div>
29
+                  </template>
30
+                </van-cell>
31
+                <div class="swipe-cell-default-icon">
32
+                  <van-icon v-if="openStatus[idx]" name="arrow-double-left" @click.stop="openSwipe(idx)" />
33
+                  <van-icon v-else name="arrow-double-right" @click.stop="closeSwipe(idx)" />
34
+                </div>
35
+              </div>
36
+            </template>
37
+
38
+            <template #right>
39
+              <van-button square class="edit-button" text="编辑" @click="handAdd('edit', item)" />
40
+              <van-button square class="delete-button" text="删除" @click="handleDelete(item, idx)" />
41
+            </template>
42
+          </van-swipe-cell>
43
+        </div>
44
+
45
+      </van-list>
46
+    </van-pull-refresh>
47
+
48
+
49
+    <!-- 删除确认弹窗 -->
50
+    <van-dialog v-model:show="deleteDialogVisible" show-cancel-button @confirm="confirmDelete">
51
+      <template #title>
52
+        <div>删除确认</div>
53
+      </template>
54
+      <div style="padding: 30px;">确定要删除该事故记录吗?</div>
55
+    </van-dialog>
56
+
57
+  </div>
58
+</template>
59
+
60
+<script setup>
61
+import { ref, reactive, onMounted, getCurrentInstance, nextTick, toRaw } from 'vue';
62
+import { Dialog, showDialog, showSuccessToast, showToast, Toast } from 'vant';
63
+
64
+const { proxy } = getCurrentInstance();
65
+
66
+const onClickLeft = () => {
67
+  history.back();
68
+};
69
+const headers = ref({
70
+  token: localStorage.getItem('token'),
71
+  userId: localStorage.getItem('userId'),
72
+  dept: JSON.parse(localStorage.getItem('dept'))[0].deptCode
73
+});
74
+const switchIconState = (idx) => {
75
+  openStatus.value[idx] = !openStatus.value[idx]
76
+  openStatus.value = new Array(resultData.value.length).fill(true);
77
+}
78
+
79
+// const onClickRight = () =>{
80
+//   searchShow.value = !searchShow.value;
81
+// }
82
+
83
+const searchShow = ref(false);
84
+const query = ref({
85
+  discovererDesc: '',
86
+  hdSelect:'隐患举报'
87
+});
88
+
89
+function formatDate(date, format) {
90
+  const year = date.getFullYear();
91
+  const month = date.getMonth() + 1;
92
+  const day = date.getDate();
93
+  const hours = date.getHours();
94
+  const minutes = date.getMinutes();
95
+  const seconds = date.getSeconds();
96
+
97
+  return format
98
+    .replace('yyyy', year)
99
+    .replace('MM', month.toString().padStart(2, '0'))
100
+    .replace('dd', day.toString().padStart(2, '0'))
101
+    .replace('HH', hours.toString().padStart(2, '0'))
102
+    .replace('mm', minutes.toString().padStart(2, '0'))
103
+    .replace('ss', seconds.toString().padStart(2, '0'));
104
+}
105
+
106
+const tableData = ref([]);
107
+const selectedRows = ref([]);
108
+const dialogVisibleLook = ref(false);
109
+const deleteDialogVisible = ref(false);
110
+const currentDeleteItem = ref([]);
111
+const dialogVisible = ref(false);
112
+const dialogVisibleFile = ref(false);
113
+const date = ref(null);
114
+
115
+const kz = ref(true);
116
+const handAdd = async (flag,item) => {
117
+  if('add'===flag) {
118
+    // 将表单数据置空
119
+    resetForma();
120
+    //todo 编辑页面
121
+    proxy.$router.push({
122
+      path: '/accidentManager/accidentJuBao/accidentJuBao_edit/index',
123
+      query: {
124
+        flag:'add'
125
+      }
126
+    });
127
+  }else if('edit'===flag) { 
128
+    proxy.$router.push({
129
+      path: '/accidentManager/accidentJuBao/accidentJuBao_edit/index',
130
+      query: {
131
+        id:item.id,
132
+        flag:'edit'
133
+      }
134
+    })
135
+  }else {
136
+    proxy.$router.push({
137
+      path: '/accidentManager/accidentJuBao/accidentJuBao_edit/index',
138
+      query: {
139
+        id:item.id,
140
+        flag:'look'
141
+      }
142
+    })
143
+  }
144
+};
145
+// 定义表单数据
146
+const form = ref({
147
+  hdPicId: '',
148
+  hdId: '',
149
+  hdType: '',
150
+  discoveryTime: '',
151
+  hdSubtype: '',
152
+  discoverer: '',
153
+  discovererOther: '',
154
+  hdDescription: '',
155
+  hdLevel: '',
156
+  bz: '',
157
+  hdLocation: '',
158
+  picBefore: '',
159
+
160
+  equipmentId: '',
161
+  hdmanageLevel: '',
162
+  handlingProcesses: '',
163
+  companyId: '',
164
+  repairLeader: '',
165
+  repairOther: '',
166
+  repairSuggest: '',
167
+  repairDdl: '',
168
+  repairDept: '',
169
+  acceptLeader: '',
170
+  acceptOther: '',
171
+  picAfter: '',
172
+  picTemp: '',
173
+  repairDescription: '',
174
+  discovererDept: '',
175
+  discovererDeptCode: '',
176
+  hdLocationCode: '',
177
+  hdLocationName: '',
178
+
179
+  status: '',
180
+
181
+
182
+  hdSelect: '隐患举报',
183
+  id: ''
184
+});
185
+const resetForma = () => {
186
+  form.value = {
187
+    hdPicId: '',
188
+    hdId: '',
189
+    hdType: '',
190
+    discoveryTime: '',
191
+    hdSubtype: '',
192
+    discoverer: '',
193
+    discovererOther: '',
194
+    hdDescription: '',
195
+    hdLevel: '',
196
+    bz: '',
197
+    hdLocation: '',
198
+    picBefore: '',
199
+
200
+    equipmentId: '',
201
+    hdmanageLevel: '',
202
+    handlingProcesses: '',
203
+    companyId: '',
204
+    repairLeader: '',
205
+    repairOther: '',
206
+    repairSuggest: '',
207
+    repairDdl: '',
208
+    repairDept: '',
209
+    acceptLeader: '',
210
+    acceptOther: '',
211
+    picAfter: '',
212
+    picTemp: '',
213
+    repairDescription: '',
214
+    status: '',
215
+    discovererDept: '',
216
+    discovererDeptCode: '',
217
+    hdLocationCode: '',
218
+    hdLocationName: '',
219
+
220
+    hdSelect: '隐患举报',
221
+    id: ''
222
+  };
223
+};
224
+
225
+const isRefreshing = ref(false);
226
+const isLoading = ref(false);
227
+const isFinished = ref(false);
228
+const currentPage = ref(1);
229
+const pageSize = ref(10);
230
+const totalRows = ref(0);
231
+const resultData = ref([]);
232
+
233
+const getTableData = async () => {
234
+  const url = 'sgsafe/AccidentDirect/query';
235
+  const param = {
236
+    page: currentPage.value,
237
+    rows: pageSize.value,
238
+    params: JSON.stringify(query.value)
239
+  };
240
+  const response = await proxy.$axios.get(url, param);
241
+  if (response.data.code === 0) {
242
+    tableData.value = response.data.data.records;
243
+    totalRows.value = response.data.data.total;
244
+    // tableData.value.forEach(item => {
245
+    //   switch (item.status) {
246
+    //     case '0':
247
+    //       item.status = '隐患登记';
248
+    //       break;
249
+    //     case '1':
250
+    //       item.status = '隐患分析确认';
251
+    //       break;
252
+    //     case '2':
253
+    //       item.status = '隐患整改';
254
+    //       break;
255
+    //     case '3':
256
+    //       item.status = '隐患验收';
257
+    //       break;
258
+    //     case '4':
259
+    //       item.status = '隐患销号';
260
+    //       break;
261
+    //     case '5':
262
+    //       item.status = '结束';
263
+    //       break;
264
+    //     case '-1':
265
+    //       item.status = '待提交';
266
+    //       break;
267
+    //   }
268
+    // });
269
+  } else {
270
+    showToast({
271
+      type: 'error',
272
+      message: '操作失败!' + response.data.msg
273
+    });
274
+  }
275
+};
276
+
277
+const onRefresh = () => {
278
+  basicReset();
279
+  onLoad();
280
+};
281
+
282
+const onLoad = async () => {
283
+  if (isRefreshing.value) {
284
+    resultData.value = [];
285
+    currentPage.value = 1;
286
+    isRefreshing.value = false;
287
+  }
288
+  try {
289
+    await getTableData();
290
+    if (pageSize.value * currentPage.value < totalRows.value) {
291
+      resultData.value = [...resultData.value, ...tableData.value];
292
+      openStatus.value = new Array(resultData.value.length).fill(true);
293
+      currentPage.value++;
294
+
295
+    } else {
296
+      resultData.value = [...resultData.value, ...tableData.value];
297
+      openStatus.value = new Array(resultData.value.length).fill(true);
298
+      isFinished.value = true;
299
+    }
300
+  } catch (error) {
301
+    console.log(error);
302
+    isFinished.value = true;
303
+  } finally {
304
+    isLoading.value = false;
305
+  }
306
+};
307
+/* 通用方法: 重置list数据 */
308
+const basicReset = () => {
309
+  isFinished.value = false;
310
+  isLoading.value = true;
311
+  currentPage.value = 1;
312
+  resultData.value = [];
313
+};
314
+
315
+/*onMounted(() => {
316
+  handleSearch();
317
+});
318
+
319
+const handleSearch = () => {
320
+/!*  currentPage.value = 1;
321
+  isFinished.value = false;
322
+  tableData.value = [];*!/
323
+  basicReset()
324
+  onLoad()
325
+};*/
326
+
327
+const handdelect = () => {
328
+  query.value.discoverer = '';
329
+  onRefresh()
330
+};
331
+
332
+const handleDetailLook = (row) => {
333
+  form.value = { ...row };
334
+  proxy.$router.push({
335
+    name: 'taiZhang_detail',
336
+    query: {
337
+      form: form.value.id
338
+    }
339
+  });
340
+  // dialogVisibleLook.value = true;
341
+};
342
+const deleteId = ref('')
343
+const handleDelete = (item, idx) => {
344
+  openStatus.value[idx] = !openStatus.value[idx]
345
+  openStatus.value = new Array(resultData.value.length).fill(true);
346
+  deleteId.value = item.id
347
+  deleteDialogVisible.value = true;
348
+};
349
+
350
+const confirmDelete = () => {
351
+  var url = 'sgsafe/AccidentDirect/remove';
352
+  var param = {
353
+    id: deleteId.value
354
+  };
355
+  proxy.$axios.get(url, param).then(response => {
356
+    if (response.data.code == 0) {
357
+      showToast({
358
+        type: 'success',
359
+        message: '删除成功'
360
+      });
361
+      onRefresh();
362
+    } else {
363
+      showToast({
364
+        type: 'fail',
365
+        message: '操作失败!' + response.data.msg
366
+      });
367
+    }
368
+  });
369
+};
370
+
371
+const edits = (row) => {
372
+  form.value = { ...row };
373
+  if (row.workId) {
374
+    sessionStorage.setItem('workflowQuery', JSON.stringify({
375
+      flowId: row.flowId,
376
+      workId: row.workId,
377
+      trackId: row.trackId,
378
+      // subjectionId: '0703E25C35BD11B2A553E9317BF53B18',
379
+      // subjectionId: '0703E25C35BD11B2A553E9317BF53B18',
380
+      type: '1',
381
+      date: new Date().getTime()
382
+    }));
383
+    proxy.$router.push({
384
+      path: '/yinhuan/JuBaohdLedger_detail'
385
+    });
386
+  } else {
387
+    proxy.$router.push({
388
+      path: '/yinhuan/JuBaoregistration_edit/index',
389
+      query: {
390
+        id: form.value.id
391
+      }
392
+    });
393
+  }
394
+
395
+};
396
+
397
+
398
+const resetForm = () => {
399
+  form.value = {
400
+    projectName: '',
401
+    projectLeader: '',
402
+    phone: '',
403
+    dept: ''
404
+  };
405
+};
406
+
407
+const baocun = () => {
408
+  nextTick(() => {
409
+    if (form.value.hdSelect === '隐患举报') {
410
+      form.value.status = '0';
411
+    } else if (form.value.hdSelect === '下发隐患') {
412
+      form.value.status = '2';
413
+    } else {
414
+      form.value.status = '-1';
415
+    }
416
+  });
417
+  // 原有保存逻辑保持不变
418
+  var url = 'sgsafe/JuBaoHiddendanger/save';
419
+  var param = {
420
+    json: JSON.stringify(form.value)
421
+  };
422
+  proxy.$axios.post(url, param).then(response => {
423
+    if (response.data.code == '0') {
424
+      showSuccessToast('保存成功!');
425
+      getTableData();
426
+      orJsons();
427
+      // clearDeptUsers()
428
+    } else {
429
+      showToast({
430
+        type: 'fail',
431
+        message: '操作失败!' + response.data.msg
432
+      });
433
+    }
434
+  });
435
+};
436
+
437
+//处理人员code
438
+const repairLL = ref('');
439
+const repairOO = ref('');
440
+const acceptLL = ref('');
441
+const orJsons = () => {
442
+  // console.log('forms',form.value)
443
+  if (form.value.hdSelect === '隐患举报') {
444
+    nextTick(() => {
445
+      nextTick(() => {
446
+        repairLL.value = qq('repairLL', form.value.discoverer);//隐患发现人
447
+        nextTick(() => {
448
+          repairOO.value = qq('repairOO', form.value.discovererOther);//其他隐患发现人
449
+          nextTick(() => {
450
+            acceptLL.value = qq('acceptLL', form.value.discoverer);//隐患销号人
451
+          });
452
+        });
453
+      });
454
+
455
+      // acceptOO.value = qq('acceptOO', form.value.acceptOther)
456
+    });
457
+  } else {
458
+    // console.log('noiajdoifjpoewjfopjp')
459
+    nextTick(() => {
460
+      nextTick(() => {
461
+        repairLL.value = qq('repairLL', form.value.acceptLeader);//隐患发现人
462
+        nextTick(() => {
463
+          repairOO.value = qq('repairOO', form.value.acceptOther);//其他隐患发现人
464
+          nextTick(() => {
465
+            acceptLL.value = qq('acceptLL', form.value.discoverer);//隐患销号人
466
+          });
467
+        });
468
+      });
469
+
470
+      // acceptOO.value = qq('acceptOO', form.value.acceptOther)
471
+    });
472
+  }
473
+};
474
+
475
+const jsons = ref({});
476
+const qq = (a, val) => {
477
+  let aa = '';
478
+  var url = 'sgsafe/JuBaoHiddendanger/qqId';
479
+  var param = {
480
+    params: val
481
+  };
482
+  proxy.$axios.post(url, param).then(response => {
483
+    if (response.data.code == 0) {
484
+
485
+      aa = response.data.data;
486
+      switch (a) {
487
+        case 'repairLL':
488
+          repairLL.value = response.data.data;
489
+          // console.log('repairLL',repairLL.value);
490
+          break;
491
+        case 'repairOO':
492
+          repairOO.value = response.data.data;
493
+          // console.log('repairOO',repairLL.value);
494
+          break;
495
+        case 'acceptLL':
496
+          acceptLL.value = response.data.data;
497
+          // console.log('acceptLL',repairLL.value);
498
+          break;
499
+        default:
500
+          break;
501
+      }
502
+      jsons.value = {
503
+        hdConfirm: repairLL.value,
504
+        hdConfirmO: repairOO.value,
505
+        hdCancel: acceptLL.value
506
+      };
507
+
508
+      // 处理函数
509
+      function processValue(value) {
510
+        // 将逗号替换为分号
511
+        const replacedValue = value.replace(/,/g, ';');
512
+        // 分割值
513
+        const parts = replacedValue.split(';');
514
+        // 每个部分前加上 U_
515
+        const processedParts = parts.map(part => `U_${part.trim()}`);
516
+        // 重新组合
517
+        return processedParts.join(';');
518
+      }
519
+
520
+      // 处理整个对象
521
+      const processedData = {};
522
+      for (const key in jsons.value) {
523
+        if (jsons.value.hasOwnProperty(key)) {
524
+          processedData[key] = processValue(jsons.value[key]);
525
+        }
526
+      }
527
+
528
+      console.log('对象', toRaw(processedData));
529
+
530
+      let b = {
531
+        acceptL: processedData.hdConfirm,
532
+        acceptO: processedData.hdConfirmO,
533
+        id: form.value.id
534
+      };
535
+
536
+      if (form.value.hdSelect === '即查即改') {
537
+        b = {
538
+          hdFxr: processedData.hdCancel,
539
+          id: form.value.id
540
+        };
541
+      }
542
+
543
+      if (form.value.hdSelect === '隐患举报') {
544
+        b = {
545
+          // hdConfirm: processedData.hdConfirm,
546
+          // hdConfirmO: processedData.hdConfirmO,
547
+          id: form.value.id
548
+        };
549
+      }
550
+
551
+      const aaa = JSON.stringify(toRaw(b));
552
+      sessionStorage.setItem('variables', aaa);
553
+      console.log('aaa', aaa);
554
+    } else {
555
+      showToast({
556
+        type: 'fail',
557
+        message: '操作失败!' + response.data.msg
558
+      });
559
+    }
560
+  });
561
+  return aa;
562
+};
563
+
564
+const reback = () => {
565
+  // 返回逻辑
566
+};
567
+
568
+const deleteRow = (row) => {
569
+  selectedRows.value = [row];
570
+  handleDelete(row);
571
+};
572
+
573
+const deleteRowa = (row) => {
574
+  deleteRow(row);
575
+};
576
+
577
+const bm = (val) => {
578
+  // 部门选择逻辑
579
+};
580
+
581
+//提交审批流程
582
+import { workflowSubmit, workflowCancel } from '@/tools/workflow.js';
583
+
584
+const flowId = ref('');
585
+flowId.value = 'hdRwardReportingId';
586
+const handleSubmit2 = (val, idx) => {
587
+  openStatus.value[idx] = !openStatus.value[idx]
588
+  openStatus.value = new Array(resultData.value.length).fill(true);
589
+  console.log('提交');
590
+  console.log('selectedRows', selectedRows.value);
591
+  let row = val;
592
+  form.value = { ...row }
593
+  form.value.workCreate = headers.value.dept;
594
+
595
+  let b = {
596
+    id: form.value.id,
597
+    hdConfirm:form.value.hdConfirm
598
+  }
599
+  const aaa = JSON.stringify(toRaw(b))
600
+  sessionStorage.setItem('variables', aaa)
601
+
602
+  if (form.value.hdSelect === '隐患举报') {
603
+    flowId.value = 'hdRwardReportingId'
604
+  } 
605
+
606
+  console.log('----');
607
+  console.log(flowId.value);
608
+  console.log(sessionStorage.getItem('variables'));
609
+  console.log(row.workId);
610
+  console.log(row.trackId);
611
+  let titles = '隐患举报'
612
+  showDialog({
613
+    title: '提示',
614
+    message: '确定提交审批?',
615
+    showCancelButton: true,
616
+    confirmButtonText: '确定',
617
+    type: 'warning',
618
+    cancelButtonText: '取消'
619
+  }
620
+  ).then(() => {
621
+    return workflowSubmit(
622
+      flowId.value,
623
+      '隐患举报',
624
+      '初始化提交',
625
+      // JSON.stringify({}),
626
+      sessionStorage.getItem('variables'),
627
+      row.workId,
628
+      row.trackId);
629
+  }).then((result) => {
630
+    if (result.status === 'success') {
631
+      // 将结果返回的workId和trackId保存
632
+      var url = 'sgsafe/JuBaoHiddendanger/saveProcessInfo';
633
+      console.log('id', result, row.id);
634
+      var process = {
635
+        'id': form.value.id,
636
+        'workId': result.workId,
637
+        'trackId': result.trackId
638
+      };
639
+      var param = {
640
+        json: JSON.stringify(process)
641
+      };
642
+      proxy.$axios.post(url, param).then(response => {
643
+        if (response.data.code === 0) {
644
+          form.value = response.data.data;
645
+          console.log('我要进来啦保存成功');
646
+          showToast({
647
+            type: 'success',
648
+            message: '提交审批成功'
649
+          });
650
+          onRefresh()
651
+        }
652
+      });
653
+    } else {
654
+      showToast({
655
+        type: 'error',
656
+        message: '提交审批失败,' + result.msg
657
+      });
658
+    }
659
+  }).catch(() => {
660
+    showToast({
661
+      type: 'info',
662
+      message: '已取消提交'
663
+    });
664
+  });
665
+};
666
+
667
+
668
+const getStatusClass = (status) => {
669
+  switch (status) {
670
+    case '-1':
671
+      return 'status-pending';
672
+    case '0':
673
+      return 'status-registered';
674
+    case '1':
675
+      return 'status-analyzing';
676
+    case '2':
677
+      return 'status-rectifying';
678
+    case '3':
679
+      return 'status-accepting';
680
+    case '4':
681
+      return 'status-closed';
682
+    case '5':
683
+      return 'status-finished';
684
+    default:
685
+      return 'status-unknown';
686
+  }
687
+};
688
+
689
+/**
690
+ * 按钮实现swipe-cell滑动
691
+ */
692
+const openStatus = ref([])
693
+const swipeCellRefs = ref([])
694
+const getSwipeCellRef = (el, index) => {
695
+  if (el) {
696
+    swipeCellRefs.value[index] = el;
697
+  }
698
+}
699
+const openSwipe = (idx) => {
700
+  openStatus.value = new Array(resultData.value.length).fill(true);
701
+  if (idx >= 0 && idx < swipeCellRefs.value.length) {
702
+    openStatus.value[idx] = false
703
+    swipeCellRefs.value[idx].open('right')
704
+  }
705
+  document.addEventListener('click', handleDocumentClick)
706
+}
707
+/**
708
+ * 当点击滑动单元格时,开始监听点击事件
709
+ */
710
+const handleDocumentClick = (event) => {
711
+  openStatus.value = new Array(resultData.value.length).fill(true);
712
+}
713
+
714
+const closeSwipe = (idx) => {
715
+  if (idx >= 0 && idx < swipeCellRefs.value.length) {
716
+    openStatus.value[idx] = true
717
+    swipeCellRefs.value[idx].close()
718
+  }
719
+}
720
+
721
+/**滑动监听**/
722
+const handleSwipeOpen = (item,idx) =>{
723
+  console.log('handleSwipeOpen', idx)
724
+  console.log('handleSwipeOpen数据', item)
725
+  openStatus.value[idx] = false
726
+}
727
+
728
+const handleSwipeClose = (item,idx) =>{
729
+  openStatus.value[idx] = true
730
+  console.log('handleSwipeClose', idx)
731
+  console.log('handleSwipeClose数据', item)
732
+}
733
+
734
+</script>
735
+
736
+<style scoped>
737
+.h5-container {
738
+  width: 100%;
739
+  padding: 5px;
740
+  box-sizing: border-box;
741
+}
742
+
743
+.status-pending {
744
+  background-color: #fff3cd;
745
+  color: #856404;
746
+  padding: 2px 4px;
747
+  border-radius: 4px;
748
+}
749
+
750
+.status-registered {
751
+  background-color: #d1ecf1;
752
+  color: #0c5460;
753
+  padding: 2px 4px;
754
+  border-radius: 4px;
755
+}
756
+
757
+.status-analyzing {
758
+  background-color: #fff8e1;
759
+  color: #ff8f00;
760
+  padding: 2px 4px;
761
+  border-radius: 4px;
762
+}
763
+
764
+.status-rectifying {
765
+  background-color: #e8f5e9;
766
+  color: #2e7d32;
767
+  padding: 2px 4px;
768
+  border-radius: 4px;
769
+}
770
+
771
+.status-accepting {
772
+  background-color: #e3f2fd;
773
+  color: #1565c0;
774
+  padding: 2px 4px;
775
+  border-radius: 4px;
776
+}
777
+
778
+.status-closed {
779
+  background-color: #f8bbd0;
780
+  color: #b71c1c;
781
+  padding: 2px 4px;
782
+  border-radius: 4px;
783
+}
784
+
785
+.status-finished {
786
+  background-color: #e8eaf6;
787
+  color: #311b92;
788
+  padding: 2px 4px;
789
+  border-radius: 4px;
790
+}
791
+
792
+.status-unknown {
793
+  background-color: #efebe9;
794
+  color: #424242;
795
+  padding: 2px 4px;
796
+  border-radius: 4px;
797
+}
798
+
799
+.cell-title {
800
+  display: -webkit-box;
801
+  /* 旧版弹性盒子模型 */
802
+  -webkit-box-orient: vertical;
803
+  /* 内容垂直排列 */
804
+  -webkit-line-clamp: 2;
805
+  /* 限制显示行数 */
806
+  overflow: hidden;
807
+  /* 超出隐藏 */
808
+  text-overflow: ellipsis;
809
+  /* 省略号 */
810
+  line-height: 1.5;
811
+  /* 可选:设置行高 */
812
+  max-height: calc(1.5em * 3);
813
+  /* 可选:根据行高限制最大高度 */
814
+  font-size: 16px;
815
+  font-weight: bold;
816
+  color: #333;
817
+  /* 字号 */
818
+}
819
+
820
+.swipe-cell-default {
821
+  display: flex;
822
+  background-color: #ffffff;
823
+  justify-content: center;
824
+  align-items: center;
825
+}
826
+
827
+.swipe-cell-default-icon {
828
+  width: 60px;
829
+  display: flex;
830
+  justify-content: center;
831
+}
832
+
833
+.delete-button {
834
+  height: 100%;
835
+  border: none;
836
+  color: #ff0000;
837
+  background-image: url('@/assets/img/del.png');
838
+  background-size: auto 100%;
839
+  background-repeat: no-repeat;
840
+}
841
+.edit-button {
842
+  height: 100%;
843
+  border: none;
844
+  color: #F9CC9D;
845
+  background-image: url('@/assets/img/edit.png');
846
+  background-size: auto 100%;
847
+  background-repeat: no-repeat;
848
+}
849
+
850
+.submit-button {
851
+  height: 100%;
852
+  border: none;
853
+  color: #07c160;
854
+  background-image: url('@/assets/img/sub.png');
855
+  background-size: auto 100%;
856
+  background-repeat: no-repeat;
857
+}
858
+
859
+.subsuccess {
860
+  height: 100%;
861
+  border: none;
862
+  color: #07c160;
863
+  background-image: url('@/assets/img/sub1.png');
864
+  background-size: auto 100%;
865
+  background-repeat: no-repeat;
866
+}
867
+</style>

+ 735
- 0
src/view/accidentManager/accidentJuBaoLedger/accidentJuBao_edit/index.vue Zobrazit soubor

@@ -0,0 +1,735 @@
1
+<template>
2
+  <div class="h5-container">
3
+    <van-nav-bar :title @click-left="onClickLeft">
4
+    </van-nav-bar>
5
+    <van-form @submit="baocun" ref="formRef">
6
+      <van-field :readonly="ifElseReadonly" border v-model="form.accidentLocation" name="事故地点" label="事故地点"
7
+                 :colon="true" placeholder="事故地点"
8
+                 required
9
+                 :rules="[{ required:true, message: '请填充内容' }]"
10
+      />
11
+      <van-field
12
+        v-model="form.accidentTime"
13
+        is-link
14
+        readonly
15
+        name="datetime"
16
+        label="发生时间"
17
+        :colon="true"
18
+        placeholder="点击选择日期和时间"
19
+        @click="showDatetimePicker = !ifElseReadonly"
20
+        required
21
+        :rules="[{ required:true, message: '请选择内容' }]"
22
+      />
23
+      <!-- 日期时间选择器部分 -->
24
+      <van-popup
25
+        v-model:show="showDatetimePicker"
26
+        position="bottom"
27
+        round
28
+        style="max-height: 50vh;"
29
+      >
30
+        <van-date-picker
31
+          v-if="!dateOrTime"
32
+          v-model="currentDate"
33
+          title="选择日期"
34
+          :min-date="minDate"
35
+          :max-date="maxDate"
36
+          @confirm="onDateConfirm"
37
+          @cancel="cancelDatePicker"
38
+        >
39
+          <template #confirm>
40
+            <van-button type="primary" @click="onDateConfirm">下一步</van-button>
41
+          </template>
42
+          <template #cancel>
43
+            <van-button type="danger" @click="cancelDatePicker">取消</van-button>
44
+          </template>
45
+        </van-date-picker>
46
+
47
+        <van-time-picker
48
+          v-if="dateOrTime"
49
+          v-model="currentTime"
50
+          title="选择时间"
51
+          :columns-type="['hour', 'minute', 'second']"
52
+          @confirm="onConfirmDatetime"
53
+          @cancel="cancelTimePicker"
54
+        >
55
+          <template #confirm>
56
+            <van-button type="primary" @click="onConfirmDatetime">确定</van-button>
57
+          </template>
58
+          <template #cancel>
59
+            <van-button type="danger" @click="cancelTimePicker">取消</van-button>
60
+          </template>
61
+        </van-time-picker>
62
+      </van-popup>
63
+
64
+      <van-field  :readonly="ifElseReadonly" border v-model="form.sceneConditions" name="事故现场情况" label="事故现场情况"
65
+                 type="textarea"
66
+                 autosize
67
+                 :colon="true" placeholder="事故现场情况"
68
+                 required
69
+                 :rules="[{ required:true, message: '请填充内容' }]"
70
+      />
71
+      <van-field  :readonly="ifElseReadonly" border v-model="form.accidentSummary" name="事故简要经过" label="事故简要经过"
72
+                 type="textarea"
73
+                 autosize
74
+                 :colon="true" placeholder="事故简要经过"
75
+                 required
76
+                 :rules="[{ required:true, message: '请填充内容' }]"
77
+      />
78
+      
79
+      <van-field is-link :colon="true" readonly v-model="form.accidentType" required label="事故类型"
80
+                 placeholder="选择事故类型"
81
+                 @click="showPicker = !ifElseReadonly" :rules="[{ required: true, message: '请选择内容' }]" />
82
+      <van-popup :readonly="ifElseReadonly" v-model:show="showPicker" round position="bottom">
83
+        <van-picker :columns="yhlxs" @cancel="showPicker = false" @confirm="onConfirmYhlx" />
84
+      </van-popup>
85
+      <van-field v-model="form.seriousInjuryCount" name="重伤人数" label="重伤人数" :colon="true" readonly clickable @touchstart.stop="showSeriousInjuryCount = !ifElseReadonly"
86
+      required :rules="[{ required: true, message: '请输入重伤人数' }]"/>
87
+      <van-number-keyboard
88
+        :readonly="ifElseReadonly"
89
+        v-model="form.seriousInjuryCount"
90
+        :show="showSeriousInjuryCount"
91
+        @blur="showSeriousInjuryCount = false"
92
+      />
93
+      <van-field v-model="form.deathCount" name="死亡人数" label="死亡人数" :colon="true" readonly clickable @touchstart.stop="showDeathCount = !ifElseReadonly"
94
+                 required :rules="[{ required: true, message: '请输入死亡人数' }]"/>
95
+      <van-number-keyboard
96
+        :readonly="ifElseReadonly"
97
+        v-model="form.deathCount"
98
+        :show="showDeathCount"
99
+        @blur="showDeathCount = false"
100
+      />
101
+      <van-field v-model="form.economicLoss" name="事故经济损失" label="事故经济损失(万元)" :colon="true" readonly clickable @touchstart.stop="showEconomicLoss = !ifElseReadonly"
102
+                 required :rules="[{ required: true, message: '请输入事故经济损失并确认是否最多只有小数',pattern: /^\d+(\.\d{1,3})?$/ }]"/>
103
+      <van-number-keyboard
104
+        :readonly="ifElseReadonly"
105
+        v-model="form.economicLoss"
106
+        :show="showEconomicLoss"
107
+        theme="custom"
108
+        extra-key="."
109
+        close-button-text="完成"
110
+        @blur="showEconomicLoss = false"
111
+        @input="onInput"
112
+        @delete="cKeyDelete"
113
+      />
114
+      <van-field readonly border v-model="accidentLevel" name="事故等级" label="事故等级"
115
+                 :colon="true" placeholder="事故等级"
116
+      />
117
+
118
+      <van-field v-if="false" border v-model="form.unlawfulAct" name="可能存在的违法行为" label="可能存在的违法行为"
119
+                 type="textarea"
120
+                 autosize
121
+                 :colon="true" placeholder="可能存在的违法行为"
122
+                 required
123
+                 :rules="[{ required:true, message: '请填充内容' }]"
124
+      />
125
+      <van-field v-if="true" border v-model="form.unlawfulAct" name="可能存在的违法行为" label="可能存在的违法行为"
126
+                 type="textarea"
127
+                 :readonly="ifElseReadonly"
128
+                 autosize
129
+                 :colon="true" placeholder="可能存在的违法行为"
130
+      />
131
+
132
+      <van-field border v-model="form.measuresTaken" name="已采取的措施" label="已采取的措施"
133
+                 type="textarea"
134
+                 autosize
135
+                 :readonly="ifElseReadonly"
136
+                 :colon="true" placeholder="已采取的措施"
137
+                 required
138
+                 :rules="[{ required:true, message: '请填充内容' }]"
139
+      />
140
+
141
+      <van-field border v-model="form.otherConditions" name="其他应当报告的情况" label="其他应当报告的情况"
142
+                 type="textarea"
143
+                 autosize
144
+                 :readonly="ifElseReadonly"
145
+                 :colon="true" placeholder="其他应当报告的情况"
146
+      />
147
+      
148
+      <van-button v-if="!ifElseReadonly" block round type="primary" native-type="submit" style="margin-bottom: 5px;">
149
+        保存
150
+      </van-button>
151
+      <van-button v-if="!ifElseReadonly" block round plain type="default" @click="qvxiao">
152
+        取消
153
+      </van-button>
154
+      <div style="height: 10px;"></div>
155
+    </van-form>
156
+  </div>
157
+
158
+
159
+  <van-dialog v-model:show="showDialogVisible" title="删除文件" show-cancel-button
160
+              confirm-button-color="#ee0124" message="确定删除该文件吗?" @confirm="onDelete" />
161
+</template>
162
+
163
+<script setup>
164
+import { ref, reactive, onMounted, getCurrentInstance, nextTick, computed } from 'vue';
165
+import { closeToast, Dialog, showFailToast, showLoadingToast, showSuccessToast, showToast } from 'vant';
166
+import AttachmentS3Image from '@/components/AttachmentS3Image.vue';
167
+import AttachmentS3 from '@/components/AttachmentS3.vue';
168
+import OrganizationalWithLeafUserOne from '@/components/OrganizationalWithLeafUserOne.vue';
169
+import OrganizationalWithLeafUser from '@/components/OrganizationalWithLeafUser.vue';
170
+import OrganizationalWithLeaf from '@/components/JuBaoOrganizationalWithLeaf.vue';
171
+
172
+const { proxy } = getCurrentInstance();
173
+
174
+const onClickLeft = () => {
175
+  history.back();
176
+};
177
+
178
+/* 风险隐患排查发现隐患,进行登记代码 */
179
+const checklistForm = ref({
180
+  evaluationId: '',
181
+  checklistType: '',
182
+  hiddenDangerId: ''
183
+});
184
+const saveCheckInfo = async () => {
185
+  let url = '/safe/ActivityRecords/save';
186
+  if (checklistForm.value.checklistType === 'equipment') {
187
+    url = '/safe/EquipmentRecords/save';
188
+  }
189
+  const param = {
190
+    json: JSON.stringify(checklistForm.value)
191
+  };
192
+  const res = await proxy.$axios.post(url, param);
193
+  if (res.data.code === 0) {
194
+    showSuccessToast('新增排查记录成功!');
195
+    sessionStorage.setItem('inspectionResult', '已排查');
196
+  } else {
197
+    showFailToast('操作失败!' + res.data.msg);
198
+  }
199
+};
200
+
201
+const ifElseReadonly = ref(false)
202
+const title = ref('')
203
+onMounted(async () => {
204
+  const id = proxy.$route.query.id
205
+  const flag = proxy.$route.query.flag
206
+  if('add'===flag){
207
+    title.value='新增事故信息'
208
+  }else if ('edit'===flag){
209
+    title.value='修改事故信息'
210
+  }else {
211
+    title.value='查看事故信息'
212
+  }
213
+  if(id){
214
+    const res = await proxy.$axios.get('/sgsafe/AccidentDirect/queryFormById', {
215
+      id
216
+    });
217
+    if(res.data.code === 0){
218
+      form.value = res.data.data
219
+    }else {
220
+      showToast({
221
+        type: 'fail',
222
+        message: '操作失败'+res.data.msg
223
+      })
224
+    }
225
+    if(flag === 'look'){
226
+      ifElseReadonly.value = true
227
+    }
228
+  }
229
+});
230
+
231
+const getTimeFormatter = (date) => {
232
+  const year = date.getFullYear();
233
+  const month = String(date.getMonth() + 1).padStart(2, '0'); // 月份从 0 开始,需加 1
234
+  const day = String(date.getDate()).padStart(2, '0');
235
+  const hours = String(date.getHours()).padStart(2, '0');
236
+  const minutes = String(date.getMinutes()).padStart(2, '0');
237
+  const seconds = String(date.getSeconds()).padStart(2, '0');
238
+  return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
239
+};
240
+
241
+/**表单*/
242
+const form = ref({
243
+  seriousInjuryCount:'',//重伤人数
244
+  deathCount:'',//死亡人数
245
+  economicLoss:'',//经济损失
246
+  accidentLevel:'',//事故等级
247
+});
248
+
249
+const showPicker = ref(false);
250
+
251
+const onConfirmYhlx = ({ selectedOptions }) => {
252
+  showPicker.value = false;
253
+  form.value.accidentType = selectedOptions[0].value;
254
+  console.log('选择的内容', form.value);
255
+};
256
+
257
+const yhlxs = ref([{text: '泄露', value: '泄露'},
258
+  {text: '坍塌', value: '坍塌'},
259
+  {text: '灼烫', value: '灼烫'},
260
+  {text: '触电', value: '触电'},
261
+  {text: '机械伤害', value: '机械伤害'},
262
+  {text: '高处坠落', value: '高处坠落'},
263
+  {text: '中毒窒息', value: '中毒窒息'},
264
+  {text: '容器爆炸', value: '容器爆炸'},
265
+  {text: '爆炸', value: '爆炸'},
266
+  {text: '火灾', value: '火灾'}]
267
+);
268
+
269
+const showDatetimePicker = ref(false);
270
+const currentDate = ref();
271
+const currentTime = ref();
272
+const minDate = ref();
273
+const maxDate = ref();
274
+
275
+const dateOrTime = ref(false);
276
+const onDateConfirm = () => {
277
+  // 日期选择确认后的处理
278
+  dateOrTime.value = true;
279
+};
280
+
281
+const onTimeConfirm = () => {
282
+  // 时间选择确认后的处理
283
+};
284
+
285
+const resetDatetime = () => {
286
+  dateOrTime.value = false;
287
+
288
+  // 初始化日期和时间
289
+  if (form.value.accidentTime) {
290
+    const dt = new Date(form.value.accidentTime);
291
+    currentDate.value = [dt.getFullYear(), dt.getMonth() + 1, dt.getDate()];
292
+    currentTime.value = [
293
+      String(dt.getHours()).padStart(2, '0'),
294
+      String(dt.getMinutes()).padStart(2, '0'),
295
+      String(dt.getSeconds()).padStart(2, '0')
296
+    ];
297
+  } else {
298
+    const now = new Date();
299
+    currentDate.value = [now.getFullYear(), now.getMonth() + 1, now.getDate()];
300
+    currentTime.value = [
301
+      String(now.getHours()).padStart(2, '0'),
302
+      String(now.getMinutes()).padStart(2, '0'),
303
+      String(now.getSeconds()).padStart(2, '0')
304
+    ];
305
+  }
306
+};
307
+
308
+const onConfirmDatetime = () => {
309
+  const year = currentDate.value[0];
310
+  const month = currentDate.value[1].toString().padStart(2, '0');
311
+  const day = currentDate.value[2].toString().padStart(2, '0');
312
+  const hours = currentTime.value[0].toString().padStart(2, '0');
313
+  const minutes = currentTime.value[1].toString().padStart(2, '0');
314
+  const seconds = currentTime.value[2].toString().padStart(2, '0');
315
+
316
+  form.value.accidentTime = `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
317
+  showDatetimePicker.value = false;
318
+  dateOrTime.value = false;
319
+};
320
+
321
+const showPicker2 = ref(false);
322
+
323
+const onConfirmYhdj = ({ selectedOptions }) => {
324
+  showPicker2.value = false;
325
+  form.value.hdLevel = selectedOptions[0].value;
326
+  console.log('选择的内容', form.value);
327
+};
328
+
329
+const yhdjs = ref([{ text: '一般隐患', value: '一般隐患' },
330
+  { text: '重大隐患', value: '重大隐患' }]
331
+);
332
+
333
+const formRef = ref(null);
334
+const qvxiao = () => {
335
+  showToast({
336
+    type: 'fail',
337
+    message: '操作取消!'
338
+  });
339
+  onClickLeft();
340
+};
341
+const baocun = async () => {
342
+  form.value.accidentLevel = accidentLevel
343
+  // 原有保存逻辑保持不变
344
+  var url = 'sgsafe/AccidentDirect/save';
345
+  var param = {
346
+    json: JSON.stringify(form.value)
347
+  };
348
+  const response = await proxy.$axios.post(url, param);
349
+  if (response.data.code === 0) {
350
+    showToast({
351
+      type: 'success',
352
+      message: '保存成功!'
353
+    });
354
+    onClickLeft();
355
+  } else {
356
+    showToast({
357
+      type: 'fail',
358
+      message: '操作失败!'
359
+    });
360
+  }
361
+};
362
+
363
+const handleChangeHdSelect = (value) => {
364
+  form.value.hdSelect = value;
365
+  if (value === '隐患举报') {
366
+    isStandardFlow.value = true;
367
+  } else if (value === '即查即改') {
368
+    isStandardFlow.value = false;
369
+  }
370
+  getYHID();
371
+};
372
+
373
+const guid = () => {
374
+  function S4() {
375
+    return (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1);
376
+  }
377
+
378
+  return (S4() + S4() + S4() + S4() + S4() + S4() + S4() + S4());
379
+};
380
+/* 发现人 */
381
+const leaderKey = guid();
382
+const PopupDepartmentLeaderNameRef = ref();
383
+const handleDepartmentLeaderName = () => {
384
+  PopupDepartmentLeaderNameRef.value.open();
385
+};
386
+
387
+const codeAndDesc = ref([]);
388
+const getDepartmentLeaderName = (item) => {
389
+  form.value.discoverer = item.user.userCode;
390
+  form.value.discovererDesc = item.user.userDesc;
391
+  form.value.discovererDeptCode = item.dept.deptCode;
392
+  form.value.discovererDept = item.dept.deptName;
393
+};
394
+
395
+/* 其他发现人 */
396
+const leaderKey2 = guid();
397
+const PopupDepartmentLeaderNameRef2 = ref();
398
+const handleDepartmentLeaderName2 = () => {
399
+  PopupDepartmentLeaderNameRef2.value.open();
400
+};
401
+
402
+const codeAndDesc2 = ref([]);
403
+const getDepartmentLeaderName2 = (items) => {
404
+  console.log('人员数据', items);
405
+  let codeList = [];
406
+  let descList = [];
407
+  for (let item of items) {
408
+    codeAndDesc2.value.push(item.userCode + '-' + item.userDesc);
409
+    codeList.push(item.userCode);
410
+    descList.push(item.userDesc);
411
+  }
412
+  form.value.discovererOther = codeList.join(',');
413
+  form.value.discovererOtherDesc = descList.join(',');
414
+};
415
+
416
+//定义一个变量切换即查即改还是标准流程
417
+const isStandardFlow = ref(true);
418
+
419
+//当是即查即改时得到隐患编号并赋值
420
+const getYHID = () => {
421
+  //直接请求后端返回一个隐患编号
422
+  console.log('getYHID');
423
+  if (form.value.hdSelect === '即查即改') {
424
+    var url = 'safe/JuBaoHiddendanger/getYhbhTemp';
425
+    var param = {};
426
+    proxy.$axios.get(url, param).then(response => {
427
+      if (response.data.code == '0') {
428
+        form.value.hdId = response.data.data;
429
+      } else {
430
+        ElMessage.error('操作失败!' + response.data.msg);
431
+      }
432
+    });
433
+  } else {
434
+    form.value.hdId = '';
435
+  }
436
+};
437
+
438
+/* 整改人 */
439
+const leaderKeyzgr = guid();
440
+const PopupDepartmentLeaderNameRefzgr = ref();
441
+const handleDepartmentLeaderNamezgr = () => {
442
+  PopupDepartmentLeaderNameRefzgr.value.open();
443
+};
444
+
445
+const codeAndDesczgr = ref([]);
446
+const getDepartmentLeaderNamezgr = (item) => {
447
+  form.value.repairLeader = item.user.userCode;
448
+  form.value.repairLeaderDesc = item.user.userDesc;
449
+  form.value.repairDept = item.dept.deptName;
450
+};
451
+
452
+/* 其他整改人 */
453
+const leaderKey2qtzgr = guid();
454
+const PopupDepartmentLeaderNameRef2qtzgr = ref();
455
+const handleDepartmentLeaderName2qtzgr = () => {
456
+  PopupDepartmentLeaderNameRef2qtzgr.value.open();
457
+};
458
+
459
+const codeAndDesc2qtzgr = ref([]);
460
+const getDepartmentLeaderName2qtzgr = (items) => {
461
+  console.log('人员数据', items);
462
+  let codeList = [];
463
+  let descList = [];
464
+  for (let item of items) {
465
+    codeAndDesc2qtzgr.value.push(item.userCode + '-' + item.userDesc);
466
+    codeList.push(item.userCode);
467
+    descList.push(item.userDesc);
468
+  }
469
+  form.value.repairOther = codeList.join(',');
470
+  form.value.repairOtherDesc = descList.join(',');
471
+};
472
+
473
+/* 组织树选择 */
474
+const showBottom = ref(false);
475
+const handleTableDataUserDeptUpdate = async (nodeData) => {
476
+  let temp = nodeData.split('-');
477
+  if(temp[0].length<9){
478
+    showFailToast('请选择四级及以下部门')
479
+    return
480
+  }
481
+  form.value.hdLocation = temp[1];
482
+  form.value.hdLocationCode = temp[0];
483
+  form.value.hdConfirm = temp[2]
484
+  // form.value.repairDept = nodeData.deptCode + '-' + nodeData.deptName
485
+  showBottom.value = false;
486
+};
487
+const showPickerHandle = () => {
488
+  showBottom.value = true;
489
+};
490
+
491
+/**表单*/
492
+
493
+/***********************新图******************************/
494
+//公共区
495
+import { atob } from 'js-base64';
496
+
497
+const bucket = ref(import.meta.env.VITE_BUCKET);
498
+
499
+function base64ToBlob(base64) {
500
+  const contentType = base64.substring(base64.indexOf(':') + 1, base64.indexOf(';'));
501
+  const byteCharacters = atob(base64);
502
+  const byteArrays = [];
503
+
504
+  for (let i = 0; i < byteCharacters.length; i++) {
505
+    byteArrays.push(byteCharacters.charCodeAt(i));
506
+  }
507
+
508
+  const byteArray = new Uint8Array(byteArrays);
509
+  return new Blob([byteArray], { type: contentType });
510
+}
511
+
512
+const headers = ref({
513
+  token: localStorage.getItem('token'),
514
+  userId: localStorage.getItem('userId')
515
+});
516
+
517
+//整改前
518
+const fileList = ref([]);
519
+const afterRead = (file) => {
520
+  const content = base64ToBlob(file.content);
521
+  const formData = new FormData();
522
+  formData.append('fId', form.value.hdPicId);
523
+  formData.append('bucket', bucket.value);
524
+  formData.append('value1', null);
525
+  formData.append('value2', null);
526
+  formData.append('value3', null);
527
+  formData.append('value4', null);
528
+  formData.append('value5', null);
529
+  formData.append('file', content, file.file.name);
530
+  let url = import.meta.env.VITE_BASE_API + '/framework/Common/uploadFileS3';
531
+  proxy.$axios.post(url, formData, { headers: headers.value }).then(res => {
532
+    if (res.data.code === 0) {
533
+      showSuccessToast('上传成功');
534
+      getTableData();
535
+    } else {
536
+      showFailToast('上传失败' + res.data.msg);
537
+    }
538
+  }).catch(error => {
539
+    console.log(error);
540
+  });
541
+};
542
+const getTableData = () => {
543
+  //携带自定义参数
544
+  var url = 'framework/Common/queryFileWithValues';
545
+  var param = {
546
+    fId: form.value.hdPicId, //必填
547
+    value1: null, //非必填
548
+    value2: null, //非必填
549
+    value3: null, //非必填
550
+    value4: null, //非必填
551
+    value5: null //非必填
552
+  };
553
+  proxy.$axios.get(url, param).then(response => {
554
+    if (response.data.code === 0) {
555
+      for (var item of response.data.data) {
556
+        fileList.value.push({
557
+          id: item.id,
558
+          uploadFile: item.fileName,
559
+          url: import.meta.env.VITE_BASE_API +
560
+            '/framework/Common/downloadFileS3?bucket=' + bucket.value +
561
+            '&id=' + item.id
562
+        });
563
+        form.value.picBefore = fileList.value[0].url;
564
+      }
565
+    } else {
566
+      showFailToast('失败!' + response.data.msg);
567
+    }
568
+  });
569
+};
570
+/* 在线删除 */
571
+const showDialogVisible = ref(false);
572
+const deleteInfo = ref();
573
+const handleDelete = (row) => {
574
+  showDialogVisible.value = true;
575
+  deleteInfo.value = row;
576
+};
577
+const onDelete = () => {
578
+  let url = 'framework/Common/removeFile';
579
+  let param = {
580
+    id: deleteInfo.value.id
581
+  };
582
+  proxy.$axios.post(url, param).then(response => {
583
+    if (response.data.code === 0) {
584
+      showSuccessToast('删除成功!');
585
+      getTableData();
586
+    } else {
587
+      showFailToast('删除失败;' + response.data.msg);
588
+    }
589
+  });
590
+};
591
+
592
+//隐患选择
593
+const selectOption = (option) => {
594
+  if (form.value.workId.length > 0) {
595
+    return;
596
+  }
597
+  form.value.hdSelect = option;
598
+  if (option === '隐患举报') {
599
+    isStandardFlow.value = true;
600
+  } else if (option === '即查即改') {
601
+    isStandardFlow.value = false;
602
+  }
603
+  getYHID();
604
+};
605
+
606
+/**修改发现时间**/
607
+// 日期选择器取消
608
+const cancelDatePicker = () => {
609
+  showDatetimePicker.value = false;
610
+  resetDatetime();
611
+};
612
+
613
+// 时间选择器取消
614
+const cancelTimePicker = () => {
615
+  resetDatetime();
616
+  // 重置为当前时间或从表单获取时间
617
+  if (form.value.accidentTime) {
618
+    const dt = new Date(form.value.accidentTime);
619
+    currentTime.value = [
620
+      String(dt.getHours()).padStart(2, '0'),
621
+      String(dt.getMinutes()).padStart(2, '0'),
622
+      String(dt.getSeconds()).padStart(2, '0')
623
+    ];
624
+  } else {
625
+    const now = new Date();
626
+    currentTime.value = [
627
+      String(now.getHours()).padStart(2, '0'),
628
+      String(now.getMinutes()).padStart(2, '0'),
629
+      String(now.getSeconds()).padStart(2, '0')
630
+    ];
631
+  }
632
+};
633
+/**修改发现时间**/
634
+
635
+/**控制显示**/
636
+const showSeriousInjuryCount = ref(false)
637
+const showDeathCount = ref(false)
638
+const showEconomicLoss = ref(false)
639
+
640
+/**控制输入**//*
641
+const onInput = (value) =>{
642
+  console.log('输入的值', value)
643
+  // 1. 过滤所有非数字和非小数点的字符(只保留数字和一个小数点)
644
+  // let value = val.replace(/[^\d.]/g, '');
645
+
646
+  // 2. 处理多个小数点:只保留第一个小数点,后续的小数点删除
647
+  // const dotIndex = value.indexOf('.');
648
+  if (value !== -1) {
649
+    // 从第一个小数点后开始,删除所有其他小数点
650
+    value = value.slice(0, dotIndex + 1) + value.slice(dotIndex + 1).replace(/\./g, '');
651
+  }
652
+
653
+  // 3. 处理开头为小数点的情况:自动补0(如 .123 → 0.123)
654
+  if (value.startsWith('.')) {
655
+    value = '0' + value;
656
+  }
657
+
658
+  // 4. 限制小数位最多3位:如果有小数点,截取小数点后前3位
659
+  if (value.includes('.')) {
660
+    const parts = value.split('.');
661
+    // 整数部分 + 小数点 + 小数部分前3位
662
+    value = parts[0] + '.' + (parts[1] || '').slice(0, 3);
663
+  }
664
+
665
+  // 5. 赋值给表单(避免空值时显示undefined)
666
+  form.value.economicLoss = value || '';
667
+}*/
668
+
669
+/**控制键盘删除**/
670
+const cKeyDelete = () => {
671
+  if (!form.value.economicLoss) return; // 为空时不操作
672
+
673
+  // 截取掉最后一个字符
674
+  let value = form.value.economicLoss.slice(0, -1);
675
+
676
+  // 处理删除后可能出现的不合理格式(比如只剩小数点)
677
+  if (value === '.') {
678
+    value = ''; // 如果删除后只剩小数点,清空
679
+  }
680
+
681
+  form.value.economicLoss = value;
682
+}
683
+
684
+/**计算属性**/
685
+//计算属性
686
+const accidentLevel = computed(()=>{
687
+  if(form.value.deathCount>=30 || form.value.economicLoss>=100000 || form.value.seriousInjuryCount>=100){
688
+    return '特别重大事故'
689
+  }else if(form.value.deathCount>=10 || form.value.economicLoss>=5000 || form.value.seriousInjuryCount>=50){
690
+    return '重大事故'
691
+  }else if(form.value.deathCount>=3 || form.value.economicLoss>=1000 || form.value.seriousInjuryCount>=10){
692
+    return '较大事故'
693
+  }else{
694
+    return '一般事故'
695
+  }
696
+})
697
+
698
+</script>
699
+
700
+<style scoped>
701
+.h5-container {
702
+  width: 100%;
703
+  box-sizing: border-box;
704
+  height: 100vh;
705
+  background-color: white;
706
+  padding: 10px;
707
+  padding-bottom: 20px;
708
+}
709
+
710
+.radio-group {
711
+  display: flex;
712
+  background-color: white;
713
+  padding: 10px;
714
+  border-radius: 5px;
715
+  margin: 10px 0;
716
+  gap: 10px;
717
+}
718
+
719
+.radio-item {
720
+  padding: 8px 12px;
721
+  border: 1px solid #222;
722
+  border-radius: 4px;
723
+  background-color: white;
724
+  cursor: pointer;
725
+  transition: background-color 0.3s ease;
726
+  /* 添加过渡效果 */
727
+}
728
+
729
+.radio-item.active {
730
+  background-color: #4285f4;
731
+  /* 选中时的蓝色 */
732
+  color: white;
733
+  border-color: #4285f4;
734
+}
735
+</style>

+ 867
- 0
src/view/accidentManager/accidentJuBaoLedger/index.vue Zobrazit soubor

@@ -0,0 +1,867 @@
1
+<template>
2
+  <div class="h5-container">
3
+    <van-nav-bar title="事故举报台账" @click-left="onClickLeft" @click-right="handAdd('add','XY')">
4
+      <template v-if="false" #right>
5
+        <van-icon name="add" size="25" color="#000" />
6
+      </template>
7
+    </van-nav-bar>
8
+    <van-search v-if="false" v-model="query.discovererDesc" show-action placeholder="请输入发现人" @search="onRefresh"
9
+      @cancel="handdelect" />
10
+
11
+    <!-- 项目列表 -->
12
+    <van-pull-refresh v-model="isRefreshing" success-text="刷新成功" @refresh="onRefresh">
13
+      <van-list v-model:loading="isLoading" :finished="isFinished" finished-text="没有更多了" offset="200" @load="onLoad">
14
+        <div v-for="(item, idx) in resultData" :key="item.id">
15
+          <van-swipe-cell @open="handleSwipeOpen(item,idx)" @close="handleSwipeClose(item,idx)" title-style="color: #007aff" style="height: 80px;" :ref="el => getSwipeCellRef(el, idx)">
16
+            <template #default>
17
+              <div class="swipe-cell-default">
18
+                <van-cell style="min-height: 100px; padding: 0 0 0 0; display: flex; align-items: flex-start;" @click="handAdd('look',item)">
19
+                  <template #title>
20
+                    <div class="cell-title">
21
+                      {{ item.hdDescription }}
22
+                    </div>
23
+                  </template>
24
+                  <template #label>
25
+                    <div>事故地点:{{ item.accidentLocation }}</div>
26
+                    <div>发生时间:{{ item.accidentTime }}</div>
27
+                    <div>事故类型:{{ item.accidentType }}</div>
28
+                    <div>事故等级:{{ item.accidentLevel }}</div>
29
+                  </template>
30
+                </van-cell>
31
+                <div v-if="false" class="swipe-cell-default-icon">
32
+                  <van-icon v-if="openStatus[idx]" name="arrow-double-left" @click.stop="openSwipe(idx)" />
33
+                  <van-icon v-else name="arrow-double-right" @click.stop="closeSwipe(idx)" />
34
+                </div>
35
+              </div>
36
+            </template>
37
+
38
+            <template v-if="false" #right>
39
+              <van-button square class="edit-button" text="编辑" @click="handAdd('edit', item)" />
40
+              <van-button square class="delete-button" text="删除" @click="handleDelete(item, idx)" />
41
+            </template>
42
+          </van-swipe-cell>
43
+        </div>
44
+
45
+      </van-list>
46
+    </van-pull-refresh>
47
+
48
+
49
+    <!-- 删除确认弹窗 -->
50
+    <van-dialog v-model:show="deleteDialogVisible" show-cancel-button @confirm="confirmDelete">
51
+      <template #title>
52
+        <div>删除确认</div>
53
+      </template>
54
+      <div style="padding: 30px;">确定要删除该事故记录吗?</div>
55
+    </van-dialog>
56
+
57
+  </div>
58
+</template>
59
+
60
+<script setup>
61
+import { ref, reactive, onMounted, getCurrentInstance, nextTick, toRaw } from 'vue';
62
+import { Dialog, showDialog, showSuccessToast, showToast, Toast } from 'vant';
63
+
64
+const { proxy } = getCurrentInstance();
65
+
66
+const onClickLeft = () => {
67
+  history.back();
68
+};
69
+const headers = ref({
70
+  token: localStorage.getItem('token'),
71
+  userId: localStorage.getItem('userId'),
72
+  dept: JSON.parse(localStorage.getItem('dept'))[0].deptCode
73
+});
74
+const switchIconState = (idx) => {
75
+  openStatus.value[idx] = !openStatus.value[idx]
76
+  openStatus.value = new Array(resultData.value.length).fill(true);
77
+}
78
+
79
+// const onClickRight = () =>{
80
+//   searchShow.value = !searchShow.value;
81
+// }
82
+
83
+const searchShow = ref(false);
84
+const query = ref({
85
+  discovererDesc: '',
86
+  hdSelect:'隐患举报'
87
+});
88
+
89
+function formatDate(date, format) {
90
+  const year = date.getFullYear();
91
+  const month = date.getMonth() + 1;
92
+  const day = date.getDate();
93
+  const hours = date.getHours();
94
+  const minutes = date.getMinutes();
95
+  const seconds = date.getSeconds();
96
+
97
+  return format
98
+    .replace('yyyy', year)
99
+    .replace('MM', month.toString().padStart(2, '0'))
100
+    .replace('dd', day.toString().padStart(2, '0'))
101
+    .replace('HH', hours.toString().padStart(2, '0'))
102
+    .replace('mm', minutes.toString().padStart(2, '0'))
103
+    .replace('ss', seconds.toString().padStart(2, '0'));
104
+}
105
+
106
+const tableData = ref([]);
107
+const selectedRows = ref([]);
108
+const dialogVisibleLook = ref(false);
109
+const deleteDialogVisible = ref(false);
110
+const currentDeleteItem = ref([]);
111
+const dialogVisible = ref(false);
112
+const dialogVisibleFile = ref(false);
113
+const date = ref(null);
114
+
115
+const kz = ref(true);
116
+const handAdd = async (flag,item) => {
117
+  if('add'===flag) {
118
+    // 将表单数据置空
119
+    resetForma();
120
+    //todo 编辑页面
121
+    proxy.$router.push({
122
+      path: '/accidentManager/accidentJuBao/accidentJuBao_edit/index',
123
+      query: {
124
+        flag:'add'
125
+      }
126
+    });
127
+  }else if('edit'===flag) { 
128
+    proxy.$router.push({
129
+      path: '/accidentManager/accidentJuBao/accidentJuBao_edit/index',
130
+      query: {
131
+        id:item.id,
132
+        flag:'edit'
133
+      }
134
+    })
135
+  }else {
136
+    proxy.$router.push({
137
+      path: '/accidentManager/accidentJuBao/accidentJuBao_edit/index',
138
+      query: {
139
+        id:item.id,
140
+        flag:'look'
141
+      }
142
+    })
143
+  }
144
+};
145
+// 定义表单数据
146
+const form = ref({
147
+  hdPicId: '',
148
+  hdId: '',
149
+  hdType: '',
150
+  discoveryTime: '',
151
+  hdSubtype: '',
152
+  discoverer: '',
153
+  discovererOther: '',
154
+  hdDescription: '',
155
+  hdLevel: '',
156
+  bz: '',
157
+  hdLocation: '',
158
+  picBefore: '',
159
+
160
+  equipmentId: '',
161
+  hdmanageLevel: '',
162
+  handlingProcesses: '',
163
+  companyId: '',
164
+  repairLeader: '',
165
+  repairOther: '',
166
+  repairSuggest: '',
167
+  repairDdl: '',
168
+  repairDept: '',
169
+  acceptLeader: '',
170
+  acceptOther: '',
171
+  picAfter: '',
172
+  picTemp: '',
173
+  repairDescription: '',
174
+  discovererDept: '',
175
+  discovererDeptCode: '',
176
+  hdLocationCode: '',
177
+  hdLocationName: '',
178
+
179
+  status: '',
180
+
181
+
182
+  hdSelect: '隐患举报',
183
+  id: ''
184
+});
185
+const resetForma = () => {
186
+  form.value = {
187
+    hdPicId: '',
188
+    hdId: '',
189
+    hdType: '',
190
+    discoveryTime: '',
191
+    hdSubtype: '',
192
+    discoverer: '',
193
+    discovererOther: '',
194
+    hdDescription: '',
195
+    hdLevel: '',
196
+    bz: '',
197
+    hdLocation: '',
198
+    picBefore: '',
199
+
200
+    equipmentId: '',
201
+    hdmanageLevel: '',
202
+    handlingProcesses: '',
203
+    companyId: '',
204
+    repairLeader: '',
205
+    repairOther: '',
206
+    repairSuggest: '',
207
+    repairDdl: '',
208
+    repairDept: '',
209
+    acceptLeader: '',
210
+    acceptOther: '',
211
+    picAfter: '',
212
+    picTemp: '',
213
+    repairDescription: '',
214
+    status: '',
215
+    discovererDept: '',
216
+    discovererDeptCode: '',
217
+    hdLocationCode: '',
218
+    hdLocationName: '',
219
+
220
+    hdSelect: '隐患举报',
221
+    id: ''
222
+  };
223
+};
224
+
225
+const isRefreshing = ref(false);
226
+const isLoading = ref(false);
227
+const isFinished = ref(false);
228
+const currentPage = ref(1);
229
+const pageSize = ref(10);
230
+const totalRows = ref(0);
231
+const resultData = ref([]);
232
+
233
+const getTableData = async () => {
234
+  const url = 'sgsafe/AccidentDirect/query';
235
+  const param = {
236
+    page: currentPage.value,
237
+    rows: pageSize.value,
238
+    params: JSON.stringify(query.value)
239
+  };
240
+  const response = await proxy.$axios.get(url, param);
241
+  if (response.data.code === 0) {
242
+    tableData.value = response.data.data.records;
243
+    totalRows.value = response.data.data.total;
244
+    // tableData.value.forEach(item => {
245
+    //   switch (item.status) {
246
+    //     case '0':
247
+    //       item.status = '隐患登记';
248
+    //       break;
249
+    //     case '1':
250
+    //       item.status = '隐患分析确认';
251
+    //       break;
252
+    //     case '2':
253
+    //       item.status = '隐患整改';
254
+    //       break;
255
+    //     case '3':
256
+    //       item.status = '隐患验收';
257
+    //       break;
258
+    //     case '4':
259
+    //       item.status = '隐患销号';
260
+    //       break;
261
+    //     case '5':
262
+    //       item.status = '结束';
263
+    //       break;
264
+    //     case '-1':
265
+    //       item.status = '待提交';
266
+    //       break;
267
+    //   }
268
+    // });
269
+  } else {
270
+    showToast({
271
+      type: 'error',
272
+      message: '操作失败!' + response.data.msg
273
+    });
274
+  }
275
+};
276
+
277
+const onRefresh = () => {
278
+  basicReset();
279
+  onLoad();
280
+};
281
+
282
+const onLoad = async () => {
283
+  if (isRefreshing.value) {
284
+    resultData.value = [];
285
+    currentPage.value = 1;
286
+    isRefreshing.value = false;
287
+  }
288
+  try {
289
+    await getTableData();
290
+    if (pageSize.value * currentPage.value < totalRows.value) {
291
+      resultData.value = [...resultData.value, ...tableData.value];
292
+      openStatus.value = new Array(resultData.value.length).fill(true);
293
+      currentPage.value++;
294
+
295
+    } else {
296
+      resultData.value = [...resultData.value, ...tableData.value];
297
+      openStatus.value = new Array(resultData.value.length).fill(true);
298
+      isFinished.value = true;
299
+    }
300
+  } catch (error) {
301
+    console.log(error);
302
+    isFinished.value = true;
303
+  } finally {
304
+    isLoading.value = false;
305
+  }
306
+};
307
+/* 通用方法: 重置list数据 */
308
+const basicReset = () => {
309
+  isFinished.value = false;
310
+  isLoading.value = true;
311
+  currentPage.value = 1;
312
+  resultData.value = [];
313
+};
314
+
315
+/*onMounted(() => {
316
+  handleSearch();
317
+});
318
+
319
+const handleSearch = () => {
320
+/!*  currentPage.value = 1;
321
+  isFinished.value = false;
322
+  tableData.value = [];*!/
323
+  basicReset()
324
+  onLoad()
325
+};*/
326
+
327
+const handdelect = () => {
328
+  query.value.discoverer = '';
329
+  onRefresh()
330
+};
331
+
332
+const handleDetailLook = (row) => {
333
+  form.value = { ...row };
334
+  proxy.$router.push({
335
+    name: 'taiZhang_detail',
336
+    query: {
337
+      form: form.value.id
338
+    }
339
+  });
340
+  // dialogVisibleLook.value = true;
341
+};
342
+const deleteId = ref('')
343
+const handleDelete = (item, idx) => {
344
+  openStatus.value[idx] = !openStatus.value[idx]
345
+  openStatus.value = new Array(resultData.value.length).fill(true);
346
+  deleteId.value = item.id
347
+  deleteDialogVisible.value = true;
348
+};
349
+
350
+const confirmDelete = () => {
351
+  var url = 'sgsafe/AccidentDirect/remove';
352
+  var param = {
353
+    id: deleteId.value
354
+  };
355
+  proxy.$axios.get(url, param).then(response => {
356
+    if (response.data.code == 0) {
357
+      showToast({
358
+        type: 'success',
359
+        message: '删除成功'
360
+      });
361
+      onRefresh();
362
+    } else {
363
+      showToast({
364
+        type: 'fail',
365
+        message: '操作失败!' + response.data.msg
366
+      });
367
+    }
368
+  });
369
+};
370
+
371
+const edits = (row) => {
372
+  form.value = { ...row };
373
+  if (row.workId) {
374
+    sessionStorage.setItem('workflowQuery', JSON.stringify({
375
+      flowId: row.flowId,
376
+      workId: row.workId,
377
+      trackId: row.trackId,
378
+      // subjectionId: '0703E25C35BD11B2A553E9317BF53B18',
379
+      // subjectionId: '0703E25C35BD11B2A553E9317BF53B18',
380
+      type: '1',
381
+      date: new Date().getTime()
382
+    }));
383
+    proxy.$router.push({
384
+      path: '/yinhuan/JuBaohdLedger_detail'
385
+    });
386
+  } else {
387
+    proxy.$router.push({
388
+      path: '/yinhuan/JuBaoregistration_edit/index',
389
+      query: {
390
+        id: form.value.id
391
+      }
392
+    });
393
+  }
394
+
395
+};
396
+
397
+
398
+const resetForm = () => {
399
+  form.value = {
400
+    projectName: '',
401
+    projectLeader: '',
402
+    phone: '',
403
+    dept: ''
404
+  };
405
+};
406
+
407
+const baocun = () => {
408
+  nextTick(() => {
409
+    if (form.value.hdSelect === '隐患举报') {
410
+      form.value.status = '0';
411
+    } else if (form.value.hdSelect === '下发隐患') {
412
+      form.value.status = '2';
413
+    } else {
414
+      form.value.status = '-1';
415
+    }
416
+  });
417
+  // 原有保存逻辑保持不变
418
+  var url = 'sgsafe/JuBaoHiddendanger/save';
419
+  var param = {
420
+    json: JSON.stringify(form.value)
421
+  };
422
+  proxy.$axios.post(url, param).then(response => {
423
+    if (response.data.code == '0') {
424
+      showSuccessToast('保存成功!');
425
+      getTableData();
426
+      orJsons();
427
+      // clearDeptUsers()
428
+    } else {
429
+      showToast({
430
+        type: 'fail',
431
+        message: '操作失败!' + response.data.msg
432
+      });
433
+    }
434
+  });
435
+};
436
+
437
+//处理人员code
438
+const repairLL = ref('');
439
+const repairOO = ref('');
440
+const acceptLL = ref('');
441
+const orJsons = () => {
442
+  // console.log('forms',form.value)
443
+  if (form.value.hdSelect === '隐患举报') {
444
+    nextTick(() => {
445
+      nextTick(() => {
446
+        repairLL.value = qq('repairLL', form.value.discoverer);//隐患发现人
447
+        nextTick(() => {
448
+          repairOO.value = qq('repairOO', form.value.discovererOther);//其他隐患发现人
449
+          nextTick(() => {
450
+            acceptLL.value = qq('acceptLL', form.value.discoverer);//隐患销号人
451
+          });
452
+        });
453
+      });
454
+
455
+      // acceptOO.value = qq('acceptOO', form.value.acceptOther)
456
+    });
457
+  } else {
458
+    // console.log('noiajdoifjpoewjfopjp')
459
+    nextTick(() => {
460
+      nextTick(() => {
461
+        repairLL.value = qq('repairLL', form.value.acceptLeader);//隐患发现人
462
+        nextTick(() => {
463
+          repairOO.value = qq('repairOO', form.value.acceptOther);//其他隐患发现人
464
+          nextTick(() => {
465
+            acceptLL.value = qq('acceptLL', form.value.discoverer);//隐患销号人
466
+          });
467
+        });
468
+      });
469
+
470
+      // acceptOO.value = qq('acceptOO', form.value.acceptOther)
471
+    });
472
+  }
473
+};
474
+
475
+const jsons = ref({});
476
+const qq = (a, val) => {
477
+  let aa = '';
478
+  var url = 'sgsafe/JuBaoHiddendanger/qqId';
479
+  var param = {
480
+    params: val
481
+  };
482
+  proxy.$axios.post(url, param).then(response => {
483
+    if (response.data.code == 0) {
484
+
485
+      aa = response.data.data;
486
+      switch (a) {
487
+        case 'repairLL':
488
+          repairLL.value = response.data.data;
489
+          // console.log('repairLL',repairLL.value);
490
+          break;
491
+        case 'repairOO':
492
+          repairOO.value = response.data.data;
493
+          // console.log('repairOO',repairLL.value);
494
+          break;
495
+        case 'acceptLL':
496
+          acceptLL.value = response.data.data;
497
+          // console.log('acceptLL',repairLL.value);
498
+          break;
499
+        default:
500
+          break;
501
+      }
502
+      jsons.value = {
503
+        hdConfirm: repairLL.value,
504
+        hdConfirmO: repairOO.value,
505
+        hdCancel: acceptLL.value
506
+      };
507
+
508
+      // 处理函数
509
+      function processValue(value) {
510
+        // 将逗号替换为分号
511
+        const replacedValue = value.replace(/,/g, ';');
512
+        // 分割值
513
+        const parts = replacedValue.split(';');
514
+        // 每个部分前加上 U_
515
+        const processedParts = parts.map(part => `U_${part.trim()}`);
516
+        // 重新组合
517
+        return processedParts.join(';');
518
+      }
519
+
520
+      // 处理整个对象
521
+      const processedData = {};
522
+      for (const key in jsons.value) {
523
+        if (jsons.value.hasOwnProperty(key)) {
524
+          processedData[key] = processValue(jsons.value[key]);
525
+        }
526
+      }
527
+
528
+      console.log('对象', toRaw(processedData));
529
+
530
+      let b = {
531
+        acceptL: processedData.hdConfirm,
532
+        acceptO: processedData.hdConfirmO,
533
+        id: form.value.id
534
+      };
535
+
536
+      if (form.value.hdSelect === '即查即改') {
537
+        b = {
538
+          hdFxr: processedData.hdCancel,
539
+          id: form.value.id
540
+        };
541
+      }
542
+
543
+      if (form.value.hdSelect === '隐患举报') {
544
+        b = {
545
+          // hdConfirm: processedData.hdConfirm,
546
+          // hdConfirmO: processedData.hdConfirmO,
547
+          id: form.value.id
548
+        };
549
+      }
550
+
551
+      const aaa = JSON.stringify(toRaw(b));
552
+      sessionStorage.setItem('variables', aaa);
553
+      console.log('aaa', aaa);
554
+    } else {
555
+      showToast({
556
+        type: 'fail',
557
+        message: '操作失败!' + response.data.msg
558
+      });
559
+    }
560
+  });
561
+  return aa;
562
+};
563
+
564
+const reback = () => {
565
+  // 返回逻辑
566
+};
567
+
568
+const deleteRow = (row) => {
569
+  selectedRows.value = [row];
570
+  handleDelete(row);
571
+};
572
+
573
+const deleteRowa = (row) => {
574
+  deleteRow(row);
575
+};
576
+
577
+const bm = (val) => {
578
+  // 部门选择逻辑
579
+};
580
+
581
+//提交审批流程
582
+import { workflowSubmit, workflowCancel } from '@/tools/workflow.js';
583
+
584
+const flowId = ref('');
585
+flowId.value = 'hdRwardReportingId';
586
+const handleSubmit2 = (val, idx) => {
587
+  openStatus.value[idx] = !openStatus.value[idx]
588
+  openStatus.value = new Array(resultData.value.length).fill(true);
589
+  console.log('提交');
590
+  console.log('selectedRows', selectedRows.value);
591
+  let row = val;
592
+  form.value = { ...row }
593
+  form.value.workCreate = headers.value.dept;
594
+
595
+  let b = {
596
+    id: form.value.id,
597
+    hdConfirm:form.value.hdConfirm
598
+  }
599
+  const aaa = JSON.stringify(toRaw(b))
600
+  sessionStorage.setItem('variables', aaa)
601
+
602
+  if (form.value.hdSelect === '隐患举报') {
603
+    flowId.value = 'hdRwardReportingId'
604
+  } 
605
+
606
+  console.log('----');
607
+  console.log(flowId.value);
608
+  console.log(sessionStorage.getItem('variables'));
609
+  console.log(row.workId);
610
+  console.log(row.trackId);
611
+  let titles = '隐患举报'
612
+  showDialog({
613
+    title: '提示',
614
+    message: '确定提交审批?',
615
+    showCancelButton: true,
616
+    confirmButtonText: '确定',
617
+    type: 'warning',
618
+    cancelButtonText: '取消'
619
+  }
620
+  ).then(() => {
621
+    return workflowSubmit(
622
+      flowId.value,
623
+      '隐患举报',
624
+      '初始化提交',
625
+      // JSON.stringify({}),
626
+      sessionStorage.getItem('variables'),
627
+      row.workId,
628
+      row.trackId);
629
+  }).then((result) => {
630
+    if (result.status === 'success') {
631
+      // 将结果返回的workId和trackId保存
632
+      var url = 'sgsafe/JuBaoHiddendanger/saveProcessInfo';
633
+      console.log('id', result, row.id);
634
+      var process = {
635
+        'id': form.value.id,
636
+        'workId': result.workId,
637
+        'trackId': result.trackId
638
+      };
639
+      var param = {
640
+        json: JSON.stringify(process)
641
+      };
642
+      proxy.$axios.post(url, param).then(response => {
643
+        if (response.data.code === 0) {
644
+          form.value = response.data.data;
645
+          console.log('我要进来啦保存成功');
646
+          showToast({
647
+            type: 'success',
648
+            message: '提交审批成功'
649
+          });
650
+          onRefresh()
651
+        }
652
+      });
653
+    } else {
654
+      showToast({
655
+        type: 'error',
656
+        message: '提交审批失败,' + result.msg
657
+      });
658
+    }
659
+  }).catch(() => {
660
+    showToast({
661
+      type: 'info',
662
+      message: '已取消提交'
663
+    });
664
+  });
665
+};
666
+
667
+
668
+const getStatusClass = (status) => {
669
+  switch (status) {
670
+    case '-1':
671
+      return 'status-pending';
672
+    case '0':
673
+      return 'status-registered';
674
+    case '1':
675
+      return 'status-analyzing';
676
+    case '2':
677
+      return 'status-rectifying';
678
+    case '3':
679
+      return 'status-accepting';
680
+    case '4':
681
+      return 'status-closed';
682
+    case '5':
683
+      return 'status-finished';
684
+    default:
685
+      return 'status-unknown';
686
+  }
687
+};
688
+
689
+/**
690
+ * 按钮实现swipe-cell滑动
691
+ */
692
+const openStatus = ref([])
693
+const swipeCellRefs = ref([])
694
+const getSwipeCellRef = (el, index) => {
695
+  if (el) {
696
+    swipeCellRefs.value[index] = el;
697
+  }
698
+}
699
+const openSwipe = (idx) => {
700
+  openStatus.value = new Array(resultData.value.length).fill(true);
701
+  if (idx >= 0 && idx < swipeCellRefs.value.length) {
702
+    openStatus.value[idx] = false
703
+    swipeCellRefs.value[idx].open('right')
704
+  }
705
+  document.addEventListener('click', handleDocumentClick)
706
+}
707
+/**
708
+ * 当点击滑动单元格时,开始监听点击事件
709
+ */
710
+const handleDocumentClick = (event) => {
711
+  openStatus.value = new Array(resultData.value.length).fill(true);
712
+}
713
+
714
+const closeSwipe = (idx) => {
715
+  if (idx >= 0 && idx < swipeCellRefs.value.length) {
716
+    openStatus.value[idx] = true
717
+    swipeCellRefs.value[idx].close()
718
+  }
719
+}
720
+
721
+/**滑动监听**/
722
+const handleSwipeOpen = (item,idx) =>{
723
+  console.log('handleSwipeOpen', idx)
724
+  console.log('handleSwipeOpen数据', item)
725
+  openStatus.value[idx] = false
726
+}
727
+
728
+const handleSwipeClose = (item,idx) =>{
729
+  openStatus.value[idx] = true
730
+  console.log('handleSwipeClose', idx)
731
+  console.log('handleSwipeClose数据', item)
732
+}
733
+
734
+</script>
735
+
736
+<style scoped>
737
+.h5-container {
738
+  width: 100%;
739
+  padding: 5px;
740
+  box-sizing: border-box;
741
+}
742
+
743
+.status-pending {
744
+  background-color: #fff3cd;
745
+  color: #856404;
746
+  padding: 2px 4px;
747
+  border-radius: 4px;
748
+}
749
+
750
+.status-registered {
751
+  background-color: #d1ecf1;
752
+  color: #0c5460;
753
+  padding: 2px 4px;
754
+  border-radius: 4px;
755
+}
756
+
757
+.status-analyzing {
758
+  background-color: #fff8e1;
759
+  color: #ff8f00;
760
+  padding: 2px 4px;
761
+  border-radius: 4px;
762
+}
763
+
764
+.status-rectifying {
765
+  background-color: #e8f5e9;
766
+  color: #2e7d32;
767
+  padding: 2px 4px;
768
+  border-radius: 4px;
769
+}
770
+
771
+.status-accepting {
772
+  background-color: #e3f2fd;
773
+  color: #1565c0;
774
+  padding: 2px 4px;
775
+  border-radius: 4px;
776
+}
777
+
778
+.status-closed {
779
+  background-color: #f8bbd0;
780
+  color: #b71c1c;
781
+  padding: 2px 4px;
782
+  border-radius: 4px;
783
+}
784
+
785
+.status-finished {
786
+  background-color: #e8eaf6;
787
+  color: #311b92;
788
+  padding: 2px 4px;
789
+  border-radius: 4px;
790
+}
791
+
792
+.status-unknown {
793
+  background-color: #efebe9;
794
+  color: #424242;
795
+  padding: 2px 4px;
796
+  border-radius: 4px;
797
+}
798
+
799
+.cell-title {
800
+  display: -webkit-box;
801
+  /* 旧版弹性盒子模型 */
802
+  -webkit-box-orient: vertical;
803
+  /* 内容垂直排列 */
804
+  -webkit-line-clamp: 2;
805
+  /* 限制显示行数 */
806
+  overflow: hidden;
807
+  /* 超出隐藏 */
808
+  text-overflow: ellipsis;
809
+  /* 省略号 */
810
+  line-height: 1.5;
811
+  /* 可选:设置行高 */
812
+  max-height: calc(1.5em * 3);
813
+  /* 可选:根据行高限制最大高度 */
814
+  font-size: 16px;
815
+  font-weight: bold;
816
+  color: #333;
817
+  /* 字号 */
818
+}
819
+
820
+.swipe-cell-default {
821
+  display: flex;
822
+  background-color: #ffffff;
823
+  justify-content: center;
824
+  align-items: center;
825
+}
826
+
827
+.swipe-cell-default-icon {
828
+  width: 60px;
829
+  display: flex;
830
+  justify-content: center;
831
+}
832
+
833
+.delete-button {
834
+  height: 100%;
835
+  border: none;
836
+  color: #ff0000;
837
+  background-image: url('@/assets/img/del.png');
838
+  background-size: auto 100%;
839
+  background-repeat: no-repeat;
840
+}
841
+.edit-button {
842
+  height: 100%;
843
+  border: none;
844
+  color: #F9CC9D;
845
+  background-image: url('@/assets/img/edit.png');
846
+  background-size: auto 100%;
847
+  background-repeat: no-repeat;
848
+}
849
+
850
+.submit-button {
851
+  height: 100%;
852
+  border: none;
853
+  color: #07c160;
854
+  background-image: url('@/assets/img/sub.png');
855
+  background-size: auto 100%;
856
+  background-repeat: no-repeat;
857
+}
858
+
859
+.subsuccess {
860
+  height: 100%;
861
+  border: none;
862
+  color: #07c160;
863
+  background-image: url('@/assets/img/sub1.png');
864
+  background-size: auto 100%;
865
+  background-repeat: no-repeat;
866
+}
867
+</style>

Loading…
Zrušit
Uložit