feat(sis): 电梯信息关联楼层
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:
@@ -61,9 +61,9 @@ export function floorRemove(id: ID | IDS) {
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据单元ID查询楼层
|
||||
* 根据楼层ID查询楼层
|
||||
* @param id id
|
||||
*/
|
||||
export function queryByUnitId(id: ID | IDS) {
|
||||
return requestClient.get<FloorVO[]>(`/property/floor/queryByUnitId/${id}`);
|
||||
export function queryByBuildingId(id: ID | IDS) {
|
||||
return requestClient.get<FloorVO[]>(`/property/floor/queryByBuildingId/${id}`);
|
||||
}
|
||||
|
@@ -107,6 +107,11 @@ export interface ElevatorInfoVO {
|
||||
deviceIp: string,
|
||||
deviceId: number,
|
||||
}[]
|
||||
|
||||
/**
|
||||
* 建筑ID
|
||||
*/
|
||||
buildingId?: number | string
|
||||
}
|
||||
|
||||
export interface ElevatorInfoForm extends BaseEntity {
|
||||
@@ -206,10 +211,9 @@ export interface ElevatorInfoForm extends BaseEntity {
|
||||
controlPwd?: string
|
||||
|
||||
/**
|
||||
* 单元ID
|
||||
* 建筑ID
|
||||
*/
|
||||
unitId?: number
|
||||
|
||||
buildingId?: number
|
||||
}
|
||||
|
||||
export interface ElevatorInfoQuery extends PageQuery {
|
||||
|
@@ -105,7 +105,7 @@ export const modalSchema: FormSchemaGetter = () => [
|
||||
},
|
||||
{
|
||||
component: 'TreeSelect',
|
||||
fieldName: 'unitId',
|
||||
fieldName: 'buildingId',
|
||||
defaultValue: undefined,
|
||||
label: '社区建筑',
|
||||
rules: 'selectRequired',
|
||||
|
@@ -1,5 +1,6 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, ref } from 'vue'
|
||||
import { computed, ref, reactive } from 'vue'
|
||||
import { Tabs, TabPane, Form, FormItem, Space, Input } from 'ant-design-vue'
|
||||
|
||||
import { useVbenModal } from '@vben/common-ui'
|
||||
import { $t } from '@vben/locales'
|
||||
@@ -15,9 +16,11 @@ import { defaultFormValueGetter, useBeforeCloseDiff } from '#/utils/popup'
|
||||
|
||||
import { modalSchema } from './data'
|
||||
import { communityTree } from '#/api/property/community'
|
||||
import { queryByBuildingId } from '#/api/property/floor'
|
||||
import type { DeviceManageForm, DeviceManageQuery } from '#/api/sis/deviceManage/model'
|
||||
import { deviceManageList } from '#/api/sis/deviceManage'
|
||||
|
||||
|
||||
const emit = defineEmits<{ reload: [] }>()
|
||||
|
||||
const isUpdate = ref(false)
|
||||
@@ -69,18 +72,26 @@ const [BasicModal, modalApi] = useVbenModal({
|
||||
|
||||
if (isUpdate.value && id) {
|
||||
const record = await elevatorInfoInfo(id)
|
||||
record.elevatorControlDeviceId = {
|
||||
value: record.elevatorControlDeviceId.deviceId,
|
||||
deviceIp: record.elevatorControlDeviceId.deviceIp,
|
||||
deviceId: record.elevatorControlDeviceId.deviceId,
|
||||
|
||||
if (record.elevatorControlDeviceId) {
|
||||
record.elevatorControlDeviceId = {
|
||||
value: record.elevatorControlDeviceId.deviceId,
|
||||
deviceIp: record.elevatorControlDeviceId.deviceIp,
|
||||
deviceId: record.elevatorControlDeviceId.deviceId,
|
||||
}
|
||||
}
|
||||
|
||||
record.remoteCallElevatorDeviceId = record.remoteCallElevatorDeviceId.map(item => ({
|
||||
value: item.deviceId,
|
||||
deviceIp: item.deviceIp,
|
||||
deviceId: item.deviceId,
|
||||
}));
|
||||
if (record.remoteCallElevatorDeviceId) {
|
||||
record.remoteCallElevatorDeviceId = record.remoteCallElevatorDeviceId.map(item => {
|
||||
return {
|
||||
value: item.deviceId,
|
||||
deviceIp: item.deviceIp,
|
||||
deviceId: item.deviceId,
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
await handleGetFloor(record.buildingId)
|
||||
await formApi.setValues(record)
|
||||
}
|
||||
await markInitialized()
|
||||
@@ -98,7 +109,16 @@ async function handleConfirm() {
|
||||
}
|
||||
// getValues获取为一个readonly的对象 需要修改必须先深拷贝一次
|
||||
const data = cloneDeep(await formApi.getValues())
|
||||
console.log(data)
|
||||
// 通道信息
|
||||
const filteredChannels = dynamicValidateForm.floor
|
||||
.filter(item => !(item.out.length === 0 && item.in.length === 0))
|
||||
.map(item => ({
|
||||
floorId: item.id,
|
||||
inChannel: item.in,
|
||||
outChannel: item.out
|
||||
}))
|
||||
|
||||
data.channels = filteredChannels
|
||||
await (isUpdate.value ? elevatorInfoUpdate(data) : elevatorInfoAdd(data))
|
||||
resetInitialized()
|
||||
emit('reload')
|
||||
@@ -183,6 +203,9 @@ async function setupCommunitySelect() {
|
||||
value: 'code',
|
||||
children: 'children',
|
||||
},
|
||||
onChange: async (value: any) => {
|
||||
await handleGetFloor(value)
|
||||
},
|
||||
getPopupContainer,
|
||||
placeholder: '请选择建筑',
|
||||
showSearch: true,
|
||||
@@ -194,11 +217,41 @@ async function setupCommunitySelect() {
|
||||
// 选中后显示在输入框的值
|
||||
treeNodeLabelProp: 'fullName',
|
||||
}),
|
||||
fieldName: 'unitId',
|
||||
fieldName: 'buildingId',
|
||||
},
|
||||
])
|
||||
}
|
||||
|
||||
interface floor {
|
||||
out: string
|
||||
in: string
|
||||
num: string | number
|
||||
id: string | number
|
||||
}
|
||||
const floorList = ref<floor[]>([])
|
||||
const dynamicValidateForm = reactive<{ floor: floor[] }>({
|
||||
floor: [],
|
||||
})
|
||||
async function handleGetFloor(unitId: string | number) {
|
||||
try {
|
||||
const res = await queryByBuildingId(unitId)
|
||||
floorList.value = []
|
||||
res.forEach((item) => {
|
||||
floorList.value.push({
|
||||
out: '',
|
||||
in: '',
|
||||
num: item.floorNumber,
|
||||
id: item.id,
|
||||
})
|
||||
})
|
||||
|
||||
dynamicValidateForm.floor = floorList.value
|
||||
} catch (error) {
|
||||
console.error('获取楼层列表失败:', error)
|
||||
floorList.value = []
|
||||
}
|
||||
}
|
||||
|
||||
async function handleClosed() {
|
||||
await formApi.resetForm()
|
||||
resetInitialized()
|
||||
@@ -207,6 +260,23 @@ async function handleClosed() {
|
||||
|
||||
<template>
|
||||
<BasicModal :title="title">
|
||||
<BasicForm />
|
||||
<Tabs style="height: 600px !important">
|
||||
<TabPane key="1" tab="基本信息">
|
||||
<BasicForm />
|
||||
</TabPane>
|
||||
<TabPane key="2" tab="楼层信息">
|
||||
<Form :model="dynamicValidateForm" layout="inline">
|
||||
<Space v-for="(floor, index) in dynamicValidateForm.floor" :key="floor.id"
|
||||
style="display: flex; margin-bottom: 8px" align="baseline">
|
||||
<FormItem :label="'楼层' + (floor.num)" :name="['floor', index, 'out']">
|
||||
<Input v-model:value="floor.out" placeholder="外部按键通道" />
|
||||
</FormItem>
|
||||
<FormItem :name="['floor', index, 'in']">
|
||||
<Input v-model:value="floor.in" placeholder="内部按键通道" />
|
||||
</FormItem>
|
||||
</Space>
|
||||
</Form>
|
||||
</TabPane>
|
||||
</Tabs>
|
||||
</BasicModal>
|
||||
</template>
|
||||
|
Reference in New Issue
Block a user