This commit is contained in:
2026-08-28 13:54:44 +08:00
parent 67a1278554
commit 251645d2d8
8 changed files with 394 additions and 69 deletions
+11 -11
View File
@@ -153,12 +153,12 @@ describe('InternalUsersView platform internal user management', () => {
expect(document.body.textContent).toContain('确认添加')
})
it('requires a shared receiving warehouse for WAREHOUSE_PICKER', async () => {
it('requires a shared receiving warehouse for OVERSEAS_WAREHOUSE_PDA_OPERATOR', async () => {
vi.mocked(getPlatformUserOptions).mockResolvedValueOnce({
tenants: [{ id: '0', name: '平台', status: 'ACTIVE' }],
roles: [
{ id: '40', tenantId: '0', roleCode: 'PLATFORM_OPERATOR', name: '运营管理员', status: 'ACTIVE' },
{ id: '4000005', tenantId: '0', roleCode: 'WAREHOUSE_PICKER', name: '仓库拣货员', status: 'ACTIVE' },
{ id: '4000005', tenantId: '0', roleCode: 'OVERSEAS_WAREHOUSE_PDA_OPERATOR', name: '海外仓 PDA 作业员', status: 'ACTIVE' },
],
})
const wrapper = await mountView()
@@ -180,16 +180,16 @@ describe('InternalUsersView platform internal user management', () => {
})
it('uses the stable role code instead of localized role names to activate the warehouse binding', () => {
expect(internalUsersSource).toContain("role.roleCode === 'WAREHOUSE_PICKER'")
expect(internalUsersSource).toContain('overseasWarehouseId: hasWarehousePickerRole.value ? form.overseasWarehouseId : null')
expect(internalUsersSource).not.toContain("role.name === '仓库拣货员'")
expect(internalUsersSource).toContain("role.roleCode === 'OVERSEAS_WAREHOUSE_PDA_OPERATOR'")
expect(internalUsersSource).toContain('overseasWarehouseId: hasOverseasPdaRole.value ? form.overseasWarehouseId : null')
expect(internalUsersSource).not.toContain("role.name === '海外仓 PDA 作业员'")
})
it('preserves the picker warehouse binding when editing a WAREHOUSE_PICKER user', async () => {
it('preserves the picker warehouse binding when editing a OVERSEAS_WAREHOUSE_PDA_OPERATOR user', async () => {
const pickerUser: PlatformManagedUser = {
...user,
roleIds: ['4000005'],
roleNames: ['仓库拣货员'],
roleNames: ['海外仓 PDA 作业员'],
overseasWarehouseId: '90071992547409931',
}
vi.mocked(listPlatformManagedUsers).mockResolvedValueOnce({
@@ -197,7 +197,7 @@ describe('InternalUsersView platform internal user management', () => {
})
vi.mocked(getPlatformUserOptions).mockResolvedValueOnce({
tenants: [{ id: '0', name: '平台', status: 'ACTIVE' }],
roles: [{ id: '4000005', tenantId: '0', roleCode: 'WAREHOUSE_PICKER', name: '仓库拣货员', status: 'ACTIVE' }],
roles: [{ id: '4000005', tenantId: '0', roleCode: 'OVERSEAS_WAREHOUSE_PDA_OPERATOR', name: '海外仓 PDA 作业员', status: 'ACTIVE' }],
})
vi.mocked(updatePlatformManagedUser).mockResolvedValueOnce(pickerUser)
@@ -220,12 +220,12 @@ describe('InternalUsersView platform internal user management', () => {
})
})
it('clears a warehouse binding after switching away from WAREHOUSE_PICKER', async () => {
it('clears a warehouse binding after switching away from OVERSEAS_WAREHOUSE_PDA_OPERATOR', async () => {
vi.mocked(getPlatformUserOptions).mockResolvedValueOnce({
tenants: [{ id: '0', name: '平台', status: 'ACTIVE' }],
roles: [
{ id: '40', tenantId: '0', roleCode: 'PLATFORM_OPERATOR', name: '运营管理员', status: 'ACTIVE' },
{ id: '4000005', tenantId: '0', roleCode: 'WAREHOUSE_PICKER', name: '仓库拣货员', status: 'ACTIVE' },
{ id: '4000005', tenantId: '0', roleCode: 'OVERSEAS_WAREHOUSE_PDA_OPERATOR', name: '海外仓 PDA 作业员', status: 'ACTIVE' },
],
})
const wrapper = await mountView()
@@ -250,7 +250,7 @@ describe('InternalUsersView platform internal user management', () => {
it('submits the selected picker warehouse as an unchanged long-id string', async () => {
vi.mocked(getPlatformUserOptions).mockResolvedValueOnce({
tenants: [{ id: '0', name: '平台', status: 'ACTIVE' }],
roles: [{ id: '4000005', tenantId: '0', roleCode: 'WAREHOUSE_PICKER', name: '仓库拣货员', status: 'ACTIVE' }],
roles: [{ id: '4000005', tenantId: '0', roleCode: 'OVERSEAS_WAREHOUSE_PDA_OPERATOR', name: '海外仓 PDA 作业员', status: 'ACTIVE' }],
})
const wrapper = await mountView()
const setupState = (wrapper.vm.$ as unknown as {
+8 -8
View File
@@ -105,10 +105,10 @@ const availableRoles = computed(() => options.value.roles.filter((role) =>
String(role.tenantId) === '0'
&& (role.status === 'ACTIVE' || form.roleIds.includes(String(role.id))),
))
const warehousePickerRoleIds = computed(() => new Set(
availableRoles.value.filter((role) => role.roleCode === 'WAREHOUSE_PICKER').map((role) => String(role.id)),
const overseasPdaRoleIds = computed(() => new Set(
availableRoles.value.filter((role) => role.roleCode === 'OVERSEAS_WAREHOUSE_PDA_OPERATOR').map((role) => String(role.id)),
))
const hasWarehousePickerRole = computed(() => form.roleIds.some((roleId) => warehousePickerRoleIds.value.has(roleId)))
const hasOverseasPdaRole = computed(() => form.roleIds.some((roleId) => overseasPdaRoleIds.value.has(roleId)))
const formRules = computed<FormRules>(() => ({
username: editingUser.value ? [] : [
@@ -122,7 +122,7 @@ const formRules = computed<FormRules>(() => ({
],
email: editingUser.value && !canEdit.value ? [] : [{ type: 'email', message: '请输入有效的邮箱地址', trigger: 'blur' }],
roleIds: editingUser.value && !canEdit.value ? [] : [{ type: 'array', required: true, min: 1, message: '请选择角色', trigger: 'change' }],
overseasWarehouseId: !hasWarehousePickerRole.value || (editingUser.value && !canEdit.value) ? [] : [
overseasWarehouseId: !hasOverseasPdaRole.value || (editingUser.value && !canEdit.value) ? [] : [
{ required: true, message: '请选择实际海外收货仓', trigger: 'change' },
],
password: editingUser.value && !form.resetPassword ? [] : [
@@ -263,7 +263,7 @@ async function saveUser() {
email: form.email.trim(),
tenantId: '0',
roleIds: form.roleIds,
overseasWarehouseId: hasWarehousePickerRole.value ? form.overseasWarehouseId : null,
overseasWarehouseId: hasOverseasPdaRole.value ? form.overseasWarehouseId : null,
password: form.password,
status: form.status,
})
@@ -277,7 +277,7 @@ async function saveUser() {
email: form.email.trim(),
tenantId: '0',
roleIds: form.roleIds,
overseasWarehouseId: hasWarehousePickerRole.value ? form.overseasWarehouseId : null,
overseasWarehouseId: hasOverseasPdaRole.value ? form.overseasWarehouseId : null,
})
}
if (canChangeStatus.value && form.status !== row.status) {
@@ -330,7 +330,7 @@ function applyFilters() {
}
watch([page, pageSize], () => void loadUsers())
watch(hasWarehousePickerRole, (selected) => {
watch(hasOverseasPdaRole, (selected) => {
if (!selected) {
form.overseasWarehouseId = ''
overseasWarehousesError.value = null
@@ -419,7 +419,7 @@ onMounted(loadInitialData)
<el-option label="禁用" value="DISABLED" />
</el-select>
</el-form-item>
<el-form-item v-if="hasWarehousePickerRole" label="实际海外收货仓" prop="overseasWarehouseId" required>
<el-form-item v-if="hasOverseasPdaRole" label="实际海外收货仓" prop="overseasWarehouseId" required>
<el-select v-model="form.overseasWarehouseId" filterable
:loading="overseasWarehousesLoading" :disabled="Boolean(editingUser) && !canEdit"
placeholder="请选择平台共享海外收货仓">