|
|
@@ -44,11 +44,6 @@
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
<el-table-column prop="sort" align="center" label="排序" width="150"></el-table-column>
|
|
|
- <el-table-column prop="platform" align="center" label="平台" width="150">
|
|
|
- <template #default="scope">
|
|
|
- <span>{{ scope.row.platform === 0 ? '工业品' : scope.row.platform === 1 ? 'PC端' : '未知' }}</span>
|
|
|
- </template>
|
|
|
- </el-table-column>
|
|
|
<el-table-column prop="isShow" align="center" label="是否提示" width="150">
|
|
|
<template #default="scope">
|
|
|
<span>{{ scope.row.isShow === 1 ? '是' : '否' }}</span>
|
|
|
@@ -68,6 +63,9 @@
|
|
|
<el-tooltip v-if="scope.row.classLevel === 3" content="设置审核员" placement="top">
|
|
|
<el-button v-hasPermi="['product:category:edit']" link type="primary" icon="User" @click="handleSetReviewer(scope.row)" />
|
|
|
</el-tooltip>
|
|
|
+ <el-tooltip v-if="scope.row.classLevel === 3" content="商品管理" placement="top">
|
|
|
+ <el-button v-hasPermi="['product:category:edit']" link type="primary" icon="Goods" @click="handleProductManage(scope.row)" />
|
|
|
+ </el-tooltip>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
</el-table>
|
|
|
@@ -88,14 +86,25 @@
|
|
|
/>
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
- <el-col :span="12">
|
|
|
- <el-form-item label="分类名称" prop="categoryName">
|
|
|
- <el-input v-model="form.categoryName" placeholder="请输入分类名称" />
|
|
|
+ <el-col :span="24">
|
|
|
+ <el-form-item label="A10分类" prop="categoryNo">
|
|
|
+ <el-tree-select
|
|
|
+ v-model="form.categoryNo"
|
|
|
+ :data="a10TreeOptions"
|
|
|
+ :props="{ value: 'categoryNo', label: 'categoryName', children: 'children' } as any"
|
|
|
+ node-key="categoryNo"
|
|
|
+ value-key="categoryNo"
|
|
|
+ placeholder="请选择A10分类"
|
|
|
+ filterable
|
|
|
+ clearable
|
|
|
+ check-strictly
|
|
|
+ style="width: 100%"
|
|
|
+ />
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
<el-col :span="12">
|
|
|
- <el-form-item label="分类编号" prop="categoryNo">
|
|
|
- <el-input v-model="form.categoryNo" placeholder="请输入分类编号" />
|
|
|
+ <el-form-item label="分类名称" prop="categoryName">
|
|
|
+ <el-input v-model="form.categoryName" placeholder="请输入分类名称" />
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
<el-col :span="12">
|
|
|
@@ -123,14 +132,7 @@
|
|
|
<el-input-number v-model="form.sort" controls-position="right" :min="0" style="width: 100%" />
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
- <el-col :span="12">
|
|
|
- <el-form-item label="平台" prop="platform">
|
|
|
- <el-select v-model="form.platform" placeholder="请选择所属平台" style="width: 100%">
|
|
|
- <el-option label="PC端" :value="0" />
|
|
|
- <el-option label="工业品" :value="1" />
|
|
|
- </el-select>
|
|
|
- </el-form-item>
|
|
|
- </el-col>
|
|
|
+
|
|
|
<el-col :span="12">
|
|
|
<el-form-item label="是否提示" prop="isShow">
|
|
|
<el-switch v-model="form.isShow" :active-value="1" :inactive-value="0" />
|
|
|
@@ -163,6 +165,8 @@
|
|
|
|
|
|
<script setup name="Category" lang="ts">
|
|
|
import { listCategory, getCategory, delCategory, addCategory, updateCategory, listCategoryExcludeChild, setCategoryReviewer } from '@/api/product/category';
|
|
|
+import { listCategory as listCategoryA10 } from '@/api/product/categoryA10';
|
|
|
+import { CategoryVO as CategoryA10VO } from '@/api/product/categoryA10/types';
|
|
|
import UserSelect from '@/components/UserSelect/index.vue';
|
|
|
import { UserVO } from '@/api/system/user/types';
|
|
|
import { CategoryVO, CategoryQuery, CategoryForm } from '@/api/product/category/types';
|
|
|
@@ -174,11 +178,29 @@ interface CategoryOptionsType {
|
|
|
}
|
|
|
|
|
|
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
|
|
|
+const route = useRoute();
|
|
|
+const router = useRouter();
|
|
|
+
|
|
|
+// 从路由参数中获取 platform
|
|
|
+const routePlatform = computed(() => {
|
|
|
+ const p = route.query.platform;
|
|
|
+ return p !== undefined && p !== '' ? Number(p) : undefined;
|
|
|
+});
|
|
|
+
|
|
|
+// 从路由参数中获取 customerId(大客户分类场景)
|
|
|
+const routeCustomerId = computed(() => {
|
|
|
+ const cid = route.query.customerId;
|
|
|
+ return cid !== undefined && cid !== '' ? String(cid) : undefined;
|
|
|
+});
|
|
|
|
|
|
const categoryList = ref<CategoryVO[]>([]);
|
|
|
const loading = ref(true);
|
|
|
const showSearch = ref(true);
|
|
|
const categoryOptions = ref<CategoryOptionsType[]>([]);
|
|
|
+// A10 分类列表(用于分类编号选择框)
|
|
|
+const a10Options = ref<CategoryA10VO[]>([]);
|
|
|
+// A10 分类树形结构(用于 el-tree-select)
|
|
|
+const a10TreeOptions = ref<any[]>([]);
|
|
|
// 存储懒加载的子节点加载状态和 resolve 函数
|
|
|
const lazyTreeNodeMap = ref<Map<string | number, { tree: any; treeNode: any; resolve: (data: CategoryVO[]) => void }>>(new Map());
|
|
|
|
|
|
@@ -202,6 +224,7 @@ const initFormData: CategoryForm = {
|
|
|
parentId: undefined,
|
|
|
sort: 0,
|
|
|
platform: undefined,
|
|
|
+ customerId: undefined,
|
|
|
isShow: 1,
|
|
|
isShowGps: 0,
|
|
|
oneLable1: undefined,
|
|
|
@@ -213,7 +236,9 @@ const initFormData: CategoryForm = {
|
|
|
const data = reactive<PageData<CategoryForm, Partial<CategoryQuery>>>({
|
|
|
form: {...initFormData},
|
|
|
queryParams: {
|
|
|
- categoryName: undefined
|
|
|
+ categoryName: undefined,
|
|
|
+ platform: undefined as number | undefined,
|
|
|
+ customerId: undefined as string | number | undefined
|
|
|
},
|
|
|
rules: {
|
|
|
categoryName: [
|
|
|
@@ -233,7 +258,7 @@ const getList = async () => {
|
|
|
// 清空懒加载缓存
|
|
|
lazyTreeNodeMap.value.clear();
|
|
|
// 只加载顶级分类(parentId = 0)
|
|
|
- const res = await listCategory({ ...queryParams.value, parentId: 0 });
|
|
|
+ const res = await listCategory({ ...queryParams.value, parentId: 0, platform: routePlatform.value, customerId: routeCustomerId.value });
|
|
|
const data = (res as any).rows || res.data || [];
|
|
|
// 根据 hasChildren 字段标记是否有子节点
|
|
|
categoryList.value = data.map((item: CategoryVO) => ({
|
|
|
@@ -248,7 +273,7 @@ const loadChildren = async (row: CategoryVO, treeNode: any, resolve: (data: Cate
|
|
|
// 存储加载状态,便于刷新时重新加载
|
|
|
lazyTreeNodeMap.value.set(row.id, { tree: row, treeNode, resolve });
|
|
|
try {
|
|
|
- const res = await listCategory({ parentId: row.id });
|
|
|
+ const res = await listCategory({ parentId: row.id, platform: routePlatform.value, customerId: routeCustomerId.value });
|
|
|
const data = (res as any).rows || res.data || [];
|
|
|
// 标记子节点是否还有子级
|
|
|
const children = data.map((item: CategoryVO) => ({
|
|
|
@@ -296,10 +321,19 @@ const refreshLazyNodes = () => {
|
|
|
});
|
|
|
};
|
|
|
|
|
|
+/** 加载 A10 分类选项列表 */
|
|
|
+const loadA10Options = async () => {
|
|
|
+ const res = await listCategoryA10();
|
|
|
+ const list = (res as any).rows || res.data || [];
|
|
|
+ a10Options.value = list;
|
|
|
+ // 构建树形结构
|
|
|
+ a10TreeOptions.value = proxy?.handleTree<any>(list, 'id') || [];
|
|
|
+}
|
|
|
+
|
|
|
/** 新增按钮操作 */
|
|
|
const handleAdd = async (row?: CategoryVO) => {
|
|
|
reset();
|
|
|
- const res = await listCategory();
|
|
|
+ const res = await listCategory({ platform: routePlatform.value, customerId: routeCustomerId.value });
|
|
|
const responseData = (res as any).rows || res.data || [];
|
|
|
const data = proxy?.handleTree<CategoryOptionsType>(responseData, 'id');
|
|
|
if (data) {
|
|
|
@@ -307,6 +341,14 @@ const handleAdd = async (row?: CategoryVO) => {
|
|
|
if (row && row.id) {
|
|
|
form.value.parentId = row?.id;
|
|
|
}
|
|
|
+ // 预填充路由中的平台
|
|
|
+ if (routePlatform.value !== undefined) {
|
|
|
+ form.value.platform = routePlatform.value;
|
|
|
+ }
|
|
|
+ // 预填充路由中的大客户ID
|
|
|
+ if (routeCustomerId.value !== undefined) {
|
|
|
+ form.value.customerId = routeCustomerId.value;
|
|
|
+ }
|
|
|
dialog.visible = true;
|
|
|
dialog.title = '添加产品分类';
|
|
|
}
|
|
|
@@ -317,7 +359,7 @@ const handleUpdate = async (row: CategoryVO) => {
|
|
|
reset();
|
|
|
const res = await getCategory(row.id);
|
|
|
form.value = res.data;
|
|
|
- const response = await listCategoryExcludeChild(row.id);
|
|
|
+ const response = await listCategoryExcludeChild(row.id, routePlatform.value);
|
|
|
// 根据后端返回结构,如果是 TableDataInfo 则用 rows,如果是直接数组则用 data
|
|
|
const responseData = (response as any).rows || response.data || [];
|
|
|
const data = proxy?.handleTree<CategoryOptionsType>(responseData, 'id');
|
|
|
@@ -340,6 +382,14 @@ const handleUpdate = async (row: CategoryVO) => {
|
|
|
const submitForm = () => {
|
|
|
categoryFormRef.value?.validate(async (valid: boolean) => {
|
|
|
if (valid) {
|
|
|
+ // 统一使用路由中的 platform 提交
|
|
|
+ if (routePlatform.value !== undefined) {
|
|
|
+ form.value.platform = routePlatform.value;
|
|
|
+ }
|
|
|
+ // 统一使用路由中的 customerId 提交
|
|
|
+ if (routeCustomerId.value !== undefined) {
|
|
|
+ form.value.customerId = routeCustomerId.value;
|
|
|
+ }
|
|
|
form.value.id ? await updateCategory(form.value) : await addCategory(form.value);
|
|
|
proxy?.$modal.msgSuccess('操作成功');
|
|
|
dialog.visible = false;
|
|
|
@@ -362,6 +412,20 @@ const handleSetReviewer = (row: CategoryVO) => {
|
|
|
userSelectRef.value?.open();
|
|
|
};
|
|
|
|
|
|
+/** 商品管理按钮操作 */
|
|
|
+const handleProductManage = (row: CategoryVO) => {
|
|
|
+ const query: Record<string, string> = {
|
|
|
+ categoryId: String(row.id)
|
|
|
+ };
|
|
|
+ if (routePlatform.value !== undefined) {
|
|
|
+ query.platform = String(routePlatform.value);
|
|
|
+ }
|
|
|
+ if (routeCustomerId.value !== undefined) {
|
|
|
+ query.customerId = routeCustomerId.value;
|
|
|
+ }
|
|
|
+ router.push({ path: '/product/category/categoryProduct', query });
|
|
|
+};
|
|
|
+
|
|
|
/** 审核员选择回调 */
|
|
|
const handleReviewerSelected = async (users: UserVO[]) => {
|
|
|
if (!currentReviewerCategory.value || users.length === 0) return;
|
|
|
@@ -377,5 +441,7 @@ const handleReviewerSelected = async (users: UserVO[]) => {
|
|
|
|
|
|
onMounted(() => {
|
|
|
getList();
|
|
|
+ // 页面加载时预加载 A10 分类树
|
|
|
+ loadA10Options();
|
|
|
});
|
|
|
</script>
|