This commit is contained in:
@@ -318,7 +318,7 @@
|
||||
// 搜索表单初始值
|
||||
const initialSearchState = {
|
||||
iccid: '',
|
||||
device_no: '',
|
||||
virtual_no: '',
|
||||
carrier_id: undefined as number | undefined,
|
||||
status: undefined as number | undefined
|
||||
}
|
||||
@@ -354,7 +354,7 @@
|
||||
},
|
||||
{
|
||||
label: '设备号',
|
||||
prop: 'device_no',
|
||||
prop: 'virtual_no',
|
||||
type: 'input',
|
||||
config: {
|
||||
clearable: true,
|
||||
@@ -460,7 +460,7 @@
|
||||
const columnOptions = [
|
||||
{ label: 'ICCID', prop: 'iccid' },
|
||||
{ label: '卡接入号', prop: 'msisdn' },
|
||||
{ label: '设备号', prop: 'device_no' },
|
||||
{ label: '设备号', prop: 'virtual_no' },
|
||||
{ label: '运营商ID', prop: 'carrier_id' },
|
||||
{ label: '运营商', prop: 'carrier_name' },
|
||||
{ label: '套餐名称', prop: 'package_name' },
|
||||
@@ -527,7 +527,7 @@
|
||||
width: 130
|
||||
},
|
||||
{
|
||||
prop: 'device_no',
|
||||
prop: 'virtual_no',
|
||||
label: '设备号',
|
||||
width: 150
|
||||
},
|
||||
@@ -612,7 +612,7 @@
|
||||
page: pagination.page,
|
||||
page_size: pagination.pageSize,
|
||||
iccid: searchForm.iccid || undefined,
|
||||
device_no: searchForm.device_no || undefined,
|
||||
virtual_no: searchForm.virtual_no || undefined,
|
||||
carrier_id: searchForm.carrier_id,
|
||||
status: searchForm.status
|
||||
}
|
||||
|
||||
@@ -87,42 +87,36 @@
|
||||
</ElRow>
|
||||
<ElRow :gutter="20">
|
||||
<ElCol :span="12">
|
||||
<ElFormItem label="省份" prop="province">
|
||||
<ElInput v-model="form.province" placeholder="请输入省份" />
|
||||
</ElFormItem>
|
||||
</ElCol>
|
||||
<ElCol :span="12">
|
||||
<ElFormItem label="城市" prop="city">
|
||||
<ElInput v-model="form.city" placeholder="请输入城市" />
|
||||
</ElFormItem>
|
||||
</ElCol>
|
||||
</ElRow>
|
||||
<ElRow :gutter="20">
|
||||
<ElCol :span="12">
|
||||
<ElFormItem label="区县" prop="district">
|
||||
<ElInput v-model="form.district" placeholder="请输入区县" />
|
||||
<ElFormItem label="所在地区" prop="region">
|
||||
<ElCascader
|
||||
v-model="form.region"
|
||||
:options="regionData"
|
||||
placeholder="请选择省/市/区"
|
||||
clearable
|
||||
filterable
|
||||
style="width: 100%"
|
||||
@change="handleRegionChange"
|
||||
/>
|
||||
</ElFormItem>
|
||||
</ElCol>
|
||||
<!-- 只有非代理账号才显示归属店铺选择 -->
|
||||
<ElCol :span="12" v-if="!isAgentAccount">
|
||||
<ElFormItem label="归属店铺" prop="owner_shop_id">
|
||||
<ElSelect
|
||||
<ElTreeSelect
|
||||
v-model="form.owner_shop_id"
|
||||
placeholder="请选择店铺"
|
||||
:data="shopTreeData"
|
||||
placeholder="请选择归属店铺"
|
||||
filterable
|
||||
remote
|
||||
:remote-method="searchShops"
|
||||
:loading="shopLoading"
|
||||
clearable
|
||||
check-strictly
|
||||
:render-after-expand="false"
|
||||
:props="{
|
||||
label: 'shop_name',
|
||||
value: 'id',
|
||||
children: 'children'
|
||||
}"
|
||||
style="width: 100%"
|
||||
>
|
||||
<ElOption
|
||||
v-for="shop in shopList"
|
||||
:key="shop.id"
|
||||
:label="shop.shop_name"
|
||||
:value="shop.id"
|
||||
/>
|
||||
</ElSelect>
|
||||
/>
|
||||
</ElFormItem>
|
||||
</ElCol>
|
||||
</ElRow>
|
||||
@@ -220,7 +214,7 @@
|
||||
import { h } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { EnterpriseService, ShopService } from '@/api/modules'
|
||||
import { ElMessage, ElSwitch } from 'element-plus'
|
||||
import { ElMessage, ElSwitch, ElCascader, ElTreeSelect } from 'element-plus'
|
||||
import type { FormInstance, FormRules } from 'element-plus'
|
||||
import type { EnterpriseItem, ShopResponse } from '@/types/api'
|
||||
import type { SearchFormItem } from '@/types'
|
||||
@@ -233,6 +227,7 @@
|
||||
import TableContextMenuHint from '@/components/core/others/TableContextMenuHint.vue'
|
||||
import type { MenuItemType } from '@/components/core/others/ArtMenuRight.vue'
|
||||
import { formatDateTime } from '@/utils/business/format'
|
||||
import { regionData } from '@/utils/constants/regionData'
|
||||
|
||||
defineOptions({ name: 'EnterpriseCustomer' })
|
||||
|
||||
@@ -261,7 +256,7 @@
|
||||
const shopLoading = ref(false)
|
||||
const tableRef = ref()
|
||||
const currentEnterpriseId = ref<number>(0)
|
||||
const shopList = ref<ShopResponse[]>([])
|
||||
const shopTreeData = ref<ShopResponse[]>([])
|
||||
|
||||
// 右键菜单
|
||||
const enterpriseOperationMenuRef = ref<InstanceType<typeof ArtMenuRight>>()
|
||||
@@ -388,6 +383,7 @@
|
||||
enterprise_name: '',
|
||||
business_license: '',
|
||||
legal_person: '',
|
||||
region: [] as string[],
|
||||
province: '',
|
||||
city: '',
|
||||
district: '',
|
||||
@@ -518,20 +514,19 @@
|
||||
}
|
||||
})
|
||||
|
||||
// 加载店铺列表(默认加载20条)
|
||||
const loadShopList = async (shopName?: string) => {
|
||||
// 加载店铺列表(获取所有店铺构建树形结构)
|
||||
const loadShopList = async () => {
|
||||
shopLoading.value = true
|
||||
try {
|
||||
const params: any = {
|
||||
page: 1,
|
||||
pageSize: 20
|
||||
}
|
||||
if (shopName) {
|
||||
params.shop_name = shopName
|
||||
page_size: 9999 // 获取所有数据用于构建树形结构
|
||||
}
|
||||
const res = await ShopService.getShops(params)
|
||||
if (res.code === 0) {
|
||||
shopList.value = res.data.items || []
|
||||
const items = res.data.items || []
|
||||
// 构建树形数据
|
||||
shopTreeData.value = buildTreeData(items)
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取店铺列表失败:', error)
|
||||
@@ -540,13 +535,31 @@
|
||||
}
|
||||
}
|
||||
|
||||
// 搜索店铺
|
||||
const searchShops = (query: string) => {
|
||||
if (query) {
|
||||
loadShopList(query)
|
||||
} else {
|
||||
loadShopList()
|
||||
}
|
||||
// 构建树形数据
|
||||
const buildTreeData = (items: ShopResponse[]) => {
|
||||
const map = new Map<number, ShopResponse & { children?: ShopResponse[] }>()
|
||||
const tree: ShopResponse[] = []
|
||||
|
||||
// 先将所有项放入 map
|
||||
items.forEach((item) => {
|
||||
map.set(item.id, { ...item, children: [] })
|
||||
})
|
||||
|
||||
// 构建树形结构
|
||||
items.forEach((item) => {
|
||||
const node = map.get(item.id)!
|
||||
if (item.parent_id && map.has(item.parent_id)) {
|
||||
// 有父节点,添加到父节点的 children 中
|
||||
const parent = map.get(item.parent_id)!
|
||||
if (!parent.children) parent.children = []
|
||||
parent.children.push(node)
|
||||
} else {
|
||||
// 没有父节点或父节点不存在,作为根节点
|
||||
tree.push(node)
|
||||
}
|
||||
})
|
||||
|
||||
return tree
|
||||
}
|
||||
|
||||
// 获取企业客户列表
|
||||
@@ -602,6 +615,19 @@
|
||||
getTableData()
|
||||
}
|
||||
|
||||
// 处理地区选择变化
|
||||
const handleRegionChange = (value: string[]) => {
|
||||
if (value && value.length === 3) {
|
||||
form.province = value[0]
|
||||
form.city = value[1]
|
||||
form.district = value[2]
|
||||
} else {
|
||||
form.province = ''
|
||||
form.city = ''
|
||||
form.district = ''
|
||||
}
|
||||
}
|
||||
|
||||
const dialogType = ref('add')
|
||||
|
||||
// 显示新增/编辑对话框
|
||||
@@ -617,6 +643,12 @@
|
||||
form.province = row.province
|
||||
form.city = row.city
|
||||
form.district = row.district
|
||||
// 设置地区级联选择器的值
|
||||
if (row.province && row.city && row.district) {
|
||||
form.region = [row.province, row.city, row.district]
|
||||
} else {
|
||||
form.region = []
|
||||
}
|
||||
form.address = row.address
|
||||
form.contact_name = row.contact_name
|
||||
form.contact_phone = row.contact_phone
|
||||
@@ -628,6 +660,7 @@
|
||||
form.enterprise_name = ''
|
||||
form.business_license = ''
|
||||
form.legal_person = ''
|
||||
form.region = []
|
||||
form.province = ''
|
||||
form.city = ''
|
||||
form.district = ''
|
||||
|
||||
Reference in New Issue
Block a user