From 1822fb1b8dc476bdb3270d0dd0cd79cbbc02ae2c Mon Sep 17 00:00:00 2001
From: 石广澎 <shiguangpeng@163.com>
Date: 星期二, 12 十二月 2023 16:58:25 +0800
Subject: [PATCH] feat: 物品规格管理页面

---
 admin-web/src/api/baseSetting/finsystenant.js              |   52 ------
 admin-web/src/views/foundation/material/edit.vue           |    8 
 admin-web/src/api/foudation/material.js                    |   81 ++++++++++
 admin-web/src/views/foundation/material/specs/specsAdd.vue |   95 +++++++++++
 admin-web/src/views/foundation/material/specs/list.vue     |  150 ++++++++++++++++++
 admin-web/src/views/foundation/material/index.vue          |   42 +++--
 6 files changed, 356 insertions(+), 72 deletions(-)

diff --git a/admin-web/src/api/baseSetting/finsystenant.js b/admin-web/src/api/baseSetting/finsystenant.js
index 5da26d1..ae74867 100644
--- a/admin-web/src/api/baseSetting/finsystenant.js
+++ b/admin-web/src/api/baseSetting/finsystenant.js
@@ -69,37 +69,6 @@
   })
 }
 
-export function editmaterial(data) {
-  return request({
-    url: `/pc/base/goods/template/detail/?id=${data}`,
-    method: 'get',
-  })
-}
-
-
-export function editcode(data) {
-  return request({
-    url: '/pc/base/goods/template/edit',
-    method: 'post',
-    data: data
-  })
-}
-
-export function upcode(data) {
-  return request({
-    url: '/pc/base/goods/template/updStatus',
-    method: 'post',
-    data: data
-  })
-}
-
-export function delCode(data) {
-  return request({
-    url: '/pc/base/goods/template/del',
-    method: 'delete',
-    data: data
-  })
-}
 
 export function treeList() {
   return request({
@@ -129,15 +98,6 @@
   })
 }
 
-/**
- * @Description 鏍规嵁鏈烘瀯id鑾峰彇鐢ㄦ埛
- * @Author wh
- * @Date 2023/10/4 16:10
- */
-export function getUserByOrgId(parameter) {
-  return request.get(SettingIplatform.apiBaseURL + '/pc/fin/sys/tenant/getUserByOrgId', {params: parameter})
-}
-
 // 浠撳簱閫夋嫨鍒楄〃
 export function selectTenantWarehouse(params) {
   return request({
@@ -146,16 +106,6 @@
     params,
   });
 }
-
-// 鐗╁搧鍒嗙被鍒楄〃
-export function getCategoryDetail(params) {
-  return request({
-    url: '/pc/base/category/detail',
-    method: 'get',
-    params,
-  });
-}
-
 // 鐗╁搧鍒楄〃
 export function goodsTemplate(params) {
   return request({
@@ -203,4 +153,4 @@
     method: 'get',
     params,
   });
-}
\ No newline at end of file
+}
diff --git a/admin-web/src/api/foudation/material.js b/admin-web/src/api/foudation/material.js
new file mode 100644
index 0000000..77d451d
--- /dev/null
+++ b/admin-web/src/api/foudation/material.js
@@ -0,0 +1,81 @@
+import request from "@/utils/request";
+/*鐗╁搧绠$悊*/
+
+/*
+* 鏂板鐗╁搧
+* */
+export function addGoods(data) {
+  return request({
+    url: '/pc/base/goods/template/add',
+    method: 'post',
+    data: data
+  })
+}
+
+/*
+* 鍒犻櫎鐗╁搧
+* */
+export function delGoods(data) {
+  return request({
+    url: '/pc/base/goods/template/del',
+    method: 'delete',
+    data: data
+  })
+}
+
+/*
+* 缂栬緫鐗╁搧
+* */
+export function editGoods(data) {
+  return request({
+    url: '/pc/base/goods/template/edit',
+    method: 'post',
+    data: data
+  })
+}
+
+/*
+* 鐗╁搧璇︽儏
+* */
+export function goodsDetail(data) {
+  return request({
+    url: `/pc/base/goods/template/detail/?id=${data}`,
+    method: 'get',
+  })
+}
+
+/*
+* 鍚敤/绂佺敤
+* */
+export function updStatus(data) {
+  return request({
+    url: '/pc/base/goods/template/updStatus',
+    method: 'post',
+    data: data
+  })
+}
+
+
+/*   瑙勬牸鍨嬪彿绠$悊  */
+
+/*
+* 鏂板鐗╁搧瑙勬牸鍨嬪彿
+* */
+export function addSpecs(data) {
+  return request({
+    url: '/pc/base/goods/template/add',
+    method: 'post',
+    data: data
+  })
+}
+
+/*
+* 鍒犻櫎鐗╁搧瑙勬牸鍨嬪彿
+* */
+export function delSpecs(data) {
+  return request({
+    url: '/pc/base/goods/template/del',
+    method: 'delete',
+    data: data
+  })
+}
diff --git a/admin-web/src/views/foundation/material/edit.vue b/admin-web/src/views/foundation/material/edit.vue
index 37b9590..7d271d5 100644
--- a/admin-web/src/views/foundation/material/edit.vue
+++ b/admin-web/src/views/foundation/material/edit.vue
@@ -57,7 +57,7 @@
 <script>
 import winMd from '@/components/win/win-md'
 import myButton from '@/components/myButton/myButton'
