授权逻辑更改

This commit is contained in:
15683799673 2025-07-11 07:36:51 +08:00
parent 332d8eccba
commit 195d7fff7d
24 changed files with 242 additions and 1642 deletions

View File

@ -1,78 +0,0 @@
import type {
AccessControlDeviceForm,
AccessControlDeviceQuery,
AccessControlDeviceVO,
} from './model';
import type { ID, IDS, PageResult } from '#/api/common';
import { commonExport } from '#/api/helper';
import { requestClient } from '#/api/request';
/**
*
* @param params
* @returns
*/
export function accessControlDeviceList(params?: AccessControlDeviceQuery) {
return requestClient.get<PageResult<AccessControlDeviceVO>>(
'/sis/accessControlDevice/list',
{ params },
);
}
/**
*
* @param params
* @returns
*/
export function queryListByFactoryNo(factory: string) {
return requestClient.get<AccessControlDeviceVO[]>(`/sis/accessControlDevice/list/${factory}`,);
}
/**
*
* @param params
* @returns
*/
export function accessControlDeviceExport(params?: AccessControlDeviceQuery) {
return commonExport('/sis/accessControlDevice/export', params ?? {});
}
/**
*
* @param id id
* @returns
*/
export function accessControlDeviceInfo(id: ID) {
return requestClient.get<AccessControlDeviceVO>(
`/sis/accessControlDevice/${id}`,
);
}
/**
*
* @param data
* @returns void
*/
export function accessControlDeviceAdd(data: AccessControlDeviceForm) {
return requestClient.postWithMsg<void>('/sis/accessControlDevice', data);
}
/**
*
* @param data
* @returns void
*/
export function accessControlDeviceUpdate(data: AccessControlDeviceForm) {
return requestClient.putWithMsg<void>('/sis/accessControlDevice', data);
}
/**
*
* @param id id
* @returns void
*/
export function accessControlDeviceRemove(id: ID | IDS) {
return requestClient.deleteWithMsg<void>(`/sis/accessControlDevice/${id}`);
}

View File

@ -1,202 +0,0 @@
import type { BaseEntity, PageQuery } from '#/api/common';
export interface AccessControlDeviceVO {
/**
* id
*/
id: number | string;
/**
*
*/
eqpNo: string;
/**
*
*/
eqpName: string;
/**
*
*/
factoryNo: string;
/**
*
*/
eqpType: number;
/**
* (1: 平台接入2:设备接入)
*/
accessType: number;
/**
* ip
*/
eqpIp: string;
/**
*
*/
eqpPort: number;
/**
*
*/
eqpAccount: string;
/**
*
*/
eqpPwd: string;
/**
* id
*/
createById: number | string;
/**
* id
*/
updateById: number | string;
/**
*
*/
searchValue: string;
}
export interface AccessControlDeviceForm extends BaseEntity {
/**
* id
*/
id?: number | string;
/**
*
*/
eqpNo?: string;
/**
*
*/
eqpName?: string;
/**
*
*/
factoryNo?: string;
/**
*
*/
eqpType?: number;
/**
* (1: 平台接入2:设备接入)
*/
accessType?: number;
/**
* ip
*/
eqpIp?: string;
/**
*
*/
eqpPort?: number;
/**
*
*/
eqpAccount?: string;
/**
*
*/
eqpPwd?: string;
/**
* id
*/
createById?: number | string;
/**
* id
*/
updateById?: number | string;
/**
*
*/
searchValue?: string;
}
export interface AccessControlDeviceQuery extends PageQuery {
/**
*
*/
eqpNo?: string;
/**
*
*/
eqpName?: string;
/**
*
*/
factoryNo?: string;
/**
*
*/
eqpType?: number;
/**
* (1: 平台接入2:设备接入)
*/
accessType?: number;
/**
* ip
*/
eqpIp?: string;
/**
*
*/
eqpPort?: number;
/**
*
*/
eqpAccount?: string;
/**
*
*/
eqpPwd?: string;
/**
* id
*/
createById?: number | string;
/**
* id
*/
updateById?: number | string;
/**
*
*/
searchValue?: string;
/**
*
*/
params?: any;
}

View File

