门禁授权操作优化

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; title?: string;
key?:any key?:any
disabled: boolean
} }

View File

@ -39,7 +39,7 @@ export function authRecordInfo(id: ID) {
* @returns void * @returns void
*/ */
export function authRecordAdd(data: AuthRecordForm) { 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 { export interface AuthRecordVO {
/** /**
@ -15,25 +15,25 @@ export interface AuthRecordVO {
* id * id
*/ */
acdId: string | number; acdId: string | number;
} }
export interface AuthRecordForm extends BaseEntity { export interface AuthRecordForm extends BaseEntity {
/** /**
* id * id
*/ */
id?: string | number; libId?: string | number;
/** /**
* id * id
*/ */
imgId?: string | number; imgIds?: string[] | number[];
/** /**
* id * id
*/ */
acdId?: string | number; acIds?: string[] | number[];
issue: boolean;
} }
export interface AuthRecordQuery extends PageQuery { export interface AuthRecordQuery extends PageQuery {

View File

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

View File

@ -129,7 +129,9 @@ function handleDownloadExcel() {
* 对图像进行门禁授权 * 对图像进行门禁授权
*/ */
function accessControlAuth() { 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(); authModalApi.open();
} }
</script> </script>