|
|
@@ -109,15 +109,37 @@ const route = useRoute()
|
|
109
|
109
|
let planInfo = {}
|
|
110
|
110
|
const userName1=localStorage.getItem('userName');
|
|
111
|
111
|
const isEdit = ref(route.query.mark === '1');
|
|
112
|
|
-
|
|
|
112
|
+const isReadOnly = ref(route.query.readOnly === 'true');
|
|
|
113
|
+const isCaseSubmitted = computed(() => isReadOnly.value && isEdit.value);
|
|
113
|
114
|
const result=ref('')
|
|
114
|
115
|
const fromVue=ref({})
|
|
115
|
116
|
if (route.query.mark) {
|
|
116
|
117
|
planInfo = JSON.parse(route.query.mark)
|
|
117
|
118
|
}
|
|
118
|
119
|
console.log(planInfo);
|
|
|
120
|
+// 新增模式
|
|
119
|
121
|
if (planInfo==-1){
|
|
120
|
|
- result.value=guid()
|
|
|
122
|
+ const caseNumber = generateCode();
|
|
|
123
|
+ const fileId = ref()
|
|
|
124
|
+ result.value= caseNumber
|
|
|
125
|
+ //初始化 fromVue
|
|
|
126
|
+ fromVue.value = {
|
|
|
127
|
+ caseNumber: caseNumber,
|
|
|
128
|
+ caseTitle: '',
|
|
|
129
|
+ caseSource: '',
|
|
|
130
|
+ accidentLevel: '',
|
|
|
131
|
+ accidentDept: '',
|
|
|
132
|
+ accidentLocation: '',
|
|
|
133
|
+ accidentTime: '',
|
|
|
134
|
+ accidentType: '',
|
|
|
135
|
+ accidentTags: '',
|
|
|
136
|
+ casualtyCount: '',
|
|
|
137
|
+ accidentSummary: '',
|
|
|
138
|
+ preventiveMeasures: '',
|
|
|
139
|
+ fileId: fileId,
|
|
|
140
|
+ viewCount: '0',
|
|
|
141
|
+ downloadCount: '0'
|
|
|
142
|
+ };
|
|
121
|
143
|
console.log( result.value);
|
|
122
|
144
|
}
|
|
123
|
145
|
|
|
|
@@ -143,14 +165,92 @@ if (planInfo==1) {
|
|
143
|
165
|
console.log(planInfo);
|
|
144
|
166
|
title = '修改事故案例'
|
|
145
|
167
|
fromVue.value= JSON.parse(route.query.data)
|
|
|
168
|
+ if (!fromVue.value.fileId) {
|
|
|
169
|
+ const newFileId = guid();
|
|
|
170
|
+ fromVue.value.fileId = newFileId;
|
|
|
171
|
+ result.value = newFileId;
|
|
|
172
|
+ } else {
|
|
|
173
|
+ result.value = fromVue.value.fileId;
|
|
|
174
|
+ }
|
|
146
|
175
|
|
|
147
|
|
- result.value=fromVue.value.fileId
|
|
148
|
|
- console.log(result.value);
|
|
|
176
|
+ console.log('编辑模式 - fileId:', result.value);
|
|
149
|
177
|
}
|
|
150
|
178
|
const whether=ref(false)
|
|
151
|
179
|
|
|
152
|
180
|
const planLevelList1=ref([])
|
|
153
|
181
|
|
|
|
182
|
+const onConfirmDatetime = () => {
|
|
|
183
|
+ const year = currentDate.value[0];
|
|
|
184
|
+ const month = currentDate.value[1].toString().padStart(2, '0');
|
|
|
185
|
+ const day = currentDate.value[2].toString().padStart(2, '0');
|
|
|
186
|
+ const hours = currentTime.value[0].toString().padStart(2, '0');
|
|
|
187
|
+ const minutes = currentTime.value[1].toString().padStart(2, '0');
|
|
|
188
|
+ const seconds = currentTime.value[2].toString().padStart(2, '0');
|
|
|
189
|
+
|
|
|
190
|
+ fromVue.value.accidentTime = `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
|
|
|
191
|
+ showDatetimePicker.value = false;
|
|
|
192
|
+ dateOrTime.value = false;
|
|
|
193
|
+};
|
|
|
194
|
+
|
|
|
195
|
+
|
|
|
196
|
+const showDatetimePicker = ref(false);
|
|
|
197
|
+const currentTime = ref();
|
|
|
198
|
+const minDate = ref();
|
|
|
199
|
+const maxDate = ref();
|
|
|
200
|
+
|
|
|
201
|
+const dateOrTime = ref(false);
|
|
|
202
|
+const onDateConfirm = () => {
|
|
|
203
|
+ // 日期选择确认后的处理
|
|
|
204
|
+ dateOrTime.value = true;
|
|
|
205
|
+};
|
|
|
206
|
+const resetDatetime = () => {
|
|
|
207
|
+ dateOrTime.value = false;
|
|
|
208
|
+
|
|
|
209
|
+ // 初始化日期和时间
|
|
|
210
|
+ if (fromVue.value.accidentTime) {
|
|
|
211
|
+ const dt = new Date(fromVue.value.accidentTime);
|
|
|
212
|
+ currentDate.value = [dt.getFullYear(), dt.getMonth() + 1, dt.getDate()];
|
|
|
213
|
+ currentTime.value = [
|
|
|
214
|
+ String(dt.getHours()).padStart(2, '0'),
|
|
|
215
|
+ String(dt.getMinutes()).padStart(2, '0'),
|
|
|
216
|
+ String(dt.getSeconds()).padStart(2, '0')
|
|
|
217
|
+ ];
|
|
|
218
|
+ } else {
|
|
|
219
|
+ const now = new Date();
|
|
|
220
|
+ currentDate.value = [now.getFullYear(), now.getMonth() + 1, now.getDate()];
|
|
|
221
|
+ currentTime.value = [
|
|
|
222
|
+ String(now.getHours()).padStart(2, '0'),
|
|
|
223
|
+ String(now.getMinutes()).padStart(2, '0'),
|
|
|
224
|
+ String(now.getSeconds()).padStart(2, '0')
|
|
|
225
|
+ ];
|
|
|
226
|
+ }
|
|
|
227
|
+};
|
|
|
228
|
+const cancelDatePicker = () => {
|
|
|
229
|
+ showDatetimePicker.value = false;
|
|
|
230
|
+ resetDatetime();
|
|
|
231
|
+};
|
|
|
232
|
+
|
|
|
233
|
+// 时间选择器取消
|
|
|
234
|
+const cancelTimePicker = () => {
|
|
|
235
|
+ resetDatetime();
|
|
|
236
|
+ // 重置为当前时间或从表单获取时间
|
|
|
237
|
+ if (fromVue.value.accidentTime) {
|
|
|
238
|
+ const dt = new Date(fromVue.value.accidentTime);
|
|
|
239
|
+ currentTime.value = [
|
|
|
240
|
+ String(dt.getHours()).padStart(2, '0'),
|
|
|
241
|
+ String(dt.getMinutes()).padStart(2, '0'),
|
|
|
242
|
+ String(dt.getSeconds()).padStart(2, '0')
|
|
|
243
|
+ ];
|
|
|
244
|
+ } else {
|
|
|
245
|
+ const now = new Date();
|
|
|
246
|
+ currentTime.value = [
|
|
|
247
|
+ String(now.getHours()).padStart(2, '0'),
|
|
|
248
|
+ String(now.getMinutes()).padStart(2, '0'),
|
|
|
249
|
+ String(now.getSeconds()).padStart(2, '0')
|
|
|
250
|
+ ];
|
|
|
251
|
+ }
|
|
|
252
|
+};
|
|
|
253
|
+
|
|
154
|
254
|
|
|
155
|
255
|
/* 下拉框 */
|
|
156
|
256
|
const showActionSheet = ref(false)
|
|
|
@@ -260,6 +360,9 @@ const addEmergencyDrillPlan = async () => {
|
|
260
|
360
|
message: '加载中',
|
|
261
|
361
|
forbidClick: true
|
|
262
|
362
|
})
|
|
|
363
|
+
|
|
|
364
|
+ fromVue.value.fileId = result.value
|
|
|
365
|
+
|
|
263
|
366
|
var url = '/sgsafe/Manager/saveAccident';
|
|
264
|
367
|
const params = {
|
|
265
|
368
|
json: JSON.stringify(fromVue.value)
|
|
|
@@ -306,6 +409,24 @@ onMounted(() => {
|
|
306
|
409
|
const month = today.getMonth() + 1 // 月份从 0 开始
|
|
307
|
410
|
const day = today.getDate()
|
|
308
|
411
|
currentDate.value = [year, month, day]
|
|
|
412
|
+ // 初始化时间
|
|
|
413
|
+ currentTime.value = [today.getHours(), today.getMinutes(), today.getSeconds()];
|
|
|
414
|
+ // 如果是编辑模式且有已有的事故时间,解析并初始化
|
|
|
415
|
+ if (isEdit.value && fromVue.value.accidentTime) {
|
|
|
416
|
+ try {
|
|
|
417
|
+ // 解析格式如 "2025-01-15 14:30:00" 的时间字符串
|
|
|
418
|
+ const timeStr = fromVue.value.accidentTime;
|
|
|
419
|
+ const [datePart, timePart] = timeStr.split(' ');
|
|
|
420
|
+ if (datePart && timePart) {
|
|
|
421
|
+ const [year, month, day] = datePart.split('-').map(Number);
|
|
|
422
|
+ const [hours, minutes, seconds] = timePart.split(':').map(Number);
|
|
|
423
|
+ currentDate.value = [year, month, day];
|
|
|
424
|
+ currentTime.value = [hours || 0, minutes || 0, seconds || 0];
|
|
|
425
|
+ }
|
|
|
426
|
+ } catch (error) {
|
|
|
427
|
+ console.error('解析事故时间失败:', error);
|
|
|
428
|
+ }
|
|
|
429
|
+ }
|
|
309
|
430
|
//selectedDateText.value = `${year}-${String(month).padStart(2, '0')}-${String(day).padStart(2, '0')}`
|
|
310
|
431
|
getDicList()
|
|
311
|
432
|
})
|
|
|
@@ -361,10 +482,10 @@ const onAccidentLevelConfirm = ({ selectedOptions }) => {
|
|
361
|
482
|
<!-- :rules="[{required: true, message: '请输入文件编号'}]"-->
|
|
362
|
483
|
<!-- />-->
|
|
363
|
484
|
<van-field
|
|
364
|
|
- v-model="generatedCode"
|
|
|
485
|
+ v-model="fromVue.caseNumber"
|
|
365
|
486
|
label="案例编号"
|
|
366
|
487
|
name="caseNumber"
|
|
367
|
|
- :readonly="isCaseSubmitted"
|
|
|
488
|
+ readonly
|
|
368
|
489
|
:rules="[{required: true, message: '编号生成失败,请点击“重新生成”'}]"
|
|
369
|
490
|
/>
|
|
370
|
491
|
|
|
|
@@ -372,9 +493,10 @@ const onAccidentLevelConfirm = ({ selectedOptions }) => {
|
|
372
|
493
|
v-model="fromVue.caseTitle"
|
|
373
|
494
|
label="案例标题"
|
|
374
|
495
|
name="caseTitle"
|
|
|
496
|
+ :readonly="isCaseSubmitted"
|
|
375
|
497
|
required
|
|
376
|
498
|
placeholder="请输入案例标题"
|
|
377
|
|
- :rules="[{required: true, message: '请输入文件名称'}]"
|
|
|
499
|
+ :rules="[{required: true, message: '请输入标题名称'}]"
|
|
378
|
500
|
/>
|
|
379
|
501
|
|
|
380
|
502
|
<van-field
|
|
|
@@ -382,25 +504,24 @@ const onAccidentLevelConfirm = ({ selectedOptions }) => {
|
|
382
|
504
|
readonly
|
|
383
|
505
|
label="案例来源"
|
|
384
|
506
|
name="caseSource"
|
|
385
|
|
- required
|
|
386
|
|
- @click="caseSourceFlag = true"
|
|
|
507
|
+ :readonly="isCaseSubmitted"
|
|
|
508
|
+ @click="!isCaseSubmitted && (caseSourceFlag = true)"
|
|
387
|
509
|
/>
|
|
388
|
510
|
<van-field
|
|
389
|
511
|
readonly
|
|
390
|
512
|
v-model="fromVue.accidentLevel"
|
|
391
|
513
|
label="事故等级"
|
|
392
|
514
|
name="accidentLevel"
|
|
393
|
|
- @click="accidentLevelFlag = true"
|
|
|
515
|
+ :readonly="isCaseSubmitted"
|
|
|
516
|
+ @click="!isCaseSubmitted && (accidentLevelFlag = true)"
|
|
394
|
517
|
/>
|
|
395
|
518
|
|
|
396
|
|
-
|
|
397
|
|
-
|
|
398
|
519
|
<van-field
|
|
399
|
520
|
v-model="fromVue.accidentDept"
|
|
400
|
521
|
label="事故单位"
|
|
401
|
522
|
name="accidentDept"
|
|
402
|
|
- required
|
|
403
|
523
|
placeholder="请输入事故单位"
|
|
|
524
|
+ :readonly="isCaseSubmitted"
|
|
404
|
525
|
:rules="[{required: true, message: '请输入事故单位'}]"
|
|
405
|
526
|
/>
|
|
406
|
527
|
|
|
|
@@ -408,57 +529,114 @@ const onAccidentLevelConfirm = ({ selectedOptions }) => {
|
|
408
|
529
|
v-model="fromVue.accidentLocation"
|
|
409
|
530
|
label="事故地点"
|
|
410
|
531
|
name="accidentLocation"
|
|
411
|
|
- required
|
|
|
532
|
+ :readonly="isCaseSubmitted"
|
|
412
|
533
|
placeholder="请输入事故地点"
|
|
413
|
534
|
:rules="[{required: true, message: '请输入事故地点'}]"
|
|
414
|
535
|
/>
|
|
415
|
536
|
|
|
416
|
537
|
<!-- //时间-->
|
|
|
538
|
+ <van-field
|
|
|
539
|
+ v-model="fromVue.accidentTime"
|
|
|
540
|
+ is-link
|
|
|
541
|
+ readonly
|
|
|
542
|
+ name="datetime"
|
|
|
543
|
+ label="发生时间"
|
|
|
544
|
+ :colon="true"
|
|
|
545
|
+ placeholder="点击选择日期和时间"
|
|
|
546
|
+ @click="showDatetimePicker = !isCaseSubmitted"
|
|
|
547
|
+ :rules="[{ required:true, message: '请选择内容' }]"
|
|
|
548
|
+ />
|
|
417
|
549
|
|
|
|
550
|
+ <van-popup
|
|
|
551
|
+ v-model:show="showDatetimePicker"
|
|
|
552
|
+ position="bottom"
|
|
|
553
|
+ round
|
|
|
554
|
+ style="max-height: 50vh;"
|
|
|
555
|
+ >
|
|
|
556
|
+ <van-date-picker
|
|
|
557
|
+ v-if="!dateOrTime"
|
|
|
558
|
+ v-model="currentDate"
|
|
|
559
|
+ title="选择日期"
|
|
|
560
|
+ :min-date="minDate"
|
|
|
561
|
+ :max-date="maxDate"
|
|
|
562
|
+ @confirm="onDateConfirm"
|
|
|
563
|
+ @cancel="cancelDatePicker"
|
|
|
564
|
+ >
|
|
|
565
|
+ <template #confirm>
|
|
|
566
|
+ <van-button type="primary" @click="onDateConfirm">下一步</van-button>
|
|
|
567
|
+ </template>
|
|
|
568
|
+ <template #cancel>
|
|
|
569
|
+ <van-button type="danger" @click="cancelDatePicker">取消</van-button>
|
|
|
570
|
+ </template>
|
|
|
571
|
+ </van-date-picker>
|
|
|
572
|
+
|
|
|
573
|
+ <van-time-picker
|
|
|
574
|
+ v-if="dateOrTime"
|
|
|
575
|
+ v-model="currentTime"
|
|
|
576
|
+ title="选择时间"
|
|
|
577
|
+ :columns-type="['hour', 'minute', 'second']"
|
|
|
578
|
+ @confirm="onConfirmDatetime"
|
|
|
579
|
+ @cancel="cancelTimePicker"
|
|
|
580
|
+ >
|
|
|
581
|
+ <template #confirm>
|
|
|
582
|
+ <van-button type="primary" @click="onConfirmDatetime">确定</van-button>
|
|
|
583
|
+ </template>
|
|
|
584
|
+ <template #cancel>
|
|
|
585
|
+ <van-button type="danger" @click="cancelTimePicker">取消</van-button>
|
|
|
586
|
+ </template>
|
|
|
587
|
+ </van-time-picker>
|
|
|
588
|
+ </van-popup>
|
|
418
|
589
|
<!-- // 标签-->
|
|
|
590
|
+
|
|
|
591
|
+ <van-field
|
|
|
592
|
+ v-model="fromVue.accidentTags"
|
|
|
593
|
+ label="关键词/标签"
|
|
|
594
|
+ name="accidentTags"
|
|
|
595
|
+ :readonly="isCaseSubmitted"
|
|
|
596
|
+ :rules="[{required: true, message: '请输入事故关键词/标签”'}]"
|
|
|
597
|
+ />
|
|
|
598
|
+
|
|
419
|
599
|
<van-field
|
|
420
|
600
|
v-model="fromVue.casualtyCount"
|
|
421
|
601
|
label="事故造成后果"
|
|
422
|
602
|
name="casualtyCount"
|
|
423
|
|
- required
|
|
424
|
603
|
rows="1"
|
|
425
|
604
|
autosize
|
|
426
|
605
|
type="textarea"
|
|
427
|
606
|
placeholder="请输入事故造成后果"
|
|
|
607
|
+ :readonly="isCaseSubmitted"
|
|
428
|
608
|
:rules="[{required: true, message: '请输入事故造成后果'}]"
|
|
429
|
609
|
/>
|
|
430
|
610
|
<van-field
|
|
431
|
611
|
v-model="fromVue.accidentSummary"
|
|
432
|
612
|
label="事故简要经过"
|
|
433
|
613
|
name="accidentSummary"
|
|
434
|
|
- required
|
|
435
|
614
|
rows="3"
|
|
436
|
615
|
autosize
|
|
437
|
616
|
type="textarea"
|
|
438
|
617
|
placeholder="请输入事故简要经过"
|
|
|
618
|
+ :readonly="isCaseSubmitted"
|
|
439
|
619
|
:rules="[{required: true, message: '请输入事故简要经过'}]"
|
|
440
|
620
|
/>
|
|
441
|
621
|
<van-field
|
|
442
|
622
|
v-model="fromVue.preventiveMeasures"
|
|
443
|
623
|
label="防范与整改措施"
|
|
444
|
624
|
name="preventiveMeasures"
|
|
445
|
|
- required
|
|
446
|
625
|
rows="3"
|
|
447
|
626
|
autosize
|
|
448
|
627
|
type="textarea"
|
|
449
|
628
|
placeholder="请输入防范与整改措施"
|
|
|
629
|
+ :readonly="isCaseSubmitted"
|
|
450
|
630
|
:rules="[{required: true, message: '请输入防范与整改措施'}]"
|
|
451
|
631
|
/>
|
|
452
|
632
|
|
|
453
|
|
-
|
|
454
|
|
-
|
|
455
|
633
|
<van-field label="附件上传" >
|
|
456
|
634
|
<template #input>
|
|
457
|
635
|
<AttachmentS3 :f-id="result" />
|
|
458
|
636
|
</template>
|
|
459
|
637
|
</van-field>
|
|
460
|
638
|
<div style="margin: 16px;">
|
|
461
|
|
- <van-button round block type="primary" native-type="submit">
|
|
|
639
|
+ <van-button v-if="!isReadOnly" round block type="primary" native-type="submit">
|
|
462
|
640
|
{{ isEdit ? '保存' : '提交' }}
|
|
463
|
641
|
</van-button>
|
|
464
|
642
|
</div>
|