|
@@ -1,5 +1,5 @@
|
|
|
<template>
|
|
<template>
|
|
|
- <div class="new-farming-page">
|
|
|
|
|
|
|
+ <div class="new-farming-page" ref="pageRef">
|
|
|
<custom-header :name="isEdit ? '编辑方案' : '查看详情'"></custom-header>
|
|
<custom-header :name="isEdit ? '编辑方案' : '查看详情'"></custom-header>
|
|
|
<div class="new-farming-content">
|
|
<div class="new-farming-content">
|
|
|
<el-form
|
|
<el-form
|
|
@@ -439,23 +439,20 @@
|
|
|
<div class="info-title-wrap">
|
|
<div class="info-title-wrap">
|
|
|
<div class="sub-title font-bold">药肥费用</div>
|
|
<div class="sub-title font-bold">药肥费用</div>
|
|
|
<div class="info-more">
|
|
<div class="info-more">
|
|
|
- {{ quotationData?.pesticideFertilizerCost ? formatArea(quotationData.pesticideFertilizerCost) : "--" }}<span class="unit-text">元</span>
|
|
|
|
|
|
|
+ {{ pesticideCostTotal ? formatArea(pesticideCostTotal) : "--" }}<span class="unit-text">元</span>
|
|
|
</div>
|
|
</div>
|
|
|
</div>
|
|
</div>
|
|
|
</div>
|
|
</div>
|
|
|
<div class="info-content-wrap">
|
|
<div class="info-content-wrap">
|
|
|
- <price-table :prescriptionData="dynamicValidateForm.prescription">
|
|
|
|
|
|
|
+ <price-table :prescriptionData="dynamicValidateForm.prescription" :area="detailData?.farm?.mianji">
|
|
|
<template #bottomContent>
|
|
<template #bottomContent>
|
|
|
<div class="price-bottom">
|
|
<div class="price-bottom">
|
|
|
<div class="info-title-wrap">
|
|
<div class="info-title-wrap">
|
|
|
<div class="sub-title font-bold">服务费用</div>
|
|
<div class="sub-title font-bold">服务费用</div>
|
|
|
<div class="info-more">
|
|
<div class="info-more">
|
|
|
{{
|
|
{{
|
|
|
- quotationData?.farmWorkServiceCost
|
|
|
|
|
- ? getServiceCost(
|
|
|
|
|
- quotationData.farmWorkServiceCost,
|
|
|
|
|
- quotationData.farm?.mianji
|
|
|
|
|
- )
|
|
|
|
|
|
|
+ quotationData?.serviceMuPrice
|
|
|
|
|
+ ? getServiceTotal()
|
|
|
: "--"
|
|
: "--"
|
|
|
}}<span class="unit-text">元</span>
|
|
}}<span class="unit-text">元</span>
|
|
|
</div>
|
|
</div>
|
|
@@ -481,7 +478,7 @@
|
|
|
</div>
|
|
</div>
|
|
|
<div class="price-total">
|
|
<div class="price-total">
|
|
|
报价合计:<span class="main-val">{{
|
|
报价合计:<span class="main-val">{{
|
|
|
- quotationData?.totalCost ? formatArea(quotationData.totalCost) : "--"
|
|
|
|
|
|
|
+ totalCost ? formatArea(totalCost) : "--"
|
|
|
}}</span
|
|
}}</span
|
|
|
>元
|
|
>元
|
|
|
</div>
|
|
</div>
|
|
@@ -511,7 +508,7 @@
|
|
|
</template>
|
|
</template>
|
|
|
|
|
|
|
|
<script setup>
|
|
<script setup>
|
|
|
-import { onActivated, ref, reactive, onDeactivated, onBeforeUnmount, computed, onMounted } from "vue";
|
|
|
|
|
|
|
+import { onActivated, ref, reactive, onDeactivated, onBeforeUnmount, computed, onMounted, nextTick } from "vue";
|
|
|
import { useRouter, useRoute } from "vue-router";
|
|
import { useRouter, useRoute } from "vue-router";
|
|
|
import { ElMessage, ElMessageBox } from "element-plus";
|
|
import { ElMessage, ElMessageBox } from "element-plus";
|
|
|
import customHeader from "@/components/customHeader.vue";
|
|
import customHeader from "@/components/customHeader.vue";
|
|
@@ -523,6 +520,7 @@ import priceTable from "../agri_work/components/priceTable.vue";
|
|
|
|
|
|
|
|
import dayjs from "dayjs";
|
|
import dayjs from "dayjs";
|
|
|
const store = useStore();
|
|
const store = useStore();
|
|
|
|
|
+const pageRef = ref(null);
|
|
|
const router = useRouter();
|
|
const router = useRouter();
|
|
|
const route = useRoute();
|
|
const route = useRoute();
|
|
|
|
|
|
|
@@ -542,14 +540,20 @@ const interactFormData = ref({
|
|
|
});
|
|
});
|
|
|
const phenologyList = ref([]);
|
|
const phenologyList = ref([]);
|
|
|
|
|
|
|
|
-const isEdit = ref(true);
|
|
|
|
|
|
|
+const isEdit = ref(false);
|
|
|
|
|
|
|
|
onActivated(() => {
|
|
onActivated(() => {
|
|
|
- // isEdit.value = route.query.isEdit ? true : false;
|
|
|
|
|
|
|
+ isEdit.value = route.query.isEdit ? true : false;
|
|
|
if (route.query.farmWorkId) {
|
|
if (route.query.farmWorkId) {
|
|
|
getDetail();
|
|
getDetail();
|
|
|
}
|
|
}
|
|
|
- window.scrollTo(0, 0);
|
|
|
|
|
|
|
+ nextTick(() => {
|
|
|
|
|
+ if (pageRef.value) {
|
|
|
|
|
+ pageRef.value.scrollTop = 0;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ window.scrollTo(0, 0);
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
// 初始化 prescription 对象
|
|
// 初始化 prescription 对象
|
|
|
if (!route.query.farmWorkId) {
|
|
if (!route.query.farmWorkId) {
|
|
|
dynamicValidateForm.prescription = {
|
|
dynamicValidateForm.prescription = {
|
|
@@ -618,11 +622,17 @@ const getPriceList = async (schemeId, pesticideFertilizerCodes) => {
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
quotationData.value = {...detailData.value, ...dynamicValidateForm};
|
|
quotationData.value = {...detailData.value, ...dynamicValidateForm};
|
|
|
- console.log('quotationData.value', quotationData.value)
|
|
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
const toEditPrescription = () => {
|
|
const toEditPrescription = () => {
|
|
|
isEdit.value = true;
|
|
isEdit.value = true;
|
|
|
|
|
+ nextTick(() => {
|
|
|
|
|
+ if (pageRef.value) {
|
|
|
|
|
+ pageRef.value.scrollTo({ top: 0, behavior: "auto" });
|
|
|
|
|
+ } else {
|
|
|
|
|
+ window.scrollTo(0, 0);
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
const quotationData = ref({});
|
|
const quotationData = ref({});
|
|
@@ -702,6 +712,13 @@ const cancelEdit = () => {
|
|
|
})
|
|
})
|
|
|
.then(() => {
|
|
.then(() => {
|
|
|
isEdit.value = false;
|
|
isEdit.value = false;
|
|
|
|
|
+ nextTick(() => {
|
|
|
|
|
+ if (pageRef.value) {
|
|
|
|
|
+ pageRef.value.scrollTop = 0;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ window.scrollTo(0, 0);
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
})
|
|
})
|
|
|
.catch(() => {
|
|
.catch(() => {
|
|
|
console.log("取消编辑");
|
|
console.log("取消编辑");
|
|
@@ -859,15 +876,44 @@ const resetItemForm = (index) => {
|
|
|
|
|
|
|
|
const servicePricePerMu = ref(null);
|
|
const servicePricePerMu = ref(null);
|
|
|
|
|
|
|
|
-// 计算服务费用总计:亩单价 * 亩数
|
|
|
|
|
-const getServiceTotal = () => {
|
|
|
|
|
|
|
+// 服务费用总计(数值):亩单价 * 亩数
|
|
|
|
|
+const serviceCostTotal = computed(() => {
|
|
|
const price = Number(servicePricePerMu.value || 0);
|
|
const price = Number(servicePricePerMu.value || 0);
|
|
|
const area = Number(detailData.value?.farm?.mianji || detailData.value?.area || 0);
|
|
const area = Number(detailData.value?.farm?.mianji || detailData.value?.area || 0);
|
|
|
- if (!price || !area) return "--";
|
|
|
|
|
- const total = (price * area).toFixed(2);
|
|
|
|
|
- return total;
|
|
|
|
|
|
|
+ if (!price || !area) return 0;
|
|
|
|
|
+ return Number((price * area).toFixed(2));
|
|
|
|
|
+});
|
|
|
|
|
+
|
|
|
|
|
+// 显示用的服务费用(字符串或 "--")
|
|
|
|
|
+const getServiceTotal = () => {
|
|
|
|
|
+ const total = serviceCostTotal.value;
|
|
|
|
|
+ return total ? total.toFixed(2) : "--";
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
|
|
+// 药肥费用总计:∑(单价 * 单亩用量 * 亩数)
|
|
|
|
|
+const pesticideCostTotal = computed(() => {
|
|
|
|
|
+ const list = dynamicValidateForm.prescription?.pesticideFertilizerList || [];
|
|
|
|
|
+ const area = Number(detailData.value?.farm?.mianji || detailData.value?.area || 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));
|
|
|
|
|
+});
|
|
|
|
|
+
|
|
|
const submitForm = (formEl) => {
|
|
const submitForm = (formEl) => {
|
|
|
if (!formEl) return;
|
|
if (!formEl) return;
|
|
|
formEl.validate(async (valid) => {
|
|
formEl.validate(async (valid) => {
|
|
@@ -969,6 +1015,13 @@ const submit = () => {
|
|
|
await getDetail();
|
|
await getDetail();
|
|
|
ElMessage.success("保存成功");
|
|
ElMessage.success("保存成功");
|
|
|
isEdit.value = false;
|
|
isEdit.value = false;
|
|
|
|
|
+ nextTick(() => {
|
|
|
|
|
+ if (pageRef.value) {
|
|
|
|
|
+ pageRef.value.scrollTop = 0;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ window.scrollTo(0, 0);
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
|
|
|