qualityAnalysis.vue
14.9 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
<route lang="yaml">
name: qualityAnalysis
</route>
<script lang="ts" setup name="qualityAnalysis">
import { ref } from 'vue'
import { ElMessage, ElMessageBox } from "element-plus";
import TableTools from '@/components/Tools/table_tools.vue'
import Table from '@/components/Table/index.vue'
import Dialog from '@/components/Dialog/index.vue'
import { useRouter } from "vue-router";
import {
getQualityWordList,
deleteQualityWord,
addQualityWord,
updateQualityWord,
executeReport,
stateChange
} from '@/api/modules/dataQualityWord';
import {
getPlanList
} from '@/api/modules/dataQualityAssess';
import {
getCronExecTime
} from '@/api/modules/queryService';
import { TableColumnWidth } from '@/utils/enum';
const { proxy } = getCurrentInstance() as any;
const router = useRouter();
const searchItemList = ref([
{
type: 'input',
label: '',
maxlength: 50,
field: 'analysisReportName',
default: '',
placeholder: '报告名称',
clearable: true
}
])
const currTableData: any = ref<Object>({});
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 },
],
analysisReportName: '', //报告名称
});
const selectRowData = ref([])
const tableInfo = ref({
id: "word-manage-table",
// multiple: true,
loading: false,
fields: [
{ label: "报告名称", field: "analysisReportName", width: 160 },
{ label: "评估方案名称", field: "planName", width: 140 },
{
label: "方案类型", field: "planType", width: 90, getName: (scope) => {
let planType = scope.row.planType;
return planType == 1 ? '表' : (planType == 2 ? '数据库' : '分组');
}
},
{ label: "质量规则集", field: "qualityModelName", width: 150 },
{ label: "质量评分", field: "qualityScore", width: 100, align: 'right' },
{
label: '状态', field: 'state', type: 'switch', activeText: '上线', inactiveText: '下线', activeValue: 1, inactiveValue: 0, switchWidth: 56, width: 96, align: 'center', isDisabled: (scope) => {
return scope.row.isPlanGen == 'Y';
},toolTipContent:"质量评估方案生成的报告禁止上下线、编辑、删除",columClass:"text_btn"
},
{ label: "执行状态", field: "execState", type: 'tag', width: 100, align: 'center' },
{
label: "执行周期", field: "execCycle", width: TableColumnWidth.EXECCYCLE
},
{ label: "下次执行时间", field: "nextExecTime", width: TableColumnWidth.DATETIME, },
{ label: "最后执行时间", field: "lastExecTime", width: TableColumnWidth.DATETIME, },
{ label: "修改人", field: "updateUserName", width: TableColumnWidth.USERNAME },
{ label: "修改时间", field: "updateTime", width: TableColumnWidth.DATETIME, },
],
data: [],
page: {
type: "normal",
rows: 0,
...page.value,
},
actionInfo: {
label: "操作",
type: "btn",
width: 300,
fixed: 'right',
btns: (scope) => {
const row = scope.row
let btnsArr: any = [
{ label: "查看报告", value: "reportView", disabled: row['execState'] != 2 },
{ label: "编辑", value: "edit", disabled: row.execState === 1 || row.isExecute || scope.row.isPlanGen == 'Y' || scope.row.state == 1 }];
if (row.isExecute) {
btnsArr.splice(2, 0, { label: "执行中...", value: "execute", disabled: true })
} else {
btnsArr.splice(2, 0, { label: "手动执行", value: "execute", disabled: row.execState === 1 || scope.row.state == 0 })
}
btnsArr.push({ label: "执行日志", value: "path_log", disabled: !row['execState'] });
btnsArr.push({ label: "删除", value: "delete", disabled: row.isExecute || row.execState === 1 || scope.row.isPlanGen == 'Y' || scope.row.state == 1 });
return btnsArr
}
}
});
/** 评估方案选择列表。 */
const planList: any = ref([]);
const getAllPlanListPromise: any = ref(null);
onActivated(() => {
// 新建分析报告时应该只能选择上线的方案。
getAllPlanListPromise.value = getPlanList({ pageSize: -1, pageIndex: 1, state: 1 }).then((res: any) => {
getAllPlanListPromise.value = null;
if (res.code == proxy.$passCode) {
const data = res.data || {}
planList.value = data.records || [];
formItems.value[0].options = planList.value;
} else {
ElMessage({
type: 'error',
message: res.msg,
})
}
});
})
/** 新建编辑方案的对话框对象。 */
const wordDialogRef = ref();
const formItems = ref([
{
label: '评估方案名称',
type: 'select',
placeholder: '请选择',
field: 'planGuid',
default: '',
options: planList.value,
props: {
value: 'guid',
label: 'planName'
},
clearable: true,
filterable: true,
required: true,
disabled: false,
}, {
label: '报告名称',
type: 'input',
maxlength: 50,
placeholder: '请输入',
field: 'analysisReportName',
default: '',
clearable: true,
required: true
}, {
label: '报告保留期数(期)',
type: 'input',
inputType: 'integerNumber',
placeholder: '请输入',
field: 'reserveCycle',
default: 365,
max: 1000,
min: 1,
clearable: true,
required: false
},{
label: '是否上线',
type: 'switch',
field: 'state',
default: 0,
activeText:"上线",
inactiveText:"下线",
activeValue: 1,
inactiveValue: 0
},{
label: '执行周期',
type: 'input-popover-panel',
placeholder: '',
field: 'execCycle',
teleported: false,
default: "",
append: {
btn: { label: '执行时间', value: 'cron' }
},
required: true,
block: true
},
{
label: '接下来五次执行时间',
type: 'textarea',
placeholder: '执行时间',
field: 'zxzq',
clearable: true,
required: false,
rows: 5,
block: true,
visible: true,
readonly: true
},
])
const formRules = ref({
planGuid: [{ required: true, trigger: 'change', message: "请填写评估方案" }],
analysisReportName: [{ required: true, trigger: 'blur', message: "请填写报告名称" }],
execCycle: [
{
required: true,
message: "请设置执行周期",
trigger: "blur",
},
]
})
const dialogInfo = ref({
visible: false,
size: 700,
direction: "column",
header: {
title: "新建",
},
type: '',
contents: [
{
type: "form",
title: "",
formInfo: {
id: "word-edit-form",
items: formItems.value,
rules: formRules.value
},
}
],
footer: {
visible: true,
btns: [
{ type: "default", label: "取消", value: "cancel" },
{ type: "primary", label: "确定", value: "submit" },
],
},
});
const toSearch = (val: any, clear: boolean = false) => {
if (clear) {
page.value.analysisReportName = '';
} else {
page.value.analysisReportName = val.analysisReportName;
}
page.value.curr = 1;
getTableData();
};
const getTableData = () => {
tableInfo.value.loading = true;
getQualityWordList({ pageIndex: page.value.curr, pageSize: page.value.limit, analysisReportName: page.value.analysisReportName }).then((res: any) => {
tableInfo.value.loading = false;
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 {
ElMessage.error(res.msg);
}
})
};
const tableSelectionChange = (val) => {
selectRowData.value = val.map((item) => item.guid);
};
const tablePageChange = (info) => {
page.value.curr = Number(info.curr);
page.value.limit = Number(info.limit);
getTableData();
};
const tableBtnClick = (scope, btn) => {
const type = btn.value;
const row = scope.row;
currTableData.value = row;
if (type == "edit") {
dialogInfo.value.header.title = "编辑分析报告";
dialogInfo.value.type = type
dialogInfo.value.visible = true;
setFormItems(row);
formItems.value[0].disabled = true;
formItems.value[0].options = [{
guid: row.planGuid,
planName: row.planName
}]
} else if (type === 'reportView') {
router.push({
name: 'analysisReport',
query: {
planGuid: row.planGuid,
reportExecGuid: row.reportExecGuid,
name: row.analysisReportName,
}
});
} else if (type == 'path_log') {
router.push({
name: 'analysisLog',
query: {
guid: row.guid,
name: row.analysisReportName
}
});
} else if (type == "execute") {
row.isExecute = true
const guid = row.guid
executeReport(guid).then((res: any) => {
if (res.code == proxy.$passCode) {
getTableData();
ElMessage({
type: "success",
message: "手动执行提交成功",
});
} else {
ElMessage({
type: "error",
message: res.msg,
});
}
row.isExecute = false
}).catch(() => {
row.isExecute = false
})
} else if (type == 'delete') {
open("此操作将永久删除该分析报告,是否继续?", "warning");
} else if(type=='state') {
}
};
const tableSwitchBeforeChange = (scope, field, callback) => {
const row = scope.row
const msg = `确定【${scope.row[field] == 1 ? '下线' : '上线'}】该方案吗?`;
ElMessageBox.confirm(
msg,
'提示',
{
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
}
).then(() => {
const guid = row.guid
const state1 = row.state
stateChange({guid,state:state1===1?0:1}).then((res:any)=>{
if(res.code===proxy.$passCode){
ElMessage.success(`${scope.row[field] == 1 ? '下线' : '上线'}成功`)
getTableData();
} else {
ElMessage.error(res.msg)
}
})
}).catch(() => {
callback(false)
})
}
const open = (msg, type, isBatch = false) => {
ElMessageBox.confirm(msg, "提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: type,
}).then(() => {
let guids = [currTableData.value.guid]
if (isBatch) {
guids = selectRowData.value
}
deleteQualityWord(guids).then((res: any) => {
if (res.code == proxy.$passCode) {
getTableData();
ElMessage({
type: "success",
message: "删除成功",
});
} else {
ElMessage({
type: "error",
message: res.msg,
});
}
});
});
};
/** 打开新建报告的编辑框 */
const handleCreateNewWord = () => {
if (getAllPlanListPromise.value) {
getAllPlanListPromise.value.then(() => {
setFormItems(null);
formItems.value[0].disabled = false;
formItems.value[0].options = planList.value;
dialogInfo.value.header.title = '新建分析报告'
dialogInfo.value.type = 'add'
dialogInfo.value.footer.visible = true
dialogInfo.value.visible = true
});
} else {
setFormItems(null);
formItems.value[0].disabled = false;
formItems.value[0].options = planList.value;
dialogInfo.value.header.title = '新建分析报告'
dialogInfo.value.type = 'add'
dialogInfo.value.footer.visible = true
dialogInfo.value.visible = true
}
};
const batching = (type) => {
if (type == 'delete') {
if (selectRowData.value.length == 0) {
ElMessage({
type: 'error',
message: '请选择需要删除的报告',
})
return
}
open("此操作将永久删除,是否继续?", "warning", true);
}
};
const dialogBtnClick = (btn, info) => {
if (btn.value == 'submit') {
if (!info.reserveCycle && info.reserveCycle !== 0) {
info.reserveCycle = null;
}
if (dialogInfo.value.type == 'add') {
addQualityWord(info).then((res: any) => {
if (res.code == proxy.$passCode) {
page.value.curr = 1;
getTableData();
ElMessage({
type: 'success',
message: '添加质量分析报告成功'
})
dialogInfo.value.visible = false;
} else {
ElMessage({
type: 'error',
message: res.msg,
})
}
})
} else {
const params = { ...info };
params.guid = currTableData.value.guid;
updateQualityWord(params).then((res: any) => {
if (res.code == proxy.$passCode) {
toSearch({analysisReportName:page.value.analysisReportName});
ElMessage({
type: 'success',
message: '修改成功'
})
dialogInfo.value.visible = false;
} else {
ElMessage({
type: 'error',
message: res.msg,
})
}
})
}
} else if (btn.value == 'cancel') {
dialogInfo.value.visible = false;
} else if (btn.value = 'cron') {
let vInfo = wordDialogRef.value.dialogFormRef[0].formInline;
if (!vInfo.execCycle) {
return;
}
getCronExecTime(vInfo.execCycle).then((res: any) => {
if (res?.length) {
vInfo.zxzq = res.join('\n');
setFormItems(vInfo);
} else {
ElMessage({
type: 'error',
message: res.msg,
})
}
})
}
};
const dialogSelectChange = (val, row, info) => {
if (row.field == 'planGuid') {
formItems.value[0].default = val;
formItems.value[1].default = planList.value.find(p => p.guid == val)?.planName || "";
}
}
const scheduleChange = (val, rowValue) => {
setFormItems(rowValue);
// formItems.value[3].default = val
}
const setFormItems = (row) => {
formItems.value.map(item => {
if (item.field == 'reserveCycle') {
item.default = row ? row[item.field] : 365;
} else {
item.default = row ? row[item.field] : ''
}
})
}
onBeforeMount(() => {
})
</script>
<template>
<div class="container_wrap">
<div class="table_tool_wrap has_search">
<TableTools :searchItems="searchItemList" searchId="word-search" @search="toSearch" />
<div class="tools_btns">
<el-button type="primary" @click="handleCreateNewWord">新建分析报告</el-button>
<!-- <el-button @click="batching('delete')" v-preReClick>批量删除</el-button> -->
</div>
</div>
<div class="table_panel_wrap">
<Table :tableInfo="tableInfo" @tableBtnClick="tableBtnClick" @tableSelectionChange="tableSelectionChange"
@tablePageChange="tablePageChange" @tableSwitchBeforeChange="tableSwitchBeforeChange" />
</div>
<Dialog ref="wordDialogRef" :dialogInfo="dialogInfo" @btnClick="dialogBtnClick" @selectChange="dialogSelectChange"
@scheduleChange="scheduleChange" />
</div>
</template>
<style lang="scss" scoped>
.table_tool_wrap {
width: 100%;
height: 84px !important;
padding: 0 8px;
.tools_btns {
padding: 8px 0 0;
}
}
.table_panel_wrap {
width: 100%;
height: calc(100% - 84px);
padding: 8px 8px 0;
}
</style>