ct 4 روز پیش
والد
کامیت
3f2056d115
1فایلهای تغییر یافته به همراه107 افزوده شده و 29 حذف شده
  1. 107 29
      src/views/components/his/storeOrderDetails.vue

+ 107 - 29
src/views/components/his/storeOrderDetails.vue

@@ -341,6 +341,7 @@
                           :key="dict.dictValue"
                           :label="dict.dictLabel"
                           :value="dict.dictValue"
+                          :disabled="dict.dictLabel == '待推送'"
                         />
                       </el-select>
                    </el-form-item>
@@ -355,7 +356,7 @@
                       </el-select>
                    </el-form-item>
                    <el-form-item label="物流跟踪状态" prop="deliveryType" >
-                   <el-select v-model="editForm.deliveryType" placeholder="请选择状态" clearable size="small" filterable>
+                    <el-select v-model="editForm.deliveryType" placeholder="请选择状态" clearable size="small" filterable>
                         <el-option
                           v-for="dict in deliveryTypeOptions "
                           :key="dict.dictValue"
@@ -365,7 +366,14 @@
                       </el-select>
                    </el-form-item>
                    <el-form-item label="详情地址" prop="userAddress"  >
-                    <el-input v-model="editForm.userAddress" placeholder="请输入" />
+                    <el-cascader
+                      ref="citySelect"
+                      v-model="cityIds"
+                      :options="citys"
+                      @change="handleCityChange"
+                      clearable>
+                    </el-cascader>
+                    <el-input v-model="editForm.userAddress" placeholder="请输入详细地址(不含省/市/区)" />
                    </el-form-item>
                    <el-form-item label="收货人电话" prop="userPhone"  >
                     <el-input v-model="editForm.userPhone" placeholder="请输入" />
@@ -427,6 +435,7 @@ import packageOrderDetails from '../his/packageOrderDetails2.vue';
 import prescribeDetails from '../his/prescribeDetails.vue';
 import msgDetails from '../../components/his/followMsgDetails.vue';
 import { getTcmScheduleList } from "@/api/company/schedule";
+import {getCitys} from "@/api/store/city";
   export default {
     name: "orderDe",
     props:["data"],
@@ -543,8 +552,12 @@ import { getTcmScheduleList } from "@/api/company/schedule";
           deliveryName:null,
           deliverySn:null,
           orderId:null,
-        }
+        },
+        cityIds:[],
+        citys:[],
+        userAddress:null,
       }
+      
     },
 
     created() {
@@ -599,7 +612,36 @@ import { getTcmScheduleList } from "@/api/company/schedule";
 
     },
     methods: {
+      getCitys() {
+        return getCitys().then(res => {
+          this.citys = res.data || [];
+          return this.citys;
+        });
+      },
+      // 新增:切换省市区
+      handleCityChange(val) {
+        this.cityIds = Array.isArray(val) ? val : [];
+      },
+
+      // 新增:根据已选的 cityIds 从 citys 中获取对应的 label 数组 [省, 市, 区]
+      getCityLabelsByIds() {
+        if (!this.cityIds || this.cityIds.length === 0) return [];
+        const [pVal, cVal, aVal] = this.cityIds;
+        const p = this.citys.find(p => p.value === pVal);
+        const c = p?.children?.find(c => c.value === cVal);
+        const a = c?.children?.find(a => a.value === aVal);
+        return [p?.label, c?.label, a?.label].filter(Boolean);
+      },
 
+      // 新增:拼装完整地址 = 省 市 区 + 详细地址
+      buildFullAddress() {
+        const region = this.getCityLabelsByIds().join(' ');
+        const detail = (this.editForm.userAddress || '').trim();
+        console.log(region)
+        console.log(detail)
+        return region && detail ? `${region} ${detail}` : (region || detail || '');
+      },
+      
       followMsg(row){
          const userId = this.item.userId;
          const followDoctorId =this.item.followDoctorId;
@@ -706,34 +748,70 @@ import { getTcmScheduleList } from "@/api/company/schedule";
       });
     },
 
-    //修改订单状态
-    submitEditForm(){
-        this.$refs["editForm"].validate(valid => {
-        if (valid) {
-          updateStoreOrder(this.editForm).then(response => {
-            if (response.code === 200) {
-              this.msgSuccess("操作成功");
-               this.edit.open = false;
-              getOrder(this.item.orderId).then(response => {
-                this.item=response.data
-                that.getlogList(this.item.orderId);
-                that.$parent.$parent.getList();
-              });
-            }
-          });
-        }
-      });
+    // 修改订单状态
+    submitEditForm() {
+      this.$refs["editForm"].validate(valid => {
+        if (!valid) return;
+
+        // 提交前拼接完整地址
+        const payload = {
+          ...this.editForm,
+          userAddress: this.buildFullAddress(),
+        };
+
+        updateStoreOrder(payload).then(response => {
+          if (response.code === 200) {
+            this.msgSuccess("操作成功");
+            this.edit.open = false;
+            getOrder(this.item.orderId).then(response => {
+              this.item = response.data;
+              this.getlogList(this.item.orderId);
+              this.$parent.$parent.getList();
+            });
+          }
+        });
+        });
     },
-    editOrder(){
-        this.edit.open=true;
-        this.editForm.orderId=this.item.orderId;
-        this.editForm.remark=this.item.remark;
-        this.editForm.userAddress = this.item.userAddress.toString();
-        this.editForm.userPhone = this.item.userPhone.toString();
-        this.editForm.status = this.item.status.toString();
-        this.editForm.deliveryType = this.item.deliveryType.toString();
-        this.editForm.deliveryStatus = this.item.deliveryStatus.toString();
+    editOrder() {
+      this.edit.open = true;
+      this.editForm.orderId = this.item.orderId;
+      this.editForm.remark = this.item.remark;
+
+      // 先设置其他同步的字段
+      this.editForm.userPhone = this.item.userPhone != null ? this.item.userPhone.toString() : "";
+      this.editForm.status = this.item.status != null ? this.item.status.toString() : "";
+      this.editForm.deliveryType = this.item.deliveryType;
+      this.editForm.deliveryStatus = this.item.deliveryStatus;
+
+      // 等城市数据加载后再解析地址
+      const currentAddress = (this.item.userAddress || "").toString().trim();
+      this.getCitys().then(() => {
+        if (!currentAddress) {
+          this.cityIds = [];
+          this.editForm.userAddress = "";
+          return;
+        }
 
+        // 假设格式为:省 市 区 详细地址(空格分隔)
+        const parts = currentAddress.split(/\s+/);
+        const detail = parts.pop() || ""; // 最后一段作为详细地址
+        const provLabel = parts[0];
+        const cityLabel = parts[1];
+        const areaLabel = parts[2];
+
+        const province = this.citys.find(p => p.label === provLabel);
+        const city = province?.children?.find(c => c.label === cityLabel);
+        const area = city?.children?.find(a => a.label === areaLabel);
+
+        if (province && city && area) {
+          this.cityIds = [province.value, city.value, area.value];
+        } else {
+          console.warn("未匹配到完整省市区:", { provLabel, cityLabel, areaLabel });
+          this.cityIds = [];
+        }
+        // 把详细地址写回到输入框(只保留详细地址,不含省市区)
+        this.editForm.userAddress = detail;
+      });
     },
     updateExpress(){
       var that=this;