fix(前端): 后台摘掉公司这一维度——列表列/筛选/建号选择/顶栏旁白全部去掉
用户定案:隔离该由数据和后端自己做,不该把"公司"摆到操作员眼前多一个选错的机会。 于是原计划里给品牌库/去重库两页加公司列(Task 9)反向执行,顺带把一期已上线的展示也收掉。 建号归属改为请求体不带 company_id,由后端 resolveTargetCompanyId 落操作者自己的公司。 这条前端删下拉的安全依据完全靠后端那两条分支撑着,所以用跨仓读 Java 源码的方式钉成可执行断言: 谁把那边改成"必填公司"或删掉任一分支,这边立刻红。 副作用要说清——超管建的号一律归公司 1,给第 2 家建号得用那家公司自己的管理员登录。 「公司管理」页的引导语原写"建号时选哪家公司",下拉没了就成了错的承诺; "停用后不能再用于新建账号"也不再成立(requireActive 两个调用点都要求显式传 company_id, 而页面现在一律不传)。文案改成真实口径,并断言这三句失效说法不得回流。 1683 例 / 0 红,vue-tsc 干净,变异 6/6 被杀。
This commit is contained in:
@@ -8,9 +8,6 @@ import type { AdminUser } from '@/types/admin'
|
||||
import { roleLabel } from '@/types/admin'
|
||||
import { useAdminSessionStore } from '@/stores/admin-session'
|
||||
import { deleteUser, fetchUserList } from '@/api/users'
|
||||
import { fetchCompanies } from '@/api/companies'
|
||||
import type { CompanyItem } from '@/api/companies-dto'
|
||||
import type { CreateOperatorScope } from './user-create-model'
|
||||
import { createUserFilterState, toUserListParams, type UserFilterState } from './users-filter'
|
||||
import { totalPageCount } from './user-pagination'
|
||||
import { deleteBlockReason, deleteConfirmMessage } from './user-delete-model'
|
||||
@@ -27,12 +24,6 @@ const rows = ref<AdminUser[]>([])
|
||||
const total = ref(0)
|
||||
/** 所属管理员候选(来自列表响应的 admins),供超管筛选下拉使用。 */
|
||||
const admins = ref<Array<{ id: number; username: string }>>([])
|
||||
/** 公司目录(GET /api/admin/companies):后端已按操作者收窄,前端不再自己判权限。 */
|
||||
const companies = ref<CompanyItem[]>([])
|
||||
const operatorScope = computed<CreateOperatorScope>(() => ({
|
||||
role: session.user?.role,
|
||||
companyId: session.user?.companyId ?? null,
|
||||
}))
|
||||
const filters = reactive<UserFilterState>(createUserFilterState())
|
||||
const isSuperAdmin = computed(() => session.isSuperAdmin)
|
||||
const currentUserId = computed(() => session.user?.id ?? null)
|
||||
@@ -87,18 +78,6 @@ function retry() {
|
||||
void loadUsers()
|
||||
}
|
||||
|
||||
/**
|
||||
* 公司目录只服务下拉,不参与表格状态机:拉失败时列表照常显示,
|
||||
* 但超管建号会卡在"请选择所属公司"——所以要把原因说出来,别让人对着空下拉猜。
|
||||
*/
|
||||
async function loadCompanies() {
|
||||
try {
|
||||
companies.value = await fetchCompanies()
|
||||
} catch (error) {
|
||||
ElMessage.warning(error instanceof Error ? error.message : '公司目录加载失败')
|
||||
}
|
||||
}
|
||||
|
||||
/** 提交新筛选条件:重置回第一页再查询。 */
|
||||
function search() {
|
||||
filters.page = 1
|
||||
@@ -143,7 +122,6 @@ function goJump() {
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
void loadCompanies()
|
||||
void loadUsers()
|
||||
})
|
||||
</script>
|
||||
@@ -162,12 +140,6 @@ onMounted(() => {
|
||||
<label>用户名(模糊搜索)</label>
|
||||
<input v-model="filters.keyword" type="text" placeholder="输入用户名关键字" @keyup.enter="search" />
|
||||
</div>
|
||||
<div v-if="isSuperAdmin" class="form-group" style="min-width: 160px">
|
||||
<label>所属公司</label>
|
||||
<el-select v-model="filters.companyId" class="admin-filter" filterable clearable placeholder="全部公司" @change="search">
|
||||
<el-option v-for="company in companies" :key="company.id" :label="company.companyName" :value="company.id" />
|
||||
</el-select>
|
||||
</div>
|
||||
<div v-if="isSuperAdmin" class="form-group" style="min-width: 160px">
|
||||
<label>所属管理员</label>
|
||||
<el-select v-model="filters.createdByAdminId" class="admin-filter" filterable clearable placeholder="全部" @change="search">
|
||||
@@ -197,7 +169,6 @@ onMounted(() => {
|
||||
<th style="width: 70px">ID</th>
|
||||
<th style="width: 180px">用户名</th>
|
||||
<th style="width: 140px">角色</th>
|
||||
<th style="width: 140px">所属公司</th>
|
||||
<th style="width: 160px">所属管理员</th>
|
||||
<th style="width: 180px">创建时间</th>
|
||||
<th style="width: 180px">更新时间</th>
|
||||
@@ -210,7 +181,6 @@ onMounted(() => {
|
||||
<td>{{ row.id }}</td>
|
||||
<td>{{ row.username }}</td>
|
||||
<td>{{ roleLabel(row.role) }}</td>
|
||||
<td>{{ row.companyName || '-' }}</td>
|
||||
<td>{{ row.creatorUsername || '-' }}</td>
|
||||
<td>{{ formatDateTime(row.createdAt) }}</td>
|
||||
<td>{{ formatDateTime(row.updatedAt) }}</td>
|
||||
@@ -237,10 +207,10 @@ onMounted(() => {
|
||||
</tr>
|
||||
</template>
|
||||
<tr v-else-if="loading">
|
||||
<td colspan="8" class="empty-tip">加载中...</td>
|
||||
<td colspan="7" class="empty-tip">加载中...</td>
|
||||
</tr>
|
||||
<tr v-else>
|
||||
<td colspan="8" class="empty-tip">{{ userListEmptyHint() }}</td>
|
||||
<td colspan="7" class="empty-tip">{{ userListEmptyHint() }}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
@@ -253,8 +223,6 @@ onMounted(() => {
|
||||
v-model="createVisible"
|
||||
:operator-super="isSuperAdmin"
|
||||
:admin-options="admins"
|
||||
:companies="companies"
|
||||
:operator="operatorScope"
|
||||
@created="loadUsers"
|
||||
/>
|
||||
<EditUserDialog v-model="editVisible" :user="editUser" :operator-super="isSuperAdmin" @updated="loadUsers" />
|
||||
|
||||
Reference in New Issue
Block a user