浏览代码

feat: 对接接口:商品分类的大类小类

莫绍宝 1 年之前
父节点
当前提交
9b74c4cec9
共有 3 个文件被更改,包括 37 次插入34 次删除
  1. 9 0
      src/api/common.js
  2. 0 9
      src/api/goods.js
  3. 28 25
      src/views/goods/classify_index.vue

+ 9 - 0
src/api/common.js

@@ -22,4 +22,13 @@ export function getCompanyList(params) {
     method: 'get',
     params
   })
+}
+
+export function getWorkerDictList(params) {
+  return request({
+    url: '/dict/listDict',
+    method: 'post',
+    server: 'worker',
+    params
+  })
 }

+ 0 - 9
src/api/goods.js

@@ -243,15 +243,6 @@ export function getMarketingList(params) {
   })
 }
 
-// 获取小类列表
-export function getSmallType(params) {
-  return request({
-    url: '/common/gongdan/smalltype',
-    method: 'get',
-    params
-  })
-}
-
 // 获取标签列表
 export function getTagList(params) {
   return request({

+ 28 - 25
src/views/goods/classify_index.vue

@@ -103,18 +103,18 @@
 
         <el-form-item label="工单大类" prop="orderType">
           <el-select v-model="addChildForm.orderType" placeholder="请选择工单大类" style="width: 250px;" @change="changeOrderType()">
-            <el-option :label="item.name" :value="item.number" v-for="(item, index) in orderMainType" :key="index">
-              <span style="color: #8492a6">{{ item.number }}</span>
-              <span style="margin-left: 10px;">{{ item.name }}</span>
+            <el-option :label="item.dictValue" :value="item.dictCode" v-for="(item, index) in orderMainType" :key="index">
+              <span style="color: #8492a6">{{ item.dictCode }}</span>
+              <span style="margin-left: 10px;">{{ item.dictValue }}</span>
             </el-option>
           </el-select>
         </el-form-item>
 
         <el-form-item label="工单小类" prop="smallType">
           <el-select v-model="addChildForm.smallType" placeholder="请选择工单小类" style="width: 250px;" :disabled="!addChildForm.orderType">
-            <el-option :label="item.name" :value="item.id" v-for="(item, index) in orderSmallType" :key="index">
-              <span style="color: #8492a6">{{ item.id }}</span>
-              <span style="margin-left: 10px;">{{ item.name }}</span>
+            <el-option :label="item.dictValue" :value="item.dictCode" v-for="(item, index) in orderSmallType" :key="index">
+              <span style="color: #8492a6">{{ item.dictCode }}</span>
+              <span style="margin-left: 10px;">{{ item.dictValue }}</span>
             </el-option>
           </el-select>
         </el-form-item>
@@ -166,9 +166,8 @@
 
 <script>
 import { getToken } from '@/utils/auth'
-import { getClassifyList, addClassify, editClassify, deleteClassify, getClassifyDetail, getSmallType } from '@/api/goods'
-import { ORDER_MAIN_TYPE } from "@/utils/select_data";
-import { findElem } from '@/utils/util.js';
+import { getClassifyList, addClassify, editClassify, deleteClassify, getClassifyDetail } from '@/api/goods'
+import { getWorkerDictList } from '@/api/common'
 
 export default {
   data() {
@@ -235,7 +234,7 @@ export default {
 
       classifyList: [],
 
-      orderMainType: ORDER_MAIN_TYPE,
+      orderMainType: [],
       orderSmallType: [],
 
     }
@@ -324,10 +323,19 @@ export default {
       this.getSmallType();
     },
 
+    getMainType() {
+      getWorkerDictList({
+        dictType: 'MAIN_TYPE',
+      }).then(res => {
+        this.orderMainType = res.data;
+      })
+    },
+
     getSmallType() {
-      getSmallType({
-        mainNumber: this.addChildForm.orderType,
-        categoryId: this.addChildForm.oneClassify
+      getWorkerDictList({
+        dictType: 'SMALL_TYPE',
+        parentDictType: 'MAIN_TYPE',
+        parentDictCode: this.addChildForm.orderType,
       }).then(res => {
         this.orderSmallType = res.data;
       })
@@ -340,10 +348,11 @@ export default {
       getClassifyList({name: ''}).then(res => {
         this.classifyList = res.data;
       })
+      this.getMainType();
       
       if(type == 'add') {
         this.addChildForm.oneClassify = cid;
-        let item = this.dataList[findElem(this.dataList, 'categoryId', cid)];
+        let item = this.dataList.find(item => item.categoryId == cid);
         this.addChildForm.taxNumber = item.taxNumber;
         this.addChildForm.taxPercent = item.taxPercent;
       }
@@ -354,8 +363,8 @@ export default {
           this.addChildForm = {
             oneClassify: res.data.parentId,
             twoClassify: res.data.name,
-            orderType: Number(res.data.mainNumber),
-            smallType: Number(res.data.smallNumber),
+            orderType: res.data.mainNumber,
+            smallType: res.data.smallNumber,
             workOrderType: res.data.workOrderType,
             imgUrl: res.data.imgUrl,
             taxNumber: res.data.taxNumber,
@@ -378,21 +387,15 @@ export default {
     submitAddChildForm() {
       this.$refs.addChildForm.validate((valid) => {
         if (valid) {
-          let index = findElem(ORDER_MAIN_TYPE, 'number', this.addChildForm.orderType);
-          let mainName = index >= 0 ? ORDER_MAIN_TYPE[index].name : '';
-
-          let index2 = findElem(this.orderSmallType, 'id', this.addChildForm.smallType);
-          let smallName = index2 >= 0 ? this.orderSmallType[index2].name : '';
-          
           let params = {}
           if(this.addChildFormType == 'edit') {
             params = {
                 categoryId: this.editChildId,
                 name: this.addChildForm.twoClassify,
                 mainNumber: this.addChildForm.orderType || '',
-                mainName: mainName,
+                mainName: this.addChildForm.orderType ? this.orderMainType.find(item => item.dictCode == this.addChildForm.orderType).dictValue : '',
                 smallNumber: this.addChildForm.smallType || '',
-                smallName: smallName,
+                smallName: this.addChildForm.smallType ? this.orderSmallType.find(item => item.dictCode == this.addChildForm.smallType).dictValue : '',
                 workOrderType: this.addChildForm.workOrderType,
                 imgUrl: this.addChildForm.imgUrl,
                 taxNumber: this.addChildForm.taxNumber,
@@ -411,7 +414,7 @@ export default {
                 parentId: this.addChildForm.oneClassify,
                 name: this.addChildForm.twoClassify,
                 mainNumber: this.addChildForm.orderType || '',
-                mainName: mainName,
+                mainName: this.addChildForm.orderType ? this.orderMainType.find(item => item.dictCode == this.addChildForm.orderType).dictValue : '',
                 imgUrl: this.addChildForm.imgUrl,
                 taxNumber: this.addChildForm.taxNumber,
                 taxPercent: this.addChildForm.taxPercent,