修改bug
All checks were successful
构建并部署前端到测试环境 / build-and-deploy (push) Successful in 4m54s

This commit is contained in:
sexygoat
2026-04-09 13:48:11 +08:00
parent cc9d2a85a2
commit cb3ba06106
26 changed files with 987 additions and 1984 deletions

View File

@@ -104,20 +104,15 @@
<!-- 只有非代理账号才显示归属店铺选择 -->
<ElCol :span="12" v-if="!isAgentAccount">
<ElFormItem label="归属店铺" prop="owner_shop_id">
<ElTreeSelect
<ElCascader
v-model="form.owner_shop_id"
:data="shopTreeData"
:options="shopCascadeOptions"
:props="shopCascadeProps"
placeholder="请选择归属店铺"
filterable
clearable
check-strictly
:render-after-expand="false"
:props="{
label: 'shop_name',
value: 'id',
children: 'children'
}"
style="width: 100%"
@change="handleShopChange"
/>
</ElFormItem>
</ElCol>
@@ -240,6 +235,37 @@
const currentEnterpriseId = ref<number>(0)
const shopTreeData = ref<ShopResponse[]>([])
// 店铺级联选择相关
const shopCascadeOptions = ref<any[]>([])
const shopCascadeProps = {
lazy: true,
checkStrictly: true,
lazyLoad: async (node: any, resolve: any) => {
const { level, value } = node
const parentId = level === 0 ? undefined : value
try {
const res = await ShopService.getShopsCascade({ parent_id: parentId })
if (res.code === 0) {
const nodes = (res.data || []).map((item: any) => ({
value: item.id,
label: item.shop_name,
leaf: !item.has_children
}))
resolve(nodes)
} else {
resolve([])
}
} catch (error) {
console.error('加载店铺级联数据失败:', error)
resolve([])
}
},
value: 'value',
label: 'label',
children: 'children'
}
// 搜索表单初始值
const initialSearchState = {
enterprise_name: '',
@@ -510,19 +536,17 @@
}
})
// 加载店铺列表(获取所有店铺构建树形结构)
// 加载店铺列表 - 改用级联查询
const loadShopList = async () => {
shopLoading.value = true
try {
const params: any = {
page: 1,
page_size: 9999 // 获取所有数据用于构建树形结构
}
const res = await ShopService.getShops(params)
const res = await ShopService.getShopsCascade({ parent_id: undefined })
if (res.code === 0) {
const items = res.data.items || []
// 构建树形数据
shopTreeData.value = buildTreeData(items)
shopCascadeOptions.value = (res.data || []).map((item: any) => ({
value: item.id,
label: item.shop_name,
leaf: !item.has_children
}))
}
} catch (error) {
console.error('获取店铺列表失败:', error)
@@ -531,6 +555,15 @@
}
}
// 处理店铺选择变化
const handleShopChange = (value: any) => {
if (Array.isArray(value) && value.length > 0) {
form.owner_shop_id = value[value.length - 1]
} else {
form.owner_shop_id = null
}
}
// 构建树形数据
const buildTreeData = (items: ShopResponse[]) => {
const map = new Map<number, ShopResponse & { children?: ShopResponse[] }>()