-import * as finsystenant from '@/api/baseSetting/finsystenant'
+import {addGoods,editGoods,goodsDetail} from "@/api/foudation/material";
 import {getTree} from '@/api/foudation/classification';
 import {mapGetters} from 'vuex'
 
@@ -111,7 +111,7 @@
   },
   async created() {
     if (this.setting.id) {
-      await finsystenant.editmaterial(this.setting.id).then(res => {
+      await goodsDetail(this.setting.id).then(res => {
         this.formData = res
         if (!this.formData.agencyId) {
           this.formData.agencyId = this.userInfo.tenantId
@@ -155,7 +155,7 @@
           this.loading = true
           if (this.setting.id) {
             // 缂栬緫鎺ュ彛
-            finsystenant.editcode(params).then(res => {
+            editGoods(params).then(res => {
               this.loading = false
               if (res) {
                 this.$message.success('淇濆瓨鎴愬姛锛�')
@@ -169,7 +169,7 @@
             });
           } else {
             params.orgId = this.setting.orgId
-            finsystenant.addcode(params).then(res => {
+            addGoods(params).then(res => {
               this.loading = false
               if (res) {
                 this.$message.success('淇濆瓨鎴愬姛锛�')
diff --git a/admin-web/src/views/foundation/material/index.vue b/admin-web/src/views/foundation/material/index.vue
index fbc8293..972c790 100644
--- a/admin-web/src/views/foundation/material/index.vue
+++ b/admin-web/src/views/foundation/material/index.vue
@@ -13,11 +13,13 @@
               <my-table-v2 ref="myTable" :filter="filterFrom" :table="table"/>
             </el-col>
           </el-row>
-          <!--娣诲姞/缂栬緫寮圭獥-->
-          <edit v-if="editSetting.show" :setting="editSetting" @close="editSetting.show = false" @search="search"/>
         </el-card>
       </el-container>
     </el-container>
+    <!--娣诲姞/缂栬緫寮圭獥-->
+    <edit v-if="editSetting.show" :setting="editSetting" @close="editSetting.show = false" @search="search"/>
+    <!--瑙勬牸-->
+    <specs v-if="specsSetting.show" :setting="specsSetting" @close="specsSetting.show = false" @search="search"></specs>
     <my-import
       :import-setting="importSetting"
       :dialog-show="importSetting.dialogShow"
@@ -33,13 +35,14 @@
 import MyButton from "@/components/myButton/myButton";
 import SettingIplatform from '@/utils/settingIplatform';
 import edit from './edit'
-import * as finsystenant from '@/api/baseSetting/finsystenant'
+import {updStatus,delGoods} from '@/api/foudation/material'
 import myImport from '@/views/components/myImport'
 import {getBaseUrl} from '@/utils/base';
+import Specs from "@/views/foundation/material/specs/list.vue";
 
 export default {
   name: "index",
-  components: {MyButton, MyTableV2, edit, myTree, myImport},
+  components: {Specs, MyButton, MyTableV2, edit, myTree, myImport},
   data() {
     return {
       // 鎼滅储妗�
@@ -128,6 +131,11 @@
         orgId: '',
         show: false,
       },
+      specsSetting: {
+        title: '',
+        id: '',
+        show: false,
+      },
       // 琛ㄦ牸鏁版嵁
       table: {
         showIndex: true, // 鏄惁鏄剧ず搴忓彿
@@ -205,7 +213,7 @@
         // 鎿嶄綔淇℃伅
         operation: {
           show: true, // 鏄剧ず鎿嶄綔鍒�
-          width: 160, // 鍒楀
+          width: 250, // 鍒楀
           attr: [
             {
               title: '缂栬緫',
@@ -219,12 +227,13 @@
                 this.del(row);
               },
             },
-            // {
-            //   title: '瑙勬牸鍨嬪彿',
-            //   events: (row) => {
-            //     this.showAudit(row);
-            //   },
-            // },
+            {
+              title: '瑙勬牸鍨嬪彿',
+              type: 'primary',
+              events: (row) => {
+                this.showSpecs(row);
+              },
+            },
           ],
         },
         paging: {
@@ -262,7 +271,7 @@
       vm.$modal.confirm('纭瑕�' + text + '"' + row.goodsName + '"鍚楋紵').then(function () {
         let params = Object.assign({}, row)
         params.states = row.states == 1 ? 0 : 1
-        finsystenant.upcode(params).then(res => {
+        updStatus(params).then(res => {
           if (res) {
             row.states = row.states === 1 ? 0 : 1
             vm.$modal.msgSuccess(text + "鎴愬姛");
@@ -275,7 +284,7 @@
       this.$modal
         .confirm('鏄惁纭鍒犻櫎鍚嶇О涓�"' + row.goodsName + '"鐨勬満鏋勫悧锛�')
         .then(function () {
-          finsystenant.delCode({id: row.id}).then((res) => {
+          delGoods({id: row.id}).then((res) => {
           });
         })
         .then((res) => {
@@ -294,10 +303,9 @@
         this.editSetting.show = true;
       // }
     },
-    showAudit(row) {
-      this.editSetting.id = row.id;
-      this.editSetting.title = '缂栬緫';
-      this.editSetting.show = true;
+    showSpecs(row) {
+      this.specsSetting.id = row.id;
+      this.specsSetting.show = true;
     },
     // 鏌ヨtable鍒楄〃
     search(pageNum) {
diff --git a/admin-web/src/views/foundation/material/specs/list.vue b/admin-web/src/views/foundation/material/specs/list.vue
new file mode 100644
index 0000000..aff54dc
--- /dev/null
+++ b/admin-web/src/views/foundation/material/specs/list.vue
@@ -0,0 +1,150 @@
+<template>
+  <win-md title="瑙勬牸鍨嬪彿" @close="close" :width="'800px'">
+    <!--鍒楄〃-->
+    <my-table-v2 ref="myTable" :table="table"/>
+    <div slot="footer" align="center" class="dialog-footer">
+      <my-button name="鍙栨秷" site="form" @click="close"/>
+    </div>
+    <specsAdd v-if="specsSetting.show" :setting="specsSetting" @close="specsSetting.show = false" @search="search"/>
+  </win-md>
+</template>
+
+<script>
+import winMd from '@/components/win/win-md'
+import myButton from '@/components/myButton/myButton'
+import {delSpecs} from "@/api/foudation/material";
+import specsAdd from "@/views/foundation/material/specs/specsAdd.vue";
+import {mapGetters} from 'vuex'
+import MyTableV2 from "@/components/myTable/myTableV2.vue";
+import SettingIplatform from "@/utils/settingIplatform";
+
+export default {
+  name: 'specs',
+  components: {MyTableV2, winMd, myButton, specsAdd},
+  props: {
+    setting: {
+      type: Object,
+      default: () => {
+      }
+    }
+  },
+  data() {
+    return {
+      specsSetting: {
+        title: '',
+        id: '',
+        show: false,
+      },
+      // 琛ㄦ牸鏁版嵁
+      table: {
+        showIndex: true, // 鏄惁鏄剧ず搴忓彿
+        expand: false, // 鏄惁鏄剧ず璇︽儏鏁版嵁
+        url: SettingIplatform.apiBaseURL + '/pc/base/goods/template/list', // 璇锋眰鍦板潃
+        // 宸ュ叿鏉�
+        tools: {
+          columnsCtrl: {// 鍒楁帶鍒舵寜閽�
+            show: false
+          },
+          generalExport: {// 閫氱敤瀵煎嚭鎸夐挳
+            show: false
+          },
+          // 鑷畾涔夊伐鍏锋潯鎸夐挳
+          custom: [
+            {
+              name: '鏂板',
+              click: () => {
+                this.showAdd(null);
+              },
+            },
+          ]
+        },
+        // 鍒椾俊鎭�
+        columns: [
+          {title: '瑙勬牸鍨嬪彿', field: 'goodsCode', align: 'left', minWidth: 120},
+          {title: '鍗曚綅', field: 'classification', align: 'center', width: 100},
+          {
+            field: 'states',
+            title: '鐘舵��',
+            align: 'center',
+            width: 100,
+            switch: row => {
+              const result = {}
+              if (row.states == 1) {
+                Object.assign(result, {
+                  value: true, // 寮�
+                  label: '鏄�', // 寮�鐨勬弿杩�
+                  click: () => { // 鐐瑰嚮浜嬩欢
+                    this.updState(row)
+                  }
+                })
+              } else {
+                Object.assign(result, {
+                  value: false, // 鍏�
+                  label: '鍚�', // 鍏崇殑鎻忚堪
+                  click: () => {
+                    this.updState(row)
+                  }
+                })
+              }
+              return result
+            }
+          }
+        ],
+        // 鎿嶄綔淇℃伅
+        operation: {
+          show: true, // 鏄剧ず鎿嶄綔鍒�
+          width: 100, // 鍒楀
+          attr: [
+            {
+              title: '鍒犻櫎',
+              events: (row) => {
+                this.del(row);
+              },
+            },
+          ],
+        },
+        paging: {
+          show: true, // 鏄剧ず鍒嗛〉
+          // 鍒嗛〉淇℃伅
+          page: {
+            small: false,
+            pageNum: 1,
+            pageSize: 10,
+            total: 0
+          }
+        }
+      },
+    }
+  },
+  computed: {
+    ...mapGetters(['userInfo'])
+  },
+  created() {
+  },
+  methods: {
+    showAdd(){
+      this.specsSetting.mid = this.setting.id;//鐗╁搧ID
+      this.specsSetting.show = true;
+    },
+    del(row) {
+      this.$modal
+        .confirm('鏄惁纭鍒犻櫎鍚嶇О涓�"' + row.categoryName + '"鐨勬満鏋勫悧锛�')
+        .then(function () {
+          delSpecs({ id: row.id }).then((res) => {});
+        })
+        .then((res) => {
+          this.$message.success('鍒犻櫎鎴愬姛锛�');this.$refs.myTable.search();
+        })
+        .catch(() => {});
+    },
+    close() {
+      this.$emit('close')
+    },
+    // 鏌ヨtable鍒楄〃
+    search() {
+      this.$refs.myTable.search()
+    },
+
+  }
+}
+</script>
diff --git a/admin-web/src/views/foundation/material/specs/specsAdd.vue b/admin-web/src/views/foundation/material/specs/specsAdd.vue
new file mode 100644
index 0000000..7f5fdec
--- /dev/null
+++ b/admin-web/src/views/foundation/material/specs/specsAdd.vue
@@ -0,0 +1,95 @@
+<template>
+  <win-md title="鏂板瑙勬牸鍨嬪彿" @close="close" width="500px" :loading="loading">
+    <el-form ref="ruleForm" :model="formData" :rules="rules" class="demo-ruleForm" label-width="100px">
+      <el-form-item label="鍨嬪彿鍚嶇О" prop="modelName">
+        <el-input v-model="formData.modelName" placeholder="璇疯緭鍏ュ瀷鍙峰悕绉�" clearable maxlength="20" show-word-limit
+                  style="width: 100%"/>
+      </el-form-item>
+      <el-form-item label="鍗曚綅" prop="unit">
+        <el-input v-model="formData.unit" placeholder="璇疯緭鍏ュ崟浣�" clearable maxlength="20" show-word-limit
+                  style="width: 100%"/>
+      </el-form-item>
+      <el-form-item label="鐘舵��" prop="states">
+        <el-radio-group v-model="formData.states">
+          <el-radio :label="1" border>鍚敤</el-radio>
+          <el-radio :label="0" border>绂佺敤</el-radio>
+        </el-radio-group>
+      </el-form-item>
+    </el-form>
+    <div slot="footer" align="center" class="dialog-footer">
+      <my-button name="鍙栨秷" site="form" @click="close"/>
+      <my-button name="淇濆瓨" site="form" @click="save"/>
+    </div>
+  </win-md>
+</template>
+
+<script>
+import winMd from '@/components/win/win-md'
+import myButton from '@/components/myButton/myButton'
+import {mapGetters} from 'vuex'
+import {addSpecs} from "@/api/foudation/material";
+
+
+export default {
+  name: 'specsAdd',
+  components: {winMd, myButton},
+  props: {
+    setting: {
+      type: Object,
+      default: () => {
+      }
+    }
+  },
+  data() {
+    return {
+      loading: false,
+      formData: {
+        modelName: '',
+        unit: '',
+        states: 1,
+      },
+      rules: {
+        modelName: [
+          {required: true, message: '璇疯緭鍏ュ瀷鍙峰悕绉�', trigger: 'blur'}
+        ],
+        unit: [
+          {required: true, message: '璇疯緭鍏ュ崟浣�', trigger: 'blur'}
+        ]
+      }
+    }
+  },
+  computed: {
+    ...mapGetters(['userInfo'])
+  },
+  created() {
+  },
+  methods: {
+    close() {
+      this.$emit('close')
+    },
+    save() {
+      this.$refs.ruleForm.validate((valid) => {
+        if (valid) {
+          const params = Object.assign({}, this.formData)
+          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('淇濆瓨澶辫触')
+            }
+          }).catch(() => {
+            this.loading = false
+          });
+        } else {
+          this.$message.error('鏍¢獙鏈�氳繃锛岃妫�鏌ャ��')
+        }
+      })
+    }
+  }
+}
+</script>

--
Gitblit v1.9.1