This commit is contained in:
@@ -59,9 +59,9 @@
|
||||
<ElDialog
|
||||
v-model="dialogVisible"
|
||||
:title="isShopType ? '新增店铺账号' : '新增企业账号'"
|
||||
width="500px"
|
||||
width="30%"
|
||||
>
|
||||
<ElForm ref="formRef" :model="accountForm" :rules="accountRules" label-width="100px">
|
||||
<ElForm ref="formRef" :model="accountForm" :rules="accountRules" label-width="80">
|
||||
<ElFormItem label="用户名" prop="username">
|
||||
<ElInput v-model="accountForm.username" placeholder="请输入用户名" />
|
||||
</ElFormItem>
|
||||
@@ -226,7 +226,7 @@
|
||||
} from 'element-plus'
|
||||
import { ArrowLeft } from '@element-plus/icons-vue'
|
||||
import type { FormInstance, FormRules } from 'element-plus'
|
||||
import { AccountService, RoleService } from '@/api/modules'
|
||||
import { AccountService, RoleService, ShopService, EnterpriseService } from '@/api/modules'
|
||||
import ArtButtonTable from '@/components/core/forms/ArtButtonTable.vue'
|
||||
import type { SearchFormItem } from '@/types'
|
||||
import type { PlatformAccount, PlatformRole } from '@/types/api'
|
||||
@@ -243,7 +243,11 @@
|
||||
const isShopType = computed(() => route.query.type === 'shop')
|
||||
|
||||
// 页面标题
|
||||
const pageTitle = computed(() => (isShopType.value ? '店铺账号列表' : '企业客户账号列表'))
|
||||
const entityName = ref('')
|
||||
const pageTitle = computed(() => {
|
||||
const baseTitle = isShopType.value ? '店铺账号列表' : '企业客户账号列表'
|
||||
return entityName.value ? `${baseTitle} - ${entityName.value}` : baseTitle
|
||||
})
|
||||
|
||||
// 过滤参数键名
|
||||
const filterParamKey = computed(() => (isShopType.value ? 'shop_id' : 'enterprise_id'))
|
||||
@@ -425,6 +429,37 @@
|
||||
return baseColumns
|
||||
})
|
||||
|
||||
// 加载店铺/企业名称
|
||||
const loadEntityName = async () => {
|
||||
const entityId = Number(route.params.id)
|
||||
if (!entityId) return
|
||||
|
||||
try {
|
||||
if (isShopType.value) {
|
||||
const res = await ShopService.getShops({ id: entityId, page: 1, page_size: 1 })
|
||||
if (res.code === 0 && res.data.items?.length) {
|
||||
entityName.value = res.data.items[0].shop_name || ''
|
||||
}
|
||||
} else {
|
||||
const res = await EnterpriseService.getEnterprises({ id: entityId, page: 1, page_size: 1 })
|
||||
if (res.code === 0 && res.data.items?.length) {
|
||||
entityName.value = res.data.items[0].enterprise_name || ''
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取名称失败:', error)
|
||||
}
|
||||
}
|
||||
|
||||
// 从账号数据中提取店铺/企业名称
|
||||
const extractEntityNameFromAccounts = () => {
|
||||
if (entityName.value || !accountList.value.length) return
|
||||
const firstAccount = accountList.value[0]
|
||||
if (firstAccount) {
|
||||
entityName.value = (firstAccount as any).shop_name || (firstAccount as any).enterprise_name || ''
|
||||
}
|
||||
}
|
||||
|
||||
// 获取账号列表
|
||||
const getTableData = async () => {
|
||||
loading.value = true
|
||||
@@ -451,6 +486,7 @@
|
||||
if (res.code === 0) {
|
||||
accountList.value = res.data.items || []
|
||||
pagination.total = res.data.total || 0
|
||||
extractEntityNameFromAccounts()
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
@@ -583,7 +619,7 @@
|
||||
const params: any = {
|
||||
page: 1,
|
||||
page_size: 20,
|
||||
role_type: 1
|
||||
role_type: 2
|
||||
}
|
||||
if (keyword) {
|
||||
params.role_name = keyword
|
||||
@@ -699,6 +735,7 @@
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
loadEntityName()
|
||||
getTableData()
|
||||
})
|
||||
</script>
|
||||
@@ -755,7 +792,7 @@
|
||||
display: flex;
|
||||
flex: 1;
|
||||
flex-direction: column;
|
||||
max-width: 380px;
|
||||
max-width: 440px;
|
||||
overflow: hidden;
|
||||
border: 1px solid var(--el-border-color);
|
||||
border-radius: 4px;
|
||||
|
||||
Reference in New Issue
Block a user