templateConfig.vue
20 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
<route lang="yaml">
name: taskConfig //分类分级模板
</route>
<script lang="ts" setup name="templateConfig">
import { ref, onMounted } from "vue";
import TableTools from '@/components/Tools/table_tools.vue';
import { MoreFilled } from "@element-plus/icons-vue";
import { useValidator } from '@/hooks/useValidator';
import { saveClassifyGrad, getClassifyGradList, deleteClassifyGrad, updateClassifyGrad, } from "@/api/modules/dataInventory";
const router = useRouter();
const { required } = useValidator();
const { proxy } = getCurrentInstance() as any;
const refGradePageParams = ref({
pageIndex: 1,
pageSize: -1,
type: "G"
});
const refClassifyPageParams = ref({
pageIndex: 1,
pageSize: -1,
type: "C"
});
// 分级列表
const classifyGradListData: any = ref([]);
// 分类列表
const classListData: any = ref([]);
//记录分级guid
const classifyGradGuid = ref('');
// 记录分类guid
const classGuid = ref('');
const classListDataLoading = ref(false);
// 获取分级列表
const getClassifyGradListData = async () => {
classListDataLoading.value = true;
const res: any = await getClassifyGradList(refGradePageParams.value);
if (res.code == proxy.$passCode) {
classifyGradListData.value = res.data.records || [];
(classStandardFormItems.value[1].options as any) = classifyGradListData.value;
classListDataLoading.value = false;
} else {
proxy.$ElMessage.error(res.msg);
}
}
//获取分类列表
const getClassListData = async (params = {}) => {
const inParams = {
type: 'C',
pageIndex: 1,
pageSize: -1
}
const finalParams = {
...inParams,
...params
}
classListDataLoading.value = true;
const res: any = await getClassifyGradList(finalParams);
if (res.code == proxy.$passCode) {
classListData.value = res.data.records || [];
classListDataLoading.value = false;
} else {
proxy.$ElMessage.error(res.msg);
}
}
onMounted(() => {
getClassifyGradListData();
// getClassListData();
})
const tabsInfo = ref({
activeName: 'gradeStandard',
tabs: [
// { label: '分类分级模板', name: 'classTemplate' },
{ label: '分级规则', name: 'gradeStandard' },
{ label: '分类规则', name: 'classStandard' },
]
});
const tabChange = (val) => {
tabsInfo.value.activeName = val;
}
/** ------------------------------- 分类标准相关 ------------------------------------- */
/** 分类标准的搜索配置 */
const classSearchItemList = ref([
{
type: 'input',
label: '',
field: 'classStandardName',
default: '',
maxlength: 50,
placeholder: '分类名称',
clearable: true,
visible: true
}
]);
/** 记录点击省略号弹出菜单的visible */
const cardBtnVisible: any = ref(false);
/** 搜索查询分类标准 */
const searchClass = async (val: any, clear: boolean = false) => {
console.log(val, 'val');
if (clear) {
classSearchItemList.value.map(item => item.default = '')
getClassListData();
return;
}
// const params = {
// type: 'C',
// name: val.classStandardName,
// pageIndex: 1,
// pageSize: -1
// }
// const res: any = await getClassifyGradList(params);
// if (res.code == proxy.$passCode) {
// classListData.value = res.data.records || [];
// } else {
// proxy.$ElMessage.error(res.msg);
// }
getClassListData(
{
name: val.classStandardName
}
);
};
/** 编辑分类 */
const handleClassDataEdit = (params) => {
classGuid.value = params.guid;
newCreateClassStandardDialogInfo.value.submitBtnLoading = false;
newCreateClassStandardDialogInfo.value.visible = true;
newCreateClassStandardDialogInfo.value.title = '编辑分类';
classStandardFormItems.value.forEach(item => {
if (item.field === 'refGradeGuid') {
item.default = params.refGradeGuid
}
if (item.field === 'classStandardName') {
item.default = params.name
}
if (item.field === 'description') {
item.default = params.description
}
})
}
// 配置分类
const handleClassDataClick = (item, des = '') => {
console.log(item, 'i111tem');
// 获取分级标准
router.push({
name: 'classStandardEdit',
query: {
guid: item.guid,
type: des === '' ? '配置' : des,
classStandardName: item.name,
refGradeGuid: item.refGradeGuid,
description: item.description,
isExpand: item.isExpand || false
}
});
}
const handleClassDataDel = async (item) => {
try {
// 弹出确认框
await proxy.$confirm('此操作将永久删除该分级, 是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
});
const res: any = await deleteClassifyGrad({ guid: item.guid });
if (res.code === proxy.$passCode) {
await getClassListData(); // 获取更新后的列表数据
proxy.$ElMessage({
type: 'success',
message: '删除成功!'
});
} else {
proxy.$ElMessage.error(res.msg); // 显示错误信息
}
} catch (error) {
if (error !== 'cancel') {
proxy.$ElMessage({
type: 'info',
message: '已取消删除'
});
}
}
}
const classStandardFormItems = ref([{
label: '分类名称',
type: 'input',
maxlength: 50,
placeholder: '请输入',
field: 'classStandardName',
default: '',
block: true,
clearable: true,
required: true
}, {
label: '分级标准',
type: 'select',
placeholder: '请选择',
field: 'refGradeGuid',
options: [],
props: {
label: "name",
value: "guid",
},
filterable: true,
clearable: true,
default: '',
required: true,
block: true,
}, {
label: '分类描述',
type: 'textarea',
placeholder: '请输入',
field: 'description',
default: '',
clearable: true,
required: false,
block: true
}]);
const classStandardFormRules = ref({
classStandardName: [required('请填写分类名称')],
refGradeGuid: [required('请选择分级标准')]
});
const newCreateClassStandardDialogInfo = ref({
visible: false,
size: 460,
title: "新增分类",
type: "",
formInfo: {
id: "class-standard-form",
items: classStandardFormItems.value,
rules: classStandardFormRules.value,
},
submitBtnLoading: false,
btns: {
cancel: () => {
newCreateClassStandardDialogInfo.value.visible = false;
},
submit: async (btn, info) => {
if (newCreateClassStandardDialogInfo.value.title === '新增分类') {
newCreateClassStandardDialogInfo.value.submitBtnLoading = true;
const params = {
description: info.description,
name: info.classStandardName,
refGradeGuid: info.refGradeGuid,
type: 'C'
}
const res: any = await saveClassifyGrad(params);
if (res.code == proxy.$passCode) {
await getClassListData();
proxy.$ElMessage({
type: 'success',
message: '新增分类成功'
})
nextTick(() => {
// 拿到新增的分类数据,跳转到配置页面
const item = classListData.value.find(item => item.name === info.classStandardName);
console.log(item, 'item---------------');
if (item) {
const params = {
name: item.name,
guid: item.guid,
refGradeGuid: item.refGradeGuid,
description: item.description,
isExpand: true
}
handleClassDataClick(params, '');
}
})
newCreateClassStandardDialogInfo.value.submitBtnLoading = false;
newCreateClassStandardDialogInfo.value.visible = false;
} else {
newCreateClassStandardDialogInfo.value.submitBtnLoading = false;
proxy.$ElMessage.error(res.msg);
}
} else {
newCreateClassStandardDialogInfo.value.submitBtnLoading = true;
const params = {
name: info.classStandardName,
refGradeGuid: info.refGradeGuid,
guid: classGuid.value,
type: 'C'
}
const res: any = await updateClassifyGrad(params);
if (res.code == proxy.$passCode) {
getClassListData();
proxy.$ElMessage({
type: 'success',
message: '修改分类成功'
})
newCreateClassStandardDialogInfo.value.visible = false;
} else {
proxy.$ElMessage.error(res.msg);
}
}
}
}
})
const newCreateClass = () => {
newCreateClassStandardDialogInfo.value.submitBtnLoading = false;
newCreateClassStandardDialogInfo.value.visible = true;
classStandardFormItems.value.forEach(item => item.default = '');
}
/** ------------------------------- 分级标准相关 ------------------------------------- */
const newCreateGradeFormItems = ref([{
label: '分级名称',
type: 'input',
maxlength: 50,
placeholder: '请输入',
field: 'name',
default: '',
block: true,
clearable: true,
required: true
}]);
const newCreateGradeFormRules = ref({
name: [required('请填写分级名称')],
});
const newCreateGradeStandardDialogInfo = ref({
visible: false,
size: 460,
title: "新增分级",
type: "",
formInfo: {
id: "grade-form",
items: newCreateGradeFormItems.value,
rules: newCreateGradeFormRules.value,
},
submitBtnLoading: false,
btns: {
cancel: () => {
newCreateGradeStandardDialogInfo.value.visible = false;
},
submit: async (btn, info) => {
newCreateGradeStandardDialogInfo.value.submitBtnLoading = true;
console.log(info, newCreateGradeStandardDialogInfo.value.title);
if (newCreateGradeStandardDialogInfo.value.title === '新增分级') {
const params = {
name: info.name,
type: 'G'
}
const res: any = await saveClassifyGrad(params);
if (res.code == proxy.$passCode) {
await getClassifyGradListData();
proxy.$ElMessage({
type: 'success',
message: '新增分级成功'
})
// 拿到新增的分级数据,跳转到配置页面
const item = classifyGradListData.value.find(item => item.name === info.name);
if (item) {
const params = {
name: item.name,
guid: item.guid,
}
handleClassifyGradDataClick(params);
}
newCreateGradeStandardDialogInfo.value.submitBtnLoading = false;
newCreateGradeStandardDialogInfo.value.visible = false;
} else {
newCreateGradeStandardDialogInfo.value.submitBtnLoading = false;
proxy.$ElMessage.error(res.msg);
}
} else {
const params = {
name: info.name,
guid: classifyGradGuid.value,
type: 'G'
}
const res: any = await updateClassifyGrad(params);
if (res.code == proxy.$passCode) {
getClassifyGradListData();
proxy.$ElMessage({
type: 'success',
message: '修改分级成功'
})
newCreateGradeStandardDialogInfo.value.visible = false;
} else {
proxy.$ElMessage.error(res.msg);
}
}
}
}
})
// 删除分级
const handleClassifyGradDataDel = async (item) => {
try {
// 弹出确认框
await proxy.$confirm('此操作将永久删除该分级, 是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
});
const res: any = await deleteClassifyGrad({ guid: item.guid });
if (res.code === proxy.$passCode) {
await getClassifyGradListData(); // 获取更新后的列表数据
proxy.$ElMessage({
type: 'success',
message: '删除成功!'
});
} else {
proxy.$ElMessage.error(res.msg); // 显示错误信息
}
} catch (error) {
if (error !== 'cancel') {
proxy.$ElMessage({
type: 'info',
message: '已取消删除'
});
}
}
};
// 编辑分级
const handleClassifyGradDataEdit = (itemGradeName) => {
newCreateGradeStandardDialogInfo.value.submitBtnLoading = false;
classifyGradGuid.value = itemGradeName.guid;
newCreateGradeStandardDialogInfo.value.visible = true;
newCreateGradeStandardDialogInfo.value.title = '编辑分级';
newCreateGradeFormItems.value.forEach(item => {
item.default = itemGradeName.name
})
}
// 配置分级
const handleClassifyGradDataClick = (item) => {
console.log(item);
router.push({
name: 'classifyGradEdit',
query: {
guid: item.guid,
classClassifyGradName: item.name
}
});
}
const newCreateGrade = () => {
newCreateGradeStandardDialogInfo.value.submitBtnLoading = false;
newCreateGradeStandardDialogInfo.value.visible = true;
newCreateGradeFormItems.value.forEach(item => item.default = '');
}
/** ------------------------------- 分类分级模板 ------------------------------------- */
// const pageInfo = ref({
// limit: 50,
// curr: 1,
// sizes: [
// { label: "10", value: 10 },
// { label: "50", value: 50 },
// { label: "100", value: 100 },
// { label: "150", value: 150 },
// { label: "200", value: 200 },
// ],
// type: "normal",
// rows: 0,
// })
// const newCreateTemplate = () => {
// router.push({
// name: 'newCreateTemplate',
// query: {
// classStandardName: '分类分级模板'
// }
// });
// }
// const tempBtn = () => {
// router.push({
// name: 'classificationTemplateEdit',
// query: {
// classClassifyGradName: '分类分级模板名称'
// }
// });
// }
// const pageChange = (info) => {
// pageInfo.value.curr = Number(info.curr);
// pageInfo.value.limit = Number(info.limit);
// getClassificationTemplateList();
// }
// const getClassificationTemplateList = async () => {
// const params = {
// pageSize: pageInfo.value.limit,
// pageIndex: pageInfo.value.curr,
// }
// const res = await getTempleteClassifyData(params);
// console.log(res);
// }
// onBeforeMount(() => {
// getClassificationTemplateList();
// })
</script>
<template>
<div class="container">
<Tabs :tabs-info="tabsInfo" @tab-change="tabChange" />
<!-- <div class="panel" v-show="tabsInfo.activeName == 'classTemplate'">
<div class="table_tool_wrap">
<TableTools :searchItems="searchItemList" :searchId="'template-manage-search'" @search="searchTemplate" />
<div class="tools_btns">
<el-button type="primary" @click="newCreateTemplate">新增模板</el-button>
<el-button type="primary" @click="tempBtn">测试页面</el-button>
</div>
</div>
<div class="content">
<TemplateItem />
</div>
<div class="botton-page-nav">
<PageNav :class="[pageInfo.type]" :pageInfo="pageInfo" @pageChange="pageChange" />
</div>
</div> -->
<div class="panel" v-show="tabsInfo.activeName == 'classStandard'">
<div class="table_tool_wrap">
<TableTools :searchItems="classSearchItemList" :searchId="'template-manage-search'" @search="searchClass" />
<div class="tools_btns">
<el-button type="primary" @click="newCreateClass">新增分类</el-button>
</div>
</div>
<div class="data-content" v-loading="classListDataLoading">
<div class="card-content" v-for="item in classListData" :key="item.guid" @click="handleClassDataClick(item)">
<div class="type-btn">
<el-popover v-model="cardBtnVisible" placement="bottom" width="96" trigger="click"
popper-class="tree-item-edit-menu" :show-arrow="false" :hide-after="0">
<template #reference>
<el-icon color="#666" @click.stop="cardBtnVisible = true">
<MoreFilled />
</el-icon>
</template>
<div class="levitation-ul">
<span class="levitation-li" @click="handleClassDataClick(item)">编辑</span>
<!-- <span class="levitation-li" @click="handleClassDataEdit(item)">编辑</span> -->
<span class="levitation-li" @click="handleClassDataDel(item)">删除</span>
</div>
</el-popover>
</div>
<el-icon class="title-icon">
<svg-icon name="folder" />
</el-icon>
<div class="title">{{ item.name }}</div>
</div>
<div v-if="!classListData.length" class="card-noData">
<img src="../../assets/images/no-data.png" :style="{ width: '96px', height: '96px' }" />
<span>暂无分类标准</span>
</div>
</div>
</div>
<div class="panel" v-show="tabsInfo.activeName == 'gradeStandard'">
<div class="tools_btns">
<el-button type="primary" @click="newCreateGrade">新增分级</el-button>
</div>
<div class="data-content" v-loading="classListDataLoading">
<div class="card-content" v-for="item in classifyGradListData" :key="item.guid"
@click="handleClassifyGradDataClick(item)">
<div class="type-btn">
<el-popover v-model="cardBtnVisible" placement="bottom" width="96" trigger="click"
popper-class="tree-item-edit-menu" :show-arrow="false" :hide-after="0">
<template #reference>
<el-icon color="#666" @click.stop="cardBtnVisible = true">
<MoreFilled />
</el-icon>
</template>
<div class="levitation-ul">
<span class="levitation-li" @click="handleClassifyGradDataClick(item)">编辑</span>
<!-- <span class="levitation-li" @click="handleClassifyGradDataEdit(item)">编辑</span> -->
<span class="levitation-li" @click="handleClassifyGradDataDel(item)">删除</span>
</div>
</el-popover>
</div>
<el-icon class="title-icon">
<svg-icon name="folder" />
</el-icon>
<div class="title">{{ item.name }}</div>
</div>
<div v-if="!classifyGradListData.length" class="card-noData">
<img src="../../assets/images/no-data.png" :style="{ width: '96px', height: '96px' }" />
<span>暂无分类标准</span>
</div>
</div>
</div>
<Dialog_form :dialogConfigInfo="newCreateClassStandardDialogInfo" />
<Dialog_form :dialogConfigInfo="newCreateGradeStandardDialogInfo" />
</div>
</template>
<style lang="scss" scoped>
.container {
height: 100%;
padding: 12px 16px 20px 16px;
.panel {
height: calc(100% - 51px);
display: flex;
flex-direction: column;
.content {
flex: 1;
height: 100%;
overflow-y: auto;
}
.botton-page-nav {
position: sticky;
bottom: 0;
width: 100%;
background-color: #fff;
z-index: 10;
}
}
}
:deep(.table-tools) {
.tools_search {
padding: 0px;
}
}
.tools_btns {
padding: 8px 0px 16px;
}
.data-content {
height: calc(100% - 92px);
display: flex;
flex-wrap: wrap;
gap: 24px;
align-content: flex-start;
overflow-y: auto;
.card-noData {
height: 100%;
width: 100%;
background: #fafafa;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
color: #909399;
font-size: 14px;
}
.card-content {
width: 18%;
max-width: 240px;
min-width: 220px;
height: 160px;
padding: 12px;
border: 1px solid var(--el-border-color-regular);
cursor: pointer;
display: flex;
flex-direction: column;
align-items: center;
position: relative;
&:hover {
border: 1px solid var(--el-color-primary);
}
:deep(.title-icon.el-icon) {
width: 40px;
height: 40px;
margin-top: 28px;
margin-bottom: 16px;
svg {
width: 40px;
height: 40px;
}
}
.title {
font-size: 14px;
color: #212121;
text-align: center;
line-height: 21px;
font-weight: 600;
margin-bottom: 12px;
}
.desc-row {
width: 100%;
display: flex;
justify-content: space-between;
.desc {
font-size: 12px;
color: #999999;
line-height: 18px;
}
}
.type-btn {
position: absolute;
right: 12px;
}
}
}
</style>