dataUsage.vue
8.25 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
<script lang="ts" setup name="dataUsage">
import TableTools from "@/components/Tools/table_tools.vue";
import { commonPageConfig, TableColumnWidth } from '@/utils/enum';
import {
getDataUsePageList,
deleteDataUse,
distributeContract,
} from "@/api/modules/dataDelivery";
import { useValidator } from "@/hooks/useValidator";
const { required } = useValidator();
const router = useRouter();
const route = useRoute();
const { proxy } = getCurrentInstance() as any;
const searchItemList = ref([
{
type: "input",
label: "",
field: "dataProductName",
default: "",
placeholder: "数据产品名称",
maxlength: 50,
clearable: true,
},
{
type: "input",
label: "",
field: "contractName",
default: "",
placeholder: "合约名称",
maxlength: 50,
clearable: true,
},
]);
const page = ref({
...commonPageConfig,
dataProductName: '',
contractName: ''
});
const tableFields = ref([
{ label: "序号", type: "index", width: 56, align: "center" },
{
label: "数据产品名称", field: "dataProductName", width: 160, type: "text_btn", columClass: 'text_btn', value: "detail", disabled: (scope) => {
return scope.row.contractStatus == '06';
}, click: (scope) => {
if (scope.row.contractStatus == '06') {
return;
}
router.push({
name: 'usageCatalogDetail',
query: {
guid: scope.row.dataProductGuid,
type: 'detail',
foundMode: 'use',
name: scope.row.dataProductName,
}
});
}
},
{
label: "合约名称", field: "contractName", width: 170, type: "text_btn", columClass: 'text_btn', value: "detail1", disabled: (scope) => {
return scope.row.isDistribute == 'Y';
}, click: (scope) => {
let isDistribute = scope.row.isDistribute;
if (isDistribute == 'Y') {
return;
}
//履约中的合约状态
router.push({
name: 'smartContractDetail',
query: {
guid: scope.row.contractGuid,
name: scope.row.contractName,
type: 'keepAgree',
isDetail: 'Y'
}
});
}
},
{
label: "交付方式", field: "deliveryMethod", width: 120, getName: (scope) => {
return scope.row.deliveryMethod == 1 ? '文件' : 'API';
}
},
{ label: "交付方", field: "deliveryPartyName", width: 220 },
{ label: "交付时间", field: "deliveryTime", width: 170 },
{ label: "合约状态", field: "contractStatus", type: "tag", width: 96, align: 'center' },
]);
const currTableData: any = ref({});
const tableInfo = ref({
id: 'contract-table',
rowKey: 'guid',
loading: false,
fields: tableFields.value,
data: [], //{ verifySatus: 2 }, { verifySatus: 4 }, { verifySatus: 3, deliveryStatus: 2, }
page: {
type: "normal",
rows: 0,
...page.value,
},
actionInfo: {
label: "操作",
type: "btn",
width: 230,
btns: (scope) => {
let actions = scope.row.actions || {};
let arrBtns: any = [];
if (scope.row.contractStatus != '06') {
for (let action in actions) {
arrBtns.push({ label: actions[action], value: action, click: btnHanldesMap[action] });
}
}
arrBtns.push({ label: '日志', value: 'log', click: btnHanldesMap['log'] });
return arrBtns;
}
}
});
const btnHanldesMap = {
/** 查看产品详情 */
read: (scope) => {
router.push({
name: 'usageCatalogDetail',
query: {
guid: scope.row.dataProductGuid,
type: 'detail',
foundMode: 'read',
name: scope.row.dataProductName,
useGuid: scope.row.guid
}
});
},
download: (scope) => { //下载
router.push({
name: 'usageCatalogDetail',
query: {
guid: scope.row.dataProductGuid,
type: 'detail',
foundMode: 'download',
name: scope.row.dataProductName,
useGuid: scope.row.guid
}
});
},
distribute: (scope) => { //分发
currTableData.value = scope.row;
tenantDialogInfo.value.visible = true;
templateFormItems.value[0].options = currTableData.value.deliveryNodes || [];
let distributeNodes = currTableData.value.distributeNodes || [];
if (distributeNodes?.length) {
templateFormItems.value[0].options = currTableData.value.deliveryNodes?.map(d => {
d.disabled = distributeNodes.includes(d.guid) ? true : false;
return d;
})
}
templateFormItems.value[0].default = '';
},
delete: (scope) => {//删除
proxy.$openMessageBox('确定要删除该数据使用吗?', () => {
deleteDataUse([scope.row.guid]).then((res: any) => {
if (res.code == proxy.$passCode) {
page.value.curr = 1;
getTableData();
proxy.$ElMessage.success("删除成功");
} else {
proxy.$ElMessage.error(res.msg);
}
});
}, () => {
proxy.$ElMessage.info("已取消");
})
},
log: (scope) => { //日志
router.push({
name: 'dataUsageLog',
query: {
contractGuid: scope.row.contractGuid,
contractName: scope.row.contractName
}
});
}
}
const toSearch = (val: any, clear: boolean = false) => {
if (clear) {
searchItemList.value.map((item) => (item.default = ""));
page.value.dataProductName = '';
page.value.contractName = '';
} else {
page.value.dataProductName = val.dataProductName;
page.value.contractName = val.contractName;
}
getTableData();
};
const getTableData = () => {
tableInfo.value.loading = true
getDataUsePageList({
pageIndex: page.value.curr,
pageSize: page.value.limit,
dataProductName: page.value.dataProductName,
contractName: page.value.contractName
}).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 {
res?.msg && proxy.$ElMessage.error(res?.msg)
}
}).catch(() => {
tableInfo.value.loading = false
})
};
const tablePageChange = (info) => {
page.value.curr = Number(info.curr);
page.value.limit = Number(info.limit);
tableInfo.value.page.curr = page.value.curr;
tableInfo.value.page.limit = page.value.limit;
getTableData();
};
onBeforeMount(() => {
toSearch({});
});
const templateFormItems = ref([{
type: 'select',
label: '分发连接器',
field: 'tenantGuids',
default: '',
block: true,
placeholder: '请选择',
options: [],
props: {
value: 'guid',
label: 'tenantName',
disabled: 'disabled'
},
filterable: true,
multiple: true,
collapse: true,
tagsTooltip: true,
clearable: true,
required: true
}]);
const templateFormRules = ref({
tenantGuids: [{ required: true, trigger: 'change', message: "请选择分发连接器" }]
});
const tenantDialogInfo = ref({
visible: false,
size: 480,
title: "选择分发连接器",
type: 'edit',
formInfo: {
id: 'copy-form',
items: templateFormItems.value,
rules: templateFormRules.value
},
submitBtnLoading: false,
btns: {
submit: (btn, info) => {
tenantDialogInfo.value.submitBtnLoading = true;
distributeContract({
useGuid: currTableData.value.guid,
nodeGuid: info.tenantGuids
}).then((res: any) => {
tenantDialogInfo.value.submitBtnLoading = false;
if (res?.code == proxy.$passCode) {
tenantDialogInfo.value.visible = false;
proxy.$ElMessage.success('分发连接器提交成功');
} else {
res?.msg && proxy.$ElMessage.error(res?.msg)
}
})
},
cancel: () => {
tenantDialogInfo.value.visible = false;
}
}
});
</script>
<template>
<div class="container_wrap">
<div class="table_tool_wrap">
<TableTools :searchItems="searchItemList" :searchId="'contract-search'" @search="toSearch" :init="false" />
</div>
<div class="table_panel_wrap" style="height: calc(100% - 44px);">
<Table :tableInfo="tableInfo" @tablePageChange="tablePageChange" />
</div>
<!-- 选择分发企业的对话框 -->
<Dialog_form :dialogConfigInfo="tenantDialogInfo" />
</div>
</template>
<style lang="scss" scoped>
.container_wrap {
padding: 0px 16px;
}
</style>