授权逻辑更改

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,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>