|
|
@@ -24,16 +24,51 @@ try {
|
|
24
|
24
|
deptInformation.value = jsonArray ? JSON.parse(jsonArray) : [];
|
|
25
|
25
|
} catch (error) {
|
|
26
|
26
|
deptInformation.value = [];
|
|
|
27
|
+ console.error('解析部门信息失败:', error)
|
|
27
|
28
|
}
|
|
28
|
|
-const deptName = deptInformation.value[0].deptName
|
|
29
|
|
-const deptCode = deptInformation.value[0].deptCode
|
|
30
|
29
|
|
|
31
|
|
-const guid = () => {
|
|
32
|
|
- function S4() {
|
|
33
|
|
- return (((1+Math.random())*0x10000)|0).toString(16).substring(1);
|
|
34
|
|
- }
|
|
35
|
|
- return (S4()+S4()+S4()+S4()+S4()+S4()+S4()+S4())
|
|
|
30
|
+
|
|
|
31
|
+const deptName = deptInformation.value[0]?.deptName || ''
|
|
|
32
|
+const deptCode = deptInformation.value[0]?.deptCode || ''
|
|
|
33
|
+
|
|
|
34
|
+// 如果部门信息为空,给出提示
|
|
|
35
|
+if (!deptCode) {
|
|
|
36
|
+ console.warn('部门编码为空,可能影响数据保存')
|
|
36
|
37
|
}
|
|
|
38
|
+
|
|
|
39
|
+
|
|
|
40
|
+
|
|
|
41
|
+// 添加:与Web端一致的 generateCode 函数
|
|
|
42
|
+const generateCode = () => {
|
|
|
43
|
+ // 获取当前日期并格式化为 YYYYMMDD
|
|
|
44
|
+ const now = new Date();
|
|
|
45
|
+ const year = now.getFullYear();
|
|
|
46
|
+ const month = String(now.getMonth() + 1).padStart(2, '0'); // 月份从0开始,需加1
|
|
|
47
|
+ const day = String(now.getDate()).padStart(2, '0');
|
|
|
48
|
+ const formattedDate = `${year}${month}${day}`;
|
|
|
49
|
+
|
|
|
50
|
+ // 时间部分:HHmmss
|
|
|
51
|
+ const hours = String(now.getHours()).padStart(2, '0');
|
|
|
52
|
+ const minutes = String(now.getMinutes()).padStart(2, '0');
|
|
|
53
|
+ const seconds = String(now.getSeconds()).padStart(2, '0');
|
|
|
54
|
+ const formattedTime = `${hours}${minutes}${seconds}`;
|
|
|
55
|
+
|
|
|
56
|
+ // 模拟生成三位流水号(可以根据需要替换为递增逻辑)
|
|
|
57
|
+ const sequenceNumber = Math.floor(Math.random() * 1000); // 随机生成 0-999
|
|
|
58
|
+ const paddedSequence = String(sequenceNumber).padStart(3, '0'); // 补零到三位
|
|
|
59
|
+
|
|
|
60
|
+ // 拼接编号
|
|
|
61
|
+ return `LZFJ${formattedDate}${formattedTime}${paddedSequence}`;
|
|
|
62
|
+};
|
|
|
63
|
+
|
|
|
64
|
+// 使用 ref 存储生成的编号
|
|
|
65
|
+const generatedCode = ref(generateCode());
|
|
|
66
|
+
|
|
|
67
|
+// 定义重新生成编号的方法
|
|
|
68
|
+const regenerateCode = () => {
|
|
|
69
|
+ generatedCode.value = generateCode();
|
|
|
70
|
+};
|
|
|
71
|
+
|
|
37
|
72
|
const formJieguo = ref({
|
|
38
|
73
|
resultWhether:'',
|
|
39
|
74
|
resultDetail:'',
|
|
|
@@ -49,13 +84,32 @@ const userName1=localStorage.getItem('userName');
|
|
49
|
84
|
|
|
50
|
85
|
const result=ref('')
|
|
51
|
86
|
const fromVue=ref({})
|
|
|
87
|
+
|
|
|
88
|
+// 修复:新增时初始化基础字段(与Web端保持一致)
|
|
52
|
89
|
if (route.query.mark) {
|
|
53
|
90
|
planInfo = JSON.parse(route.query.mark)
|
|
54
|
91
|
}
|
|
|
92
|
+
|
|
55
|
93
|
console.log(planInfo);
|
|
56
|
94
|
if (planInfo==-1){
|
|
57
|
|
- result.value=guid()
|
|
58
|
|
- console.log( result.value);
|
|
|
95
|
+ // 新增模式:初始化基础字段(与Web端handAdd函数保持一致)
|
|
|
96
|
+ regenerateCode() // 重新生成编号
|
|
|
97
|
+ result.value = generatedCode.value // 使用 generateCode 生成的编号
|
|
|
98
|
+ fromVue.value = {
|
|
|
99
|
+ id: '', // 新增时 id 为空字符串
|
|
|
100
|
+ fileName: '',
|
|
|
101
|
+ fileType: '',
|
|
|
102
|
+ fileContent: '',
|
|
|
103
|
+ fileTime: '', // 添加:Web端有此字段
|
|
|
104
|
+ filePeoples: '', // 添加:Web端有此字段
|
|
|
105
|
+ fileSubmit: '',
|
|
|
106
|
+ remarks: '',
|
|
|
107
|
+ enable: '',
|
|
|
108
|
+ fileNumber: '',
|
|
|
109
|
+ yearValue: '', // H5端特有
|
|
|
110
|
+ fileId: result.value
|
|
|
111
|
+ }
|
|
|
112
|
+ console.log('生成的 fileId:', result.value);
|
|
59
|
113
|
}
|
|
60
|
114
|
|
|
61
|
115
|
const resDetail=ref('')
|
|
|
@@ -80,7 +134,6 @@ if (planInfo==1) {
|
|
80
|
134
|
console.log(planInfo);
|
|
81
|
135
|
title = '修改安全文件'
|
|
82
|
136
|
fromVue.value= JSON.parse(route.query.data)
|
|
83
|
|
-
|
|
84
|
137
|
result.value=fromVue.value.fileId
|
|
85
|
138
|
console.log(result.value);
|
|
86
|
139
|
}
|
|
|
@@ -100,15 +153,18 @@ const planLevelList = [
|
|
100
|
153
|
const isdisabled=ref(true)
|
|
101
|
154
|
const isdisabled2=ref(true)
|
|
102
|
155
|
const onSelect = (item) => {
|
|
103
|
|
-fromVue.value.fileContent = item.name
|
|
104
|
|
-
|
|
|
156
|
+ fromVue.value.fileContent = item.name
|
|
105
|
157
|
showActionSheet.value=false
|
|
|
158
|
+ // 性质改变时也触发文件编号生成
|
|
|
159
|
+ generateFileSumbmit()
|
|
106
|
160
|
}
|
|
107
|
161
|
|
|
108
|
162
|
const onSelect2 = (item) => {
|
|
109
|
163
|
fromVue.value.fileType=item.name
|
|
110
|
164
|
showActionSheet2.value=false
|
|
111
|
|
- }
|
|
|
165
|
+ // 文件类别改变时触发文件编号生成
|
|
|
166
|
+ generateFileSumbmit()
|
|
|
167
|
+}
|
|
112
|
168
|
|
|
113
|
169
|
const displayFileName = ref('')
|
|
114
|
170
|
const onSelect1 = (item) => {
|
|
|
@@ -119,6 +175,39 @@ const onSelect1 = (item) => {
|
|
119
|
175
|
console.log(result.value);
|
|
120
|
176
|
showActionSheet1.value = false
|
|
121
|
177
|
}
|
|
|
178
|
+
|
|
|
179
|
+const yearOptions = Array.from({ length: 10 }, (_, i) => {
|
|
|
180
|
+ const year = currentYear.value - 5 + i; // 修复:使用 currentYear.value
|
|
|
181
|
+ return {
|
|
|
182
|
+ text: String(year),
|
|
|
183
|
+ value: String(year)
|
|
|
184
|
+ };
|
|
|
185
|
+}).reverse();
|
|
|
186
|
+const showYearPicker = ref(false);
|
|
|
187
|
+
|
|
|
188
|
+const formData = ref({
|
|
|
189
|
+ year: String(currentYear.value), // 修复:使用 currentYear.value
|
|
|
190
|
+ quarter: null
|
|
|
191
|
+})
|
|
|
192
|
+
|
|
|
193
|
+// 年份选择确认
|
|
|
194
|
+const onConfirmYear = (value) => {
|
|
|
195
|
+ let selectedYear = '';
|
|
|
196
|
+ if (value && value.selectedOptions && value.selectedOptions.length > 0) {
|
|
|
197
|
+ const selectedOption = value.selectedOptions[0];
|
|
|
198
|
+ selectedYear = typeof selectedOption === 'string' ? selectedOption : selectedOption.value || selectedOption.text;
|
|
|
199
|
+ } else if (typeof value === 'string') {
|
|
|
200
|
+ selectedYear = value;
|
|
|
201
|
+ }
|
|
|
202
|
+
|
|
|
203
|
+ formData.value.year = selectedYear;
|
|
|
204
|
+ fromVue.value.yearValue = selectedYear; // 修复:同步到 fromVue
|
|
|
205
|
+ showYearPicker.value = false;
|
|
|
206
|
+ // 触发文件编号生成,而不是调用不存在的 search()
|
|
|
207
|
+ generateFileSumbmit();
|
|
|
208
|
+}
|
|
|
209
|
+
|
|
|
210
|
+
|
|
122
|
211
|
const questionIds = ref([])
|
|
123
|
212
|
const actions=ref([])
|
|
124
|
213
|
/*const getQuestionId = () => {
|
|
|
@@ -129,7 +218,7 @@ const actions=ref([])
|
|
129
|
218
|
questionIds.value = response.data.data; // 先赋值给 questionIds.value
|
|
130
|
219
|
|
|
131
|
220
|
|
|
132
|
|
- // ✅ 关键:使用 questionIds.value.map
|
|
|
221
|
+ // 关键:使用 questionIds.value.map
|
|
133
|
222
|
actions.value = questionIds.value.map(item => ({
|
|
134
|
223
|
name: item.ruleName,
|
|
135
|
224
|
value: item.id
|
|
|
@@ -181,26 +270,73 @@ const handleTableDataUserDeptUpdate = async (nodeData) => {
|
|
181
|
270
|
}
|
|
182
|
271
|
|
|
183
|
272
|
const addEmergencyDrillPlan = async () => {
|
|
|
273
|
+ // 参数验证
|
|
|
274
|
+ if (!deptCode) {
|
|
|
275
|
+ showFailToast('获取部门信息失败,请重新登录')
|
|
|
276
|
+ return
|
|
|
277
|
+ }
|
|
|
278
|
+
|
|
|
279
|
+ if (!result.value) {
|
|
|
280
|
+ showFailToast('文件ID生成失败,请重试')
|
|
|
281
|
+ return
|
|
|
282
|
+ }
|
|
|
283
|
+
|
|
|
284
|
+ // 表单验证
|
|
|
285
|
+ if (!fromVue.value.fileName) {
|
|
|
286
|
+ showFailToast('请输入文件名称')
|
|
|
287
|
+ return
|
|
|
288
|
+ }
|
|
|
289
|
+
|
|
|
290
|
+ if (!fromVue.value.fileType) {
|
|
|
291
|
+ showFailToast('请选择文件类别')
|
|
|
292
|
+ return
|
|
|
293
|
+ }
|
|
|
294
|
+
|
|
184
|
295
|
const loadingToast = showLoadingToast({
|
|
185
|
296
|
duration: 0,
|
|
186
|
297
|
message: '加载中',
|
|
187
|
298
|
forbidClick: true
|
|
188
|
299
|
})
|
|
189
|
|
- var url = '/sgsafe/ResponFile/save1';
|
|
190
|
|
- const params = {
|
|
191
|
|
- json: JSON.stringify(fromVue.value)
|
|
192
|
|
- }
|
|
193
|
|
- proxy.$axios.post(url,params).then(res=>{
|
|
|
300
|
+
|
|
|
301
|
+ try {
|
|
|
302
|
+ // 与Web端保持一致:只设置 addDeptCode,其他字段已经在 fromVue.value 中
|
|
|
303
|
+ fromVue.value.addDeptCode = deptCode
|
|
|
304
|
+
|
|
|
305
|
+ // 确保 fileId 正确设置
|
|
|
306
|
+ if (!fromVue.value.fileId) {
|
|
|
307
|
+ fromVue.value.fileId = result.value
|
|
|
308
|
+ }
|
|
|
309
|
+
|
|
|
310
|
+ // 确保文件编号已生成
|
|
|
311
|
+ if (!fromVue.value.fileSubmit && fromVue.value.fileType && fromVue.value.yearValue) {
|
|
|
312
|
+ generateFileSumbmit()
|
|
|
313
|
+ }
|
|
|
314
|
+
|
|
|
315
|
+ // 调试:打印完整数据(与Web端保持一致)
|
|
|
316
|
+ console.log('保存的数据:', JSON.stringify(fromVue.value))
|
|
|
317
|
+
|
|
|
318
|
+ var url = '/sgsafe/ResponFile/save1';
|
|
|
319
|
+ const params = {
|
|
|
320
|
+ json: JSON.stringify(fromVue.value)
|
|
|
321
|
+ }
|
|
|
322
|
+
|
|
|
323
|
+ const res = await proxy.$axios.post(url, params)
|
|
|
324
|
+
|
|
194
|
325
|
if (res.data.code === 0) {
|
|
195
|
326
|
loadingToast.close()
|
|
196
|
327
|
showSuccessToast('保存成功')
|
|
197
|
328
|
onClickLeft()
|
|
198
|
|
-
|
|
199
|
329
|
} else {
|
|
200
|
330
|
loadingToast.close()
|
|
201
|
|
- showFailToast('操作失败!' + res.data.msg)
|
|
|
331
|
+ showFailToast('操作失败!' + (res.data.msg || '未知错误'))
|
|
202
|
332
|
}
|
|
203
|
|
- })
|
|
|
333
|
+ } catch (error) {
|
|
|
334
|
+ loadingToast.close()
|
|
|
335
|
+ console.error('保存失败:', error)
|
|
|
336
|
+ // 打印详细错误信息
|
|
|
337
|
+ console.error('错误详情:', error.response?.data || error)
|
|
|
338
|
+ showFailToast('保存失败:' + (error.message || '网络错误,请稍后重试'))
|
|
|
339
|
+ }
|
|
204
|
340
|
}
|
|
205
|
341
|
const showDatePicker = ref(false)
|
|
206
|
342
|
const onDatePicker = (value) => {
|
|
|
@@ -214,24 +350,69 @@ const dicList = ref([])
|
|
214
|
350
|
//获取字典集合
|
|
215
|
351
|
import tools from '@/tools'
|
|
216
|
352
|
const getDicList = () => {
|
|
217
|
|
- tools.dic.getDicList(['systemTypes']).then((response => {
|
|
218
|
|
-
|
|
219
|
|
- const rawData = response.data.data
|
|
220
|
|
- dicList.value = rawData.systemTypes.map(item => ({
|
|
221
|
|
- name: item.dicName, // 必须有 name 字段!
|
|
222
|
|
- code: item.dicCode // 可选,保留原始 code 供后续使用
|
|
|
353
|
+ // 修复:使用 'fileTypes' 而不是 'systemTypes'
|
|
|
354
|
+ tools.dic.getDicList(['fileTypes']).then((response => {
|
|
|
355
|
+ const rawData = response.data.data
|
|
|
356
|
+ // 修复:使用 fileTypes 而不是 systemTypes,value 使用 dicName
|
|
|
357
|
+ dicList.value = rawData.fileTypes.map(item => ({
|
|
|
358
|
+ name: item.dicName, // 使用 dicName
|
|
|
359
|
+ value: item.dicName // value 也使用 dicName,与 web 端保持一致
|
|
223
|
360
|
}));
|
|
224
|
361
|
console.log(JSON.stringify(dicList.value))
|
|
225
|
362
|
}))
|
|
226
|
363
|
}
|
|
|
364
|
+
|
|
|
365
|
+// 新增:文件编号自动生成函数
|
|
|
366
|
+const generateFileSumbmit = () => {
|
|
|
367
|
+ let fileSubmit = ''
|
|
|
368
|
+
|
|
|
369
|
+ // 1. 根据文件类别拼接前缀
|
|
|
370
|
+ if (fromVue.value.fileType && fromVue.value.fileType !== '其他') {
|
|
|
371
|
+ const prefixMap = {
|
|
|
372
|
+ '安全正式发文': '山信安管便字',
|
|
|
373
|
+ '安全管理便文': '山信软件安字',
|
|
|
374
|
+ '环保正式发文': '山信软件环字',
|
|
|
375
|
+ '安委会纪要': '山信软件纪要安委字'
|
|
|
376
|
+ }
|
|
|
377
|
+ const prefix = prefixMap[fromVue.value.fileType]
|
|
|
378
|
+ if (prefix) {
|
|
|
379
|
+ fileSubmit += prefix
|
|
|
380
|
+ }
|
|
|
381
|
+ }
|
|
|
382
|
+
|
|
|
383
|
+ // 2. 拼接年份
|
|
|
384
|
+ if (fromVue.value.yearValue) {
|
|
|
385
|
+ fileSubmit += `〔${fromVue.value.yearValue}〕`
|
|
|
386
|
+ }
|
|
|
387
|
+
|
|
|
388
|
+ // 3. 拼接编号
|
|
|
389
|
+ if (fromVue.value.fileNumber) {
|
|
|
390
|
+ fileSubmit += `${fromVue.value.fileNumber}号`
|
|
|
391
|
+ }
|
|
|
392
|
+
|
|
|
393
|
+ // 更新文件编号
|
|
|
394
|
+ fromVue.value.fileSubmit = fileSubmit
|
|
|
395
|
+}
|
|
|
396
|
+
|
|
227
|
397
|
onMounted(() => {
|
|
228
|
398
|
const today = new Date()
|
|
229
|
399
|
const year = today.getFullYear()
|
|
230
|
|
- const month = today.getMonth() + 1 // 月份从 0 开始
|
|
|
400
|
+ const month = today.getMonth() + 1
|
|
231
|
401
|
const day = today.getDate()
|
|
232
|
402
|
currentDate.value = [year, month, day]
|
|
233
|
|
- //selectedDateText.value = `${year}-${String(month).padStart(2, '0')}-${String(day).padStart(2, '0')}`
|
|
|
403
|
+
|
|
|
404
|
+ // 新增:初始化年份值
|
|
|
405
|
+ if (!fromVue.value.yearValue) {
|
|
|
406
|
+ fromVue.value.yearValue = String(year)
|
|
|
407
|
+ formData.value.year = String(year)
|
|
|
408
|
+ }
|
|
|
409
|
+
|
|
234
|
410
|
getDicList()
|
|
|
411
|
+
|
|
|
412
|
+ // 新增:如果是编辑模式,初始化文件编号生成
|
|
|
413
|
+ if (planInfo == 1) {
|
|
|
414
|
+ generateFileSumbmit()
|
|
|
415
|
+ }
|
|
235
|
416
|
})
|
|
236
|
417
|
const showActionSheet2=ref(false)
|
|
237
|
418
|
/* 文件上传 */
|
|
|
@@ -240,7 +421,7 @@ import AttachmentS3 from '@/components/AttachmentS3.vue';
|
|
240
|
421
|
const onSubmit = (values) => {
|
|
241
|
422
|
addEmergencyDrillPlan()
|
|
242
|
423
|
}
|
|
243
|
|
-const leaderKeyysr = guid();
|
|
|
424
|
+const leaderKeyysr = generateCode(); // 或者保留 guid 用于其他用途
|
|
244
|
425
|
const PopupDepartmentLeaderNameRefysr = ref();
|
|
245
|
426
|
const handleDepartmentLeaderNameysr = () => {
|
|
246
|
427
|
PopupDepartmentLeaderNameRefysr.value.open();
|
|
|
@@ -266,12 +447,14 @@ const getDepartmentLeaderNameysr = (item) => {
|
|
266
|
447
|
</van-sticky>
|
|
267
|
448
|
<div class="scroll-container">
|
|
268
|
449
|
<van-form @submit="onSubmit">
|
|
|
450
|
+ <!-- 修复:文件编号改为只读,提示自动生成 -->
|
|
269
|
451
|
<van-field
|
|
270
|
452
|
v-model="fromVue.fileSubmit"
|
|
271
|
453
|
label="文件编号"
|
|
272
|
454
|
name="fileSubmit"
|
|
273
|
455
|
required
|
|
274
|
|
- placeholder="请输入文件编号"
|
|
|
456
|
+ placeholder="选择文件类别、年份、编号后自动生成"
|
|
|
457
|
+ readonly
|
|
275
|
458
|
:rules="[{required: true, message: '请输入文件编号'}]"
|
|
276
|
459
|
/>
|
|
277
|
460
|
|
|
|
@@ -280,7 +463,7 @@ const getDepartmentLeaderNameysr = (item) => {
|
|
280
|
463
|
label="名称"
|
|
281
|
464
|
name="fileName"
|
|
282
|
465
|
required
|
|
283
|
|
- placeholder="请输入文件编号"
|
|
|
466
|
+ placeholder="请输入文件名称"
|
|
284
|
467
|
:rules="[{required: true, message: '请输入文件名称'}]"
|
|
285
|
468
|
/>
|
|
286
|
469
|
|
|
|
@@ -292,6 +475,33 @@ const getDepartmentLeaderNameysr = (item) => {
|
|
292
|
475
|
required
|
|
293
|
476
|
@click="showActionSheet2 = true"
|
|
294
|
477
|
/>
|
|
|
478
|
+
|
|
|
479
|
+ <van-field
|
|
|
480
|
+ :model-value="fromVue.yearValue"
|
|
|
481
|
+ is-link
|
|
|
482
|
+ readonly
|
|
|
483
|
+ name="yearValue"
|
|
|
484
|
+ label="年份"
|
|
|
485
|
+ placeholder="点击选择年份"
|
|
|
486
|
+ @click="showYearPicker = true"
|
|
|
487
|
+ />
|
|
|
488
|
+ <van-popup v-model:show="showYearPicker" position="bottom">
|
|
|
489
|
+ <van-picker
|
|
|
490
|
+ :columns="yearOptions"
|
|
|
491
|
+ @confirm="onConfirmYear"
|
|
|
492
|
+ @cancel="showYearPicker = false"
|
|
|
493
|
+ />
|
|
|
494
|
+ </van-popup>
|
|
|
495
|
+
|
|
|
496
|
+ <!-- 新增:编号输入框 -->
|
|
|
497
|
+ <van-field
|
|
|
498
|
+ v-model="fromVue.fileNumber"
|
|
|
499
|
+ label="编号"
|
|
|
500
|
+ name="fileNumber"
|
|
|
501
|
+ placeholder="请输入编号"
|
|
|
502
|
+ @input="generateFileSumbmit"
|
|
|
503
|
+ />
|
|
|
504
|
+
|
|
295
|
505
|
<van-field
|
|
296
|
506
|
readonly
|
|
297
|
507
|
v-model="fromVue.fileContent"
|
|
|
@@ -304,13 +514,14 @@ const getDepartmentLeaderNameysr = (item) => {
|
|
304
|
514
|
v-model="fromVue.remarks"
|
|
305
|
515
|
label="备注"
|
|
306
|
516
|
name="remarks"
|
|
307
|
|
-
|
|
308
|
517
|
/>
|
|
|
518
|
+
|
|
309
|
519
|
<van-field label="附件上传" >
|
|
310
|
520
|
<template #input>
|
|
311
|
521
|
<AttachmentS3 :f-id="result" />
|
|
312
|
522
|
</template>
|
|
313
|
523
|
</van-field>
|
|
|
524
|
+
|
|
314
|
525
|
<div style="margin: 16px;">
|
|
315
|
526
|
<van-button round block type="primary" native-type="submit">
|
|
316
|
527
|
提交
|