门禁授权操作优化

This commit is contained in:
15683799673 2025-07-01 08:44:21 +08:00
parent d24d03457a
commit bef5cc55e9
5 changed files with 37 additions and 20 deletions

View File

@ -51,5 +51,6 @@ export interface TreeNode<T = any> {
title?: string;
key?:any
disabled: boolean
}

View File

@ -39,7 +39,7 @@ export function authRecordInfo(id: ID) {
* @returns void
*/
export function authRecordAdd(data: AuthRecordForm) {
return requestClient.postWithMsg<void>('/sis/authRecord', data);
return requestClient.postWithMsg<void>('/sis/authRecord/add', data);
}
/**

View File

@ -1,4 +1,4 @@
import type { PageQuery, BaseEntity } from '#/api/common';
import type { BaseEntity, PageQuery } from '#/api/common';
export interface AuthRecordVO {
/**
@ -15,25 +15,25 @@ export interface AuthRecordVO {
* id
*/
acdId: string | number;
}
export interface AuthRecordForm extends BaseEntity {
/**
* id
*/
id?: string | number;
libId?: string | number;
/**
* id
*/
imgId?: string | number;
imgIds?: string[] | number[];
/**
* id
*/
acdId?: string | number;
acIds?: string[] | number[];
issue: boolean;
}
export interface AuthRecordQuery extends PageQuery {
@ -48,7 +48,7 @@ export interface AuthRecordQuery extends PageQuery {
acdId?: string | number;
/**
*
*/
*
*/
params?: any;
}

View File

@ -5,11 +5,12 @@ import { useVbenModal } from '@vben/common-ui';
import { useBeforeCloseDiff } from '#/utils/popup';
import { Switch, Transfer, Tree } from 'ant-design-vue';
import { queryTree } from '#/api/sis/accessControl';
import { authRecordAdd } from '#/api/sis/authRecord';
import type { TreeNode } from '#/api/common';
import type { AuthRecordForm } from '#/api/sis/authRecord/model';
const emit = defineEmits<{ reload: [] }>();
const title = ref('门禁授权');
const { onBeforeClose } = useBeforeCloseDiff({});
const [BasicModal, modalApi] = useVbenModal({
@ -19,20 +20,29 @@ const [BasicModal, modalApi] = useVbenModal({
onBeforeClose,
onClosed: handleClosed,
onConfirm: handleConfirm,
onOpenChange: async (isOpen) => {
if (!isOpen) {
checked.value = false;
targetKeys.value = []
}
}
});
async function handleConfirm() {
try {
modalApi.lock(true);
/*const { valid } = await formApi.validate();
if (!valid) {
return;
}
const data = cloneDeep(await formApi.getValues());
await (isUpdate.value ? personLibImgUpdate(data) : personLibImgAdd(data));*/
// resetInitialized();
const { ids, libId } = modalApi.getData() as {
ids?: number[] | string[];
libId: number | string;
};
const params: AuthRecordForm = {
libId,
imgIds: ids,
acIds: targetKeys.value,
issue: checked.value
};
const res = await authRecordAdd(params);
console.log(res);
emit('reload');
modalApi.close();
} catch (error) {
@ -60,6 +70,10 @@ function handleTreeData(treeData: TreeNode[] | any[], datasource: TreeNode[]) {
treeData.forEach((item) => {
item.title = item.label;
item.key = item.code;
//
if (item.level != 5) {
item.disabled = true;
}
datasource.push(item);
if (item.children) {
handleTreeData(item.children, datasource);
@ -102,7 +116,7 @@ function isChecked(
<div class="p-4">
<Transfer
v-model:target-keys="targetKeys"
class="tree-transfer h-[400px]"
class="tree-transfer h-[400px] overflow-auto"
:data-source="dataSource"
:render="(item) => item.title"
>

View File

@ -129,7 +129,9 @@ function handleDownloadExcel() {
* 对图像进行门禁授权
*/
function accessControlAuth() {
authModalApi.setData({});
const rows = tableApi.grid.getCheckboxRecords();
const ids = rows.map((row: Required<PersonLibImgForm>) => row.id);
authModalApi.setData({ ids, libId: rows[0].libId });
authModalApi.open();
}
</script>