Commit 969c3877641eeecf77c7395b7981bb006b8d2f13
1 parent
6a0f7134
mall:完善商品分类的管理后台界面
Showing
7 changed files
with
48 additions
and
176 deletions
sql/optional/mall/mall.sql
| @@ -20,25 +20,6 @@ SET NAMES utf8mb4; | @@ -20,25 +20,6 @@ SET NAMES utf8mb4; | ||
| 20 | -- ---------------------------- | 20 | -- ---------------------------- |
| 21 | -- Table structure for product_category | 21 | -- Table structure for product_category |
| 22 | -- ---------------------------- | 22 | -- ---------------------------- |
| 23 | -DROP TABLE IF EXISTS `product_category`; | ||
| 24 | -CREATE TABLE `product_category` | ||
| 25 | -( | ||
| 26 | - `id` bigint NOT NULL AUTO_INCREMENT COMMENT '分类编号', | ||
| 27 | - `parent_id` bigint NOT NULL COMMENT '父分类编号', | ||
| 28 | - `name` varchar(255) NOT NULL COMMENT '分类名称', | ||
| 29 | - `icon` varchar(100) NOT NULL DEFAULT '#' COMMENT '分类图标', | ||
| 30 | - `banner_url` varchar(255) NOT NULL COMMENT '分类图片', | ||
| 31 | - `sort` int DEFAULT '0' COMMENT '分类排序', | ||
| 32 | - `description` varchar(1024) DEFAULT NULL COMMENT '分类描述', | ||
| 33 | - `status` tinyint NOT NULL COMMENT '开启状态', | ||
| 34 | - `creator` varchar(64) DEFAULT '' COMMENT '创建者', | ||
| 35 | - `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', | ||
| 36 | - `updater` varchar(64) DEFAULT '' COMMENT '更新者', | ||
| 37 | - `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', | ||
| 38 | - `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除', | ||
| 39 | - `tenant_id` bigint NOT NULL DEFAULT '0' COMMENT '租户编号', | ||
| 40 | - PRIMARY KEY (`id`) USING BTREE | ||
| 41 | -) ENGINE=InnoDB COMMENT='商品分类'; | ||
| 42 | 23 | ||
| 43 | -- ---------------------------- | 24 | -- ---------------------------- |
| 44 | -- Table structure for product_brand | 25 | -- Table structure for product_brand |
| @@ -83,6 +64,7 @@ INSERT INTO `system_menu`(`name`, `permission`, `type`, `sort`, `parent_id`, `pa | @@ -83,6 +64,7 @@ INSERT INTO `system_menu`(`name`, `permission`, `type`, `sort`, `parent_id`, `pa | ||
| 83 | VALUES ('分类删除', 'product:category:delete', 3, 4, @parentId, '', '', '', 0); | 64 | VALUES ('分类删除', 'product:category:delete', 3, 4, @parentId, '', '', '', 0); |
| 84 | INSERT INTO `system_menu`(`name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`) | 65 | INSERT INTO `system_menu`(`name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`) |
| 85 | VALUES ('分类导出', 'product:category:export', 3, 5, @parentId, '', '', '', 0); | 66 | VALUES ('分类导出', 'product:category:export', 3, 5, @parentId, '', '', '', 0); |
| 67 | + | ||
| 86 | -- 品牌管理 菜单 SQL | 68 | -- 品牌管理 菜单 SQL |
| 87 | INSERT INTO `system_menu`(`name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`) | 69 | INSERT INTO `system_menu`(`name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`) |
| 88 | VALUES ('品牌管理', '', 2, 1, 2001, 'brand', '', 'mall/product/brand/index', 0); | 70 | VALUES ('品牌管理', '', 2, 1, 2001, 'brand', '', 'mall/product/brand/index', 0); |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/category/AppCategoryController.java
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/category/vo/AppCategoryListRespVO.java
| @@ -8,7 +8,7 @@ import javax.validation.constraints.NotBlank; | @@ -8,7 +8,7 @@ import javax.validation.constraints.NotBlank; | ||
| 8 | import javax.validation.constraints.NotNull; | 8 | import javax.validation.constraints.NotNull; |
| 9 | 9 | ||
| 10 | @Data | 10 | @Data |
| 11 | -@ApiModel(value = "App - 商品分类 列表 Request VO", description = "参数和 CategoryBaseVO 是一致的") | 11 | +@ApiModel(value = "App - 商品分类 Response VO") |
| 12 | public class AppCategoryListRespVO { | 12 | public class AppCategoryListRespVO { |
| 13 | 13 | ||
| 14 | @ApiModelProperty(value = "分类编号", required = true, example = "2") | 14 | @ApiModelProperty(value = "分类编号", required = true, example = "2") |
| @@ -22,17 +22,8 @@ public class AppCategoryListRespVO { | @@ -22,17 +22,8 @@ public class AppCategoryListRespVO { | ||
| 22 | @NotBlank(message = "分类名称不能为空") | 22 | @NotBlank(message = "分类名称不能为空") |
| 23 | private String name; | 23 | private String name; |
| 24 | 24 | ||
| 25 | - @ApiModelProperty(value = "分类图标") | ||
| 26 | - @NotBlank(message = "分类图标不能为空") | ||
| 27 | - private String icon; | ||
| 28 | - | ||
| 29 | @ApiModelProperty(value = "分类图片", required = true) | 25 | @ApiModelProperty(value = "分类图片", required = true) |
| 30 | @NotBlank(message = "分类图片不能为空") | 26 | @NotBlank(message = "分类图片不能为空") |
| 31 | - private String bannerUrl; | ||
| 32 | - | ||
| 33 | - @ApiModelProperty(value = "分类排序", required = true, example = "1") | ||
| 34 | - private Integer sort; | 27 | + private String picUrl; |
| 35 | 28 | ||
| 36 | - @ApiModelProperty(value = "分类描述", required = true, example = "描述") | ||
| 37 | - private String description; | ||
| 38 | } | 29 | } |
yudao-ui-admin/src/api/mall/product/category.js
| 1 | import request from '@/utils/request' | 1 | import request from '@/utils/request' |
| 2 | 2 | ||
| 3 | // 创建商品分类 | 3 | // 创建商品分类 |
| 4 | -export function createCategory(data) { | 4 | +export function createProductCategory(data) { |
| 5 | return request({ | 5 | return request({ |
| 6 | url: '/product/category/create', | 6 | url: '/product/category/create', |
| 7 | method: 'post', | 7 | method: 'post', |
| @@ -10,7 +10,7 @@ export function createCategory(data) { | @@ -10,7 +10,7 @@ export function createCategory(data) { | ||
| 10 | } | 10 | } |
| 11 | 11 | ||
| 12 | // 更新商品分类 | 12 | // 更新商品分类 |
| 13 | -export function updateCategory(data) { | 13 | +export function updateProductCategory(data) { |
| 14 | return request({ | 14 | return request({ |
| 15 | url: '/product/category/update', | 15 | url: '/product/category/update', |
| 16 | method: 'put', | 16 | method: 'put', |
| @@ -19,7 +19,7 @@ export function updateCategory(data) { | @@ -19,7 +19,7 @@ export function updateCategory(data) { | ||
| 19 | } | 19 | } |
| 20 | 20 | ||
| 21 | // 删除商品分类 | 21 | // 删除商品分类 |
| 22 | -export function deleteCategory(id) { | 22 | +export function deleteProductCategory(id) { |
| 23 | return request({ | 23 | return request({ |
| 24 | url: '/product/category/delete?id=' + id, | 24 | url: '/product/category/delete?id=' + id, |
| 25 | method: 'delete' | 25 | method: 'delete' |
| @@ -27,37 +27,18 @@ export function deleteCategory(id) { | @@ -27,37 +27,18 @@ export function deleteCategory(id) { | ||
| 27 | } | 27 | } |
| 28 | 28 | ||
| 29 | // 获得商品分类 | 29 | // 获得商品分类 |
| 30 | -export function getCategory(id) { | 30 | +export function getProductCategory(id) { |
| 31 | return request({ | 31 | return request({ |
| 32 | url: '/product/category/get?id=' + id, | 32 | url: '/product/category/get?id=' + id, |
| 33 | method: 'get' | 33 | method: 'get' |
| 34 | }) | 34 | }) |
| 35 | } | 35 | } |
| 36 | 36 | ||
| 37 | -// 获得商品分类 | ||
| 38 | -export function listCategory(query) { | ||
| 39 | - return request({ | ||
| 40 | - url: '/product/category/listByQuery', | ||
| 41 | - method: 'get', | ||
| 42 | - params: query | ||
| 43 | - }) | ||
| 44 | -} | ||
| 45 | - | ||
| 46 | -// 获得商品分类分页 | ||
| 47 | -export function getCategoryPage(query) { | 37 | +// 获得商品分类列表 |
| 38 | +export function getProductCategoryList(query) { | ||
| 48 | return request({ | 39 | return request({ |
| 49 | - url: '/product/category/page', | 40 | + url: '/product/category/list', |
| 50 | method: 'get', | 41 | method: 'get', |
| 51 | params: query | 42 | params: query |
| 52 | }) | 43 | }) |
| 53 | } | 44 | } |
| 54 | - | ||
| 55 | -// 导出商品分类 Excel | ||
| 56 | -export function exportCategoryExcel(query) { | ||
| 57 | - return request({ | ||
| 58 | - url: '/product/category/export-excel', | ||
| 59 | - method: 'get', | ||
| 60 | - params: query, | ||
| 61 | - responseType: 'blob' | ||
| 62 | - }) | ||
| 63 | -} |
yudao-ui-admin/src/views/mall/product/brand/index.vue
| @@ -118,7 +118,7 @@ import { | @@ -118,7 +118,7 @@ import { | ||
| 118 | getBrandPage, | 118 | getBrandPage, |
| 119 | updateBrand | 119 | updateBrand |
| 120 | } from "@/api/mall/product/brand"; | 120 | } from "@/api/mall/product/brand"; |
| 121 | -import {listCategory} from "@/api/mall/product/category"; | 121 | +import {getProductCategoryList} from "@/api/mall/product/category"; |
| 122 | import ImageUpload from '@/components/ImageUpload'; | 122 | import ImageUpload from '@/components/ImageUpload'; |
| 123 | import Treeselect from "@riophae/vue-treeselect"; | 123 | import Treeselect from "@riophae/vue-treeselect"; |
| 124 | import "@riophae/vue-treeselect/dist/vue-treeselect.css"; | 124 | import "@riophae/vue-treeselect/dist/vue-treeselect.css"; |
| @@ -194,7 +194,7 @@ export default { | @@ -194,7 +194,7 @@ export default { | ||
| 194 | }, | 194 | }, |
| 195 | /** 查询分类下拉树结构 */ | 195 | /** 查询分类下拉树结构 */ |
| 196 | getTreeselect() { | 196 | getTreeselect() { |
| 197 | - listCategory().then(response => { | 197 | + getProductCategoryList().then(response => { |
| 198 | this.categoryOptions = []; | 198 | this.categoryOptions = []; |
| 199 | const menu = {id: 0, name: '商品分类', children: []}; | 199 | const menu = {id: 0, name: '商品分类', children: []}; |
| 200 | menu.children = this.handleTree(response.data, "id", "pid"); | 200 | menu.children = this.handleTree(response.data, "id", "pid"); |
yudao-ui-admin/src/views/mall/product/category/index.vue
| @@ -6,12 +6,6 @@ | @@ -6,12 +6,6 @@ | ||
| 6 | <el-form-item label="分类名称" prop="name"> | 6 | <el-form-item label="分类名称" prop="name"> |
| 7 | <el-input v-model="queryParams.name" placeholder="请输入分类名称" clearable @keyup.enter.native="handleQuery"/> | 7 | <el-input v-model="queryParams.name" placeholder="请输入分类名称" clearable @keyup.enter.native="handleQuery"/> |
| 8 | </el-form-item> | 8 | </el-form-item> |
| 9 | - <el-form-item label="开启状态" prop="status"> | ||
| 10 | - <el-select v-model="queryParams.status" placeholder="请选择开启状态" clearable size="small"> | ||
| 11 | - <el-option v-for="dict in this.getDictDatas(DICT_TYPE.COMMON_STATUS)" | ||
| 12 | - :key="dict.value" :label="dict.label" :value="dict.value"/> | ||
| 13 | - </el-select> | ||
| 14 | - </el-form-item> | ||
| 15 | <el-form-item> | 9 | <el-form-item> |
| 16 | <el-button type="primary" icon="el-icon-search" @click="handleQuery">搜索</el-button> | 10 | <el-button type="primary" icon="el-icon-search" @click="handleQuery">搜索</el-button> |
| 17 | <el-button icon="el-icon-refresh" @click="resetQuery">重置</el-button> | 11 | <el-button icon="el-icon-refresh" @click="resetQuery">重置</el-button> |
| @@ -28,27 +22,16 @@ | @@ -28,27 +22,16 @@ | ||
| 28 | <el-col :span="1.5"> | 22 | <el-col :span="1.5"> |
| 29 | <el-button type="info" plain icon="el-icon-sort" size="mini" @click="toggleExpandAll">展开/折叠</el-button> | 23 | <el-button type="info" plain icon="el-icon-sort" size="mini" @click="toggleExpandAll">展开/折叠</el-button> |
| 30 | </el-col> | 24 | </el-col> |
| 31 | - <el-col :span="1.5"> | ||
| 32 | - <el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport" | ||
| 33 | - :loading="exportLoading" | ||
| 34 | - v-hasPermi="['product:category:export']">导出 | ||
| 35 | - </el-button> | ||
| 36 | - </el-col> | ||
| 37 | <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar> | 25 | <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar> |
| 38 | </el-row> | 26 | </el-row> |
| 39 | 27 | ||
| 40 | <!-- 列表 --> | 28 | <!-- 列表 --> |
| 41 | <el-table v-if="refreshTable" v-loading="loading" :data="list" row-key="id" :default-expand-all="isExpandAll" | 29 | <el-table v-if="refreshTable" v-loading="loading" :data="list" row-key="id" :default-expand-all="isExpandAll" |
| 42 | :tree-props="{children: 'children', hasChildren: 'hasChildren'}"> | 30 | :tree-props="{children: 'children', hasChildren: 'hasChildren'}"> |
| 43 | - <el-table-column label="分类名称" align="center" prop="name"/> | ||
| 44 | - <el-table-column label="分类图标" align="center" prop="icon"> | ||
| 45 | - <template slot-scope="scope"> | ||
| 46 | - <svg-icon :icon-class="scope.row.icon" /> | ||
| 47 | - </template> | ||
| 48 | - </el-table-column> | ||
| 49 | - <el-table-column label="分类图片" align="center" prop="bannerUrl"> | 31 | + <el-table-column label="分类名称" prop="name"/> |
| 32 | + <el-table-column label="分类图片" align="center" prop="picUrl"> | ||
| 50 | <template slot-scope="scope"> | 33 | <template slot-scope="scope"> |
| 51 | - <img v-if="scope.row.bannerUrl" :src="scope.row.bannerUrl" alt="分类图片" class="img-height"/> | 34 | + <img v-if="scope.row.picUrl" :src="scope.row.picUrl" alt="分类图片" style="height: 100px"/> |
| 52 | </template> | 35 | </template> |
| 53 | </el-table-column> | 36 | </el-table-column> |
| 54 | <el-table-column label="分类排序" align="center" prop="sort"/> | 37 | <el-table-column label="分类排序" align="center" prop="sort"/> |
| @@ -78,32 +61,22 @@ | @@ -78,32 +61,22 @@ | ||
| 78 | <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body> | 61 | <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body> |
| 79 | <el-form ref="form" :model="form" :rules="rules" label-width="80px"> | 62 | <el-form ref="form" :model="form" :rules="rules" label-width="80px"> |
| 80 | <el-form-item label="上级分类" prop="parentId"> | 63 | <el-form-item label="上级分类" prop="parentId"> |
| 81 | - <Treeselect v-model="form.parentId" :options="parentCategoryOptions" :normalizer="normalizer" | ||
| 82 | - :show-count="true" | ||
| 83 | - placeholder="上级分类"/> | 64 | + <el-select v-model="form.parentId" placeholder="请选择上级分类" clearable size="small"> |
| 65 | + <el-option :key="0" label="顶级分类" :value="0"/> | ||
| 66 | + <el-option v-for="item in list.filter(v => v.parentId === 0)" :key="item.id" :label="item.name" :value="item.id"/> | ||
| 67 | + </el-select> | ||
| 84 | </el-form-item> | 68 | </el-form-item> |
| 85 | <el-form-item label="分类名称" prop="name"> | 69 | <el-form-item label="分类名称" prop="name"> |
| 86 | <el-input v-model="form.name" placeholder="请输入分类名称"/> | 70 | <el-input v-model="form.name" placeholder="请输入分类名称"/> |
| 87 | </el-form-item> | 71 | </el-form-item> |
| 88 | - <el-form-item label="分类图标" prop="icon"> | ||
| 89 | - <el-popover placement="bottom-start" width="460" trigger="click" @show="$refs['iconSelect'].reset()"> | ||
| 90 | - <IconSelect ref="iconSelect" @selected="iconSelected"/> | ||
| 91 | - <el-input slot="reference" v-model="form.icon" placeholder="点击选择分类图标" readonly> | ||
| 92 | - <svg-icon v-if="form.icon" slot="prefix" :icon-class="form.icon" class="el-input__icon" | ||
| 93 | - style="height: 32px;width: 16px;"/> | ||
| 94 | - <i v-else slot="prefix" class="el-icon-search el-input__icon"/> | ||
| 95 | - </el-input> | ||
| 96 | - </el-popover> | ||
| 97 | - </el-form-item> | ||
| 98 | <el-form-item label="分类图片" prop="bannerUrl"> | 72 | <el-form-item label="分类图片" prop="bannerUrl"> |
| 99 | - <ImageUpload v-model="form.bannerUrl" :limit="1"/> | 73 | + <ImageUpload v-model="form.picUrl" :limit="1" :is-show-tip="false" /> |
| 74 | + <div v-if="form.parentId === 0" style="font-size: 10px">推荐 200x100 图片分辨率</div> | ||
| 75 | + <div v-else style="font-size: 10px">推荐 100x100 图片分辨率</div> | ||
| 100 | </el-form-item> | 76 | </el-form-item> |
| 101 | <el-form-item label="分类排序" prop="sort"> | 77 | <el-form-item label="分类排序" prop="sort"> |
| 102 | <el-input-number v-model="form.sort" controls-position="right" :min="0" /> | 78 | <el-input-number v-model="form.sort" controls-position="right" :min="0" /> |
| 103 | </el-form-item> | 79 | </el-form-item> |
| 104 | - <el-form-item label="分类描述"> | ||
| 105 | - <editor v-model="form.description" :min-height="192"/> | ||
| 106 | - </el-form-item> | ||
| 107 | <el-form-item label="开启状态" prop="status"> | 80 | <el-form-item label="开启状态" prop="status"> |
| 108 | <el-radio-group v-model="form.status"> | 81 | <el-radio-group v-model="form.status"> |
| 109 | <el-radio v-for="dict in this.getDictDatas(DICT_TYPE.COMMON_STATUS)" | 82 | <el-radio v-for="dict in this.getDictDatas(DICT_TYPE.COMMON_STATUS)" |
| @@ -111,6 +84,9 @@ | @@ -111,6 +84,9 @@ | ||
| 111 | </el-radio> | 84 | </el-radio> |
| 112 | </el-radio-group> | 85 | </el-radio-group> |
| 113 | </el-form-item> | 86 | </el-form-item> |
| 87 | + <el-form-item label="分类描述"> | ||
| 88 | + <el-input v-model="form.description" type="textarea" placeholder="请输入分类描述" /> | ||
| 89 | + </el-form-item> | ||
| 114 | </el-form> | 90 | </el-form> |
| 115 | <div slot="footer" class="dialog-footer"> | 91 | <div slot="footer" class="dialog-footer"> |
| 116 | <el-button type="primary" @click="submitForm">确 定</el-button> | 92 | <el-button type="primary" @click="submitForm">确 定</el-button> |
| @@ -122,34 +98,31 @@ | @@ -122,34 +98,31 @@ | ||
| 122 | 98 | ||
| 123 | <script> | 99 | <script> |
| 124 | import { | 100 | import { |
| 125 | - createCategory, | ||
| 126 | - deleteCategory, | 101 | + createProductCategory, |
| 102 | + deleteProductCategory, | ||
| 127 | exportCategoryExcel, | 103 | exportCategoryExcel, |
| 128 | - getCategory, | ||
| 129 | - listCategory, | ||
| 130 | - updateCategory | 104 | + getProductCategory, |
| 105 | + getProductCategoryList, | ||
| 106 | + updateProductCategory | ||
| 131 | } from "@/api/mall/product/category"; | 107 | } from "@/api/mall/product/category"; |
| 132 | import Editor from '@/components/Editor'; | 108 | import Editor from '@/components/Editor'; |
| 133 | import Treeselect from "@riophae/vue-treeselect"; | 109 | import Treeselect from "@riophae/vue-treeselect"; |
| 134 | import "@riophae/vue-treeselect/dist/vue-treeselect.css"; | 110 | import "@riophae/vue-treeselect/dist/vue-treeselect.css"; |
| 135 | import IconSelect from "@/components/IconSelect"; | 111 | import IconSelect from "@/components/IconSelect"; |
| 136 | import ImageUpload from '@/components/ImageUpload'; | 112 | import ImageUpload from '@/components/ImageUpload'; |
| 113 | +import {CommonStatusEnum} from "@/utils/constants"; | ||
| 137 | 114 | ||
| 138 | export default { | 115 | export default { |
| 139 | name: "Category", | 116 | name: "Category", |
| 140 | components: { | 117 | components: { |
| 141 | - Editor, Treeselect, IconSelect, ImageUpload | 118 | + Editor, Treeselect, ImageUpload |
| 142 | }, | 119 | }, |
| 143 | data() { | 120 | data() { |
| 144 | return { | 121 | return { |
| 145 | // 遮罩层 | 122 | // 遮罩层 |
| 146 | loading: true, | 123 | loading: true, |
| 147 | - // 导出遮罩层 | ||
| 148 | - exportLoading: false, | ||
| 149 | // 显示搜索条件 | 124 | // 显示搜索条件 |
| 150 | showSearch: true, | 125 | showSearch: true, |
| 151 | - // 总条数 | ||
| 152 | - total: 0, | ||
| 153 | // 商品分类列表 | 126 | // 商品分类列表 |
| 154 | list: [], | 127 | list: [], |
| 155 | // 商品分类树选项 | 128 | // 商品分类树选项 |
| @@ -164,10 +137,7 @@ export default { | @@ -164,10 +137,7 @@ export default { | ||
| 164 | refreshTable: true, | 137 | refreshTable: true, |
| 165 | // 查询参数 | 138 | // 查询参数 |
| 166 | queryParams: { | 139 | queryParams: { |
| 167 | - pageNo: 1, | ||
| 168 | - pageSize: 10, | ||
| 169 | name: null, | 140 | name: null, |
| 170 | - status: null, | ||
| 171 | }, | 141 | }, |
| 172 | // 表单参数 | 142 | // 表单参数 |
| 173 | form: {}, | 143 | form: {}, |
| @@ -175,8 +145,8 @@ export default { | @@ -175,8 +145,8 @@ export default { | ||
| 175 | rules: { | 145 | rules: { |
| 176 | parentId: [{required: true, message: "请选择上级分类", trigger: "blur"}], | 146 | parentId: [{required: true, message: "请选择上级分类", trigger: "blur"}], |
| 177 | name: [{required: true, message: "分类名称不能为空", trigger: "blur"}], | 147 | name: [{required: true, message: "分类名称不能为空", trigger: "blur"}], |
| 178 | - icon: [{required: true, message: "分类图标不能为空", trigger: "blur"}], | ||
| 179 | - bannerUrl: [{required: true, message: "分类图片不能为空", trigger: "blur"}], | 148 | + picUrl: [{required: true, message: "分类图片不能为空", trigger: "blur"}], |
| 149 | + sort: [{required: true, message: "分类排序不能为空", trigger: "blur"}], | ||
| 180 | status: [{required: true, message: "开启状态不能为空", trigger: "blur"}], | 150 | status: [{required: true, message: "开启状态不能为空", trigger: "blur"}], |
| 181 | } | 151 | } |
| 182 | }; | 152 | }; |
| @@ -191,35 +161,11 @@ export default { | @@ -191,35 +161,11 @@ export default { | ||
| 191 | // 处理查询参数 | 161 | // 处理查询参数 |
| 192 | let params = {...this.queryParams}; | 162 | let params = {...this.queryParams}; |
| 193 | // 执行查询 | 163 | // 执行查询 |
| 194 | - listCategory(params).then(response => { | 164 | + getProductCategoryList(params).then(response => { |
| 195 | this.list = this.handleTree(response.data, "id", "parentId"); | 165 | this.list = this.handleTree(response.data, "id", "parentId"); |
| 196 | this.loading = false; | 166 | this.loading = false; |
| 197 | }); | 167 | }); |
| 198 | }, | 168 | }, |
| 199 | - // 选择图标 | ||
| 200 | - iconSelected(name) { | ||
| 201 | - this.form.icon = name; | ||
| 202 | - }, | ||
| 203 | - /** 转换菜单数据结构 */ | ||
| 204 | - normalizer(node) { | ||
| 205 | - if (node.children && !node.children.length) { | ||
| 206 | - delete node.children; | ||
| 207 | - } | ||
| 208 | - return { | ||
| 209 | - id: node.id, | ||
| 210 | - label: node.name, | ||
| 211 | - children: node.children | ||
| 212 | - }; | ||
| 213 | - }, | ||
| 214 | - /** 查询分类下拉树结构 */ | ||
| 215 | - getTreeselect() { | ||
| 216 | - listCategory().then(response => { | ||
| 217 | - this.parentCategoryOptions = []; | ||
| 218 | - const menu = {id: 0, name: '主分类', children: []}; | ||
| 219 | - menu.children = this.handleTree(response.data, "id", "parentId"); | ||
| 220 | - this.parentCategoryOptions.push(menu); | ||
| 221 | - }); | ||
| 222 | - }, | ||
| 223 | /** 取消按钮 */ | 169 | /** 取消按钮 */ |
| 224 | cancel() { | 170 | cancel() { |
| 225 | this.open = false; | 171 | this.open = false; |
| @@ -231,11 +177,10 @@ export default { | @@ -231,11 +177,10 @@ export default { | ||
| 231 | id: undefined, | 177 | id: undefined, |
| 232 | parentId: undefined, | 178 | parentId: undefined, |
| 233 | name: undefined, | 179 | name: undefined, |
| 234 | - icon: undefined, | ||
| 235 | - bannerUrl: undefined, | ||
| 236 | - sort: undefined, | 180 | + pirUrl: undefined, |
| 181 | + sort: 0, | ||
| 237 | description: undefined, | 182 | description: undefined, |
| 238 | - status: undefined, | 183 | + status: CommonStatusEnum.ENABLE, |
| 239 | }; | 184 | }; |
| 240 | this.resetForm("form"); | 185 | this.resetForm("form"); |
| 241 | }, | 186 | }, |
| @@ -260,16 +205,14 @@ export default { | @@ -260,16 +205,14 @@ export default { | ||
| 260 | /** 新增按钮操作 */ | 205 | /** 新增按钮操作 */ |
| 261 | handleAdd() { | 206 | handleAdd() { |
| 262 | this.reset(); | 207 | this.reset(); |
| 263 | - this.getTreeselect(); | ||
| 264 | this.open = true; | 208 | this.open = true; |
| 265 | this.title = "添加商品分类"; | 209 | this.title = "添加商品分类"; |
| 266 | }, | 210 | }, |
| 267 | /** 修改按钮操作 */ | 211 | /** 修改按钮操作 */ |
| 268 | handleUpdate(row) { | 212 | handleUpdate(row) { |
| 269 | this.reset(); | 213 | this.reset(); |
| 270 | - this.getTreeselect(); | ||
| 271 | const id = row.id; | 214 | const id = row.id; |
| 272 | - getCategory(id).then(response => { | 215 | + getProductCategory(id).then(response => { |
| 273 | this.form = response.data; | 216 | this.form = response.data; |
| 274 | this.open = true; | 217 | this.open = true; |
| 275 | this.title = "修改商品分类"; | 218 | this.title = "修改商品分类"; |
| @@ -283,7 +226,7 @@ export default { | @@ -283,7 +226,7 @@ export default { | ||
| 283 | } | 226 | } |
| 284 | // 修改的提交 | 227 | // 修改的提交 |
| 285 | if (this.form.id != null) { | 228 | if (this.form.id != null) { |
| 286 | - updateCategory(this.form).then(response => { | 229 | + updateProductCategory(this.form).then(response => { |
| 287 | this.$modal.msgSuccess("修改成功"); | 230 | this.$modal.msgSuccess("修改成功"); |
| 288 | this.open = false; | 231 | this.open = false; |
| 289 | this.getList(); | 232 | this.getList(); |
| @@ -291,7 +234,7 @@ export default { | @@ -291,7 +234,7 @@ export default { | ||
| 291 | return; | 234 | return; |
| 292 | } | 235 | } |
| 293 | // 添加的提交 | 236 | // 添加的提交 |
| 294 | - createCategory(this.form).then(response => { | 237 | + createProductCategory(this.form).then(response => { |
| 295 | this.$modal.msgSuccess("新增成功"); | 238 | this.$modal.msgSuccess("新增成功"); |
| 296 | this.open = false; | 239 | this.open = false; |
| 297 | this.getList(); | 240 | this.getList(); |
| @@ -302,36 +245,13 @@ export default { | @@ -302,36 +245,13 @@ export default { | ||
| 302 | handleDelete(row) { | 245 | handleDelete(row) { |
| 303 | const id = row.id; | 246 | const id = row.id; |
| 304 | this.$modal.confirm('是否确认删除商品分类编号为"' + id + '"的数据项?').then(function () { | 247 | this.$modal.confirm('是否确认删除商品分类编号为"' + id + '"的数据项?').then(function () { |
| 305 | - return deleteCategory(id); | 248 | + return deleteProductCategory(id); |
| 306 | }).then(() => { | 249 | }).then(() => { |
| 307 | this.getList(); | 250 | this.getList(); |
| 308 | this.$modal.msgSuccess("删除成功"); | 251 | this.$modal.msgSuccess("删除成功"); |
| 309 | }).catch(() => { | 252 | }).catch(() => { |
| 310 | }); | 253 | }); |
| 311 | - }, | ||
| 312 | - /** 导出按钮操作 */ | ||
| 313 | - handleExport() { | ||
| 314 | - // 处理查询参数 | ||
| 315 | - let params = {...this.queryParams}; | ||
| 316 | - params.pageNo = undefined; | ||
| 317 | - params.pageSize = undefined; | ||
| 318 | - // 执行导出 | ||
| 319 | - this.$modal.confirm('是否确认导出所有商品分类数据项?').then(() => { | ||
| 320 | - this.exportLoading = true; | ||
| 321 | - return exportCategoryExcel(params); | ||
| 322 | - }).then(response => { | ||
| 323 | - this.$download.excel(response, '商品分类.xls'); | ||
| 324 | - this.exportLoading = false; | ||
| 325 | - }).catch(() => { | ||
| 326 | - }); | ||
| 327 | } | 254 | } |
| 328 | } | 255 | } |
| 329 | }; | 256 | }; |
| 330 | </script> | 257 | </script> |
| 331 | - | ||
| 332 | -<style scoped lang="scss"> | ||
| 333 | -// | ||
| 334 | -.img-height { | ||
| 335 | - height: 150px; | ||
| 336 | -} | ||
| 337 | -</style> |
yudao-ui-admin/src/views/mall/product/spu/index.vue
| @@ -283,12 +283,12 @@ | @@ -283,12 +283,12 @@ | ||
| 283 | <script> | 283 | <script> |
| 284 | import {createSpu, updateSpu, deleteSpu, getSpu, getSpuPage, exportSpuExcel} from "@/api/mall/product/spu"; | 284 | import {createSpu, updateSpu, deleteSpu, getSpu, getSpuPage, exportSpuExcel} from "@/api/mall/product/spu"; |
| 285 | import { | 285 | import { |
| 286 | - createCategory, | ||
| 287 | - deleteCategory, | 286 | + createProductCategory, |
| 287 | + deleteProductCategory, | ||
| 288 | exportCategoryExcel, | 288 | exportCategoryExcel, |
| 289 | - getCategory, | ||
| 290 | - listCategory, | ||
| 291 | - updateCategory | 289 | + getProductCategory, |
| 290 | + getProductCategoryList, | ||
| 291 | + updateProductCategory | ||
| 292 | } from "@/api/mall/product/category"; | 292 | } from "@/api/mall/product/category"; |
| 293 | import { | 293 | import { |
| 294 | createProperty, | 294 | createProperty, |
| @@ -585,7 +585,7 @@ export default { | @@ -585,7 +585,7 @@ export default { | ||
| 585 | /** 查询分类 */ | 585 | /** 查询分类 */ |
| 586 | getListCategory() { | 586 | getListCategory() { |
| 587 | // 执行查询 | 587 | // 执行查询 |
| 588 | - listCategory().then(response => { | 588 | + getProductCategoryList().then(response => { |
| 589 | this.categoryList = this.handleTree(response.data, "id", "parentId"); | 589 | this.categoryList = this.handleTree(response.data, "id", "parentId"); |
| 590 | 590 | ||
| 591 | }); | 591 | }); |