Browse Source

叮当国医需求

wjj 11 giờ trước cách đây
mục cha
commit
c462e73574

+ 84 - 21
src/views/hisStore/components/addUserAddress.vue

@@ -15,7 +15,7 @@
                   v-for="item in province"
                   :key="item.cityId"
                   :label="item.name"
-                  :value="item.cityId">
+                  :value="item.name">
                 </el-option>
               </el-select>
           </el-col>
@@ -25,7 +25,7 @@
                   v-for="item in city"
                   :key="item.cityId"
                   :label="item.name"
-                  :value="item.cityId">
+                  :value="item.name">
                 </el-option>
               </el-select>
           </el-col>
@@ -35,7 +35,7 @@
                   v-for="item in district"
                   :key="item.cityId"
                   :label="item.name"
-                  :value="item.cityId">
+                  :value="item.name">
                 </el-option>
               </el-select>
           </el-col>
@@ -58,16 +58,23 @@ export default {
   name: "add",
   data() {
     return {
+      isEdit: false,
+      editAddressId: null,
       citys:[],
       province:[],
       city:[],
       district:[],
       // 表单参数
       form: {
+        userId: null,
+        realName: null,
+        phone: null,
+        detail: null,
         province:null,
         city:null,
         district:null,
         cityId:null,
+        isDefault: null,
       },
       // 表单校验
       rules: {
@@ -95,26 +102,24 @@ export default {
   },
   methods: {
     districtChange(val){
-      const item = this.district.find(i => i.cityId === val)
-      this.form.district=item.name;
+      const item = this.district.find(i => i.name === val)
     },
     cityChange(val){
-      const item = this.city.find(i => i.cityId === val)
-      this.district = item.children
+      const item = this.city.find(i => i.name === val)
+      this.district = item.children || []
       this.form.district=null;
-      this.form.city=item.name;
-      this.form.cityId=val;
+      this.form.cityId=item.cityId;
     },
     provinceChange(val){
-      const item = this.citys.find(i => i.cityId === val)
-      this.city = item.children
+      const item = this.citys.find(i => i.name === val)
+      this.city = item.children || []
       this.district=[];
       this.form.city=null;
       this.form.district=null;
-      this.form.province=item.name;
+      this.form.cityId=null;
     },
     getCityList(){
-      getCitys().then(res => {
+      return getCitys().then(res => {
           this.loading = false;
           this.citys = this.convertCityData(res.data)
           this.province=this.citys.filter(item => item.parentId===0 )
@@ -130,18 +135,76 @@ export default {
         }
       });
     },
-    init(userId){
-      this.form.userId=userId;
+    async init(userId, addressData){
+      this.form.userId = userId;
+      if (this.province.length === 0) {
+        await this.getCityList();
+      }
+      this.$nextTick(() => {
+        if (this.$refs["form"]) {
+          this.$refs["form"].clearValidate();
+        }
+      });
+      if (addressData) {
+        this.isEdit = true;
+        this.editAddressId = addressData.addressId;
+        this.form.realName = addressData.realName;
+        this.form.phone = addressData.phone;
+        this.form.detail = addressData.detail;
+        this.form.isDefault = addressData.isDefault;
+        this.findAndSetCityIds(addressData);
+      } else {
+        this.isEdit = false;
+        this.editAddressId = null;
+        if (this.$refs["form"]) {
+          this.$refs["form"].resetFields();
+        }
+        this.form.realName = null;
+        this.form.phone = null;
+        this.form.detail = null;
+        this.form.province = null;
+        this.form.city = null;
+        this.form.district = null;
+        this.city = [];
+        this.district = [];
+      }
+    },
+    findAndSetCityIds(addressData) {
+      const provinceItem = this.province.find(p => p.name === addressData.province);
+      if (provinceItem) {
+        this.form.province = provinceItem.name;
+        this.city = provinceItem.children || [];
+        const cityItem = this.city.find(c => c.name === addressData.city);
+        if (cityItem) {
+          this.form.city = cityItem.name;
+          this.form.cityId = cityItem.cityId;
+          this.district = cityItem.children || [];
+          const districtItem = this.district.find(d => d.name === addressData.district);
+          if (districtItem) {
+            this.form.district = districtItem.name;
+          }
+        }
+      }
     },
     submitForm() {
       this.$refs["form"].validate(valid => {
         if (valid) {
-          addUserAddress(this.form).then(response => {
-            if (response.code === 200) {
-              this.msgSuccess("新增成功");
-              this.$emit("addUserAddress")
-            }
-          });
+          if (this.isEdit) {
+            this.form.addressId = this.editAddressId;
+            updateUserAddress(this.form).then(response => {
+              if (response.code === 200) {
+                this.msgSuccess("修改成功");
+                this.$emit("addUserAddress");
+              }
+            });
+          } else {
+            addUserAddress(this.form).then(response => {
+              if (response.code === 200) {
+                this.msgSuccess("新增成功");
+                this.$emit("addUserAddress");
+              }
+            });
+          }
         }
       });
     },

+ 6 - 0
src/views/hisStore/components/productOrder.vue

@@ -163,6 +163,11 @@
                   {{ order.remark }}
                 </span>
           </el-descriptions-item>
+          <el-descriptions-item v-if="projectCode === 'ddgy'" label="交易码">
+                <span v-if="order!=null ">
+                  {{ order.transactionCode }}
+                </span>
+          </el-descriptions-item>
           <el-descriptions-item label="销售名称" v-if="order!=null && order.orderType != 0">
                 <span >
                   {{ order.companyUserName }}
@@ -1120,6 +1125,7 @@ export default {
   data() {
     return {
       zdyInfo: process.env.VUE_APP_FS_USER_INFO,
+      projectCode: process.env.VUE_APP_PROJECT_CODE,
       // 遮罩层
       productOrderLoading: true,
       isStores: true,

+ 53 - 12
src/views/hisStore/storeOrder/list.vue

@@ -192,7 +192,7 @@
               v-hasPermi="['store:storeOrder:exportItems']"
             >导出订单明细</el-button>
           </el-col>
-          <!-- <el-col :span="1.5">
+          <el-col :span="1.5">
             <el-button
               type="success"
               icon="el-icon-s-check"
@@ -202,7 +202,7 @@
               v-hasPermi="['store:storeOrder:batchAudit']"
             >确认审核
             </el-button>
-          </el-col> -->
+          </el-col>
         <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
         </el-row>
         <el-tabs type="card" v-model="activeName" @tab-click="handleClick">
@@ -411,6 +411,16 @@
                        {{scope.row.province}} {{scope.row.city}} {{scope.row.district}} {{scope.row.detail}}
                     </template>
                 </el-table-column>
+                <el-table-column label="操作" align="center" width="80px" >
+                  <template slot-scope="scope">
+                    <el-button
+                      size="mini"
+                      type="text"
+                      icon="el-icon-edit"
+                      @click="handleEditUserAddress(scope.row)"
+                    >编辑</el-button>
+                  </template>
+                </el-table-column>
               </el-table>
               </el-radio-group>
             </el-form-item>
@@ -463,6 +473,9 @@
                 </el-col>
               </el-row>
             </el-form-item>
+            <el-form-item label="交易码" prop="transactionCode" v-if ="projectCode === 'ddgy'" style="width:380px;">
+              <el-input  v-model="form.transactionCode" placeholder="交易码"  />
+            </el-form-item>
             <el-form-item label="支付方式" prop="payType">
               <el-select   v-model="form.payType" placeholder="请选择支付方式" clearable size="small" >
               <el-option
@@ -480,13 +493,13 @@
                 <el-input-number  v-model="form.totalPrice" placeholder="修改商品总价" size="medium" :precision="2" :min=0.01 :step="0.1" />
             </el-form-item>
             <el-form-item label="定金" prop="payPrice" v-if ="projectCode === 'ddgy'">
-                <el-input-number  v-model="form.payPrice" @change="syncAmountByTotalPriceAndDeposit" placeholder="修改实际支付金额" size="medium" :precision="2" :min=0.01 :step="0.1" />
+                <el-input-number  v-model="form.payPrice" @change="syncAmountByTotalPriceAndDeposit" placeholder="修改实际支付金额" size="medium" :precision="2" :min=0 :step="0.1" />
             </el-form-item>
             <el-form-item label="物流代收" prop="amount" v-if="form.payType == '3' && projectCode !== 'ddgy'" >
               <el-input-number  v-model="form.amount" placeholder="平台支付价格" size="medium" :precision="2" :min=0.01 :step="0.1" />
             </el-form-item>
             <el-form-item label="代收货款" prop="amount" v-if="form.payType == '3' && projectCode === 'ddgy'">
-                <el-input-number  v-model="form.amount" placeholder="代收货款价格" size="medium" :precision="2" :min=0.01 :step="0.1" />
+                <el-input-number  v-model="form.amount" placeholder="代收货款价格" size="medium" :precision="2" :min=0 :step="0.1" :disabled="true" />
             </el-form-item>
             <el-form-item label="订单备注" prop="mark">
               <el-input  type="textarea" rows="2" v-model="form.mark" placeholder="" />
@@ -674,6 +687,18 @@ export default {
         products: [
           { required: true, message: "商品不能为空" }
         ],
+        payPrice: [
+          {
+            validator: (rule, value, callback) => {
+              if (this.projectCode === 'ddgy' && value != null && this.form.totalPrice != null && Number(value) > Number(this.form.totalPrice)) {
+                callback(new Error('定金金额不能大于总价'));
+              } else {
+                callback();
+              }
+            },
+            trigger: 'change'
+          }
+        ],
 
       }
     };
@@ -758,11 +783,19 @@ export default {
         this.msgError("请选择会员");
         return;
       }
+      this.userAddress.title = "创建收货地址";
       this.userAddress.open=true;
       setTimeout(() => {
         this.$refs.addUserAddress.init(this.form.userId);
       }, 500);
     },
+    handleEditUserAddress(row){
+      this.userAddress.title = "编辑收货地址";
+      this.userAddress.open=true;
+      setTimeout(() => {
+        this.$refs.addUserAddress.init(this.form.userId, row);
+      }, 500);
+    },
     addUserAddress(){
       this.userAddress.open=false;
       //获取地址
@@ -898,7 +931,7 @@ export default {
         return;
       }
       const amount = Number((this.form.totalPrice - this.form.payPrice).toFixed(2));
-      this.$set(this.form, "amount", amount > 0 ? amount : null);
+      this.$set(this.form, "amount", amount >= 0 ? amount : null);
     },
     /** 搜索按钮操作 */
     handleQuery() {
@@ -1031,14 +1064,22 @@ export default {
         }).catch(function() {});
     },
 
-    /** 订单确认审核 */
+    /** 订单确认审核(支持单行和批量) */
     handleOrderAudit(row){
-      // if (this.ids.length === 0) {
-      //   this.$message.warning('请至少勾选一条订单进行审核');
-      //   return;
-      // }
-      const ids = [row.id];
-      this.$confirm('是否确认审核选中的订单?', "提示", {
+      let ids;
+      let tipMsg;
+      if (row && row.id) {
+        ids = [row.id];
+        tipMsg = '是否确认审核该订单?';
+      } else {
+        ids = this.ids.filter(id => id != null);
+        if (ids.length === 0) {
+          this.$message.warning('请至少勾选一条订单进行审核');
+          return;
+        }
+        tipMsg = `是否确认审核选中的 ${ids.length} 条订单?`;
+      }
+      this.$confirm(tipMsg, "提示", {
         confirmButtonText: "确定",
         cancelButtonText: "取消",
         type: "warning"