certificateManagement.vue
7.7 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
<route lang="yaml">
name: certificateManagement
</route>
<script lang="ts" setup name="certificateManagement">
import { ref } from 'vue';
import TableTools from "@/components/Tools/table_tools.vue";
import { ElMessage, ElMessageBox } from 'element-plus';
import {
getRegistDocumentList,
updateCertificate
} from "@/api/modules/dataAsset";
import useUserStore from "@/store/modules/user";
import useDataAssetStore from "@/store/modules/dataAsset";
const assetStore = useDataAssetStore();
const router = useRouter();
const { proxy } = getCurrentInstance() as any;
const userStore = useUserStore();
const userData = JSON.parse(userStore.userData);
/** 是否时企业端。不是企业端,则是服务端,需要显示企业名称。 */
const isCompanyPlatform = ref(userData.tenantType == 1);
onBeforeMount(() => {
if (isCompanyPlatform.value) {
tableInfo.value.fields = tableFields.value;
} else {
tableFields.value.splice(4, 0, { label: "企业名称", field: "tenantName", width: 240, align: "left" })
tableInfo.value.fields = tableFields.value;
}
})
onActivated(() => {
if (assetStore.isRefresh) {//如果是首次加载,则不需要调用
page.value.curr = 1;
getTableData();
assetStore.set(false);
}
});
const searchItemList = ref([
{
type: "input",
label: "",
field: "daName",
default: "",
placeholder: "资产名称",
clearable: true,
},
{
type: 'select',
label: '',
field: 'state',
default: '',
placeholder: '全部状态',
options: [
{ label: '已过期', value: 0 },
{ label: '待制证', value: 1 },
{ label: '待发证', value: 2 },
{ label: '发证中', value: 3 },
{ label: '已发证', value: 4 }
],
clearable: true
},
{
type: 'select',
label: '',
field: 'documentType',
default: '',
placeholder: '全部类型',
options: [
{ label: 'A证', value: 1 },
{ label: 'B证', value: 2 },
{ label: 'C证', value: 3 }
],
clearable: true
},
]);
const toSearch = (val: any, clear: boolean = false) => {
page.value.curr = 1;
if (clear) {
searchItemList.value.map((item) => (item.default = ""));
page.value.daName = '';
page.value.state = "";
page.value.documentType = "";
} else {
page.value.daName = val.daName;
page.value.state = val.state;
page.value.documentType = val.documentType;
}
getTableData();
};
const getTableData = () => {
tableInfo.value.loading = true;
getRegistDocumentList({
pageSize: page.value.limit,
pageIndex: page.value.curr,
daName: page.value.daName,
state: page.value.state,
documentType: page.value.documentType
}).then((res: any) => {
tableInfo.value.loading = false;
if (res.code == proxy.$passCode) {
const data = res.data || {};
tableInfo.value.data = data.records || [];
tableInfo.value.page.curr = data.pageIndex;
tableInfo.value.page.rows = data.totalRows || 0;
} else {
ElMessage.error(res.msg);
}
})
}
const page = 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 },
],
daName: '',
state: '',
documentType: ''
});
const tableFields = ref([
{ label: "序号", type: "index", width: 56, align: "center" },
{ label: "资产名称", field: "daName", width: 160, align: "left" },
{ label: "资产编码", field: "daCode", width: 160, align: "left" },
{ label: "登记时间", field: "registerTime", width: 120 },
{ label: "有限期", field: "effectiveDate", width: 140 },
//{ label: "企业名称", field: "tenantName", width: 240, align: "left" },
{ label: "发证主体", field: "issuingEntityName", width: 250, align: "left" },
{
label: "类型", field: "documentType", width: 96, align: "left", getName: (scope) => {
let type = scope.row.documentType;
return type == 1 ? 'A证' : (type == 2 ? 'B证' : 'C证');
}
},
{ label: "状态", field: "state", type: "tag", width: 96, align: 'center' },
]);
const tableInfo = ref({
id: 'certificate-data-table',
rowKey: 'guid',
loading: false,
fields: tableFields.value,
data: [],
page: {
type: "normal",
rows: 0,
...page.value,
},
actionInfo: {
label: "操作",
type: "btn",
width: 120,
btns: (scope) => {
let row = scope.row;
return getTableBtns(row);
}
}
});
const getTableBtns = (row) => {
let btnsArr: any[] = [];
if (row.state == 3) {
btnsArr.push({ label: "确认", value: "confirm" })
}
btnsArr.push({ label: "详情", value: "path_detail" })
return btnsArr;
}
const currTableData: any = ref({});
const tableBtnClick = (scope, btn) => {
const type = btn.value;
const row = scope.row;
currTableData.value = row;
if (type == "confirm") {
formItems.value[0].default = [];
dialogInfo.value.visible = true;
} if (type === 'path_detail') { // 详情
router.push({
name: 'certificateDetail',
query: { guid: row.registerGuid, certificateGuid: row.guid, type: 'certificate', daTenantGuid: row.tenantGuid }
});
}
};
const tablePageChange = (info) => {
page.value.curr = Number(info.curr);
page.value.limit = Number(info.limit);
getTableData();
};
const formItems = ref([{
label: '证件上传',
tip: '支持扩展名:.jpg .png',
accept: '.jpg, .png',
type: 'upload-file',
placeholder: '请选择',
field: 'documentFile',
default: [],
block: true,
required: true
}]);
const formRules = ref({
documentFile: [{
validator: (rule: any, value: any, callback: any) => {
if (!value?.length) {
callback(new Error('请上传证件'))
} else {
callback();
}
}, trigger: 'change'
}]
});
const dialogInfo = ref({
visible: false,
size: 400,
direction: "column",
header: {
title: "确认发证",
},
type: '',
contents: [
{
type: 'form',
title: '',
formInfo: {
id: 'confirm-upload-file',
items: formItems.value,
rules: formRules.value
}
}
],
footer: {
btns: [
{ type: "default", label: "取消", value: "cancel" },
{ type: "primary", label: "确定", value: "submit" },
],
},
});
const updatePromise: any = ref(null);
/** 确认发证上传后的确定按钮处理。 */
const dialogBtnClick = (btn, info) => {
if (btn.value == 'submit') {
if (updatePromise.value) {
return;
}
updatePromise.value = updateCertificate({
guid: currTableData.value.guid,
tenantGuid: userData.tenantGuid,
daCode: currTableData.value.daCode,
state: 4,
documentFile: info.documentFile?.map(f => f.url) || []
}).then((res: any) => {
updatePromise.value = null;
if (res?.code == proxy.$passCode) {
ElMessage.success('该资产发证确认成功');
dialogInfo.value.visible = false;
page.value.curr = 1;
getTableData();
} else {
ElMessage.error(res.msg);
}
})
} else if (btn.value == 'cancel') {
dialogInfo.value.visible = false;
}
};
</script>
<template>
<div class="container_wrap">
<div class="table_tool_wrap">
<TableTools :searchItems="searchItemList" :searchId="'register-data-search'" @search="toSearch" :init="true" />
</div>
<div class="table_panel_wrap">
<Table :tableInfo="tableInfo" @tableBtnClick="tableBtnClick" @tablePageChange="tablePageChange" />
</div>
<Dialog :dialogInfo="dialogInfo" @btnClick="dialogBtnClick" />
</div>
</template>
<style scoped lang="scss">
.container_wrap {
padding: 0 16px;
.table_panel_wrap {
height: calc(100% - 44px);
}
}
:deep(.upload-file) {
.el-upload__tip {
margin-left: 0px;
}
}
</style>