refactor(sis): 重构人员库授权功能
This commit is contained in:
parent
3fe2ff30f8
commit
aad204ae85
@ -1,6 +1,6 @@
|
||||
import type { AuthRecordForm, AuthRecordQuery, AuthRecordVO } from './model';
|
||||
|
||||
import type { ID, IDS, PageResult } from '#/api/common';
|
||||
import type { ID, IDS, PageResult, TreeNode } from '#/api/common';
|
||||
|
||||
import { commonExport } from '#/api/helper';
|
||||
import { requestClient } from '#/api/request';
|
||||
@ -35,12 +35,12 @@ export function authRecordInfo(id: ID) {
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增授权记录
|
||||
* 新增授权记录(授权只针对人员库,不对单张照片进行授权)
|
||||
* @param data
|
||||
* @returns void
|
||||
*/
|
||||
export function authRecordAdd(data: AuthRecordForm) {
|
||||
return requestClient.postWithMsg<void>('/sis/authRecord/add', data);
|
||||
return requestClient.postWithMsg<void>('/sis/authRecord', data);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -61,14 +61,15 @@ export function authRecordRemove(id: ID | IDS) {
|
||||
return requestClient.deleteWithMsg<void>(`/sis/authRecord/${id}`);
|
||||
}
|
||||
|
||||
/**
|
||||
* 对人员库进行授权
|
||||
* @param params id
|
||||
*/
|
||||
export function authPersonLib(params: any) {
|
||||
return requestClient.postWithMsg<void>(`/sis/authRecord/authLib`, params);
|
||||
}
|
||||
|
||||
export function queryAuthDevice(id: ID) {
|
||||
return requestClient.get<AuthRecordVO[]>(`/sis/authRecord/authDevice/${id}`);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询所有可授权设备树
|
||||
* @returns void
|
||||
*/
|
||||
export function queryTree() {
|
||||
return requestClient.get<TreeNode<Number>[]>(`/sis/authRecord/authDevice/tree`);
|
||||
}
|
||||
|
11
apps/web-antd/src/api/sis/authRecord/model.d.ts
vendored
11
apps/web-antd/src/api/sis/authRecord/model.d.ts
vendored
@ -26,16 +26,9 @@ export interface AuthRecordForm extends BaseEntity {
|
||||
libId?: string | number;
|
||||
|
||||
/**
|
||||
* 人像id
|
||||
* 设备ids
|
||||
*/
|
||||
imgIds?: string[] | number[];
|
||||
|
||||
/**
|
||||
* 门禁id
|
||||
*/
|
||||
acIds?: string[] | number[];
|
||||
|
||||
issue: boolean;
|
||||
deviceIds?: string[] | number[];
|
||||
}
|
||||
|
||||
export interface AuthRecordQuery extends PageQuery {
|
||||
|
@ -4,8 +4,7 @@ import { onMounted, ref } from 'vue';
|
||||
import { useVbenModal } from '@vben/common-ui';
|
||||
import { useBeforeCloseDiff } from '#/utils/popup';
|
||||
import { message, Tree } from 'ant-design-vue';
|
||||
import { queryTree } from '#/api/sis/deviceManage';
|
||||
import { authPersonLib, queryAuthDevice } from '#/api/sis/authRecord';
|
||||
import { authRecordAdd, queryAuthDevice, queryTree } from '#/api/sis/authRecord';
|
||||
|
||||
const emit = defineEmits<{ reload: [] }>();
|
||||
const title = ref('门禁授权');
|
||||
@ -18,7 +17,7 @@ const [BasicModal, modalApi] = useVbenModal({
|
||||
onClosed: handleClosed,
|
||||
onConfirm: handleConfirm,
|
||||
onOpenChange: async (isOpen) => {
|
||||
if (!isOpen) {
|
||||
if (isOpen) {
|
||||
const { id } = modalApi.getData();
|
||||
queryAuthDevice(id).then((res = []) => {
|
||||
const arr: any[] = [];
|
||||
@ -27,6 +26,9 @@ const [BasicModal, modalApi] = useVbenModal({
|
||||
checkedKeys.value = arr;
|
||||
});
|
||||
});
|
||||
}else {
|
||||
// 关闭时清除选中
|
||||
checkedKeys.value = [];
|
||||
}
|
||||
},
|
||||
});
|
||||
@ -44,7 +46,7 @@ async function handleConfirm() {
|
||||
libId: id,
|
||||
deviceIds: arr,
|
||||
};
|
||||
authPersonLib(params);
|
||||
authRecordAdd(params);
|
||||
emit('reload');
|
||||
modalApi.close();
|
||||
} catch (error) {
|
||||
@ -83,11 +85,10 @@ function loadDeviceTree() {
|
||||
<BasicModal :title="title">
|
||||
<div class="p-4">
|
||||
<Tree
|
||||
defaultExpandAll
|
||||
:fieldNames="fieldNames"
|
||||
v-model:checkedKeys="checkedKeys"
|
||||
checkable
|
||||
:fieldNames="fieldNames"
|
||||
:tree-data="treeData"
|
||||
v-model:checkedKeys="checkedKeys"
|
||||
>
|
||||
</Tree>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user