2 Revize

Autor SHA1 Zpráva Datum
  jiajunchen 08d47fc68a 1 před 2 týdny
  jiajunchen 862ddca1f2 管理档案 před 2 týdny

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

@@ -604,6 +604,16 @@ const router = createRouter({
604 604
 			name: '事故案例编辑',
605 605
 			component: () => import('@/view/knowledge/accidentList.vue')
606 606
 		},
607
+		{
608
+			path: '/knowledge/manager',
609
+			name: '管理案例',
610
+			component: () => import('@/view/knowledge/manager.vue')
611
+		},
612
+		{
613
+			path: '/managerList',
614
+			name: '管理案例编辑',
615
+			component: () => import('@/view/knowledge/managerList.vue')
616
+		},
607 617
 	]
608 618
 })
609 619
 

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

@@ -240,6 +240,10 @@
240 240
           <img src="../../public/images/yj.png" width="45rpx" />
241 241
           <span class="vanicon_text">通知公告</span>
242 242
         </van-grid-item>
243
+        <van-grid-item to="/knowledge/manager">
244
+          <img src="../../public/images/zd.png" width="45rpx" />
245
+          <span class="vanicon_text">管理案例</span>
246
+        </van-grid-item>
243 247
       </van-grid>
244 248
     </div>
245 249
 

+ 617
- 0
src/view/knowledge/manager.vue Zobrazit soubor

