jiajunchen il y a 1 mois
Parent
révision
862ddca1f2
4 fichiers modifiés avec 1258 ajouts et 0 suppressions
  1. 10
    0
      src/router/index.ts
  2. 4
    0
      src/view/Home2.vue
  3. 617
    0
      src/view/knowledge/manager.vue
  4. 627
    0
      src/view/knowledge/managerList.vue

+ 10
- 0
src/router/index.ts Voir le fichier

@@ -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 Voir le fichier

@@ -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 Voir le fichier

@@ -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>

+ 627
- 0
src/view/knowledge/managerList.vue Voir le fichier

@@ -0,0 +1,627 @@
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
+
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
+  console.log(result.value);
157
+}
158
+ const  whether=ref(false)
159
+
160
+const planLevelList1=ref([])
161
+
162
+
163
+/* 下拉框 */
164
+const showActionSheet = ref(false)
165
+const showActionSheet1 = ref(false)
166
+const planLevelList = [
167
+  { name: '转发', value: '转发' },
168
+  { name: '内部', value: '内部' },
169
+  { name: '文章', value: '文章' }
170
+];
171
+const isdisabled=ref(true)
172
+const isdisabled2=ref(true)
173
+const onSelect = (item) => {
174
+fromVue.value.fileContent = item.name
175
+
176
+  showActionSheet.value=false
177
+}
178
+
179
+const onSelect2 = (item) => {
180
+  fromVue.value.fileType=item.name
181
+  showActionSheet2.value=false
182
+  }
183
+
184
+const onCaseSourseSelect = (item) => {
185
+  fromVue.value.caseSource=item.dicCode
186
+  caseSourceFlag.value = false
187
+}
188
+
189
+const onAccidentLevelSelect = (item) => {
190
+  fromVue.value.accidentLevel = item.dicCode
191
+  accidentLevelFlag.value = false
192
+
193
+}
194
+
195
+const displayFileName = ref('')
196
+const onSelect1 = (item) => {
197
+  console.log(item);
198
+  formJieguo.value.resultFile = item.value
199
+  result.value=formJieguo.value.resultFile
200
+  displayFileName.value = item.name
201
+  console.log(result.value);
202
+  showActionSheet1.value = false
203
+}
204
+const questionIds = ref([])
205
+const actions=ref([])
206
+/*const getQuestionId = () => {
207
+  var url = '/sgsafe/AssessmentRecord/queryRuleNoPage';
208
+  var param = {};
209
+  proxy.$axios.get(url, param).then(response => {
210
+    if (response.data.code == '0') {
211
+      questionIds.value = response.data.data; // 先赋值给 questionIds.value
212
+
213
+
214
+      // ✅ 关键:使用 questionIds.value.map
215
+      actions.value = questionIds.value.map(item => ({
216
+        name: item.ruleName,
217
+        value: item.id
218
+      }));
219
+      console.log('actions:', actions.value); // 看看有没有输出
220
+    } else {
221
+      ElMessage.error('操作失败!' + response.data.msg);
222
+    }
223
+  });
224
+};
225
+getQuestionId()*/
226
+
227
+const baocun3 = (ruleFormRef) => {
228
+  console.log(formJieguo.value)
229
+  ruleFormRef.validate((valid, fields) => {
230
+    if (valid) {
231
+
232
+      var url = '/sgsafe/Manager/save';
233
+      var param = {
234
+        json: JSON.stringify(formJieguo.value)
235
+      };
236
+      proxy.$axios.post(url, param).then(response => {
237
+        if (response.data.code == '0') {
238
+          getTableData1()
239
+          ElMessage({
240
+            message: '保存成功',
241
+            type: 'success',
242
+          })
243
+          if (ruleFormRef.value) {
244
+            ruleFormRef.value.resetFields();
245
+          }
246
+          dialogVisibletemplate.value=false
247
+        } else {
248
+          ElMessage.error('操作失败!' + response.data.msg)
249
+        }
250
+
251
+      })
252
+    }
253
+  })
254
+}
255
+
256
+/* 组织树选择 */
257
+const showBottom = ref(false)
258
+import OrganizationalWithLeaf from '@/components/OrganizationalWithLeaf.vue';
259
+import { showFailToast, showLoadingToast, showSuccessToast } from 'vant';
260
+const handleTableDataUserDeptUpdate = async (nodeData) => {
261
+  formJieguo.value.drillDept = nodeData.deptCode + '-' + nodeData.deptName
262
+  showBottom.value = false
263
+}
264
+
265
+const addEmergencyDrillPlan = async () => {
266
+  const loadingToast = showLoadingToast({
267
+    duration: 0,
268
+    message: '加载中',
269
+    forbidClick: true
270
+  })
271
+  var url = '/sgsafe/Manager/save';
272
+  const params = {
273
+    json: JSON.stringify(fromVue.value)
274
+  }
275
+  proxy.$axios.post(url,params).then(res=>{
276
+    if (res.data.code === 0) {
277
+      loadingToast.close()
278
+      showSuccessToast('保存成功')
279
+      onClickLeft()
280
+
281
+    } else {
282
+      loadingToast.close()
283
+      showFailToast('操作失败!' + res.data.msg)
284
+    }
285
+  })
286
+}
287
+const showDatePicker = ref(false)
288
+const onDatePicker = (value) => {
289
+  const dateArr = value.selectedValues
290
+  fromVue.value.checkTime = dateArr[0] + '-' + dateArr[1] + '-' + dateArr[2]
291
+  showDatePicker.value = false
292
+}
293
+const currentDate = ref([2025, 7, 25])
294
+//定义字典集合
295
+const dicList = ref([])
296
+//获取字典集合
297
+// import tools from '@/tools'
298
+const getDicList = () => {
299
+  tools.dic.getDicList(['systemTypes']).then((response => {
300
+
301
+   const rawData = response.data.data
302
+    dicList.value = rawData.systemTypes.map(item => ({
303
+      name: item.dicName,      // 必须有 name 字段!
304
+      code: item.dicCode       // 可选,保留原始 code 供后续使用
305
+    }));
306
+    console.log(JSON.stringify(dicList.value))
307
+  }))
308
+}
309
+onMounted(() => {
310
+  getAccidentDicList()
311
+  console.log('这是编辑页面')
312
+  const today = new Date()
313
+  const year = today.getFullYear()
314
+  const month = today.getMonth() + 1 // 月份从 0 开始
315
+  const day = today.getDate()
316
+  currentDate.value = [year, month, day]
317
+  //selectedDateText.value = `${year}-${String(month).padStart(2, '0')}-${String(day).padStart(2, '0')}`
318
+  getDicList()
319
+})
320
+const showActionSheet2=ref(false)
321
+/* 文件上传 */
322
+import AttachmentS3 from '@/components/AttachmentS3.vue';
323
+
324
+const onSubmit = (values) => {
325
+  fromVue.value.caseNumber = generatedCode.value;
326
+  fromVue.value.fileId = generatedCode.value;
327
+  addEmergencyDrillPlan()
328
+}
329
+const leaderKeyysr = guid();
330
+const PopupDepartmentLeaderNameRefysr = ref();
331
+const handleDepartmentLeaderNameysr = () => {
332
+  PopupDepartmentLeaderNameRefysr.value.open();
333
+};
334
+const getDepartmentLeaderNameysr = (item) => {
335
+  fromVue.value.punCode = item.user.userCode;
336
+  fromVue.value.punName = item.user.userDesc;
337
+  fromVue.value.punId = item.user.id
338
+};
339
+
340
+const onCaseSourceConfirm = ({ selectedOptions }) => {
341
+  caseSourceFlag.value = false;
342
+  fromVue.value.caseSource = selectedOptions[0].text;
343
+};
344
+
345
+const onAccidentLevelConfirm = ({ selectedOptions }) => {
346
+  accidentLevelFlag.value = false;
347
+  fromVue.value.caseType = selectedOptions[0].text;
348
+};
349
+
350
+const onprimaryTwoConfirm = ({ selectedOptions }) => {
351
+  primaryDomainTwoFlag.value = false;
352
+  fromVue.value.primaryDomainTwo = selectedOptions[0].text;
353
+};
354
+const selectedPrimary = ref(null)
355
+const onprimaryConfirm = ({ selectedOptions }) => {
356
+  if (!selectedOptions?.length) {
357
+    selectedPrimary.value = null;
358
+    fromVue.value.primaryDomainTwo = '';
359
+    primaryDomainFlag.value = false;
360
+    return;
361
+  }
362
+
363
+  primaryDomainFlag.value = false;
364
+  fromVue.value.primaryDomain = selectedOptions[0].text;
365
+
366
+  const primaryList = accidentDictList.value?.primary_domain || [];
367
+  const selectedItem = primaryList.find(item => item.dicName === selectedOptions[0].text);
368
+
369
+  selectedPrimary.value = selectedItem || null;
370
+  fromVue.value.primaryDomainTwo = '';
371
+};
372
+
373
+const filteredSecondaryList = computed(() =>
374
+  selectedPrimary.value?.dicValue1
375
+    ? (accidentDictList.value?.primary_domain_two || [])
376
+      .filter(item => item.dicValue1 === selectedPrimary.value.dicValue1)
377
+      .map(({ dicName, dicCode }) => ({ text: dicName, value: dicCode }))
378
+    : []
379
+);
380
+
381
+
382
+</script>
383
+
384
+<template>
385
+
386
+  <div class="page-container">
387
+    <van-sticky class="header">
388
+      <van-nav-bar
389
+        :title="title"
390
+        left-text="返回"
391
+        left-arrow
392
+        @click-left="onClickLeft" >
393
+      </van-nav-bar>
394
+    </van-sticky>
395
+    <div class="scroll-container">
396
+      <van-form @submit="onSubmit">
397
+<!--        <van-field-->
398
+<!--          v-model="fromVue.caseNumber"-->
399
+<!--          label="案例编号"-->
400
+<!--          name="caseNumber"-->
401
+<!--          required-->
402
+<!--          placeholder="请输入案例编号"-->
403
+<!--          :rules="[{required: true, message: '请输入文件编号'}]"-->
404
+<!--        />-->
405
+        <van-field
406
+            v-model="generatedCode"
407
+        label="案例编号"
408
+        name="caseNumber"
409
+            :readonly="true"
410
+        :rules="[{required: true, message: '编号生成失败,请点击“重新生成”'}]"
411
+        />
412
+
413
+        <van-field
414
+          v-model="fromVue.caseTitle"
415
+          label="案例标题"
416
+          name="caseTitle"
417
+          required
418
+          placeholder="请输入案例标题"
419
+          :rules="[{required: true, message: '请输入文件名称'}]"
420
+        />
421
+
422
+        <van-field
423
+          v-model="fromVue.caseSource"
424
+          readonly
425
+          label="案例来源"
426
+          name="caseSource"
427
+          required
428
+          @click="caseSourceFlag = true"
429
+        />
430
+        <van-field
431
+          readonly
432
+          v-model="fromVue.caseType"
433
+          label="案例类型"
434
+          name="caseType"
435
+          @click="accidentLevelFlag = true"
436
+        />
437
+        <van-field
438
+          readonly
439
+          v-model="fromVue.primaryDomain"
440
+          label="专业领域一级分类"
441
+          name="primaryDomain"
442
+          @click="primaryDomainFlag = true"
443
+        />
444
+        <van-field
445
+          readonly
446
+          v-model="fromVue.primaryDomainTwo"
447
+          label="专业领域二级分类"
448
+          name="primaryDomainTwo"
449
+          @click="primaryDomainTwoFlag = true"
450
+        />
451
+        <van-field
452
+          v-model="fromVue.tags"
453
+          label="标签"
454
+          name="tags"
455
+          required
456
+          placeholder="请输入案例标题"
457
+          :rules="[{required: true, message: '请输入标签'}]"
458
+        />
459
+
460
+        <van-field
461
+            v-model="fromVue.caseSummary"
462
+            label="案例摘要"
463
+            name="caseSummary"
464
+            required
465
+            rows="1"
466
+            autosize
467
+            type="textarea"
468
+            placeholder="请输入案例摘要"
469
+            :rules="[{required: true, message: '请输入案例摘要'}]"
470
+        />
471
+        <van-field
472
+            v-model="fromVue.highLights"
473
+            label="创新点与亮点"
474
+            name="highLights"
475
+            required
476
+            rows="3"
477
+            autosize
478
+            type="textarea"
479
+            placeholder="请输入创新点与亮点"
480
+            :rules="[{required: true, message: '请输入创新点与亮点'}]"
481
+        />
482
+        <van-field
483
+            v-model="fromVue.resultsValue"
484
+            label="应用成效与价值"
485
+            name="resultsValue"
486
+            required
487
+            rows="3"
488
+            autosize
489
+            type="textarea"
490
+            placeholder="请输入应用成效与价值"
491
+            :rules="[{required: true, message: '请输入应用成效与价值'}]"
492
+        />
493
+        <van-field label="附件上传" >
494
+          <template #input>
495
+            <AttachmentS3 :f-id="result" />
496
+          </template>
497
+        </van-field>
498
+        <div style="margin: 16px;">
499
+          <van-button round block type="primary" native-type="submit">
500
+            {{ isEdit ? '保存' : '提交' }}
501
+          </van-button>
502
+        </div>
503
+      </van-form>
504
+
505
+      <van-action-sheet
506
+        v-model:show="showActionSheet"
507
+        :actions="planLevelList"
508
+        @select="onSelect"
509
+      />
510
+      <van-action-sheet
511
+        v-model:show="showActionSheet2"
512
+        :actions="dicList"
513
+        @select="onSelect2"
514
+      />
515
+
516
+      <van-action-sheet
517
+          v-model:show="caseSourceFlag"
518
+          :actions="accidentDictList.case_source"
519
+          @select="onCaseSourseSelect"
520
+      />
521
+
522
+      <van-popup v-model:show="caseSourceFlag" round position="bottom">
523
+        <van-picker
524
+            :columns="columns"
525
+            @cancel="caseSourceFlag = false"
526
+            @confirm="onCaseSourceConfirm"
527
+        />
528
+      </van-popup>
529
+
530
+      <van-popup v-model:show="accidentLevelFlag" round position="bottom">
531
+        <van-picker
532
+            :columns="columnsLevel"
533
+            @cancel="accidentLevelFlag = false"
534
+            @confirm="onAccidentLevelConfirm"
535
+        />
536
+      </van-popup>
537
+      <van-popup v-model:show="primaryDomainFlag" round position="bottom">
538
+        <van-picker
539
+          :columns="columnsprimary"
540
+          @cancel="primaryDomainFlag = false"
541
+          @confirm="onprimaryConfirm"
542
+        />
543
+      </van-popup>
544
+      <van-popup v-model:show="primaryDomainTwoFlag" round position="bottom">
545
+        <van-picker
546
+          :columns="filteredSecondaryList"
547
+          @cancel="primaryDomainTwoFlag = false"
548
+          @confirm="onprimaryTwoConfirm"
549
+        />
550
+      </van-popup>
551
+
552
+<!--      <van-action-sheet-->
553
+<!--          v-model:show="accidentLevelFlag"-->
554
+<!--          :actions="accidentDictList.accident_level"-->
555
+<!--          @select="onAccidentLevelSelect"-->
556
+<!--      />-->
557
+
558
+<!--      <van-action-sheet-->
559
+<!--        v-model:show="showActionSheet1"-->
560
+<!--        :actions="planLevelList1"-->
561
+<!--        field-names="{ text: 'fileName', value: 'fileId' }"-->
562
+<!--        @select="onSelect1"-->
563
+<!--      />-->
564
+
565
+      <van-popup v-model:show="showBottom" position="bottom" :style="{ height: '30%' }">
566
+        <OrganizationalWithLeaf @update:selected-node="handleTableDataUserDeptUpdate" />
567
+      </van-popup>
568
+      <van-popup v-model:show="showDatePicker" position="bottom">
569
+        <van-date-picker
570
+          v-model="currentDate"
571
+          @confirm="onDatePicker"
572
+          @cancel="showDatePicker = false" />
573
+      </van-popup>
574
+    </div>
575
+  </div>
576
+</template>
577
+
578
+<style scoped>
579
+.page-container {
580
+  height: 100vh; /* 关键:外层容器高度设为视口高度 */
581
+  display: flex;
582
+  flex-direction: column;
583
+
584
+}
585
+/*  overflow-y: auto; !* 启用垂直滚动 *!*/
586
+
587
+
588
+.scroll-container {
589
+  flex: 1;
590
+  overflow: auto;
591
+  -webkit-overflow-scrolling: touch; /* iOS 平滑滚动 */
592
+}
593
+
594
+/* 可选:隐藏滚动条(视觉优化) */
595
+.scroll-container::-webkit-scrollbar {
596
+  display: none;
597
+}
598
+
599
+.header, .footer {
600
+  /* 固定高度区域 */
601
+  flex-shrink: 0; /* 防止被压缩 */
602
+  background: #f5f5f5;
603
+  padding: 12px;
604
+}
605
+.row-container {
606
+  display: flex;
607
+  justify-content: space-between; /* 关键:左右分布 */
608
+  align-items: center;             /* 垂直居中 */
609
+
610
+}
611
+
612
+.cell-period-text {
613
+  font-size: 14px;
614
+  color: #333;
615
+  white-space: nowrap;
616
+  overflow: hidden;
617
+  text-overflow: ellipsis;
618
+
619
+}
620
+
621
+.mini-btn {
622
+  height: 22px;
623
+  font-size: 12px;
624
+  padding: 0 8px;
625
+  min-width: 60px;                 /* 可选:保持按钮最小宽度一致 */
626
+}
627
+</style>

Loading…
Annuler
Enregistrer