戴艳蓉 пре 3 година
родитељ
комит
095bd82bca

+ 25 - 5
src/views/goodStore/goodsCost/components/baseForm.vue

@@ -983,10 +983,10 @@
               <el-select
                 v-model="ruleForm.is_step"
                 filterable
-                clearable
                 :disabled="type === 'view' || type === 'editBase'"
                 style="width: 100%"
                 placeholder="启用阶梯"
+                @change="is_step_change"
               >
                 <el-option
                   v-for="group in options5"
@@ -1177,6 +1177,11 @@ export default {
       this.showModel = true;
     },
     openCostEdit(index, sitem) {
+      const { is_step } = this.ruleForm;
+      if (index === -1 && is_step === "0" && this.ladder_tableData.length > 0) {
+        this.$message.warning("不启用阶梯成本,只能录入一条阶梯成本信息!");
+        return;
+      }
       this.costmodelIndex = index;
       this.costsitem = sitem;
       this.costshowModel = true;
@@ -1187,6 +1192,20 @@ export default {
     openCostEditDelete(index) {
       this.ladder_tableData.splice(index, 1);
     },
+    is_step_change() {
+      const { is_step } = this.ruleForm;
+      if (is_step === "0") {
+        let res = [];
+        let list =
+          this.ladder_tableData.length === 0
+            ? []
+            : JSON.parse(JSON.stringify(this.ladder_tableData));
+        if (list.length > 0) {
+          res.push(list[0]);
+        }
+        this.ladder_tableData = res;
+      }
+    },
     async submitForm() {
       this.sch_is_noble();
       this.good_type_change();
@@ -1518,7 +1537,7 @@ export default {
         market_price: "0",
         nake_price: "0",
         cgd_gold_price: "0",
-        is_step: "",
+        is_step: "0",
         is_diff: "",
         config: [],
         other_config: "",
@@ -1709,7 +1728,7 @@ export default {
             market_price: market_price || "",
             nake_price: nake_price || "",
             cgd_gold_price: cgd_gold_price || "",
-            is_step: is_step || "",
+            is_step: is_step || "0",
             is_diff: is_diff || "",
             config: config ? config.split(",") : [],
             other_config: other_config || "",
@@ -1726,6 +1745,7 @@ export default {
         "is_diff",
         "config",
         "other_config",
+        "cgd_gold_pric",
       ];
       for (let i = 0; i < list.length; i++) {
         this.rulesThis[list[i]][0].required = this.is_noble;
@@ -1748,7 +1768,7 @@ export default {
         delete item["is_gold_price"];
         delete item["market_price"];
         delete item["nake_price"];
-        delete item['cgd_gold_price'];
+        delete item["cgd_gold_price"];
         delete item["is_step"];
         delete item["good_ladder"];
       } else {
@@ -1781,7 +1801,7 @@ export default {
           is_gold_price: is_gold_price || "",
           market_price: market_price || "",
           nake_price: nake_price || "",
-          cgd_gold_price:cgd_gold_price||"",
+          cgd_gold_price: cgd_gold_price || "",
           is_step: is_step || "",
           good_ladder: good_ladder || [],
           spuCode: spuCode || "",

+ 1 - 2
src/views/goodStore/goodsOnline/columns.js

@@ -106,7 +106,6 @@ const listCol = [
     label: "业务公司名称",
     width: "150px",
   },
-
   {
     prop: "plat_code",
     label: "平台商品编号",
@@ -128,7 +127,7 @@ const listCol = [
     label: "操作",
     fixed: "right",
     _noset_: true,
-    width: "80px",
+    width: "110px",
     _slot_: "operation",
   },
 ]

+ 129 - 24
src/views/goodStore/goodsOnline/components/fixed-price-form.vue

@@ -5,7 +5,6 @@
     :model="ruleForm"
     status-icon
     :rules="rulesThis"
-    :label-width="labelWidth || '110px'"
     class="demo-ruleForm-goodsOnline"
     :size="'mini'"
   >
@@ -34,13 +33,45 @@
                 :size="'mini'"
                 :style="{ marginBottom: scope.row.edit ? '13px' : '0' }"
               >
-                <el-input
-                  v-model="scope.min_num"
-                  placeholder="起订量(>=)"
+                <digital-input
+                  :values="scope.row.min_num"
+                  :placeholder="'起订量(>=)'"
+                  :min="0"
+                  :max="100000000000"
+                  :position="'right'"
+                  :precision="0"
+                  :controls="false"
+                  :append="''"
+                  :size="'mini'"
                   :disabled="!scope.row.edit"
+                  @reschange="num_change($event, 'min_num', scope.$index)"
                 />
               </el-form-item>
-              <span v-if="!scope.row.edit">{{ scope.row.min_num }}</span>
+              <span v-else>{{ scope.row.min_num }}</span>
+            </template>
+          </el-table-column>
+          <el-table-column
+            prop="new_sale_price"
+            label="系统售价(元)"
+            show-overflow-tooltip
+          >
+            <template slot-scope="scope">
+              <el-form-item
+                v-if="scope.row.edit"
+                :prop="'good_ladder.' + scope.$index + '.' + 'new_sale_price'"
+                :rules="addrRules.new_sale_price"
+                :size="'mini'"
+                :style="{ marginBottom: scope.row.edit ? '13px' : '0' }"
+              >
+                <el-input
+                  v-loading="scope.row.loading"
+                  v-model="scope.row.new_sale_price"
+                  placeholder="系统售价"
+                  :disabled="true"
+                  :size="'mini'"
+                />
+              </el-form-item>
+              <span v-else>{{ scope.row.new_sale_price }}</span>
             </template>
           </el-table-column>
           <el-table-column prop="sale_price" label="售价" show-overflow-tooltip>
@@ -53,12 +84,12 @@
                 :style="{ marginBottom: scope.row.edit ? '13px' : '0' }"
               >
                 <el-input
-                  v-model="scope.sale_price"
+                  v-model="scope.row.sale_price"
                   placeholder="售价"
                   :disabled="!scope.row.edit"
                 />
               </el-form-item>
-              <span v-if="!scope.row.edit">{{ scope.row.sale_price }}</span>
+              <span v-else>{{ scope.row.sale_price }}</span>
             </template>
           </el-table-column>
           <el-table-column
@@ -75,12 +106,12 @@
                 :style="{ marginBottom: scope.row.edit ? '13px' : '0' }"
               >
                 <el-input
-                  v-model="scope.market_price"
+                  v-model="scope.row.market_price"
                   placeholder="市场价"
                   :disabled="!scope.row.edit"
                 />
               </el-form-item>
-              <span v-if="!scope.row.edit">{{ scope.row.market_price }}</span>
+              <span v-else>{{ scope.row.market_price }}</span>
             </template>
           </el-table-column>
           <el-table-column
@@ -97,19 +128,35 @@
                 :style="{ marginBottom: scope.row.edit ? '13px' : '0' }"
               >
                 <el-input
-                  v-model="scope.market_platform"
+                  v-model="scope.row.market_platform"
                   placeholder="对比平台"
                   :disabled="!scope.row.edit"
                 />
               </el-form-item>
-              <span v-if="!scope.row.edit">{{
-                scope.row.market_platform
-              }}</span>
+              <span v-else>{{ scope.row.market_platform }}</span>
             </template>
           </el-table-column>
           <el-table-column prop="status" label="状态" show-overflow-tooltip>
             <template slot-scope="scope">
+              <el-form-item
+                v-if="scope.row.edit"
+                :prop="'good_ladder.' + scope.$index + '.' + 'status'"
+                :rules="addrRules.status"
+                :size="'mini'"
+                :style="{ marginBottom: scope.row.edit ? '13px' : '0' }"
+              >
+                <el-select v-model="scope.row.status" placeholder="状态">
+                  <el-option
+                    v-for="item in status_options"
+                    :key="item.value"
+                    :label="item.label"
+                    :value="item.value"
+                  >
+                  </el-option>
+                </el-select>
+              </el-form-item>
               <el-tag
+                v-else
                 :size="'mini'"
                 :type="scope.row.status == '1' ? '' : 'warning'"
                 >{{ scope.row.status == "1" ? "启用" : "禁用" }}</el-tag
@@ -122,7 +169,7 @@
               <el-tooltip effect="dark" content="添加阶梯" placement="top">
                 <i
                   class="el-icon-circle-plus-outline tb-icon fr"
-                  @click="openCostEdit(-1, {})"
+                  @click="openCostEdit(-1)"
                 ></i>
               </el-tooltip>
             </template>
@@ -130,7 +177,7 @@
               <el-tooltip effect="dark" content="修改" placement="top">
                 <i
                   class="el-icon-edit tb-icon"
-                  @click="openCostEdit(scope.$index, scope.row)"
+                  @click="openCostEdit(scope.$index)"
                 ></i>
               </el-tooltip>
 
@@ -144,14 +191,14 @@
           </el-table-column>
         </el-table>
         <!-- 弹窗 新增/修改 -->
-        <cost-form-add-edit
+        <!-- <cost-form-add-edit
           :index="costmodelIndex"
           :show-model="costshowModel"
           :sitem="costsitem"
           :spuCode="spuCode"
           @refresh="costrefreshEdit"
           @cancel="costshowModel = false"
-        />
+        /> -->
       </el-col>
       <el-col :span="24"
         ><el-form-item label="售价凭证类型" prop="proof_type">
@@ -302,7 +349,7 @@
 </template>
 
 <script>
-import costFormAddEdit from "./costFormAddEdit";
+// import costFormAddEdit from "./costFormAddEdit";
 import asyncRequest from "@/apis/service/goodStore/goodsOnline";
 import showVoucherModel from "@/components/show-voucher-model";
 export default {
@@ -318,7 +365,7 @@ export default {
     "sitem",
   ],
   components: {
-    costFormAddEdit,
+    // costFormAddEdit,
     showVoucherModel,
   },
   /**
@@ -380,6 +427,16 @@ export default {
           label: "其他",
         },
       ],
+      status_options: [
+        {
+          value: "1",
+          label: "启用",
+        },
+        {
+          value: "0",
+          label: "禁用",
+        },
+      ],
       showModelThis: this.showModel,
       pickerOptions: {
         disabledDate(time) {
@@ -495,15 +552,63 @@ export default {
       this.loading = false;
     },
 
-    openCostEdit(index, sitem) {
-      this.costmodelIndex = index;
-      this.costsitem = sitem;
-      this.costshowModel = true;
+    openCostEdit(index) {
+      let findex = this.ruleForm.good_ladder.findIndex((v) => v.edit === true);
+      if (findex !== -1) {
+        this.$message.warning("当前已有阶梯售价在编辑,请保存后再试!");
+        return;
+      } else {
+        if (index === -1) {
+          this.ruleForm.good_ladder.push({
+            edit: true,
+            min_num: "",
+            new_sale_price: "",
+            sale_price: "",
+            market_price: "",
+            market_platform: "",
+            status: "1",
+          });
+        } else {
+          this.ruleForm.good_ladder[index].edit = true;
+        }
+      }
+    },
+    async get_new(index) {
+      const { min_num, search_loading } = this.ruleForm.good_ladder[index];
+      console.log(this.spuCode);
+      if (!search_loading) {
+        if (min_num === "" || min_num === "0") {
+          this.ruleForm.good_ladder[index].new_sale_price = "0";
+        } else {
+          this.ruleForm.good_ladder[index].search_loading = true;
+          let { code, data, message } = await asyncRequest.goodupprice({
+            min_num: min_num,
+            spuCode: this.spuCode,
+          });
+          this.ruleForm.good_ladder[index].search_loading = false;
+          if (code === 0) {
+            const { sale_price } = data;
+            this.ruleForm.good_ladder[index].new_sale_price = sale_price;
+          } else if (code >= 100 && code <= 104) {
+            await this.logout();
+          } else if (code == 1010) {
+            this.ruleForm.good_ladder[index].new_sale_price = "0";
+            this.$message.warning(message);
+          } else {
+            this.$message.warning(message);
+          }
+        }
+      }
     },
-
     openCostEditDelete(index) {
       this.ruleForm.good_ladder.splice(index, 1);
     },
+    async num_change(e, key, index) {
+      this.ruleForm.good_ladder[index][key] = e + "" || "0";
+      if (key === "min_num") {
+        await this.get_new(index);
+      }
+    },
     //阶梯成本修改
     costrefreshEdit(e) {
       let item = JSON.parse(JSON.stringify(e));