damQualityAssess.vue
8.97 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
<route lang="yaml">
name: damQualityAssess
</route>
<script lang="ts" setup name="damQualityAssess">
import { ref } from 'vue';
import { TableColumnWidth, commonPageConfig } from '@/utils/enum';
import {
getQualityList,
getQualityDamList,
deleteQualityPlan,
executePlan,
downPlanSql
} from "@/api/modules/dataAssetQuality";
import useDataAssetStore from "@/store/modules/dataAsset";
import { download } from '@/utils/common';
import useUserStore from "@/store/modules/user";
const userStore = useUserStore()
const userData = JSON.parse(userStore.userData)
const assetStore = useDataAssetStore();
const { proxy } = getCurrentInstance() as any;
const router = useRouter();
const damListData = ref([]);
const serachFormRef = ref();
const searchItemList = ref([
{
type: 'select',
label: '',
field: 'damGuid',
default: '',
placeholder: '数据资产名称',
options: damListData.value,
props: {
value: 'guid',
label: 'damName'
},
filterable: true,
clearable: true,
required: true,
visible: true
}
])
/** 分页及搜索传参信息配置。 */
const page = ref({
...commonPageConfig,
damGuid: ''
});
/** 方案表格配置信息。 */
const tableInfo = ref({
id: 'quality-table',
// multiple: true,
loading: false,
nodeKey: 'guid',
fields: [
{ label: "序号", type: "index", width: TableColumnWidth.INDEX, fixed: "left", align: "center" },
{
label: "数据资产名称", field: "damName", width: 160, fixed: "left", type: "text_btn", value: "damDetail", columClass: 'text_btn', click: (scope) => {
router.push({
name: "registerCatalogDetail",
query: { guid: scope.row.damGuid },
});
}
},
{ label: "所属企业", field: "tenantName", width: 240 },
{ label: "质量评分", field: "qualityScore", width: 120, align: 'right' },
{ label: "执行状态", field: "execState", width: TableColumnWidth.STATE, align: 'center', type: "tag" },
{ label: "执行时间", field: "lastExecTime", width: TableColumnWidth.DATETIME, },
{ label: "创建人", field: "createUserName", width: TableColumnWidth.USERNAME },
{ label: "修改人", field: "updateUserName", width: TableColumnWidth.USERNAME },
{ label: "修改时间", field: "updateTime", width: TableColumnWidth.DATETIME, },
],
data: [],
page: {
type: "normal",
rows: 0,
...page.value,
},
actionInfo: {
label: "操作",
type: "btn",
isMore: true,
width: 271,
btns: (scope) => {
const row = scope.row
let btnsArr: any = [{
label: "查看报告", value: "reportView", disabled: row.execState == 1 || row.isExecute || row.execState == 0, click: (scope) => {
router.push({
name: 'damAnalysisReport',
query: {
planGuid: row.guid,
name: row.damName,
reportExecGuid: row.reportExecGuid
}
});
}
}, {
label: "查看结果", value: "resultView", disabled: row.execState == 1 || row.isExecute || row.execState == 0, click: (scope) => {
router.push({
name: 'damAssessDetail',
query: {
name: row.damName,
planExecGuid: row.planExecGuid
}
});
}
}, {
label: "编辑", value: "edit", disabled: row.execState == 1 || row.isExecute, click: (scope) => {
router.push({
name: 'damQualityPlan',
query: {
guid: row.guid,
damName: row.damName
}
});
}
}];
if (row.isExecute) {
btnsArr.push({ label: "执行中", value: "execute", disabled: true });
} else {
btnsArr.push({
label: "执行", value: "execute", disabled: row.execState == 1 || row.state == 0, click: (scope) => {
row.isExecute = true
executePlan({ planGuid: row.guid, reportGuid: row.reportGuid }).then((res: any) => {
if (res.code == proxy.$passCode) {
getTableData();
proxy.$ElMessage.success('执行完成');
} else {
proxy.$ElMessage.error(res.msg);
}
row.isExecute = false
}).catch(() => {
row.isExecute = false
})
}
});
}
btnsArr.push({
label: "日志", value: "path_log", disabled: row.execState == 0, click: (scope) => {
router.push({
name: 'damQualityAssessLog',
query: {
guid: row.damGuid,
name: row.damName,
reportGuid: row.reportGuid
}
});
}
});
btnsArr.push({
label: "删除", value: "delete", disabled: row.execState == 1 || row.isExecute, click: (scope) => {
if (scope.row.createUserId && userData.userGuid !== scope.row.createUserId) {
proxy.$ElMessage.error('只有创建人才可以删除该资产质量评估');
return;
}
proxy.$openMessageBox("确定要删除该资产质量评估吗?", () => {
deleteQualityPlan([scope.row.guid]).then((res: any) => {
if (res.code == proxy.$passCode) {
page.value.curr = 1;
/** 将当前查询到的删除了,清除。 */
if (page.value.damGuid == row.damGuid) {
page.value.damGuid = '';
serachFormRef.value?.toolSearch?.formRef?.resetFields?.();
getTableData();
} else {
getTableData();
}
proxy.$ElMessage.success('删除该资产质量评估成功');
} else {
proxy.$ElMessage.error(res.msg);
}
});
}, () => {
proxy.$ElMessage.info("已取消删除");
})
}
});
btnsArr.push({
label: 'SQL下载', value: 'sqldown', disabled: row.execState == 1 || row.isExecute || row.execState == 0, click: (scope) => {
downPlanSql(scope.row.guid).then((res: any) => {
if (res && !res.msg) {
download(res, `SQL-${scope.row.damName}.zip`, 'zip');
} else {
res?.msg && proxy.$ElMessage.error(res?.msg);
}
});
}
});
return btnsArr
}
}
});
const toSearch = (val: any, clear: boolean = false) => {
page.value.curr = 1;
if (clear) {
searchItemList.value.map(item => item.default = '')
page.value.damGuid = '';
getTableData(false);
return;
}
page.value.damGuid = val.damGuid;
getTableData(false);
};
/**
* 调用接口刷新获取方案表格数据
* @param refreshData 如果是刷新数据,需要更新查询列表。
*/
const getTableData = (refreshData = true) => {
tableInfo.value.loading = true;
getQualityList({
pageIndex: page.value.curr, pageSize: page.value.limit,
damGuid: page.value.damGuid
}).then((res: any) => {
tableInfo.value.loading = false;
if (res === undefined) {
return;
}
if (res.code == proxy.$passCode) {
const data = res.data || {}
tableInfo.value.data = data.records || []
tableInfo.value.page.limit = data.pageSize
tableInfo.value.page.curr = data.pageIndex
tableInfo.value.page.rows = data.totalRows
} else {
proxy.$ElMessage.error(res.msg);
}
})
if (refreshData) {
getSearchQualityDamList();
}
};
/** 监听处理分页事件。 */
const tablePageChange = (info) => {
page.value.curr = Number(info.curr);
page.value.limit = Number(info.limit);
getTableData(false);
};
const handleCreate = () => {
router.push({
name: 'damQualityPlan'
});
}
const getSearchQualityDamList = () => {
getQualityDamList().then((res: any) => {
if (res.code == proxy.$passCode) {
const data = res.data || [];
searchItemList.value[0].options = data;
} else {
proxy.$ElMessage.error(res.msg);
}
});
}
onBeforeMount(() => {
if (!assetStore.qualityAssessRefresh) {
getSearchQualityDamList();
}
});
onActivated(() => {
if (assetStore.qualityAssessRefresh) {
page.value.curr = 1;
getTableData();
assetStore.setQualityAssessRefresh(false);
}
})
</script>
<template>
<div class="container_wrap">
<div class="table_tool_wrap has_search">
<Table_tools ref="serachFormRef" :searchItems="searchItemList" searchId="quality-search" @search="toSearch" />
<div class="tools_btns">
<el-button type="primary" @click="handleCreate">新建</el-button>
</div>
</div>
<div class="table_panel_wrap">
<Table :tableInfo="tableInfo" @tablePageChange="tablePageChange" />
</div>
</div>
</template>
<style lang="scss" scoped>
.table_tool_wrap {
width: 100%;
height: 84px !important;
padding: 0 8px;
:deep(.table-tools) {
.el-select {
width: 230px;
}
}
.tools_btns {
padding: 8px 0 0;
}
}
.table_panel_wrap {
width: 100%;
height: calc(100% - 84px);
padding: 8px 8px 0;
}
</style>