Merge branch 'master' of http://47.109.37.87:3000/by2025/admin-vben5
Some checks are pending
Gitea Actions Demo / Explore-Gitea-Actions (push) Waiting to run
Some checks are pending
Gitea Actions Demo / Explore-Gitea-Actions (push) Waiting to run
This commit is contained in:
commit
28295b283e
@ -96,6 +96,17 @@ export interface ElevatorInfoVO {
|
|||||||
*/
|
*/
|
||||||
controlPwd: string
|
controlPwd: string
|
||||||
|
|
||||||
|
elevatorControlDeviceId: {
|
||||||
|
value: number,
|
||||||
|
deviceIp: string,
|
||||||
|
deviceId: number,
|
||||||
|
}
|
||||||
|
|
||||||
|
remoteCallElevatorDeviceId: {
|
||||||
|
value: number,
|
||||||
|
deviceIp: string,
|
||||||
|
deviceId: number,
|
||||||
|
}[]
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ElevatorInfoForm extends BaseEntity {
|
export interface ElevatorInfoForm extends BaseEntity {
|
||||||
@ -299,9 +310,9 @@ export interface ElevatorInfoQuery extends PageQuery {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface ElevatorFloorRefVo {
|
export interface ElevatorFloorRefVo {
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
elevatorId: string | number
|
elevatorId: string | number
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,29 +1,29 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { computed, ref } from 'vue';
|
import { computed, ref } from 'vue'
|
||||||
|
|
||||||
import { useVbenModal } from '@vben/common-ui';
|
import { useVbenModal } from '@vben/common-ui'
|
||||||
import { $t } from '@vben/locales';
|
import { $t } from '@vben/locales'
|
||||||
import { cloneDeep, getPopupContainer, handleNode } from '@vben/utils';
|
import { cloneDeep, getPopupContainer, handleNode } from '@vben/utils'
|
||||||
|
|
||||||
import { useVbenForm } from '#/adapter/form';
|
import { useVbenForm } from '#/adapter/form'
|
||||||
import {
|
import {
|
||||||
elevatorInfoAdd,
|
elevatorInfoAdd,
|
||||||
elevatorInfoInfo,
|
elevatorInfoInfo,
|
||||||
elevatorInfoUpdate,
|
elevatorInfoUpdate,
|
||||||
} from '#/api/sis/elevatorInfo';
|
} from '#/api/sis/elevatorInfo'
|
||||||
import { defaultFormValueGetter, useBeforeCloseDiff } from '#/utils/popup';
|
import { defaultFormValueGetter, useBeforeCloseDiff } from '#/utils/popup'
|
||||||
|
|
||||||
import { modalSchema } from './data';
|
import { modalSchema } from './data'
|
||||||
import { communityTree } from '#/api/property/community';
|
import { communityTree } from '#/api/property/community'
|
||||||
import type { DeviceManageForm, DeviceManageQuery } from '#/api/sis/deviceManage/model';
|
import type { DeviceManageForm, DeviceManageQuery } from '#/api/sis/deviceManage/model'
|
||||||
import { deviceManageList } from '#/api/sis/deviceManage';
|
import { deviceManageList } from '#/api/sis/deviceManage'
|
||||||
|
|
||||||
const emit = defineEmits<{ reload: [] }>();
|
const emit = defineEmits<{ reload: [] }>()
|
||||||
|
|
||||||
const isUpdate = ref(false);
|
const isUpdate = ref(false)
|
||||||
const title = computed(() => {
|
const title = computed(() => {
|
||||||
return isUpdate.value ? $t('pages.common.edit') : $t('pages.common.add');
|
return isUpdate.value ? $t('pages.common.edit') : $t('pages.common.add')
|
||||||
});
|
})
|
||||||
|
|
||||||
const [BasicForm, formApi] = useVbenForm({
|
const [BasicForm, formApi] = useVbenForm({
|
||||||
commonConfig: {
|
commonConfig: {
|
||||||
@ -39,14 +39,14 @@ const [BasicForm, formApi] = useVbenForm({
|
|||||||
schema: modalSchema(),
|
schema: modalSchema(),
|
||||||
showDefaultActions: false,
|
showDefaultActions: false,
|
||||||
wrapperClass: 'grid-cols-2',
|
wrapperClass: 'grid-cols-2',
|
||||||
});
|
})
|
||||||
|
|
||||||
const { onBeforeClose, markInitialized, resetInitialized } = useBeforeCloseDiff(
|
const { onBeforeClose, markInitialized, resetInitialized } = useBeforeCloseDiff(
|
||||||
{
|
{
|
||||||
initializedGetter: defaultFormValueGetter(formApi),
|
initializedGetter: defaultFormValueGetter(formApi),
|
||||||
currentGetter: defaultFormValueGetter(formApi),
|
currentGetter: defaultFormValueGetter(formApi),
|
||||||
},
|
},
|
||||||
);
|
)
|
||||||
|
|
||||||
const [BasicModal, modalApi] = useVbenModal({
|
const [BasicModal, modalApi] = useVbenModal({
|
||||||
// 在这里更改宽度
|
// 在这里更改宽度
|
||||||
@ -57,57 +57,70 @@ const [BasicModal, modalApi] = useVbenModal({
|
|||||||
onConfirm: handleConfirm,
|
onConfirm: handleConfirm,
|
||||||
onOpenChange: async (isOpen) => {
|
onOpenChange: async (isOpen) => {
|
||||||
if (!isOpen) {
|
if (!isOpen) {
|
||||||
return null;
|
return null
|
||||||
}
|
}
|
||||||
modalApi.modalLoading(true);
|
modalApi.modalLoading(true)
|
||||||
// 加载社区树
|
// 加载社区树
|
||||||
setupCommunitySelect();
|
setupCommunitySelect()
|
||||||
// 加载未绑定的设备
|
// 加载未绑定的设备
|
||||||
loadDeviceList();
|
loadDeviceList()
|
||||||
const { id } = modalApi.getData() as { id?: number | string };
|
const { id } = modalApi.getData() as { id?: number | string }
|
||||||
isUpdate.value = !!id;
|
isUpdate.value = !!id
|
||||||
|
|
||||||
if (isUpdate.value && id) {
|
if (isUpdate.value && id) {
|
||||||
const record = await elevatorInfoInfo(id);
|
const record = await elevatorInfoInfo(id)
|
||||||
await formApi.setValues(record);
|
record.elevatorControlDeviceId = {
|
||||||
}
|
value: record.elevatorControlDeviceId.deviceId,
|
||||||
await markInitialized();
|
deviceIp: record.elevatorControlDeviceId.deviceIp,
|
||||||
|
deviceId: record.elevatorControlDeviceId.deviceId,
|
||||||
|
}
|
||||||
|
|
||||||
modalApi.modalLoading(false);
|
record.remoteCallElevatorDeviceId = record.remoteCallElevatorDeviceId.map(item => ({
|
||||||
|
value: item.deviceId,
|
||||||
|
deviceIp: item.deviceIp,
|
||||||
|
deviceId: item.deviceId,
|
||||||
|
}));
|
||||||
|
|
||||||
|
await formApi.setValues(record)
|
||||||
|
}
|
||||||
|
await markInitialized()
|
||||||
|
|
||||||
|
modalApi.modalLoading(false)
|
||||||
},
|
},
|
||||||
});
|
})
|
||||||
|
|
||||||
async function handleConfirm() {
|
async function handleConfirm() {
|
||||||
try {
|
try {
|
||||||
modalApi.lock(true);
|
modalApi.lock(true)
|
||||||
const { valid } = await formApi.validate();
|
const { valid } = await formApi.validate()
|
||||||
if (!valid) {
|
if (!valid) {
|
||||||
return;
|
return
|
||||||
}
|
}
|
||||||
// getValues获取为一个readonly的对象 需要修改必须先深拷贝一次
|
// getValues获取为一个readonly的对象 需要修改必须先深拷贝一次
|
||||||
const data = cloneDeep(await formApi.getValues());
|
const data = cloneDeep(await formApi.getValues())
|
||||||
await (isUpdate.value ? elevatorInfoUpdate(data) : elevatorInfoAdd(data));
|
console.log(data)
|
||||||
resetInitialized();
|
await (isUpdate.value ? elevatorInfoUpdate(data) : elevatorInfoAdd(data))
|
||||||
emit('reload');
|
resetInitialized()
|
||||||
modalApi.close();
|
emit('reload')
|
||||||
|
modalApi.close()
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error);
|
console.error(error)
|
||||||
} finally {
|
} finally {
|
||||||
modalApi.lock(false);
|
modalApi.lock(false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let rows: any = [];
|
let rows: any = []
|
||||||
|
|
||||||
async function loadDeviceList() {
|
async function loadDeviceList() {
|
||||||
if (rows.length === 0) {
|
if (rows.length === 0) {
|
||||||
const params: DeviceManageQuery = {
|
const params: DeviceManageQuery = {
|
||||||
pageNum: 1,
|
pageNum: 1,
|
||||||
pageSize: 500,
|
pageSize: 500,
|
||||||
};
|
}
|
||||||
const res = await deviceManageList(params);
|
const res = await deviceManageList(params)
|
||||||
if (res && res.rows && res.rows.length > 0) {
|
if (res && res.rows && res.rows.length > 0) {
|
||||||
rows = res.rows;
|
rows = res.rows
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const arr = rows.map((item: DeviceManageForm) => {
|
const arr = rows.map((item: DeviceManageForm) => {
|
||||||
@ -116,8 +129,8 @@ async function loadDeviceList() {
|
|||||||
value: item.id,
|
value: item.id,
|
||||||
deviceIp: item.deviceIp,
|
deviceIp: item.deviceIp,
|
||||||
deviceId: item.id,
|
deviceId: item.id,
|
||||||
};
|
}
|
||||||
});
|
})
|
||||||
|
|
||||||
formApi.updateSchema([
|
formApi.updateSchema([
|
||||||
{
|
{
|
||||||
@ -125,9 +138,9 @@ async function loadDeviceList() {
|
|||||||
options: arr,
|
options: arr,
|
||||||
mode: 'multiple', // 关键属性,启用多选模式
|
mode: 'multiple', // 关键属性,启用多选模式
|
||||||
onChange: async (value: string, option: any) => {
|
onChange: async (value: string, option: any) => {
|
||||||
const data = cloneDeep(await formApi.getValues());
|
const data = cloneDeep(await formApi.getValues())
|
||||||
data.remoteCallElevatorDeviceId = option;
|
data.remoteCallElevatorDeviceId = option
|
||||||
formApi.setValues(data);
|
formApi.setValues(data)
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
fieldName: 'remoteCallElevatorDeviceId',
|
fieldName: 'remoteCallElevatorDeviceId',
|
||||||
@ -137,29 +150,29 @@ async function loadDeviceList() {
|
|||||||
options: arr,
|
options: arr,
|
||||||
allowClear: true,
|
allowClear: true,
|
||||||
onChange: async (value: string, option: any) => {
|
onChange: async (value: string, option: any) => {
|
||||||
const data = cloneDeep(await formApi.getValues());
|
const data = cloneDeep(await formApi.getValues())
|
||||||
data.elevatorControlDeviceId = option;
|
data.elevatorControlDeviceId = option
|
||||||
formApi.setValues(data);
|
formApi.setValues(data)
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
fieldName: 'elevatorControlDeviceId',
|
fieldName: 'elevatorControlDeviceId',
|
||||||
},
|
},
|
||||||
]);
|
])
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 初始化城市
|
* 初始化城市
|
||||||
*/
|
*/
|
||||||
async function setupCommunitySelect() {
|
async function setupCommunitySelect() {
|
||||||
const areaList = await communityTree(3);
|
const areaList = await communityTree(2)
|
||||||
// 选中后显示在输入框的值 即父节点 / 子节点
|
// 选中后显示在输入框的值 即父节点 / 子节点
|
||||||
// addFullName(areaList, 'areaName', ' / ');
|
// addFullName(areaList, 'areaName', ' / ');
|
||||||
const splitStr = '/';
|
const splitStr = '/'
|
||||||
handleNode(areaList, 'label', splitStr, function (node: any) {
|
handleNode(areaList, 'label', splitStr, function (node: any) {
|
||||||
if (node.level != 3) {
|
if (node.level != 2) {
|
||||||
node.disabled = true;
|
node.disabled = true
|
||||||
}
|
}
|
||||||
});
|
})
|
||||||
formApi.updateSchema([
|
formApi.updateSchema([
|
||||||
{
|
{
|
||||||
componentProps: () => ({
|
componentProps: () => ({
|
||||||
@ -183,12 +196,12 @@ async function setupCommunitySelect() {
|
|||||||
}),
|
}),
|
||||||
fieldName: 'unitId',
|
fieldName: 'unitId',
|
||||||
},
|
},
|
||||||
]);
|
])
|
||||||
}
|
}
|
||||||
|
|
||||||
async function handleClosed() {
|
async function handleClosed() {
|
||||||
await formApi.resetForm();
|
await formApi.resetForm()
|
||||||
resetInitialized();
|
resetInitialized()
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user