戴艳蓉 3 年之前
父節點
當前提交
6d0bfa589f
共有 4 個文件被更改,包括 102 次插入108 次删除
  1. 1 1
      src/App.vue
  2. 4 1
      src/apis/service/sellOut/salesOrder/index.js
  3. 0 1
      src/mixins/resToken.js
  4. 97 105
      src/views/sellOut/salesOrder/components/addForm.vue

+ 1 - 1
src/App.vue

@@ -15,7 +15,6 @@ export default {
     };
   },
   async created() {
-
     if (JudgeEnvironment() === "isDingDing") {
       await this.testing();
     } else {
@@ -73,6 +72,7 @@ export default {
     async logout() {
       if (this.$route.path !== "/login") {
         await this.$store.dispatch("user/logout");
+        console.log(this.$route.fullPath);
         this.$router.push(`/login`);
       }
     },

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

@@ -16,5 +16,8 @@ export default {
   status: (data, params) => http(api + "accountstatus", data, "post", params),
   //验证售价
   salegetprice: (data, params) => http(api + "salegetprice", data, "post", params),
+  // 线上商品详情
+  goods_detail: (data, params) => http(api + "goodinfo", data, "post", params),
+  // 线上商品获取活动
+  goods_active: (data, params) => http(api + "goodinfo", data, "post", params),
 };
-   

+ 0 - 1
src/mixins/resToken.js

@@ -3,7 +3,6 @@ export default {
     async logout() {
       if (this.$route.path !== "/login") {
         await this.$store.dispatch("user/logout");
-
         this.$router.push(`/login?redirect=${this.$route.fullPath}`);
       }
     },

+ 97 - 105
src/views/sellOut/salesOrder/components/addForm.vue

@@ -168,27 +168,20 @@
                 </show-data-table>
               </el-form-item>
             </el-col>
-
-            <!-- <el-col :span="12">
-              <el-form-item label="参与活动" prop="is_activity">
-                <el-select
-                  v-model="ruleForm.is_activity"
-                  placeholder="是否参与活动"
-                  @change="activity_change"
-                  style="width: 100%"
-                >
-                  <el-option
-                    v-for="item in activity_options"
-                    :key="item.value"
-                    :label="item.label"
-                    :value="item.value"
-                  >
-                  </el-option>
-                </el-select>
-              </el-form-item>
-            </el-col> -->
             <el-col :span="12" v-if="ruleForm.good_code">
               <el-row>
+                <el-col :span="24">
+                  <el-form-item label="活动类型" prop="goodtype">
+                    <el-cascader
+                      v-model="ruleForm.goodtype"
+                      :options="goodtype_options"
+                      placeholder="活动类型"
+                      style="width: 100%"
+                      :props="{ expandTrigger: 'hover' }"
+                      @change="handleChange"
+                    ></el-cascader>
+                  </el-form-item>
+                </el-col>
                 <el-col :span="24">
                   <el-form-item label="凭证文件" prop="proof_id">
                     <el-tooltip
@@ -261,24 +254,7 @@
                     </ul>
                   </el-form-item>
                 </el-col>
-                <el-col :span="24">
-                  <el-form-item label="商品类型" prop="goodtype">
-                    <el-select
-                      v-model="ruleForm.goodtype"
-                      placeholder="商品类型"
-                      style="width: 100%"
-                    >
-                      <el-option
-                        v-for="item in goodtype_options"
-                        :key="item.value"
-                        :label="item.label"
-                        :value="item.value"
-                        :disabled="item.disabled"
-                      >
-                      </el-option>
-                    </el-select>
-                  </el-form-item>
-                </el-col>
+
                 <el-col :span="12">
                   <el-form-item label="销售数量" prop="good_num">
                     <digital-input
@@ -321,6 +297,7 @@
                 </el-date-picker>
               </el-form-item>
             </el-col>
+
             <el-col :span="6">
               <el-form-item label="发货方式" prop="sendtype">
                 <el-select
@@ -683,31 +660,29 @@ export default {
           return time.getTime() < Date.now() - 1000 * 60 * 60 * 24;
         },
       },
-      activity_options: [
-        {
-          value: "1",
-          label: "参与活动",
-        },
-        {
-          value: "0",
-          label: "不参与活动",
-        },
-      ],
       goodtype_options: [
         {
-          value: "1",
-          label: "常规商品",
-          disabled: false,
-        },
-        {
-          value: "2",
-          label: "赠品",
-          disabled: false,
+          value: "is_activity_0",
+          label: "不参与活动",
+          children: [
+            {
+              value: "1",
+              label: "常规商品",
+            },
+            {
+              value: "2",
+              label: "赠品",
+            },
+            {
+              value: "3",
+              label: "样品",
+            },
+          ],
         },
         {
-          value: "3",
-          label: "样品",
-          disabled: false,
+          value: "is_activity_1",
+          label: "参与活动",
+          children: [],
         },
       ],
       sendtype_options: [
@@ -731,7 +706,7 @@ export default {
         proof_url: "", //凭证地址
 
         is_activity: "0", //是否参与活动,
-        goodtype: "1", //商品类型
+        goodtype: ["is_activity_0", "1"], //活动类型
         good_num: "", //商品数量
         good_price: "0", //商品单价
         platform_order: "", //平台订单号
@@ -779,24 +754,19 @@ export default {
             trigger: "change",
           },
         ],
-        is_activity: [
-          {
-            required: true,
-            message: "请选择是否参加活动",
-            trigger: "change",
-          },
-        ],
+
         goodtype: [
           {
+            type: "array",
             required: true,
-            message: "请选择商品类型",
+            message: "请选择活动类型",
             trigger: "change",
           },
         ],
         good_num: [
           {
             required: true,
-            message: "请选择商品类型",
+            message: "请选择活动类型",
             trigger: "change",
           },
         ],
@@ -898,8 +868,7 @@ export default {
             proof_id: "", //凭证ID
             proof_type: "", //凭证类型
             proof_url: "", //凭证地址
-            is_activity: "0", //是否参与活动,
-            goodtype: "2", //商品类型
+            goodtype: ["is_activity_0", "1"], //活动类型
             good_num: "10", //商品数量
             good_price: "0", //商品单价
             platform_order: "", //平台订单号
@@ -957,12 +926,56 @@ export default {
       this.ruleForm.proof_url = "";
       this.$refs.ruleForm.validateField("proof_id");
     },
-    resultList(e) {
+    async resultList(e) {
       this.showModel = false;
       if (e.length === 1) {
         let ssitem = JSON.parse(JSON.stringify(e[0]));
-        ssitem.good_info_img = ssitem.good_info_img.split(",");
-        const { weight } = ssitem;
+        await this.get_goods_detail(ssitem.skuCode);
+        this.ruleForm.good_code = this.goods_sitem.skuCode;
+      } else {
+        this.goods_sitem = {};
+        this.ruleForm.good_code = "";
+      }
+      this.$refs.ruleForm.validateField("good_code");
+      this.ruleForm.proof_id = "";
+      this.ruleForm.proof_url = "";
+      this.ruleForm.proof_type = "";
+      this.$refs.ruleForm.validateField("proof_id");
+      if (e.length === 1) {
+        await this.get_goods_active()
+      }
+    },
+    async get_goods_active() {
+      const { skuCode, supplierNo, platform_id } = this.ruleForm;
+      let model = {
+        skuCode,
+        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_name;
+          a.label = a.activity_code;
+        });
+        this.goodtype_options[1].children = list;
+      } else if (code >= 100 && code <= 104) {
+        await this.logout();
+      } else {
+        this.$message.warning(message);
+      }
+    },
+    async get_goods_detail(skuCode) {
+      let { code, data, message } = await asyncRequest.goods_detail({
+        skuCode: skuCode,
+      });
+      if (code === 0) {
+        this.goods_sitem = data;
+        this.goods_sitem.good_info_img =
+          this.goods_sitem.good_info_img.split(",");
+        const { weight } = this.goods_sitem;
         let kgnum = parseInt((weight * 1) / 1000);
         let gnum = (weight * 1) % 1000;
         let new_weight,
@@ -974,20 +987,14 @@ export default {
           new_weight = weight;
           weight_unit = "g";
         }
-        ssitem.new_weight = new_weight;
-        ssitem.weight_unit = weight_unit;
-        this.goods_sitem = ssitem;
-
-        this.ruleForm.good_code = this.goods_sitem.skuCode;
+        this.goods_sitem.new_weight = new_weight;
+        this.goods_sitem.weight_unit = weight_unit;
+        this.ruleForm.good_code = this.goods_sitem.good_code;
+      } else if (code >= 100 && code <= 104) {
+        await this.logout();
       } else {
-        this.goods_sitem = {};
-        this.ruleForm.good_code = "";
+        this.$message.warning(message);
       }
-      this.$refs.ruleForm.validateField("good_code");
-      this.ruleForm.proof_id = "";
-      this.ruleForm.proof_url = "";
-      this.ruleForm.proof_type = "";
-      this.$refs.ruleForm.validateField("proof_id");
     },
     showVoucherFun() {
       if (this.goods_sitem && this.goods_sitem.spuCode) {
@@ -997,25 +1004,6 @@ export default {
         return;
       }
     },
-    activity_change() {
-      const { is_activity } = this.ruleForm;
-      if (is_activity === "1") {
-        this.goodtype_options.map((a) => {
-          if (a.value !== "1") {
-            a.disabled = true;
-          }
-          return a;
-        });
-        this.ruleForm.goodtype = "1";
-      } else {
-        this.goodtype_options.map((a) => {
-          a.disabled = false;
-          return a;
-        });
-      }
-      this.rulesThis.proof_id[0].required = is_activity === "1";
-      this.$refs.ruleForm.validateField("proof_id");
-    },
     async addGoodsRes(e) {
       if (e && e.length === 1) {
         this.ruleForm.good_name = e[0].good_name;
@@ -1029,6 +1017,10 @@ export default {
       } else {
       }
     },
+
+    handleChange(e) {
+      console.log(e);
+    },
     change_good_code() {
       const { supplierNo, platform_id } = this.ruleForm;
       if (supplierNo === "") {
@@ -1201,7 +1193,7 @@ export default {
       let model = {
         skuCode: good_code,
         sale_num: good_num,
-        is_activity: is_activity,
+        is_activity: "0",
       };
       let { code, message, data } = await asyncRequest.salegetprice(model);