|
@@ -38,7 +38,7 @@
|
|
|
</div>
|
|
</div>
|
|
|
<div class="total-bar">
|
|
<div class="total-bar">
|
|
|
<span class="total-label">报价合计:</span>
|
|
<span class="total-label">报价合计:</span>
|
|
|
- <span class="total-value">{{ priceData?.totalCost ? formatArea(priceData.totalCost) : '--' }}</span>
|
|
|
|
|
|
|
+ <span class="total-value">{{ totalCost ? formatArea(totalCost) : "--" }}</span>
|
|
|
<span class="total-unit">元</span>
|
|
<span class="total-unit">元</span>
|
|
|
</div>
|
|
</div>
|
|
|
</div>
|
|
</div>
|
|
@@ -47,7 +47,7 @@
|
|
|
<div class="fertilizer-cost-section">
|
|
<div class="fertilizer-cost-section">
|
|
|
<div class="section-header">
|
|
<div class="section-header">
|
|
|
<div class="section-title">肥药费用</div>
|
|
<div class="section-title">肥药费用</div>
|
|
|
- <div class="section-total">{{ priceData?.pesticideFertilizerCost ? formatArea(priceData.pesticideFertilizerCost) : '--' }}<span class="unit-text">元</span></div>
|
|
|
|
|
|
|
+ <div class="section-total">{{ pesticideCostTotal ? formatArea(pesticideCostTotal) : "--" }}<span class="unit-text">元</span></div>
|
|
|
</div>
|
|
</div>
|
|
|
<div class="cost-table">
|
|
<div class="cost-table">
|
|
|
<div class="table-header">
|
|
<div class="table-header">
|
|
@@ -60,15 +60,15 @@
|
|
|
</div>
|
|
</div>
|
|
|
<div
|
|
<div
|
|
|
class="table-row"
|
|
class="table-row"
|
|
|
- v-for="(item, index) in processedPrescriptionList"
|
|
|
|
|
|
|
+ v-for="(item, index) in priceData?.prescription?.pesticideFertilizerList || []"
|
|
|
:key="index"
|
|
:key="index"
|
|
|
>
|
|
>
|
|
|
<div class="col-1">{{ item.typeName || '--' }}</div>
|
|
<div class="col-1">{{ item.typeName || '--' }}</div>
|
|
|
- <div class="col-2">{{ item.defaultName || item.pesticideFertilizerName || '--' }}</div>
|
|
|
|
|
|
|
+ <div class="col-2">{{ item.name || item.pesticideFertilizerName || '--' }}</div>
|
|
|
<div class="col-3">{{ item.brand || '--' }}</div>
|
|
<div class="col-3">{{ item.brand || '--' }}</div>
|
|
|
<div class="col-4">{{ item.price || '--' }}</div>
|
|
<div class="col-4">{{ item.price || '--' }}</div>
|
|
|
- <div class="col-5">{{ item.usageDisplay || '--' }}</div>
|
|
|
|
|
- <div class="col-6">{{ item.totalDisplay === '--' ? '--' : (item.totalDisplay + '元') }}</div>
|
|
|
|
|
|
|
+ <div class="col-5">{{ item.dosage ? item.dosage + item.unit : '--' }}</div>
|
|
|
|
|
+ <div class="col-6">{{ getTotal(item) }}</div>
|
|
|
</div>
|
|
</div>
|
|
|
</div>
|
|
</div>
|
|
|
</div>
|
|
</div>
|
|
@@ -77,7 +77,7 @@
|
|
|
<div class="service-cost-section">
|
|
<div class="service-cost-section">
|
|
|
<div class="section-header">
|
|
<div class="section-header">
|
|
|
<div class="section-title">服务费用</div>
|
|
<div class="section-title">服务费用</div>
|
|
|
- <div class="section-total">{{ priceData?.farmWorkServiceCost ? getServiceCost(priceData.farmWorkServiceCost, quotationData.area) : '--' }}<span class="unit-text">元</span></div>
|
|
|
|
|
|
|
+ <div class="section-total">{{ priceData?.serviceMuPrice ? serviceCostTotal : '--' }}<span class="unit-text">元</span></div>
|
|
|
</div>
|
|
</div>
|
|
|
<div class="service-details">
|
|
<div class="service-details">
|
|
|
<div class="detail-item">
|
|
<div class="detail-item">
|
|
@@ -85,11 +85,11 @@
|
|
|
<div class="detail-label">执行方式</div>
|
|
<div class="detail-label">执行方式</div>
|
|
|
</div>
|
|
</div>
|
|
|
<div class="detail-item">
|
|
<div class="detail-item">
|
|
|
- <div class="detail-value">{{ (priceData?.farmWorkServiceCost || priceData?.manualServicePrice ? (priceData.farmWorkServiceCost || priceData.manualServicePrice) + '元/亩' : '--') }}</div>
|
|
|
|
|
|
|
+ <div class="detail-value">{{ (priceData?.serviceMuPrice ? priceData?.serviceMuPrice + '元/亩' : '--') }}</div>
|
|
|
<div class="detail-label">亩单价</div>
|
|
<div class="detail-label">亩单价</div>
|
|
|
</div>
|
|
</div>
|
|
|
<div class="detail-item">
|
|
<div class="detail-item">
|
|
|
- <div class="detail-value">{{ quotationData?.area ? (formatArea(quotationData?.area) + '亩') : '--' }}</div>
|
|
|
|
|
|
|
+ <div class="detail-value">{{ priceData?.farm?.mianji ? (formatArea(priceData?.farm?.mianji) + '亩') : '--' }}</div>
|
|
|
<div class="detail-label">亩数</div>
|
|
<div class="detail-label">亩数</div>
|
|
|
</div>
|
|
</div>
|
|
|
</div>
|
|
</div>
|
|
@@ -146,63 +146,46 @@ onActivated(() => {
|
|
|
fetchPriceData()
|
|
fetchPriceData()
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
-// 处理后的处方列表(展平并匹配价格)
|
|
|
|
|
-const processedPrescriptionList = computed(() => {
|
|
|
|
|
- if (!priceData.value?.prescriptionList || !Array.isArray(priceData.value.prescriptionList)) {
|
|
|
|
|
- return [];
|
|
|
|
|
- }
|
|
|
|
|
|
|
+const getTotal = (item) => {
|
|
|
|
|
+ const price = Number(item?.price ?? 0);
|
|
|
|
|
+ const dosage = Number(item?.dosage ?? 0);
|
|
|
|
|
+ const area = Number(priceData.value?.farm?.mianji ?? 0);
|
|
|
|
|
+ if (!price || !dosage || !area) return '--';
|
|
|
|
|
+ return (price * dosage * area).toFixed(2);
|
|
|
|
|
+}
|
|
|
|
|
|
|
|
- // 创建价格映射表,方便快速查找
|
|
|
|
|
- const priceMap = new Map();
|
|
|
|
|
- if (priceData.value?.itemsList && Array.isArray(priceData.value.itemsList)) {
|
|
|
|
|
- priceData.value.itemsList.forEach(item => {
|
|
|
|
|
- priceMap.set(String(item.pesticideFertilizerId), { price: item.price, brand: item.brand, totalPrice: item.totalPrice });
|
|
|
|
|
- });
|
|
|
|
|
- }
|
|
|
|
|
- // 展平 prescriptionList 中的所有 pesticideFertilizerList
|
|
|
|
|
- const result = [];
|
|
|
|
|
- priceData.value.prescriptionList.forEach(prescription => {
|
|
|
|
|
- if (prescription.pesticideFertilizerList && Array.isArray(prescription.pesticideFertilizerList)) {
|
|
|
|
|
- prescription.pesticideFertilizerList.forEach(item => {
|
|
|
|
|
- const pesticideFertilizerId = String(item.pesticideFertilizerId || '');
|
|
|
|
|
- const mapped = priceMap.get(pesticideFertilizerId) || {};
|
|
|
|
|
- const price = mapped.price || 0;
|
|
|
|
|
- const brand = mapped.brand || item.brand || '';
|
|
|
|
|
- const total = mapped.totalPrice || item.total || '';
|
|
|
|
|
- const muUsage = priceData.value.usageMode === "叶面施" ? (item.muUsage2 || item.muUsage) : item.muUsage
|
|
|
|
|
- const unit = item.unit || '';
|
|
|
|
|
-
|
|
|
|
|
- result.push({
|
|
|
|
|
- typeName: item.typeName || item.pesticideFertilizerTypeName || '--',
|
|
|
|
|
- defaultName: item.defaultName || item.pesticideFertilizerName || '--',
|
|
|
|
|
- brand: brand,
|
|
|
|
|
- priceVal: price || null,
|
|
|
|
|
- pesticideFertilizerId: item.pesticideFertilizerId,
|
|
|
|
|
- price: price ? `${price}元` : '--',
|
|
|
|
|
- unit: unit,
|
|
|
|
|
- muUsage: muUsage,
|
|
|
|
|
- // total: total,
|
|
|
|
|
- // 显示的格式化字符串
|
|
|
|
|
- priceDisplay: price > 0 ? `${price}元/${unit}` : '--',
|
|
|
|
|
- usageDisplay: muUsage > 0 ? `${muUsage}${unit}` : '--',
|
|
|
|
|
- totalDisplay: total > 0 ? `${total.toFixed(2)}` : '--'
|
|
|
|
|
- });
|
|
|
|
|
- });
|
|
|
|
|
- }
|
|
|
|
|
- });
|
|
|
|
|
|
|
|
|
|
- return result;
|
|
|
|
|
|
|
+// 药肥费用总计:∑(单价 * 单亩用量 * 亩数)
|
|
|
|
|
+const pesticideCostTotal = computed(() => {
|
|
|
|
|
+ const list = priceData.value?.prescription?.pesticideFertilizerList || [];
|
|
|
|
|
+ const area = Number(priceData.value?.farm?.mianji || 0);
|
|
|
|
|
+ if (!list.length || !area) return 0;
|
|
|
|
|
+
|
|
|
|
|
+ const sum = list.reduce((acc, item) => {
|
|
|
|
|
+ const price = Number(item?.price || 0);
|
|
|
|
|
+ const dosage = Number(item?.dosage || 0);
|
|
|
|
|
+ if (!price || !dosage) return acc;
|
|
|
|
|
+ return acc + price * dosage * area;
|
|
|
|
|
+ }, 0);
|
|
|
|
|
+
|
|
|
|
|
+ return Number(sum.toFixed(2));
|
|
|
|
|
+});
|
|
|
|
|
+
|
|
|
|
|
+// 报价合计 = 药肥费用 + 服务费用
|
|
|
|
|
+const totalCost = computed(() => {
|
|
|
|
|
+ const pesticide = Number(pesticideCostTotal.value || 0);
|
|
|
|
|
+ const service = Number(serviceCostTotal.value || 0);
|
|
|
|
|
+ if (!pesticide && !service) return 0;
|
|
|
|
|
+ return Number((pesticide + service).toFixed(2));
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
-function getServiceCost(cost, area) {
|
|
|
|
|
- if (!cost || !area) return '--';
|
|
|
|
|
- return (parseFloat(cost) * parseFloat(area)).toFixed(2);
|
|
|
|
|
-}
|
|
|
|
|
|
|
|
|
|
|
|
+const ids = ref({});
|
|
|
const handleShowPopup = ({id, farmId, agriculturalId}) => {
|
|
const handleShowPopup = ({id, farmId, agriculturalId}) => {
|
|
|
if (id) {
|
|
if (id) {
|
|
|
loading.value = true;
|
|
loading.value = true;
|
|
|
- getDetail(id, farmId, agriculturalId);
|
|
|
|
|
|
|
+ ids.value = {id, farmId, agriculturalId};
|
|
|
|
|
+ getDetail();
|
|
|
}
|
|
}
|
|
|
showPopup.value = true;
|
|
showPopup.value = true;
|
|
|
};
|
|
};
|
|
@@ -219,7 +202,8 @@ function fetchPriceData(id) {
|
|
|
// });
|
|
// });
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-const getDetail = async (id, farmId, agriculturalId) => {
|
|
|
|
|
|
|
+const getDetail = async () => {
|
|
|
|
|
+ const { id, farmId, agriculturalId } = ids.value;
|
|
|
const { data, code } = await VE_API.farm.getFarmWorkLib({ id, farmId, agriculturalId });
|
|
const { data, code } = await VE_API.farm.getFarmWorkLib({ id, farmId, agriculturalId });
|
|
|
if(code === 0) {
|
|
if(code === 0) {
|
|
|
priceData.value = data;
|
|
priceData.value = data;
|
|
@@ -243,11 +227,11 @@ const getPriceList = async (schemeId, pesticideFertilizerCodes) => {
|
|
|
|
|
|
|
|
// 检查 itemsList 是否都有价格和品牌
|
|
// 检查 itemsList 是否都有价格和品牌
|
|
|
function checkItemsListHasPrice() {
|
|
function checkItemsListHasPrice() {
|
|
|
- if (!priceData.value?.itemsList || !Array.isArray(priceData.value.itemsList) || priceData.value.itemsList.length === 0) {
|
|
|
|
|
|
|
+ if (!priceData.value?.prescription?.pesticideFertilizerList || !Array.isArray(priceData.value.prescription.pesticideFertilizerList) || priceData.value.prescription.pesticideFertilizerList.length === 0) {
|
|
|
return false;
|
|
return false;
|
|
|
}
|
|
}
|
|
|
// 检查所有项是否都有 price 且 price 不为 0,以及 brand 有值
|
|
// 检查所有项是否都有 price 且 price 不为 0,以及 brand 有值
|
|
|
- return priceData.value.itemsList.every(item => {
|
|
|
|
|
|
|
+ return priceData.value.prescription.pesticideFertilizerList.every(item => {
|
|
|
const hasPrice = item.price != null && item.price !== '' && item.price !== 0;
|
|
const hasPrice = item.price != null && item.price !== '' && item.price !== 0;
|
|
|
const hasBrand = item.brand && item.brand.trim() !== '';
|
|
const hasBrand = item.brand && item.brand.trim() !== '';
|
|
|
return hasPrice && hasBrand;
|
|
return hasPrice && hasBrand;
|
|
@@ -259,41 +243,6 @@ async function checkOrder() {
|
|
|
if (!checkItemsListHasPrice()) {
|
|
if (!checkItemsListHasPrice()) {
|
|
|
return false; // 没有价格,返回 false
|
|
return false; // 没有价格,返回 false
|
|
|
}
|
|
}
|
|
|
- if (!priceData.value?.id) {
|
|
|
|
|
- // 如果 itemsList 都有价格,调用接口创建报价
|
|
|
|
|
- const pesticideFertilizerQuoteList = processedPrescriptionList.value.map(item => {
|
|
|
|
|
- return {
|
|
|
|
|
- pesticideFertilizerId: item.pesticideFertilizerId,
|
|
|
|
|
- price: item.priceVal,
|
|
|
|
|
- brand: item.brand,
|
|
|
|
|
- }
|
|
|
|
|
- });
|
|
|
|
|
-
|
|
|
|
|
- const payload = {
|
|
|
|
|
- farmWorkRecordId: quotationData.value?.id,
|
|
|
|
|
- pesticideFertilizerQuoteList,
|
|
|
|
|
- servicePrice: priceData.value.farmWorkServiceCost,
|
|
|
|
|
- executionMethod: priceData.value.executionMethod,
|
|
|
|
|
- };
|
|
|
|
|
-
|
|
|
|
|
- try {
|
|
|
|
|
- const { code } = await VE_API.z_farm_work_record.acceptFarmWorkRecord(payload);
|
|
|
|
|
- if (code === 0) {
|
|
|
|
|
- // 创建成功后,重新获取价格数据
|
|
|
|
|
- await fetchPriceData();
|
|
|
|
|
- return true; // 创建成功,返回 true
|
|
|
|
|
- } else {
|
|
|
|
|
- return false; // 创建失败,返回 false
|
|
|
|
|
- }
|
|
|
|
|
- } catch (error) {
|
|
|
|
|
- return false; // 接口调用失败,返回 false
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- // 如果有 id,检查 itemsList 是否都有价格
|
|
|
|
|
- if (!checkItemsListHasPrice()) {
|
|
|
|
|
- return false; // 没有价格,返回 false
|
|
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
// 有 id 且都有价格,返回 true
|
|
// 有 id 且都有价格,返回 true
|
|
|
return true;
|
|
return true;
|
|
@@ -309,14 +258,14 @@ const handleShare = async () => {
|
|
|
}, 1000);
|
|
}, 1000);
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
- const userId = quotationData.value.farmMiniUserId;
|
|
|
|
|
|
|
+ const userId = priceData.value.farmMiniUserId;
|
|
|
const parmasPage = {
|
|
const parmasPage = {
|
|
|
- farmWorkOrderId:quotationData.value.orderId,
|
|
|
|
|
|
|
+ farmWorkOrderId:priceData.value.orderId,
|
|
|
farmMiniUserId:userId,
|
|
farmMiniUserId:userId,
|
|
|
- farmMiniUserName:quotationData.value.farmMiniUserName,
|
|
|
|
|
- farmId:quotationData.value.farmId,
|
|
|
|
|
- farmWorkName:quotationData.value.farmWorkName,
|
|
|
|
|
- id:quotationData.value.id,
|
|
|
|
|
|
|
+ farmMiniUserName:priceData.value.farmMiniUserName,
|
|
|
|
|
+ farmId:priceData.value.farmId,
|
|
|
|
|
+ farmWorkName:priceData.value.farmWorkName,
|
|
|
|
|
+ id:priceData.value.id,
|
|
|
type:'quotation'
|
|
type:'quotation'
|
|
|
}
|
|
}
|
|
|
if(userId){
|
|
if(userId){
|
|
@@ -328,7 +277,7 @@ const handleShare = async () => {
|
|
|
|
|
|
|
|
const handleWechat = async () => {
|
|
const handleWechat = async () => {
|
|
|
// 检查订单状态,如果返回 false 说明数据不完整
|
|
// 检查订单状态,如果返回 false 说明数据不完整
|
|
|
- const canProceed = await checkOrder();
|
|
|
|
|
|
|
+ const canProceed = await checkItemsListHasPrice();
|
|
|
if (!canProceed) {
|
|
if (!canProceed) {
|
|
|
ElMessage.warning('请补全报价数据');
|
|
ElMessage.warning('请补全报价数据');
|
|
|
return;
|
|
return;
|
|
@@ -344,6 +293,14 @@ const handleWechat = async () => {
|
|
|
});
|
|
});
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
|
|
+// 服务费用总计(数值):亩单价 * 亩数
|
|
|
|
|
+const serviceCostTotal = computed(() => {
|
|
|
|
|
+ const price = Number(priceData.value?.serviceMuPrice || 0);
|
|
|
|
|
+ const area = Number(priceData.value?.farm?.mianji || 0);
|
|
|
|
|
+ if (!price || !area) return 0;
|
|
|
|
|
+ return Number((price * area).toFixed(2));
|
|
|
|
|
+});
|
|
|
|
|
+
|
|
|
const handleSaveImage = async () => {
|
|
const handleSaveImage = async () => {
|
|
|
try {
|
|
try {
|
|
|
if (!contentEl.value) return;
|
|
if (!contentEl.value) return;
|
|
@@ -415,10 +372,9 @@ const handleEdit = () => {
|
|
|
path: "/modify",
|
|
path: "/modify",
|
|
|
query: {
|
|
query: {
|
|
|
isEdit: true,
|
|
isEdit: true,
|
|
|
- id: priceData.value.id,
|
|
|
|
|
|
|
+ onlyPrice: true,
|
|
|
farmId: priceData.value.farm.id,
|
|
farmId: priceData.value.farm.id,
|
|
|
farmWorkId: priceData.value.id,
|
|
farmWorkId: priceData.value.id,
|
|
|
- containerSpaceTimeId: priceData.value.containerSpaceTimeId,
|
|
|
|
|
agriculturalStoreId: priceData.value.agriculturalStoreId,
|
|
agriculturalStoreId: priceData.value.agriculturalStoreId,
|
|
|
},
|
|
},
|
|
|
});
|
|
});
|