b098398c by lihua

添加新的计算定价页面

1 parent c7a693dd
...@@ -121,6 +121,36 @@ const routes: RouteRecordRaw[] = [ ...@@ -121,6 +121,36 @@ const routes: RouteRecordRaw[] = [
121 } 121 }
122 } 122 }
123 }, 123 },
124 {
125 path: 'price-calculate-new',
126 name: 'priceCalculateNew',
127 component: () => import('@/views/data_pricing/priceCalculateNew.vue'),
128 meta: {
129 title: '数据定价(新)',
130 breadcrumb: false,
131 cache: true
132 }
133 },
134 {
135 path: 'calculate-config-new',
136 name: 'calculateConfigNew',
137 component: () => import('@/views/data_pricing/calculateConfigNew.vue'),
138 meta: {
139 title: '新增数据定价',
140 sidebar: false,
141 breadcrumb: false,
142 cache: true,
143 editPage: true,
144 activeMenu: '/data-pricing/pricing-manage/price-calculate-new'
145 },
146 beforeEnter: (to, from) => {
147 if (to.query.guid) {
148 to.meta.title = `编辑-${to.query.name}`;
149 } else {
150 to.meta.title = `新增数据定价`;
151 }
152 }
153 },
124 ], 154 ],
125 }, 155 },
126 ] 156 ]
......
...@@ -313,7 +313,7 @@ const setDictFormItems = (dictList) => { ...@@ -313,7 +313,7 @@ const setDictFormItems = (dictList) => {
313 required: true, 313 required: true,
314 }); 314 });
315 baseConfigFormRules.value[dictField] = [{ required: true, trigger: 'change', message: `请选择${dictName}` }]; 315 baseConfigFormRules.value[dictField] = [{ required: true, trigger: 'change', message: `请选择${dictName}` }];
316 dictName == '数据用途' && (dataUsage.value.field = dictField); 316 d.dictionaryName == '数据用途' && (dataUsage.value.field = dictField);
317 (() => { 317 (() => {
318 if (typeMap.value[dictField] == undefined) { 318 if (typeMap.value[dictField] == undefined) {
319 getDataType(d.dictionaryName, dictField) 319 getDataType(d.dictionaryName, dictField)
......
1 <route lang="yaml">
2 name: calculateConfig
3 </route>
4 <script lang="ts" setup name="calculateConfig">
5 import { ref, onMounted } from "vue";
6 import { useRouter, useRoute } from "vue-router";
7 import { ElMessage, ElMessageBox } from "element-plus";
8 import useUserStore from "@/store/modules/user";
9 import useDataAssetStore from "@/store/modules/dataAsset";
10 import { getAllFlowData } from '@/api/modules/queryService';
11 import { download } from '@/utils/common'
12 import {
13 getConfigureList,
14 getConfigureDetail,
15 getDiseaseAll,
16 getPriceDetail,
17 getDemandList,
18 getModelScore,
19 savePrice,
20 getModelDemand,
21 getPriceResult,
22 exportModelScore,
23 calculatPrice
24 } from '@/api/modules/dataPricing';
25 import { changeNum } from "@/utils/common";
26 import { useValidator } from '@/hooks/useValidator';
27
28 const { required } = useValidator();
29 const { proxy } = getCurrentInstance() as any;
30 const router = useRouter();
31 const route = useRoute();
32 const userStore = useUserStore();
33 const assetStore = useDataAssetStore();
34 const fullPath = route.fullPath;
35 const userData = JSON.parse(localStorage.userData);
36 const guid = route.query.guid;
37 const priceName = route.query.name;
38 const loading = ref(false);
39 const flowDetail: any = ref({});
40 const typeMap: any = ref({});
41 const expandProduct = ref(true);
42 const expand1 = ref(true)
43 const expand3 = ref(true)
44 const demandTableList: any = ref([]);
45 const pricingTargetList: any = ref([]);
46 const demandTableFieldAllNum = ref(0);
47 const resourceTableAllNum = ref(0);
48 const resourceTableFieldAllNum = ref(0);
49 const modelData: any = ref({});
50 const pricingDimensionalityData: any = ref([]);
51 const dictionaryData: any = ref([]);
52 const diseaseData: any = ref([]);
53 const qualityScoreData: any = ref({});
54 const disScore: any = ref([]);
55 const buildInData: any = ref([]);
56 const dataUsage = ref({
57 field: '',
58 dictValue: ''
59 });
60 const currModelGuid = ref('');
61
62 const productConfigFormRef = ref();
63 /** 产品信息配置表单信息 */
64 const productConfigFormItems = ref([{
65 label: '企业名称',
66 type: 'input',
67 placeholder: '请输入',
68 field: 'companyName',
69 default: '',
70 required: true,
71 maxlength: 100,
72 visible: true
73 }, {
74 label: '联系人',
75 type: 'input',
76 placeholder: '请输入',
77 field: 'contactPerson',
78 default: '',
79 required: true,
80 maxlength: 50,
81 visible: true
82 }, {
83 label: '联系方式',
84 type: 'input',
85 placeholder: '请输入',
86 field: 'contactInformation',
87 default: '',
88 required: true,
89 maxlength: 50,
90 visible: true
91 }, {
92 label: '数据产品名称',
93 type: 'input',
94 placeholder: '请输入',
95 field: 'damName',
96 default: '',
97 required: true,
98 maxlength: 50,
99 visible: true
100 }, {
101 label: '产品简介',
102 placeholder: '该输入',
103 field: 'productDesc',
104 type: 'textarea',
105 default: '',
106 maxlength: 250,
107 block: true,
108 clearable: true,
109 required: true,
110 }]);
111
112 const productConfigFormRules = ref({
113 companyName: [required('请填写企业名称')],
114 contactPerson: [required('请填写联系人')],
115 contactInformation: [required('请填写联系方式')],
116 damName: [required('请填写产品名称')],
117 productDesc: [required('请填写产品简介')],
118 });
119
120 // 基础设置
121 const baseConfigFormRef = ref();
122 const baseConfigFormItems: any = ref([
123 {
124 label: '模型名称',
125 type: 'select',
126 placeholder: '请选择',
127 field: 'modelGuid',
128 default: '',
129 options: [],
130 props: {
131 label: "modelName",
132 value: "guid",
133 },
134 clearable: true,
135 filterable: true,
136 required: true
137 },
138 {
139 label: '数据资源名称',
140 type: 'input',
141 placeholder: '请输入',
142 field: 'dataResourceGuid',
143 maxlength: 50,
144 default: '',
145 clearable: true,
146 required: true
147 },
148 // {
149 // label: '数据资源',
150 // type: 'select',
151 // placeholder: '请选择',
152 // field: 'dataResourceGuid',
153 // default: '',
154 // options: [],
155 // props: {
156 // label: "damName",
157 // value: "guid",
158 // },
159 // clearable: true,
160 // filterable: true,
161 // required: true,
162 // },
163 // {
164 // label: '所属主体',
165 // type: 'input',
166 // placeholder: '',
167 // field: 'belongingEntityGuid',
168 // default: '',
169 // clearable: true,
170 // disabled: true
171 // },
172 // {
173 // label: '所属主题',
174 // type: 'tree-select',
175 // placeholder: '请选择',
176 // field: 'belongingTheme',
177 // default: '',
178 // options: [],
179 // showAllLevels: false,
180 // checkStrictly: false,//只能选择叶子节点。
181 // lazy: false,
182 // props: {
183 // label: "label",
184 // value: "value",
185 // children: 'childDictList'
186 // },
187 // filterable: true,
188 // clearable: true,
189 // disabled: true
190 // },
191 ])
192 const baseConfigFormRules: any = ref({
193 modelGuid: [
194 { required: true, trigger: 'change', message: "请选择模型名称" }
195 ],
196 dataResourceGuid: [
197 { required: true, trigger: 'blur', message: "请填写数据资源" }
198 ],
199 });
200 const baseConfigForm = ref({
201 items: baseConfigFormItems.value,
202 rules: baseConfigFormRules.value,
203 })
204 const tableFields: any = ref([
205 { label: '需求表', field: 'demandTableName', type: 'input', width: 200, disabled: true },
206 { label: '数据资源表', field: 'dataTableGuid', type: 'select', width: 200 },
207 { label: '表描述', field: 'tableDescription', type: 'input', width: 200, disabled: true },
208 { label: '需求表权重(%)', field: 'weightDemandTable', type: 'input', width: 140, disabled: true },
209 ])
210 const expendTableRef = ref();
211 const tableData: any = ref([]);
212 const tableLoading = ref(false);
213 const dataTransactionPrice: any = ref('');
214 const setFormItems = (info = null) => {
215 let datas: any = info || flowDetail.value || {};
216 const dictData = datas.dictionaryJson ? JSON.parse(datas.dictionaryJson) : {};
217 const builtIndicators = datas.builtIndicators || buildInData.value || [];
218 let buildData = {};
219 builtIndicators.map(item => {
220 buildData[`build_${item.guid}`] = item.isInputParameter != 'Y' ? changeNum(item.targetValue, 2) : item.targetValue != '' && item.targetValue != null ? parseFloat(item.targetValue).toFixed(2) : '';
221 });
222 datas = { ...datas, ...dictData, ...buildData };
223 baseConfigFormItems.value.map(item => {
224 item.default = datas[item.field] || '';
225 item.label == '数据用途' && (dataUsage.value.dictValue = datas[item.field] || '');
226 })
227 nextTick(() => {
228 baseConfigFormRef.value.ruleFormRef?.clearValidate();
229 })
230 }
231 /**
232 * 传入多个promise对象,当全部结束时取消Loading
233 * @param promises 传入多个promise对象,当全部结束时取消Loading
234 */
235 const promiseList = (...promises: Promise<void>[]) => {
236 // loading方法全局封装成一个组件
237 !guid && (loading.value = true);
238 try {
239 Promise.all(promises).then(res => {
240 loading.value = false;
241 });
242 } catch (e) {
243 loading.value = false;
244 } finally {
245 !guid && (loading.value = false);
246 }
247 };
248 // 获取模型
249 const getModel = () => {
250 getConfigureList({ pageSize: -1, pageIndex: 1, bizState: 'Y' }).then((res: any) => {
251 if (res.code == proxy.$passCode) {
252 const data = res.data.records || [];
253 typeMap.value.modelGuid = JSON.parse(JSON.stringify(data));
254 let item = baseConfigFormItems.value.find(item => item.field == 'modelGuid');
255 item && (item.options = data);
256 }
257 })
258 }
259 // 获取所有疾病数据
260 const getDiseaseData = () => {
261 getDiseaseAll().then((res: any) => {
262 if (res.code == proxy.$passCode) {
263 const data = res.data || [];
264 typeMap.value.diseaseGuid = JSON.parse(JSON.stringify(data));
265 let item = baseConfigFormItems.value.find(item => item.field == 'diseaseGuid');
266 if (item) {
267 item.options = typeMap.value['diseaseGuid'];
268 if (guid) {
269 const diseaseData = typeMap.value.diseaseGuid.find(m => m.guid == flowDetail.value.diseaseGuid);
270 if (!diseaseData) {
271 item.options.unshift({
272 guid: flowDetail.value.diseaseGuid,
273 diseaseName: flowDetail.value.diseaseName
274 });
275 }
276 }
277 }
278 }
279 })
280 }
281 // 获取数据资源
282 // const getDataCatalog = () => {
283 // return getDamCatalogList({ dataType: userData.superTubeFlag == 'Y' ? "P" : "D", sceneType: "D" }).then((res: any) => {
284 // if (res.code == proxy.$passCode) {
285 // let data = res.data || [];
286 // data.map(item => item.damGuid = item.guid);
287 // typeMap.value.dataResourceGuid = JSON.parse(JSON.stringify(data));
288 // let item = baseConfigFormItems.value.find(item => item.field == 'dataResourceGuid');
289 // if (item) {
290 // item.options = data;
291 // if (guid) {
292 // const rItem = typeMap.value.dataResourceGuid.find(m => m.damGuid == flowDetail.value.dataResourceGuid);
293 // if (!rItem) {
294 // const rtem = { damGuid: flowDetail.value.dataResourceGuid, damName: flowDetail.value.dataResourceName };
295 // item.options.unshift(rtem);
296 // typeMap.value.dataResourceGuid.unshift(rtem);
297 // }
298 // }
299 // }
300 // }
301 // })
302 // }
303 // 获取数据资源主题
304 const getSourceThem = (dictType, fieldName) => {
305 return getAllFlowData({ dictType }).then((res: any) => {
306 if (res.code == proxy.$passCode) {
307 const data = res.data || [];
308 typeMap.value[fieldName] = JSON.parse(JSON.stringify(data));
309 let item = baseConfigFormItems.value.find(item => item.field == fieldName);
310 item && (item.options = data);
311 } else {
312 proxy.$ElMessage.error(res.msg);
313 }
314 })
315 }
316 // 获取数据字典
317 const getDataType = (dictType, fieldName) => {
318 getAllFlowData({ dictType }).then((res: any) => {
319 if (res.code == proxy.$passCode) {
320 const data = res.data || [];
321 typeMap.value[fieldName] = JSON.parse(JSON.stringify(data));
322 let item = baseConfigFormItems.value.find(item => item.field == fieldName);
323 item && (item.options = data);
324 } else {
325 proxy.$ElMessage.error(res.msg);
326 }
327 })
328 }
329 // 获取详情
330 const getDetail = () => {
331 loading.value = true;
332 getPriceDetail({ guid }).then((res: any) => {
333 if (res.code == proxy.$passCode) {
334 const data = res.data || {};
335 flowDetail.value = data;
336 dataTransactionPrice.value = flowDetail.value.dataTransactionPrice;
337 dataUsage.value.dictValue = data.dataUsage || '';
338 currModelGuid.value = flowDetail.value.modelGuid;
339 const mItem = typeMap.value.modelGuid.find(m => m.guid == flowDetail.value.modelGuid);
340 if (!mItem) {
341 const mtem = { guid: flowDetail.value.modelGuid, modelName: flowDetail.value.modelName };
342 typeMap.value.modelGuid.unshift(mtem);
343 baseConfigFormItems.value[0].options.unshift(mtem);
344 };
345 productConfigFormItems.value.forEach(item => {
346 item.default = flowDetail.value[item.field] || '';
347 })
348 getModelInfo(flowDetail.value.modelGuid);
349 // getDataTypeList()
350 }
351 }).catch(() => {
352 loading.value = false;
353 })
354 }
355 // const getDataTypeList = () => {
356 // if (guid) {
357 // promiseList(
358 // // getDataCatalog(),
359 // // getSourceThem('数据资产目录主题名称', 'belongingTheme'),
360 // getQuilityModelScore(flowDetail.value.dataResourceGuid)
361 // )
362 // }
363 // }
364
365 // 设置数据字典选项
366 const setDictFormItems = (dictList) => {
367 dictList.map(d => {
368 const dictName = d.targetName;
369 const dictField = `dict_${d.guid}`;
370 baseConfigFormItems.value.push({
371 label: dictName,
372 type: 'select',
373 placeholder: '请选择',
374 field: dictField,
375 default: '',
376 options: [],
377 clearable: true,
378 filterable: true,
379 required: true,
380 });
381 baseConfigFormRules.value[dictField] = [{ required: true, trigger: 'change', message: `请选择${dictName}` }];
382 d.dictionaryName == '数据用途' && (dataUsage.value.field = dictField);
383 (() => {
384 if (typeMap.value[dictField] == undefined) {
385 getDataType(d.dictionaryName, dictField)
386 } else {
387 let item = baseConfigFormItems.value.find(item => item.field == dictField);
388 item && (item.options = typeMap.value[dictField]);
389 }
390 })()
391 })
392 }
393
394 // 设置疾病选项
395 const setDiseaseFormItems = () => {
396 baseConfigFormItems.value.push({
397 label: '所属疾病',
398 type: 'cascader',
399 placeholder: '请选择',
400 field: 'diseaseGuid',
401 default: '',
402 options: [],
403 showAllLevels: false,
404 props: {
405 checkStrictly: true,
406 label: "diseaseName",
407 value: "guid",
408 children: 'childList',
409 emitPath: false
410 },
411 filterable: true,
412 clearable: true,
413 required: true,
414 });
415 baseConfigFormRules.value.diseaseGuid = [{ required: true, trigger: 'change', message: "请选择所属疾病" }];
416 if (typeMap.value['diseaseGuid'] == undefined) {
417 getDiseaseData();
418 } else {
419 let item = baseConfigFormItems.value.find(item => item.field == 'diseaseGuid');
420 if (item) {
421 item.options = typeMap.value['diseaseGuid'];
422 const diseaseData = typeMap.value.diseaseGuid.find(m => m.guid == flowDetail.value.diseaseGuid);
423 if (!diseaseData) {
424 item.options.unshift({
425 guid: flowDetail.value.diseaseGuid,
426 diseaseName: flowDetail.value.diseaseName
427 });
428 }
429 }
430 }
431 }
432
433 // 设置内置指标选项
434 const setBuildInFormItems = (buildList) => {
435 buildList.map(b => {
436 const buildName = b.targetName;
437 const buildField = `build_${b.guid}`;
438 buildInData.value.push({
439 guid: b.guid,
440 targetName: buildName,
441 targetValue: b.defaultValue || '',
442 isInputParameter: b.isInputParameter,
443 })
444 baseConfigFormItems.value.push({
445 label: buildName,
446 type: 'input',
447 placeholder: '',
448 field: buildField,
449 default: b.isInputParameter != 'Y' ? changeNum(b.defaultValue, 2) : b.defaultValue != '' && b.defaultValue != null ? parseFloat(b.defaultValue).toFixed(2) : '',
450 inputType: 'moneyNumber',
451 maxlength: 18,
452 clearable: true,
453 disabled: b.isInputParameter != 'Y',
454 required: true
455 });
456 baseConfigFormRules.value[buildField] = [
457 { required: true, message: `请填写${buildName}`, trigger: 'blur' },
458 {
459 validator: (rule, value, callback) => {
460 if (value === '') {
461 callback(new Error(`请填写${buildName}`));
462 return;
463 }
464 const num = parseFloat(value);
465 if (isNaN(num)) {
466 callback(new Error('请输入有效的数字'));
467 return;
468 }
469
470 // 已自动保留两位小数,不需再验证小数位数
471 if (num < 0 || num > b.defaultValue) {
472 callback(new Error(`输入值必须在0到${b.defaultValue}之间`));
473 } else {
474 callback();
475 }
476 }, trigger: "blur",
477 },
478 ]
479 })
480 };
481
482 // 添加表单选项数据
483 const setFormItemData = async () => {
484 let dictionaryList: any = [], diseaseList: any = [], buildInList: any = [];
485 pricingTargetList.value.map(item => {
486 switch (item.targetType) {
487 case '2':
488 item.functionName == '2' && diseaseList.push(item);
489 break;
490 case '3':
491 dictionaryList.push(item);
492 break;
493 case '1':
494 buildInList.push(item);
495 break;
496 default:
497 break;
498 }
499 })
500 dictionaryData.value = dictionaryList;
501 diseaseData.value = diseaseList;
502 if (diseaseList.length) {
503 const diseaseName = flowDetail.value.diseaseName || '';
504 const modelGuid = flowDetail.value.modelGuid || '';
505 // 获取疾病得分
506 if (diseaseName && modelGuid) {
507 getTargetNum({ diseaseName, guid: modelGuid });
508 }
509 }
510 baseConfigFormItems.value.splice(4);
511 for (var r in baseConfigFormRules.value) {
512 if (r != 'modelGuid' && r != 'dataResourceGuid') {
513 delete baseConfigFormRules.value[r];
514 }
515 }
516 // 添加所属疾病
517 diseaseList.length > 0 && await setDiseaseFormItems();
518 // 添加数据字典
519 dictionaryList.length > 0 && await setDictFormItems(dictionaryList);
520 // 添加内置指标
521 buildInList.length > 0 && await setBuildInFormItems(buildInList);
522
523 setTimeout(() => {
524 baseConfigFormRef.value.ruleFormRef?.clearValidate();
525 }, 100)
526 }
527
528 const setdemandTableData = (mGuid = '') => {
529 const tList = flowDetail.value.dataPricingDemandmatchingRQVOS || demandTableList.value || [];
530 let tDatas: any = [];
531 if (guid) {
532 if (mGuid) {
533 tDatas = mGuid == flowDetail.value.modelGuid ? tList : demandTableList.value || [];
534 } else {
535 tDatas = tList;
536 }
537 } else {
538 tDatas = tList;
539 }
540 setTableData(JSON.parse(JSON.stringify(tDatas)))
541 }
542
543 const setTableData = (dataArr) => {
544 tableData.value.splice(0);
545 dataArr.map((item, i) => {
546 const demInfo = pricingTargetList.value.find(t => t.demandTableGuid == (item.demandTableGuid || item.guid));
547 const demWeight = demInfo?.weight || '';
548 tableData.value.push({
549 ...item,
550 demandTableName: item.demandTableName || item.menuName,
551 dataTableGuid: item.dataTableGuid || '',
552 tableDescription: item.tableDescription || '',
553 weightDemandTable: item.weightDemandTable ? parseFloat(item.weightDemandTable).toFixed(2) : (demWeight ? parseFloat(demWeight).toFixed(2) : ''),
554 dataFields: item.pricingDemandFieldRQVOS || [],
555 dataFieldsNum: item.dataFieldsNum || 0,
556 })
557 if ((item.demandTableGuid || item.guid)) {
558 const rGuid = item.demandTableGuid || item.guid;
559 const rIndex = i;
560 (() => {
561 getDemandField(rGuid, rIndex);
562 })()
563 }
564 })
565 resourceTableFieldAllNum.value = tableData.value.reduce((accumulator, currentValue) => {
566 return accumulator + Number(currentValue.dataFieldsNum);
567 }, 0);
568 setTimeout(() => {
569 tableData.value.map(t => {
570 expendTableRef.value.toggleRowExpansion(t);
571 })
572 }, 200)
573 }
574 // 获取模型配置信息
575 const getModelConfig = (mGuid) => {
576 return getModelDemand({ guid: mGuid }).then((res: any) => {
577 if (res.code == proxy.$passCode) {
578 const data = res.data || [];
579 demandTableList.value = data.pricingDemandMenuRSVOS || [];
580 pricingTargetList.value = data.pricingTargetRSVOS || [];
581 demandTableFieldAllNum.value = data.fieldCount || 0;
582 buildInData.value = [];
583 }
584 })
585 }
586 // 获取模型详情
587 const getModelDetail = (mGuid) => {
588 return getConfigureDetail({ guid: mGuid }).then((res: any) => {
589 if (res.code == proxy.$passCode) {
590 const data = res.data || [];
591 modelData.value = data;
592 const pricingDimensionality = data.pricingDimensionalityRSVOS || [];
593 let tData: any = [];
594 pricingDimensionality.map(p => {
595 p.pricingTargetRSVOS.map(t => {
596 tData.push({ ...p, ...t })
597 })
598 })
599 pricingDimensionalityData.value = tData;
600 }
601 })
602 }
603 // 获取质量模型评分
604 const getQuilityModelScore = (sGuid) => {
605 return getModelScore({ damGuid: sGuid }).then((res: any) => {
606 if (res.code === proxy.$passCode) {
607 const data = res.data || {};
608 qualityScoreData.value = data;
609 } else {
610 proxy.$ElMessage.error(res.msg);
611 }
612 })
613 }
614 // 獲取模型相关信息
615 const getModelInfo = (mGuid) => {
616 const promises: any = [
617 getModelConfig(mGuid),
618 getModelDetail(mGuid)
619 ];
620 try {
621 loading.value = true;
622 Promise.all(promises).then(res => {
623 loading.value = false;
624 setFormItemData();
625 if (guid && mGuid == flowDetail.value.modelGuid) {
626 dataTransactionPrice.value = flowDetail.value.dataTransactionPrice;
627 setTimeout(() => {
628 // getResourceDetail(flowDetail.value.dataResourceGuid, false);
629 setFormItems();
630 setdemandTableData(mGuid);
631 }, 200);
632 } else {
633 setdemandTableData(mGuid);
634 }
635 });
636 } catch (e) {
637 loading.value = false;
638 }
639 }
640 // 获取数据资源管理信息
641 // const getResourceInfo = (sGuid) => {
642 // const promises: any = [/*getResourceDetail(sGuid),*/ getQuilityModelScore(sGuid)];
643 // try {
644 // loading.value = true;
645 // Promise.all(promises).then(res => {
646 // loading.value = false;
647 // });
648 // } catch (e) {
649 // loading.value = false;
650 // }
651 // }
652
653 // // 需求表字段匹配
654 // const matchTableFields = (rData, tData) => {
655 // rData.dataFields.map(t => {
656 // const match = tData.find(d => d.chName == t.fieldName);
657 // if (match) {
658 // t.chName = match.chName;
659 // t.enName = match.enName;
660 // }
661 // })
662 // rData.dataFieldsNum = rData.dataFields.filter(item => item.chName != '' && item.chName != null).length;
663 // resourceTableFieldAllNum.value = tableData.value.reduce((accumulator, currentValue) => {
664 // return accumulator + Number(currentValue.dataFieldsNum);
665 // }, 0);
666 // }
667
668 // const setRowData = (rowData, dGuid, detailDataTable) => {
669 // if (guid && dGuid == rowData.dataTableGuid) {
670 // const pricingDemandField = detailDataTable?.pricingDemandFieldRQVOS || [];
671 // rowData.dataFields.map(f => {
672 // f.chName = pricingDemandField.find(s => f.guid == s.guid)?.chName || ''
673 // })
674 // } else {
675 // rowData.dataFields.map(f => f.chName = '')
676 // }
677 // const damData = rowData.damDataTable.find(item => item.guid == dGuid);
678 // rowData.tableDescription = damData?.tableDescription || '';
679 // rowData.dataFieldsNum = rowData.dataFields.filter(item => item.chName != '' && item.chName != null).length;
680 // resourceTableFieldAllNum.value = tableData.value.reduce((accumulator, currentValue) => {
681 // return accumulator + Number(currentValue.dataFieldsNum);
682 // }, 0);
683 // resourceTableAllNum.value = tableData.value.filter(item => item.dataTableGuid != '' && item.dataTableGuid != null).length;
684 // }
685
686 // const setTableRowData = (dGuid, rIndex, setRow = true) => {
687 // let rowData = tableData.value[rIndex];
688 // const detailDataTable = (flowDetail.value.dataPricingDemandmatchingRQVOS || []).find(f => f.dataTableGuid == dGuid && f.demandTableGuid == rowData.demandTableGuid);
689 // setRow && setRowData(rowData, dGuid, detailDataTable);
690 // const currDataTableGuid = detailDataTable?.dataTableGuid || '';
691 // if (dGuid) {
692 // tableLoading.value = true;
693 // getRegisterCatalogTableDetail(dGuid).then((res: any) => {
694 // tableLoading.value = false;
695 // if (res.code == proxy.$passCode) {
696 // const data = res.data || {};
697 // const damTableField = data.damCatalogTableField || [];
698 // const damFieldOptions = damTableField.map(d => {
699 // return {
700 // ...d,
701 // label: d.chName || '',
702 // value: d.chName || ''
703 // }
704 // })
705 // rowData.dataFields.map(t => {
706 // t.damFieldTable = JSON.parse(JSON.stringify(damFieldOptions));
707 // })
708 // // 匹配
709 // if (!guid || (guid && (dGuid != currDataTableGuid || currModelGuid.value != flowDetail.value.modelGuid))) {
710 // matchTableFields(rowData, damTableField);
711 // }
712 // } else {
713 // proxy.$ElMessage.error(res.msg);
714 // }
715 // }).catch(() => {
716 // tableLoading.value = false;
717 // })
718 // }
719 // }
720
721 // const changeDatasource = () => {
722 // baseConfigFormItems.value.map(item => {
723 // if (item.field == 'belongingEntityGuid') {
724 // item.default = '';
725 // } else if (item.field == 'belongingTheme') {
726 // item.default = '';
727 // }
728 // })
729 // }
730
731 const cascaderChange = (val) => {
732 disScore.value = [];
733 if (val) {
734 const baseConfigFormObj = baseConfigFormRef.value;
735 const baseConfigFormInfo = baseConfigFormObj.formInline;
736 const parentsData = baseConfigFormObj.getCascaderCheckedData();
737 const diseaseName = parentsData[0]?.label || '';
738 const modelGuid = baseConfigFormInfo.modelGuid;
739 // 获取疾病得分
740 getTargetNum({ diseaseName, guid: modelGuid });
741 }
742 }
743 const selectChange = async (val, row, info) => {
744 dataTransactionPrice.value = '';
745 if (row.field == 'modelGuid') {
746 tableData.value = [];
747 demandTableFieldAllNum.value = 0;
748 resourceTableAllNum.value = 0;
749 resourceTableFieldAllNum.value = 0;
750 await setFormItems(info);
751 val && getModelInfo(val);
752 currModelGuid.value = val || '';
753 qualityScoreData.value = {};
754 baseConfigFormItems.value[1].default = '';
755 // changeDatasource();
756 }
757 // else if (row.field == 'dataResourceGuid') {
758 // await setFormItems(info);
759 // qualityScoreData.value = {};
760 // resourceTableAllNum.value = 0;
761 // resourceTableFieldAllNum.value = 0;
762 // if (val) {
763 // getResourceInfo(val);
764 // } else {
765 // changeDatasource();
766 // }
767 // }
768 else if (row.field == dataUsage.value.field) {
769 dataUsage.value.dictValue = val || '';
770 setFormItems(info);
771 }
772 // else if (row.field == 'dataTableGuid') {
773 // setTableRowData(val, info.$index)
774 // } else if (row.field == 'chName') {
775 // let tData = info.row;
776 // if (val) {
777 // const damData = tData.dataFields[row.index].damFieldTable.find(item => item.chName == val);
778 // tData.dataFields[row.index].enName = damData?.enName || '';
779 // } else {
780 // tData.dataFields[row.index].enName = '';
781 // }
782 // tData.dataFieldsNum = tData.dataFields.filter(item => item.chName != '' && item.chName != null).length;
783 // resourceTableFieldAllNum.value = tableData.value.reduce((accumulator, currentValue) => {
784 // return accumulator + Number(currentValue.dataFieldsNum);
785 // }, 0);
786 // }
787 else {
788 setFormItems(info);
789 }
790 }
791 // 获取需求表字段
792 const getDemandField = (rGuid, rIndex) => {
793 getDemandList({
794 pageSize: -1,
795 pageIndex: 1,
796 relationMenuGuid: rGuid,
797 bizState: 'Y'
798 }).then((res: any) => {
799 tableLoading.value = false;
800 if (res.code == proxy.$passCode) {
801 const data = res.data || {};
802 const fData = data.records || [];
803 const tFields = tableData.value[rIndex].dataFields;
804 const tData = fData.map(item => {
805 const iData = tFields.find(t => t.demandFieldGuid == item.guid) || {};
806 return {
807 ...item,
808 fieldName: item.fieldName,
809 isRequired: item.isRequired,
810 chName: item.chName || '',
811 enName: item.enName || '',
812 ...iData
813 }
814 });
815 tableData.value[rIndex].dataFields = tData;
816
817 } else {
818 proxy.$ElMessage.error(res.msg);
819 }
820 }).catch(() => {
821 tableLoading.value = false;
822 })
823 }
824 const toPath = () => {
825 userStore.setTabbar(userStore.tabbar.filter((tab: any) => tab.fullPath !== fullPath));
826 assetStore.set(true);
827 router.push({
828 name: 'priceCalculate',
829 })
830 }
831
832 // 获取疾病得分
833 const getTargetNum = (params) => {
834 // loading.value = true;
835 getPriceResult(params).then((res: any) => {
836 // loading.value = false;
837 if (res.code === proxy.$passCode) {
838 const data = res.data || [];
839 disScore.value = data;
840 } else {
841 proxy.$ElMessage.error(res.msg);
842 }
843 }).catch(() => {
844 // loading.value = false;
845 });
846 }
847
848 // 获取定价计算配置参数
849 const getCalculateParams = (baseConfigFormObj, baseConfigFormInfo) => {
850 let companyInfo = productConfigFormRef.value.formInline;
851 const modelName = typeMap.value.modelGuid.find(d => d.guid == baseConfigFormInfo.modelGuid)?.modelName || '';
852 // const dataResourceName = typeMap.value.dataResourceGuid.find(d => d.damGuid == baseConfigFormInfo.dataResourceGuid)?.damName || '';
853 const diseaseGuid = baseConfigFormInfo.diseaseGuid || '';
854 let params: any = {
855 tenantGuid: userData.tenantGuid,
856 dataTransactionPrice: dataTransactionPrice.value,
857 modelGuid: baseConfigFormInfo.modelGuid,
858 modelName,
859 dataResourceGuid: baseConfigFormInfo.dataResourceGuid,
860 dataResourceName: baseConfigFormInfo.dataResourceGuid,
861 belongingEntityGuid: companyInfo.companyName,
862 belongingTheme: baseConfigFormInfo.belongingTheme,
863 diseaseGuid,
864 diseaseName: '',
865 dataUsage: dataUsage.value.dictValue
866 };
867 Object.assign(params, companyInfo);
868 if (diseaseGuid) {
869 const parentsData = baseConfigFormObj.getCascaderCheckedData();
870 params.diseaseName = parentsData[0]?.label || '';
871 }
872 let dictionaryJson = {}, builtInTarget: any = [];
873 for (var b in baseConfigFormInfo) {
874 if (b.indexOf('dict_') > -1) {
875 dictionaryJson[b] = baseConfigFormInfo[b];
876 }
877 }
878 buildInData.value.map(item => {
879 let targetValue = baseConfigFormInfo[`build_${item.guid}`];
880 if (typeof targetValue === 'string') {
881 if (/^[+-]?\d{1,3}(,\d{3})*(\.\d{2})?$/.test(targetValue)) {
882 targetValue = parseFloat(targetValue.replace(/,/g, ''))
883 }
884 }
885 builtInTarget.push({
886 ...item,
887 targetValue
888 })
889 })
890 params.dictionaryJson = Object.keys(dictionaryJson).length ? JSON.stringify(dictionaryJson) : '';
891 params.builtIndicators = builtInTarget;
892 let demandMatchingData: any = [];
893 tableData.value.map(item => {
894 demandMatchingData.push({
895 demandTableName: item.demandTableName,
896 demandTableGuid: item.demandTableGuid || item.guid, // 需求表guid
897 dataTableGuid: item.dataTableGuid || '', // 数据资源表guid
898 weightDemandTable: item.weightDemandTable,
899 dataFieldsNum: item.dataFieldsNum,
900 pricingDemandFieldRQVOS: item.dataFields.map(d => {
901 return {
902 demandFieldGuid: d.demandFieldGuid || d.guid, // 资源表字段guid
903 fieldName: d.fieldName,
904 enName: d.enName,
905 chName: d.chName,
906 isRequired: d.isRequired,
907 orderNum: d.orderNum
908 }
909 })
910 })
911 });
912 params.dataPricingDemandmatchingRQVOS = demandMatchingData;
913 guid && (params.guid = guid);
914 return params;
915 }
916
917 // 获取定价计算结构
918 const getCalculatPrice = async (params) => {
919 try {
920 const res: any = await calculatPrice(params);
921 loading.value = false;
922 if (res.code === proxy.$passCode) {
923 const data = res.data || {};
924 return data; // 返回计算结果以便后续使用
925 } else {
926 proxy.$ElMessage.error(res.msg);
927 throw new Error(res.msg); // 抛出错误以便 catch 捕获
928 }
929 } catch (error) {
930 console.error('计算价格失败:', error);
931 loading.value = false;
932 throw error; // 重新抛出错误
933 }
934 };
935
936 // 计算结果和提交
937 const checkForm = (type) => {
938 const baseConfigFormObj = baseConfigFormRef.value;
939 const baseConfigFormEl = baseConfigFormObj.ruleFormRef;
940 const baseConfigFormInfo = baseConfigFormObj.formInline;
941 productConfigFormRef.value.ruleFormRef.validate((valid1, errorItem) => {
942 if (valid1) {
943 baseConfigFormEl.validate(async (valid, errorItem) => {
944 if (valid) {
945 const paramsInfo = getCalculateParams(baseConfigFormObj, baseConfigFormInfo);
946 loading.value = true;
947 // 先获取计算结果
948 const priceData = await getCalculatPrice(paramsInfo);
949 // 显示结果
950 dataTransactionPrice.value = priceData.transactionPrice.toFixed(2);
951 if (type == 'export') {
952 loading.value = true;
953 const exportOut = {
954 one: priceData.one,
955 two: priceData.two,
956 three: priceData.three,
957 }
958 exportModelScore(exportOut).then((res: any) => {
959 loading.value = false;
960 if (res && !res.msg) {
961 ElMessage({
962 type: "success",
963 message: '下载报告成功',
964 });
965 download(res, `数据定价报告.doc`, 'word');
966 } else {
967 res?.msg && ElMessage.error(res?.msg);
968 }
969 }).catch(() => {
970 loading.value = false;
971 ElMessage({
972 type: "error",
973 message: '下载报告请求失败',
974 });
975 })
976 } else if (type == 'submit') {
977 let params = {
978 ...paramsInfo,
979 dataTransactionPrice: dataTransactionPrice.value,
980 }
981 loading.value = true;
982 savePrice(params).then((res: any) => {
983 loading.value = false;
984 if (res.code == proxy.$passCode) {
985 ElMessage({
986 type: "success",
987 message: guid ? '编辑数据定价成功' : '新增数据定价成功',
988 });
989 toPath()
990 } else {
991 proxy.$ElMessage.error(res.msg);
992 }
993 }).catch(() => {
994 loading.value = false;
995 });
996 }
997 } else {
998 expand1.value = true;
999 var obj = Object.keys(errorItem);
1000 baseConfigFormEl.scrollToField(obj[0]);
1001 }
1002 })
1003 } else {
1004 expandProduct.value = true;
1005 var obj = Object.keys(errorItem);
1006 productConfigFormRef.value.scrollToField(obj[0]);
1007 baseConfigFormEl.validate((valid, errorItem1) => {
1008 if (!valid) {
1009 expand1.value = true;
1010 }
1011 })
1012 }
1013 })
1014 }
1015 const btnClick = async (btn, row: any = null) => {
1016 const type = btn.value;
1017 if (type == 'dim') {
1018 baseConfigFormItems.value.at(-1).default += btn.name;
1019 } else if (type == 'del-signatory') {
1020 open('确定要删除该条维度数据吗?', 'warning');
1021 } else if (type == 'expend') {
1022 expendTableRef.value.toggleRowExpansion(row);
1023 } else if (type == 'calculate' || type == 'submit') {
1024 if (type == 'submit') {
1025 const errorMsgText = document.querySelectorAll('.el-form-item__error');
1026 if (errorMsgText.length) {
1027 ElMessage.info('请修改错误提示项内容后,再操作');
1028 return
1029 }
1030 ElMessageBox.confirm(dataTransactionPrice.value === '' ? '是否直接计算价格并提交' : '请确认当前数据交易价格是否为最新计算结果', '提示', {
1031 confirmButtonText: '确定',
1032 cancelButtonText: '取消',
1033 type: 'warning',
1034 }).then(() => {
1035 checkForm(type);
1036 }).catch(() => {
1037 ElMessage.info('已取消提交操作');
1038 });
1039 } else {
1040 checkForm(type);
1041 }
1042 } else if (type == 'export') {
1043 ElMessageBox.confirm(dataTransactionPrice.value === '' ? '是否直接计算价格并下载' : '请确认当前数据交易价格是否为最新计算结果', '提示', {
1044 confirmButtonText: '确定',
1045 cancelButtonText: '取消',
1046 type: 'warning',
1047 }).then(() => {
1048 checkForm(type);
1049 }).catch(() => {
1050 ElMessage.info('已取消下载操作');
1051 });
1052 } else if (type == 'cancel') {
1053 ElMessageBox.confirm(
1054 "当前页面尚未保存,确定关闭吗?",
1055 "提示",
1056 {
1057 confirmButtonText: "确定",
1058 cancelButtonText: "取消",
1059 type: "warning",
1060 }
1061 ).then(() => {
1062 toPath()
1063 }).catch(() => {
1064 ElMessage({
1065 type: "info",
1066 message: "已取消",
1067 });
1068 });
1069 }
1070 }
1071 onActivated(() => {
1072 let tab: any = userStore.tabbar.find((tab: any) => tab.fullPath === router.currentRoute.value.fullPath);
1073 if (tab) {
1074 switch (route.query.type) {
1075 case 'create':
1076 tab.meta.title = `新增数据定价`;
1077 break;
1078 case 'edit':
1079 tab.meta.title = `编辑-${priceName}`;
1080 break;
1081 case 'detail':
1082 tab.meta.title = `详情-${priceName}`;
1083 break;
1084 }
1085 }
1086 getModel()
1087 })
1088 onBeforeMount(() => {
1089 if (guid) {
1090 getDetail();
1091 }
1092 // else {
1093 // getDataTypeList();
1094 // }
1095 })
1096 onMounted(() => {
1097 })
1098 </script>
1099 <template>
1100 <div class="container_wrap full" v-loading="loading">
1101 <div class="content_main panel">
1102 <ContentWrap id="contract-content-wrap" title="产品信息" expandSwicth style="margin-top: 15px"
1103 :isExpand="expandProduct" @expand="(v) => expandProduct = v">
1104 <Form ref="productConfigFormRef" formId="product-content-form" :itemList="productConfigFormItems"
1105 :rules="productConfigFormRules" col="col3" />
1106 </ContentWrap>
1107 <ContentWrap id="contract-content-wrap" title="输入参数" expandSwicth style="margin-top: 15px" :isExpand="expand1"
1108 @expand="(v) => expand1 = v">
1109 <Form ref="baseConfigFormRef" formId="contract-content-form" :itemList="baseConfigForm.items"
1110 :rules="baseConfigForm.rules" col="col3" @selectChange="selectChange" @cascaderChange="cascaderChange" />
1111 </ContentWrap>
1112 <!-- <ContentWrap id="contract-signatory-wrap" title="需求匹配" expandSwicth style="margin-top: 15px" :isExpand="expand2"
1113 @expand="(v) => expand2 = v">
1114 <div class="table_panel_wrap">
1115 <div class="table_tool">
1116 <div class="tool_title">
1117 <div class="title_desc">
1118 <span>需求表数量:</span>
1119 <span class="text-num">{{ demandTableList.length }}</span>
1120 <span>张,字段数:</span>
1121 <span class="text-num">{{ demandTableFieldAllNum }}</span>
1122 <span>匹配表数量:</span>
1123 <span class="text-num">{{ resourceTableAllNum }}</span>
1124 <span>张,字段数:</span>
1125 <span class="text-num">{{ resourceTableFieldAllNum }}</span>
1126 </div>
1127 </div>
1128 </div>
1129 <div class="table_panel" v-loading="tableLoading">
1130 <el-table ref="expendTableRef" border :data="tableData" row-key="demandTableName" tooltip-effect="light"
1131 style="height: 100%;">
1132 <el-table-column type="expand">
1133 <template #default="props">
1134 <div class="expand_panel">
1135 <div class="table_tool">
1136 <div class="tool_title">
1137 <div class="title_desc">
1138 <span>需求字段数:</span>
1139 <span class="text-num">{{ props.row.dataFields.length }}</span>
1140 <span>个,匹配字段数:</span>
1141 <span class="text-num">{{ props.row.dataFieldsNum }}</span>
1142 </div>
1143 </div>
1144 </div>
1145 <el-table :data="props.row.dataFields" border>
1146 <el-table-column label="序号" type="index" width="56" align="center" />
1147 <el-table-column label="需求字段中文" prop="fieldName" class-name="edit-col">
1148 <template #default="scope">
1149 <el-input v-model.trim="scope.row.fieldName" placeholder="请输入" disabled />
1150 </template>
1151 </el-table-column>
1152 <el-table-column label="匹配字段中文" prop="chName" class-name="edit-col">
1153 <template #default="scope">
1154 <el-select v-model="scope.row.chName" clearable filterable
1155 @change="val => selectChange(val, { field: 'chName', index: scope.$index }, props)">
1156 <el-option v-for="(opt, o) in scope.row.damFieldTable" :label="opt.label" :value="opt.value"
1157 :key="o" />
1158 </el-select>
1159 </template>
1160 </el-table-column>
1161 <el-table-column label="匹配字段英文" prop="enName" class-name="edit-col">
1162 <template #default="scope">
1163 <el-input v-model.trim="scope.row.enName" placeholder="请输入" disabled />
1164 </template>
1165 </el-table-column>
1166 <el-table-column label="是否必需字段" prop="isRequired" class-name="edit-col">
1167 <template #default="scope">
1168 <el-select v-model="scope.row.isRequired" disabled>
1169 <el-option label="是" value="Y" />
1170 <el-option label="否" value="N" />
1171 </el-select>
1172 </template>
1173 </el-table-column>
1174 </el-table>
1175 </div>
1176 </template>
1177 </el-table-column>
1178 <el-table-column label="序号" type="index" width="56" align="center" />
1179 <el-table-column v-for="item in tableFields" :key="item.field" :label="item.label" :prop="item.field"
1180 :width="item.width" :align="item.align" class-name="edit-col">
1181 <template #default="scope">
1182 <el-select v-if="item.type == 'select'" v-model="scope.row[item.field]" clearable filterable
1183 @change="val => selectChange(val, item, scope)">
1184 <el-option v-for="(opt, o) in scope.row.damDataTable" :label="opt.label" :value="opt.value"
1185 :key="o" />
1186 </el-select>
1187 <el-input v-else v-model.trim="scope.row[item.field]" :disabled="item.disabled" placeholder="请输入"
1188 clearable />
1189 </template>
1190 </el-table-column>
1191 </el-table>
1192 </div>
1193 </div>
1194 </ContentWrap> -->
1195 <ContentWrap id="contract-content-wrap" title="输出结果" expandSwicth style="margin-top: 15px" :isExpand="expand3"
1196 @expand="(v) => expand3 = v">
1197 <el-form class="result-form">
1198 <el-form-item class="flex-column" label="数据交易价格(元)">
1199 <el-input v-model="dataTransactionPrice" placeholder="" disabled style="display: none;" />
1200 <div class="result-price">{{ changeNum(dataTransactionPrice, 2) }}</div>
1201 </el-form-item>
1202 <el-form-item class="align-end" style="margin-bottom: 14px;">
1203 <el-button type="primary" @click="btnClick({ value: 'calculate' })">开始计算</el-button>
1204 <!-- <el-button @click="btnClick({ value: 'export' })">下载报告</el-button> -->
1205 <!-- <span style="margin-left: 8px">如需出具详细的定价报告,请联系后台管理员,谢谢!</span> -->
1206 </el-form-item>
1207 </el-form>
1208 </ContentWrap>
1209 </div>
1210 <div class="tool_btns">
1211 <div class="btns">
1212 <el-button @click="btnClick({ value: 'cancel' })">取消</el-button>
1213 <el-button type="primary" @click="btnClick({ value: 'submit' })">提交</el-button>
1214 </div>
1215 </div>
1216 </div>
1217 </template>
1218 <style scoped lang="scss">
1219 .container_wrap {
1220 overflow: hidden;
1221
1222 .content_main {
1223 height: calc(100% - 45px);
1224 overflow: hidden auto;
1225
1226 &.panel {
1227 padding: 0 16px 16px;
1228 }
1229
1230 :deep(.el-card) {
1231 &#contract-signatory-wrap {
1232 .card-body-content {
1233 padding: 8px 16px;
1234 }
1235 }
1236 }
1237
1238 .signatory-tags {
1239 margin-bottom: 11px;
1240 }
1241
1242 .table_panel_wrap {
1243 margin-bottom: 4px;
1244
1245 .table_tool {
1246 height: 36px;
1247 display: flex;
1248 justify-content: space-between;
1249 align-items: center;
1250
1251 .tool_title {
1252 width: 100%;
1253 display: flex;
1254 justify-content: start;
1255 }
1256
1257 .title_desc {
1258 overflow: hidden;
1259 white-space: nowrap;
1260 text-overflow: ellipsis;
1261
1262 .text-num {
1263 color: var(--el-color-primary);
1264 margin: 0 8px;
1265 }
1266 }
1267 }
1268
1269 .table_panel {
1270 margin-bottom: 4px;
1271 height: 392px;
1272
1273 :deep(.el-table) {
1274 .el-table__cell {
1275 &.edit-col {
1276 padding: 4px 0;
1277
1278 .cell {
1279 padding: 0 4px;
1280
1281 .el-cascader {
1282 width: 100%;
1283 height: 28px;
1284 }
1285
1286 .el-input {
1287 height: 28px;
1288 }
1289 }
1290 }
1291
1292 .expand-icon {
1293 color: #888;
1294 margin-right: 8px;
1295 vertical-align: text-bottom;
1296 cursor: pointer;
1297 }
1298 }
1299
1300 .el-input.is-disabled .el-input__wrapper {
1301 background-color: var(--el-disabled-bg-color);
1302 }
1303
1304 .el-select__wrapper.is-disabled {
1305 background-color: var(--el-disabled-bg-color);
1306 }
1307 }
1308
1309 .expand_panel {
1310 padding: 6px;
1311 margin: -6px 0;
1312 background: #fff;
1313 }
1314 }
1315 }
1316 }
1317
1318 .btn-block {
1319 width: 100%;
1320 margin: 16px 0 8px;
1321 }
1322
1323 .tool_btns {
1324 height: 44px;
1325 margin: 0 -8px;
1326 display: flex;
1327 justify-content: center;
1328 align-items: center;
1329 border-top: 1px solid #d9d9d9;
1330 }
1331 }
1332
1333 :deep(.el-form) {
1334 &.result-form {
1335 display: flex;
1336
1337 .el-form-item {
1338 &.flex-column {
1339 width: calc(33.33% - 6px);
1340 margin-right: 8px;
1341 display: flex;
1342 flex-direction: column;
1343 align-items: self-start;
1344
1345 .el-form-item__content {
1346 width: 100%;
1347 }
1348
1349 .result-price {
1350 width: 100%;
1351 height: 32px;
1352 line-height: 32px;
1353 padding: 1px 11px;
1354 border-radius: 4px;
1355 cursor: not-allowed;
1356 color: var(--el-disabled-text-color);
1357 background-color: var(--el-disabled-bg-color);
1358 box-shadow: 0 0 0 1px var(--el-disabled-border-color) inset;
1359 }
1360 }
1361
1362 &.align-end {
1363 align-self: flex-end;
1364 }
1365 }
1366 }
1367
1368 .el-select__wrapper.is-disabled {
1369 background-color: var(--el-disabled-bg-color);
1370 }
1371 }
1372 </style>
1 <route lang="yaml">
2 name: priceCalculate
3 </route>
4
5 <script lang="ts" setup name="priceCalculate">
6 import { ref } from 'vue';
7 import TableTools from '@/components/Tools/table_tools.vue';
8 import { TableColumnWidth, commonPageConfig } from '@/utils/enum';
9 import { ElMessage, ElMessageBox } from "element-plus";
10 import { CirclePlus } from "@element-plus/icons-vue";
11 import { useRouter, useRoute } from "vue-router";
12 import useUserStore from "@/store/modules/user";
13 import useDataAssetStore from "@/store/modules/dataAsset";
14 import { getAllFlowData } from '@/api/modules/queryService';
15 import { changeNum } from "@/utils/common";
16 import {
17 getDiseaseAll,
18 getPriceList,
19 deletePrice,
20 } from '@/api/modules/dataPricing';
21
22 const router = useRouter();
23 const userStore = useUserStore()
24 const assetStore = useDataAssetStore();
25 const userData = JSON.parse(userStore.userData)
26 const { proxy } = getCurrentInstance() as any;
27
28 const searchItemList = ref([
29 {
30 type: "input",
31 label: "",
32 field: "dataResourceName",
33 default: "",
34 placeholder: "数据资源名称",
35 clearable: true,
36 },
37 {
38 type: "cascader",
39 label: "",
40 field: "diseaseName",
41 placeholder: "疾病名称",
42 default: "",
43 options: [],
44 showAllLevels: false,
45 props: {
46 checkStrictly: true,
47 label: "diseaseName",
48 value: "guid",
49 children: 'childList',
50 emitPath: false
51 },
52 filterable: true,
53 clearable: true,
54 }
55 ]);
56
57 const typeMap: any = ref({});
58 const selectRowData: any = ref([])
59 const currTableData: any = ref({});
60 const page: any = ref({
61 ...commonPageConfig,
62 dataResourceName: '',
63 diseaseName: ''
64 });
65 const tableField: any = ref([
66 { label: "序号", type: "index", width: TableColumnWidth.INDEX, align: "center" },
67 { label: "定价模型名称", field: "modelName", width: 200 },
68 { label: "数据资源名称", field: "dataResourceName", width: 200 },
69 { label: "疾病名称", field: "diseaseName", width: 200 },
70 {
71 label: "交易价格(元)", field: "dataTransactionPrice", width: 120, align: 'right', getName: (scope) => {
72 return scope.row.dataTransactionPrice ? changeNum(parseFloat(scope.row.dataTransactionPrice), 2) : '-';
73 }
74 },
75 { label: "创建人", field: "createUserName", width: 120 },
76 { label: "创建时间", field: "createTime", width: TableColumnWidth.DATETIME },
77 ]);
78 const tableInfo = ref({
79 id: 'api-data-table',
80 rowKey: 'guid',
81 loading: false,
82 fields: tableField.value,
83 data: [],
84 page: {
85 type: "normal",
86 rows: 0,
87 ...page.value,
88 },
89 actionInfo: {
90 label: "操作",
91 type: "btn",
92 isMore: false,
93 width: 120,
94 btns: [
95 { label: "编辑", value: "edit" },
96 { label: "删除", value: "del" }
97 ]
98 }
99 });
100
101 const setTableField = () => {
102 tableField.value.splice(4, 0, {
103 label: "交易用途", field: "dataUsage", width: 120, getName: (scope) => {
104 return typeMap.value['dataUsage'].find((item) => item.value == scope.row['dataUsage'])?.label || '-';
105 }
106 });
107 tableInfo.value.fields = tableField.value;
108 }
109
110 // 获取所有疾病数据
111 const getDiseaseData = () => {
112 getDiseaseAll().then((res: any) => {
113 if (res.code == proxy.$passCode) {
114 const data = res.data || [];
115 searchItemList.value[1].options = data;
116 }
117 })
118 }
119
120 // 获取数据字典
121 const getDataType = (dictType, fieldName) => {
122 getAllFlowData({ dictType }).then((res: any) => {
123 if (res.code == proxy.$passCode) {
124 const data = res.data || [];
125 typeMap.value[fieldName] = JSON.parse(JSON.stringify(data));
126 setTableField()
127 } else {
128 proxy.$ElMessage.error(res.msg);
129 }
130 })
131 }
132
133 const toSearch = (val: any, clear: boolean = false) => {
134 page.value.curr = 1;
135 if (clear) {
136 searchItemList.value.map((item) => (item.default = ""));
137 page.value.dataResourceName = ''
138 page.value.diseaseName = '';
139 } else {
140 page.value.dataResourceName = val.dataResourceName || '';
141 page.value.diseaseName = val.diseaseName || '';
142 }
143 getTableData();
144 };
145
146 const getTableData = () => {
147 tableInfo.value.loading = true;
148 getPriceList({
149 pageSize: page.value.limit,
150 pageIndex: page.value.curr,
151 dataResourceName: page.value.dataResourceName,
152 diseaseName: page.value.diseaseName,
153 }).then((res: any) => {
154 tableInfo.value.loading = false;
155 if (res.code == proxy.$passCode) {
156 const data = res.data || {};
157 tableInfo.value.data = data.records || [];
158 tableInfo.value.page.limit = data.pageSize
159 tableInfo.value.page.curr = data.pageIndex
160 tableInfo.value.page.rows = data.totalRows
161 } else {
162 proxy.$ElMessage.error(res.msg);
163 }
164 })
165 }
166
167 const tablePageChange = (info) => {
168 page.value.curr = Number(info.curr);
169 page.value.limit = Number(info.limit);
170 tableInfo.value.page.limit = page.value.limit;
171 tableInfo.value.page.curr = page.value.curr;
172 getTableData();
173 };
174
175 const tableBtnClick = (scope, btn) => {
176 const type = btn.value;
177 const row = scope.row;
178 currTableData.value = row;
179 if (type === 'edit') { // 编辑
180 if (row.belongingTheme) {
181 router.push(
182 {
183 name: 'calculateConfig',
184 query: {
185 guid: row.guid,
186 name: row.modelName,
187 type: 'edit'
188 }
189 }
190 );
191 } else {
192 router.push(
193 {
194 name: 'calculateConfigNew',
195 query: {
196 guid: row.guid,
197 name: row.modelName,
198 type: 'edit'
199 }
200 }
201 );
202 }
203 } else if (type === 'del') { // 删除
204 open('确定要删除该条数据吗?', 'warning');
205 }
206 };
207
208 const open = (msg, type, isBatch = false) => {
209 ElMessageBox.confirm(msg, "提示", {
210 confirmButtonText: "确定",
211 cancelButtonText: "取消",
212 type: type,
213 }).then(() => {
214 let guids = [currTableData.value.guid]
215 if (isBatch) {
216 guids = selectRowData.value
217 }
218 deletePrice(guids).then((res: any) => {
219 if (res.code == proxy.$passCode) {
220 getTableData();
221 ElMessage({
222 type: "success",
223 message: "删除成功",
224 });
225 } else {
226 proxy.$ElMessage.error(res.msg);
227 }
228 });
229 });
230 };
231
232 const addDisease = () => {
233 router.push(
234 {
235 name: 'calculateConfigNew',
236 query: {
237 type: 'create'
238 }
239 }
240 );
241 }
242
243 onBeforeMount(() => {
244 getDiseaseData();
245 getDataType('数据用途', 'dataUsage')
246 });
247
248 onActivated(() => {
249 if (assetStore.isRefresh) {//如果是首次加载,则不需要调用
250 toSearch(null, true);
251 assetStore.set(false);
252 }
253 })
254
255 </script>
256
257 <template>
258 <div class="container_wrap">
259 <div class="table_tool_wrap">
260 <TableTools :searchItems="searchItemList" :searchId="'data-source-search'" @search="toSearch" />
261 <div class="tools_btns">
262 <el-button type="primary" @click="addDisease" v-preReClick>新增</el-button>
263 </div>
264 </div>
265 <div class="table_panel_wrap">
266 <Table :tableInfo="tableInfo" @tablePageChange="tablePageChange" @tableBtnClick="tableBtnClick" />
267 </div>
268 </div>
269 </template>
270
271 <style lang="scss" scoped>
272 .table_tool_wrap {
273 width: 100%;
274 height: 84px !important;
275 padding: 0 8px;
276
277 .tools_btns {
278 padding: 0px 0 0;
279 }
280 }
281
282 .table_panel_wrap {
283 width: 100%;
284 height: calc(100% - 84px);
285 padding: 0px 8px 0;
286 }
287 </style>
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!