update:修改经营品类为联级菜单
This commit is contained in:
parent
179ed1f0bd
commit
389e2ca762
@ -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
|
||||
}
|
||||
})
|
||||
}
|
||||
@ -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',
|
||||
//查看商家签署合同
|
||||
|
||||
@ -46,20 +46,16 @@
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item :label="__('经营分类')" prop="store_category_id">
|
||||
<el-select
|
||||
v-model.trim="form.store_category_id"
|
||||
clearable
|
||||
:placeholder="__('经营分类')"
|
||||
:style="{ width: '48%' }"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in classifyData"
|
||||
:key="item.store_category_id"
|
||||
:label="item.store_category_name"
|
||||
:value="item.store_category_id"
|
||||
<el-form-item :label="__('经营品类')">
|
||||
<el-cascader
|
||||
v-model="cascaderValue"
|
||||
:options="cascaderOptions"
|
||||
placeholder="请选择经营品类"
|
||||
:show-all-levels="false"
|
||||
@change="handleChangeBizCategory"
|
||||
clearable
|
||||
:disabled="isReadonly"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item :label="__('分账比例')" prop="split_ratio">
|
||||
<el-input v-model.trim="form.split_ratio" :placeholder="__('比例在70%-99%之间')" clearable />
|
||||
@ -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) {
|
||||
|
||||
@ -43,26 +43,15 @@
|
||||
|
||||
<div class="item-block" style="margin-left: 30px;">
|
||||
<div class="item-lable">经营品类</div>
|
||||
<!-- <el-input
|
||||
class="item-input"
|
||||
v-model="form.biz_category"
|
||||
clearable
|
||||
:disabled="isReadonly"
|
||||
/> -->
|
||||
<el-select
|
||||
v-model.trim="form.biz_category"
|
||||
clearable
|
||||
:placeholder="__('经营分类')"
|
||||
:style="{ width: '48%' }"
|
||||
:disabled="isReadonly"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in classifyData"
|
||||
:key="item.store_category_id"
|
||||
:label="item.store_category_name"
|
||||
:value="item.store_category_id"
|
||||
/>
|
||||
</el-select>
|
||||
<el-cascader
|
||||
v-model="cascaderValue"
|
||||
:options="cascaderOptions"
|
||||
placeholder="请选择经营品类"
|
||||
:show-all-levels="false"
|
||||
@change="handleChangeBizCategory"
|
||||
clearable
|
||||
:disabled="isReadonly"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="item-info">
|
||||
@ -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 = ""
|
||||
|
||||
Loading…
Reference in New Issue
Block a user