From 3c9c1a4f8ccbf765c35e44b21c790ef428e12868 Mon Sep 17 00:00:00 2001
From: 石广澎 <shiguangpeng@163.com>
Date: 星期三, 13 十二月 2023 18:26:05 +0800
Subject: [PATCH] feat: 物品规格管理 接口对接

---
 admin-web/src/api/foudation/material.js                    |   10 +++++
 admin-web/src/components/myTable/myTableV2.vue             |    9 +++-
 admin-web/src/views/foundation/material/specs/specsAdd.vue |   11 ++---
 admin-web/src/views/foundation/material/specs/list.vue     |   36 ++++++++++++++----
 admin-web/src/views/foundation/material/index.vue          |    6 +-
 5 files changed, 51 insertions(+), 21 deletions(-)

diff --git a/admin-web/src/api/foudation/material.js b/admin-web/src/api/foudation/material.js
index 0d8844e..33ca53c 100644
--- a/admin-web/src/api/foudation/material.js
+++ b/admin-web/src/api/foudation/material.js
@@ -79,3 +79,13 @@
     data: data
   })
 }
+/*
+* 淇敼鐗╁搧瑙勬牸鍨嬪彿鐘舵��
+* */
+export function updSpecsStatus(data) {
+  return request({
+    url: '/pc/base/goods/models/updStatus',
+    method: 'post',
+    data: data
+  })
+}
diff --git a/admin-web/src/components/myTable/myTableV2.vue b/admin-web/src/components/myTable/myTableV2.vue
index 7932ddc..fe8f738 100644
--- a/admin-web/src/components/myTable/myTableV2.vue
+++ b/admin-web/src/components/myTable/myTableV2.vue
@@ -252,6 +252,7 @@
       myTable: {
         url: '',
         params: {},
+        autoLoad: true,
         border: false,
         showIndex: true, // 鏄惁鏄剧ず搴忓彿
         expand: true, // 鏄惁鏄剧ず璇︽儏鏁版嵁
@@ -348,9 +349,11 @@
             total: 0
           })
         }