@@ -0,0 +1,617 @@
1
+<template>
2
+  <div class="h5-container">
3
+    <van-nav-bar title="管理案例" @click-left="onClickLeft" @click-right="handAdd">
4
+      <template #right>
5
+        <van-icon name="add" size="25" color="#000" />
6
+      </template>
7
+    </van-nav-bar>
8
+    <van-search v-model="query.caseTitle" show-action placeholder="请输入案例标题" @search="onRefresh"
9
+                @cancel="handdelectTitle" />
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 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="edits(item)">
19
+                  <template #title>
20
+                    <div class="cell-title">
21
+                      {{ item.caseTitle }}
22
+                    </div>
23
+                  </template>
24
+                  <template #label>
25
+                      <div>案例编号:{{ item.caseNumber }} </div>
26
+                      <div>案例类型:{{ item.caseType }}</div>
27
+                      <div> 浏览量:{{item.viewCount}}</div>
28
+
29
+<!--                    <div style="width: 112px" :class="getStatusClass(item.isFinish)">
30
+                      类型:
31
+                      <span v-if="item.isFinish === '待学习'" style="width: 200px">待学习</span>
32
+                      <span v-else-if="item.isFinish === '已学习'" style="width: 200px">已学习</span>
33
+                      <span v-else-if="item.isFinish === '已扣除'" style="width: 200px">已扣除</span>
34
+                    </div>-->
35
+                  </template>
36
+                </van-cell>
37
+                <div class="swipe-cell-default-icon">
38
+                  <van-icon v-if="openStatus[idx]" name="arrow-double-left" @click.stop="openSwipe(idx)" />
39
+                  <van-icon v-else name="arrow-double-right" @click.stop="closeSwipe(idx)" />
40
+                </div>
41
+              </div>
42
+            </template>
43
+
44
+            <template #right>
45
+              <van-button  square class="delete-button" text="删除" v-show="item.canDelete"  @click="handleDelete(item)" />
46
+            </template>
47
+          </van-swipe-cell>
48
+        </div>
49
+
50
+      </van-list>
51
+    </van-pull-refresh>
52
+
53
+    <!-- 删除确认弹窗 -->
54
+    <van-dialog v-model:show="deleteDialogVisible" show-cancel-button @confirm="confirmDelete">
55
+      <template #title>
56
+        <div>删除确认</div>
57
+      </template>
58
+      <div style="padding: 30px;">确定要删除该项目吗?</div>
59
+    </van-dialog>
60
+
61
+  </div>
62
+</template>
63
+
64
+<script setup>
65
+import { ref, reactive, onMounted, getCurrentInstance, nextTick, toRaw } from 'vue';
66
+import { Dialog, showDialog, showSuccessToast, showToast, Toast } from 'vant';
67
+
68
+import tools from '@/tools'
69
+
70
+const { proxy } = getCurrentInstance();
71
+
72
+const onClickLeft = () => {
73
+  history.back();
74
+};
75
+const headers = ref({
76
+  token: localStorage.getItem('token'),
77
+  userId: localStorage.getItem('userId'),
78
+  dept: JSON.parse(localStorage.getItem('dept'))[0].deptCode
79
+});
80
+const switchIconState = (idx) => {
81
+  openStatus.value[idx] = !openStatus.value[idx]
82
+  openStatus.value = new Array(resultData.value.length).fill(true);
83
+}
84
+
85
+// const onClickRight = () =>{
86
+//   searchShow.value = !searchShow.value;
87
+// }
88
+
89
+const searchShow = ref(false);
90
+const query = ref({
91
+  caseNumber:'',
92
+  caseTitle:'',
93
+})
94
+
95
+
96
+
97
+const tableData = ref([]);
98
+const selectedRows = ref([]);
99
+const dialogVisibleLook = ref(false);
100
+const deleteDialogVisible = ref(false);
101
+const currentDeleteItem = ref([]);
102
+const dialogVisible = ref(false);
103
+const dialogVisibleFile = ref(false);
104
+const date = ref(null);
105
+
106
+const kz = ref(true);
107
+import { useRouter } from 'vue-router';
108
+const router = useRouter();
109
+const handAdd =  () => {
110
+
111
+  router.push({ path: "/managerList",
112
+    query: {
113
+      mark:-1
114
+    } });
115
+
116
+};
117
+const goaddPeo = (item) => {
118
+  router.push({
119
+    path: '/addPeo',
120
+    query: {
121
+      data: JSON.stringify(item)
122
+    }
123
+  })
124
+}
125
+
126
+const edits = (row) => {
127
+  const isOwner = String(row.addId) === currentUserId;
128
+  kz.value = true;
129
+  form.value = { ...row };
130
+  router.push({ path: "/managerList",
131
+    query: {
132
+      mark:1,
133
+      data:JSON.stringify(form.value),
134
+      readOnly: !isOwner ? 'true' : undefined
135
+    } });
136
+  //浏览量
137
+  saveManagerRecord(form.value)
138
+};
139
+
140
+const saveManagerRecord = async (formValue) => {
141
+  const payload = formValue;
142
+  payload.viewCount = String((Number(payload.viewCount) || 0) + 1);
143
+
144
+  var url = '/sgsafe/Manager/save';
145
+  var param = {
146
+    json: JSON.stringify(payload)
147
+  };
148
+  proxy.$axios.post(url, param).then(response => {
149
+    if (response.data.code == '0') {
150
+      getTableData();
151
+    }
152
+  });
153
+};
154
+const form = ref({
155
+  caseNumber:'',
156
+  caseTitle:'',
157
+  caseSource:'',
158
+  accidentLevel:'',
159
+  accidentDept:'',
160
+  accidentLocation:'',
161
+  accidentTime:'',
162
+  accidentType:'',
163
+  accidentTags:'',
164
+  casualtyCount:'',
165
+  accidentSummary:'',
166
+  preventiveMeasures:'',
167
+  fileId:'',
168
+  viewCount:'',
169
+  downloadCount:''
170
+});
171
+
172
+
173
+const isRefreshing = ref(false);
174
+const isLoading = ref(false);
175
+const isFinished = ref(false);
176
+const currentPage = ref(1);
177
+const pageSize = ref(10);
178
+const totalRows = ref(0);
179
+const resultData = ref([]);
180
+
181
+const dept=localStorage.getItem("dept")[0].deptCode;
182
+const currentUserId = String(localStorage.getItem('userId'));
183
+const getTableData = async () => {
184
+  var url = '/sgsafe/Manager/query'
185
+  var param = {
186
+    page: currentPage.value,
187
+    rows: pageSize.value,
188
+    params: JSON.stringify(query.value)
189
+  }
190
+  const response = await proxy.$axios.get(url, param);
191
+  if (response.data.code == 0) {
192
+    tableData.value = response.data.data.records.map(item => ({
193
+      ...item,
194
+      canDelete: String(item.addId) === currentUserId
195
+    }));
196
+    console.log('列表数据',tableData.value)
197
+    totalRows.value = response.data.data.total;
198
+  } else {
199
+    showToast({
200
+      type: 'error',
201
+      message: '操作失败!' + response.data.msg
202
+    });
203
+  }
204
+};
205
+const ruleIds = ref([]);
206
+
207
+const onRefresh = () => {
208
+  basicReset();
209
+  onLoad();
210
+};
211
+
212
+//*************************************
213
+
214
+
215
+
216
+//定义字典集合
217
+const dicList = ref([])
218
+
219
+const getDicList = () => {
220
+  tools.dic.getDicList([ 'case_type','SEX', 'case_source','accident_level','accident_type','sgsafe_taccidentTags']).then((response => {
221
+    console.log(JSON.stringify(response.data.data))
222
+    dicList.value = response.data.data
223
+
224
+  }))
225
+}
226
+
227
+
228
+const onLoad = async () => {
229
+  if (isRefreshing.value) {
230
+    resultData.value = [];
231
+    currentPage.value = 1;
232
+    isRefreshing.value = false;
233
+  }
234
+
235
+  getDicList()
236
+
237
+
238
+
239
+
240
+
241
+  try {
242
+    await getTableData();
243
+
244
+    if (pageSize.value * currentPage.value < totalRows.value) {
245
+      resultData.value = [...resultData.value, ...tableData.value];
246
+      openStatus.value = new Array(resultData.value.length).fill(true);
247
+      currentPage.value++;
248
+
249
+    } else {
250
+      resultData.value = [...resultData.value, ...tableData.value];
251
+      openStatus.value = new Array(resultData.value.length).fill(true);
252
+      isFinished.value = true;
253
+    }
254
+
255
+    console.log('resultData',resultData.value)
256
+  } catch (error) {
257
+    console.log(error);
258
+    isFinished.value = true;
259
+  } finally {
260
+    isLoading.value = false;
261
+  }
262
+};
263
+/* 通用方法: 重置list数据 */
264
+const basicReset = () => {
265
+  isFinished.value = false;
266
+  isLoading.value = true;
267
+  currentPage.value = 1;
268
+  resultData.value = [];
269
+};
270
+
271
+/*onMounted(() => {
272
+  handleSearch();
273
+});
274
+
275
+const handleSearch = () => {
276
+/!*  currentPage.value = 1;
277
+  isFinished.value = false;
278
+  tableData.value = [];*!/
279
+  basicReset()
280
+  onLoad()
281
+};*/
282
+
283
+const handdelectNumber = () => {
284
+  query.value.caseNumber = '';
285
+  onRefresh()
286
+};
287
+
288
+const handdelectTitle = () => {
289
+  query.value.caseTitle = '';
290
+  onRefresh()
291
+};
292
+
293
+
294
+
295
+
296
+// 定义生成编号的函数
297
+const generateCode = () => {
298
+  // 获取当前日期并格式化为 YYYYMMDD
299
+  const now = new Date();
300
+  const year = now.getFullYear();
301
+  const month = String(now.getMonth() + 1).padStart(2, '0'); // 月份从0开始,需加1
302
+  const day = String(now.getDate()).padStart(2, '0');
303
+  const formattedDate = `${year}${month}${day}`;
304
+  // 时间部分:HHmmss
305
+  const hours = String(now.getHours()).padStart(2, '0');
306
+  const minutes = String(now.getMinutes()).padStart(2, '0');
307
+  const seconds = String(now.getSeconds()).padStart(2, '0');
308
+  const formattedTime = `${hours}${minutes}${seconds}`;
309
+
310
+  // 模拟生成三位流水号(可以根据需要替换为递增逻辑)
311
+  const sequenceNumber = Math.floor(Math.random() * 1000); // 随机生成 0-999
312
+  const paddedSequence = String(sequenceNumber).padStart(3, '0'); // 补零到三位
313
+
314
+  // 拼接编号
315
+  return `SGAL${formattedDate}${formattedTime}${paddedSequence}`;
316
+};
317
+
318
+// 使用 ref 存储生成的编号
319
+const generatedCode = ref(generateCode());
320
+
321
+// 定义重新生成编号的方法
322
+const regenerateCode = () => {
323
+  generatedCode.value = generateCode();
324
+};
325
+
326
+const handleDetailLook = (row) => {
327
+  form.value = { ...row };
328
+  proxy.$router.push({
329
+    name: 'taiZhang_detail',
330
+    query: {
331
+      form: form.value.id
332
+    }
333
+  });
334
+  // dialogVisibleLook.value = true;
335
+};
336
+const deleteData=ref({})
337
+
338
+const handleDelete = (item) => {
339
+
340
+  deleteData.value=item
341
+  const now = new Date();
342
+  const year = now.getFullYear();
343
+  const month = String(now.getMonth() + 1).padStart(2, '0'); // 月份从0开始
344
+  const day = String(now.getDate()).padStart(2, '0');
345
+  const hours = String(now.getHours()).padStart(2, '0');
346
+  const minutes = String(now.getMinutes()).padStart(2, '0');
347
+  const seconds = String(now.getSeconds()).padStart(2, '0');
348
+  deleteData.value.cancelTime = `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
349
+
350
+    deleteData.value.cancelFlag='1'
351
+  var url = '/sgsafe/Manager/save';
352
+  var param = {
353
+    json: JSON.stringify(deleteData.value)
354
+  };
355
+  proxy.$axios.post(url, param).then(response => {
356
+    if (response.data.code == '0') {
357
+      showSuccessToast("删除成功")
358
+      onRefresh();
359
+
360
+    } else {
361
+    }
362
+
363
+  })
364
+};
365
+
366
+
367
+const confirmDelete = () => {
368
+  for (let item of currentDeleteItem.value) {
369
+    if (item.addId !== headers.value.userId) {
370
+      showToast({
371
+        type: 'warning',
372
+        message: '只能删除自己添加的数据!'
373
+      });
374
+      return;
375
+    }
376
+  }
377
+
378
+  if (currentDeleteItem.value[0].status !== '0' && currentDeleteItem.value[0].hdSelect !== '下发隐患'
379
+    && currentDeleteItem.value[0].hdSelect !== '即查即改') {
380
+    showToast({
381
+      type: 'fail',
382
+      message: '只有尚未提交流程的记录或回到起点的流程经过作废后才可以删除!'
383
+    });
384
+    return;
385
+  }
386
+  if (currentDeleteItem.value[0].status !== '2' && currentDeleteItem.value[0].hdSelect === '下发隐患'
387
+    && currentDeleteItem.value[0].hdSelect !== '即查即改') {
388
+    showToast({
389
+      type: 'fail',
390
+      message: '只有尚未提交流程的记录或回到起点的流程经过作废后才可以删除!'
391
+    });
392
+    return;
393
+  }
394
+
395
+  var url = 'sgsafe/Hiddendanger/remove';
396
+  var param = {
397
+    params: JSON.stringify({ ...currentDeleteItem.value.map(x => x.id) })
398
+  };
399
+  proxy.$axios.get(url, param).then(response => {
400
+    if (response.data.code == 0) {
401
+      showToast({
402
+        type: 'success',
403
+        message: '删除成功'
404
+      });
405
+      onRefresh();
406
+    } else {
407
+      showToast({
408
+        type: 'fail',
409
+        message: '操作失败!' + response.data.msg
410
+      });
411
+    }
412
+  });
413
+};
414
+
415
+
416
+
417
+
418
+const resetForm = () => {
419
+  form.value = {
420
+    projectName: '',
421
+    projectLeader: '',
422
+    phone: '',
423
+    dept: ''
424
+  };
425
+};
426
+
427
+
428
+//处理人员code
429
+const repairLL = ref('');
430
+const repairOO = ref('');
431
+const acceptLL = ref('');
432
+
433
+const jsons = ref({});
434
+
435
+const reback = () => {
436
+  // 返回逻辑
437
+};
438
+
439
+const deleteRow = (row) => {
440
+  selectedRows.value = [row];
441
+  handleDelete(row);
442
+};
443
+
444
+const deleteRowa = (row) => {
445
+  deleteRow(row);
446
+};
447
+
448
+/**
449
+ * 按钮实现swipe-cell滑动
450
+ */
451
+const openStatus = ref([])
452
+const swipeCellRefs = ref([])
453
+const getSwipeCellRef = (el, index) => {
454
+  if (el) {
455
+    swipeCellRefs.value[index] = el;
456
+  }
457
+}
458
+const openSwipe = (idx) => {
459
+  openStatus.value = new Array(resultData.value.length).fill(true);
460
+  if (idx >= 0 && idx < swipeCellRefs.value.length) {
461
+    openStatus.value[idx] = false
462
+    swipeCellRefs.value[idx].open('right')
463
+  }
464
+  document.addEventListener('click', handleDocumentClick)
465
+}
466
+/**
467
+ * 当点击滑动单元格时,开始监听点击事件
468
+ */
469
+const handleDocumentClick = (event) => {
470
+  openStatus.value = new Array(resultData.value.length).fill(true);
471
+}
472
+
473
+const closeSwipe = (idx) => {
474
+  if (idx >= 0 && idx < swipeCellRefs.value.length) {
475
+    openStatus.value[idx] = true
476
+    swipeCellRefs.value[idx].close()
477
+  }
478
+}
479
+// *********************************** 事故案例 ************************************************
480
+
481
+
482
+
483
+
484
+
485
+</script>
486
+
487
+<style scoped>
488
+.h5-container {
489
+  width: 100%;
490
+  padding: 5px;
491
+  box-sizing: border-box;
492
+}
493
+
494
+.status-pending {
495
+  background-color: #fff3cd;
496
+  color: #856404;
497
+  padding: 2px 4px;
498
+  border-radius: 4px;
499
+}
500
+
501
+.status-registered {
502
+  background-color: #d1ecf1;
503
+  color: #0c5460;
504
+  padding: 2px 4px;
505
+  border-radius: 4px;
506
+}
507
+
508
+.status-analyzing {
509
+  background-color: #fff8e1;
510
+  color: #ff8f00;
511
+  padding: 2px 4px;
512
+  border-radius: 4px;
513
+}
514
+
515
+.status-rectifying {
516
+  background-color: #e8f5e9;
517
+  color: #2e7d32;
518
+  padding: 2px 4px;
519
+  border-radius: 4px;
520
+}
521
+
522
+.status-accepting {
523
+  background-color: #e3f2fd;
524
+  color: #1565c0;
525
+  padding: 2px 2px;
526
+  border-radius: 2px;
527
+}
528
+
529
+.status-closed {
530
+  background-color: #f8bbd0;
531
+  color: #b71c1c;
532
+  padding: 2px 2px;
533
+  border-radius: 2px;
534
+}
535
+
536
+.status-finished {
537
+  background-color: #e8eaf6;
538
+  color: #311b92;
539
+  padding: 2px 2px;
540
+  border-radius: 2px;
541
+}
542
+
543
+.status-unknown {
544
+  background-color: #efebe9;
545
+  color: #424242;
546
+  padding: 2px 2px;
547
+  border-radius: 2px;
548
+}
549
+
550
+.cell-title {
551
+  display: -webkit-box;
552
+  /* 旧版弹性盒子模型 */
553
+  -webkit-box-orient: vertical;
554
+  /* 内容垂直排列 */
555
+  -webkit-line-clamp: 2;
556
+  /* 限制显示行数 */
557
+  overflow: hidden;
558
+  /* 超出隐藏 */
559
+  text-overflow: ellipsis;
560
+  /* 省略号 */
561
+  line-height: 1.5;
562
+  /* 可选:设置行高 */
563
+  max-height: calc(1.5em * 2);
564
+  /* 可选:根据行高限制最大高度 */
565
+  font-size: 16px;
566
+  font-weight: bold;
567
+  color: #333;
568
+  /* 字号 */
569
+}
570
+
571
+.swipe-cell-default {
572
+  display: flex;
573
+  background-color: #ffffff;
574
+  justify-content: center;
575
+  align-items: center;
576
+}
577
+
578
+.swipe-cell-default-icon {
579
+  width: 60px;
580
+  display: flex;
581
+  justify-content: center;
582
+}
583
+
584
+.delete-button {
585
+  height: 100%;
586
+  border: none;
587
+  color: #ff0000;
588
+  background-image: url('@/assets/img/del.png');
589
+  background-size: auto 100%;
590
+  background-repeat: no-repeat;
591
+}
592
+
593
+.submit-button {
594
+  height: 100%;
595
+  border: none;
596
+  color: #07c160;
597
+  background-image: url('@/assets/img/sub.png');
598
+  background-size: auto 100%;
599
+  background-repeat: no-repeat;
600
+}
601
+
602
+.subsuccess {
603
+  height: 100%;
604
+  border: none;
605
+  color: #07c160;
606
+  background-image: url('@/assets/img/sub1.png');
607
+  background-size: auto 100%;
608
+  background-repeat: no-repeat;
609
+}
610
+.single-line-text {
611
+  white-space: nowrap;        /* 强制不换行 */
612
+  overflow: hidden;           /* 超出部分隐藏 */
613
+  text-overflow: ellipsis;    /* 超出显示省略号 ... */
614
+  width: 100%;                /* 或指定宽度 */
615
+  box-sizing: border-box;
616
+}
617
+</style>

+ 632
- 0
src/view/knowledge/managerList.vue Zobrazit soubor

@@ -0,0 +1,632 @@
1
+<script setup>
2
+import { getCurrentInstance, onMounted, ref , computed } from 'vue';
3
+import { useRoute, useRouter } from 'vue-router';
4
+import tools from '@/tools'
5
+import OrganizationalWithLeafUserOne from '@/components/OrganizationalWithLeafUserOne.vue';
6
+const {
7
+  proxy
8
+} = getCurrentInstance()
9
+const accidentDictList = ref([])
10
+const columns =  ref([])
11
+const columnsLevel =  ref([])
12
+const columnsprimary=ref([])
13
+
14
+//     [
15
+//   { text: '杭州', value: 'Hangzhou' },
16
+//   { text: '宁波', value: 'Ningbo' },
17
+//   { text: '温州', value: 'Wenzhou' },
18
+//   { text: '绍兴', value: 'Shaoxing' },
19
+//   { text: '湖州', value: 'Huzhou' },
20
+// ];
21
+
22
+// 定义生成编号的函数(你已写好的逻辑)
23
+
24
+const generateCode = () => {
25
+  const now = new Date();
26
+  const year = now.getFullYear();
27
+  const month = String(now.getMonth() + 1).padStart(2, '0');
28
+  const day = String(now.getDate()).padStart(2, '0');
29
+  const formattedDate = `${year}${month}${day}`;
30
+  const hours = String(now.getHours()).padStart(2, '0');
31
+  const minutes = String(now.getMinutes()).padStart(2, '0');
32
+  const seconds = String(now.getSeconds()).padStart(2, '0');
33
+  const formattedTime = `${hours}${minutes}${seconds}`;
34
+  const sequenceNumber = Math.floor(Math.random() * 1000);
35
+  const paddedSequence = String(sequenceNumber).padStart(3, '0');
36
+  return `SGAL${formattedDate}${formattedTime}${paddedSequence}`;
37
+};
38
+
39
+// 存储生成的编号(响应式变量)
40
+const generatedCode = ref('');
41
+
42
+// 重新生成编号的方法
43
+const regenerateCode = () => {
44
+  generatedCode.value = generateCode();
45
+};
46
+
47
+
48
+
49
+const getAccidentDicList = () => {
50
+  tools.dic.getDicList([ 'case_type','SEX', 'case_source','primary_domain','primary_domain_two','accident_level','accident_type','sgsafe_taccidentTags']).then((response => {
51
+    console.log(JSON.stringify(response.data.data))
52
+    accidentDictList.value = response.data.data
53
+    console.log('case_source',accidentDictList.value.case_source)
54
+    columns.value = accidentDictList.value.case_source.map(item => ({
55
+      text: item.dicName,
56
+      value: item.dicCode
57
+    }));
58
+    columnsLevel.value = accidentDictList.value.case_type.map(item => ({
59
+      text: item.dicName,
60
+      value: item.dicCode
61
+    }));
62
+    columnsprimary.value = accidentDictList.value.primary_domain.map(item => ({
63
+      text: item.dicName,
64
+      value: item.dicCode
65
+    }));
66
+
67
+
68
+    console.log('accident_level',accidentDictList.value.accident_level)
69
+
70
+  }))
71
+}
72
+
73
+
74
+const caseSourceFlag = ref(false)
75
+const accidentLevelFlag = ref(false)
76
+const primaryDomainFlag = ref(false)
77
+const primaryDomainTwoFlag = ref(false)
78
+let title = '新增事故案例'
79
+
80
+/* 返回上一级页面 */
81
+const router = useRouter()
82
+const onClickLeft = () => {
83
+  router.go(-1)
84
+}
85
+
86
+const currentYear = ref()
87
+currentYear.value = new Date().getFullYear()
88
+
89
+/* 获取用户部门信息 */
90
+const jsonArray = localStorage.getItem('dept')
91
+const deptInformation = ref([])
92
+try {
93
+  deptInformation.value = jsonArray ? JSON.parse(jsonArray) : [];
94
+} catch (error) {
95
+  deptInformation.value = [];
96
+}
97
+const deptName = deptInformation.value[0].deptName
98
+const deptCode = deptInformation.value[0].deptCode
99
+
100
+const guid = () =>  {
101
+  function S4() {
102
+    return (((1+Math.random())*0x10000)|0).toString(16).substring(1);
103
+  }
104
+  return (S4()+S4()+S4()+S4()+S4()+S4()+S4()+S4())
105
+}
106
+const formJieguo = ref({
107
+  resultWhether:'',
108
+  resultDetail:'',
109
+  resultWhy:'',
110
+  resultFile:'',
111
+  itemsId:'',
112
+  resultFileId:'',
113
+  resType:''
114
+})
115
+const route = useRoute()
116
+let planInfo = {}
117
+const  userName1=localStorage.getItem('userName');
118
+const isEdit = ref(route.query.mark === '1');
119
+
120
+const result=ref('')
121
+const fromVue=ref({})
122
+if (route.query.mark) {
123
+  planInfo = JSON.parse(route.query.mark)
124
+}
125
+console.log(planInfo);
126
+if (planInfo==-1){
127
+  result.value=guid()
128
+  generatedCode.value = generateCode();
129
+  console.log( result.value);
130
+}
131
+
132
+const resDetail=ref('')
133
+const ruleIds = ref([]);
134
+/*const getRuleId = () => {
135
+  var url = '/sgsafe/ExamHead/getCheckRuleId'
136
+  var param = {}
137
+  proxy.$axios.get(url, param).then(response => {
138
+    if (response.data.code == '0') {
139
+      ruleIds.value = response.data.data
140
+    } else {
141
+      console.log("1111111");
142
+    }
143
+  })
144
+  console.log('ruleIds', ruleIds)
145
+}
146
+getRuleId()*/
147
+const showRule=ref(false);
148
+const showSmit=ref(true);
149
+const distestType=ref(false)
150
+if (planInfo==1) {
151
+  console.log(planInfo);
152
+  title = '修改管理档案'
153
+  fromVue.value= JSON.parse(route.query.data)
154
+  generatedCode.value = fromVue.value.caseNumber || '';
155
+  result.value=fromVue.value.fileId
156
+  const userIds= localStorage.getItem('userId')
157
+  if (userIds == fromVue.value.addId) {
158
+    showSmit.value=false
159
+    title = '查看管理档案'
160
+  }
161
+  console.log(result.value);
162
+}
163
+ const  whether=ref(false)
164
+
165
+const planLevelList1=ref([])
166
+
167
+
168
+/* 下拉框 */
169
+const showActionSheet = ref(false)
170
+const showActionSheet1 = ref(false)
171
+const planLevelList = [
172
+  { name: '转发', value: '转发' },
173
+  { name: '内部', value: '内部' },
174
+  { name: '文章', value: '文章' }
175
+];
176
+const isdisabled=ref(true)
177
+const isdisabled2=ref(true)
178
+const onSelect = (item) => {
179
+fromVue.value.fileContent = item.name
180
+
181
+  showActionSheet.value=false
182
+}
183
+
184
+const onSelect2 = (item) => {
185
+  fromVue.value.fileType=item.name
186
+  showActionSheet2.value=false
187
+  }
188
+
189
+const onCaseSourseSelect = (item) => {
190
+  fromVue.value.caseSource=item.dicCode
191
+  caseSourceFlag.value = false
192
+}
193
+
194
+const onAccidentLevelSelect = (item) => {
195
+  fromVue.value.accidentLevel = item.dicCode
196
+  accidentLevelFlag.value = false
197
+
198
+}
199
+
200
+const displayFileName = ref('')
201
+const onSelect1 = (item) => {
202
+  console.log(item);
203
+  formJieguo.value.resultFile = item.value
204
+  result.value=formJieguo.value.resultFile
205
+  displayFileName.value = item.name
206
+  console.log(result.value);
207
+  showActionSheet1.value = false
208
+}
209
+const questionIds = ref([])
210
+const actions=ref([])
211
+/*const getQuestionId = () => {
212
+  var url = '/sgsafe/AssessmentRecord/queryRuleNoPage';
213
+  var param = {};
214
+  proxy.$axios.get(url, param).then(response => {
215
+    if (response.data.code == '0') {
216
+      questionIds.value = response.data.data; // 先赋值给 questionIds.value
217
+
218
+
219
+      // ✅ 关键:使用 questionIds.value.map
220
+      actions.value = questionIds.value.map(item => ({
221
+        name: item.ruleName,
222
+        value: item.id
223
+      }));
224
+      console.log('actions:', actions.value); // 看看有没有输出
225
+    } else {
226
+      ElMessage.error('操作失败!' + response.data.msg);
227
+    }
228
+  });
229
+};
230
+getQuestionId()*/
231
+
232
+const baocun3 = (ruleFormRef) => {
233
+  console.log(formJieguo.value)
234
+  ruleFormRef.validate((valid, fields) => {
235
+    if (valid) {
236
+
237
+      var url = '/sgsafe/Manager/save';
238
+      var param = {
239
+        json: JSON.stringify(formJieguo.value)
240
+      };
241
+      proxy.$axios.post(url, param).then(response => {
242
+        if (response.data.code == '0') {
243
+          getTableData1()
244
+          ElMessage({
245
+            message: '保存成功',
246
+            type: 'success',
247
+          })
248
+          if (ruleFormRef.value) {
249
+            ruleFormRef.value.resetFields();
250
+          }
251
+          dialogVisibletemplate.value=false
252
+        } else {
253
+          ElMessage.error('操作失败!' + response.data.msg)
254
+        }
255
+
256
+      })
257
+    }
258
+  })
259
+}
260
+
261
+/* 组织树选择 */
262
+const showBottom = ref(false)
263
+import OrganizationalWithLeaf from '@/components/OrganizationalWithLeaf.vue';
264
+import { showFailToast, showLoadingToast, showSuccessToast } from 'vant';
265
+const handleTableDataUserDeptUpdate = async (nodeData) => {
266
+  formJieguo.value.drillDept = nodeData.deptCode + '-' + nodeData.deptName
267
+  showBottom.value = false
268
+}
269
+
270
+const addEmergencyDrillPlan = async () => {
271
+  const loadingToast = showLoadingToast({
272
+    duration: 0,
273
+    message: '加载中',
274
+    forbidClick: true
275
+  })
276
+  var url = '/sgsafe/Manager/save';
277
+  const params = {
278
+    json: JSON.stringify(fromVue.value)
279
+  }
280
+  proxy.$axios.post(url,params).then(res=>{
281
+    if (res.data.code === 0) {
282
+      loadingToast.close()
283
+      showSuccessToast('保存成功')
284
+      onClickLeft()
285
+
286
+    } else {
287
+      loadingToast.close()
288
+      showFailToast('操作失败!' + res.data.msg)
289
+    }
290
+  })
291
+}
292
+const showDatePicker = ref(false)
293
+const onDatePicker = (value) => {
294
+  const dateArr = value.selectedValues
295
+  fromVue.value.checkTime = dateArr[0] + '-' + dateArr[1] + '-' + dateArr[2]
296
+  showDatePicker.value = false
297
+}
298
+const currentDate = ref([2025, 7, 25])
299
+//定义字典集合
300
+const dicList = ref([])
301
+//获取字典集合
302
+// import tools from '@/tools'
303
+const getDicList = () => {
304
+  tools.dic.getDicList(['systemTypes']).then((response => {
305
+
306
+   const rawData = response.data.data
307
+    dicList.value = rawData.systemTypes.map(item => ({
308
+      name: item.dicName,      // 必须有 name 字段!
309
+      code: item.dicCode       // 可选,保留原始 code 供后续使用
310
+    }));
311
+    console.log(JSON.stringify(dicList.value))
312
+  }))
313
+}
314
+onMounted(() => {
315
+  getAccidentDicList()
316
+  console.log('这是编辑页面')
317
+  const today = new Date()
318
+  const year = today.getFullYear()
319
+  const month = today.getMonth() + 1 // 月份从 0 开始
320
+  const day = today.getDate()
321
+  currentDate.value = [year, month, day]
322
+  //selectedDateText.value = `${year}-${String(month).padStart(2, '0')}-${String(day).padStart(2, '0')}`
323
+  getDicList()
324
+})
325
+const showActionSheet2=ref(false)
326
+/* 文件上传 */
327
+import AttachmentS3 from '@/components/AttachmentS3.vue';
328
+
329
+const onSubmit = (values) => {
330
+  fromVue.value.caseNumber = generatedCode.value;
331
+  fromVue.value.fileId = generatedCode.value;
332
+  addEmergencyDrillPlan()
333
+}
334
+const leaderKeyysr = guid();
335
+const PopupDepartmentLeaderNameRefysr = ref();
336
+const handleDepartmentLeaderNameysr = () => {
337
+  PopupDepartmentLeaderNameRefysr.value.open();
338
+};
339
+const getDepartmentLeaderNameysr = (item) => {
340
+  fromVue.value.punCode = item.user.userCode;
341
+  fromVue.value.punName = item.user.userDesc;
342
+  fromVue.value.punId = item.user.id
343
+};
344
+
345
+const onCaseSourceConfirm = ({ selectedOptions }) => {
346
+  caseSourceFlag.value = false;
347
+  fromVue.value.caseSource = selectedOptions[0].text;
348
+};
349
+
350
+const onAccidentLevelConfirm = ({ selectedOptions }) => {
351
+  accidentLevelFlag.value = false;
352
+  fromVue.value.caseType = selectedOptions[0].text;
353
+};
354
+
355
+const onprimaryTwoConfirm = ({ selectedOptions }) => {
356
+  primaryDomainTwoFlag.value = false;
357
+  fromVue.value.primaryDomainTwo = selectedOptions[0].text;
358
+};
359
+const selectedPrimary = ref(null)
360
+const onprimaryConfirm = ({ selectedOptions }) => {
361
+  if (!selectedOptions?.length) {
362
+    selectedPrimary.value = null;
363
+    fromVue.value.primaryDomainTwo = '';
364
+    primaryDomainFlag.value = false;
365
+    return;
366
+  }
367
+
368
+  primaryDomainFlag.value = false;
369
+  fromVue.value.primaryDomain = selectedOptions[0].text;
370
+
371
+  const primaryList = accidentDictList.value?.primary_domain || [];
372
+  const selectedItem = primaryList.find(item => item.dicName === selectedOptions[0].text);
373
+
374
+  selectedPrimary.value = selectedItem || null;
375
+  fromVue.value.primaryDomainTwo = '';
376
+};
377
+
378
+const filteredSecondaryList = computed(() =>
379
+  selectedPrimary.value?.dicValue1
380
+    ? (accidentDictList.value?.primary_domain_two || [])
381
+      .filter(item => item.dicValue1 === selectedPrimary.value.dicValue1)
382
+      .map(({ dicName, dicCode }) => ({ text: dicName, value: dicCode }))
383
+    : []
384
+);
385
+
386
+
387
+</script>
388
+
389
+<template>
390
+
391
+  <div class="page-container">
392
+    <van-sticky class="header">
393
+      <van-nav-bar
394
+        :title="title"
395
+        left-text="返回"
396
+        left-arrow
397
+        @click-left="onClickLeft" >
398
+      </van-nav-bar>
399
+    </van-sticky>
400
+    <div class="scroll-container">
401
+      <van-form @submit="onSubmit">
402
+<!--        <van-field-->
403
+<!--          v-model="fromVue.caseNumber"-->
404
+<!--          label="案例编号"-->
405
+<!--          name="caseNumber"-->
406
+<!--          required-->
407
+<!--          placeholder="请输入案例编号"-->
408
+<!--          :rules="[{required: true, message: '请输入文件编号'}]"-->
409
+<!--        />-->
410
+        <van-field
411
+            v-model="generatedCode"
412
+        label="案例编号"
413
+        name="caseNumber"
414
+            :readonly="true"
415
+        :rules="[{required: true, message: '编号生成失败,请点击“重新生成”'}]"
416
+        />
417
+
418
+        <van-field
419
+          v-model="fromVue.caseTitle"
420
+          label="案例标题"
421
+          name="caseTitle"
422
+          required
423
+          placeholder="请输入案例标题"
424
+          :rules="[{required: true, message: '请输入文件名称'}]"
425
+        />
426
+
427
+        <van-field
428
+          v-model="fromVue.caseSource"
429
+          readonly
430
+          label="案例来源"
431
+          name="caseSource"
432
+          required
433
+          @click="caseSourceFlag = true"
434
+        />
435
+        <van-field
436
+          readonly
437
+          v-model="fromVue.caseType"
438
+          label="案例类型"
439
+          name="caseType"
440
+          @click="accidentLevelFlag = true"
441
+        />
442
+        <van-field
443
+          readonly
444
+          v-model="fromVue.primaryDomain"
445
+          label="专业领域一级分类"
446
+          name="primaryDomain"
447
+          @click="primaryDomainFlag = true"
448
+        />
449
+        <van-field
450
+          readonly
451
+          v-model="fromVue.primaryDomainTwo"
452
+          label="专业领域二级分类"
453
+          name="primaryDomainTwo"
454
+          @click="primaryDomainTwoFlag = true"
455
+        />
456
+        <van-field
457
+          v-model="fromVue.tags"
458
+          label="标签"
459
+          name="tags"
460
+          required
461
+          placeholder="请输入案例标题"
462
+          :rules="[{required: true, message: '请输入标签'}]"
463
+        />
464
+
465
+        <van-field
466
+            v-model="fromVue.caseSummary"
467
+            label="案例摘要"
468
+            name="caseSummary"
469
+            required
470
+            rows="1"
471
+            autosize
472
+            type="textarea"
473
+            placeholder="请输入案例摘要"
474
+            :rules="[{required: true, message: '请输入案例摘要'}]"
475
+        />
476
+        <van-field
477
+            v-model="fromVue.highLights"
478
+            label="创新点与亮点"
479
+            name="highLights"
480
+            required
481
+            rows="3"
482
+            autosize
483
+            type="textarea"
484
+            placeholder="请输入创新点与亮点"
485
+            :rules="[{required: true, message: '请输入创新点与亮点'}]"
486
+        />
487
+        <van-field
488
+            v-model="fromVue.resultsValue"
489
+            label="应用成效与价值"
490
+            name="resultsValue"
491
+            required
492
+            rows="3"
493
+            autosize
494
+            type="textarea"
495
+            placeholder="请输入应用成效与价值"
496
+            :rules="[{required: true, message: '请输入应用成效与价值'}]"
497
+        />
498
+        <van-field label="附件上传" >
499
+          <template #input>
500
+            <AttachmentS3 :f-id="result" />
501
+          </template>
502
+        </van-field>
503
+        <div style="margin: 16px;">
504
+          <van-button round block type="primary" v-show='showSmit' native-type="submit">
505
+            {{ isEdit ? '保存' : '提交' }}
506
+          </van-button>
507
+        </div>
508
+      </van-form>
509
+
510
+      <van-action-sheet
511
+        v-model:show="showActionSheet"
512
+        :actions="planLevelList"
513
+        @select="onSelect"
514
+      />
515
+      <van-action-sheet
516
+        v-model:show="showActionSheet2"
517
+        :actions="dicList"
518
+        @select="onSelect2"
519
+      />
520
+
521
+      <van-action-sheet
522
+          v-model:show="caseSourceFlag"
523
+          :actions="accidentDictList.case_source"
524
+          @select="onCaseSourseSelect"
525
+      />
526
+
527
+      <van-popup v-model:show="caseSourceFlag" round position="bottom">
528
+        <van-picker
529
+            :columns="columns"
530
+            @cancel="caseSourceFlag = false"
531
+            @confirm="onCaseSourceConfirm"
532
+        />
533
+      </van-popup>
534
+
535
+      <van-popup v-model:show="accidentLevelFlag" round position="bottom">
536
+        <van-picker
537
+            :columns="columnsLevel"
538
+            @cancel="accidentLevelFlag = false"
539
+            @confirm="onAccidentLevelConfirm"
540
+        />
541
+      </van-popup>
542
+      <van-popup v-model:show="primaryDomainFlag" round position="bottom">
543
+        <van-picker
544
+          :columns="columnsprimary"
545
+          @cancel="primaryDomainFlag = false"
546
+          @confirm="onprimaryConfirm"
547
+        />
548
+      </van-popup>
549
+      <van-popup v-model:show="primaryDomainTwoFlag" round position="bottom">
550
+        <van-picker
551
+          :columns="filteredSecondaryList"
552
+          @cancel="primaryDomainTwoFlag = false"
553
+          @confirm="onprimaryTwoConfirm"
554
+        />
555
+      </van-popup>
556
+
557
+<!--      <van-action-sheet-->
558
+<!--          v-model:show="accidentLevelFlag"-->
559
+<!--          :actions="accidentDictList.accident_level"-->
560
+<!--          @select="onAccidentLevelSelect"-->
561
+<!--      />-->
562
+
563
+<!--      <van-action-sheet-->
564
+<!--        v-model:show="showActionSheet1"-->
565
+<!--        :actions="planLevelList1"-->
566
+<!--        field-names="{ text: 'fileName', value: 'fileId' }"-->
567
+<!--        @select="onSelect1"-->
568
+<!--      />-->
569
+
570
+      <van-popup v-model:show="showBottom" position="bottom" :style="{ height: '30%' }">
571
+        <OrganizationalWithLeaf @update:selected-node="handleTableDataUserDeptUpdate" />
572
+      </van-popup>
573
+      <van-popup v-model:show="showDatePicker" position="bottom">
574
+        <van-date-picker
575
+          v-model="currentDate"
576
+          @confirm="onDatePicker"
577
+          @cancel="showDatePicker = false" />
578
+      </van-popup>
579
+    </div>
580
+  </div>
581
+</template>
582
+
583
+<style scoped>
584
+.page-container {
585
+  height: 100vh; /* 关键:外层容器高度设为视口高度 */
586
+  display: flex;
587
+  flex-direction: column;
588
+
589
+}
590
+/*  overflow-y: auto; !* 启用垂直滚动 *!*/
591
+
592
+
593
+.scroll-container {
594
+  flex: 1;
595
+  overflow: auto;
596
+  -webkit-overflow-scrolling: touch; /* iOS 平滑滚动 */
597
+}
598
+
599
+/* 可选:隐藏滚动条(视觉优化) */
600
+.scroll-container::-webkit-scrollbar {
601
+  display: none;
602
+}
603
+
604
+.header, .footer {
605
+  /* 固定高度区域 */
606
+  flex-shrink: 0; /* 防止被压缩 */
607
+  background: #f5f5f5;
608
+  padding: 12px;
609
+}
610
+.row-container {
611
+  display: flex;
612
+  justify-content: space-between; /* 关键:左右分布 */
613
+  align-items: center;             /* 垂直居中 */
614
+
615
+}
616
+
617
+.cell-period-text {
618
+  font-size: 14px;
619
+  color: #333;
620
+  white-space: nowrap;
621
+  overflow: hidden;
622
+  text-overflow: ellipsis;
623
+
624
+}
625
+
626
+.mini-btn {
627
+  height: 22px;
628
+  font-size: 12px;
629
+  padding: 0 8px;
630
+  min-width: 60px;                 /* 可选:保持按钮最小宽度一致 */
631
+}
632
+</style>

Loading…
Zrušit
Uložit