官方纰漏bug修复和安全能力提升

This commit is contained in:
Weiming committed 2026-12-02 14:12:35 +08:00
1 parent 459339719d
commit ce00640ea4
148 files changed
+9524 -1701

No files matched your search

+119 -56
View File
@@ -6,15 +6,26 @@
</div>
<div class="card fill-list-card primary-list-card" :class="{ 'panel-card': embedded }">
<div class="filter-bar">
<label v-if="canViewAll" class="filter-search">
<span aria-hidden="true">&#x1F50D;</span>
<input v-model="search" type="search" placeholder="搜索姓名、工号或金蝶账号" aria-label="搜索财务人员">
</label>
<span v-else class="filter-hint">当前权限:仅查看本人</span>
<span class="filter-spacer"></span>
<span class="tag info">{{ filtered.length }} 人</span>
<span class="tag" :class="boundCount ? 'success' : 'neutral'">已绑定 {{ boundCount }}</span>
<div class="filter-bar list-toolbar">
<div class="list-toolbar__filters">
<label v-if="canViewAll" class="filter-search">
<span aria-hidden="true">&#x1F50D;</span>
<input v-model="search" type="search" placeholder="搜索姓名或金蝶账号" aria-label="搜索财务人员">
</label>
<span v-else class="filter-hint">当前权限:仅查看本人</span>
</div>
<div class="list-toolbar__meta">
<button
v-if="canCreateBinding"
class="btn small primary"
type="button"
:disabled="loading || !addCandidates.length"
:title="addButtonTitle"
@click="openCreate"
>新增绑定</button>
<span class="tag info">{{ filtered.length }} 人</span>
<span v-if="uiRead('ui.kingdee.binding.column.status')" class="tag" :class="boundCount ? 'success' : 'neutral'">已绑定 {{ boundCount }}</span>
</div>
</div>
<div v-if="loading" class="load-wrap" role="status">
@@ -24,30 +35,26 @@
<table class="data-table responsive-table">
<thead>
<tr>
<th>财务人员</th>
<th>工号</th>
<th>金蝶账号</th>
<th>绑定状态</th>
<th v-if="uiRead('ui.kingdee.binding.column.employee')">财务人员</th>␍ <th v-if="uiRead('ui.kingdee.binding.column.username')">金蝶账号</th>
<th v-if="uiRead('ui.kingdee.binding.column.status')">绑定状态</th>
<th>操作</th>
</tr>
</thead>
<tbody>
<tr v-for="item in paginatedItems" :key="item.userId">
<td data-label="财务人员">
<tr v-for="item in paginatedItems" :key="item.employeeOpenId">
<td v-if="uiRead('ui.kingdee.binding.column.employee')" data-label="财务人员">
<strong>{{ item.realName }}</strong>
<small v-if="item.userId === meId" class="self-mark">本人</small>
</td>
<td data-label="工号"><small>{{ item.employeeNo || '—' }}</small></td>
<td data-label="金蝶账号"><small>{{ item.kingdeeUsername || '—' }}</small></td>
<td data-label="绑定状态">
<small v-if="item.employeeOpenId === meId" class="self-mark">本人</small>
</td>␍ <td v-if="uiRead('ui.kingdee.binding.column.username')" data-label="金蝶账号"><small>{{ item.kingdeeUsername || '—' }}</small></td>
<td v-if="uiRead('ui.kingdee.binding.column.status')" data-label="绑定状态">
<span class="tag" :class="item.bound ? 'success' : 'neutral'">{{ item.bound ? '已绑定' : '未绑定' }}</span>
</td>
<td data-label="操作" class="actions-cell">
<button v-if="canBindRow(item)" class="table-action" type="button" @click="openBind(item)">
{{ item.bound ? '重新绑定' : '绑定' }}
</button>
<button v-if="canBindRow(item) && item.bound" class="table-action" type="button" :disabled="testingId === item.userId" @click="testBinding(item)">
{{ testingId === item.userId ? '验证中…' : '验证' }}
<button v-if="canTestRow(item) && item.bound" class="table-action" type="button" :disabled="testingId === item.employeeOpenId" @click="testBinding(item)">
{{ testingId === item.employeeOpenId ? '验证中…' : '验证' }}
</button>
<button v-if="canUnbindRow(item) && item.bound" class="table-action danger-action" type="button" @click="unbind(item)">解绑</button>
</td>
@@ -68,35 +75,42 @@
/>
</div>
<dialog ref="bindDialog" v-dialog-drag class="app-dialog" aria-labelledby="kingdee-bind-title" @cancel.prevent="closeBind">
<dialog v-if="canOpenDialog" ref="bindDialog" v-dialog-drag class="app-dialog" aria-labelledby="kingdee-bind-title" @cancel.prevent="closeBind">
<form @submit.prevent="saveBind">
<div class="modal-head" data-dialog-drag-handle>
<div>
<span class="eyebrow">BIND KINGDEE ACCOUNT</span>
<h2 id="kingdee-bind-title">绑定金蝶账号 · {{ editing?.realName }}</h2>
<h2 id="kingdee-bind-title">{{ adding ? '新增金蝶账号绑定' : '绑定金蝶账号' }} · {{ activeBinding?.realName || '请选择人员' }}</h2>
<p>填写该人员在金蝶云星空的登录用户名与密码;保存前默认验证登录。</p>
</div>
<button class="modal-close" type="button" aria-label="关闭" :disabled="saving" @click="closeBind">×</button>
</div>
<div class="modal-body">
<div class="form-grid">
<div class="field">
<label for="kingdee-username">金蝶用户名 <em>*</em></label>
<input id="kingdee-username" v-model.trim="form.kingdeeUsername" required autocomplete="username" :disabled="saving">
<div v-if="adding" class="field full">
<label for="kingdee-binding-user">绑定人员 <em>*</em></label>
<select id="kingdee-binding-user" v-model="selectedEmployeeOpenId" class="select" required :disabled="saving">
<option :value="null" disabled>请选择未绑定人员</option>
<option v-for="item in addCandidates" :key="item.employeeOpenId" :value="item.employeeOpenId">{{ addCandidateLabel(item) }}</option>
</select>
</div>
<div class="field">
<div v-if="uiRead('dialog.kingdee.account.username')" class="field">
<label for="kingdee-username">金蝶用户名 <em>*</em></label>
<input id="kingdee-username" v-model.trim="form.kingdeeUsername" required autocomplete="username" :disabled="saving || !uiEdit('dialog.kingdee.account.username')">
</div>
<div v-if="uiRead('dialog.kingdee.account.password')" class="field">
<label for="kingdee-password">金蝶密码 <em>*</em></label>
<input id="kingdee-password" v-model="form.kingdeePassword" type="password" required autocomplete="new-password" :disabled="saving" :placeholder="editing?.bound ? '请重新输入密码' : '请输入金蝶密码'">
<input id="kingdee-password" v-model="form.kingdeePassword" type="password" required autocomplete="new-password" :disabled="saving || !uiEdit('dialog.kingdee.account.password')" :placeholder="editing?.bound ? '已安全保存;编辑时请重新输入' : '请输入金蝶密码'">
</div>
<label class="check-option full">
<input v-model="form.verifyLogin" type="checkbox" :disabled="saving">
<input v-model="form.verifyLogin" type="checkbox" :disabled="saving || !canEditCredentials">
<span>保存前验证金蝶登录</span>
</label>
</div>
</div>
<div class="modal-actions">
<button class="btn" type="button" :disabled="saving" @click="closeBind">取消</button>
<button class="btn primary" type="submit" :disabled="saving">{{ saving ? '保存中…' : '保存绑定' }}</button>
<button v-if="canEditCredentials" class="btn primary" type="submit" :disabled="saving">{{ saving ? '保存中…' : '保存绑定' }}</button>
</div>
</form>
</dialog>
@@ -105,35 +119,49 @@
<script setup lang="ts">
import { computed, nextTick, onMounted, reactive, ref } from 'vue'
import { ElMessage, ElMessageBox } from 'element-plus'
import { ElMessage, ElMessageBox } from '@/utils/uiFeedback'
import AppListPagination from '@/components/common/AppListPagination.vue'
import { matchesReadableSearch } from '@/authorization/searchProjection'
import { useListPagination } from '@/composables/useListPagination'
import { kingdeeAccountsApi, type KingdeeAccountBinding } from '@/api/kingdeeAccounts'
import { useAuthorizationStore } from '@/store/authorization'
import { useUserStore } from '@/store/user'
defineProps<{ embedded?: boolean }>()
const userStore = useUserStore()
const meId = computed(() => Number(userStore.userInfo?.id || 0) || null)
const canViewAll = computed(() => userStore.canRead('finance.kingdee.account.view-all'))
const canBindAll = computed(() => userStore.canEdit('finance.kingdee.account.bind'))
const canBindOwn = computed(() => userStore.canEdit('finance.kingdee.account.bind-own'))
const canUnbindAll = computed(() => userStore.canEdit('finance.kingdee.account.unbind'))
const canUnbindOwn = computed(() => userStore.canEdit('finance.kingdee.account.unbind-own'))
const authorizationStore = useAuthorizationStore()
const uiRead = (code: string) => userStore.canRead(code)
const uiEdit = (code: string) => userStore.canEdit(code)
const meId = computed(() => userStore.userInfo?.feishuOpenId || null)
const canViewAll = computed(() => userStore.canRead('finance.kingdee.account.view-all') && authorizationStore.can('integration.kingdee.account:read-all'))
const canViewOwn = computed(() => userStore.canRead('finance.kingdee.account.view-own') && authorizationStore.can('integration.kingdee.account:read-own'))
const canViewAny = computed(() => canViewAll.value || canViewOwn.value)
const canBindAll = computed(() => userStore.canEdit('finance.kingdee.account.bind') && authorizationStore.can('integration.kingdee.account:manage-all'))
const canBindOwn = computed(() => userStore.canEdit('finance.kingdee.account.bind-own') && authorizationStore.can('integration.kingdee.account:manage-own'))
const canUnbindAll = computed(() => userStore.canEdit('finance.kingdee.account.unbind') && authorizationStore.can('integration.kingdee.account:manage-all'))
const canUnbindOwn = computed(() => userStore.canEdit('finance.kingdee.account.unbind-own') && authorizationStore.can('integration.kingdee.account:manage-own'))
const canOpenDialog = computed(() => uiRead('dialog.kingdee.account'))
const canEditCredentials = computed(() => uiEdit('dialog.kingdee.account.username') && uiEdit('dialog.kingdee.account.password'))
const canCreateBinding = computed(() => canOpenDialog.value && canEditCredentials.value && (canBindAll.value || canBindOwn.value))
const canBindRow = (item: KingdeeAccountBinding) =>
canBindAll.value || (canBindOwn.value && item.userId === meId.value)
canOpenDialog.value && (canBindAll.value || (canBindOwn.value && item.employeeOpenId === meId.value))
const canUnbindRow = (item: KingdeeAccountBinding) =>
canUnbindAll.value || (canUnbindOwn.value && item.userId === meId.value)
canUnbindAll.value || (canUnbindOwn.value && item.employeeOpenId === meId.value)
const canTestRow = (item: KingdeeAccountBinding) =>
(item.employeeOpenId === meId.value ? uiEdit('dialog.kingdee.account.test-own') : uiEdit('dialog.kingdee.account.test-all')) && canBindRow(item)
const items = ref<KingdeeAccountBinding[]>([])
const loading = ref(false)
const loadError = ref('')
const search = ref('')
const saving = ref(false)
const testingId = ref<number | null>(null)
const testingId = ref<string | null>(null)
const bindDialog = ref<HTMLDialogElement | null>(null)
const editing = ref<KingdeeAccountBinding | null>(null)
const adding = ref(false)
const selectedEmployeeOpenId = ref<string | null>(null)
const form = reactive({ kingdeeUsername: '', kingdeePassword: '', verifyLogin: true })
const errorText = (error: unknown) => {
@@ -143,16 +171,32 @@ const errorText = (error: unknown) => {
}
const filtered = computed(() => {
const q = search.value.trim().toLowerCase()
if (!q) return items.value
return items.value.filter(item =>
[item.realName, item.employeeNo, item.kingdeeUsername]
.some(value => String(value || '').toLowerCase().includes(q)))
return items.value.filter(item => matchesReadableSearch(search.value, [
{ readable: uiRead('ui.kingdee.binding.column.employee'), values: [item.realName] },␍ { readable: uiRead('ui.kingdee.binding.column.username'), values: [item.kingdeeUsername] },
]))
})
const boundCount = computed(() => items.value.filter(item => item.bound).length)
const canReadEmployeeIdentity = computed(() => uiRead('ui.kingdee.binding.column.employee'))
const addCandidates = computed(() => items.value.filter(item =>
!item.bound && canBindRow(item) && (item.employeeOpenId === meId.value || canReadEmployeeIdentity.value),
))
const activeBinding = computed(() => adding.value
? addCandidates.value.find(item => item.employeeOpenId === selectedEmployeeOpenId.value) || null
: editing.value)
const addButtonTitle = computed(() => {
if (addCandidates.value.length) return '为未绑定人员新增金蝶账号绑定'
if (canBindAll.value && !canReadEmployeeIdentity.value && !canBindOwn.value) return '需要“财务人员”字段查看权限才能选择绑定人员'
return '当前没有可新增绑定的人员'
})
const addCandidateLabel = (item: KingdeeAccountBinding) => item.realName
const { page, pageSize, paginatedItems } = useListPagination(filtered, { resetSources: [search] })
const load = async () => {
if (!canViewAny.value) {
items.value = []
loadError.value = '当前账号没有金蝶账号绑定查看权限。'
return
}
loading.value = true
loadError.value = ''
try {
@@ -167,6 +211,8 @@ const load = async () => {
const openBind = async (item: KingdeeAccountBinding) => {
if (!canBindRow(item)) return
adding.value = false
selectedEmployeeOpenId.value = item.employeeOpenId
editing.value = item
form.kingdeeUsername = item.kingdeeUsername || ''
form.kingdeePassword = ''
@@ -175,38 +221,55 @@ const openBind = async (item: KingdeeAccountBinding) => {
bindDialog.value?.showModal()
}
const openCreate = async () => {
if (!canCreateBinding.value || !addCandidates.value.length) return
adding.value = true
editing.value = null
selectedEmployeeOpenId.value = addCandidates.value[0].employeeOpenId
form.kingdeeUsername = ''
form.kingdeePassword = ''
form.verifyLogin = true
await nextTick()
bindDialog.value?.showModal()
}
const closeBind = () => {
if (saving.value) return
bindDialog.value?.close()
adding.value = false
selectedEmployeeOpenId.value = null
editing.value = null
}
const saveBind = async () => {
if (!editing.value || !canBindRow(editing.value) || saving.value) return
const target = activeBinding.value
if (!target || !canBindRow(target) || !canEditCredentials.value || saving.value) return
saving.value = true
let savedSuccessfully = false
try {
const saved = await kingdeeAccountsApi.bind(editing.value.userId, {
const saved = await kingdeeAccountsApi.bind(target.employeeOpenId, {
kingdeeUsername: form.kingdeeUsername,
kingdeePassword: form.kingdeePassword,
verifyLogin: form.verifyLogin,
})
const index = items.value.findIndex(item => item.userId === saved.userId)
const index = items.value.findIndex(item => item.employeeOpenId === saved.employeeOpenId)
if (index >= 0) items.value[index] = saved
else items.value.push(saved)
savedSuccessfully = true
ElMessage.success('金蝶账号已绑定')
closeBind()
} catch (error) {
ElMessage.error(`绑定失败:${errorText(error)}`)
} finally {
saving.value = false
if (savedSuccessfully) closeBind()
}
}
const testBinding = async (item: KingdeeAccountBinding) => {
if (!canBindRow(item) || testingId.value != null) return
testingId.value = item.userId
if (!canTestRow(item) || testingId.value != null) return
testingId.value = item.employeeOpenId
try {
const result = await kingdeeAccountsApi.test(item.userId)
const result = await kingdeeAccountsApi.test(item.employeeOpenId)
if (result?.success) ElMessage.success(result.message || '验证成功')
else ElMessage.error(result?.message || '验证失败')
} catch (error) {
@@ -228,8 +291,8 @@ const unbind = async (item: KingdeeAccountBinding) => {
return
}
try {
await kingdeeAccountsApi.unbind(item.userId)
const index = items.value.findIndex(row => row.userId === item.userId)
await kingdeeAccountsApi.unbind(item.employeeOpenId)
const index = items.value.findIndex(row => row.employeeOpenId === item.employeeOpenId)
if (index >= 0) {
items.value[index] = {
...items.value[index],
@@ -246,7 +309,7 @@ const unbind = async (item: KingdeeAccountBinding) => {
}
}
onMounted(() => { void load() })
onMounted(() => { if (canViewAny.value) void load() })
defineExpose({ reload: load })
</script>
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.