013d56af by lxs

数据定价对接计算接口

1 parent 7045957c
......@@ -242,6 +242,15 @@ export const getPriceResult = (params) => {
});
};
// 计算数据定价
export const calculatPrice = (params) => {
return request({
url: `${import.meta.env.VITE_API_NEW_PORTAL}/pricing-data/calculate-price`,
method: "post",
data: params,
});
};
// 删除数据定价
export const deletePrice = (params) => {
return request({
......
......@@ -21,7 +21,8 @@ import {
savePrice,
getModelDemand,
getPriceResult,
exportModelScore
exportModelScore,
calculatPrice
} from '@/api/modules/dataPricing';
import { changeNum } from "@/utils/common";
......@@ -908,94 +909,8 @@ const calculatePrice = (pData) => {
}
};
// 计算结果和提交
const checkForm = (type) => {
const baseConfigFormObj = baseConfigFormRef.value;
const baseConfigFormEl = baseConfigFormObj.ruleFormRef;
const baseConfigFormInfo = baseConfigFormObj.formInline;
baseConfigFormEl.validate((valid, errorItem) => {
if (valid) {
if (type == 'calculate') {
const { signatoryData, resultInfo } = reporting(baseConfigFormInfo);
exportData.value = resultInfo;
calculatePrice(signatoryData);
} else if (type == 'export') {
const { signatoryData, resultInfo } = reporting(baseConfigFormInfo);
exportData.value = resultInfo;
!dataTransactionPrice.value && calculatePrice(signatoryData);
loading.value = true;
let exportOut: any = {};
// 估值对象信息
const damName = typeMap.value.dataResourceGuid.find(f => f.damGuid == baseConfigFormInfo.dataResourceGuid)?.damName || '';
exportOut.one = `因${baseConfigFormInfo.belongingEntityGuid}拟了解其所持有的\"${damName}\"相关数据资源的价格,为此需对该行为涉及的数据资源在不同应用场景下,基于数据资源持有单位的性质、信息化程度、数据稀缺性、需求匹配等情况下,为上述经济行为提供定价参考依据。`;
exportOut.two = `估值对象:${baseConfigFormInfo.belongingEntityGuid}持有的\"${damName}\"`;
// 估值范围信息
const damNames = demandTableList.value.map(item => item.menuName)
let rangStr = `包含${damNames.join('、')}${damNames.length}张表单,${damNames.length}张表共计${demandTableFieldAllNum.value}个字段`;
const dataTimeliness = pricingTargetList.value.find(p => p.dictionaryName == '时效性');
const dataTimelinessStr = dataTimeliness ? typeMap.value[`dict_${dataTimeliness.guid}`].find(f => f.value == baseConfigFormInfo[`dict_${dataTimeliness.guid}`])?.label || '' : '';
rangStr += dataTimelinessStr ? `,时间跨度为${dataTimelinessStr}的数据` : `的数据`;
damNames.length && (exportOut.two = `${exportOut.two}\n估值范围:${rangStr}`);
// 字典
let dictList: any = [], hasModelScore = false;
const dictStr = exportData.value.map(e => {
// 检查是否有质量模型评分
hasModelScore = hasModelScore || e.pricingTargetRSVOS.some(
t => t.targetType === '2' && t.functionName === '1'
);
// 只有当维度指标数大于1时才处理明细
if (e.pricingTargetRSVOS.length > 1) {
const targetStr = e.pricingTargetRSVOS
.map(t => `${t.targetName}${changeNum(t.tNum, 2)}`)
.join('、');
dictList.push(`${e.dimensionalityName}${changeNum(e.sNum, 2)},其中${targetStr}`);
}
return `${e.dimensionalityName}${changeNum(e.sNum, 2)}`;
})
let dictListStr = `${dictStr.join(',')}。\n${dictList.join(';\n')}`
// 质量模型
if (hasModelScore) {
const { largeCategoryScoreList = [], qualityScore = 0 } = qualityScoreData.value;
const qualityParts = [
`数据的总体质量得分为${changeNum(qualityScore, 2)}`
];
if (largeCategoryScoreList.length) {
const categoryScores = largeCategoryScoreList.map(
q => `${q.largeCategoryName}方面得分为${changeNum(q.largeCategoryScore || 0, 2)}`
);
qualityParts.push(`其中${categoryScores.join(',')}`);
}
dictListStr += `;\n${qualityParts.join('。')}`;
}
exportOut.three = `${baseConfigFormInfo.belongingEntityGuid}持有的"${damName}"的数据(患者人次)单价为${changeNum(dataTransactionPrice.value, 2)}${dictListStr ? `;其中${dictListStr}` : '。'}`;
exportModelScore(exportOut).then((res: any) => {
loading.value = false;
if (res && !res.msg) {
ElMessage({
type: "success",
message: '下载报告成功',
});
download(res, `数据定价报告.doc`, 'word');
} else {
res?.msg && ElMessage.error(res?.msg);
}
}).catch(() => {
loading.value = false;
ElMessage({
type: "error",
message: '下载报告请求失败',
});
})
} else {
const { signatoryData, resultInfo } = reporting(baseConfigFormInfo);
exportData.value = resultInfo;
!dataTransactionPrice.value && calculatePrice(signatoryData);
// 获取定价计算配置参数
const getCalculateParams = (baseConfigFormObj, baseConfigFormInfo) => {
const modelName = typeMap.value.modelGuid.find(d => d.guid == baseConfigFormInfo.modelGuid)?.modelName || '';
const dataResourceName = typeMap.value.dataResourceGuid.find(d => d.damGuid == baseConfigFormInfo.dataResourceGuid)?.damName || '';
const diseaseGuid = baseConfigFormInfo.diseaseGuid || '';
......@@ -1028,7 +943,7 @@ const checkForm = (type) => {
demandMatchingData.push({
demandTableName: item.demandTableName,
demandTableGuid: item.demandTableGuid || item.guid, // 需求表guid
dataTableGuid: item.dataTableGuid, // 数据资源表guid
dataTableGuid: item.dataTableGuid || '', // 数据资源表guid
weightDemandTable: item.weightDemandTable,
dataFieldsNum: item.dataFieldsNum,
pricingDemandFieldRQVOS: item.dataFields.map(d => {
......@@ -1045,7 +960,72 @@ const checkForm = (type) => {
});
params.dataPricingDemandmatchingRQVOS = demandMatchingData;
guid && (params.guid = guid);
return params;
}
// 获取定价计算结构
const getCalculatPrice = async (params) => {
try {
const res: any = await calculatPrice(params);
if (res.code === proxy.$passCode) {
const data = res.data || {};
return data; // 返回计算结果以便后续使用
} else {
proxy.$ElMessage.error(res.msg);
loading.value = false;
throw new Error(res.msg); // 抛出错误以便 catch 捕获
}
} catch (error) {
loading.value = false;
throw error; // 重新抛出错误
}
};
// 计算结果和提交
const checkForm = (type) => {
const baseConfigFormObj = baseConfigFormRef.value;
const baseConfigFormEl = baseConfigFormObj.ruleFormRef;
const baseConfigFormInfo = baseConfigFormObj.formInline;
baseConfigFormEl.validate(async (valid, errorItem) => {
if (valid) {
const paramsInfo = getCalculateParams(baseConfigFormObj, baseConfigFormInfo);
loading.value = true;
// 先获取计算结果
const priceData = await getCalculatPrice(paramsInfo);
// 显示结果
dataTransactionPrice.value = priceData.transactionPrice.toFixed(2);
if (type == 'calculate') {
loading.value = false;
} else if (type == 'export') {
const exportOut = {
one: priceData.one,
two: priceData.two,
three: priceData.three,
}
exportModelScore(exportOut).then((res: any) => {
loading.value = false;
if (res && !res.msg) {
ElMessage({
type: "success",
message: '下载报告成功',
});
download(res, `数据定价报告.doc`, 'word');
} else {
res?.msg && ElMessage.error(res?.msg);
}
}).catch(() => {
loading.value = false;
ElMessage({
type: "error",
message: '下载报告请求失败',
});
})
} else {
let params = {
...paramsInfo,
dataTransactionPrice: dataTransactionPrice.value,
}
savePrice(params).then((res: any) => {
loading.value = false;
if (res.code == proxy.$passCode) {
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!