@@ -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 = ""