|
|
@@ -77,7 +77,7 @@
|
|
|
<div class="price-bottom">
|
|
|
<div class="info-title-wrap">
|
|
|
<div class="sub-title">服务费用</div>
|
|
|
- <div class="info-more">{{ quotationData.farmWorkServiceCost || '--' }}<span class="unit-text">元</span></div>
|
|
|
+ <div class="info-more">{{ quotationData?.farmWorkServiceCost ? getServiceCost(quotationData.farmWorkServiceCost, quotationData.area) : '--' }}<span class="unit-text">元</span></div>
|
|
|
</div>
|
|
|
<div class="price-info">
|
|
|
<div class="info-l">执行方式<span class="main-text">{{ quotationData.executionMethodName || '--' }}</span></div>
|
|
|
@@ -85,7 +85,7 @@
|
|
|
<div class="info-r">亩数<span class="main-text">{{ quotationData.area ? formatArea(quotationData.area) + '亩' : '--' }}</span></div>
|
|
|
</div>
|
|
|
<div class="price-total">
|
|
|
- 报价合计:<span class="main-val">{{ quotationData.totalCost || '--' }}</span>元
|
|
|
+ 报价合计:<span class="main-val">{{ quotationData?.totalCost ? formatArea(quotationData.totalCost) : '--' }}</span>元
|
|
|
</div>
|
|
|
</div>
|
|
|
</template>
|
|
|
@@ -439,6 +439,7 @@ const handleRemindExecute = () => {
|
|
|
}
|
|
|
|
|
|
const handleForward = () => {
|
|
|
+ console.log('quotationData.value',quotationData.value)
|
|
|
if(quotationData.value.itemsList && quotationData.value.itemsList.length > 0) {
|
|
|
onlyShare.value = true;
|
|
|
setTimeout(() => {
|
|
|
@@ -497,9 +498,76 @@ onActivated(async () => {
|
|
|
}
|
|
|
if (query.value?.farmWorkOrderId || detailData.value?.flowStatus === 4) {
|
|
|
const farmWorkOrderId = query.value?.farmWorkOrderId || detailData.value.orderId;
|
|
|
- const { data } = await VE_API.z_farm_work_record_cost.listByOrderId({ farmWorkOrderId });
|
|
|
- if (data && data.length > 0) {
|
|
|
- const priceDataObj = data[0];
|
|
|
+ let priceDataObj = {}
|
|
|
+ if (curRole.value == 2) {
|
|
|
+ const {data} = await VE_API.z_farm_work_record_cost.getByRecordId({ farmWorkRecordId: detailData.value.id });
|
|
|
+ priceDataObj = data;
|
|
|
+ } else {
|
|
|
+ const {data} = await VE_API.z_farm_work_record_cost.listByOrderId({ farmWorkOrderId });
|
|
|
+ priceDataObj = data[0];
|
|
|
+ }
|
|
|
+ console.log('priceD3333ataObj',priceDataObj)
|
|
|
+ if (priceDataObj && Object.keys(priceDataObj).length > 0) {
|
|
|
+
|
|
|
+ // 合并外层字段
|
|
|
+ quotationData.value = {
|
|
|
+ ...detailData.value,
|
|
|
+ ...priceDataObj,
|
|
|
+ agriculturalId: priceDataObj.agriculturalId,
|
|
|
+ };
|
|
|
+
|
|
|
+ // 根据 itemsList 的 pesticideFertilizerId 匹配并赋值品牌和价格
|
|
|
+ if (priceDataObj.itemsList && Array.isArray(priceDataObj.itemsList) && detailData.value.prescriptionList) {
|
|
|
+ // 创建价格映射表
|
|
|
+ const priceMap = new Map();
|
|
|
+ priceDataObj.itemsList.forEach(item => {
|
|
|
+ priceMap.set(String(item.pesticideFertilizerId), {
|
|
|
+ brand: item.brand || '',
|
|
|
+ price: item.price || 0,
|
|
|
+ totalPrice: item.totalPrice || null
|
|
|
+ });
|
|
|
+ });
|
|
|
+
|
|
|
+ // 遍历处方列表,赋值品牌和价格,并计算格式化字段供 price-table 使用
|
|
|
+ quotationData.value.prescriptionList = detailData.value.prescriptionList.map(prescription => {
|
|
|
+ return {
|
|
|
+ ...prescription,
|
|
|
+ pesticideFertilizerList: prescription.pesticideFertilizerList.map(pesticide => {
|
|
|
+ const pesticideId = String(pesticide.pesticideFertilizerId || '');
|
|
|
+ const priceInfo = priceMap.get(pesticideId);
|
|
|
+
|
|
|
+ if (priceInfo) {
|
|
|
+ const price = priceInfo.price || 0;
|
|
|
+ const muUsage = pesticide.muUsage || 0;
|
|
|
+ const unit = pesticide.unit || '';
|
|
|
+ const area = detailData.value.area || 0;
|
|
|
+
|
|
|
+ // 计算总价:优先使用 totalPrice,否则计算 price * muUsage * area
|
|
|
+ const total = priceInfo.totalPrice
|
|
|
+ ? priceInfo.totalPrice
|
|
|
+ : (price * muUsage * area);
|
|
|
+
|
|
|
+ return {
|
|
|
+ ...pesticide,
|
|
|
+ brand: priceInfo.brand || '--',
|
|
|
+ totalPrice: priceInfo.totalPrice,
|
|
|
+ // 格式化字段供 price-table 组件使用
|
|
|
+ price: price > 0 ? `${price}元/${unit}` : '--', // 格式化单价显示
|
|
|
+ dosage: muUsage > 0 ? `${muUsage}${unit}` : '--', // 格式化用量显示
|
|
|
+ total: total > 0 ? total.toFixed(2) : '--' // 格式化总价显示
|
|
|
+ };
|
|
|
+ }
|
|
|
+ return pesticide;
|
|
|
+ })
|
|
|
+ };
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else if (curRole.value == 2) {
|
|
|
+ let priceDataObj = {}
|
|
|
+ const {data} = await VE_API.z_farm_work_record_cost.getByRecordId({ farmWorkRecordId: detailData.value.id });
|
|
|
+ priceDataObj = data;
|
|
|
+ if (priceDataObj && Object.keys(priceDataObj).length > 0) {
|
|
|
|
|
|
// 合并外层字段
|
|
|
quotationData.value = {
|
|
|
@@ -567,6 +635,10 @@ onActivated(async () => {
|
|
|
// }
|
|
|
});
|
|
|
|
|
|
+function getServiceCost(cost, area) {
|
|
|
+ if (!cost || !area) return '--';
|
|
|
+ return (parseFloat(cost) * parseFloat(area)).toFixed(2);
|
|
|
+}
|
|
|
|
|
|
const triggerImg = ref([]);
|
|
|
const getTriggerImg = async (id) => {
|