数据定价对接计算接口
Showing
1 changed file
with
131 additions
and
89 deletions
| ... | @@ -908,94 +908,8 @@ const calculatePrice = (pData) => { | ... | @@ -908,94 +908,8 @@ const calculatePrice = (pData) => { |
| 908 | } | 908 | } |
| 909 | }; | 909 | }; |
| 910 | 910 | ||
| 911 | // 计算结果和提交 | 911 | // 获取定价计算配置参数 |
| 912 | const checkForm = (type) => { | 912 | const getCalculateParams = (baseConfigFormObj, baseConfigFormInfo) => { |
| 913 | const baseConfigFormObj = baseConfigFormRef.value; | ||
| 914 | const baseConfigFormEl = baseConfigFormObj.ruleFormRef; | ||
| 915 | const baseConfigFormInfo = baseConfigFormObj.formInline; | ||
| 916 | baseConfigFormEl.validate((valid, errorItem) => { | ||
| 917 | if (valid) { | ||
| 918 | if (type == 'calculate') { | ||
| 919 | const { signatoryData, resultInfo } = reporting(baseConfigFormInfo); | ||
| 920 | exportData.value = resultInfo; | ||
| 921 | calculatePrice(signatoryData); | ||
| 922 | } else if (type == 'export') { | ||
| 923 | const { signatoryData, resultInfo } = reporting(baseConfigFormInfo); | ||
| 924 | exportData.value = resultInfo; | ||
| 925 | !dataTransactionPrice.value && calculatePrice(signatoryData); | ||
| 926 | loading.value = true; | ||
| 927 | let exportOut: any = {}; | ||
| 928 | // 估值对象信息 | ||
| 929 | const damName = typeMap.value.dataResourceGuid.find(f => f.damGuid == baseConfigFormInfo.dataResourceGuid)?.damName || ''; | ||
| 930 | exportOut.one = `因${baseConfigFormInfo.belongingEntityGuid}拟了解其所持有的\"${damName}\"相关数据资源的价格,为此需对该行为涉及的数据资源在不同应用场景下,基于数据资源持有单位的性质、信息化程度、数据稀缺性、需求匹配等情况下,为上述经济行为提供定价参考依据。`; | ||
| 931 | exportOut.two = `估值对象:${baseConfigFormInfo.belongingEntityGuid}持有的\"${damName}\"`; | ||
| 932 | // 估值范围信息 | ||
| 933 | const damNames = demandTableList.value.map(item => item.menuName) | ||
| 934 | let rangStr = `包含${damNames.join('、')}等${damNames.length}张表单,${damNames.length}张表共计${demandTableFieldAllNum.value}个字段`; | ||
| 935 | const dataTimeliness = pricingTargetList.value.find(p => p.dictionaryName == '时效性'); | ||
| 936 | const dataTimelinessStr = dataTimeliness ? typeMap.value[`dict_${dataTimeliness.guid}`].find(f => f.value == baseConfigFormInfo[`dict_${dataTimeliness.guid}`])?.label || '' : ''; | ||
| 937 | rangStr += dataTimelinessStr ? `,时间跨度为${dataTimelinessStr}的数据` : `的数据`; | ||
| 938 | damNames.length && (exportOut.two = `${exportOut.two}\n估值范围:${rangStr}`); | ||
| 939 | // 字典 | ||
| 940 | let dictList: any = [], hasModelScore = false; | ||
| 941 | const dictStr = exportData.value.map(e => { | ||
| 942 | // 检查是否有质量模型评分 | ||
| 943 | hasModelScore = hasModelScore || e.pricingTargetRSVOS.some( | ||
| 944 | t => t.targetType === '2' && t.functionName === '1' | ||
| 945 | ); | ||
| 946 | |||
| 947 | // 只有当维度指标数大于1时才处理明细 | ||
| 948 | if (e.pricingTargetRSVOS.length > 1) { | ||
| 949 | const targetStr = e.pricingTargetRSVOS | ||
| 950 | .map(t => `${t.targetName}为${changeNum(t.tNum, 2)}`) | ||
| 951 | .join('、'); | ||
| 952 | |||
| 953 | dictList.push(`${e.dimensionalityName}为${changeNum(e.sNum, 2)},其中${targetStr}`); | ||
| 954 | } | ||
| 955 | |||
| 956 | return `${e.dimensionalityName}为${changeNum(e.sNum, 2)}`; | ||
| 957 | }) | ||
| 958 | let dictListStr = `${dictStr.join(',')}。\n${dictList.join(';\n')}` | ||
| 959 | // 质量模型 | ||
| 960 | if (hasModelScore) { | ||
| 961 | const { largeCategoryScoreList = [], qualityScore = 0 } = qualityScoreData.value; | ||
| 962 | const qualityParts = [ | ||
| 963 | `数据的总体质量得分为${changeNum(qualityScore, 2)}` | ||
| 964 | ]; | ||
| 965 | |||
| 966 | if (largeCategoryScoreList.length) { | ||
| 967 | const categoryScores = largeCategoryScoreList.map( | ||
| 968 | q => `${q.largeCategoryName}方面得分为${changeNum(q.largeCategoryScore || 0, 2)}` | ||
| 969 | ); | ||
| 970 | qualityParts.push(`其中${categoryScores.join(',')}`); | ||
| 971 | } | ||
| 972 | |||
| 973 | dictListStr += `;\n${qualityParts.join('。')}`; | ||
| 974 | } | ||
| 975 | exportOut.three = `${baseConfigFormInfo.belongingEntityGuid}持有的"${damName}"的数据(患者人次)单价为${changeNum(dataTransactionPrice.value, 2)}元${dictListStr ? `;其中${dictListStr}` : '。'}`; | ||
| 976 | |||
| 977 | exportModelScore(exportOut).then((res: any) => { | ||
| 978 | loading.value = false; | ||
| 979 | if (res && !res.msg) { | ||
| 980 | ElMessage({ | ||
| 981 | type: "success", | ||
| 982 | message: '下载报告成功', | ||
| 983 | }); | ||
| 984 | download(res, `数据定价报告.doc`, 'word'); | ||
| 985 | } else { | ||
| 986 | res?.msg && ElMessage.error(res?.msg); | ||
| 987 | } | ||
| 988 | }).catch(() => { | ||
| 989 | loading.value = false; | ||
| 990 | ElMessage({ | ||
| 991 | type: "error", | ||
| 992 | message: '下载报告请求失败', | ||
| 993 | }); | ||
| 994 | }) | ||
| 995 | } else { | ||
| 996 | const { signatoryData, resultInfo } = reporting(baseConfigFormInfo); | ||
| 997 | exportData.value = resultInfo; | ||
| 998 | !dataTransactionPrice.value && calculatePrice(signatoryData); | ||
| 999 | const modelName = typeMap.value.modelGuid.find(d => d.guid == baseConfigFormInfo.modelGuid)?.modelName || ''; | 913 | const modelName = typeMap.value.modelGuid.find(d => d.guid == baseConfigFormInfo.modelGuid)?.modelName || ''; |
| 1000 | const dataResourceName = typeMap.value.dataResourceGuid.find(d => d.damGuid == baseConfigFormInfo.dataResourceGuid)?.damName || ''; | 914 | const dataResourceName = typeMap.value.dataResourceGuid.find(d => d.damGuid == baseConfigFormInfo.dataResourceGuid)?.damName || ''; |
| 1001 | const diseaseGuid = baseConfigFormInfo.diseaseGuid || ''; | 915 | const diseaseGuid = baseConfigFormInfo.diseaseGuid || ''; |
| ... | @@ -1028,7 +942,7 @@ const checkForm = (type) => { | ... | @@ -1028,7 +942,7 @@ const checkForm = (type) => { |
| 1028 | demandMatchingData.push({ | 942 | demandMatchingData.push({ |
| 1029 | demandTableName: item.demandTableName, | 943 | demandTableName: item.demandTableName, |
| 1030 | demandTableGuid: item.demandTableGuid || item.guid, // 需求表guid | 944 | demandTableGuid: item.demandTableGuid || item.guid, // 需求表guid |
| 1031 | dataTableGuid: item.dataTableGuid, // 数据资源表guid | 945 | dataTableGuid: item.dataTableGuid || '', // 数据资源表guid |
| 1032 | weightDemandTable: item.weightDemandTable, | 946 | weightDemandTable: item.weightDemandTable, |
| 1033 | dataFieldsNum: item.dataFieldsNum, | 947 | dataFieldsNum: item.dataFieldsNum, |
| 1034 | pricingDemandFieldRQVOS: item.dataFields.map(d => { | 948 | pricingDemandFieldRQVOS: item.dataFields.map(d => { |
| ... | @@ -1045,6 +959,134 @@ const checkForm = (type) => { | ... | @@ -1045,6 +959,134 @@ const checkForm = (type) => { |
| 1045 | }); | 959 | }); |
| 1046 | params.dataPricingDemandmatchingRQVOS = demandMatchingData; | 960 | params.dataPricingDemandmatchingRQVOS = demandMatchingData; |
| 1047 | guid && (params.guid = guid); | 961 | guid && (params.guid = guid); |
| 962 | return params; | ||
| 963 | } | ||
| 964 | |||
| 965 | // 获取定价计算结构 | ||
| 966 | const getCalculatPrice = async (params) => { | ||
| 967 | try { | ||
| 968 | const res: any = await calculatPrice(params); | ||
| 969 | loading.value = false; | ||
| 970 | if (res.code === proxy.$passCode) { | ||
| 971 | const data = res.data || {}; | ||
| 972 | console.log('getCalculatPrice', data); | ||
| 973 | return data; // 返回计算结果以便后续使用 | ||
| 974 | } else { | ||
| 975 | proxy.$ElMessage.error(res.msg); | ||
| 976 | throw new Error(res.msg); // 抛出错误以便 catch 捕获 | ||
| 977 | } | ||
| 978 | } catch (error) { | ||
| 979 | console.error('计算价格失败:', error); | ||
| 980 | loading.value = false; | ||
| 981 | throw error; // 重新抛出错误 | ||
| 982 | } | ||
| 983 | }; | ||
| 984 | |||
| 985 | // 计算结果和提交 | ||
| 986 | const checkForm = (type) => { | ||
| 987 | const baseConfigFormObj = baseConfigFormRef.value; | ||
| 988 | const baseConfigFormEl = baseConfigFormObj.ruleFormRef; | ||
| 989 | const baseConfigFormInfo = baseConfigFormObj.formInline; | ||
| 990 | baseConfigFormEl.validate(async (valid, errorItem) => { | ||
| 991 | if (valid) { | ||
| 992 | const paramsInfo = getCalculateParams(baseConfigFormObj, baseConfigFormInfo); | ||
| 993 | loading.value = true; | ||
| 994 | // 先获取计算结果 | ||
| 995 | const priceData = await getCalculatPrice(paramsInfo); | ||
| 996 | // 显示结果 | ||
| 997 | dataTransactionPrice.value = priceData.transactionPrice.toFixed(2); | ||
| 998 | |||
| 999 | if (type == 'calculate') { | ||
| 1000 | // const { signatoryData, resultInfo } = reporting(baseConfigFormInfo); | ||
| 1001 | // exportData.value = resultInfo; | ||
| 1002 | // calculatePrice(signatoryData); | ||
| 1003 | } else if (type == 'export') { | ||
| 1004 | // const { signatoryData, resultInfo } = reporting(baseConfigFormInfo); | ||
| 1005 | // exportData.value = resultInfo; | ||
| 1006 | // !dataTransactionPrice.value && calculatePrice(signatoryData); | ||
| 1007 | // loading.value = true; | ||
| 1008 | // let exportOut: any = {}; | ||
| 1009 | // // 估值对象信息 | ||
| 1010 | // const damName = typeMap.value.dataResourceGuid.find(f => f.damGuid == baseConfigFormInfo.dataResourceGuid)?.damName || ''; | ||
| 1011 | // exportOut.one = `因${baseConfigFormInfo.belongingEntityGuid}拟了解其所持有的\"${damName}\"相关数据资源的价格,为此需对该行为涉及的数据资源在不同应用场景下,基于数据资源持有单位的性质、信息化程度、数据稀缺性、需求匹配等情况下,为上述经济行为提供定价参考依据。`; | ||
| 1012 | // exportOut.two = `估值对象:${baseConfigFormInfo.belongingEntityGuid}持有的\"${damName}\"`; | ||
| 1013 | // // 估值范围信息 | ||
| 1014 | // const damNames = demandTableList.value.map(item => item.menuName) | ||
| 1015 | // let rangStr = `包含${damNames.join('、')}等${damNames.length}张表单,${damNames.length}张表共计${demandTableFieldAllNum.value}个字段`; | ||
| 1016 | // const dataTimeliness = pricingTargetList.value.find(p => p.dictionaryName == '时效性'); | ||
| 1017 | // const dataTimelinessStr = dataTimeliness ? typeMap.value[`dict_${dataTimeliness.guid}`].find(f => f.value == baseConfigFormInfo[`dict_${dataTimeliness.guid}`])?.label || '' : ''; | ||
| 1018 | // rangStr += dataTimelinessStr ? `,时间跨度为${dataTimelinessStr}的数据` : `的数据`; | ||
| 1019 | // damNames.length && (exportOut.two = `${exportOut.two}\n估值范围:${rangStr}`); | ||
| 1020 | // // 字典 | ||
| 1021 | // let dictList: any = [], hasModelScore = false; | ||
| 1022 | // const dictStr = exportData.value.map(e => { | ||
| 1023 | // // 检查是否有质量模型评分 | ||
| 1024 | // hasModelScore = hasModelScore || e.pricingTargetRSVOS.some( | ||
| 1025 | // t => t.targetType === '2' && t.functionName === '1' | ||
| 1026 | // ); | ||
| 1027 | |||
| 1028 | // // 只有当维度指标数大于1时才处理明细 | ||
| 1029 | // if (e.pricingTargetRSVOS.length > 1) { | ||
| 1030 | // const targetStr = e.pricingTargetRSVOS | ||
| 1031 | // .map(t => `${t.targetName}为${changeNum(t.tNum, 2)}`) | ||
| 1032 | // .join('、'); | ||
| 1033 | |||
| 1034 | // dictList.push(`${e.dimensionalityName}为${changeNum(e.sNum, 2)},其中${targetStr}`); | ||
| 1035 | // } | ||
| 1036 | |||
| 1037 | // return `${e.dimensionalityName}为${changeNum(e.sNum, 2)}`; | ||
| 1038 | // }) | ||
| 1039 | // let dictListStr = `${dictStr.join(',')}。\n${dictList.join(';\n')}` | ||
| 1040 | // // 质量模型 | ||
| 1041 | // if (hasModelScore) { | ||
| 1042 | // const { largeCategoryScoreList = [], qualityScore = 0 } = qualityScoreData.value; | ||
| 1043 | // const qualityParts = [ | ||
| 1044 | // `数据的总体质量得分为${changeNum(qualityScore, 2)}` | ||
| 1045 | // ]; | ||
| 1046 | |||
| 1047 | // if (largeCategoryScoreList.length) { | ||
| 1048 | // const categoryScores = largeCategoryScoreList.map( | ||
| 1049 | // q => `${q.largeCategoryName}方面得分为${changeNum(q.largeCategoryScore || 0, 2)}` | ||
| 1050 | // ); | ||
| 1051 | // qualityParts.push(`其中${categoryScores.join(',')}`); | ||
| 1052 | // } | ||
| 1053 | |||
| 1054 | // dictListStr += `;\n${qualityParts.join('。')}`; | ||
| 1055 | // } | ||
| 1056 | // exportOut.three = `${baseConfigFormInfo.belongingEntityGuid}持有的"${damName}"的数据(患者人次)单价为${changeNum(dataTransactionPrice.value, 2)}元${dictListStr ? `;其中${dictListStr}` : '。'}`; | ||
| 1057 | |||
| 1058 | loading.value = true; | ||
| 1059 | const exportOut = { | ||
| 1060 | one: priceData.one, | ||
| 1061 | two: priceData.two, | ||
| 1062 | three: priceData.three, | ||
| 1063 | } | ||
| 1064 | exportModelScore(exportOut).then((res: any) => { | ||
| 1065 | loading.value = false; | ||
| 1066 | if (res && !res.msg) { | ||
| 1067 | ElMessage({ | ||
| 1068 | type: "success", | ||
| 1069 | message: '下载报告成功', | ||
| 1070 | }); | ||
| 1071 | download(res, `数据定价报告.doc`, 'word'); | ||
| 1072 | } else { | ||
| 1073 | res?.msg && ElMessage.error(res?.msg); | ||
| 1074 | } | ||
| 1075 | }).catch(() => { | ||
| 1076 | loading.value = false; | ||
| 1077 | ElMessage({ | ||
| 1078 | type: "error", | ||
| 1079 | message: '下载报告请求失败', | ||
| 1080 | }); | ||
| 1081 | }) | ||
| 1082 | } else { | ||
| 1083 | // const { signatoryData, resultInfo } = reporting(baseConfigFormInfo); | ||
| 1084 | // exportData.value = resultInfo; | ||
| 1085 | // !dataTransactionPrice.value && calculatePrice(signatoryData); | ||
| 1086 | let params = { | ||
| 1087 | ...paramsInfo, | ||
| 1088 | dataTransactionPrice: dataTransactionPrice.value, | ||
| 1089 | } | ||
| 1048 | loading.value = true; | 1090 | loading.value = true; |
| 1049 | savePrice(params).then((res: any) => { | 1091 | savePrice(params).then((res: any) => { |
| 1050 | loading.value = false; | 1092 | loading.value = false; | ... | ... |
-
Please register or sign in to post a comment