From 389e2ca7620d2f4be5ba9706b513ddc5bb66fa35 Mon Sep 17 00:00:00 2001 From: lihaoyuan <18278596806@163.com> Date: Mon, 29 Sep 2025 17:46:56 +0800 Subject: [PATCH] =?UTF-8?q?update:=E4=BF=AE=E6=94=B9=E7=BB=8F=E8=90=A5?= =?UTF-8?q?=E5=93=81=E7=B1=BB=E4=B8=BA=E8=81=94=E7=BA=A7=E8=8F=9C=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/shopAudit/shopAudit.js | 10 ++ src/config/net.config.js | 1 + .../store/base/components/StoreBaseEdit.vue | 95 +++++++++++++++---- .../store/shopAudit/shopAuditDetails.vue | 91 +++++++++++------- 4 files changed, 140 insertions(+), 57 deletions(-) diff --git a/src/api/shopAudit/shopAudit.js b/src/api/shopAudit/shopAudit.js index 2f7c94f..108f5ce 100644 --- a/src/api/shopAudit/shopAudit.js +++ b/src/api/shopAudit/shopAudit.js @@ -154,4 +154,14 @@ export function updateUserInfo(data){ }, data: data, }) +} +//查询分类列表 +export function getStoreCategories(){ + return request({ + url: URL.shop.merch.category, + method: 'get', + params:{ + category_is_enable:1 + } + }) } \ No newline at end of file diff --git a/src/config/net.config.js b/src/config/net.config.js index 1ed0368..f9a4850 100644 --- a/src/config/net.config.js +++ b/src/config/net.config.js @@ -449,6 +449,7 @@ let url = { merchApproval: api_url + '/admin/shop/merch/approval', //更新商家信息 update:api_url + '/admin/shop/merch/update', + category:api_url + '/admin/shop/shop-base-store-category/categoryTree', // 发起合同签署 createByFile: api_url + '/admin/shop/esign/sign-flow/create-by-file', //查看商家签署合同 diff --git a/src/views/store/base/components/StoreBaseEdit.vue b/src/views/store/base/components/StoreBaseEdit.vue index f1f503d..e7e9388 100644 --- a/src/views/store/base/components/StoreBaseEdit.vue +++ b/src/views/store/base/components/StoreBaseEdit.vue @@ -46,20 +46,16 @@ /> - - - + - @@ -143,7 +139,9 @@ import { translateTitle as __ } from '@/utils/i18n' import { doEdit, FindStoreLevel, storeSetUp } from '@/api/store/base' import { GetStoreClassify } from '@/api/base/store/category' import { getList as getSubsite } from '@/api/plantform/subsite' - +import { + getStoreCategories +} from '@/api/shopAudit/shopAudit' export default { name: 'StoreBaseEdit', @@ -152,6 +150,8 @@ export default { options: [], classifyData: [], siteOptions: [], + cascaderValue: [], // 级联选择器专用绑定值(数组类型) + cascaderOptions: [], form: { store_is_open: 0, store_is_selfsupport: 1, @@ -278,9 +278,20 @@ export default { }) }, async fetchdataGetStoreClassify() { - await GetStoreClassify().then((res) => { - this.classifyData = res.data - }) + try { + const res = await getStoreCategories(); + if (res.status === 200 && res.data) { + this.classifyData = res.data; + // 关键:将分类数据格式化为级联选择器需要的结构 + this.cascaderOptions = this.transformStoreCategories(res.data); + console.log("级联分类数据源:", this.cascaderOptions); + } else { + this.$baseMessage("获取经营品类失败", "error"); + } + } catch (err) { + this.$baseMessage("获取经营品类异常", "error"); + console.error(err); + } }, async getSubsiteList() { let param = { @@ -295,13 +306,31 @@ export default { } }, showEdit(row) { + this.cascaderValue = []; if (!row) { - this.title = this.__('新增') + // 新增:清空表单,设置标题 + this.title = this.__('新增'); + this.form = { + store_is_open: 0, + store_is_selfsupport: 1, + store_type: 1, + store_o2o_flag: 0, + subsite_id: 0, + split_ratio: 0, + store_category_id: 0, + store_2nd_category_id:0, + }; } else { - this.title = this.__('编辑') - this.form = Object.assign({}, row) + this.title = this.__('编辑'); + this.form = Object.assign({}, row); + if (row.store_category_id && row.store_2nd_category_id) { + this.cascaderValue = [ + row.store_category_id, // 一级分类ID + row.store_2nd_category_id // 二级分类ID + ]; + } } - this.dialogFormVisible = true + this.dialogFormVisible = true; }, close() { this.form = { @@ -313,6 +342,30 @@ export default { this.$refs['form'].resetFields() this.dialogFormVisible = false }, + transformStoreCategories(data) { + return data.map(item => ({ + value: item.store_category_id, + label: item.store_category_name, + children: item.children ? [ + // 添加一个与一级目录同名的选项 + { + value: item.store_category_id, + label: item.store_category_name + }, + ...item.children.map(child => ({ + value: child.store_category_id, + label: child.store_category_name + })) + ] : [] + })); + }, + handleChangeBizCategory(value) { + if (value && value.length === 2) { + const [bizCategoryId, bizSecondCategoryId] = value; + this.form.store_category_id = bizCategoryId; + this.form.store_2nd_category_id = bizSecondCategoryId; + } + }, save() { this.$refs['form'].validate(async (valid) => { if (valid) { diff --git a/src/views/store/shopAudit/shopAuditDetails.vue b/src/views/store/shopAudit/shopAuditDetails.vue index 6f07066..3fc361f 100644 --- a/src/views/store/shopAudit/shopAuditDetails.vue +++ b/src/views/store/shopAudit/shopAuditDetails.vue @@ -43,26 +43,15 @@
经营品类
- - - - +
@@ -1034,6 +1023,7 @@ import { createSubAccount, checkShopName, updateUserInfo, + getStoreCategories } from '@/api/shopAudit/shopAudit' import { GetStoreClassify } from '@/api/base/store/category' import { batchNoApi, imgOcrResultApi } from "@/api/upload"; @@ -1081,6 +1071,8 @@ export default { formConfig: JSON.parse(JSON.stringify(config)), cityData: JSON.parse(JSON.stringify(city.cityData)), classifyData: [], + cascaderValue: [], // 级联选择器专用绑定值(数组类型) + cascaderOptions: [], form: { id:'', login_mobile: '66', @@ -1338,9 +1330,7 @@ export default { }, }, created() { - this.uploadParams.authorization = getToken() - this.fetchdataGetStoreClassify() - console.log(this.uploadParams) + this.uploadParams.authorization = getToken(); }, methods: { async getMerchDetail() { @@ -1384,6 +1374,13 @@ export default { this.showLoading = false await this.getCategoryList(); + if (this.form.biz_category && this.form.biz_second_category) { + this.cascaderValue = [ + this.form.biz_category, // 一级分类ID + this.form.biz_second_category // 二级分类ID + ]; + console.log("级联回显值:", this.cascaderValue); + } const areaData = await getAreaJSON() if(this.form.store_district){ @@ -1490,6 +1487,30 @@ export default { } }, + transformStoreCategories(data) { + return data.map(item => ({ + value: item.store_category_id, + label: item.store_category_name, + children: item.children ? [ + // 添加一个与一级目录同名的选项 + { + value: item.store_category_id, + label: `${item.store_category_name} 到账比例(${item.split_ratio}%)` + }, + ...item.children.map(child => ({ + value: child.store_category_id, + label: `${child.store_category_name} 到账比例(${child.split_ratio}%)` + })) + ] : [] + })); + }, + handleChangeBizCategory(value) { + if (value && value.length === 2) { + const [bizCategoryId, bizSecondCategoryId] = value; + this.form.biz_category = bizCategoryId; + this.form.biz_second_category = bizSecondCategoryId; + } + }, formatAreaData(data){ let provinces = [] data.forEach((item) => { @@ -1535,15 +1556,18 @@ export default { const parts = url.split('/') return parts[parts.length - 1] || 'contract.pdf' }, - async getCategoryList(){ - let res = await GetCategoryList(); - - if(res && res.status == 200){ - - let name = this.findCategoryName(res.data,this.form.biz_category); - if(name){ - this.form.biz_category = name + async getCategoryList() { + try { + const res = await getStoreCategories(); + if (res.code === 0 && res.status === 200) { + this.cascaderOptions = this.transformStoreCategories(res.data); + console.log("分类列表加载完成:", this.cascaderOptions); + } else { + this.$message.warning("获取分类列表异常"); } + } catch (err) { + this.$message.error("获取店铺分类失败"); + console.error(err); } }, findCategoryName(categories, targetId) { @@ -1857,11 +1881,6 @@ export default { console.log(this.form.province_nmae) } }, - async fetchdataGetStoreClassify() { - await GetStoreClassify().then((res) => { - this.classifyData = res.data - }) - }, handerChangeCity(e){ this.provinceData = []; this.provinceCode = ""