Przeglądaj źródła

feat: 增加对接服务报价单弹窗

刘秀芳 1 dzień temu
rodzic
commit
e6709930ea

+ 9 - 0
src/api/modules/z_farm_work_record_cost.js

@@ -0,0 +1,9 @@
+const config = require("../config")
+const url = config.base_dev_url + "z_farm_work_record_cost"
+
+module.exports = {
+    listByOrderId: {
+        url: url + "/listByOrderId",
+        type: "get",
+    },
+}

BIN
src/assets/img/home/bird.png


BIN
src/assets/img/home/wechat.png


+ 90 - 58
src/components/popup/priceSheetPopup.vue

@@ -20,18 +20,18 @@
                     <div class="quotation-info">
                         <div class="info-item">
                             <span class="info-label">报价组织</span>
-                            <span class="info-value">{{ quotationData.organization || '河南农资农服组织' }}</span>
+                            <span class="info-value">{{ quotationData.serviceMain || '--' }}</span>
                         </div>
                         <div class="info-item">
                             <span class="info-label">报价农事</span>
-                            <span class="info-value">{{ quotationData.farmWorkName || '梢期杀虫' }}</span>
+                            <span class="info-value">{{ quotationData?.farmWorkName || '--' }}</span>
                         </div>
                         <div class="info-item catalog-label">
                             <span class="info-label">报价目录</span>
                         </div>
                         <div class="total-bar">
                             <span class="total-label">报价合计:</span>
-                            <span class="total-value">{{ quotationData.totalPrice || '1258' }}</span>
+                            <span class="total-value">{{ priceData?.totalCost || '--' }}</span>
                             <span class="total-unit">元</span>
                         </div>
                     </div>
@@ -40,7 +40,7 @@
                     <div class="fertilizer-cost-section">
                         <div class="section-header">
                             <div class="section-title">肥药费用</div>
-                            <div class="section-total">{{ quotationData.fertilizerTotal || '1582' }}<span class="unit-text">元</span></div>
+                            <div class="section-total">{{ priceData?.pesticideFertilizerCost || '--' }}<span class="unit-text">元</span></div>
                         </div>
                         <div class="cost-table">
                             <div class="table-header">
@@ -53,15 +53,15 @@
                             </div>
                             <div 
                                 class="table-row"
-                                v-for="(item, index) in prescriptionList"
+                                v-for="(item, index) in processedPrescriptionList"
                                 :key="index"
                             >
-                                <div class="col-1">{{ item.typeName || '营养' }}</div>
-                                <div class="col-2">{{ item.defaultName || '乙烯利' }}</div>
-                                <div class="col-3">{{ item.brand || '国光' }}</div>
-                                <div class="col-4">{{ item.price || '5元/ml' }}</div>
-                                <div class="col-5">{{ item.dosage || '300ml' }}</div>
-                                <div class="col-6">{{ item.total || '500' }}元</div>
+                                <div class="col-1">{{ item.typeName || '--' }}</div>
+                                <div class="col-2">{{ item.defaultName || '--' }}</div>
+                                <div class="col-3">{{ item.brand || '--' }}</div>
+                                <div class="col-4">{{ item.priceDisplay || '--' }}</div>
+                                <div class="col-5">{{ item.usageDisplay || '--' }}</div>
+                                <div class="col-6">{{ item.totalDisplay === '--' ? '--' : (item.totalDisplay + '元') }}</div>
                             </div>
                         </div>
                     </div>
@@ -70,19 +70,19 @@
                     <div class="service-cost-section">
                         <div class="section-header">
                             <div class="section-title">服务费用</div>
-                            <div class="section-total">{{ quotationData.serviceTotal || '1582' }}<span class="unit-text">元</span></div>
+                            <div class="section-total">{{ quotationData?.farmWorkServiceCost || '1582' }}<span class="unit-text">元</span></div>
                         </div>
                         <div class="service-details">
                             <div class="detail-item">
-                                <div class="detail-value">{{ quotationData.executionMethod || '无人机' }}</div>
+                                <div class="detail-value">{{ quotationData?.executionMethod || '--' }}</div>
                                 <div class="detail-label">执行方式</div>
                             </div>
                             <div class="detail-item">
-                                <div class="detail-value">{{ quotationData.muPrice || '500元/亩' }}</div>
+                                <div class="detail-value">{{ quotationData?.muPrice || '--元/亩' }}</div>
                                 <div class="detail-label">亩单价</div>
                             </div>
                             <div class="detail-item">
-                                <div class="detail-value">{{ quotationData.muCount || '10亩' }}</div>
+                                <div class="detail-value">{{ quotationData?.area ? (quotationData?.area + '亩') : '--' }}</div>
                                 <div class="detail-label">亩数</div>
                             </div>
                         </div>
@@ -98,13 +98,13 @@
                 <div class="action-buttons">
                     <div class="action-btn blue-btn">
                         <div class="icon-circle">
-                            <el-icon :size="24"><Star /></el-icon>
+                            <img src="@/assets/img/home/bird.png" alt="" />
                         </div>
                         <span class="btn-label">飞鸟用户</span>
                     </div>
                     <div class="action-btn green-btn">
                         <div class="icon-circle">
-                            <el-icon :size="24"><ChatDotRound /></el-icon>
+                            <img src="@/assets/img/home/wechat.png" alt="" />
                         </div>
                         <span class="btn-label">微信</span>
                     </div>
