Procházet zdrojové kódy

在收单表格中加上核价功能

Yannay před 1 měsícem
rodič
revize
05b4ce1b85
1 změnil soubory, kde provedl 108 přidání a 3 odebrání
  1. 108 3
      pages/orderDetailRefactored/components/PageThree.vue

+ 108 - 3
pages/orderDetailRefactored/components/PageThree.vue

@@ -72,6 +72,11 @@
72 72
               <u-icon name="plus" size="40rpx" color="#999" />
73 73
             </view>
74 74
           </view>
75
+          <view v-if="displayImages.length > 0" class="pricing-button-wrap">
76
+            <view class="pay-now-button pricing-button" @click.stop="handlePricing">
77
+              <text class="button-text">核价</text>
78
+            </view>
79
+          </view>
75 80
         </view>
76 81
       </view>
77 82
     </view>
@@ -126,6 +131,10 @@
126 131
       confirmText="确认并继续付款" :show="riskWarningModalVisible" title="付款警示" :content="'湖南耒阳地区身份证号请确认!'">
127 132
     </u-modal>
128 133
 
134
+    <!-- 核价对话框 -->
135
+    <add-inquiry-dialog ref="pricingDialog" :clueId="pricingClueId" :editOrAdd="pricingEditOrAdd"
136
+      :editInfo="pricingEditInfo" :type="2" />
137
+
129 138
     <u-modal :show="payNowModalVisible" title="确认支付信息" :showConfirmButton="false">
130 139
       <view class="modal-content">
131 140
         <view class="payment-amount-display">¥{{ paymentAmount }}</view>
@@ -162,11 +171,13 @@
162 171
 <script>
163 172
 import PicComp from './PicComp.vue'
164 173
 import imageUpload from '../utils/imageUpload.js'
174
+import addInquiryDialog from '@/components/add-inquiry-dialog/index.vue'
165 175
 
166 176
 export default {
167 177
   name: 'PageThree',
168 178
   components: {
169
-    PicComp
179
+    PicComp,
180
+    addInquiryDialog
170 181
   },
171 182
   props: {
172 183
     orderDetail: {
@@ -207,7 +218,11 @@ export default {
207 218
       payNowModalVisible: false,
208 219
       riskWarningModalVisible: false,
209 220
       unpaidRating: 0,
210
-      followUpNotes: ''
221
+      followUpNotes: '',
222
+      // 核价相关
223
+      pricingClueId: '',
224
+      pricingEditOrAdd: 'receptFormAdd',
225
+      pricingEditInfo: {}
211 226
     }
212 227
   },
213 228
   computed: {
@@ -658,7 +673,88 @@ export default {
658 673
           ...this.paymentInfo
659 674
         }
660 675
       })
661
-    }
676
+    },
677
+
678
+    /**
679
+     * 核价
680
+     */
681
+    async handlePricing() {
682
+      const brandList = await this.$getDicts("crm_form_brand");
683
+
684
+
685
+      if (!this.currentReceipt || !this.currentReceipt.clueId) {
686
+        uni.$u.toast('缺少线索ID')
687
+        return
688
+      }
689
+      if (!this.currentReceipt.brand) {
690
+        uni.$u.toast('缺少品牌信息')
691
+        return
692
+      }
693
+      if (!this.displayImages || this.displayImages.length === 0) {
694
+        uni.$u.toast('请先上传图片')
695
+        return
696
+      }
697
+
698
+      this.pricingClueId = this.currentReceipt.clueId
699
+
700
+      // brand 是品牌的 id(dictValue),itemBrand 是品牌的 label(dictLabel)
701
+      const brandDictLabel = this.currentReceipt.brand
702
+      const brandDictValue = brandList.find(item => item.dictLabel === this.currentReceipt.brand).dictValue;
703
+
704
+      // 将图片转换为 imgsUrl 格式
705
+      const imgsUrl = this.displayImages.map(item => item.fileUrl).filter(url => url)
706
+
707
+      // 检查是否已有核价记录
708
+      try {
709
+        const data = {
710
+          clueId: this.currentReceipt.clueId,
711
+          type: 2
712
+        }
713
+        const res = await uni.$u.api.inquiryDetail(data)
714
+        if (res.code === 200 && res.data) {
715
+          // 编辑模式:保留原有数据,但更新品牌和图片
716
+          this.pricingEditOrAdd = 'editForm'
717
+          this.pricingEditInfo = {
718
+            ...res.data,
719
+            dictLabel: brandDictLabel || res.data.dictLabel,
720
+            dictValue: brandDictValue || res.data.dictValue,
721
+            imgsUrl: imgsUrl.length > 0 ? imgsUrl : (res.data.imgsUrl || [])
722
+          }
723
+          this.$nextTick(() => {
724
+            this.$refs.pricingDialog.showDialog()
725
+          })
726
+        } else {
727
+          // 新增模式:设置品牌和图片
728
+          this.pricingEditOrAdd = 'editForm'
729
+          this.pricingEditInfo = {
730
+            dictLabel: brandDictLabel,
731
+            dictValue: brandDictValue,
732
+            imgsUrl: imgsUrl,
733
+            model: '',
734
+            code: '',
735
+            price: ''
736
+          }
737
+          this.$nextTick(() => {
738
+            this.$refs.pricingDialog.showDialog()
739
+          })
740
+        }
741
+      } catch (error) {
742
+        // 如果没有记录,则新增
743
+        this.pricingEditOrAdd = 'receptFormAdd'
744
+        this.pricingEditInfo = {
745
+          dictLabel: brandDictLabel,
746
+          dictValue: brandDictValue,
747
+          imgsUrl: imgsUrl,
748
+          model: '',
749
+          code: '',
750
+          price: ''
751
+        }
752
+        this.$nextTick(() => {
753
+          this.$refs.pricingDialog.showDialog()
754
+        })
755
+      }
756
+    },
757
+
662 758
   }
663 759
 }
664 760
 </script>
@@ -794,6 +890,15 @@ export default {
794 890
   cursor: pointer;
795 891
 }
796 892
 
893
+.pricing-button-wrap {
894
+  width: 100%;
895
+  margin-top: 20rpx;
896
+}
897
+
898
+.pricing-button {
899
+  margin-top: 0;
900
+}
901
+
797 902
 .payment-card {
798 903
   margin-top: 20rpx;
799 904
 }