|
|
@@ -141,20 +141,29 @@
|
|
|
// 费用模板初始化
|
|
|
const handleDesignerInit = async (instance) => {
|
|
|
designer = instance
|
|
|
- console.log('葡萄城初始化了!!!')
|
|
|
+ console.log('[calcCheckItemFee] 葡萄城初始化了!!!')
|
|
|
+ console.log('[calcCheckItemFee] props:', { equipmentId: props.equipmentId, templateInfo: props.templateInfo, isBatch: props.isBatch })
|
|
|
await handleGetPressureReportTemplateInfo()
|
|
|
+ console.log('[calcCheckItemFee] fetchTemplateData 加载完成:', fetchTemplateData.value)
|
|
|
+ console.log('[calcCheckItemFee] combineTemplateInfo:', combineTemplateInfo.value)
|
|
|
+ console.log('[calcCheckItemFee] isManualInput:', isManualInput.value)
|
|
|
// 加载费用计算模板
|
|
|
await handleRenderFormulaTemplate()
|
|
|
// 获取费用计算字段
|
|
|
if (props.equipmentId) {
|
|
|
+ console.log('[calcCheckItemFee] equipmentId 存在,开始获取费用计算字段')
|
|
|
await handleQueryCheckItemCalcPreFillField()
|
|
|
+ } else {
|
|
|
+ console.warn('[calcCheckItemFee] equipmentId 为空,跳过获取费用计算字段!')
|
|
|
}
|
|
|
|
|
|
// 优先从已保存的 feeCalculateJson 中回显实际费用
|
|
|
+ console.log('[calcCheckItemFee] feeCalculateJson:', feeCalculateJson.value)
|
|
|
feeForm.value = {
|
|
|
actualFee: feeCalculateJson.value['actualFee'] || combineTemplateInfo.value.fee || 0,
|
|
|
totalCost: feeCalculateJson.value['totalCost'] || combineTemplateInfo.value.fee || 0
|
|
|
}
|
|
|
+ console.log('[calcCheckItemFee] 初始化完成,feeForm:', feeForm.value)
|
|
|
}
|
|
|
|
|
|
// 获取费用模板信息
|
|
|
@@ -163,16 +172,29 @@
|
|
|
const feeCalculateJson = computed(() => !props.templateInfo.feeCalculateJson ? {} : JSON.parse(props.templateInfo.feeCalculateJson))
|
|
|
|
|
|
// 是否手动录入 true是,false否
|
|
|
- const isManualInput = computed(() => combineTemplateInfo.value.isAutoAmount === '0')
|
|
|
+ const isManualInput = computed(() => {
|
|
|
+ const result = combineTemplateInfo.value.isAutoAmount === '0'
|
|
|
+ console.log('[calcCheckItemFee] isManualInput 计算:', { isAutoAmount: combineTemplateInfo.value.isAutoAmount, result })
|
|
|
+ return result
|
|
|
+ })
|
|
|
const handleGetPressureReportTemplateInfo = async () => {
|
|
|
+ console.log('[calcCheckItemFee] 开始获取模板信息,templateId:', props.templateInfo.templateId)
|
|
|
fetchTemplateData.value = await getPressureReportTemplateInfo({id: props.templateInfo.templateId})
|
|
|
+ console.log('[calcCheckItemFee] 模板信息获取结果:', fetchTemplateData.value)
|
|
|
}
|
|
|
|
|
|
// 渲染费用计算模板
|
|
|
const handleRenderFormulaTemplate = async () => {
|
|
|
const spread = designer?.getWorkbook()
|
|
|
- if(!combineTemplateInfo.value.formulaTemplateUrl) return
|
|
|
+ console.log('[calcCheckItemFee] handleRenderFormulaTemplate 开始')
|
|
|
+ console.log('[calcCheckItemFee] formulaTemplateUrl:', combineTemplateInfo.value.formulaTemplateUrl)
|
|
|
+ console.log('[calcCheckItemFee] combineTemplateInfo.keys:', Object.keys(combineTemplateInfo.value))
|
|
|
+ if(!combineTemplateInfo.value.formulaTemplateUrl) {
|
|
|
+ console.warn('[calcCheckItemFee] formulaTemplateUrl 为空,无法渲染公式模板!')
|
|
|
+ return
|
|
|
+ }
|
|
|
const response = await axios.get(buildFileUrl(combineTemplateInfo.value.formulaTemplateUrl), { responseType: 'blob' })
|
|
|
+ console.log('[calcCheckItemFee] 公式模板文件获取成功,status:', response.status)
|
|
|
|
|
|
const blob = new Blob([response.data], { type: response.headers['content-type'] })
|
|
|
spread.open(
|
|
|
@@ -180,10 +202,10 @@
|
|
|
function () {
|
|
|
// 让活动工作表的单元格全部失焦
|
|
|
spread.getActiveSheet().setActiveCell(null);
|
|
|
- console.log('费用计算模板加载成功')
|
|
|
+ console.log('[calcCheckItemFee] 费用计算模板加载成功')
|
|
|
},
|
|
|
function () {
|
|
|
- console.log('费用计算模板加载失败')
|
|
|
+ console.error('[calcCheckItemFee] 费用计算模板加载失败')
|
|
|
}
|
|
|
)
|
|
|
}
|
|
|
@@ -201,7 +223,9 @@
|
|
|
equipId: props.equipmentId,
|
|
|
templateId: combineTemplateInfo.value.templateId
|
|
|
}
|
|
|
+ console.log('[calcCheckItemFee] queryCheckItemCalcPreFillField 请求参数:', params)
|
|
|
const fieldResult = await queryCheckItemCalcPreFillField(params)
|
|
|
+ console.log('[calcCheckItemFee] queryCheckItemCalcPreFillField 返回结果:', fieldResult)
|
|
|
|
|
|
allCalcPreFillField.value = fieldResult
|
|
|
// 保存所有的输入项
|
|
|
@@ -211,36 +235,39 @@
|
|
|
// 获取所有需要field的code,转成{[code]: ''}格式,set到费用模板中
|
|
|
allCalcPreFillFieldKeyValue.value = Object.fromEntries(enterDataList.value.map(item => ([item.code, feeCalculateJson.value[item.code] || ''])))
|
|
|
|
|
|
+ console.log('[calcCheckItemFee] enterDataList:', enterDataList.value.length, '项')
|
|
|
+ console.log('[calcCheckItemFee] outputDataList:', outputDataList.value.length, '项')
|
|
|
+ console.log('[calcCheckItemFee] allCalcPreFillFieldKeyValue:', allCalcPreFillFieldKeyValue.value)
|
|
|
+
|
|
|
// 检验费用数据回显
|
|
|
feeForm.value = {
|
|
|
actualFee: feeCalculateJson.value['actualFee'] || 0,
|
|
|
totalCost: feeCalculateJson.value['totalCost'] || 0
|
|
|
}
|
|
|
} catch(error) {
|
|
|
-
|
|
|
- console.error('获取费用计算字段报错了', error)
|
|
|
-
|
|
|
+ console.error('[calcCheckItemFee] 获取费用计算字段报错了', error)
|
|
|
} finally {
|
|
|
-
|
|
|
loading.value = false
|
|
|
-
|
|
|
}
|
|
|
}
|
|
|
// 自动计算费用
|
|
|
const handleCalcFee = () => {
|
|
|
+ console.log('[calcCheckItemFee] handleCalcFee 开始计算')
|
|
|
const spread = designer?.getWorkbook()
|
|
|
const entryData = Object.fromEntries(enterDataList.value.map(item => ([item.code, item.inputText])))
|
|
|
const combineDataSource = {
|
|
|
...allCalcPreFillFieldKeyValue.value,
|
|
|
...entryData
|
|
|
}
|
|
|
- // console.log('combineDataSource', combineDataSource)
|
|
|
+ console.log('[calcCheckItemFee] combineDataSource:', combineDataSource)
|
|
|
+ console.log('[calcCheckItemFee] bindingPathSchema:', combineTemplateInfo.value.bindingPathSchema)
|
|
|
// set数据
|
|
|
spreadDesignerRef.value.newSetDataSource(combineTemplateInfo.value.bindingPathSchema, combineDataSource)
|
|
|
|
|
|
// get数据
|
|
|
nextTick(() => {
|
|
|
const getDataSource = spreadDesignerRef.value.getDataSource()
|
|
|
+ console.log('[calcCheckItemFee] getDataSource:', getDataSource)
|
|
|
// 输出项的值
|
|
|
outputDataList.value = outputDataList.value.map(item => {
|
|
|
if(is(getDataSource[item.code], 'Null') || is(getDataSource[item.code], 'Undefined')) return item
|
|
|
@@ -249,11 +276,12 @@
|
|
|
inputText: getDataSource[item.code]
|
|
|
}
|
|
|
})
|
|
|
- // console.log('输出项', outputDataList.value)
|
|
|
const totalCostCode = allCalcPreFillField.value.find(x => x.type === '3')?.code || 'totalCost'
|
|
|
+ console.log('[calcCheckItemFee] totalCostCode:', totalCostCode, '值:', getDataSource[totalCostCode])
|
|
|
// 自动计算总费用
|
|
|
feeForm.value.totalCost = getDataSource[totalCostCode]
|
|
|
feeForm.value.actualFee = getDataSource[totalCostCode]
|
|
|
+ console.log('[calcCheckItemFee] 计算完成 feeForm:', feeForm.value)
|
|
|
})
|
|
|
}
|
|
|
|
|
|
@@ -261,7 +289,9 @@
|
|
|
const handleSave = () => {
|
|
|
const inputParams = Object.fromEntries(enterDataList.value.map(item => ([item.code, item.inputText])))
|
|
|
const outputParams = Object.fromEntries(outputDataList.value.map(item => ([item.code, item.inputText])))
|
|
|
- emit('save', {...props.templateInfo, fee: feeForm.value.actualFee || 0, feeCalculateJson: JSON.stringify({...inputParams, ...feeForm.value, ...outputParams})})
|
|
|
+ const saveData = {...props.templateInfo, fee: feeForm.value.actualFee || 0, feeCalculateJson: JSON.stringify({...inputParams, ...feeForm.value, ...outputParams})}
|
|
|
+ console.log('[calcCheckItemFee] handleSave emit save:', saveData)
|
|
|
+ emit('save', saveData)
|
|
|
handleClose()
|
|
|
}
|
|
|
|