registerManagemant.vue
19 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
<route lang="yaml">
name: registerManagemant
</route>
<script lang="ts" setup name="registerManagemant">
import { ref } from 'vue';
import TableTools from "@/components/Tools/table_tools.vue";
import { ElMessage, ElMessageBox } from 'element-plus';
import { useRouter, useRoute } from "vue-router";
import { MoreFilled } from "@element-plus/icons-vue";
import {
tagMethod,
tagType,
} from "@/utils/common";
import {
getRegisterList,
registerDelete,
registerApproveCancel,
registerApproveReSubmit,
registerApproveAllow,
registerApproveBackup,
getRegisterTenant
} from "@/api/modules/dataAsset";
import useDataAssetStore from "@/store/modules/dataAsset";
import useUserStore from "@/store/modules/user";
const userStore = useUserStore();
const userData = JSON.parse(userStore.userData)
const assetStore = useDataAssetStore();
const router = useRouter();
const route = useRoute();
const { proxy } = getCurrentInstance() as any;
const path = route.path;
const searchItemList = ref([
{
type: "input",
label: "",
field: "daName",
default: "",
placeholder: "资产名称",
clearable: true,
},
{
type: "select",
label: "",
field: "tenantGuid",
default: "",
placeholder: "企业名称",
clearable: true,
filterable: true,
options: [],
props: {
value: 'guid',
label: 'tenantName'
},
visible: false,
},
{
type: 'select',
label: '',
field: 'approveState',
default: '',
placeholder: '全部状态',
options: [
{ label: '草稿中', value: 'N' },
{ label: '审批中', value: 'A' },
{ label: '已通过', value: 'Y' },
{ label: '已驳回', value: 'R' },
{ label: '已撤销', value: 'C' },
],
clearable: true
},
]);
const pageInfo = ref({
limit: 50,
curr: 1,
rows: 0,
type: "normal",
sizes: [
{ label: "10", value: 10 },
{ label: "50", value: 50 },
{ label: "100", value: 100 },
{ label: "150", value: 150 },
{ label: "200", value: 200 },
],
daName: '',
approveState: '',
tenantGuid: '',
});
const tableFields = ref([{ label: "序号", type: "index", width: 56, align: "center" },
{ label: "资产名称", field: "daName", width: 160, align: "left" },
{ label: "数据分类", field: "dataCategoryName", width: 120, align: "left" },
{ label: "存储方式", field: "storageFormName", width: 120, align: "left" },
{
label: "所属行业", field: "ownIndustryName", width: 120, align: "left", getName: (scope) => {
return scope.row['ownIndustryName']?.join(',')
}
},
{ label: "状态", field: "approveState", type: "tag", width: 96, align: 'center' },
{ label: "修改人", field: "updateUserName", width: 140 },
{ label: "修改时间", field: "updateTime", width: 180 }]);
/** 是否时企业端。不是企业端,则是服务端。 */
const isCompanyPlatform = ref(userData.tenantType == 1);
const listDataLoading = ref(false);
const activeListType = ref('card');
const listData: any = ref([]);
/** 记录点击省略号弹出菜单的visible */
const cardBtnVisible: any = ref(false);
const tableInfo = ref({
id: 'asset-data-table',
rowKey: 'guid',
loading: false,
fields: tableFields.value,
data: listData.value,
showPage: false,
actionInfo: {
label: "操作",
type: "btn",
width: 160,
btns: (scope) => {
let row = scope.row;
return getTableBtns(row);
}
}
});
const getTableBtns = (row, includeDetail = true) => {
let btnsArr: any[] = [];
if (row.approveState == 'N') {//只有草稿中的详情是可以编辑的
includeDetail && btnsArr.push({ label: "详情", value: "path_detail" })
if (row.tenantGuid == userData.tenantGuid) {
btnsArr.push({ label: "删除", value: "delete" });
}
} else if (row.approveState == 'A') {//审批中
includeDetail && btnsArr.push({ label: "详情", value: "path_detail" })
if (row.tenantGuid == userData.tenantGuid) {
btnsArr.push({ label: "撤销", value: "revoke" });
}
if (row.approveTenantGuids?.includes(userData.tenantGuid)) {
btnsArr.push({ label: "通过", value: "pass" });
btnsArr.push({ label: "驳回", value: "backup" });
}
} else if (row.approveState == 'Y') {//已通过的不能删除。
includeDetail && btnsArr.push({ label: "详情", value: "path_detail" })
} else if (row.approveState == 'R' || row.approveState == 'C') {//已驳回或已撤销
includeDetail && btnsArr.push({ label: "详情", value: "path_detail" });
if (row.tenantGuid == userData.tenantGuid) {
btnsArr.push({ label: "重新提交", value: "edit", disabled: false })
}
if (row.tenantGuid == userData.tenantGuid) {
btnsArr.push({ label: "删除", value: "delete" });
}
}
return btnsArr;
}
const currTableData: any = ref({});
const tableBtnClick = (scope, btn) => {
const type = btn.value;
const row = scope.row;
currTableData.value = row;
if (type === "edit") { //草稿中\已驳回\已撤销\已通过 状态,才可以编辑。
router.push({
name: 'registerStart',
query: { guid: row.guid }
});
} else if (type == "delete") {
delTableOpen("此操作将永久删除该资产登记,是否继续?", "warning");
} else if (type === 'revoke') { // 撤销,状态为审批中时可以撤销。
ElMessageBox.confirm('确定撤销该资产登记审批流程吗?', "提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: 'warning',
}).then(() => {
listDataLoading.value = true;
let params = {
bizGuid: row.guid,
funcCode: row.funcCode
}
registerApproveCancel(params).then((res: any) => {
listDataLoading.value = false;
if (res?.code == proxy.$passCode) {
if (res.data) {
ElMessage.success('该审批流程撤销成功!');
row.approveState = "C";
} else {
ElMessage.error('该审批流程撤销失败!');
}
} else {
ElMessage.error(res.msg);
}
});
}).catch(() => {
ElMessage({
type: 'info',
message: '已取消撤销'
});
});
} else if (type === 'path_detail') { // 详情, 若是草稿中,详情就是编辑,
if (row.approveState === 'N') {
router.push({
name: 'registerStart',
query: { guid: row.guid }
});
} else {
router.push({
name: 'registerInfoDetail',
query: { guid: row.guid, type: 'asset', daTenantGuid: row.tenantGuid }
});
}
} else if (type === 'pass') {
passDialogInfo.value.visible = true;
} else if (type == 'backup') {
rejectDialogInfo.value.visible = true;
}
};
const handleDataClick = (item) => {
if (item.approveState === 'N') {
router.push({
name: 'registerStart',
query: { guid: item.guid }
});
} else {
router.push({
name: 'registerInfoDetail',
query: { guid: item.guid, type: 'asset', daTenantGuid: item.tenantGuid }
});
}
}
const delTableOpen = (msg, type, isBatch: boolean = false) => {
ElMessageBox.confirm(msg, "提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: type,
}).then(() => {
let guids: any = [];
guids = [currTableData.value.guid]
registerDelete(guids).then((res: any) => {
if (res.code == proxy.$passCode) {
pageInfo.value.curr = 1;
getTableData();
ElMessage({
type: "success",
message: "删除资产登记成功",
});
} else {
ElMessage({
type: "error",
message: res.msg,
});
}
})
}).catch(() => {
ElMessage({
type: 'info',
message: '已取消删除'
});
});
};
const getTableData = () => {
listDataLoading.value = true;
tableInfo.value.loading = true;
getRegisterList({
pageSize: pageInfo.value.limit,
pageIndex: pageInfo.value.curr,
daName: pageInfo.value.daName,
approveState: pageInfo.value.approveState,
tenantGuid: pageInfo.value.tenantGuid
}).then((res: any) => {
listDataLoading.value = false;
tableInfo.value.loading = false;
if (res.code == proxy.$passCode) {
const data = res.data || {}
listData.value = tableInfo.value.data = data.records || [];
pageInfo.value.limit = data.pageSize
pageInfo.value.curr = data.pageIndex
pageInfo.value.rows = data.totalRows
} else {
ElMessage.error(res.msg);
}
})
}
const toSearch = (val: any, clear: boolean = false) => {
pageInfo.value.curr = 1;
if (clear) {
searchItemList.value.map((item) => (item.default = ""));
pageInfo.value.daName = '';
pageInfo.value.approveState = "";
pageInfo.value.tenantGuid = "";
} else {
pageInfo.value.daName = val.daName;
pageInfo.value.approveState = val.approveState;
pageInfo.value.tenantGuid = val.tenantGuid;
}
getTableData();
};
const pageChange = (info) => {
pageInfo.value.curr = Number(info.curr);
pageInfo.value.limit = Number(info.limit);
getTableData();
};
onActivated(() => {
if (assetStore.isRefresh) {//如果是首次加载,则不需要调用
pageInfo.value.curr = 1;
getTableData();
assetStore.set(false);
}
})
onBeforeMount(() => {
if (isCompanyPlatform.value) {
tableInfo.value.fields = tableFields.value;
searchItemList.value[1].visible = false;
} else {
tableFields.value.splice(2, 0, { label: "企业名称", field: "tenantName", width: 240, align: "left" });
tableInfo.value.fields = tableFields.value;
searchItemList.value[1].visible = true;
getRegisterTenant().then((res: any) => {
if (res.code == proxy.$passCode) {
searchItemList.value[1].options = res.data || [];
} else {
ElMessage.error(res.msg);
}
});
}
})
const handleCreate = () => {
router.push({
name: 'registerStart'
});
}
const passDialogInfo = ref({
visible: false,
size: 460,
direction: "column",
header: {
title: "通过",
},
type: '',
contents: [
{
type: 'form',
title: '',
formInfo: {
id: 'batch-pass-form',
items: [
{
label: '',
type: "textarea",
placeholder: "请填写通过理由(必填)",
field: "approveSuggest",
clearable: true,
block: true,
col: 'margin_b_0',
}
]
}
}
],
footer: {
btns: [
{ type: "default", label: "取消", value: "cancel" },
{ type: "primary", label: "确定", value: "submit" },
],
},
});
const passDialogBtnClick = (btn, info) => {
if (btn.value == 'submit') {
listDataLoading.value = true;
let params = {
bizGuid: currTableData.value.guid,
funcCode: currTableData.value.funcCode,
approveSuggest: info.approveSuggest
}
registerApproveAllow(params).then((res: any) => {
listDataLoading.value = false;
if (res?.code == proxy.$passCode) {
if (res.data) {
ElMessage.success('审批成功');
passDialogInfo.value.visible = false;
getTableData();
} else {
ElMessage.error('审批失败');
}
} else {
ElMessage.error(res.msg);
}
});
} else if (btn.value == 'cancel') {
passDialogInfo.value.visible = false;
}
};
const rejectDialogInfo = ref({
visible: false,
size: 460,
direction: "column",
header: {
title: "驳回",
},
type: '',
contents: [
{
type: 'form',
title: '',
formInfo: {
id: 'batch-reject-form',
items: [
{
label: '',
type: "textarea",
placeholder: "请填写驳回理由(必填)",
field: "approveSuggest",
clearable: true,
block: true,
col: 'margin_b_0',
}
]
}
}
],
footer: {
btns: [
{ type: "default", label: "取消", value: "cancel" },
{ type: "primary", label: "确定", value: "submit" },
],
},
});
const rejectDialogBtnClick = (btn, info) => {
if (btn.value == 'submit') {
if (info.approveSuggest == '') {
ElMessage.error('请填写驳回理由');
return
}
listDataLoading.value = true;
let params = {
bizGuid: currTableData.value.guid,
funcCode: currTableData.value.funcCode,
approveSuggest: info.approveSuggest
}
registerApproveBackup(params).then((res: any) => {
listDataLoading.value = false;
if (res?.code == proxy.$passCode) {
if (res.data) {
ElMessage.success('驳回成功');
rejectDialogInfo.value.visible = false;
getTableData();
} else {
ElMessage.error('驳回失败');
}
} else {
ElMessage.error(res.msg);
}
});
} else if (btn.value == 'cancel') {
rejectDialogInfo.value.visible = false;
}
};
const createBtnVisible = computed(() => {
return isCompanyPlatform || (userStore.hasPermission('数据资产', path, '新建'))
})
</script>
<template>
<div class="container_wrap">
<div class="table_tool_wrap">
<TableTools :searchItems="searchItemList" :searchId="'register-data-search'" @search="toSearch" />
<div class="tools_btns">
<el-button type="primary" @click="handleCreate" v-if="createBtnVisible" v-preReClick>新建</el-button>
<div class="view-change">
<div class="list-btn" :class="[activeListType === 'list' ? 'active' : '']" @click="activeListType = 'list'">
<el-icon style="width: 12px;height: 12px;">
<svg-icon style="width: 12px;height: 12px;"
:name="activeListType === 'list' ? 'btn-list-white' : 'btn-list'" />
</el-icon>
</div>
<div class="card-btn" :class="[activeListType === 'card' ? 'active' : '']" @click="activeListType = 'card'">
<el-icon style="width: 12px;height: 12px;">
<svg-icon style="width: 12px;height: 12px;"
:name="activeListType === 'card' ? 'btn-card-white' : 'btn-card'" />
</el-icon>
</div>
</div>
</div>
</div>
<div class="table_panel_wrap" :style="{ height: createBtnVisible ? 'calc(100% - 89px)' : 'calc(100% - 40px)' }">
<div v-if="activeListType === 'card'" class="data-content" v-loading="listDataLoading">
<div class="card-content" v-for="item in listData" :key="item.guid" @click="handleDataClick(item)">
<div class="title-row">
<div class="title">
<ellipsis-tooltip :content="item.daName" class-name="w100f"
:refName="'tooltipOver' + item.guid"></ellipsis-tooltip>
</div>
<el-tag :type="(tagType(item, 'approveState') as any)">{{
tagMethod(item, 'approveState')
}}</el-tag>
</div>
<div v-if="!isCompanyPlatform" class="desc">{{ item.tenantName ?? '深圳传世般若有限公司' }}</div>
<div class="desc">{{ item.updateTime }}</div>
<div class="type-btn">
<template v-if="item.ownIndustryName?.length">
<div class="type-items">
<div v-for="(info) in item.ownIndustryName" class="type">{{ info }}</div>
</div>
</template>
<template v-else>
<div class="type-items"></div>
</template>
<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 class="list-more" color="#666" v-show="getTableBtns(item, false)?.length > 0"
@click.stop="cardBtnVisible = true">
<MoreFilled />
</el-icon>
</template>
<div class="levitation-ul">
<span class="levitation-li" v-for="btn in getTableBtns(item, false)"
@click="tableBtnClick({ row: item }, btn)">{{
btn.label }}</span>
</div>
</el-popover>
</div>
</div>
<div v-if="!listData.length" class="card-noData">
<img src="../../assets/images/no-data.png" :style="{ width: '96px', height: '96px' }" />
<span>暂无数据资产</span>
</div>
</div>
<Table v-else :tableInfo="tableInfo" @tableBtnClick="tableBtnClick" />
<PageNav :class="[pageInfo.type]" :pageInfo="pageInfo" @pageChange="pageChange" />
</div>
<Dialog :dialogInfo="passDialogInfo" @btnClick="passDialogBtnClick" />
<Dialog :dialogInfo="rejectDialogInfo" @btnClick="rejectDialogBtnClick" />
</div>
</template>
<style scoped lang="scss">
.container_wrap {
padding: 0 16px;
}
.table_panel {
height: calc(100% - 44px) !important;
}
.tools_btns {
display: flex;
justify-content: space-between;
align-items: center;
.view-change {
width: 56px;
height: 22px;
border: 1px solid var(--el-border-color-regular);
border-radius: 2px;
display: flex;
cursor: pointer;
.list-btn {
width: 50%;
display: flex;
justify-content: center;
align-items: center;
&.active {
background-color: var(--el-color-primary);
}
}
.card-btn {
width: 50%;
border-left: 1px solid var(--el-border-color-regular);
display: flex;
justify-content: center;
align-items: center;
&.active {
background-color: var(--el-color-primary);
}
}
}
}
.data-content {
height: calc(100% - 44px);
display: flex;
flex-wrap: wrap;
gap: 20px 20px;
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: 22%;
min-width: 220px;
height: auto;
padding: 16px;
border: 1px solid var(--el-border-color-regular);
border-radius: 4px;
cursor: pointer;
&:hover {
border: 1px solid var(--el-color-primary);
}
.title-row {
display: flex;
height: 24px;
line-height: 24px;
justify-content: space-between;
.title {
font-size: 16px;
color: var(--el-text-color-primary);
font-weight: 600;
flex-shrink: 1;
min-width: 0;
flex-grow: 1;
margin-right: 12px;
}
}
.desc {
font-size: 14px;
color: var(--el-text-color-regular);
line-height: 21px;
margin-top: 4px;
height: 21px;
}
.type-btn {
margin-top: 4px;
display: flex;
height: 24px;
line-height: 24px;
justify-content: space-between;
align-items: center;
.type-items {
display: inline-flex;
}
.type {
width: auto;
padding: 0 6px;
height: 18px;
border-radius: 10px;
border: 1px solid var(--el-color-primary);
line-height: 18px;
font-size: 12px;
color: var(--el-color-primary);
text-align: center;
margin-right: 4px;
}
.list-more {
margin: 0px 4px;
}
}
}
}
</style>