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

+ 4 - 0
src/apis/service/goodStore/goodsCost/index.js

@@ -8,6 +8,10 @@ export default {
   delete: (data, params) => http(api + "gooddel", data, "post", params),
   // 分页查询
   list: (data, params) => http(api + "gooduplist", data, "post", params),
+  // 获取全部规格值
+  valueall: (data, params) => http(api + "valueall", data, "post", params),
+  // 规格值添加
+  valueadd: (data, params) => http(api + "valuecreate", data, "post", params),
   // 详情
   detail: (data, params) => http(api + "goodinfo", data, "post", params),
   // 更改

+ 26 - 42
src/components/globalComponents/goodClass/main.vue

@@ -18,7 +18,6 @@
 <script>
 import asyncRequest from "@/apis/components/goods-class";
 import resToken from "@/mixins/resToken";
-import { isArray } from "@/utils/validate";
 export default {
   name: "goodClass",
   mixins: [resToken],
@@ -39,6 +38,7 @@ export default {
     return {
       loading: false,
       props: {
+        checkStrictly: true,
         lazy: true, //开启远程加载
         async lazyLoad(node, resolve) {
           // console.log(node);
@@ -62,6 +62,7 @@ export default {
                 value: v1.id,
                 label: v1.cat_name,
                 leaf: level >= 2,
+                desc: v1.cat_desc,
               };
               list.push(province);
             });
@@ -85,53 +86,36 @@ export default {
   // },
   mounted() {
     this.options = [];
-    // this.getInfo();
     this.selectLoading = false;
   },
   methods: {
-    handleChange(value) {
-      this.$emit("handleChange", value);
-    },
-    async selectChange(e) {
-      if (e && e.length > 0) {
-        let index = this.options.findIndex((v) => v.code === e[0]);
-        if (index !== -1) {
-          this.$emit("searchChange", this.options[index]);
-        } else {
-          this.$emit("searchChange", {});
-        }
-      } else {
-        this.$emit("searchChange", {});
-      }
-    },
-    delChild(list) {
-      let arr = [];
-      list.forEach((v) => {
-        let sitem = JSON.parse(JSON.stringify(v));
-        if (isArray(sitem.child) && sitem.child.length === 0) {
-          delete sitem["child"];
-        } else if (isArray(sitem.child) && sitem.child.length > 0) {
-          sitem.child = this.delChild(sitem.child);
+    async handleChange(value) {
+      let model = {
+        value: value,
+        item: {},
+      };
+      let length = value.length;
+      let item = {
+        cat_name: "",
+        pid: "0",
+        status: "",
+      };
+      if (value.length > 0) {
+        if (length > 1) {
+          item.pid = value[length - 2];
         }
-        arr.push(sitem);
-      });
-      return arr;
-    },
-    async getInfo() {
-      this.selectLoading = true;
-      let res = await asyncRequest.list({});
-      if (res && res.code === 0 && res.data) {
-        let arr = res.data;
-        let list = [];
 
-        list = this.delChild(arr);
-        this.options = list;
-      } else if (res && res.code >= 100 && res.code <= 104) {
-        await this.logout();
-      } else {
-        this.$message.warning(res.message);
+        const res = await asyncRequest.list(item);
+        const { code, data } = res;
+        if (code === 0) {
+          data.forEach((i) => {
+            if (i.id === value[length - 1]) {
+              model.item = i;
+            }
+          });
+        }
       }
-      this.selectLoading = false;
+      this.$emit("handleChange", model);
     },
   },
 };

+ 4 - 19
src/components/globalComponents/search-spec/main.vue

@@ -83,28 +83,16 @@ export default {
   },
   methods: {
     async selectChange(e) {
-      if (e && e.length > 0) {
-        let index = this.options.findIndex((v) => v.id === e[0]);
-        if (index !== -1) {
-          let model = {
-            id: this.options[index].id,
-            code: this.options[index].id,
-            label: this.options[index].spec_name,
-          };
-          this.$emit("searchChange", model);
-        } else {
-          this.$emit("searchChange", {});
-        }
-      } else {
-        this.$emit("searchChange", {});
+      let item = {};
+      if (e) {
+        item = this.options.find((i) => i.id === e);
       }
+      this.$emit("searchChange", item);
     },
     //query
     async remoteMethod() {
       this.selectLoading = true;
-      // if (query !== "") {
       this.options = [];
-      // this.formValue.spec_name = query;
       const { code, data, message } = await asyncRequest.list(this.formValue);
       if (code === 0) {
         this.options = data;
@@ -113,9 +101,6 @@ export default {
       } else {
         this.$message.warning(message);
       }
-      // } else {
-      //   this.options = [];
-      // }
       this.selectLoading = false;
     },
   },

+ 1 - 1
src/views/goodStore/goodsCost/add.vue

@@ -48,7 +48,7 @@ export default {
   data() {
     return {
       size: "small",
-      activeName: "3",
+      activeName: "1",
       loading: false,
    
      

+ 2 - 2
src/views/goodStore/goodsCost/columns.js

@@ -1,8 +1,8 @@
 
 //是否定制
 const options1 = [
-  { id: "0", name: "" },
-  { id: "1", name: "" },
+  { id: "0", name: "" },
+  { id: "1", name: "" },
 ]
 //专属类型
 const options2 = [

+ 92 - 62
src/views/goodStore/goodsCost/components/baseForm.vue

@@ -170,7 +170,7 @@
               />
             </el-form-item>
           </el-col>
-          <el-col :span="8">
+          <el-col :span="8" v-if="is_noble">
             <el-form-item label="贵金属重量" prop="noble_weight">
               <el-input
                 placeholder="贵金属重量"
@@ -184,7 +184,7 @@
               </el-input>
             </el-form-item>
           </el-col>
-          <el-col :span="8">
+          <el-col :span="8" v-if="is_noble">
             <el-form-item label="贵金属种类" prop="noble_metal">
               <search-metal-kind
                 :value="ruleForm.noble_metal"
@@ -196,7 +196,7 @@
               />
             </el-form-item>
           </el-col>
-          <el-col :span="8">
+          <el-col :span="8" v-if="is_noble">
             <el-form-item label="启用实时金价" prop="is_gold_price">
               <el-select
                 v-model="ruleForm.is_gold_price"
@@ -214,6 +214,40 @@
               </el-select>
             </el-form-item>
           </el-col>
+
+          <el-col :span="8">
+            <el-form-item label="售后说明" prop="after_sales">
+              <el-input
+                type="textarea"
+                :rows="4"
+                placeholder="售后说明"
+                v-model="ruleForm.after_sales"
+              >
+              </el-input>
+            </el-form-item>
+          </el-col>
+          <el-col :span="8">
+            <el-form-item label="商品备注" prop="good_remark">
+              <el-input
+                type="textarea"
+                :rows="4"
+                placeholder="商品备注"
+                v-model="ruleForm.good_remark"
+              >
+              </el-input>
+            </el-form-item>
+          </el-col>
+          <el-col :span="8">
+            <el-form-item label="工艺说明" prop="craft_desc">
+              <el-input
+                type="textarea"
+                :rows="4"
+                placeholder="工艺说明"
+                v-model="ruleForm.craft_desc"
+              >
+              </el-input>
+            </el-form-item>
+          </el-col>
           <el-col :span="8">
             <el-form-item label="是否定制" prop="good_type">
               <el-select
@@ -232,7 +266,7 @@
               </el-select>
             </el-form-item>
           </el-col>
-          <el-col :span="8">
+          <el-col :span="8" v-if="ruleForm.good_type === '1'">
             <el-form-item label="定制起订量" prop="moq">
               <el-input
                 placeholder="定制起订量"
@@ -244,7 +278,7 @@
               />
             </el-form-item>
           </el-col>
-          <el-col :span="8">
+          <el-col :span="8" v-if="ruleForm.good_type === '1'">
             <el-form-item label="定制工期" prop="customized">
               <el-input
                 placeholder="定制工期"
@@ -258,40 +292,6 @@
               </el-input>
             </el-form-item>
           </el-col>
-
-          <el-col :span="8">
-            <el-form-item label="售后说明" prop="after_sales">
-              <el-input
-                type="textarea"
-                :rows="4"
-                placeholder="售后说明"
-                v-model="ruleForm.after_sales"
-              >
-              </el-input>
-            </el-form-item>
-          </el-col>
-          <el-col :span="8">
-            <el-form-item label="商品备注" prop="good_remark">
-              <el-input
-                type="textarea"
-                :rows="4"
-                placeholder="商品备注"
-                v-model="ruleForm.good_remark"
-              >
-              </el-input>
-            </el-form-item>
-          </el-col>
-          <el-col :span="8">
-            <el-form-item label="工艺说明" prop="craft_desc">
-              <el-input
-                type="textarea"
-                :rows="4"
-                placeholder="工艺说明"
-                v-model="ruleForm.craft_desc"
-              >
-              </el-input>
-            </el-form-item>
-          </el-col>
         </el-row>
       </el-col>
     </el-row>
@@ -308,8 +308,8 @@
       <el-col :span="23" class="dmain" style="padding-left: 18px">
         <el-table :data="tableData" :size="'mini'" border style="width: 100%">
           <!-- <el-table-column prop="index" label="序号"> </el-table-column> -->
-          <el-table-column prop="name" label="规格类型" />
-          <el-table-column prop="address" label="规格值"> </el-table-column>
+          <el-table-column prop="spec_value" label="规格类型" />
+          <el-table-column prop="spec_value_value" label="规格值" />
           <el-table-column fixed="right">
             <template slot="header" slot-scope="scope">
               <span>操作</span>
@@ -322,30 +322,26 @@
                 <i
                   class="el-icon-circle-plus-outline fr"
                   style="font-size: 18px; margin-top: 2px"
-                  @click="openEdit('add', {})"
+                  @click="openEdit('-1', {})"
                 />
               </el-tooltip>
             </template>
             <template slot-scope="scope">
               <el-button
-                @click="handleClick(scope.row)"
+                @click="openEdit(scope.$index, scope.row)"
                 type="text"
                 size="small"
-                >新建规格值</el-button
+                >修改</el-button
               >
-              <el-button
-                @click="handleClick(scope.row)"
-                type="text"
-                size="small"
-                >修改规格值</el-button
+              <el-button type="text" size="small" @click="openEdit('0', {})"
+                >移除</el-button
               >
-              <el-button type="text" size="small">移除规格类型</el-button>
             </template>
           </el-table-column>
         </el-table>
         <!-- 弹窗 新增/修改 -->
         <base-form-add-edit
-          :id="modelId"
+          :index="modelIndex"
           :show-model="showModel"
           :sitem="sitem"
           @refresh="refreshEdit"
@@ -384,7 +380,8 @@ export default {
   data() {
     return {
       showModel: false,
-      modelId: "000",
+      modelIndex: "",
+      is_noble: false,
       sitem: {},
       size: "small",
       rulesThis: this.rules,
@@ -408,7 +405,7 @@ export default {
         brandid: [
           {
             type: "array",
-            required: true,
+            required: false,
             message: "商品品牌",
             trigger: "change",
           },
@@ -443,7 +440,6 @@ export default {
         ],
         company_id: [
           {
-            type: "array",
             required: true,
             message: "请选择业务公司",
             trigger: "change",
@@ -535,7 +531,6 @@ export default {
           },
         ],
       },
-   
     };
   },
   mounted() {
@@ -552,9 +547,9 @@ export default {
     handleClick(row) {
       console.log(row);
     },
-    openEdit(type, sitem) {
+    openEdit(index, sitem) {
+      this.modelIndex = index;
       this.sitem = sitem;
-      this.modelId = type;
       this.showModel = true;
     },
     async initData() {
@@ -590,7 +585,7 @@ export default {
         good_type: "",
         is_stock: "",
         supplierNo: [],
-        company_id: [],
+        company_id: "",
         is_auth: "",
         tax: "",
         good_name: "2018春秋新款V领修身丝绒西装女 双排扣复古极简中长款工装外套",
@@ -606,12 +601,47 @@ export default {
       };
     },
     refreshEdit(e) {
-      console.log(e);
+      let item = JSON.parse(JSON.stringify(e));
+      const {
+        index,
+        id,
+        spec_id,
+        spec_value,
+        spec_value_id,
+        spec_value_value,
+      } = item;
+      if (index + "" === "-1") {
+        this.tableData.push(item);
+      } else {
+        this.tableData.forEach((i,findex) => {
+          if (i.spec_id === spec_id) {
+            this.tableData[findex].id = id;
+            this.tableData[findex].spec_id = spec_id;
+            this.tableData[findex].spec_value = spec_value;
+            this.tableData[findex].spec_value_id = spec_value_id;
+            this.tableData[findex].spec_value_value = spec_value_value;
+          }
+        });
+      }
+      this.showModel = false;
     },
     //商品分类选择
     goods_class_change(e) {
-      this.ruleForm.cat_id = e;
+      const { value, item } = e;
+      const { cat_desc } = item;
+      this.ruleForm.cat_id = value || [];
       this.$refs.ruleForm.validateField("cat_id");
+      this.ruleForm.after_sales = cat_desc || "";
+      this.$refs.ruleForm.validateField("after_sales");
+      let isok = false;
+      if (e.length > 0) {
+        e.forEach((i) => {
+          if (i === "8") {
+            isok = true;
+          }
+        });
+      }
+      this.is_noble = isok;
     },
     //商品品牌选择
     brandidsearchChange(e) {
@@ -636,9 +666,9 @@ export default {
     company_idsearchChange(e) {
       const { id, code, label } = e;
       if (id) {
-        this.ruleForm.company_id = [code];
+        this.ruleForm.company_id = code;
       } else {
-        this.ruleForm.company_id = [];
+        this.ruleForm.company_id = "";
       }
       this.$refs.ruleForm.validateField("company_id");
     },

+ 128 - 134
src/views/goodStore/goodsCost/components/baseFormAddEdit.vue

@@ -5,7 +5,7 @@
     :center="true"
     align="left"
     top="18vh"
-    width="500px"
+    width="600px"
     :close-on-click-modal="false"
     :visible.sync="showModelThis"
     element-loading-text="拼命加载中"
@@ -25,45 +25,52 @@
             label-width="80px"
             class="demo-ruleForm"
           >
-            <el-form-item label="规格类型" prop="brand_name">
+            <el-form-item label="规格类型" prop="spec_id">
               <search-spec
-                :value="ruleForm.brand_name"
+                :value="ruleForm.spec_id"
                 :disabled="false"
                 :size="'mini'"
                 :isDetail="false"
                 :placeholder="'规格类型'"
-                @searchChange="brand_namesearchChange"
+                @searchChange="spec_idsearchChange"
               />
             </el-form-item>
-            <el-form-item label="规格值" prop="logo_url">
-              <el-radio-group v-model="ruleForm.logo_url">
-                <el-radio
-                  v-for="item in specVlist"
-                  :key="item.id + item.name"
-                  :label="item.id"
-                  >{{ item.name }}</el-radio
+            <el-form-item label="规格值" prop="spec_value_id">
+              <div v-if="specVlist.length > 0">
+                <el-radio-group
+                  v-model="ruleForm.spec_value_id"
+                  @change="spec_value_id_change"
                 >
-              </el-radio-group>
+                  <el-radio
+                    v-for="item in specVlist"
+                    :key="item.id + item.spec_value"
+                    :label="item.id"
+                    >{{ item.spec_value }}</el-radio
+                  >
+                </el-radio-group>
+              </div>
+              <div class="no-data" v-else>暂无规格值,请添加!</div>
             </el-form-item>
-            <div style="width: 100%; padding: 0 0 0 80px">
-              <el-input
-                style="width: 209px"
-                v-model="sinput"
-                :disabled="id == 'edit'"
-                :size="'small'"
-                placeholder="规格值名称,如红色"
-                maxlength="20"
-              />
-              <el-button
-                style="margin: 0 0 0 10px"
-                icon="el-icon-plus"
-                :size="'small'"
-                >新增规格值</el-button
-              >
-            </div>
           </el-form>
         </el-col>
         <el-col :span="24" style="text-align: right; padding-top: 18px">
+          <el-input
+            style="width: 209px"
+            v-model="sinput"
+            class="fl"
+            :disabled="id == 'edit'"
+            :size="'small'"
+            placeholder="规格值名称,如红色"
+            maxlength="20"
+          />
+          <el-button
+            style="margin: 0 0 0 10px"
+            icon="el-icon-plus"
+            :size="'small'"
+            @click="add_spec"
+            class="fl"
+            >新增规格值</el-button
+          >
           <el-button
             v-if="id !== 'edit'"
             :size="'small'"
@@ -80,37 +87,32 @@
   </el-dialog>
 </template>
 <script>
-import asyncRequest from "@/apis/service/goodStore/brand";
+import asyncRequest from "@/apis/service/goodStore/goodsCost";
 import resToken from "@/mixins/resToken";
 export default {
   name: "brand",
-  props: ["showModel", "id", "sitem"],
+  props: ["showModel", "index", "sitem"],
   mixins: [resToken],
   data() {
     return {
       loading: false,
-      title: "",
+      title: "商品规格",
       sinput: "",
       showModelThis: this.showModel,
-      select: "1",
-      specVlist: [
-        { id: "1", name: "111" },
-        { id: "2", name: "222" },
-      ],
-      activeOptions: [],
-      actionList: [],
-      ruleForm: {
-        id: "",
-        brand_name: "",
-        logo_url: "",
-      },
+      specVlist: [],
+      ruleForm: {},
       rulesThis: this.rules,
+
       rules: {
-        brand_name: [
-          { required: true, message: "品牌名称不能为空", trigger: "change" },
+        spec_id: [
+          {
+            required: true,
+            message: "规格类型不能为空",
+            trigger: "change",
+          },
         ],
-        logo_url: [
-          { required: true, message: "品牌名称不能为空", trigger: "change" },
+        spec_value_id: [
+          { required: true, message: "请选择规格值", trigger: "change" },
         ],
       },
     };
@@ -131,15 +133,12 @@ export default {
   methods: {
     async initForm() {
       this.loading = true;
-      if (this.id === "add") {
-        this.title = "添加商品类型";
-        this.rulesThis = this.rules;
-      } else if (this.id === "005") {
-        this.title = "修改商品类型";
-        this.rulesThis = this.rules;
+      this.resetFormData();
+      this.rulesThis = this.rules;
+      if (this.index === "0") {
+        this.title = "添加商品规格值";
       } else {
-        this.title = "品牌商品类型";
-        this.rulesThis = {};
+        this.title = "修改商品规格值";
       }
       await this.resetForm();
       this.loading = false;
@@ -150,100 +149,88 @@ export default {
         if (this.$refs.ruleForm) {
           this.$refs.ruleForm.resetFields();
           this.$refs.ruleForm.clearValidate();
-          const { id, brand_name, logo_url } = this.sitem;
-          this.ruleForm = {
-            id: id || "",
-            brand_name: brand_name || "",
-            logo_url: logo_url || "",
-          };
+          console.log(this.index);
+          console.log(this.sitem);
+          this.resetFormData();
         }
       });
     },
-
-    brand_namesearchChange(e) {
-      const { id, code, label } = e;
-      if (id) {
-        this.ruleForm.brand_name = code;
+    resetFormData() {
+      const { id, spec_id, spec_value, spec_value_id, spec_value_value } =
+        this.sitem;
+      this.ruleForm = {
+        index: this.index,
+        id: id || "",
+        spec_id: spec_id || "",
+        spec_value: spec_value || "",
+        spec_value_id: spec_value_id || "",
+        spec_value_value: spec_value_value || "",
+      };
+    },
+    async add_spec() {
+      const { spec_id } = this.ruleForm;
+      if (spec_id) {
+        if (this.sinput) {
+          const { code, data, message } = await asyncRequest.valueadd({
+            spec_id: spec_id,
+            spec_value: this.sinput,
+          });
+          if (code === 0) {
+            await this.getlist();
+          } else if (code >= 100 && code <= 104) {
+            await this.logout();
+          } else {
+            this.$message.warning(message);
+          }
+        } else {
+          this.$message.warning("请输入规格值!");
+        }
       } else {
-        this.ruleForm.brand_name = "";
+        this.$message.warning("请选择规格类型!");
       }
-      this.$refs.ruleForm.validateField("brand_name");
-      this.getlist();
     },
-    async getlist() {
-      const { brand_name } = this.ruleForm;
-      const { code, data, message } = await asyncRequest.list({
-        brand_name: brand_name,
-      });
-      if (code === 0) {
-        this.options = data;
-      } else if (code >= 100 && code <= 104) {
-        await this.logout();
+    async spec_idsearchChange(e) {
+      const { id, spec_name } = e;
+      this.ruleForm.spec_id = id || "";
+      this.ruleForm.spec_value = spec_name || "";
+      this.$refs.ruleForm.validateField("spec_id");
+      await this.getlist();
+    },
+    spec_value_id_change(e) {
+      if (e) {
+        const { id, spec_value } = this.specVlist.find((i) => i.id === e);
+        this.ruleForm.spec_value_id = id || "";
+        this.ruleForm.spec_value_value = spec_value || "";
       } else {
-        this.$message.warning(message);
+        this.ruleForm.spec_value_id = "";
+        this.ruleForm.spec_value_value = "";
       }
+      this.$refs.ruleForm.validateField("spec_value_id");
     },
-
-    async submitForm() {
-      await this.$refs.ruleForm.validate(async (valid) => {
-        if (valid) {
-          this.loading = true;
-          let model = JSON.parse(JSON.stringify(this.ruleForm));
-          let res = {};
-          if (this.id === "003") {
-            delete model["id"];
-            res = await asyncRequest.add(model);
-          } else {
-            res = await asyncRequest.update(model);
-          }
-          this.loading = false;
-          if (res && res.code === 0) {
-            const title = this.id === "add" ? "添加成功!" : "修改成功!";
-            this.$notify.success({
-              title,
-              message: "",
-            });
-            this.showModelThis = false;
-            // 刷新
-            this.$emit("refresh");
-          } else if (res && res.code >= 100 && res.code <= 104) {
-            await this.logout();
-          } else {
-            this.$message.warning(res.message);
-          }
+    async getlist() {
+      const { spec_id } = this.ruleForm;
+      if (spec_id) {
+        const { code, data, message } = await asyncRequest.valueall({
+          spec_id: spec_id,
+        });
+        if (code === 0) {
+          this.specVlist = data;
+        } else if (code >= 100 && code <= 104) {
+          await this.logout();
         } else {
-          console.log("error submit!!");
-          return false;
+          this.$message.warning(message);
         }
-      });
+      } else {
+        this.specVlist = [];
+      }
     },
-     async submitForm1() {
+
+    async submitForm() {
       await this.$refs.ruleForm.validate(async (valid) => {
         if (valid) {
           this.loading = true;
-          let model = JSON.parse(JSON.stringify(this.ruleForm));
-          let res = {};
-          if (this.id === "003") {
-            delete model["id"];
-            res = await asyncRequest.add(model);
-          } else {
-            res = await asyncRequest.update(model);
-          }
+          this.$emit("refresh", this.ruleForm);
           this.loading = false;
-          if (res && res.code === 0) {
-            const title = this.id === "add" ? "添加成功!" : "修改成功!";
-            this.$notify.success({
-              title,
-              message: "",
-            });
-            this.showModelThis = false;
-            // 刷新
-            this.$emit("refresh");
-          } else if (res && res.code >= 100 && res.code <= 104) {
-            await this.logout();
-          } else {
-            this.$message.warning(res.message);
-          }
         } else {
           console.log("error submit!!");
           return false;
@@ -255,6 +242,13 @@ export default {
 </script>
 
    <style lang="scss" scoped>
-.brand {
+.goodsCostAdd {
+  .no-data {
+    text-align: center;
+    line-height: 32px;
+    color: #8492a6;
+    // border: 1px solid #ccc;
+    border-radius: 6px;
+  }
 }
 </style>