-        this.$nextTick(() => {
-          this.search({ pageNum: 1 })
-        })
+        if (this.myTable.autoLoad) {
+          this.$nextTick(() => {
+            this.search({pageNum: 1})
+          })
+        }
         this.myTable.columns.forEach((column, idx) => {
           if (!column.hidden) {
             this.checkColumns.push(idx)
diff --git a/admin-web/src/views/foundation/material/index.vue b/admin-web/src/views/foundation/material/index.vue
index 972c790..e436695 100644
--- a/admin-web/src/views/foundation/material/index.vue
+++ b/admin-web/src/views/foundation/material/index.vue
@@ -268,7 +268,7 @@
     updState(row) {
       let vm = this
       let text = row.states == 0 ? "鍚敤" : "绂佺敤";
-      vm.$modal.confirm('纭瑕�' + text + '"' + row.goodsName + '"鍚楋紵').then(function () {
+      vm.$modal.confirm('纭瑕�' + text + '"' + row.goodsName + '"鐗╁搧鍚楋紵').then(function () {
         let params = Object.assign({}, row)
         params.states = row.states == 1 ? 0 : 1
         updStatus(params).then(res => {
@@ -282,7 +282,7 @@
     },
     del(row) {
       this.$modal
-        .confirm('鏄惁纭鍒犻櫎鍚嶇О涓�"' + row.goodsName + '"鐨勬満鏋勫悧锛�')
+        .confirm('鏄惁纭鍒犻櫎鍚嶇О涓�"' + row.goodsName + '"鐨勭墿鍝佸悧锛�')
         .then(function () {
           delGoods({id: row.id}).then((res) => {
           });
@@ -304,7 +304,7 @@
       // }
     },
     showSpecs(row) {
-      this.specsSetting.id = row.id;
+      this.specsSetting.goodsTemplatesId = row.id;
       this.specsSetting.show = true;
     },
     // 鏌ヨtable鍒楄〃
diff --git a/admin-web/src/views/foundation/material/specs/list.vue b/admin-web/src/views/foundation/material/specs/list.vue
index 63e01c7..eadc4a7 100644
--- a/admin-web/src/views/foundation/material/specs/list.vue
+++ b/admin-web/src/views/foundation/material/specs/list.vue
@@ -12,7 +12,7 @@
 <script>
 import winMd from '@/components/win/win-md'
 import myButton from '@/components/myButton/myButton'
-import {delSpecs} from "@/api/foudation/material";
+import {delSpecs, updSpecsStatus} from "@/api/foudation/material";
 import specsAdd from "@/views/foundation/material/specs/specsAdd.vue";
 import {mapGetters} from 'vuex'
 import MyTableV2 from "@/components/myTable/myTableV2.vue";
@@ -37,6 +37,7 @@
       },
       // 琛ㄦ牸鏁版嵁
       table: {
+        autoLoad: false,
         showIndex: true, // 鏄惁鏄剧ず搴忓彿
         expand: false, // 鏄惁鏄剧ず璇︽儏鏁版嵁
         dataIndex: 'goodsTemplatesId',
@@ -61,8 +62,8 @@
         },
         // 鍒椾俊鎭�
         columns: [
-          {title: '瑙勬牸鍨嬪彿', field: 'goodsCode', align: 'left', minWidth: 120},
-          {title: '鍗曚綅', field: 'classification', align: 'center', width: 100},
+          {title: '瑙勬牸鍨嬪彿', field: 'modelName', align: 'left', minWidth: 120},
+          {title: '鍗曚綅', field: 'unit', align: 'center', width: 100},
           {
             field: 'states',
             title: '鐘舵��',
@@ -105,7 +106,7 @@
           ],
         },
         paging: {
-          show: true, // 鏄剧ず鍒嗛〉
+          show: false, // 鏄剧ず鍒嗛〉
           // 鍒嗛〉淇℃伅
           page: {
             small: false,
@@ -120,16 +121,35 @@
   computed: {
     ...mapGetters(['userInfo'])
   },
-  created() {
+  mounted() {
+    this.$nextTick(()=>{
+      this.search()
+    })
+
   },
   methods: {
     showAdd(){
-      this.specsSetting.mid = this.setting.id;//鐗╁搧ID
+      this.specsSetting.goodsTemplatesId = this.setting.goodsTemplatesId;//鐗╁搧ID
       this.specsSetting.show = true;
+    },
+    updState(row) {
+      let vm = this
+      let text = row.states == 0 ? "鍚敤" : "绂佺敤";
+      vm.$modal.confirm('纭瑕�' + text + '"' + row.modelName + '"瑙勬牸鍚楋紵').then(function () {
+        let params = Object.assign({}, row)
+        params.states = row.states == 1 ? 0 : 1
+        updSpecsStatus(params).then(res => {
+          if (res) {
+            row.states = row.states === 1 ? 0 : 1
+            vm.$modal.msgSuccess(text + "鎴愬姛");
+            vm.search()
+          }
+        })
+      })
     },
     del(row) {
       this.$modal
-        .confirm('鏄惁纭鍒犻櫎鍚嶇О涓�"' + row.categoryName + '"鐨勬満鏋勫悧锛�')
+        .confirm('鏄惁纭鍒犻櫎鍚嶇О涓�"' + row.modelName + '"鐨勮鏍煎悧锛�')
         .then(function () {
           delSpecs({ id: row.id }).then((res) => {});
         })
@@ -143,7 +163,7 @@
     },
     // 鏌ヨtable鍒楄〃
     search() {
-      this.$refs.myTable.search()
+      this.$refs.myTable.search({goodsTemplatesId:this.specsSetting.goodsTemplatesId})
     },
 
   }
diff --git a/admin-web/src/views/foundation/material/specs/specsAdd.vue b/admin-web/src/views/foundation/material/specs/specsAdd.vue
index 19c0961..1534454 100644
--- a/admin-web/src/views/foundation/material/specs/specsAdd.vue
+++ b/admin-web/src/views/foundation/material/specs/specsAdd.vue
@@ -72,17 +72,14 @@
       this.$refs.ruleForm.validate((valid) => {
         if (valid) {
           const params = Object.assign({}, this.formData)
+          params.goodsTemplatesId = this.setting.goodsTemplatesId
           if (this.loading) return
           this.loading = true
           addSpecs(params).then(res => {
             this.loading = false
-            if (res) {
-              this.$message.success('淇濆瓨鎴愬姛锛�')
-              this.close()
-              this.$emit('search')
-            } else {
-              this.$message.error('淇濆瓨澶辫触')
-            }
+            this.$message.success('淇濆瓨鎴愬姛锛�')
+            this.close()
+            this.$emit('search')
           }).catch(() => {
             this.loading = false
           });

--
Gitblit v1.9.1