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

+ 1 - 3
src/apis/components/search-unit.js

@@ -2,8 +2,6 @@ import http from "@/apis/axios";
 const api = "admin/";
 export default {
   // 列表
-  list: (data, params) => http(api + "brandlist", data, "post", params),
-  //  // 获取仓库  供应商仓/自建仓
-  //  warequery: (data, params) => http(api + "warequery", data, "post", params),
+  list: (data, params) => http(api + "unitlist", data, "post", params),
 };
    

+ 1 - 1
src/apis/service/goodStore/unit/index.js

@@ -7,7 +7,7 @@ export default {
   // 更新
   update: (data, params) => http(api + "unitedit", data, "post", params),
   // 分页查询
-  list: (data, params) => http(api + "speclist", data, "post", params),
+  list: (data, params) => http(api + "unitlist", data, "post", params),
   // 删除
   delete: (data, params) => http(api + "unitdelete", data, "post", params),
   // 修改状态

+ 17 - 20
src/components/globalComponents/search-brand/main.vue

@@ -16,10 +16,10 @@
   >
     <el-option
       v-for="(item, index) in options"
-      :key="item.id + index"
-      :label="item.name"
-      :value="item.wsm_code"
-      :disabled="item.status === '0'"
+      :key="item.id + index + 'brand'"
+      :label="item.brand_name"
+      :value="item.id"
+      :disabled="item.status === '1'"
     >
     </el-option>
   </el-select>
@@ -61,17 +61,15 @@ export default {
       formValue: {
         page: 1,
         size: 100,
-        supplierNo: "",
-        wsm_code: "",
         start: "",
         end: "",
-        mobile: "",
-        contactor: "",
+        creater: "",
+        status: "",
+        name: "",
       },
     };
   },
   watch: {
-   
     //  names: function (val, old) {
     //   // console.log(val, old);
     //   this.searchName = val;
@@ -87,12 +85,12 @@ export default {
   methods: {
     async selectChange(e) {
       if (e && e.length > 0) {
-        let index = this.options.findIndex((v) => v.wsm_code === e[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].wsm_code,
-            label: this.options[index].name,
+            code: this.options[index].id,
+            label: this.options[index].brand_name,
           };
           this.$emit("searchChange", model);
         } else {
@@ -106,17 +104,16 @@ export default {
       this.selectLoading = true;
       if (query !== "") {
         this.options = [];
-        let res = {};
-      this.formValue.supplierNo = query;
-          res = await asyncRequest.list(this.formValue);
+        this.formValue.name = query;
+       const {code ,data,message} = await asyncRequest.list(this.formValue);
 
-        if (res && res.code === 0 && res.data) {
-            const { list } = res.data;
-            this.options = list;
-        } else if (res && res.code >= 100 && res.code <= 104) {
+        if (code === 0 ) {
+          const { list } = data;
+          this.options = list;
+        } else if (code >= 100 && code <= 104) {
           await this.logout();
         } else {
-          this.$message.warning(res.message);
+          this.$message.warning(message);
         }
       } else {
         this.options = [];

+ 1 - 1
src/components/globalComponents/search-metal-kind/main.vue

@@ -29,7 +29,7 @@
 import asyncRequest from "@/apis/components/search-metal-kind";
 import resToken from "@/mixins/resToken";
 export default {
-  name: "SearchMetalkind",
+  name: "SearchMetalKind",
   mixins: [resToken],
   props: [
     "size",

+ 19 - 19
src/components/globalComponents/search-tax/main.vue

@@ -18,7 +18,7 @@
       v-for="(item, index) in options"
       :key="item.id + index"
       :label="item.name"
-      :value="item.wsm_code"
+      :value="item.id"
       :disabled="item.status === '0'"
     >
     </el-option>
@@ -61,17 +61,11 @@ export default {
       formValue: {
         page: 1,
         size: 100,
-        supplierNo: "",
-        wsm_code: "",
-        start: "",
-        end: "",
-        mobile: "",
-        contactor: "",
+        name: "",
       },
     };
   },
   watch: {
-   
     //  names: function (val, old) {
     //   // console.log(val, old);
     //   this.searchName = val;
@@ -87,11 +81,11 @@ export default {
   methods: {
     async selectChange(e) {
       if (e && e.length > 0) {
-        let index = this.options.findIndex((v) => v.wsm_code === e[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].wsm_code,
+            code: this.options[index].code,
             label: this.options[index].name,
           };
           this.$emit("searchChange", model);
@@ -106,17 +100,23 @@ export default {
       this.selectLoading = true;
       if (query !== "") {
         this.options = [];
-        let res = {};
-      this.formValue.supplierNo = query;
-          res = await asyncRequest.list(this.formValue);
-
-        if (res && res.code === 0 && res.data) {
-            const { list } = res.data;
-            this.options = list;
-        } else if (res && res.code >= 100 && res.code <= 104) {
+        this.formValue.name = query;
+        const { code, data, message } = await asyncRequest.list(this.formValue);
+        if (code === 0) {
+          const { list } = data;
+          // this.options = list;
+          this.options = [
+            { id: "0", name: "0%" },
+            { id: "1", name: "1%" },
+            { id: "3", name: "3%" },
+            { id: "6", name: "6%" },
+            { id: "9", name: "9%" },
+            { id: "13", name: "13%" },
+          ];
+        } else if (code >= 100 && code <= 104) {
           await this.logout();
         } else {
-          this.$message.warning(res.message);
+          this.$message.warning(message);
         }
       } else {
         this.options = [];

+ 13 - 20
src/components/globalComponents/search-unit/main.vue

@@ -29,7 +29,7 @@
 import asyncRequest from "@/apis/components/search-unit";
 import resToken from "@/mixins/resToken";
 export default {
-  name: "SearchBrand",
+  name: "SearchUnit",
   mixins: [resToken],
   props: [
     "size",
@@ -61,17 +61,14 @@ export default {
       formValue: {
         page: 1,
         size: 100,
-        supplierNo: "",
-        wsm_code: "",
         start: "",
         end: "",
-        mobile: "",
-        contactor: "",
+        unit: "",
+        creater: "",
       },
     };
   },
   watch: {
-   
     //  names: function (val, old) {
     //   // console.log(val, old);
     //   this.searchName = val;
@@ -87,15 +84,12 @@ export default {
   methods: {
     async selectChange(e) {
       if (e && e.length > 0) {
-        let index = this.options.findIndex((v) => v.wsm_code === e[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].wsm_code,
-            label: this.options[index].name,
-            contactor: this.options[index].wsm_name,
-            mobile: this.options[index].mobile,
-            addr: this.options[index].addr_cn + this.options[index].wsm_addr,
+            code: this.options[index].id,
+            label: this.options[index].unit,
           };
           this.$emit("searchChange", model);
         } else {
@@ -109,17 +103,16 @@ export default {
       this.selectLoading = true;
       if (query !== "") {
         this.options = [];
-        let res = {};
-      this.formValue.supplierNo = query;
-          res = await asyncRequest.list(this.formValue);
+        this.formValue.unit = query;
+        const { code, data, message } = await asyncRequest.list(this.formValue);
 
-        if (res && res.code === 0 && res.data) {
-            const { list } = res.data;
-            this.options = list;
-        } else if (res && res.code >= 100 && res.code <= 104) {
+        if (code === 0) {
+          const { list } = data;
+          this.options = list;
+        } else if (code >= 100 && code <= 104) {
           await this.logout();
         } else {
-          this.$message.warning(res.message);
+          this.$message.warning(message);
         }
       } else {
         this.options = [];

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

@@ -50,7 +50,7 @@ export default {
     return {
       size: "small",
       rulesThis: this.rules,
-      activeName: "2",
+      activeName: "1",
       loading: false,
       tableData: [],
       options1: options1,
@@ -169,19 +169,6 @@ export default {
         if (this.$refs.ruleForm) {
           this.$refs.ruleForm.resetFields();
           this.$refs.ruleForm.clearValidate();
-          // if (data) {
-          //   this.ruleForm = {
-          //     id: this.id,
-          //     catid: data.good_cat.split(","),
-          //     good_name: data.good_name,
-          //     unit: data.good_unit,
-          //     supplier: data.supplier,
-          //     brandid: data.brand_id,
-          //     image: data.galley.split(","),
-          //   };
-          //   this.oldcatid = this.ruleForm.catid;
-          //   // await this.specByCat(false);
-          // } else {
           this.ruleForm = {
             id: this.id,
             catid: ["1", "2", "3"],
@@ -293,236 +280,6 @@ export default {
         }
       });
     },
-    // groupChange($event, index, item) {
-    //   this.$set(this.mock, index, item);
-    //   this.actionSpecList();
-    // },
-    // actionSpecList() {
-    //   // this.leftS = "0px";
-    //   this.left.header = [];
-    //   this.left.middle = [];
-    //   this.left.specList = [];
-    //   console.log(this.mock);
-    //   console.log(this.right.specList);
-    //   this.mock.forEach((v1) => {
-    //     if (
-    //       v1.change &&
-    //       v1.change.length > 0 &&
-    //       v1.child &&
-    //       v1.child.length > 0
-    //     ) {
-    //       this.left.header.push({
-    //         spec_id: v1.spec_id,
-    //         spec_name: v1.spec_name,
-    //       });
-    //       let arr = [];
-    //       let changeList = v1.change;
-    //       changeList.forEach((v2) => {
-    //         let index = v1.child.findIndex((v3) => v2 === v3.id);
-    //         if (index !== -1) {
-    //           let x = {
-    //             spec_id: v1.spec_id,
-    //             spec_name: v1.spec_name,
-    //             id: v1.child[index].id,
-    //             spec_value: v1.child[index].spec_value,
-    //           };
-    //           arr.push(x);
-    //         }
-    //       });
-    //       this.left.middle.push(arr);
-    //     }
-    //   });
-    //   let lang = this.left.header.length;
-    //   this.leftS = lang * 70 + "px";
-    //   if (this.left.middle.length > 1) {
-    //     this.left.specList = this.doExchange(this.left.middle);
-    //   } else if (this.left.middle.length === 0) {
-    //     this.left.specList = [];
-    //   } else {
-    //     let list1 = [];
-    //     this.left.middle.forEach((v1) => {
-    //       if (v1) {
-    //         v1.forEach((v2) => {
-    //           let list2 = [];
-    //           list2.push(v2);
-    //           list1.push(list2);
-    //         });
-    //       }
-    //     });
-    //     this.left.specList = list1;
-    //   }
-    //   this.right.header = [];
-    //   for (let i = 0; i < this.ladderNum; i++) {
-    //     this.right.header.push(this.headLadder);
-    //   }
-    //   this.right.specList = [];
-    //   this.left.specList.forEach((v1) => {
-    //     let arr = [];
-    //     let model = {
-    //       specid: [],
-    //       limit: [],
-    //     };
-    //     v1.forEach((v2) => {
-    //       model.specid.push(v2.id);
-    //     });
-    //     for (let i = 0; i < this.ladderNum; i++) {
-    //       let bodyLadder = {
-    //         num: 0,
-    //         price: 0,
-    //       };
-    //       model.limit.push(bodyLadder);
-    //     }
-    //     arr.push(model);
-    //     this.right.specList.push(arr);
-    //   });
-    //   console.log(this.right.specList);
-    // },
-
-    // closeLadder(index) {
-    //   console.log(index);
-    // },
-    // async handleChange(type) {
-    //   if (this.ruleForm.catid !== this.oldcatid && this.oldcatid.length === 0) {
-    //     await this.specByCat();
-
-    //     if (this.step === 0 && !type) {
-    //       this.step = 1;
-    //     }
-    //   } else if (
-    //     this.ruleForm.catid !== this.oldcatid &&
-    //     this.oldcatid.length > 0
-    //   ) {
-    //     await this.$confirm(
-    //       "分类修改会影响该商品规格与价格!",
-    //       "确定要修改?",
-    //       {
-    //         confirmButtonText: "确定",
-    //         cancelButtonText: "取消",
-    //         type: "warning",
-    //       }
-    //     )
-    //       .then(async () => {
-    //         await this.specByCat();
-    //         if (this.step === 0) {
-    //           this.step = 1;
-    //         }
-    //       })
-    //       .catch(() => {
-    //         this.ruleForm.catid = this.oldcatid;
-    //       });
-    //   } else {
-    //     if (this.step === 0 && !type) {
-    //       this.step = 1;
-    //     }
-    //   }
-    // },
-    // //  商品种类ID换取规格值
-    // async specByCat(type) {
-    //   console.log("准备拉取!");
-    //   this.mock = [];
-    //   this.$set(this.mock);
-    //   let list = this.ruleForm.catid;
-    //   let res = await asyncRequest.specByCat({ catid: list[list.length - 1] });
-    //   if (res.code === 0) {
-    //     this.dealWitHInitMock(res.data, type);
-    //     this.oldcatid = list;
-    //   } else if (res.code !== 101 && res.code !== 102) {
-    //     this.ruleForm.catid = this.oldcatid;
-    //   }
-    // },
-    // //  规格属性值新建
-    // async specinfoadd(id, value) {
-    //   console.log(id, value);
-    //   let list = this.ruleForm.catid;
-    //   let model = {
-    //     catid: list[list.length - 1],
-    //     specid: id,
-    //     spec_value: value,
-    //   };
-    //   let res = await asyncRequest.specinfoadd(model);
-    //   if (res.code === 0) {
-    //     await this.specByCat(true);
-    //   }
-    // },
-    // dealWitHInitMock(list, type) {
-    //   console.log(list, type);
-    //   if (!type) {
-    //     this.mock = [];
-    //     console.log("12345678");
-    //     console.log(this.mock);
-
-    //     this.left.header = [];
-    //     this.left.specList = [];
-    //     this.right.header = [];
-    //     this.right.specList = [];
-    //     list.map((v1) => {
-    //       v1.value = "";
-    //       v1.change = [];
-    //       return v1;
-    //     });
-    //     this.mock = list;
-    //     console.log(this.mock);
-    //     this.mock.forEach((v3, i) => {
-    //       this.$set(this.mock, i, v3);
-    //     });
-    //   } else {
-    //     let arr = JSON.parse(JSON.stringify(this.mock));
-    //     list.map((v1) => {
-    //       v1.value = "";
-    //       let index = arr.findIndex((v2) => v2.spec_id === v1.spec_id);
-    //       if (index !== -1) {
-    //         v1.change = arr[index].change;
-    //       }
-    //       return v1;
-    //     });
-    //     this.mock = list;
-    //     this.mock.forEach((v3, i) => {
-    //       this.$set(this.mock, i, v3);
-    //     });
-    //   }
-    // },
-    // async getAllbrandid() {
-    //   const res = await asyncRequest.brandAll({});
-    //   if (res.code === 0 && res.data) {
-    //     this.brandidOptions = res.data;
-    //   }
-    // },
-    // async getAllCat() {
-    //   const res = await asyncRequest.catAll({});
-    //   if (res.code === 0 && res.data) {
-    //     let list = res.data;
-    //     list.map((v1) => {
-    //       v1.value = v1.id;
-    //       v1.label = v1.cat_name;
-    //       if (v1.child && v1.child.length > 0) {
-    //         v1.child.map((v2) => {
-    //           v2.value = v2.id;
-    //           v2.label = v2.cat_name;
-    //           if (v2.child && v2.child.length > 0) {
-    //             v2.child.map((v3) => {
-    //               v3.value = v3.id;
-    //               v3.label = v3.cat_name;
-    //               return v3;
-    //             });
-    //             v2.children = v2.child;
-    //           }
-    //           return v2;
-    //         });
-    //         v1.children = v1.child;
-    //       }
-
-    //       return v1;
-    //     });
-    //     this.catOptions = list;
-    //   }
-    // },
-    // async getAllSupplier() {
-    //   const res = await asyncRequest.supplierAll({});
-    //   if (res.code === 0 && res.data) {
-    //     let list = res.data;
-    //     this.supplierOptions = list;
-    //   }
-    // },
     //图片上传失败
     UploadErrorEvent() {
       this.$message.error("图片上传失败!");

+ 163 - 335
src/views/goodStore/goodsCost/components/baseForm.vue

@@ -5,7 +5,7 @@
     :rules="rulesThis"
     ref="ruleForm"
     :size="'mini'"
-    label-width="100px"
+    label-width="110px"
     class="demo-ruleForm"
   >
     <el-row>
@@ -21,17 +21,23 @@
         <el-row>
           <el-col :span="8">
             <el-form-item label="商品分类" prop="a1">
-              <good-class
+              111
+              <!-- <good-class
                 :value="ruleForm.a1"
                 @handleChange="goods_class_change"
                 :disabled="false"
                 :size="'mini'"
+                :isDetail="false"
                 :placeholder="'商品分类'"
-              />
+              /> -->
             </el-form-item>
             <el-form-item label="商品品牌" prop="a2">
               <search-brand
                 :value="ruleForm.a2"
+                :disabled="false"
+                :size="'mini'"
+                :isDetail="false"
+                :placeholder="'商品品牌'"
                 @searchChange="a2searchChange"
               />
             </el-form-item>
@@ -84,6 +90,9 @@
               <search-supplier
                 :value="ruleForm.a6"
                 :placeholder="'供应商'"
+                :disabled="false"
+                :size="'mini'"
+                :isDetail="false"
                 @searchChange="a6searchChange"
               />
             </el-form-item>
@@ -104,8 +113,12 @@
               </el-select>
             </el-form-item>
             <el-form-item label="税点" prop="a8">
-              <search-brand
+              <search-tax
                 :value="ruleForm.a8"
+                :disabled="false"
+                :size="'mini'"
+                :isDetail="false"
+                :placeholder="'税点'"
                 @searchChange="a8searchChange"
               />
             </el-form-item>
@@ -114,6 +127,7 @@
             <el-form-item label="商品名称" prop="b1">
               <el-input
                 placeholder="请输入商品名称"
+                maxlength="100"
                 v-model="ruleForm.b1"
               ></el-input>
             </el-form-item>
@@ -122,6 +136,10 @@
                 <el-form-item label="商品单位" prop="b2">
                   <search-unit
                     :value="ruleForm.b2"
+                    :disabled="false"
+                    :size="'mini'"
+                    :isDetail="false"
+                    :placeholder="'商品单位'"
                     @searchChange="b2searchChange"
                   />
                 </el-form-item>
@@ -148,6 +166,10 @@
                 <el-form-item label="贵金属种类" prop="b4">
                   <search-metal-kind
                     :value="ruleForm.b4"
+                    :disabled="false"
+                    :size="'mini'"
+                    :isDetail="false"
+                    :placeholder="'贵金属种类'"
                     @searchChange="b4searchChange"
                   /> </el-form-item
               ></el-col>
@@ -245,7 +267,14 @@
           <el-table-column fixed="right">
             <template slot="header" slot-scope="scope">
               <span>操作</span>
-              <el-button :size="'mini'" class="fr">添加规格类型</el-button>
+              <el-tooltip
+                class="item"
+                effect="dark"
+                content="添加规格类型"
+                placement="top"
+              >
+                <i class="el-icon-circle-plus-outline fr"  style="font-size:18px;margin-top:2px" />
+              </el-tooltip>
             </template>
             <template slot-scope="scope">
               <el-button
@@ -302,73 +331,128 @@ export default {
       options3: options3,
       options4: options4,
       options5: options5,
-      supplierOptions4: [
-        { id: "0", name: "0%" },
-        { id: "1", name: "1%" },
-        { id: "3", name: "3%" },
-        { id: "6", name: "6%" },
-        { id: "9", name: "9%" },
-        { id: "13", name: "13%" },
-      ],
-      supplierOptions6: [
-        { id: "0", name: "供应商1" },
-        { id: "1", name: "供应商1" },
-      ],
-
       ruleForm: {},
-
       rules: {
-        supplier: [
+        a1: [
           {
             required: true,
-            message: "供应商联系人",
+            message: "商品分类",
             trigger: "change",
           },
         ],
-        image: [
+        a2: [
           {
+            type: "array",
             required: true,
-            message: "商品主图",
+            message: "商品品牌",
             trigger: "change",
           },
         ],
-        a1: [
+        a3: [
           {
             required: true,
-            message: "商品分类",
+            message: "商品重量为合法数字",
+            trigger: "blur",
+          },
+        ],
+        a4: [
+          {
+            required: true,
+            message: "请选择是否定制",
             trigger: "change",
           },
         ],
-        a2: [
+        a5: [
           {
             required: true,
-            message: "商品品牌",
+            message: "请选择是否库存品",
             trigger: "change",
           },
         ],
-        good_name: [
+        a6: [
+          {
+            type: "array",
+            required: true,
+            message: "请选择供应商",
+            trigger: "change",
+          },
+        ],
+        a7: [
+          {
+            required: true,
+            message: "商品主图",
+            trigger: "change",
+          },
+        ],
+        a8: [
+          {
+            type: "array",
+            required: true,
+            message: "请选择税率",
+            trigger: "change",
+          },
+        ],
+        b1: [
           {
             required: true,
             message: "请输入商品名称",
             trigger: "blur",
           },
+        ],
+        b2: [
+          {
+            required: true,
+            message: "请输入商品单位",
+            trigger: "blur",
+          },
+        ],
+        b3: [
+          {
+            required: true,
+            message: "请选择专属类型",
+            trigger: "change",
+          },
+        ],
+        b4: [
+          {
+            type: "array",
+            required: true,
+            message: "请选择贵金属种类",
+            trigger: "change",
+          },
+        ],
+        b5: [
           {
-            min: 2,
-            max: 50,
-            message: "长度在 2 到 50 个字符",
+            required: true,
+            message: "请选择是否启用实时金价",
+            trigger: "change",
+          },
+        ],
+        b6: [
+          {
+            required: true,
+            message: "定制起订量应为合法数字",
             trigger: "blur",
           },
         ],
-        unit: [
+        b7: [
           {
             required: true,
-            message: "请输入商品单位",
+            message: "定制工期为合法数字",
             trigger: "blur",
           },
+        ],
+        b8: [
           {
-            min: 1,
-            max: 10,
-            message: "长度在 1 到 10 个字符",
+            required: true,
+            message: "售后说明不能为空",
+            trigger: "blur",
+          },
+        ],
+        bb1: [
+          {
+            required: true,
+            message: "商品备注不能为空",
             trigger: "blur",
           },
         ],
@@ -382,6 +466,7 @@ export default {
   methods: {
     async initForm() {
       this.loading = true;
+      this.resetFormData();
       this.rulesThis = this.rules;
       await this.resetForm();
       this.loading = false;
@@ -391,10 +476,16 @@ export default {
     },
     async initData() {
       this.loading = true;
-      let res = await asyncRequest.detail({ id: this.id });
+      const { code, data, message } = await asyncRequest.detail({
+        id: this.id,
+      });
       this.loading = false;
-      if (res.code === 0) {
-        await this.resetForm(res.data);
+      if (code === 0) {
+        await this.resetForm(data);
+      } else if (code >= 100 && code <= 104) {
+        await this.logout();
+      } else {
+        this.$message.warning(message);
       }
     },
     async resetForm() {
@@ -403,29 +494,32 @@ export default {
         if (this.$refs.ruleForm) {
           this.$refs.ruleForm.resetFields();
           this.$refs.ruleForm.clearValidate();
-          this.ruleForm = {
-            a1: "",
-            a2: "",
-            a3: "",
-            a4: "",
-            a5: "",
-            a6: "",
-            a7: "",
-            a8: "",
-            b1: "2018春秋新款V领修身丝绒西装女 双排扣复古极简中长款工装外套",
-            b2: "",
-            b3: "",
-            b4: "",
-            b5: "",
-            b6: "",
-            b7: "",
-            b8: "",
-            b9: "",
-            bb1: "",
-          };
+          this.resetFormData();
         }
       });
     },
+    resetFormData() {
+      this.ruleForm = {
+        a1: "",
+        a2: [],
+        a3: "",
+        a4: "",
+        a5: "",
+        a6: [],
+        a7: "",
+        a8: [],
+        b1: "2018春秋新款V领修身丝绒西装女 双排扣复古极简中长款工装外套",
+        b2: "",
+        b3: "",
+        b4: "",
+        b5: "",
+        b6: "",
+        b7: "",
+        b8: "",
+        b9: "",
+        bb1: "",
+      };
+    },
     //商品分类选择
     goods_class_change(e) {
       this.ruleForm.a1 = e;
@@ -435,29 +529,30 @@ export default {
     a2searchChange(e) {
       const { id, code, label } = e;
       if (id) {
-        this.ruleForm.a2 = id;
+        this.ruleForm.a2 = [id];
       } else {
-        this.ruleForm.a2 = "";
+        this.ruleForm.a2 = [];
       }
-      this.$refs.ruleForm.validateField("a1");
+      this.$refs.ruleForm.validateField("a2");
     },
     //供应商选择
     a6searchChange(e) {
       const { id, code, label } = e;
       if (id) {
-        this.ruleForm.a6 = code;
+        this.ruleForm.a6 = [code];
       } else {
-        this.ruleForm.a6 = "";
+        this.ruleForm.a6 = [];
       }
       this.$refs.ruleForm.validateField("a6");
     },
     //税点选择
     a8searchChange(e) {
       const { id, code, label } = e;
+      console.log(e);
       if (id) {
-        this.ruleForm.a8 = code;
+        this.ruleForm.a8 = [id];
       } else {
-        this.ruleForm.a8 = "";
+        this.ruleForm.a8 = [];
       }
       this.$refs.ruleForm.validateField("a8");
     },
@@ -465,9 +560,9 @@ export default {
     b2searchChange(e) {
       const { id, code, label } = e;
       if (id) {
-        this.ruleForm.b2 = code;
+        this.ruleForm.b2 = [code];
       } else {
-        this.ruleForm.b2 = "";
+        this.ruleForm.b2 = [];
       }
       this.$refs.ruleForm.validateField("b2");
     },
@@ -576,274 +671,7 @@ export default {
         }
       });
     },
-    // groupChange($event, index, item) {
-    //   this.$set(this.mock, index, item);
-    //   this.actionSpecList();
-    // },
-    // actionSpecList() {
-    //   // this.leftS = "0px";
-    //   this.left.header = [];
-    //   this.left.middle = [];
-    //   this.left.specList = [];
-    //   console.log(this.mock);
-    //   console.log(this.right.specList);
-    //   this.mock.forEach((v1) => {
-    //     if (
-    //       v1.change &&
-    //       v1.change.length > 0 &&
-    //       v1.child &&
-    //       v1.child.length > 0
-    //     ) {
-    //       this.left.header.push({
-    //         spec_id: v1.spec_id,
-    //         spec_name: v1.spec_name,
-    //       });
-    //       let arr = [];
-    //       let changeList = v1.change;
-    //       changeList.forEach((v2) => {
-    //         let index = v1.child.findIndex((v3) => v2 === v3.id);
-    //         if (index !== -1) {
-    //           let x = {
-    //             spec_id: v1.spec_id,
-    //             spec_name: v1.spec_name,
-    //             id: v1.child[index].id,
-    //             spec_value: v1.child[index].spec_value,
-    //           };
-    //           arr.push(x);
-    //         }
-    //       });
-    //       this.left.middle.push(arr);
-    //     }
-    //   });
-    //   let lang = this.left.header.length;
-    //   this.leftS = lang * 70 + "px";
-    //   if (this.left.middle.length > 1) {
-    //     this.left.specList = this.doExchange(this.left.middle);
-    //   } else if (this.left.middle.length === 0) {
-    //     this.left.specList = [];
-    //   } else {
-    //     let list1 = [];
-    //     this.left.middle.forEach((v1) => {
-    //       if (v1) {
-    //         v1.forEach((v2) => {
-    //           let list2 = [];
-    //           list2.push(v2);
-    //           list1.push(list2);
-    //         });
-    //       }
-    //     });
-    //     this.left.specList = list1;
-    //   }
-    //   this.right.header = [];
-    //   for (let i = 0; i < this.ladderNum; i++) {
-    //     this.right.header.push(this.headLadder);
-    //   }
-    //   this.right.specList = [];
-    //   this.left.specList.forEach((v1) => {
-    //     let arr = [];
-    //     let model = {
-    //       specid: [],
-    //       limit: [],
-    //     };
-    //     v1.forEach((v2) => {
-    //       model.specid.push(v2.id);
-    //     });
-    //     for (let i = 0; i < this.ladderNum; i++) {
-    //       let bodyLadder = {
-    //         num: 0,
-    //         price: 0,
-    //       };
-    //       model.limit.push(bodyLadder);
-    //     }
-    //     arr.push(model);
-    //     this.right.specList.push(arr);
-    //   });
-    //   console.log(this.right.specList);
-    // },
 
-    // closeLadder(index) {
-    //   console.log(index);
-    // },
-    // async handleChange(type) {
-    //   if (this.ruleForm.a1 !== this.olda1 && this.olda1.length === 0) {
-    //     await this.specByCat();
-
-    //     if (this.step === 0 && !type) {
-    //       this.step = 1;
-    //     }
-    //   } else if (
-    //     this.ruleForm.a1 !== this.olda1 &&
-    //     this.olda1.length > 0
-    //   ) {
-    //     await this.$confirm(
-    //       "分类修改会影响该商品规格与价格!",
-    //       "确定要修改?",
-    //       {
-    //         confirmButtonText: "确定",
-    //         cancelButtonText: "取消",
-    //         type: "warning",
-    //       }
-    //     )
-    //       .then(async () => {
-    //         await this.specByCat();
-    //         if (this.step === 0) {
-    //           this.step = 1;
-    //         }
-    //       })
-    //       .catch(() => {
-    //         this.ruleForm.a1 = this.olda1;
-    //       });
-    //   } else {
-    //     if (this.step === 0 && !type) {
-    //       this.step = 1;
-    //     }
-    //   }
-    // },
-    // //  商品种类ID换取规格值
-    // async specByCat(type) {
-    //   console.log("准备拉取!");
-    //   this.mock = [];
-    //   this.$set(this.mock);
-    //   let list = this.ruleForm.a1;
-    //   let res = await asyncRequest.specByCat({ a1: list[list.length - 1] });
-    //   if (res.code === 0) {
-    //     this.dealWitHInitMock(res.data, type);
-    //     this.olda1 = list;
-    //   } else if (res.code !== 101 && res.code !== 102) {
-    //     this.ruleForm.a1 = this.olda1;
-    //   }
-    // },
-    // //  规格属性值新建
-    // async specinfoadd(id, value) {
-    //   console.log(id, value);
-    //   let list = this.ruleForm.a1;
-    //   let model = {
-    //     a1: list[list.length - 1],
-    //     specid: id,
-    //     spec_value: value,
-    //   };
-    //   let res = await asyncRequest.specinfoadd(model);
-    //   if (res.code === 0) {
-    //     await this.specByCat(true);
-    //   }
-    // },
-    // dealWitHInitMock(list, type) {
-    //   console.log(list, type);
-    //   if (!type) {
-    //     this.mock = [];
-    //     console.log("12345678");
-    //     console.log(this.mock);
-
-    //     this.left.header = [];
-    //     this.left.specList = [];
-    //     this.right.header = [];
-    //     this.right.specList = [];
-    //     list.map((v1) => {
-    //       v1.value = "";
-    //       v1.change = [];
-    //       return v1;
-    //     });
-    //     this.mock = list;
-    //     console.log(this.mock);
-    //     this.mock.forEach((v3, i) => {
-    //       this.$set(this.mock, i, v3);
-    //     });
-    //   } else {
-    //     let arr = JSON.parse(JSON.stringify(this.mock));
-    //     list.map((v1) => {
-    //       v1.value = "";
-    //       let index = arr.findIndex((v2) => v2.spec_id === v1.spec_id);
-    //       if (index !== -1) {
-    //         v1.change = arr[index].change;
-    //       }
-    //       return v1;
-    //     });
-    //     this.mock = list;
-    //     this.mock.forEach((v3, i) => {
-    //       this.$set(this.mock, i, v3);
-    //     });
-    //   }
-    // },
-    // async getAlla2() {
-    //   const res = await asyncRequest.brandAll({});
-    //   if (res.code === 0 && res.data) {
-    //     this.a2Options = res.data;
-    //   }
-    // },
-    // async getAllCat() {
-    //   const res = await asyncRequest.catAll({});
-    //   if (res.code === 0 && res.data) {
-    //     let list = res.data;
-    //     list.map((v1) => {
-    //       v1.value = v1.id;
-    //       v1.label = v1.cat_name;
-    //       if (v1.child && v1.child.length > 0) {
-    //         v1.child.map((v2) => {
-    //           v2.value = v2.id;
-    //           v2.label = v2.cat_name;
-    //           if (v2.child && v2.child.length > 0) {
-    //             v2.child.map((v3) => {
-    //               v3.value = v3.id;
-    //               v3.label = v3.cat_name;
-    //               return v3;
-    //             });
-    //             v2.children = v2.child;
-    //           }
-    //           return v2;
-    //         });
-    //         v1.children = v1.child;
-    //       }
-
-    //       return v1;
-    //     });
-    //     this.catOptions = list;
-    //   }
-    // },
-    // async getAllSupplier() {
-    //   const res = await asyncRequest.supplierAll({});
-    //   if (res.code === 0 && res.data) {
-    //     let list = res.data;
-    //     this.supplierOptions = list;
-    //   }
-    // },
-    //图片上传失败
-    UploadErrorEvent() {
-      this.$message.error("图片上传失败!");
-      this.$refs.ruleForm.validateField("image");
-    },
-    closeImg(index) {
-      this.ruleForm.image.splice(index, 1);
-      this.$refs.ruleForm.validateField("image");
-    },
-    //图片上传成功
-    UploadSuccessEvent(data) {
-      console.log(data);
-      this.ruleForm.image.push(data.url);
-      this.$message.success("图片上传成功!");
-      this.$refs.ruleForm.validateField("image");
-    },
-    //判断图片规格
-    beforeAvatarUpload(file) {
-      console.log(file);
-      let isJPG = false;
-      if (
-        file.type === "image/jpg" ||
-        file.type === "image/png" ||
-        file.type === "image/bmp" ||
-        file.type === "image/jpeg" ||
-        file.type === "image/gif"
-      ) {
-        isJPG = true;
-      }
-      const isLt2M = file.size / 1024 / 1024 < 1;
-      if (!isJPG) {
-        this.$message.error("图片格式不正确!");
-      }
-      if (!isLt2M) {
-        this.$message.error("图片大小不能超过 1MB!");
-      }
-      return isJPG && isLt2M;
-    },
     doExchange(arr) {
       let len = arr.length;
       // 当数组大于等于2个的时候

+ 1 - 1
src/views/goodStore/goodsCost/components/costForm.vue

@@ -5,7 +5,7 @@
     :rules="rulesThis"
     ref="ruleForm"
     :size="'mini'"
-    label-width="100px"
+    label-width="110px"
     class="demo-ruleForm"
   >
     <el-row>

+ 1 - 1
src/views/goodStore/goodsCost/components/packForm.vue

@@ -5,7 +5,7 @@
     :rules="rulesThis"
     ref="ruleForm"
     :size="'mini'"
-    label-width="100px"
+    label-width="110px"
     class="demo-ruleForm"
   >
     <el-row>

+ 760 - 0
src/views/goodStore/goodsCost/index copy.vue

@@ -0,0 +1,760 @@
+<template>
+  <div class="goodsCost pagePadding">
+    <div
+      v-if="powers && powers.length > 0 && powers.some((item) => item == '001')"
+    >
+      <el-row style="margin-bottom: 10px">
+        <el-col :span="6" style="width: 316px">
+          <period-date-picker
+            :start="parmValue.start"
+            :end="parmValue.end"
+            :type="1"
+            :width="'147px'"
+            :size="searchSize"
+            @timeReturned="timeReturned($event)"
+          ></period-date-picker>
+        </el-col>
+        <el-col :span="18" id="el-cor-full-style">
+          <el-row :gutter="10">
+            <el-col :span="6">
+              <el-cascader
+                v-model="parmValue.catid"
+                style="width: 100%"
+                filterable
+                :size="searchSize"
+                clearable
+                placeholder="商品分类"
+                :options="catOptions"
+                :props="{ expandTrigger: 'hover', checkStrictly: true }"
+                @change="handleChange"
+              ></el-cascader>
+            </el-col>
+            <el-col :span="6">
+              <el-select
+                v-model="parmValue.status"
+                filterable
+                clearable
+                :size="searchSize"
+                placeholder="请选择状态"
+                style="width: 100%"
+              >
+                <el-option
+                  v-for="item in statusList"
+                  :key="'status' + item.code"
+                  :label="item.name"
+                  :value="item.code"
+                />
+              </el-select>
+            </el-col>
+
+            <el-col :span="6">
+              <el-input
+                :size="searchSize"
+                style="100%"
+                v-model="parmValue.supplier_name"
+                :maxlength="40"
+                placeholder="供货商名称"
+              ></el-input>
+            </el-col>
+            <el-col :span="6">
+              <el-input
+                :size="searchSize"
+                style="100%"
+                v-model="parmValue.good_code"
+                :maxlength="40"
+                placeholder="商品编码"
+              ></el-input>
+            </el-col>
+          </el-row>
+        </el-col>
+      </el-row>
+      <el-row style="margin-bottom: 18px">
+        <el-col :span="6" style="width: 316px">
+          <el-input
+            :size="searchSize"
+            :maxlength="10"
+            placeholder="最低售价"
+            v-model="parmValue.sale_price_start"
+            style="width: 150px"
+          ></el-input>
+          <samp>至</samp>
+          <el-input
+            :size="searchSize"
+            :maxlength="10"
+            placeholder="最高售价"
+            v-model="parmValue.sale_price_end"
+            style="width: 150px"
+          ></el-input>
+        </el-col>
+
+        <el-col :span="18" id="el-cor-full-style">
+          <el-row :gutter="10">
+            <el-col :span="12">
+              <el-input
+                :size="searchSize"
+                v-model="parmValue.goods_name"
+                :maxlength="40"
+                placeholder="商品名称"
+              >
+                <el-button
+                  slot="append"
+                  icon="el-icon-search"
+                  @click="searchList"
+                ></el-button>
+              </el-input>
+            </el-col>
+            <el-col :span="12">
+              <el-button
+                v-if="powers.some((item) => item == '024')"
+                type="warning"
+                class="fl"
+                :size="searchSize"
+                @click="restSearch"
+              >
+                重置
+              </el-button>
+              <el-button
+                v-if="powers.some((item) => item == '002')"
+                type="primary"
+                :size="searchSize"
+                class="fr"
+                style="margin-left: 5px"
+                @click="searchList"
+              >
+                刷新
+              </el-button>
+              <el-button
+                v-if="powers.some((item) => item == '003')"
+                type="success"
+                :size="searchSize"
+                style="float: right"
+                @click="routeGoto('goodsCostAdd', {})"
+              >
+                添加
+              </el-button>
+            </el-col>
+          </el-row></el-col
+        >
+      </el-row>
+      <el-table
+        :data="tableData"
+        stripe
+        v-loading="loading"
+        border
+        :size="size"
+        style="width: 100%"
+      >
+        <el-table-column label="商品信息" align="left" min-width="165">
+          <template slot-scope="item">
+            <div class="good_name_title">
+              {{ item.row.good_name }}
+            </div>
+            <div
+              class="good_name_img"
+              v-if="item.row.galleyList && item.row.galleyList.length > 0"
+            >
+              <img
+                v-for="(img, i) in item.row.galleyList"
+                :key="item.row.id + 'goodimg' + i"
+                :src="img"
+                @click="showGalley(item.row.galleyList, i)"
+                alt=""
+              />
+            </div> </template
+        ></el-table-column>
+        <el-table-column label="供应商信息" show-overflow-tooltip align="left">
+          <template slot-scope="item">
+            <div v-if="item.row.supplier_info">
+              <div class="good_name_title">
+                企业:{{ item.row.supplier_info.company }}
+              </div>
+              <div class="good_name_title">
+                联系人:{{ item.row.supplier_info.name }}
+              </div>
+            </div>
+          </template></el-table-column
+        >
+        <el-table-column
+          prop="good_code"
+          label="商品编码"
+          show-overflow-tooltip
+          align="center"
+        ></el-table-column>
+        <el-table-column
+          prop="catName"
+          label="商品分类"
+          show-overflow-tooltip
+          align="center"
+        ></el-table-column>
+
+        <el-table-column label="状态" show-overflow-tooltip align="center">
+          <template slot-scope="scope">
+            <el-tag
+              v-if="scope.row.status === '1'"
+              type="success"
+              :class="{ 'hover-tag': powers.some((item) => item == '004') }"
+              :size="tablebtnSize"
+              @click="
+                statusConfirm(
+                  scope.row.id,
+                  scope.row.status,
+                  powers.some((item) => item == '026')
+                )
+              "
+            >
+              <i
+                class="el-icon-thumb"
+                v-if="powers.some((item) => item == '026')"
+                style="margin-right: 1px"
+              ></i>
+              销售中</el-tag
+            >
+            <el-tag
+              v-else
+              :class="{ 'hover-tag': powers.some((item) => item == '026') }"
+              :size="tablebtnSize"
+              type="warning"
+              @click="
+                statusConfirm(
+                  scope.row.id,
+                  scope.row.status,
+                  powers.some((item) => item == '026')
+                )
+              "
+            >
+              <i
+                class="el-icon-thumb"
+                v-if="powers.some((item) => item == '026')"
+                style="margin-right: 1px"
+              ></i>
+              已下架</el-tag
+            >
+          </template>
+        </el-table-column>
+        <el-table-column
+          prop="addtime"
+          label="创建时间"
+          show-overflow-tooltip
+          align="center"
+        ></el-table-column>
+        <el-table-column fixed="right" label="操作" align="center">
+          <template slot-scope="scope">
+            <el-link
+              v-if="powers.some((item) => item == '011')"
+              type="primary"
+              style="margin: 0 4px"
+              :underline="false"
+              :size="tablebtnSize"
+              @click="
+                showPrice(
+                  scope.row.LimitPrice,
+                  scope.row.left,
+                  scope.row.right,
+                  scope.row.lang
+                )
+              "
+            >
+              价格
+            </el-link>
+            <el-link
+              v-if="powers.some((item) => item == '012')"
+              type="primary"
+              style="margin: 0 4px"
+              :underline="false"
+              :size="tablebtnSize"
+              @click="copy(scope.row.id)"
+            >
+              复制
+            </el-link>
+            <el-link
+              v-if="
+                scope.row.status === '0' && powers.some((item) => item == '005')
+              "
+              type="primary"
+              style="margin: 0 4px"
+              :underline="false"
+              :size="tablebtnSize"
+              @click="openModal(scope.row.id, false)"
+            >
+              修改
+            </el-link>
+            <el-link
+              v-if="powers.some((item) => item == '006')"
+              type="primary"
+              style="margin: 0 4px"
+              :underline="false"
+              :size="tablebtnSize"
+              @click="deleteById(scope.row.id, scope.row.status)"
+            >
+              删除
+            </el-link>
+          </template>
+        </el-table-column>
+      </el-table>
+      <div
+        class="Pagination"
+        style="text-align: right; margin-top: 10px"
+        v-show="count > 0"
+      >
+        <el-pagination
+          :size="searchSize"
+          @size-change="handleSizeChange"
+          @current-change="handlePageChange"
+          :current-page="parmValue.page"
+          :page-sizes="[10, 15, 20, 30, 40]"
+          :page-size="parmValue.size"
+          layout="total, sizes, prev, pager, next, jumper"
+          :total="count"
+        ></el-pagination>
+      </div>
+    
+      <ladder-price
+        :showModel="showLadderPrice"
+        :left="left"
+        :right="right"
+        :lang="lang"
+        @cancel="showLadderPrice = false"
+      ></ladder-price>
+  
+    </div>
+    <div v-else>
+      <no-auth></no-auth>
+    </div>
+  </div>
+</template>
+   <script>
+import mixinPage from "@/mixins/elPaginationHandle";
+import asyncRequest from "@/apis/service/goodStore/goodsCost";
+import ladderPrice from "./ladderPrice";
+import statusList from "@/assets/js/statusList";
+import { timestampToTime } from "@/utils/validate";
+import { mapGetters } from "vuex";
+import resToken from "@/mixins/resToken";
+export default {
+  name: "goodsCost",
+  mixins: [resToken, mixinPage],
+  components: {
+    ladderPrice,
+  },
+  computed: {
+    ...mapGetters(["tablebtnSize", "searchSize", "size"]),
+    powers() {
+      let tran =
+        this.$store.getters.btnList.find(
+          (item) => item.menu_route == "goodsCost"
+        ) || {};
+      if (tran && tran.action && tran.action.length > 0) {
+        return tran.action;
+      } else {
+        return [];
+      }
+    },
+  },
+  data() {
+    return {
+      imgList: [],
+      index: 0,
+      showImgModel: false,
+      statusList: statusList,
+      catOptions: [],
+      showLadderPrice: false,
+      loading: false,
+      showModel: false,
+      isDetail: false,
+      modelId: 0,
+      left: {},
+      right: {},
+      lang: "0px",
+      parmValue: {
+        catid: "", //种类id
+        start: "", //起始时间,
+        end: "", //结束时间
+        sale_price_start: "", //最低售价
+        sale_price_end: "", //最高售价
+        status: "",
+        goods_name: "", //商品名称
+        good_code: "", //商品code
+        supplier_name: "", //供货商
+        page: 1, // 页码
+        size: 10, // 每页显示条数
+      },
+      count: 0, // 总条数
+      tableData: [],
+      headLadder: {
+        num: "起订量≥",
+        price: "成本价",
+      },
+    };
+  },
+
+  mounted() {
+    // this.searchList();
+    // this.getAllCat();
+  },
+
+  methods: {
+    restSearch() {
+      this.parmValue = {
+        catid: "", //种类id
+        start: "", //起始时间,
+        end: "", //结束时间
+        sale_price_start: "", //最低售价
+        sale_price_end: "", //最高售价
+        status: "",
+        goods_name: "", //商品名称
+        good_code: "", //商品code
+        supplier_name: "", //供货商
+        page: 1, // 页码
+        size: 10, // 每页显示条数
+      };
+      this.searchList();
+    },
+    async handleChange() {
+      this.parmValue.page = 1;
+      await this.searchList();
+    },
+    async timeReturned(e) {
+      if (e.startTime !== "") {
+        this.parmValue.start = timestampToTime(e.startTime);
+      } else {
+        this.parmValue.start = "";
+      }
+
+      if (e.endTime !== "") {
+        this.parmValue.end = timestampToTime(e.endTime);
+      } else {
+        this.parmValue.end = "";
+      }
+      if (this.parmValue.start !== "" && this.parmValue.end !== "") {
+        this.parmValue.page = 1;
+        await this.searchList();
+      }
+    },
+    openModal(id, isDetail) {
+      if (id !== "add") {
+        this.$message.warning("正在开发中!");
+      } else {
+        this.showModel = true;
+        this.modelId = id;
+        this.isDetail = isDetail;
+      }
+    },
+    showGalley(list, i) {
+      this.imgList = list;
+      this.index = i;
+      this.showImgModel = true;
+    },
+    async copy(id) {
+      let res = await asyncRequest.copy({ id: id });
+      if (res.code === 0) {
+        this.$notify.success({
+          title: "商品复制成功!",
+          message: "",
+        });
+        this.searchList();
+      }
+    },
+    async deleteById(id, status) {
+      if (status === "0") {
+        await this.$confirm("确定要删除该商品?", {
+          confirmButtonText: "确定",
+          cancelButtonText: "取消",
+          type: "warning",
+        })
+          .then(async () => {
+            let res = await asyncRequest.delete({ goodids: id });
+            if (res.code === 0) {
+              this.$notify.success({
+                title: "删除成功",
+                message: "",
+              });
+              this.searchList();
+            }
+          })
+          .catch(() => {
+            console.log("取消");
+          });
+      } else {
+        this.$message.warning("只有已下架的商品才能被删除!");
+      }
+    },
+    showPrice(attr, left, right, lang) {
+      if (attr && attr.length > 0) {
+        this.left = left;
+        this.right = right;
+        this.lang = lang;
+        this.showLadderPrice = true;
+      } else {
+        this.$message.warning("该商品暂无阶梯价格信息!");
+      }
+    },
+    async searchList() {
+      let obj = JSON.parse(JSON.stringify(this.parmValue));
+
+      if (obj.catid === "") {
+        obj.catid = "0";
+      }
+      this.loading = true;
+      let res = await asyncRequest.list(obj);
+      if (res.code === 0 && res.data) {
+        let list = res.data.list;
+
+        list = list.map((v1) => {
+          v1.catName = "";
+          v1.galleyList = v1.galley.split(",");
+          v1.addtime = v1.addtime.replaceAll(".000", "");
+          if (v1 && v1.cat && v1.cat.length > 0) {
+            v1.cat.forEach((v2, index) => {
+              v1.catName += index !== 0 ? "/" + v2.cat_name : v2.cat_name;
+            });
+          } else {
+            v1.catName = "";
+          }
+          if (v1 && v1.LimitPrice && v1.LimitPrice.length > 0) {
+            v1.left = {
+              header: [],
+              spec: [],
+            };
+            v1.right = {
+              header: [],
+              spec: [],
+            };
+            v1.left.header = v1.LimitPrice[0].spec;
+            v1.lang = v1.left.header.length * 100 + "px";
+            let ladderNum = 0;
+            v1.LimitPrice.forEach((a) => {
+              if (a.limit && a.limit.length > ladderNum) {
+                ladderNum = a.limit.length;
+              }
+              if (a.spec && a.spec.length > 0) {
+                v1.left.spec.push(a.spec);
+              }
+            });
+            for (let i = 0; i < ladderNum; i++) {
+              v1.right.header.push(this.headLadder);
+            }
+
+            v1.right.spec = v1.LimitPrice;
+            v1.right.spec.map((v1) => {
+              if (v1.limit && v1.limit.length > 0) {
+                for (let j = 0; j < ladderNum; j++) {
+                  if (!v1.limit[j]) {
+                    v1.limit.push({
+                      begin_num: "",
+                      shop_price: "",
+                    });
+                  }
+                }
+              }
+            });
+          }
+          return v1;
+        });
+        this.tableData = list;
+        this.count = Number(res.data.count);
+      } else {
+        this.tableData = [];
+        this.count = 0;
+      }
+      this.loading = false;
+    },
+    async getAllCat() {
+      const res = await asyncRequest.catAll({});
+      if (res.code === 0 && res.data) {
+        let list = res.data;
+        list.map((v1) => {
+          v1.value = v1.id;
+          v1.label = v1.cat_name;
+          if (v1.child && v1.child.length > 0) {
+            v1.child.map((v2) => {
+              v2.value = v2.id;
+              v2.label = v2.cat_name;
+              if (v2.child && v2.child.length > 0) {
+                v2.child.map((v3) => {
+                  v3.value = v3.id;
+                  v3.label = v3.cat_name;
+                  return v3;
+                });
+                v2.children = v2.child;
+              }
+              return v2;
+            });
+            v1.children = v1.child;
+          }
+          return v1;
+        });
+        this.catOptions = list;
+      }
+    },
+    async statusConfirm(id, status, type) {
+      if (!type) {
+        return;
+      }
+      await this.$confirm(
+        `确定要改为${status === "1" ? "已下架" : "销售中"}?`,
+        {
+          confirmButtonText: "确定",
+          cancelButtonText: "取消",
+          type: "warning",
+        }
+      )
+        .then(async () => {
+          this.loading = true;
+          const model = {
+            goodids: id,
+            status: status === "1" ? "0" : "1",
+          };
+          const res = await asyncRequest.status(model);
+          if (res.code === 0) {
+            this.loading = false;
+            this.$notify.success({
+              title: "状态修改成功!",
+              message: "",
+            });
+            await this.searchList();
+          } else {
+            this.loading = false;
+          }
+        })
+        .catch(() => {
+          console.log("取消");
+        });
+    },
+  },
+};
+</script>
+   <style lang="scss" scoped>
+.goodsCost {
+  $gBC: #dfe6ec;
+  .list-table {
+    position: relative;
+    width: 100%;
+    border-top: 1px solid $gBC;
+    border-left: 1px solid $gBC;
+    .left {
+      position: absolute;
+      top: 0;
+      left: 0;
+      z-index: 2;
+      background: #fff;
+      .header {
+        width: 100%;
+        display: flex;
+        .header-item {
+          width: 100px;
+          flex: 1;
+          padding: 0 10px;
+          height: 50px;
+          line-height: 50px;
+          border-right: 1px solid $gBC;
+          border-bottom: 1px solid $gBC;
+        }
+      }
+      .header-body {
+        width: 100%;
+        position: relative;
+        .header-body-row {
+          width: 100%;
+          display: flex;
+          .heder-body-col {
+            flex: 1;
+            padding: 0 10px;
+            height: 30px;
+            border-right: 1px solid $gBC;
+            border-bottom: 1px solid $gBC;
+            line-height: 30px;
+          }
+        }
+      }
+    }
+    .right {
+      position: relative;
+      width: 100%;
+      display: block;
+      overflow-x: scroll;
+      .header {
+        width: 100%;
+        display: flex;
+        .header-col {
+          min-width: 240px;
+          flex: 1;
+          height: 50px;
+          line-height: 50px;
+
+          // position: relative;
+          .header-col-jieti {
+            height: 50px;
+            line-height: 50px;
+            // position: relative;
+            width: 100%;
+            .header-col-jieti-title {
+              // position: relative;
+              width: 100%;
+              line-height: 25px;
+              border-right: 1px solid $gBC;
+              border-bottom: 1px solid $gBC;
+              height: 25px;
+            }
+            .header-col-jieti-main {
+              // position: relative;
+              width: 100%;
+              .header-col-item {
+                // position: relative;
+                height: 25px;
+                line-height: 25px;
+                width: 50%;
+                border-right: 1px solid $gBC;
+                border-bottom: 1px solid $gBC;
+              }
+            }
+          }
+        }
+      }
+      .right-body {
+        position: relative;
+        .right-body-col {
+          position: relative;
+          width: 100%;
+          display: flex;
+          .right-body-col-item {
+            min-width: 240px;
+            flex: 1;
+
+            position: relative;
+            overflow: hidden;
+            .right-body-col-item-div {
+              position: relative;
+              height: 30px;
+              line-height: 30px;
+              width: 50%;
+              padding: 0 10px;
+              border-right: 1px solid $gBC;
+              border-bottom: 1px solid $gBC;
+            }
+          }
+        }
+      }
+    }
+  }
+  .good_name_img {
+    position: relative;
+    width: 156px;
+    img {
+      position: relative;
+      width: 30px;
+      height: 30px;
+      display: inline-block;
+      border-top: 1px solid #dfe6ec;
+      border-right: 1px solid #dfe6ec;
+      border-bottom: 1px solid #dfe6ec;
+      &:hover {
+        cursor: pointer;
+      }
+      &:first-child {
+        border-left: 1px solid #dfe6ec;
+      }
+    }
+  }
+}
+</style>
+   

+ 309 - 643
src/views/goodStore/goodsCost/index.vue

@@ -1,42 +1,52 @@
 <template>
   <div class="goodsCost pagePadding">
-    <div
+    <ex-table
+      v-loading="loading"
       v-if="powers && powers.length > 0 && powers.some((item) => item == '001')"
+      :table="table"
+      :data="tableData"
+      :columns="columns"
+      :page="pageInfo"
+      :size="size"
+      @page-curr-change="handlePageChange"
+      @page-size-change="handleSizeChange"
+      @screen-reset="
+        pageInfo.curr = 1;
+        parmValue.page = 1;
+        searchList();
+      "
+      @screen-submit="
+        pageInfo.curr = 1;
+        parmValue.page = 1;
+        searchList();
+      "
     >
-      <el-row style="margin-bottom: 10px">
-        <el-col :span="6" style="width: 316px">
-          <period-date-picker
-            :start="parmValue.start"
-            :end="parmValue.end"
-            :type="1"
-            :width="'147px'"
-            :size="searchSize"
-            @timeReturned="timeReturned($event)"
-          ></period-date-picker>
-        </el-col>
-        <el-col :span="18" id="el-cor-full-style">
-          <el-row :gutter="10">
-            <el-col :span="6">
-              <el-cascader
-                v-model="parmValue.catid"
-                style="width: 100%"
-                filterable
+      <template #table-header="{}">
+        <div style="width: 100%">
+          <el-row style="padding: 0 0 10px 80px">
+            <el-col :span="6" style="width: 303px">
+              <period-date-picker
+                :type="1"
+                :width="'135px'"
                 :size="searchSize"
-                clearable
-                placeholder="商品分类"
-                :options="catOptions"
-                :props="{ expandTrigger: 'hover', checkStrictly: true }"
-                @change="handleChange"
-              ></el-cascader>
+                :start="parmValue.start"
+                :end="parmValue.end"
+                @timeReturned="handleTime"
+              />
             </el-col>
-            <el-col :span="6">
+            <el-col :span="4" style="width: 160px">
               <el-select
                 v-model="parmValue.status"
                 filterable
                 clearable
                 :size="searchSize"
-                placeholder="请选择状态"
+                placeholder="单位状态"
                 style="width: 100%"
+                @change="
+                  pageInfo.curr = 1;
+                  parmValue.page = 1;
+                  searchList();
+                "
               >
                 <el-option
                   v-for="item in statusList"
@@ -47,296 +57,166 @@
               </el-select>
             </el-col>
 
-            <el-col :span="6">
-              <el-input
-                :size="searchSize"
-                style="100%"
-                v-model="parmValue.supplier_name"
-                :maxlength="40"
-                placeholder="供货商名称"
-              ></el-input>
+            <el-col
+              :span="3"
+              class="fr"
+              style="width: 66px; padding: 0 0 0 10px"
+            >
+              <el-button type="primary" :size="searchSize" @click="searchList">
+                刷新
+              </el-button>
             </el-col>
-            <el-col :span="6">
+            <el-col
+              :span="3"
+              class="fr"
+              style="width: 66px; padding: 0 0 0 10px"
+            >
+              <el-button type="warning" :size="searchSize" @click="restSearch">
+                重置
+              </el-button>
+            </el-col>
+          </el-row>
+          <el-row>
+            <el-col :span="4" style="width: 373px">
               <el-input
                 :size="searchSize"
-                style="100%"
-                v-model="parmValue.good_code"
+                v-model="parmValue.name"
                 :maxlength="40"
-                placeholder="商品编码"
+                @blur="
+                  pageInfo.curr = 1;
+                  parmValue.page = 1;
+                  searchList();
+                "
+                placeholder="单位名称"
               ></el-input>
             </el-col>
-          </el-row>
-        </el-col>
-      </el-row>
-      <el-row style="margin-bottom: 18px">
-        <el-col :span="6" style="width: 316px">
-          <el-input
-            :size="searchSize"
-            :maxlength="10"
-            placeholder="最低售价"
-            v-model="parmValue.sale_price_start"
-            style="width: 150px"
-          ></el-input>
-          <samp>至</samp>
-          <el-input
-            :size="searchSize"
-            :maxlength="10"
-            placeholder="最高售价"
-            v-model="parmValue.sale_price_end"
-            style="width: 150px"
-          ></el-input>
-        </el-col>
-
-        <el-col :span="18" id="el-cor-full-style">
-          <el-row :gutter="10">
-            <el-col :span="12">
+            <el-col :span="4" style="width: 170px; padding: 0 0 0 10px">
               <el-input
                 :size="searchSize"
-                v-model="parmValue.goods_name"
+                v-model="parmValue.creater"
                 :maxlength="40"
-                placeholder="商品名称"
-              >
-                <el-button
-                  slot="append"
-                  icon="el-icon-search"
-                  @click="searchList"
-                ></el-button>
-              </el-input>
+                @change="
+                  pageInfo.curr = 1;
+                  parmValue.page = 1;
+                  searchList();
+                "
+                placeholder="创建人"
+              ></el-input>
             </el-col>
-            <el-col :span="12">
-              <el-button
-                v-if="powers.some((item) => item == '024')"
-                type="warning"
-                class="fl"
-                :size="searchSize"
-                @click="restSearch"
-              >
-                重置
-              </el-button>
+            <el-col
+              :span="3"
+              class="fr"
+              style="width: 66px; padding: 0 0 0 10px"
+              v-if="powers.some((item) => item == '003')"
+            >
               <el-button
-                v-if="powers.some((item) => item == '002')"
-                type="primary"
                 :size="searchSize"
-                class="fr"
-                style="margin-left: 5px"
-                @click="searchList"
-              >
-                刷新
-              </el-button>
-              <el-button
-                v-if="powers.some((item) => item == '003')"
                 type="success"
-                :size="searchSize"
                 style="float: right"
                 @click="routeGoto('goodsCostAdd', {})"
               >
                 添加
               </el-button>
             </el-col>
-          </el-row></el-col
-        >
-      </el-row>
-      <el-table
-        :data="tableData"
-        stripe
-        v-loading="loading"
-        border
-        :size="size"
-        style="width: 100%"
+          </el-row>
+        </div></template
       >
-        <el-table-column label="商品信息" align="left" min-width="165">
-          <template slot-scope="item">
-            <div class="good_name_title">
-              {{ item.row.good_name }}
-            </div>
-            <div
-              class="good_name_img"
-              v-if="item.row.galleyList && item.row.galleyList.length > 0"
-            >
-              <img
-                v-for="(img, i) in item.row.galleyList"
-                :key="item.row.id + 'goodimg' + i"
-                :src="img"
-                @click="showGalley(item.row.galleyList, i)"
-                alt=""
-              />
-            </div> </template
-        ></el-table-column>
-        <el-table-column label="供应商信息" show-overflow-tooltip align="left">
-          <template slot-scope="item">
-            <div v-if="item.row.supplier_info">
-              <div class="good_name_title">
-                企业:{{ item.row.supplier_info.company }}
-              </div>
-              <div class="good_name_title">
-                联系人:{{ item.row.supplier_info.name }}
-              </div>
-            </div>
-          </template></el-table-column
-        >
-        <el-table-column
-          prop="good_code"
-          label="商品编码"
-          show-overflow-tooltip
-          align="center"
-        ></el-table-column>
-        <el-table-column
-          prop="catName"
-          label="商品分类"
-          show-overflow-tooltip
-          align="center"
-        ></el-table-column>
+      <template #status="{ scope }">
+        <el-tag
+          :size="tablebtnSize"
+          :type="scope.row.status == '1' ? 'warning' : ''"
+          v-text="
+            (statusOptions.find((item) => item.id == scope.row.status) || {})
+              .label || '--'
+          "
+        ></el-tag>
+      </template>
 
-        <el-table-column label="状态" show-overflow-tooltip align="center">
-          <template slot-scope="scope">
-            <el-tag
-              v-if="scope.row.status === '1'"
-              type="success"
-              :class="{ 'hover-tag': powers.some((item) => item == '004') }"
-              :size="tablebtnSize"
-              @click="
-                statusConfirm(
-                  scope.row.id,
-                  scope.row.status,
-                  powers.some((item) => item == '026')
-                )
-              "
-            >
-              <i
-                class="el-icon-thumb"
-                v-if="powers.some((item) => item == '026')"
-                style="margin-right: 1px"
-              ></i>
-              销售中</el-tag
-            >
-            <el-tag
-              v-else
-              :class="{ 'hover-tag': powers.some((item) => item == '026') }"
-              :size="tablebtnSize"
-              type="warning"
-              @click="
-                statusConfirm(
-                  scope.row.id,
-                  scope.row.status,
-                  powers.some((item) => item == '026')
-                )
-              "
-            >
-              <i
-                class="el-icon-thumb"
-                v-if="powers.some((item) => item == '026')"
-                style="margin-right: 1px"
-              ></i>
-              已下架</el-tag
-            >
-          </template>
-        </el-table-column>
-        <el-table-column
-          prop="addtime"
-          label="创建时间"
-          show-overflow-tooltip
-          align="center"
-        ></el-table-column>
-        <el-table-column fixed="right" label="操作" align="center">
-          <template slot-scope="scope">
-            <el-link
-              v-if="powers.some((item) => item == '011')"
-              type="primary"
-              style="margin: 0 4px"
-              :underline="false"
-              :size="tablebtnSize"
-              @click="
-                showPrice(
-                  scope.row.LimitPrice,
-                  scope.row.left,
-                  scope.row.right,
-                  scope.row.lang
-                )
-              "
-            >
-              价格
-            </el-link>
-            <el-link
-              v-if="powers.some((item) => item == '012')"
-              type="primary"
-              style="margin: 0 4px"
-              :underline="false"
-              :size="tablebtnSize"
-              @click="copy(scope.row.id)"
-            >
-              复制
-            </el-link>
-            <el-link
-              v-if="
-                scope.row.status === '0' && powers.some((item) => item == '005')
-              "
-              type="primary"
-              style="margin: 0 4px"
-              :underline="false"
-              :size="tablebtnSize"
-              @click="openModal(scope.row.id, false)"
-            >
-              修改
-            </el-link>
-            <el-link
-              v-if="powers.some((item) => item == '006')"
-              type="primary"
-              style="margin: 0 4px"
-              :underline="false"
-              :size="tablebtnSize"
-              @click="deleteById(scope.row.id, scope.row.status)"
-            >
-              删除
-            </el-link>
-          </template>
-        </el-table-column>
-      </el-table>
-      <div
-        class="Pagination"
-        style="text-align: right; margin-top: 10px"
-        v-show="count > 0"
-      >
-        <el-pagination
-          :size="searchSize"
-          @size-change="handleSizeChange"
-          @current-change="handlePageChange"
-          :current-page="parmValue.page"
-          :page-sizes="[10, 15, 20, 30, 40]"
-          :page-size="parmValue.size"
-          layout="total, sizes, prev, pager, next, jumper"
-          :total="count"
-        ></el-pagination>
-      </div>
-    
-      <ladder-price
-        :showModel="showLadderPrice"
-        :left="left"
-        :right="right"
-        :lang="lang"
-        @cancel="showLadderPrice = false"
-      ></ladder-price>
-  
-    </div>
-    <div v-else>
-      <no-auth></no-auth>
-    </div>
+      <template #operation="{ scope }">
+        <el-tooltip
+          v-if="powers.some((item) => item == '007')"
+          effect="dark"
+          content="详情"
+          placement="top"
+        >
+          <i
+            class="el-icon-view tb-icon"
+            @click="openModal(scope.row, '007')"
+          ></i>
+        </el-tooltip>
+        <el-tooltip
+          v-if="powers.some((item) => item == '005')"
+          effect="dark"
+          content="修改"
+          placement="top"
+        >
+          <i
+            class="el-icon-edit tb-icon"
+            @click="openModal(scope.row, '005')"
+          ></i>
+        </el-tooltip>
+        <el-tooltip
+          v-if="
+            powers.some((item) => item == '004') && scope.row.status === '0'
+          "
+          effect="dark"
+          content="禁用"
+          placement="top"
+        >
+          <i
+            class="el-icon-video-pause tb-icon"
+            @click="changeStatus(scope.row.id, scope.row.status)"
+          ></i>
+        </el-tooltip>
+        <el-tooltip
+          v-if="
+            powers.some((item) => item == '004') && scope.row.status === '1'
+          "
+          effect="dark"
+          content="启用"
+          placement="top"
+        >
+          <i
+            class="el-icon-video-play tb-icon"
+            @click="changeStatus(scope.row.id, scope.row.status)"
+          ></i>
+        </el-tooltip>
+        <el-tooltip
+          v-if="powers.some((item) => item == '006')"
+          effect="dark"
+          content="删除"
+          placement="top"
+        >
+          <i
+            class="el-icon-delete tb-icon"
+            @click="deleteItem(scope.row.id)"
+          ></i>
+        </el-tooltip>
+      </template>
+    </ex-table>
+    <no-auth v-else></no-auth>
+    <!-- 弹窗 新增/修改 -->
+    <add-edit
+      :id="modelId"
+      :show-model="showModel"
+      :sitem="sitem"
+      @refresh="searchList"
+      @cancel="showModel = false"
+    />
   </div>
 </template>
-   <script>
-import mixinPage from "@/mixins/elPaginationHandle";
+<script>
 import asyncRequest from "@/apis/service/goodStore/goodsCost";
-import ladderPrice from "./ladderPrice";
 import statusList from "@/assets/js/statusList";
-import { timestampToTime } from "@/utils/validate";
+import roleLevel from "@/assets/js/roleLevel";
+import mixinPage from "@/mixins/elPaginationHandle";
 import { mapGetters } from "vuex";
 import resToken from "@/mixins/resToken";
 export default {
   name: "goodsCost",
-  mixins: [resToken, mixinPage],
-  components: {
-    ladderPrice,
-  },
+  mixins: [mixinPage, resToken],
   computed: {
+    //组件SIZE设置
     ...mapGetters(["tablebtnSize", "searchSize", "size"]),
     powers() {
       let tran =
@@ -352,409 +232,195 @@ export default {
   },
   data() {
     return {
-      imgList: [],
-      index: 0,
-      showImgModel: false,
       statusList: statusList,
-      catOptions: [],
-      showLadderPrice: false,
+      roleLevel: roleLevel,
       loading: false,
       showModel: false,
-      isDetail: false,
-      modelId: 0,
-      left: {},
-      right: {},
-      lang: "0px",
+      modelId: "000",
+      sitem: {},
       parmValue: {
-        catid: "", //种类id
-        start: "", //起始时间,
-        end: "", //结束时间
-        sale_price_start: "", //最低售价
-        sale_price_end: "", //最高售价
-        status: "",
-        goods_name: "", //商品名称
-        good_code: "", //商品code
-        supplier_name: "", //供货商
         page: 1, // 页码
-        size: 10, // 每页显示条数
+        size: 15, // 每页显示条数
+        start: "",
+        end: "",
+        status: "",
+        creater: "",
       },
-      count: 0, // 总条数
+      // 状态
+      statusOptions: [
+        { id: "1", label: "禁用" },
+        { id: "0", label: "启用" },
+      ],
+      // 表格 - 数据
       tableData: [],
-      headLadder: {
-        num: "起订量≥",
-        price: "成本价",
+      // 表格 - 参数
+      table: {
+        stripe: true,
+        border: true,
+        _defaultHeader_: ["setcol"],
+      },
+      // 表格 - 分页
+      pageInfo: {
+        size: 15,
+        curr: 1,
+        total: 0,
       },
+      // 表格 - 列参数
+      columns: [
+        {
+          prop: "id",
+          label: "ID",
+        },
+        {
+          prop: "goodsCost",
+          label: "单位名称",
+        },
+        {
+          prop: "status",
+          label: "状态",
+          sortable: true,
+          _slot_: "status",
+        },
+        {
+          prop: "creater",
+          label: "创建人",
+        },
+        {
+          prop: "addtime",
+          label: "创建时间",
+          sortable: true,
+        },
+        {
+          prop: "",
+          label: "操作",
+          fixed: "right",
+          _noset_: true,
+          _slot_: "operation",
+        },
+      ],
     };
   },
-
   mounted() {
     // this.searchList();
-    // this.getAllCat();
   },
-
   methods: {
     restSearch() {
+      // 表格 - 分页
+      this.pageInfo = {
+        size: 15,
+        curr: 1,
+        total: 0,
+      };
       this.parmValue = {
-        catid: "", //种类id
-        start: "", //起始时间,
-        end: "", //结束时间
-        sale_price_start: "", //最低售价
-        sale_price_end: "", //最高售价
-        status: "",
-        goods_name: "", //商品名称
-        good_code: "", //商品code
-        supplier_name: "", //供货商
         page: 1, // 页码
-        size: 10, // 每页显示条数
+        size: 15, // 每页显示条数
+        start: "",
+        end: "",
+        status: "",
+        creater: "",
       };
       this.searchList();
     },
-    async handleChange() {
-      this.parmValue.page = 1;
-      await this.searchList();
+    // 新建/编辑/详情
+    openModal(row, type) {
+      this.sitem = row;
+      this.modelId = type;
+      this.showModel = true;
     },
-    async timeReturned(e) {
-      if (e.startTime !== "") {
-        this.parmValue.start = timestampToTime(e.startTime);
-      } else {
-        this.parmValue.start = "";
-      }
-
-      if (e.endTime !== "") {
-        this.parmValue.end = timestampToTime(e.endTime);
-      } else {
-        this.parmValue.end = "";
-      }
-      if (this.parmValue.start !== "" && this.parmValue.end !== "") {
+    // 时间
+    async handleTime(e) {
+      this.parmValue.start = e.startTime || "";
+      this.parmValue.end = e.endTime || "";
+      if (
+        (this.parmValue.start !== "" && this.parmValue.end !== "") ||
+        (this.parmValue.start === "" && this.parmValue.end === "")
+      ) {
+        this.pageInfo.curr = 1;
         this.parmValue.page = 1;
         await this.searchList();
       }
     },
-    openModal(id, isDetail) {
-      if (id !== "add") {
-        this.$message.warning("正在开发中!");
-      } else {
-        this.showModel = true;
-        this.modelId = id;
-        this.isDetail = isDetail;
-      }
-    },
-    showGalley(list, i) {
-      this.imgList = list;
-      this.index = i;
-      this.showImgModel = true;
-    },
-    async copy(id) {
-      let res = await asyncRequest.copy({ id: id });
-      if (res.code === 0) {
-        this.$notify.success({
-          title: "商品复制成功!",
-          message: "",
-        });
-        this.searchList();
-      }
-    },
-    async deleteById(id, status) {
-      if (status === "0") {
-        await this.$confirm("确定要删除该商品?", {
-          confirmButtonText: "确定",
-          cancelButtonText: "取消",
-          type: "warning",
-        })
-          .then(async () => {
-            let res = await asyncRequest.delete({ goodids: id });
-            if (res.code === 0) {
-              this.$notify.success({
-                title: "删除成功",
-                message: "",
-              });
-              this.searchList();
-            }
-          })
-          .catch(() => {
-            console.log("取消");
-          });
-      } else {
-        this.$message.warning("只有已下架的商品才能被删除!");
-      }
-    },
-    showPrice(attr, left, right, lang) {
-      if (attr && attr.length > 0) {
-        this.left = left;
-        this.right = right;
-        this.lang = lang;
-        this.showLadderPrice = true;
-      } else {
-        this.$message.warning("该商品暂无阶梯价格信息!");
-      }
-    },
-    async searchList() {
-      let obj = JSON.parse(JSON.stringify(this.parmValue));
-
-      if (obj.catid === "") {
-        obj.catid = "0";
-      }
-      this.loading = true;
-      let res = await asyncRequest.list(obj);
-      if (res.code === 0 && res.data) {
-        let list = res.data.list;
-
-        list = list.map((v1) => {
-          v1.catName = "";
-          v1.galleyList = v1.galley.split(",");
-          v1.addtime = v1.addtime.replaceAll(".000", "");
-          if (v1 && v1.cat && v1.cat.length > 0) {
-            v1.cat.forEach((v2, index) => {
-              v1.catName += index !== 0 ? "/" + v2.cat_name : v2.cat_name;
-            });
-          } else {
-            v1.catName = "";
-          }
-          if (v1 && v1.LimitPrice && v1.LimitPrice.length > 0) {
-            v1.left = {
-              header: [],
-              spec: [],
-            };
-            v1.right = {
-              header: [],
-              spec: [],
-            };
-            v1.left.header = v1.LimitPrice[0].spec;
-            v1.lang = v1.left.header.length * 100 + "px";
-            let ladderNum = 0;
-            v1.LimitPrice.forEach((a) => {
-              if (a.limit && a.limit.length > ladderNum) {
-                ladderNum = a.limit.length;
-              }
-              if (a.spec && a.spec.length > 0) {
-                v1.left.spec.push(a.spec);
-              }
-            });
-            for (let i = 0; i < ladderNum; i++) {
-              v1.right.header.push(this.headLadder);
-            }
-
-            v1.right.spec = v1.LimitPrice;
-            v1.right.spec.map((v1) => {
-              if (v1.limit && v1.limit.length > 0) {
-                for (let j = 0; j < ladderNum; j++) {
-                  if (!v1.limit[j]) {
-                    v1.limit.push({
-                      begin_num: "",
-                      shop_price: "",
-                    });
-                  }
-                }
-              }
-            });
-          }
-          return v1;
-        });
-        this.tableData = list;
-        this.count = Number(res.data.count);
-      } else {
-        this.tableData = [];
-        this.count = 0;
-      }
-      this.loading = false;
-    },
-    async getAllCat() {
-      const res = await asyncRequest.catAll({});
-      if (res.code === 0 && res.data) {
-        let list = res.data;
-        list.map((v1) => {
-          v1.value = v1.id;
-          v1.label = v1.cat_name;
-          if (v1.child && v1.child.length > 0) {
-            v1.child.map((v2) => {
-              v2.value = v2.id;
-              v2.label = v2.cat_name;
-              if (v2.child && v2.child.length > 0) {
-                v2.child.map((v3) => {
-                  v3.value = v3.id;
-                  v3.label = v3.cat_name;
-                  return v3;
-                });
-                v2.children = v2.child;
-              }
-              return v2;
-            });
-            v1.children = v1.child;
-          }
-          return v1;
-        });
-        this.catOptions = list;
-      }
-    },
-    async statusConfirm(id, status, type) {
-      if (!type) {
-        return;
-      }
-      await this.$confirm(
-        `确定要改为${status === "1" ? "已下架" : "销售中"}?`,
-        {
-          confirmButtonText: "确定",
-          cancelButtonText: "取消",
-          type: "warning",
-        }
-      )
+    /**
+     * 启用/禁用
+     * @param {String} id id
+     * @param {String} status 0-禁用 1-启用
+     */
+    async changeStatus(id, status) {
+      await this.$confirm(`确定要改为${status === "0" ? "禁用" : "启用"}?`, {
+        confirmButtonText: "确定",
+        cancelButtonText: "取消",
+        type: "warning",
+      })
         .then(async () => {
           this.loading = true;
           const model = {
-            goodids: id,
+            id: id,
             status: status === "1" ? "0" : "1",
           };
           const res = await asyncRequest.status(model);
-          if (res.code === 0) {
+          if (res && res.code === 0) {
             this.loading = false;
             this.$notify.success({
               title: "状态修改成功!",
               message: "",
             });
             await this.searchList();
+          } else if (res && res.code >= 100 && res.code <= 104) {
+            await this.logout();
           } else {
             this.loading = false;
+            this.$message.warning(res.message);
+          }
+        })
+        .catch(() => {
+          console.log("取消");
+        });
+    },
+    async deleteItem(id) {
+      await this.$confirm("确定要删除?", {
+        confirmButtonText: "确定",
+        cancelButtonText: "取消",
+        type: "warning",
+      })
+        .then(async () => {
+          const model = {
+            id: id,
+          };
+          const res = await asyncRequest.delete(model);
+          if (res && res.code === 0) {
+            this.$notify.success({
+              title: "删除成功",
+              message: "",
+            });
+            this.searchList();
+          } else if (res && res.code >= 100 && res.code <= 104) {
+            await this.logout();
+          } else {
+            this.$message.warning(res.message);
           }
         })
         .catch(() => {
           console.log("取消");
         });
     },
+    // 刷新表格
+    async searchList() {
+      this.loading = true;
+      const res = await asyncRequest.list(this.parmValue);
+      if (res && res.code === 0 && res.data) {
+        this.tableData = res.data.list;
+        this.pageInfo.total = Number(res.data.count);
+      } else if (res && res.code >= 100 && res.code <= 104) {
+        await this.logout();
+      } else {
+        this.tableData = [];
+        this.pageInfo.total = 0;
+      }
+      this.loading = false;
+    },
   },
 };
 </script>
-   <style lang="scss" scoped>
-.goodsCost {
-  $gBC: #dfe6ec;
-  .list-table {
-    position: relative;
-    width: 100%;
-    border-top: 1px solid $gBC;
-    border-left: 1px solid $gBC;
-    .left {
-      position: absolute;
-      top: 0;
-      left: 0;
-      z-index: 2;
-      background: #fff;
-      .header {
-        width: 100%;
-        display: flex;
-        .header-item {
-          width: 100px;
-          flex: 1;
-          padding: 0 10px;
-          height: 50px;
-          line-height: 50px;
-          border-right: 1px solid $gBC;
-          border-bottom: 1px solid $gBC;
-        }
-      }
-      .header-body {
-        width: 100%;
-        position: relative;
-        .header-body-row {
-          width: 100%;
-          display: flex;
-          .heder-body-col {
-            flex: 1;
-            padding: 0 10px;
-            height: 30px;
-            border-right: 1px solid $gBC;
-            border-bottom: 1px solid $gBC;
-            line-height: 30px;
-          }
-        }
-      }
-    }
-    .right {
-      position: relative;
-      width: 100%;
-      display: block;
-      overflow-x: scroll;
-      .header {
-        width: 100%;
-        display: flex;
-        .header-col {
-          min-width: 240px;
-          flex: 1;
-          height: 50px;
-          line-height: 50px;
-
-          // position: relative;
-          .header-col-jieti {
-            height: 50px;
-            line-height: 50px;
-            // position: relative;
-            width: 100%;
-            .header-col-jieti-title {
-              // position: relative;
-              width: 100%;
-              line-height: 25px;
-              border-right: 1px solid $gBC;
-              border-bottom: 1px solid $gBC;
-              height: 25px;
-            }
-            .header-col-jieti-main {
-              // position: relative;
-              width: 100%;
-              .header-col-item {
-                // position: relative;
-                height: 25px;
-                line-height: 25px;
-                width: 50%;
-                border-right: 1px solid $gBC;
-                border-bottom: 1px solid $gBC;
-              }
-            }
-          }
-        }
-      }
-      .right-body {
-        position: relative;
-        .right-body-col {
-          position: relative;
-          width: 100%;
-          display: flex;
-          .right-body-col-item {
-            min-width: 240px;
-            flex: 1;
 
-            position: relative;
-            overflow: hidden;
-            .right-body-col-item-div {
-              position: relative;
-              height: 30px;
-              line-height: 30px;
-              width: 50%;
-              padding: 0 10px;
-              border-right: 1px solid $gBC;
-              border-bottom: 1px solid $gBC;
-            }
-          }
-        }
-      }
-    }
-  }
-  .good_name_img {
-    position: relative;
-    width: 156px;
-    img {
-      position: relative;
-      width: 30px;
-      height: 30px;
-      display: inline-block;
-      border-top: 1px solid #dfe6ec;
-      border-right: 1px solid #dfe6ec;
-      border-bottom: 1px solid #dfe6ec;
-      &:hover {
-        cursor: pointer;
-      }
-      &:first-child {
-        border-left: 1px solid #dfe6ec;
-      }
-    }
-  }
-}
+<style lang="scss" scoped>
 </style>
-   

+ 344 - 386
src/views/goodStore/unit/index.vue

@@ -1,338 +1,226 @@
 <template>
   <div class="unit pagePadding">
-    <div
+    <ex-table
+      v-loading="loading"
       v-if="powers && powers.length > 0 && powers.some((item) => item == '001')"
+      :table="table"
+      :data="tableData"
+      :columns="columns"
+      :page="pageInfo"
+      :size="size"
+      @page-curr-change="handlePageChange"
+      @page-size-change="handleSizeChange"
+      @screen-reset="
+        pageInfo.curr = 1;
+        parmValue.page = 1;
+        searchList();
+      "
+      @screen-submit="
+        pageInfo.curr = 1;
+        parmValue.page = 1;
+        searchList();
+      "
     >
-      <el-row :gutter="10">
-        <el-col :span="24" style="padding: 0 0 18px 0">
-          <el-col :span="4">
-            <el-select
-              v-model="parmValue.status"
-              filterable
-              clearable
-              :size="searchSize"
-              placeholder="请选择状态"
-              style="width: 100%"
-            >
-              <el-option
-                v-for="item in statusList"
-                :key="'status' + item.code"
-                :label="item.name"
-                :value="item.code"
+      <template #table-header="{}">
+        <div style="width: 100%">
+          <el-row style="padding: 0 0 10px 80px">
+            <el-col :span="6" style="width: 303px">
+              <period-date-picker
+                :type="1"
+                :width="'135px'"
+                :size="searchSize"
+                :start="parmValue.start"
+                :end="parmValue.end"
+                @timeReturned="handleTime"
               />
-            </el-select>
-          </el-col>
-          <el-col :span="4">
-            <el-input
-              :size="searchSize"
-              v-model="parmValue.name"
-              :maxlength="40"
-              placeholder="规格名称"
-            ></el-input>
-          </el-col>
-          <el-col :span="3" style="width: 152px">
-            <el-button
-              type="primary"
-              :size="searchSize"
-              @click="searchList"
-              icon="el-icon-search"
-            ></el-button>
-            <el-button
-              type="warning"
-              v-if="powers.some((item) => item == '024')"
-              :size="searchSize"
-              @click="restSearch"
-            >
-              重置
-            </el-button>
-          </el-col>
-          <el-col :span="3" style="width: 195px; float: right">
-            <el-button
-              v-if="powers.some((item) => item == '002')"
-              type="primary"
-              :size="searchSize"
-              style="float: right; margin-left: 5px"
-              @click="searchList"
-            >
-              刷新
-            </el-button>
-            <el-button
-              v-if="powers.some((item) => item == '003')"
-              :size="searchSize"
-              type="success"
-              style="float: right"
-              @click="openModal('add', false, false)"
-            >
-              添加
-            </el-button>
-          </el-col>
-        </el-col>
-      </el-row>
-      <el-table
-        :data="tableData"
-        stripe
-        v-loading="loading"
-        border
-        :size="size"
-        style="width: 100%"
-      >
-        <el-table-column
-          prop="spec_name"
-          label="规格名称"
-          show-overflow-tooltip
-          align="center"
-        ></el-table-column>
-        <el-table-column label="审核状态" show-overflow-tooltip align="center">
-          <template slot-scope="scope">
-            <el-tag
-              :size="tablebtnSize"
-              v-if="scope.row.ex_status === '0'"
-              :class="{
-                'hover-tag':
-                  scope.row.status === '0' &&
-                  powers.some((item) => item == '010'),
-              }"
-              :type="'warning'"
-              @click="
-                openModal(
-                  scope.row.id,
-                  false,
-                  true,
-                  scope.row.status === '0' &&
-                    powers.some((item) => item == '010')
-                )
-              "
-            >
-              <i
-                class="el-icon-thumb"
-                v-if="
-                  scope.row.status === '0' &&
-                  powers.some((item) => item == '010')
+            </el-col>
+            <el-col :span="4" style="width: 160px">
+              <el-select
+                v-model="parmValue.status"
+                filterable
+                clearable
+                :size="searchSize"
+                placeholder="单位状态"
+                style="width: 100%"
+                @change="
+                  pageInfo.curr = 1;
+                  parmValue.page = 1;
+                  searchList();
                 "
-                style="margin-right: 1px"
-              ></i>
-              {{ scope.row.ex_status_cn }}
-            </el-tag>
-            <el-tag
-              :size="tablebtnSize"
-              v-else-if="scope.row.ex_status === '1'"
-              :type="'success'"
+              >
+                <el-option
+                  v-for="item in statusList"
+                  :key="'status' + item.code"
+                  :label="item.name"
+                  :value="item.code"
+                />
+              </el-select>
+            </el-col>
+
+            <el-col
+              :span="3"
+              class="fr"
+              style="width: 66px; padding: 0 0 0 10px"
             >
-              {{ scope.row.ex_status_cn }}
-            </el-tag>
-            <el-tag
-              :size="tablebtnSize"
-              v-else-if="scope.row.ex_status === '2'"
-              :class="{
-                'hover-tag':
-                  scope.row.status === '0' &&
-                  powers.some((item) => item == '009'),
-              }"
-              :type="'danger'"
-              @click="
-                again(
-                  scope.row.id,
-                  scope.row.status === '0' &&
-                    powers.some((item) => item == '009')
-                )
-              "
+              <el-button type="primary" :size="searchSize" @click="searchList">
+                刷新
+              </el-button>
+            </el-col>
+            <el-col
+              :span="3"
+              class="fr"
+              style="width: 66px; padding: 0 0 0 10px"
             >
-              <i
-                class="el-icon-thumb"
-                v-if="
-                  scope.row.status === '0' &&
-                  powers.some((item) => item == '009')
+              <el-button type="warning" :size="searchSize" @click="restSearch">
+                重置
+              </el-button>
+            </el-col>
+          </el-row>
+          <el-row>
+            <el-col :span="4" style="width: 373px">
+              <el-input
+                :size="searchSize"
+                v-model="parmValue.name"
+                :maxlength="40"
+                @blur="
+                  pageInfo.curr = 1;
+                  parmValue.page = 1;
+                  searchList();
                 "
-                style="margin-right: 1px"
-              ></i>
-              {{ scope.row.ex_status_cn }}
-            </el-tag>
-            <el-tag
-              :size="tablebtnSize"
-              v-else-if="scope.row.ex_status === '3'"
-              :class="{
-                'hover-tag':
-                  scope.row.status === '0' &&
-                  powers.some((item) => item == '009'),
-              }"
-              :type="'info'"
-              @click="
-                again(
-                  scope.row.id,
-                  scope.row.status === '0' &&
-                    powers.some((item) => item == '009')
-                )
-              "
-            >
-              <i
-                class="el-icon-thumb"
-                v-if="
-                  scope.row.status === '0' &&
-                  powers.some((item) => item == '009')
+                placeholder="单位名称"
+              ></el-input>
+            </el-col>
+            <el-col :span="4" style="width: 170px; padding: 0 0 0 10px">
+              <el-input
+                :size="searchSize"
+                v-model="parmValue.creater"
+                :maxlength="40"
+                @change="
+                  pageInfo.curr = 1;
+                  parmValue.page = 1;
+                  searchList();
                 "
-                style="margin-right: 1px"
-              ></i>
-              {{ scope.row.ex_status_cn }}
-            </el-tag>
-          </template>
-        </el-table-column>
-        <el-table-column label="状态" show-overflow-tooltip align="center">
-          <template slot-scope="scope">
-            <el-tag
-              v-if="scope.row.status === '1'"
-              type="success"
-              :class="{ 'hover-tag': powers.some((item) => item == '004') }"
-              :size="tablebtnSize"
-              @click="
-                statusConfirm(
-                  scope.row.id,
-                  scope.row.status,
-                  scope.row.ex_status,
-                  powers.some((item) => item == '004')
-                )
-              "
-            >
-              <i
-                class="el-icon-thumb"
-                v-if="powers.some((item) => item == '004')"
-                style="margin-right: 1px"
-              ></i>
-              启用</el-tag
-            >
-            <el-tag
-              v-else
-              :class="{ 'hover-tag': powers.some((item) => item == '004') }"
-              :size="tablebtnSize"
-              type="warning"
-              @click="
-                statusConfirm(
-                  scope.row.id,
-                  scope.row.status,
-                  scope.row.ex_status,
-                  powers.some((item) => item == '004')
-                )
-              "
-            >
-              <i
-                class="el-icon-thumb"
-                v-if="powers.some((item) => item == '004')"
-                style="margin-right: 1px"
-              ></i>
-              禁用</el-tag
-            >
-          </template>
-        </el-table-column>
-        <el-table-column
-          prop="addtime"
-          label="创建时间"
-          show-overflow-tooltip
-          align="center"
-        ></el-table-column>
-        <el-table-column fixed="right" label="操作" align="center">
-          <template slot-scope="scope">
-            <el-link
-              v-if="
-                (scope.row.status === '0' &&
-                  scope.row.ex_status === '3' &&
-                  powers.some((item) => item == '005')) ||
-                (scope.row.status === '0' &&
-                  scope.row.ex_status === '2' &&
-                  powers.some((item) => item == '005'))
-              "
-              type="primary"
-              style="margin: 0 4px"
-              :underline="false"
-              :size="tablebtnSize"
-              @click="openModal(scope.row.id, false, false, true)"
-            >
-              修改
-            </el-link>
-            <!-- <el-link
-            type="primary"
-              style="margin: 0 4px"
-              :underline="false"
-              :size="tablebtnSize"
-            @click="deleteById(scope.row.id)"
-          >
-            删除
-          </el-link> -->
-            <el-link
-              v-if="powers.some((item) => item == '007')"
-              type="primary"
-              style="margin: 0 4px"
-              :underline="false"
-              :size="tablebtnSize"
-              @click="openModal(scope.row.id, true, false, true)"
+                placeholder="创建人"
+              ></el-input>
+            </el-col>
+            <el-col
+              :span="3"
+              class="fr"
+              style="width: 66px; padding: 0 0 0 10px"
+              v-if="powers.some((item) => item == '003')"
             >
-              详情
-            </el-link>
-          </template>
-        </el-table-column>
-      </el-table>
-      <div
-        class="Pagination"
-        style="text-align: right; margin-top: 10px"
-        v-show="count > 0"
+              <el-button
+                :size="searchSize"
+                type="success"
+                style="float: right"
+                @click="openModal({}, '003')"
+              >
+                添加
+              </el-button>
+            </el-col>
+          </el-row>
+        </div></template
       >
-        <el-pagination
-          :size="searchSize"
-          @size-change="handleSizeChange"
-          @current-change="handlePageChange"
-          :current-page="parmValue.page"
-          :page-sizes="[10, 15, 20, 30, 40]"
-          :page-size="parmValue.size"
-          layout="total, sizes, prev, pager, next, jumper"
-          :total="count"
-        ></el-pagination>
-      </div>
-      <add-edit
-        :showModel="showModel"
-        :id="modelId"
-        :isApproval="approval"
-        :isDetail="isDetail"
-        @refresh="searchList"
-        @cancel="showModel = false"
-      ></add-edit>
-    </div>
-    <div v-else>
-      <no-auth></no-auth>
-    </div>
+      <template #status="{ scope }">
+        <el-tag
+          :size="tablebtnSize"
+          :type="scope.row.status == '1' ? 'warning' : ''"
+          v-text="
+            (statusOptions.find((item) => item.id == scope.row.status) || {})
+              .label || '--'
+          "
+        ></el-tag>
+      </template>
+
+      <template #operation="{ scope }">
+        <el-tooltip
+          v-if="powers.some((item) => item == '007')"
+          effect="dark"
+          content="详情"
+          placement="top"
+        >
+          <i
+            class="el-icon-view tb-icon"
+            @click="openModal(scope.row, '007')"
+          ></i>
+        </el-tooltip>
+        <el-tooltip
+          v-if="powers.some((item) => item == '005')"
+          effect="dark"
+          content="修改"
+          placement="top"
+        >
+          <i
+            class="el-icon-edit tb-icon"
+            @click="openModal(scope.row, '005')"
+          ></i>
+        </el-tooltip>
+        <el-tooltip
+          v-if="
+            powers.some((item) => item == '004') && scope.row.status === '0'
+          "
+          effect="dark"
+          content="禁用"
+          placement="top"
+        >
+          <i
+            class="el-icon-video-pause tb-icon"
+            @click="changeStatus(scope.row.id, scope.row.status)"
+          ></i>
+        </el-tooltip>
+        <el-tooltip
+          v-if="
+            powers.some((item) => item == '004') && scope.row.status === '1'
+          "
+          effect="dark"
+          content="启用"
+          placement="top"
+        >
+          <i
+            class="el-icon-video-play tb-icon"
+            @click="changeStatus(scope.row.id, scope.row.status)"
+          ></i>
+        </el-tooltip>
+        <el-tooltip
+          v-if="powers.some((item) => item == '006')"
+          effect="dark"
+          content="删除"
+          placement="top"
+        >
+          <i
+            class="el-icon-delete tb-icon"
+            @click="deleteItem(scope.row.id)"
+          ></i>
+        </el-tooltip>
+      </template>
+    </ex-table>
+    <no-auth v-else></no-auth>
+    <!-- 弹窗 新增/修改 -->
+    <add-edit
+      :id="modelId"
+      :show-model="showModel"
+      :sitem="sitem"
+      @refresh="searchList"
+      @cancel="showModel = false"
+    />
   </div>
 </template>
-   <script>
-import mixinPage from "@/mixins/elPaginationHandle";
-import asyncRequest from "@/apis/service/goodStore/unit";
+<script>
 import addEdit from "./addEdit";
+import asyncRequest from "@/apis/service/goodStore/unit";
 import statusList from "@/assets/js/statusList";
+import roleLevel from "@/assets/js/roleLevel";
+import mixinPage from "@/mixins/elPaginationHandle";
 import { mapGetters } from "vuex";
+import resToken from "@/mixins/resToken";
 export default {
   name: "unit",
-  data() {
-    return {
-      statusList: statusList,
-      approval: false,
-      loading: true,
-      showModel: false,
-      isDetail: false,
-      modelId: 0,
-      parmValue: {
-        status: "",
-        name: "", // 名称
-        page: 1, // 页码
-        size: 10, // 每页显示条数
-      },
-      count: 0, // 总条数
-      tableData: [],
-    };
-  },
-  mixins: [mixinPage],
-  mounted() {
-    this.searchList();
-  },
+  mixins: [mixinPage, resToken],
   components: {
     addEdit,
   },
   computed: {
+    //组件SIZE设置
     ...mapGetters(["tablebtnSize", "searchSize", "size"]),
     powers() {
       let tran =
@@ -346,127 +234,197 @@ export default {
       }
     },
   },
+  data() {
+    return {
+      statusList: statusList,
+      roleLevel: roleLevel,
+      loading: true,
+      showModel: false,
+      modelId: "000",
+      sitem: {},
+      parmValue: {
+        page: 1, // 页码
+        size: 15, // 每页显示条数
+        start: "",
+        end: "",
+        status: "",
+        creater: "",
+      },
+      // 状态
+      statusOptions: [
+        { id: "1", label: "禁用" },
+        { id: "0", label: "启用" },
+      ],
+      // 表格 - 数据
+      tableData: [],
+      // 表格 - 参数
+      table: {
+        stripe: true,
+        border: true,
+        _defaultHeader_: ["setcol"],
+      },
+      // 表格 - 分页
+      pageInfo: {
+        size: 15,
+        curr: 1,
+        total: 0,
+      },
+      // 表格 - 列参数
+      columns: [
+        {
+          prop: "id",
+          label: "ID",
+        },
+        {
+          prop: "unit",
+          label: "单位名称",
+        },
+        {
+          prop: "status",
+          label: "状态",
+          sortable: true,
+          _slot_: "status",
+        },
+        {
+          prop: "creater",
+          label: "创建人",
+        },
+        {
+          prop: "addtime",
+          label: "创建时间",
+          sortable: true,
+        },
+        {
+          prop: "",
+          label: "操作",
+          fixed: "right",
+          _noset_: true,
+          _slot_: "operation",
+        },
+      ],
+    };
+  },
+  mounted() {
+    this.searchList();
+  },
   methods: {
     restSearch() {
+      // 表格 - 分页
+      this.pageInfo = {
+        size: 15,
+        curr: 1,
+        total: 0,
+      };
       this.parmValue = {
-        status: "",
-        name: "", // 名称
         page: 1, // 页码
-        size: 10, // 每页显示条数
+        size: 15, // 每页显示条数
+        start: "",
+        end: "",
+        status: "",
+        creater: "",
       };
       this.searchList();
     },
-    openModal(id, isDetail, approval, type) {
-      if (!type) {
-        return;
-      }
+    // 新建/编辑/详情
+    openModal(row, type) {
+      this.sitem = row;
+      this.modelId = type;
       this.showModel = true;
-      this.modelId = id;
-      this.isDetail = isDetail;
-      this.approval = approval;
     },
-    async deleteById(id) {
-      await this.$confirm("确定要删除?", {
+    // 时间
+    async handleTime(e) {
+      this.parmValue.start = e.startTime || "";
+      this.parmValue.end = e.endTime || "";
+      if (
+        (this.parmValue.start !== "" && this.parmValue.end !== "") ||
+        (this.parmValue.start === "" && this.parmValue.end === "")
+      ) {
+        this.pageInfo.curr = 1;
+        this.parmValue.page = 1;
+        await this.searchList();
+      }
+    },
+    /**
+     * 启用/禁用
+     * @param {String} id id
+     * @param {String} status 0-禁用 1-启用
+     */
+    async changeStatus(id, status) {
+      await this.$confirm(`确定要改为${status === "0" ? "禁用" : "启用"}?`, {
         confirmButtonText: "确定",
         cancelButtonText: "取消",
         type: "warning",
       })
         .then(async () => {
-          let res = await asyncRequest.delete({ id });
-          if (res.code === 0) {
+          this.loading = true;
+          const model = {
+            id: id,
+            status: status === "1" ? "0" : "1",
+          };
+          const res = await asyncRequest.status(model);
+          if (res && res.code === 0) {
+            this.loading = false;
             this.$notify.success({
-              title: "删除成功",
+              title: "状态修改成功!",
               message: "",
             });
-            this.searchList();
+            await this.searchList();
+          } else if (res && res.code >= 100 && res.code <= 104) {
+            await this.logout();
+          } else {
+            this.loading = false;
+            this.$message.warning(res.message);
           }
         })
         .catch(() => {
           console.log("取消");
         });
     },
-
-    async again(id, type) {
-      if (!type) {
-        return;
-      }
-      await this.$confirm("确定要提交审核?", {
+    async deleteItem(id) {
+      await this.$confirm("确定要删除?", {
         confirmButtonText: "确定",
         cancelButtonText: "取消",
         type: "warning",
       })
         .then(async () => {
-          let res = await asyncRequest.again({ id: id });
-          if (res.code === 0) {
+          const model = {
+            id: id,
+          };
+          const res = await asyncRequest.delete(model);
+          if (res && res.code === 0) {
             this.$notify.success({
-              title: "提交成功",
+              title: "删除成功",
               message: "",
             });
             this.searchList();
+          } else if (res && res.code >= 100 && res.code <= 104) {
+            await this.logout();
+          } else {
+            this.$message.warning(res.message);
           }
         })
         .catch(() => {
           console.log("取消");
         });
     },
+    // 刷新表格
     async searchList() {
       this.loading = true;
-      let res = await asyncRequest.list(this.parmValue);
-      if (res.code === 0 && res.data) {
+      const res = await asyncRequest.list(this.parmValue);
+      if (res && res.code === 0 && res.data) {
         this.tableData = res.data.list;
-        this.tableData.map((v1) => {
-          v1.addtime = v1.addtime.replaceAll(".000", "");
-          return v1;
-        });
-        this.count = Number(res.data.count);
+        this.pageInfo.total = Number(res.data.count);
+      } else if (res && res.code >= 100 && res.code <= 104) {
+        await this.logout();
       } else {
         this.tableData = [];
-        this.count = 0;
+        this.pageInfo.total = 0;
       }
       this.loading = false;
     },
-    async statusConfirm(id, status, ex_status, type) {
-      if (!type) {
-        return;
-      }
-      if (ex_status === "1") {
-        await this.$confirm(`确定要改为${status === "1" ? "禁用" : "启用"}?`, {
-          confirmButtonText: "确定",
-          cancelButtonText: "取消",
-          type: "warning",
-        })
-          .then(async () => {
-            this.loading = true;
-            const model = {
-              id: id,
-              status: status === "1" ? "0" : "1",
-            };
-            const res = await asyncRequest.status(model);
-            if (res.code === 0) {
-              this.loading = false;
-              this.$notify.success({
-                title: "状态修改成功!",
-                message: "",
-              });
-              await this.searchList();
-            } else {
-              this.loading = false;
-            }
-          })
-          .catch(() => {
-            console.log("取消");
-          });
-      } else {
-        if (status === "0") {
-          this.$message.warning("只有审核通过的规格,才能启用!");
-        }
-      }
-    },
   },
 };
 </script>
-   <style lang="scss" scoped>
-.unit {
-}
+
+<style lang="scss" scoped>
 </style>
-