Эх сурвалжийг харах

商品列表可按照二级分类筛选查询

DELL 3 жил өмнө
parent
commit
2fad4a981d

+ 14 - 13
src/views/business/goods/index.vue

@@ -19,15 +19,11 @@
           @keyup.enter.native="queryParams.pageNum = 1;getList()"
         />
       </el-form-item>
-      <el-form-item label="商品分类" prop="categoryId">
-       <el-select
-          v-model="queryParams.categoryId"
-          placeholder="请选择商品分类"
-          clearable
-          @change="queryParams.pageNum = 1;getList()"
-        >
-          <el-option :label="item.name" :value="item.categoryId" v-for="(item, index) in goodsCategoryItemsList" :key="index" />
-        </el-select>
+      <el-form-item label="商品分类" prop="categoryIdList">
+        <el-cascader
+          v-model="queryParams.categoryIdList" collapse-tags clearable
+          :options="goodsCategoryItemsList" :props="{ expandTrigger: 'hover', value: 'categoryId',label: 'name', children: 'goodsCategoryList', multiple: true, }"
+          @change="queryParams.pageNum = 1;getList()"></el-cascader>
       </el-form-item>
       <el-form-item label="商品标签" prop="tagId">
         <el-select
@@ -147,7 +143,7 @@
 <script>
 import { publicFileGetUrl } from "@/api/common"
 import { getGoodsList, delGoods, setGoodsStatus, setTableData} from '@/api/business/goods'
-import { goodsCategoryItems } from '@/api/business/category'
+import { goodsCategoryListTree } from '@/api/business/category'
 import { goodsTagItems } from '@/api/business/tag'
 import { accMul } from '@/utils/util'
 import { getSupplierList } from '@/api/business/supplier'
@@ -201,8 +197,8 @@ export default {
     },
 
     getGoodsCategoryItems(){
-      goodsCategoryItems({}).then(res => {
-        this.goodsCategoryItemsList = res && res.data
+      goodsCategoryListTree("",{}).then(res => {
+        this.goodsCategoryItemsList = res && res.rows
       })
     },
 
@@ -220,10 +216,15 @@ export default {
       // if (reset) {
       //   this.queryParams = { pageNum: 1, pageSize: 20, orderByColumn: '', isAsc: '', }
       // }
+      if(this.queryParams.categoryIdList){
+        for (let i = 0; i < this.queryParams.categoryIdList.length; i++) {
+          this.queryParams.categoryIdList[i] = this.queryParams.categoryIdList[i][1]
+        }
+      }
       getGoodsList('pageNum='+this.queryParams.pageNum + '&pageSize='+this.queryParams.pageSize+'&orderByColumn='+ this.queryParams.orderByColumn +'&isAsc='+ this.queryParams.isAsc +'&', {
         title: this.queryParams.title,
         goodsId: this.queryParams.goodsId,
-        categoryId: this.queryParams.categoryId,
+        categoryIdList: this.queryParams.categoryIdList,
         tagId: this.queryParams.tagId,
         status: this.queryParams.status,
         exchangeShow: this.queryParams.exchangeShow, supplierId: this.queryParams.supplierId,