@ -1,18 +1,19 @@
import type { AuthRecordVO, AuthRecordForm, AuthRecordQuery } from './model';
import type { AuthRecordForm, AuthRecordQuery, AuthRecordVO } from './model';
import type { ID, IDS } from '#/api/common';
import type { PageResult } from '#/api/common';
import type { ID, IDS, PageResult } from '#/api/common';
import { commonExport } from '#/api/helper';
import { requestClient } from '#/api/request';
/**
*
* @param params
* @returns
*/
*
* @param params
* @returns
*/
export function authRecordList(params?: AuthRecordQuery) {
return requestClient.get<PageResult<AuthRecordVO>>('/sis/authRecord/list', { params });
return requestClient.get<PageResult<AuthRecordVO>>('/sis/authRecord/list', {
params,
});
}
/**
@ -59,3 +60,15 @@ export function authRecordUpdate(data: AuthRecordForm) {
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}`);
}

View File

@ -15,6 +15,8 @@ export interface AuthRecordVO {
* id
*/
acdId: string | number;
deviceId: string | number;
}
export interface AuthRecordForm extends BaseEntity {

View File

@ -1,18 +1,24 @@
import type { DeviceManageVO, DeviceManageForm, DeviceManageQuery } from './model';
import type {
DeviceManageForm,
DeviceManageQuery,
DeviceManageVO,
} from './model';
import type { ID, IDS } from '#/api/common';
import type { PageResult } from '#/api/common';
import type { ID, IDS, PageResult, TreeNode } from '#/api/common';
import { commonExport } from '#/api/helper';
import { requestClient } from '#/api/request';
/**
*
* @param params
* @returns
*/
*
* @param params
* @returns
*/
export function deviceManageList(params?: DeviceManageQuery) {
return requestClient.get<PageResult<DeviceManageVO>>('/sis/deviceManage/list', { params });
return requestClient.get<PageResult<DeviceManageVO>>(
'/sis/deviceManage/list',
{ params },
);
}
/**
@ -59,3 +65,11 @@ export function deviceManageUpdate(data: DeviceManageForm) {
export function deviceManageRemove(id: ID | IDS) {
return requestClient.deleteWithMsg<void>(`/sis/deviceManage/${id}`);
}
/**
*
* @returns void
*/
export function queryTree() {
return requestClient.get<TreeNode<Number>[]>(`/sis/deviceManage/tree`);
}

View File

@ -1,62 +0,0 @@
import type { DevicePointForm, DevicePointQuery, DevicePointVO } from './model';
import type { ID, IDS, PageResult } from '#/api/common';
import { commonExport } from '#/api/helper';
import { requestClient } from '#/api/request';
/**
* ()
* @param params
* @returns ()
*/
export function devicePointList(params?: DevicePointQuery) {
return requestClient.get<PageResult<DevicePointVO>>('/sis/devicePoint/list', {
params,
});
}
/**
* ()
* @param params
* @returns ()
*/
export function devicePointExport(params?: DevicePointQuery) {
return commonExport('/sis/devicePoint/export', params ?? {});
}
/**
* ()
* @param id id
* @returns ()
*/
export function devicePointInfo(id: ID) {
return requestClient.get<DevicePointVO>(`/sis/devicePoint/${id}`);
}
/**
* ()
* @param data
* @returns void
*/
export function devicePointAdd(data: DevicePointForm) {
return requestClient.postWithMsg<void>('/sis/devicePoint', data);
}
/**
* ()
* @param data
* @returns void
*/
export function devicePointUpdate(data: DevicePointForm) {
return requestClient.putWithMsg<void>('/sis/devicePoint', data);
}
/**
* ()
* @param id id
* @returns void
*/
export function devicePointRemove(id: ID | IDS) {
return requestClient.deleteWithMsg<void>(`/sis/devicePoint/${id}`);
}

View File

@ -1,259 +0,0 @@
import type { BaseEntity, PageQuery } from '#/api/common';
export interface DevicePointVO {
/**
* id
*/
id: number | string;
/**
*
*/
eqpCode: string;
/**
* 1onvif 2
rtsp
*/
video: number | string;
/**
* (AIBOX
) 1: tcp 2:
udp
*/
transportType: number;
/**
*
*/
channelName: string;
/**
* rtsp
rtsp
*/
rtspAddr: string;
/**
*
*/
ip: string;
/**
*
*/
port: number;
/**
*
*/
username: string;
/**
*
*/
pwd: string;
/**
* onvif
1 2
*/
videoType: number | string;
/**
* id
id
*/
videoId: number | string;
/**
* id
*/
createById: number | string;
/**
* id
*/
updateById: number | string;
/**
*
*/
searchValue: string;
}
export interface DevicePointForm extends BaseEntity {
/**
* id
*/
id?: number | string;
/**
*
*/
eqpCode?: string;
/**
* 1onvif 2
rtsp
*/
video?: number | string;
/**
* (AIBOX
) 1: tcp 2:
udp
*/
transportType?: number;
/**
*
*/
channelName?: string;
/**
* rtsp
rtsp
*/
rtspAddr?: string;
/**
*
*/
ip?: string;
/**
*
*/
port?: number;
/**
*
*/
username?: string;
/**
*
*/
pwd?: string;
/**
* onvif
1 2
*/
videoType?: number | string;
/**
* id
id
*/
videoId?: number | string;
/**
* id
*/
createById?: number | string;
/**
* id
*/
updateById?: number | string;
/**
*
*/
searchValue?: string;
}
export interface DevicePointQuery extends PageQuery {
/**
*
*/
eqpCode?: string;
/**
* 1onvif 2
rtsp
*/
video?: number | string;
/**
* (AIBOX
) 1: tcp 2:
udp
*/
transportType?: number;
/**
*
*/
channelName?: string;
/**
* rtsp
rtsp
*/
rtspAddr?: string;
/**
*
*/
ip?: string;
/**
*
*/
port?: number;
/**
*
*/
username?: string;
/**
*
*/
pwd?: string;
/**
* onvif
1 2
*/
videoType?: number | string;
/**
* id
id
*/
videoId?: number | string;
/**
* id
*/
createById?: number | string;
/**
* id
*/
updateById?: number | string;
/**
*
*/
searchValue?: string;
/**
*
*/
params?: any;
}

View File

@ -27,7 +27,7 @@ const [BasicForm, formApi] = useVbenForm({
//
formItemClass: 'col-span-1',
// label px
labelWidth: 80,
labelWidth: 120,
//
componentProps: {
class: 'w-full',

View File

@ -143,9 +143,10 @@ export const modalSchema: FormSchemaGetter = () => [
},
{
label: '绑定设备',
fieldName: 'bindDeviceIp',
fieldName: 'bindDeviceId',
component: 'ApiSelect',
componentProps: {
allowClear: true,
resultField: 'list', // 根据API返回结构调整
labelField: 'deviceName',
valueField: 'id',

View File

@ -1,106 +0,0 @@
<script setup lang="ts">
import { computed, ref } from 'vue';
import { useVbenModal } from '@vben/common-ui';
import { $t } from '@vben/locales';
import { cloneDeep } from '@vben/utils';
import { useVbenForm } from '#/adapter/form';
import {
accessControlDeviceAdd,
accessControlDeviceInfo,
accessControlDeviceUpdate,
} from '#/api/sis/accessControlDevice';
import { defaultFormValueGetter, useBeforeCloseDiff } from '#/utils/popup';
import { modalSchema } from './data';
const emit = defineEmits<{ reload: [] }>();
const isUpdate = ref(false);
const title = computed(() => {
return isUpdate.value ? $t('pages.common.edit') : $t('pages.common.add');
});
const [BasicForm, formApi] = useVbenForm({
commonConfig: {
//
formItemClass: 'col-span-1',
// label px
labelWidth: 80,
//
componentProps: {
class: 'w-full',
},
},
schema: modalSchema(),
showDefaultActions: false,
wrapperClass: 'grid-cols-2',
});
const { onBeforeClose, markInitialized, resetInitialized } = useBeforeCloseDiff(
{
initializedGetter: defaultFormValueGetter(formApi),
currentGetter: defaultFormValueGetter(formApi),
},
);
const [BasicModal, modalApi] = useVbenModal({
//
class: 'w-[60%]',
fullscreenButton: false,
onBeforeClose,
onClosed: handleClosed,
onConfirm: handleConfirm,
onOpenChange: async (isOpen) => {
if (!isOpen) {
return null;
}
modalApi.modalLoading(true);
const { id } = modalApi.getData() as { id?: number | string };
isUpdate.value = !!id;
if (isUpdate.value && id) {
const record = await accessControlDeviceInfo(id);
await formApi.setValues(record);
}
await markInitialized();
modalApi.modalLoading(false);
},
});
async function handleConfirm() {
try {
modalApi.lock(true);
const { valid } = await formApi.validate();
if (!valid) {
return;
}
// getValuesreadonly
const data = cloneDeep(await formApi.getValues());
await (isUpdate.value
? accessControlDeviceUpdate(data)
: accessControlDeviceAdd(data));
resetInitialized();
emit('reload');
modalApi.close();
} catch (error) {
console.error(error);
} finally {
modalApi.lock(false);
}
}
async function handleClosed() {
await formApi.resetForm();
resetInitialized();
}
</script>
<template>
<BasicModal :title="title">
<BasicForm />
</BasicModal>
</template>

View File

@ -1,117 +0,0 @@
import type { FormSchemaGetter } from '#/adapter/form';
import type { VxeGridProps } from '#/adapter/vxe-table';
import { DictEnum } from '@vben/constants';
import { getPopupContainer } from '@vben/utils';
import { getDictOptions } from '#/utils/dict';
export const querySchema: FormSchemaGetter = () => [
{
component: 'Input',
fieldName: 'eqpName',
label: '设备名称',
},
{
component: 'Select',
componentProps: {
getPopupContainer,
options: getDictOptions(DictEnum.SIS_ACCESS_CONTROL_DEVICE_TYPE),
},
fieldName: 'factoryNo',
label: '设备厂商',
},
];
// 需要使用i18n注意这里要改成getter形式 否则切换语言不会刷新
// export const columns: () => VxeGridProps['columns'] = () => [
export const columns: VxeGridProps['columns'] = [
{ type: 'checkbox', width: 60 },
{
title: '设备编码',
field: 'eqpNo',
},
{
title: '设备名称',
field: 'eqpName',
},
{
title: '设备厂商',
field: 'factoryName',
},
{
title: '设备ip',
field: 'eqpIp',
},
{
title: '设备端口',
field: 'eqpPort',
},
{
title: '设备账号',
field: 'eqpAccount',
},
{
title: '设备密码',
field: 'eqpPwd',
},
{
field: 'action',
fixed: 'right',
slots: { default: 'action' },
title: '操作',
width: 180,
},
];
export const modalSchema: FormSchemaGetter = () => [
{
label: '主键',
fieldName: 'id',
component: 'Input',
dependencies: {
show: () => false,
triggerFields: [''],
},
},
{
label: '设备名称',
fieldName: 'eqpName',
component: 'Input',
rules: 'required',
},
{
label: '设备厂商',
fieldName: 'factoryNo',
component: 'Select',
componentProps: {
getPopupContainer,
options: getDictOptions(DictEnum.SIS_ACCESS_CONTROL_DEVICE_TYPE),
},
},
{
label: '设备ip',
fieldName: 'eqpIp',
component: 'Input',
rules: 'required',
},
{
label: '设备端口',
fieldName: 'eqpPort',
component: 'Input',
rules: 'required',
},
{
label: '设备账号',
fieldName: 'eqpAccount',
component: 'Input',
rules: 'required',
},
{
label: '设备密码',
fieldName: 'eqpPwd',
component: 'Input',
rules: 'required',
},
];

View File

@ -1,182 +0,0 @@
<script setup lang="ts">
import type { VbenFormProps } from '@vben/common-ui';
import type { VxeGridProps } from '#/adapter/vxe-table';
import type { AccessControlDeviceForm } from '#/api/sis/accessControlDevice/model';
import { Page, useVbenModal } from '@vben/common-ui';
import { getVxePopupContainer } from '@vben/utils';
import { Modal, Popconfirm, Space } from 'ant-design-vue';
import { useVbenVxeGrid, vxeCheckboxChecked } from '#/adapter/vxe-table';
import {
accessControlDeviceExport,
accessControlDeviceList,
accessControlDeviceRemove,
} from '#/api/sis/accessControlDevice';
import { commonDownloadExcel } from '#/utils/file/download';
import accessControlDeviceModal from './accessControlDevice-modal.vue';
import { columns, querySchema } from './data';
const formOptions: VbenFormProps = {
commonConfig: {
labelWidth: 80,
componentProps: {
allowClear: true,
},
},
schema: querySchema(),
wrapperClass: 'grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4',
// RangePicker /
//
// fieldMappingTime: [
// [
// 'createTime',
// ['params[beginTime]', 'params[endTime]'],
// ['YYYY-MM-DD 00:00:00', 'YYYY-MM-DD 23:59:59'],
// ],
// ],
};
const gridOptions: VxeGridProps = {
checkboxConfig: {
//
highlight: true,
//
reserve: true,
//
// trigger: 'row',
},
// 使i18ngetter
// columns: columns(),
columns,
height: 'auto',
keepSource: true,
pagerConfig: {},
proxyConfig: {
ajax: {
query: async ({ page }, formValues = {}) => {
return await accessControlDeviceList({
pageNum: page.currentPage,
pageSize: page.pageSize,
...formValues,
});
},
},
},
rowConfig: {
keyField: 'id',
},
//
id: 'sis-accessControlDevice-index',
};
const [BasicTable, tableApi] = useVbenVxeGrid({
formOptions,
gridOptions,
});
const [AccessControlDeviceModal, modalApi] = useVbenModal({
connectedComponent: accessControlDeviceModal,
});
function handleAdd() {
modalApi.setData({});
modalApi.open();
}
async function handleEdit(row: Required<AccessControlDeviceForm>) {
modalApi.setData({ id: row.id });
modalApi.open();
}
async function handleDelete(row: Required<AccessControlDeviceForm>) {
await accessControlDeviceRemove(row.id);
await tableApi.query();
}
function handleMultiDelete() {
const rows = tableApi.grid.getCheckboxRecords();
const ids = rows.map((row: Required<AccessControlDeviceForm>) => row.id);
Modal.confirm({
title: '提示',
okType: 'danger',
content: `确认删除选中的${ids.length}条记录吗?`,
onOk: async () => {
await accessControlDeviceRemove(ids);
await tableApi.query();
},
});
}
function handleDownloadExcel() {
commonDownloadExcel(
accessControlDeviceExport,
'门禁设备数据',
tableApi.formApi.form.values,
{
fieldMappingTime: formOptions.fieldMappingTime,
},
);
}
</script>
<template>
<Page :auto-content-height="true">
<BasicTable table-title="门禁设备列表">
<template #toolbar-tools>
<Space>
<a-button
v-access:code="['sis:accessControlDevice:export']"
@click="handleDownloadExcel"
>
{{ $t('pages.common.export') }}
</a-button>
<a-button
:disabled="!vxeCheckboxChecked(tableApi)"
danger
type="primary"
v-access:code="['sis:accessControlDevice:remove']"
@click="handleMultiDelete"
>
{{ $t('pages.common.delete') }}
</a-button>
<a-button
type="primary"
v-access:code="['sis:accessControlDevice:add']"
@click="handleAdd"
>
{{ $t('pages.common.add') }}
</a-button>
</Space>
</template>
<template #action="{ row }">
<Space>
<ghost-button
v-access:code="['sis:accessControlDevice:edit']"
@click.stop="handleEdit(row)"
>
{{ $t('pages.common.edit') }}
</ghost-button>
<Popconfirm
:get-popup-container="getVxePopupContainer"
placement="left"
title="确认删除?"
@confirm="handleDelete(row)"
>
<ghost-button
danger
v-access:code="['sis:accessControlDevice:remove']"
@click.stop=""
>
{{ $t('pages.common.delete') }}
</ghost-button>
</Popconfirm>
</Space>
</template>
</BasicTable>
<AccessControlDeviceModal @reload="tableApi.query()" />
</Page>
</template>

View File

@ -23,7 +23,7 @@ const [BasicForm, formApi] = useVbenForm({
//
formItemClass: 'col-span-1',
// label px
labelWidth: 80,
labelWidth: 120,
//
componentProps: {
class: 'w-full',

View File

@ -1,236 +0,0 @@
import type { FormSchemaGetter } from '#/adapter/form';
import type { VxeGridProps } from '#/adapter/vxe-table';
export const querySchema: FormSchemaGetter = () => [
{
component: 'Input',
fieldName: 'eqpCode',
label: '设备编码',
},
{
component: 'Input',
fieldName: 'video',
label: '视频协议',
},
{
component: 'Select',
componentProps: {},
fieldName: 'transportType',
label: '传输协议',
},
{
component: 'Input',
fieldName: 'channelName',
label: '点位名称',
},
{
component: 'Input',
fieldName: 'rtspAddr',
label: 'rtsp 地址',
},
{
component: 'Input',
fieldName: 'ip',
label: '点位名称',
},
{
component: 'Input',
fieldName: 'port',
label: '端口',
},
{
component: 'Input',
fieldName: 'username',
label: '通道相机账号',
},
{
component: 'Input',
fieldName: 'pwd',
label: '相机密码',
},
{
component: 'Select',
componentProps: {},
fieldName: 'videoType',
label: '码流',
},
{
component: 'Input',
fieldName: 'videoId',
label: '码流id',
},
{
component: 'Input',
fieldName: 'createById',
label: '创建人id',
},
{
component: 'Input',
fieldName: 'updateById',
label: '更新人id',
},
{
component: 'Input',
fieldName: 'searchValue',
label: '搜索值',
},
];
// 需要使用i18n注意这里要改成getter形式 否则切换语言不会刷新
// export const columns: () => VxeGridProps['columns'] = () => [
export const columns: VxeGridProps['columns'] = [
{ type: 'checkbox', width: 60 },
{
title: '主键id',
field: 'id',
},
{
title: '设备编码',
field: 'eqpCode',
},
{
title: '视频协议',
},
{
title: '传输协议',
field: 'transportType',
},
{
title: '点位名称',
field: 'channelName',
},
{
title: 'rtsp 地址',
field: 'rtspAddr',
},
{
title: '点位名称',
field: 'ip',
},
{
title: '端口',
field: 'port',
},
{
title: '通道相机账号',
field: 'username',
},
{
title: '相机密码',
field: 'pwd',
},
{
title: '设备码流',
field: 'videoType',
},
{
title: '码流id',
field: 'videoId',
},
{
title: '创建人id',
field: 'createById',
},
{
title: '更新人id',
field: 'updateById',
},
{
title: '搜索值',
field: 'searchValue',
},
{
field: 'action',
fixed: 'right',
slots: {
default: 'action',
},
title: '操作',
width: 180,
},
];
export const modalSchema: FormSchemaGetter = () => [
{
label: '主键id',
fieldName: 'id',
component: 'Input',
dependencies: {
show: () => false,
triggerFields: [''],
},
},
{
label: '设备编码',
fieldName: 'eqpCode',
component: 'Input',
rules: 'required',
},
{
label: '视频协议',
fieldName: 'video',
component: 'Input',
},
{
label: '传输协议',
fieldName: 'transportType',
component: 'Select',
componentProps: {},
},
{
label: '点位名称',
fieldName: 'channelName',
component: 'Input',
},
{
label: 'rtsp 地址',
fieldName: 'rtspAddr',
component: 'Input',
},
{
label: '点位名称',
fieldName: 'ip',
component: 'Input',
},
{
label: '端口',
fieldName: 'port',
component: 'Input',
},
{
label: '通道相机账号',
fieldName: 'username',
component: 'Input',
},
{
label: '相机密码',
fieldName: 'pwd',
component: 'Input',
},
{
label: '设备码流',
fieldName: 'videoType',
component: 'Select',
componentProps: {},
},
{
label: '码流id',
fieldName: 'videoId',
component: 'Input',
},
{
label: '创建人id',
fieldName: 'createById',
component: 'Input',
},
{
label: '更新人id',
fieldName: 'updateById',
component: 'Input',
},
{
label: '搜索值',
fieldName: 'searchValue',
component: 'Input',
},
];

View File

@ -1,104 +0,0 @@
<script setup lang="ts">
import { computed, ref } from 'vue';
import { useVbenModal } from '@vben/common-ui';
import { $t } from '@vben/locales';
import { cloneDeep } from '@vben/utils';
import { useVbenForm } from '#/adapter/form';
import {
devicePointAdd,
devicePointInfo,
devicePointUpdate,
} from '#/api/sis/devicePoint';
import { defaultFormValueGetter, useBeforeCloseDiff } from '#/utils/popup';
import { modalSchema } from './data';
const emit = defineEmits<{ reload: [] }>();
const isUpdate = ref(false);
const title = computed(() => {
return isUpdate.value ? $t('pages.common.edit') : $t('pages.common.add');
});
const [BasicForm, formApi] = useVbenForm({
commonConfig: {
//
formItemClass: 'col-span-2',
// label px
labelWidth: 80,
//
componentProps: {
class: 'w-full',
},
},
schema: modalSchema(),
showDefaultActions: false,
wrapperClass: 'grid-cols-2',
});
const { onBeforeClose, markInitialized, resetInitialized } = useBeforeCloseDiff(
{
initializedGetter: defaultFormValueGetter(formApi),
currentGetter: defaultFormValueGetter(formApi),
},
);
const [BasicModal, modalApi] = useVbenModal({
//
class: 'w-[550px]',
fullscreenButton: false,
onBeforeClose,
onClosed: handleClosed,
onConfirm: handleConfirm,
onOpenChange: async (isOpen) => {
if (!isOpen) {
return null;
}
modalApi.modalLoading(true);
const { id } = modalApi.getData() as { id?: number | string };
isUpdate.value = !!id;
if (isUpdate.value && id) {
const record = await devicePointInfo(id);
await formApi.setValues(record);
}
await markInitialized();
modalApi.modalLoading(false);
},
});
async function handleConfirm() {
try {
modalApi.lock(true);
const { valid } = await formApi.validate();
if (!valid) {
return;
}
// getValuesreadonly
const data = cloneDeep(await formApi.getValues());
await (isUpdate.value ? devicePointUpdate(data) : devicePointAdd(data));
resetInitialized();
emit('reload');
modalApi.close();
} catch (error) {
console.error(error);
} finally {
modalApi.lock(false);
}
}
async function handleClosed() {
await formApi.resetForm();
resetInitialized();
}
</script>
<template>
<BasicModal :title="title">
<BasicForm />
</BasicModal>
</template>

View File

@ -1,182 +0,0 @@
<script setup lang="ts">
import type { VbenFormProps } from '@vben/common-ui';
import type { VxeGridProps } from '#/adapter/vxe-table';
import type { DevicePointForm } from '#/api/sis/devicePoint/model';
import { Page, useVbenModal } from '@vben/common-ui';
import { getVxePopupContainer } from '@vben/utils';
import { Modal, Popconfirm, Space } from 'ant-design-vue';
import { useVbenVxeGrid, vxeCheckboxChecked } from '#/adapter/vxe-table';
import {
devicePointExport,
devicePointList,
devicePointRemove,
} from '#/api/sis/devicePoint';
import { commonDownloadExcel } from '#/utils/file/download';
import { columns, querySchema } from './data';
import devicePointModal from './devicePoint-modal.vue';
const formOptions: VbenFormProps = {
commonConfig: {
labelWidth: 80,
componentProps: {
allowClear: true,
},
},
schema: querySchema(),
wrapperClass: 'grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4',
// RangePicker /
//
// fieldMappingTime: [
// [
// 'createTime',
// ['params[beginTime]', 'params[endTime]'],
// ['YYYY-MM-DD 00:00:00', 'YYYY-MM-DD 23:59:59'],
// ],
// ],
};
const gridOptions: VxeGridProps = {
checkboxConfig: {
//
highlight: true,
//
reserve: true,
//
// trigger: 'row',
},
// 使i18ngetter
// columns: columns(),
columns,
height: 'auto',
keepSource: true,
pagerConfig: {},
proxyConfig: {
ajax: {
query: async ({ page }, formValues = {}) => {
return await devicePointList({
pageNum: page.currentPage,
pageSize: page.pageSize,
...formValues,
});
},
},
},
rowConfig: {
keyField: 'id',
},
//
id: 'sis-devicePoint-index',
};
const [BasicTable, tableApi] = useVbenVxeGrid({
formOptions,
gridOptions,
});
const [DevicePointModal, modalApi] = useVbenModal({
connectedComponent: devicePointModal,
});
function handleAdd() {
modalApi.setData({});
modalApi.open();
}
async function handleEdit(row: Required<DevicePointForm>) {
modalApi.setData({ id: row.id });
modalApi.open();
}
async function handleDelete(row: Required<DevicePointForm>) {
await devicePointRemove(row.id);
await tableApi.query();
}
function handleMultiDelete() {
const rows = tableApi.grid.getCheckboxRecords();
const ids = rows.map((row: Required<DevicePointForm>) => row.id);
Modal.confirm({
title: '提示',
okType: 'danger',
content: `确认删除选中的${ids.length}条记录吗?`,
onOk: async () => {
await devicePointRemove(ids);
await tableApi.query();
},
});
}
function handleDownloadExcel() {
commonDownloadExcel(
devicePointExport,
'宇视设备点位(通道)数据',
tableApi.formApi.form.values,
{
fieldMappingTime: formOptions.fieldMappingTime,
},
);
}
</script>
<template>
<Page :auto-content-height="true">
<BasicTable table-title="宇视设备点位(通道)列表">
<template #toolbar-tools>
<Space>
<a-button
v-access:code="['sis:devicePoint:export']"
@click="handleDownloadExcel"
>
{{ $t('pages.common.export') }}
</a-button>
<a-button
:disabled="!vxeCheckboxChecked(tableApi)"
danger
type="primary"
v-access:code="['sis:devicePoint:remove']"
@click="handleMultiDelete"
>
{{ $t('pages.common.delete') }}
</a-button>
<a-button
type="primary"
v-access:code="['sis:devicePoint:add']"
@click="handleAdd"
>
{{ $t('pages.common.add') }}
</a-button>
</Space>
</template>
<template #action="{ row }">
<Space>
<ghost-button
v-access:code="['sis:devicePoint:edit']"
@click.stop="handleEdit(row)"
>
{{ $t('pages.common.edit') }}
</ghost-button>
<Popconfirm
:get-popup-container="getVxePopupContainer"
placement="left"
title="确认删除?"
@confirm="handleDelete(row)"
>
<ghost-button
danger
v-access:code="['sis:devicePoint:remove']"
@click.stop=""
>
{{ $t('pages.common.delete') }}
</ghost-button>
</Popconfirm>
</Space>
</template>
</BasicTable>
<DevicePointModal @reload="tableApi.query()" />
</Page>
</template>

View File

@ -1,5 +1,7 @@
import type { FormSchemaGetter } from '#/adapter/form';
import type { VxeGridProps } from '#/adapter/vxe-table';
import type { DeviceManageQuery } from '#/api/sis/deviceManage/model';
import { deviceManageList } from '#/api/sis/deviceManage';
export const querySchema: FormSchemaGetter = () => [
{
@ -58,18 +60,6 @@ export const columns: VxeGridProps['columns'] = [
title: '维保公司',
field: 'maintenanceCompany',
},
/*{
title: '维保电话',
field: 'maintenancePhone',
},
{
title: '上次年检日期',
field: 'lastInspectionDate',
},
{
title: '下次年检日期',
field: 'nextInspectionDate',
},*/
{
title: '梯控厂商',
field: 'controlFactory',
@ -173,31 +163,6 @@ export const modalSchema: FormSchemaGetter = () => [
fieldName: 'maintenanceCompany',
component: 'Input',
},
/* {
label: '维保电话',
fieldName: 'maintenancePhone',
component: 'Input',
},
{
label: '上次年检日期',
fieldName: 'lastInspectionDate',
component: 'DatePicker',
componentProps: {
showTime: true,
format: 'YYYY-MM-DD HH:mm:ss',
valueFormat: 'YYYY-MM-DD HH:mm:ss',
},
},
{
label: '下次年检日期',
fieldName: 'nextInspectionDate',
component: 'DatePicker',
componentProps: {
showTime: true,
format: 'YYYY-MM-DD HH:mm:ss',
valueFormat: 'YYYY-MM-DD HH:mm:ss',
},
},*/
{
label: '梯控厂商',
fieldName: 'controlFactory',
@ -228,4 +193,18 @@ export const modalSchema: FormSchemaGetter = () => [
component: 'Input',
rules: 'required',
},
{
component: 'Select',
fieldName: 'remoteCallElevatorDeviceId',
defaultValue: undefined,
label: '呼梯摄像头',
},
{
component: 'Select',
fieldName: 'elevatorControlDeviceId',
defaultValue: undefined,
label: '梯控摄像头',
},
];

View File

@ -6,11 +6,17 @@ import { $t } from '@vben/locales';
import { cloneDeep, getPopupContainer, handleNode } from '@vben/utils';
import { useVbenForm } from '#/adapter/form';
import { elevatorInfoAdd, elevatorInfoInfo, elevatorInfoUpdate } from '#/api/sis/elevatorInfo';
import {
elevatorInfoAdd,
elevatorInfoInfo,
elevatorInfoUpdate,
} from '#/api/sis/elevatorInfo';
import { defaultFormValueGetter, useBeforeCloseDiff } from '#/utils/popup';
import { modalSchema } from './data';
import { communityTree } from '#/api/property/community';
import type { DeviceManageForm, DeviceManageQuery } from '#/api/sis/deviceManage/model';
import { deviceManageList } from '#/api/sis/deviceManage';
const emit = defineEmits<{ reload: [] }>();
@ -24,11 +30,11 @@ const [BasicForm, formApi] = useVbenForm({
//
formItemClass: 'col-span-1',
// label px
labelWidth: 100,
labelWidth: 200,
//
componentProps: {
class: 'w-full',
}
},
},
schema: modalSchema(),
showDefaultActions: false,
@ -54,7 +60,10 @@ const [BasicModal, modalApi] = useVbenModal({
return null;
}
modalApi.modalLoading(true);
setupCommunitySelect()
//
setupCommunitySelect();
//
loadDeviceList();
const { id } = modalApi.getData() as { id?: number | string };
isUpdate.value = !!id;
@ -88,6 +97,56 @@ async function handleConfirm() {
}
}
let rows: any = [];
async function loadDeviceList() {
if (rows.length === 0) {
const params: DeviceManageQuery = {
pageNum: 1,
pageSize: 500,
};
const res = await deviceManageList(params);
if (res && res.rows && res.rows.length > 0) {
rows = res.rows;
}
}
const arr = rows.map((item: DeviceManageForm) => {
return {
label: item.deviceName,
value: item.id,
deviceIp: item.deviceIp,
deviceId: item.id,
};
});
formApi.updateSchema([
{
componentProps: () => ({
options: arr,
mode: 'multiple', //
onChange: async (value: string, option: any) => {
const data = cloneDeep(await formApi.getValues());
data.remoteCallElevatorDeviceId = option;
formApi.setValues(data);
},
}),
fieldName: 'remoteCallElevatorDeviceId',
},
{
componentProps: () => ({
options: arr,
allowClear: true,
onChange: async (value: string, option: any) => {
const data = cloneDeep(await formApi.getValues());
data.elevatorControlDeviceId = option;
formApi.setValues(data);
},
}),
fieldName: 'elevatorControlDeviceId',
},
]);
}
/**
* 初始化城市
*/
@ -127,7 +186,6 @@ async function setupCommunitySelect() {
]);
}
async function handleClosed() {
await formApi.resetForm();
resetInitialized();
@ -139,4 +197,3 @@ async function handleClosed() {
<BasicForm />
</BasicModal>
</template>

View File

@ -1,12 +1,6 @@
import type { FormSchemaGetter } from '#/adapter/form';
import type { VxeGridProps } from '#/adapter/vxe-table';
import { DictEnum } from '@vben/constants';
import { getPopupContainer } from '@vben/utils';
import { queryListByFactoryNo } from '#/api/sis/accessControlDevice';
import { getDictOptions } from '#/utils/dict';
export const querySchema: FormSchemaGetter = () => [
{
component: 'Input',
@ -58,32 +52,8 @@ export const modalSchema: FormSchemaGetter = () => [
rules: 'required',
},
{
label: '人员库描述',
label: '描述',
fieldName: 'libDesc',
component: 'Input',
},
{
label: '库类型',
fieldName: 'libType',
component: 'Select',
componentProps: {
getPopupContainer,
options: getDictOptions(DictEnum.SIS_LIB_TYPE),
},
},
{
label: '设备',
fieldName: 'eqpIds',
component: 'ApiSelect',
rules: 'required',
componentProps: {
mode: 'multiple', // 关键属性,启用多选模式
resultField: 'list', // 根据API返回结构调整
labelField: 'eqpName',
valueField: 'id',
api: async () => {
return await queryListByFactoryNo('2');
},
},
},
];

View File

@ -1,15 +1,13 @@
<script setup lang="ts">
import type { VbenFormProps } from '@vben/common-ui';
import { Page, useVbenModal } from '@vben/common-ui';
import type { VxeGridProps } from '#/adapter/vxe-table';
import { useVbenVxeGrid, vxeCheckboxChecked } from '#/adapter/vxe-table';
import type { PersonLibForm } from '#/api/sis/personLib/model';
import { Page, useVbenModal } from '@vben/common-ui';
import { getVxePopupContainer } from '@vben/utils';
import { Modal, Popconfirm, Space, Tag } from 'ant-design-vue';
import { useVbenVxeGrid, vxeCheckboxChecked } from '#/adapter/vxe-table';
import {
personLibExport,
personLibList,
@ -19,6 +17,7 @@ import { commonDownloadExcel } from '#/utils/file/download';
import { columns, querySchema } from './data';
import personLibModal from './personLib-modal.vue';
import libAuthModal from '#/views/sis/personLib/libAuth-modal.vue';
const formOptions: VbenFormProps = {
commonConfig: {
@ -82,6 +81,10 @@ const [PersonLibModal, modalApi] = useVbenModal({
connectedComponent: personLibModal,
});
const [LibAuthModal, libAuthModalApi] = useVbenModal({
connectedComponent: libAuthModal,
});
function handleAdd() {
modalApi.setData({});
modalApi.open();
@ -121,6 +124,11 @@ function handleDownloadExcel() {
},
);
}
function handleAuth(row: Required<PersonLibForm>) {
libAuthModalApi.setData({ id: row.id });
libAuthModalApi.open();
}
</script>
<template>
@ -154,6 +162,8 @@ function handleDownloadExcel() {
</template>
<template #action="{ row }">
<Space>
<ghost-button @click.stop="handleAuth(row)"> 授权</ghost-button>
<ghost-button
v-access:code="['sis:personLib:edit']"
@click.stop="handleEdit(row)"
@ -183,5 +193,6 @@ function handleDownloadExcel() {
</template>
</BasicTable>
<PersonLibModal @reload="tableApi.query()" />
<LibAuthModal @reload="tableApi.query()" />
</Page>
</template>

View File

@ -0,0 +1,95 @@
<script setup lang="ts">
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';
const emit = defineEmits<{ reload: [] }>();
const title = ref('门禁授权');
const { onBeforeClose } = useBeforeCloseDiff({});
const [BasicModal, modalApi] = useVbenModal({
//
class: 'w-[700px]',
fullscreenButton: false,
onBeforeClose,
onClosed: handleClosed,
onConfirm: handleConfirm,
onOpenChange: async (isOpen) => {
if (!isOpen) {
const { id } = modalApi.getData();
queryAuthDevice(id).then((res = []) => {
const arr: any[] = [];
res.forEach((item) => {
arr.push(item.deviceId);
checkedKeys.value = arr;
});
});
}
},
});
async function handleConfirm() {
try {
modalApi.lock(true);
const { id } = modalApi.getData();
const arr = checkedKeys.value;
if (!arr || arr.length == 0) {
message.error('请选择授权设备');
return;
}
const params = {
libId: id,
deviceIds: arr,
};
authPersonLib(params);
emit('reload');
modalApi.close();
} catch (error) {
console.error(error);
} finally {
modalApi.lock(false);
}
}
function handleClosed() {
// await formApi.resetForm();
// resetInitialized();
}
const checkedKeys = ref<any[]>([]);
const treeData = ref([]);
const fieldNames = {
title: 'label',
key: 'code',
children: 'children',
};
onMounted(() => {
loadDeviceTree();
});
function loadDeviceTree() {
queryTree().then((data: any) => {
treeData.value = data;
});
}
</script>
<template>
<BasicModal :title="title">
<div class="p-4">
<Tree
defaultExpandAll
:fieldNames="fieldNames"
v-model:checkedKeys="checkedKeys"
checkable
:tree-data="treeData"
>
</Tree>
</div>
</BasicModal>
</template>

View File

@ -7,7 +7,6 @@ import { getPopupContainer } from '@vben/utils';
import { getDictOptions } from '#/utils/dict';
import { personLibList } from '#/api/sis/personLib';
import type { PersonLibQuery, PersonLibVO } from '#/api/sis/personLib/model';
import { Tag } from 'ant-design-vue';
let libArr: PersonLibVO[] = [];
const labelText: VbenFormSchema = {
@ -16,7 +15,7 @@ const labelText: VbenFormSchema = {
component: 'ApiSelect',
componentProps: {
resultField: 'list', // 根据API返回结构调整
labelField: 'labelText',
labelField: 'libName',
valueField: 'id',
// immediate: true,
api: async () => {
@ -26,19 +25,6 @@ const labelText: VbenFormSchema = {
pageSize: 500,
};
const res = await personLibList(params);
res.rows.forEach((item) => {
let tag =
item.libType == 1 ? (
<Tag color="#108ee9"></Tag>
) : (
<Tag color="#2db7f5"></Tag>
);
item.labelText = (
<span>
{item.libName} {tag}
</span>
);
});
libArr = res.rows;
}
return libArr;

View File

@ -27,7 +27,7 @@ const [BasicForm, formApi] = useVbenForm({
//
formItemClass: 'col-span-1',
// label px
labelWidth: 80,
labelWidth: 100,
//
componentProps: {
class: 'w-full',

View File

@ -28,7 +28,7 @@ export default defineConfig(async () => {
rewrite: (path) => path.replace(/^\/api/, ''),
// mock代理目标地址
// target: 'http://192.168.43.169:8080',
target: 'http://192.168.110.207:8080',
target: 'http://127.0.0.1:8080',
// target: 'http://192.168.0.108:8080',
// target: 'http://192.168.0.106:8080',
// target: 'http://47.109.37.87:3010',