戴艳蓉 преди 3 години
родител
ревизия
45fc995f94
променени са 2 файла, в които са добавени 89 реда и са изтрити 17 реда
  1. 1 1
      src/apis/service/sellOut/salesOrder/index.js
  2. 88 16
      src/views/sellOut/salesOrder/components/addForm.vue

+ 1 - 1
src/apis/service/sellOut/salesOrder/index.js

@@ -19,5 +19,5 @@ export default {
   // 线上商品详情
   goods_detail: (data, params) => http(api + "goodinfo", data, "post", params),
   // 线上商品获取活动
-  goods_active: (data, params) => http(api + "goodinfo", data, "post", params),
+  goods_active: (data, params) => http(api + "actquery", data, "post", params),
 };

+ 88 - 16
src/views/sellOut/salesOrder/components/addForm.vue

@@ -84,7 +84,11 @@
               </el-form-item>
             </el-col>
             <el-col :span="12">
-              <el-form-item label="销售商品" prop="good_code">
+              <el-form-item
+                :label="ruleForm.good_code === '' ? '销售商品' : ''"
+                prop="good_code"
+                :label-width="ruleForm.good_code === '' ? '95px' : '0'"
+              >
                 <el-input
                   v-if="ruleForm.good_code === ''"
                   v-model="ruleForm.good_code"
@@ -848,10 +852,7 @@ export default {
     getNewTime() {
       this.newTime = new Date().valueOf();
     },
-    number_change(e, key) {
-      this.ruleForm[key] = e + "" || "0";
-      this.$refs.ruleForm.validateField(key);
-    },
+
     async resetForm() {
       // 重置
       await this.$nextTick(() => {
@@ -942,13 +943,13 @@ export default {
       this.ruleForm.proof_type = "";
       this.$refs.ruleForm.validateField("proof_id");
       if (e.length === 1) {
-        await this.get_goods_active()
+        await this.get_goods_active();
       }
     },
     async get_goods_active() {
-      const { skuCode, supplierNo, platform_id } = this.ruleForm;
+      const { good_code, supplierNo, platform_id } = this.ruleForm;
       let model = {
-        skuCode,
+        skuCode: good_code,
         companyNo: supplierNo,
         platform_id,
       };
@@ -957,8 +958,8 @@ export default {
         let list =
           data && data.length > 0 ? JSON.parse(JSON.stringify(data)) : [];
         list.forEach((a) => {
-          a.value = a.activity_name;
-          a.label = a.activity_code;
+          a.value = a.activity_code;
+          a.label = a.activity_name;
         });
         this.goodtype_options[1].children = list;
       } else if (code >= 100 && code <= 104) {
@@ -1017,9 +1018,69 @@ export default {
       } else {
       }
     },
+    //商品类型选择
+    async handleChange(e) {
+      const { goodtype, good_num } = this.ruleForm;
+      if (good_num === "0" || good_num === "") {
+        this.ruleForm.good_price = "0";
+      } else {
+        if (goodtype.length === 2) {
+          let key_1 = goodtype[1];
+          if (key_1 === "1" || key_1 === "2") {
+            this.ruleForm.good_price = "0";
+          } else {
+            const { isok, price } = await this.set_salegetprice();
+            this.ruleForm.good_price = isok ? price : "0";
+          }
+        } else {
+          this.ruleForm.good_price = "0";
+        }
+      }
+    },
+    async number_change(e, key) {
+      this.ruleForm[key] = e + "" || "0";
+      this.$refs.ruleForm.validateField(key);
+      const { goodtype, good_num } = this.ruleForm;
 
-    handleChange(e) {
-      console.log(e);
+      if (good_num === "0" || good_num === "") {
+        this.ruleForm.good_price = "0";
+      } else {
+        if (goodtype.length === 2) {
+          console.log(good_num);
+          console.log(goodtype);
+          let key_1 = goodtype[1];
+          if (key_1 === "2" || key_1 === "3") {
+            this.ruleForm.good_price = "0";
+          } else {
+            const { isok, price } = await this.set_salegetprice();
+            this.ruleForm.good_price = isok ? price : "0";
+          }
+        } else {
+          this.ruleForm.good_price = "0";
+        }
+      }
+    },
+    async get_goods_active() {
+      const { good_code, supplierNo, platform_id } = this.ruleForm;
+      let model = {
+        skuCode: good_code,
+        companyNo: supplierNo,
+        platform_id,
+      };
+      let { code, data, message } = await asyncRequest.goods_active(model);
+      if (code === 0) {
+        let list =
+          data && data.length > 0 ? JSON.parse(JSON.stringify(data)) : [];
+        list.forEach((a) => {
+          a.value = a.activity_code;
+          a.label = a.activity_name;
+        });
+        this.goodtype_options[1].children = list;
+      } else if (code >= 100 && code <= 104) {
+        await this.logout();
+      } else {
+        this.$message.warning(message);
+      }
     },
     change_good_code() {
       const { supplierNo, platform_id } = this.ruleForm;
@@ -1116,7 +1177,13 @@ export default {
             JSON.stringify(this.ruleForm)
           );
           const { order_addr } = JSON.parse(JSON.stringify(this.addrForm));
-
+          if (sendtype.length !== 2) {
+            this.$message.warning("请选择商品类型!");
+            this.loading = false;
+            return;
+          }
+          let key_0 = goodtype[0];
+          let key_1 = goodtype[1];
           if (order_addr.length === 0 && sendtype === "1") {
             this.$message.warning("至少填写一条地址信息!");
             this.loading = false;
@@ -1125,6 +1192,7 @@ export default {
           let model = JSON.parse(JSON.stringify(this.ruleForm));
           model.addrlist = [];
           model.customer_code = model.customer_code.toString();
+
           delete model["proof_type"];
           delete model["proof_url"];
           delete model["good_price"];
@@ -1160,10 +1228,13 @@ export default {
           }
           let priceres = await this.set_salegetprice();
           if (!priceres.isok) {
+            this.loading = false;
             return;
           }
+          model.is_activity = key_0 === "is_activity_0" ? "0" : "1";
+          model.goodtype = key_0 === "is_activity_1" ? "1" : key_1;
+          model.act_code = key_0 === "is_activity_1" ? Fkey_1 : "";
           let res = await asyncRequest.add(model);
-
           this.loading = false;
           if (res && res.code === 0) {
             this.$notify.success({
@@ -1189,11 +1260,12 @@ export default {
         isok: true,
         price: "0",
       };
-      const { good_num, good_code, is_activity } = this.ruleForm;
+      const { good_num, good_code, goodtype } = this.ruleForm;
+      let key_1 = goodtype[1];
       let model = {
         skuCode: good_code,
         sale_num: good_num,
-        is_activity: "0",
+        is_activity: key_1,
       };
       let { code, message, data } = await asyncRequest.salegetprice(model);