@@ -125,50 +125,81 @@
 import { Popup } from "vant";
 import { ref, computed } from "vue";
 
-const showPopup = ref(true);
+const showPopup = ref(false);
 
 // 报价数据
-const quotationData = ref({
-    organization: "河南农资农服组织",
-    farmWorkName: "梢期杀虫",
-    totalPrice: "1258",
-    fertilizerTotal: "1582",
-    serviceTotal: "1582",
-    executionMethod: "无人机",
-    muPrice: "500元/亩",
-    muCount: "10亩"
-});
+const quotationData = ref({});
+const priceData = ref({});
+
+// 处理后的处方列表(展平并匹配价格)
+const processedPrescriptionList = computed(() => {
+    if (!quotationData.value?.prescriptionList || !Array.isArray(quotationData.value.prescriptionList)) {
+        return [];
+    }
 
-// 处方列表
-const prescriptionList = ref([
-    {
-        typeName: "营养",
-        defaultName: "乙烯利",
-        brand: "国光",
-        price: "5元/ml",
-        dosage: "300ml",
-        total: "500"
-    },
-    {
-        typeName: "营养",
-        defaultName: "乙烯利",
-        brand: "国光",
-        price: "5元/ml",
-        dosage: "600ml",
-        total: "500"
+    // 创建价格映射表,方便快速查找
+    const priceMap = new Map();
+    if (priceData.value?.itemsList && Array.isArray(priceData.value.itemsList)) {
+        priceData.value.itemsList.forEach(item => {
+            priceMap.set(String(item.pesticideFertilizerId), item.price);
+        });
     }
-]);
+
+    // 展平 prescriptionList 中的所有 pesticideFertilizerList
+    const result = [];
+    quotationData.value.prescriptionList.forEach(prescription => {
+        if (prescription.pesticideFertilizerList && Array.isArray(prescription.pesticideFertilizerList)) {
+            prescription.pesticideFertilizerList.forEach(item => {
+                const pesticideFertilizerId = String(item.pesticideFertilizerId || '');
+                const price = priceMap.get(pesticideFertilizerId) || 0;
+                const muUsage = item.muUsage || 0;
+                const unit = item.unit || '';
+                
+                // 计算总价
+                const total = price * muUsage;
+
+                result.push({
+                    typeName: item.typeName || '--',
+                    defaultName: item.defaultName || item.pesticideFertilizerName || '--',
+                    brand: item.brand || '--',
+                    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 handleShowPopup = (data) => {
     if (data) {
-        quotationData.value = { ...quotationData.value, ...data };
-        if (data.prescriptionList) {
-            prescriptionList.value = data.prescriptionList;
-        }
+        console.log("dhandleShowPopuphandleShowPopuphandleShowPopupata", data);
+        quotationData.value = data;
+        fetchPriceData();
     }
     showPopup.value = true;
 };
 
+function fetchPriceData() {
+    if (!quotationData.value?.orderId) {
+        return;
+    }
+    VE_API.z_farm_work_record_cost.listByOrderId({ farmWorkOrderId: quotationData.value.orderId }).then(({ data }) => {
+        if (data && data.length > 0) {
+            priceData.value = data[0];
+        }
+    }).catch((error) => {
+        console.error('获取价格数据失败:', error);
+    });
+}
+
 const handleEdit = () => {
     // 编辑报价逻辑
     // 可以触发编辑事件或打开编辑页面
@@ -186,7 +217,7 @@ defineExpose({
 <style lang="scss" scoped>
 .price-sheet-popup {
     width: 90%;
-    max-height: 90vh;
+    max-height: 95vh;
     background: none;
     border-radius: 12px;
     overflow: hidden;
@@ -207,8 +238,8 @@ defineExpose({
 .price-sheet-content {
     display: flex;
     flex-direction: column;
-    max-height: 95vh;
-    height: 95vh;
+    max-height: 94vh;
+    // height: 95vh;
     .price-sheet-content-inner {
         background: #fff;
         border-radius: 12px;
@@ -528,13 +559,12 @@ defineExpose({
 
 // 底部操作按钮
 .bottom-actions {
-    padding: 16px 16px 20px 16px;
     flex-shrink: 0;
 
     .action-buttons {
+        padding: 16px;
         display: flex;
         justify-content: space-around;
-        margin-bottom: 16px;
 
         .action-btn {
             display: flex;
@@ -555,6 +585,9 @@ defineExpose({
                 .el-icon {
                     color: #fff;
                 }
+                img {
+                    width: 50px;
+                }
             }
 
             &.blue-btn .icon-circle {
@@ -578,10 +611,9 @@ defineExpose({
 
     .cancel-btn {
         text-align: center;
-        font-size: 16px;
-        color: #000;
+        font-size: 18px;
+        color: #fff;
         cursor: pointer;
-        padding: 8px 0;
     }
 }
 </style>

+ 1 - 1
src/views/old_mini/modify_work/completedWork.vue

@@ -301,7 +301,7 @@ const handleDemand = () => {
 
 const priceSheetPopupRef = ref(null);
 const showPriceSheetPopup = () => {
-    priceSheetPopupRef.value.handleShowPopup();
+    priceSheetPopupRef.value.handleShowPopup(detailData.value);
 };
 
 // 地图