Browse Source

feat:商品与物料的绑定关系,支持不选物料也能上架物料

Moss 1 năm trước cách đây
mục cha
commit
7871264f38
2 tập tin đã thay đổi với 75 bổ sung22 xóa
  1. 9 0
      src/api/goods.js
  2. 66 22
      src/views/mallManagement/goods/goods_add/index.vue

+ 9 - 0
src/api/goods.js

@@ -367,4 +367,13 @@ export function getGoodsSpecList(params) {
     method: 'post',
     params
   })
+}
+
+// 获取大类列表
+export function getMainList(params) {
+  return request({
+    url: '/goods/category/list',
+    method: 'get',
+    params
+  })
 }

+ 66 - 22
src/views/mallManagement/goods/goods_add/index.vue

@@ -160,24 +160,56 @@
             highlight-current-row
             stripe
             style="margin-bottom: 20px">
-            <el-table-column align="center" label="大类" prop="mainName" min-width="120">
+            <el-table-column align="center" label="大类" prop="mainId" min-width="120">
               <template slot-scope="scope">
-                {{scope.row.mainName}}
+                <el-select
+                  size="small"
+                  v-model="scope.row.mainId"
+                  filterable
+                  placeholder="请选择"
+                  :disabled="scope.row.goodsCode != ''"
+                  @change="scope.row.mainName = mainList.find(o => o.categoryId == scope.row.mainId).name">
+                  <el-option
+                    v-for="item in mainList"
+                    :key="item.categoryId"
+                    :label="item.name"
+                    :value="item.categoryId">
+                  </el-option>
+                </el-select>
               </template>
             </el-table-column>
-            <el-table-column align="center" label="小类" prop="smallName" min-width="120">
+            <el-table-column align="center" label="小类" prop="smallId" min-width="120">
               <template slot-scope="scope">
-                {{scope.row.smallName}}
+                <el-select
+                  size="small"
+                  v-model="scope.row.smallId"
+                  filterable
+                  placeholder="请选择"
+                  :disabled="scope.row.goodsCode != ''"
+                  @change="scope.row.smallName = mainList.find(o => o.categoryId == scope.row.mainId).children.find(o => o.categoryId == scope.row.smallId).name">
+                  <el-option
+                    v-for="item in scope.row.mainId ? mainList.find(o => o.categoryId == scope.row.mainId).children : []"
+                    :key="item.categoryId"
+                    :label="item.name"
+                    :value="item.categoryId">
+                  </el-option>
+                </el-select>
               </template>
             </el-table-column>
-            <el-table-column align="center" label="商品名称" prop="goodsName" min-width="120">
+            <el-table-column align="center" label="商品名称" prop="specValue" min-width="180">
               <template slot-scope="scope">
-                {{scope.row.goodsName}}
+                <el-input size="small" v-model="scope.row.specValue" :disabled="scope.row.goodsCode != ''"></el-input>
               </template>
             </el-table-column>
-            <el-table-column align="center" label="规格型号" prop="goodsCode" min-width="120">
+            <el-table-column align="center" label="规格型号" prop="goodsCode" min-width="180">
               <template slot-scope="scope">
-                <el-select size="small" v-model="scope.row.goodsCode" filterable placeholder="请选择" @change="changeSpec(scope.$index, scope.row)">
+                <el-select
+                  size="small"
+                  v-model="scope.row.goodsCode"
+                  filterable
+                  clearable
+                  placeholder="请选择"
+                  @change="changeSpec(scope.$index, scope.row)">
                   <el-option
                     v-for="item in goodsSpecList"
                     :key="item.id"
@@ -348,7 +380,7 @@
 
 <script>
 import { getToken } from '@/utils/auth'
-import { getClassifyList, getFreightList, addGoods, editGoods, getGoodsDetail, getModuleList, getTagList, getBrand, getGoodsSpecList } from '@/api/goods'
+import { getClassifyList, getFreightList, addGoods, editGoods, getGoodsDetail, getModuleList, getTagList, getBrand, getGoodsSpecList, getMainList } from '@/api/goods'
 import { getTypeList } from "@/api/workOrder/settlementStandardInstall";
 import { quillEditor } from 'vue-quill-editor'
 import 'quill/dist/quill.core.css'
@@ -496,6 +528,8 @@ export default {
       tagList: [],
 
       showImageListUpload2: false,
+
+      mainList: [],
     }
   },
 
@@ -519,6 +553,7 @@ export default {
     this.getTypeList();
     this.getBrand();
     this.getGoodsSpecList();
+    this.getMainList();
 
     if (this.isEdit) {
       this.getGoodsDetail(id);
@@ -622,6 +657,16 @@ export default {
       })
     },
 
+    // 获取大类列表
+    getMainList() {
+      getMainList({
+        type: 2,
+        status: true
+      }).then(res => {
+        this.mainList = res.data;
+      })
+    },
+
     // 获取详情
     getGoodsDetail(goodsId) {
       getGoodsDetail({ goodsId }).then(res => {
@@ -651,7 +696,6 @@ export default {
           status: data.status,
         }
         data.goodsSpecs.forEach(item => {
-          item.goodsName = item.goodsMaterialName;
           item.stockQty = item.goodsMaterialStock;
         })
         this.specList = data.goodsSpecs;
@@ -690,7 +734,7 @@ export default {
         mainName: '', // 大类名称
         smallId: '', // 小类id
         smallName: '', // 小类名称
-        goodsName: '', // 商品名称
+        specValue: '', // 商品名称
         specsName: '', // 规格名称
         unit: '', // 单位
         price: '', // 销售价格
@@ -714,17 +758,17 @@ export default {
 
     // 选择规格型号
     changeSpec(index, row) {
-      let item = this.goodsSpecList.find(o => o.id == row.goodsCode);
-      this.specList[index].goodsCode = item.id;
-      this.specList[index].mainId = item.mainId;
-      this.specList[index].mainName = item.mainName;
-      this.specList[index].smallId = item.smallId;
-      this.specList[index].smallName = item.smallName;
-      this.specList[index].goodsName = item.goodsName;
-      this.specList[index].specsName = item.specsName;
-      this.specList[index].unit = item.unit;
-      this.specList[index].costAmount = item.costAmount;
-      this.specList[index].stockQty = item.stockQty;
+      let item = this.goodsSpecList.find(o => o.id == row.goodsCode) || {};
+      this.specList[index].goodsCode = item.id || '';
+      this.specList[index].mainId = item.mainId || '';
+      this.specList[index].mainName = item.mainName || '';
+      this.specList[index].smallId = item.smallId || '';
+      this.specList[index].smallName = item.smallName || '';
+      this.specList[index].specValue = item.goodsName || '';
+      this.specList[index].specsName = item.specsName || '';
+      this.specList[index].unit = item.unit || '';
+      this.specList[index].costAmount = item.costAmount || '';
+      this.specList[index].stockQty = item.stockQty || '';
     },
 
     // 点击 提交表单