描述:设备选择地区、园区、楼宇、楼层

This commit is contained in:
SelfRidicule 2024-04-04 16:07:46 +08:00
parent 9d3388dad4
commit 22aced73cd

View File

@ -16,24 +16,82 @@
</a-form-item> </a-form-item>
<div style='display: flex;margin-bottom: 20px'> <div style='display: flex;margin-bottom: 20px'>
<span style='width: 20px;display: block;font-size: 25px;color: #1890ff;font-weight: bold;'>|</span> <span style='width: 20px;display: block;font-size: 25px;color: #1890ff;font-weight: bold;'>|</span>
<span style='display: block;margin-top: 11px;font-size: 15px'>新增设备</span> <span style='display: block;margin-top: 11px;font-size: 15px'>设备管理</span>
</div> </div>
<a-row>
<a-col :span='11'>
<a-form-item :labelCol='labelCol' :wrapperCol='wrapperCol' label='所属地区'>
<a-select v-decorator="['tenantId', {rules: [{ required: true, message: '请选择所属地区' }]}]"
@change='selectTenant'
:disabled='tenantEnable'>
<a-select-option v-for='item in tenantList' :key='item.id'>{{ item.name }}</a-select-option>
</a-select>
</a-form-item>
</a-col>
<a-col :span='11'>
<a-form-item :labelCol='labelCol' :wrapperCol='wrapperCol' label='所属园区'>
<a-select v-decorator="['parkId', {rules: [{ required: true, message: '请选择所属园区' }]}]"
@change='selectPark'
:disabled='parkEnable'>
<a-select-option v-for='item in parkList' :key='item.id'>{{ item.name }}</a-select-option>
</a-select>
</a-form-item>
</a-col>
</a-row>
<a-row>
<a-col :span='11'>
<a-form-item :labelCol='labelCol' :wrapperCol='wrapperCol' label='所属楼宇'>
<a-select v-decorator="['buildingId', {rules: [{ required: true, message: '请选择所属楼宇' }]}]"
@change='selectBuilding'>
<a-select-option v-for='item in buildingList' :key='item.id'>{{ item.buildingName }}</a-select-option>
</a-select>
</a-form-item>
</a-col>
<a-col :span='11'>
<a-form-item :labelCol='labelCol' :wrapperCol='wrapperCol' label='所属楼层'>
<a-select v-decorator="['buildId',{rules: [{ required: true, message: '请选择所属楼层' }]}]"
placeholder='所属楼层'
@change='selectBuildingDetail'>
<a-select-option v-for='item in buildingDetailList' :key='item.id' :value='item.id'>
{{ item.floorName }}
</a-select-option>
</a-select>
</a-form-item>
</a-col>
</a-row>
<a-row>
<a-col :span='11'>
<a-form-item :labelCol='labelCol' :wrapperCol='wrapperCol' label='所属房间'>
<a-select v-decorator="['roomId',{rules: [{ required: true, message: '选择所属房间' }]}]"
placeholder='所属房间'
@change='selectRoom'>
<a-select-option v-for='item in roomList' :key='item.id' :value='item.id'>
{{ item.name }}
</a-select-option>
</a-select>
</a-form-item>
</a-col>
</a-row>
<a-row> <a-row>
<a-col :span='11'> <a-col :span='11'>
<a-form-item :labelCol='labelCol' :wrapperCol='wrapperCol' label='设备编号'> <a-form-item :labelCol='labelCol' :wrapperCol='wrapperCol' label='设备编号'>
<a-input placeholder='设备编号' v-decorator="['equipmentNum', {rules: [{required: true, message: '请输入设备编号'}]}]" /> <a-input placeholder='设备编号'
v-decorator="['equipmentNum', {rules: [{required: true, message: '请输入设备编号'}]}]" />
</a-form-item> </a-form-item>
</a-col> </a-col>
<a-col :span='11'> <a-col :span='11'>
<a-form-item :labelCol='labelCol' :wrapperCol='wrapperCol' label='设备名称'> <a-form-item :labelCol='labelCol' :wrapperCol='wrapperCol' label='设备名称'>
<a-input placeholder='设备名称' v-decorator="['equipmentName',{rules: [{required: true, message: '请输入设备名称'}]}]" /> <a-input placeholder='设备名称'
v-decorator="['equipmentName',{rules: [{required: true, message: '请输入设备名称'}]}]" />
</a-form-item> </a-form-item>
</a-col> </a-col>
</a-row> </a-row>
<a-row> <a-row>
<a-col :span='11'> <a-col :span='11'>
<a-form-item :labelCol='labelCol' :wrapperCol='wrapperCol' label='设备类型'> <a-form-item :labelCol='labelCol' :wrapperCol='wrapperCol' label='设备类型'>
<a-select v-decorator="['type',{rules: [{ required: true, message: '请选择设备类型'}]}]" placeholder='请选择设备类型'> <a-select v-decorator="['type',{rules: [{ required: true, message: '请选择设备类型'}]}]"
placeholder='请选择设备类型'>
<a-select-option :value='0'> <a-select-option :value='0'>
门禁 门禁
</a-select-option> </a-select-option>
@ -49,32 +107,11 @@
</a-form-item> </a-form-item>
</a-col> </a-col>
</a-row> </a-row>
<a-row>
<a-col :span='11'>
<a-form-item :labelCol='labelCol' :wrapperCol='wrapperCol' label='所属楼层'>
<a-select v-decorator="['buildId',{rules: [{ required: true, message: '请选择所属楼层' }]}]" placeholder='所属楼层'
@change='getRoomList'>
<a-select-option v-for='item in floorList' :key='item.id' :value='item.id' >
{{ item.floorName }}
</a-select-option>
</a-select>
</a-form-item>
</a-col>
<a-col :span='11'>
<a-form-item :labelCol='labelCol' :wrapperCol='wrapperCol' label='存放地点'>
<a-select v-decorator="['roomId']" placeholder='所属房间'
>
<a-select-option v-for='item in roomList' :key='item.id' :value='item.id' >
{{ item.name }}
</a-select-option>
</a-select>
</a-form-item>
</a-col>
</a-row>
<a-row> <a-row>
<a-col :span='11'> <a-col :span='11'>
<a-form-item :labelCol='labelCol' :wrapperCol='wrapperCol' label='设备状态'> <a-form-item :labelCol='labelCol' :wrapperCol='wrapperCol' label='设备状态'>
<a-select v-decorator="['status',{rules: [{ required: true, message: '请选择设备状态'}]}]" placeholder='请选择设备状态'> <a-select v-decorator="['status',{rules: [{ required: true, message: '请选择设备状态'}]}]"
placeholder='请选择设备状态'>
<a-select-option :value='0'> <a-select-option :value='0'>
开启 开启
</a-select-option> </a-select-option>
@ -130,9 +167,14 @@
<script> <script>
import { saveEquipment, get, recordByDeviceId, getRoomList } from '@/api/admin/meeting/equipment' import { saveEquipment, get, recordByDeviceId, getRoomList } from '@/api/admin/meeting/equipment'
import pick from 'lodash.pick' import pick from 'lodash.pick'
import { getFloorList } from '@/api/admin/meeting/roomContent' import { getFloorList, getRoomListByFloorId } from '@/api/admin/meeting/roomContent'
import storage from 'store' import storage from 'store'
import { ACCESS_TOKEN } from '@/store/mutation-types' import { ACCESS_TOKEN } from '@/store/mutation-types'
import { getInfo } from '@/api/login'
import { getTenantList } from '@/api/tenant'
import { getParkList } from '@/api/admin/park'
import { getBuildingList } from '@/api/admin/building'
import { getBuildingDetailList } from '@/api/admin/buildingDetail'
export default { export default {
name: 'EquipmentModal', name: 'EquipmentModal',
@ -159,8 +201,6 @@ export default {
confirmLoading: false, confirmLoading: false,
mdl: {}, mdl: {},
form: this.$form.createForm(this), form: this.$form.createForm(this),
floorList: [],
roomList: [],
columns: [ columns: [
{ {
title: '开门时间', title: '开门时间',
@ -168,34 +208,145 @@ export default {
}, },
{ {
title: '开门方式', title: '开门方式',
dataIndex: 'type', dataIndex: 'type'
}, },
{ {
title: '开门人', title: '开门人',
dataIndex: 'userName' dataIndex: 'userName'
}, }
], ],
//
userDetail: {},
tenantList: [], //
parkList: [], //
buildingList: [], //
buildingDetailList: [], //
roomList: [], //
tenantEnable: false,
parkEnable: false
} }
}, },
beforeCreate() { beforeCreate() {
}, },
created() { created() {
this.getFloorList()
}, },
methods: { methods: {
getFloorList() { //
getFloorList().then((res) => { getUserDetail() {
this.floorList = res.data getInfo().then(res => {
console.log('getUserDetail', res)
this.userDetail = res
// 5
if (this.userDetail.roleIds && this.userDetail.roleIds.length > 0 && this.userDetail.roleIds[0] == 5) {
//
//
let { id } = this.mdl
if (!id) {
// ->
this.selectTenant(this.userDetail.tenantId)
// ->
this.selectPark(this.userDetail.parkId)
}
//
//
this.tenantEnable = true
this.parkEnable = true
//
this.mdl.parkId = this.userDetail.parkId
this.mdl.tenantId = this.userDetail.tenantId
this.form.setFieldsValue({
parkId: this.mdl.parkId,
tenantId: this.mdl.tenantId
})
}
}) })
}, },
getRoomList(value) { //
getRoomList({ 'buildingDetailId': value, }).then((res) => { getTenantData() {
getTenantList().then(res => {
this.tenantList = res.rows
})
},
// ->
selectTenant(id) {
console.log('selectTenant', id)
//
this.mdl.parkId = null //
this.mdl.buildingId = null //
this.mdl.buildId = null //
this.mdl.roomId = null //
this.form.setFieldsValue({
parkId: null, //
buildingId: null, //
buildId: null, //
roomId: null //
})
//
getParkList({
tenantId: id
}).then(res => {
this.parkList = res.rows
})
},
// ->
selectPark(id) {
//
this.mdl.buildingId = null //
this.mdl.buildId = null //
this.mdl.roomId = null //
this.form.setFieldsValue({
buildingId: null, //
buildId: null, //
roomId: null //
})
//
getBuildingList({
parkId: id
}).then(res => {
this.buildingList = res.rows
})
},
// ->
selectBuilding(id) {
//
this.mdl.buildId = null //
this.mdl.roomId = null //
this.form.setFieldsValue({
buildId: null, //
roomId: null //
})
//
getBuildingDetailList({
buildingId: id
}).then(res => {
this.buildingDetailList = res.rows
})
},
// ->
selectBuildingDetail(buildingDetailId) {
//
this.getRoomListByFloorIdMethod(buildingDetailId)
},
//
getRoomListByFloorIdMethod(buildingDetailId, id) {
//
this.mdl.roomId = null //
this.form.setFieldsValue({
roomId: null //
})
//
getRoomListByFloorId({
'id': id,
'buildingDetailId': buildingDetailId
}).then((res) => {
this.roomList = res.data this.roomList = res.data
}) })
}, },
//
beforeUpload(file) { beforeUpload(file) {
const isJpgOrPng = file.type === 'image/jpeg' || file.type === 'image/png' const isJpgOrPng = file.type === 'image/jpeg' || file.type === 'image/png'
if (!isJpgOrPng) { if (!isJpgOrPng) {
@ -234,32 +385,53 @@ export default {
this.edit({ id: 0 }) this.edit({ id: 0 })
}, },
edit(record) { edit(record) {
//
this.getTenantData()
if (record.id != 0){ //
get(record.id).then((res) => { this.mdl = Object.assign(this.mdl, record)
this.form.setFieldsValue({ let copyMdl = JSON.parse(JSON.stringify(this.mdl))
}) //
}) this.getUserDetail()
//
if (record.id) {
//
recordByDeviceId(record.id).then(res => { recordByDeviceId(record.id).then(res => {
this.loadData = res.data this.loadData = res.data
}) })
// ->
if (copyMdl.tenantId) {
this.mdl = JSON.parse(JSON.stringify(copyMdl))
this.selectTenant(copyMdl.tenantId)
}
// ->
if (copyMdl.parkId) {
this.mdl = JSON.parse(JSON.stringify(copyMdl))
this.selectPark(copyMdl.parkId)
}
// ->
if (copyMdl.buildingId) {
this.mdl = JSON.parse(JSON.stringify(copyMdl))
this.selectBuilding(copyMdl.buildingId)
}
// ->
if (copyMdl.buildId) {
this.mdl = JSON.parse(JSON.stringify(copyMdl))
this.getRoomListByFloorIdMethod(copyMdl.buildId, copyMdl.roomId)
}
//
this.mdl = JSON.parse(JSON.stringify(copyMdl))
} }
this.mdl = Object.assign(record)
if (this.mdl.pic) { if (this.mdl.pic) {
this.imageUrl = process.env.VUE_APP_API_BASE_URL + this.mdl.pic this.imageUrl = process.env.VUE_APP_API_BASE_URL + this.mdl.pic
} else {
this.imageUrl = ''
} }
//
getRoomList({ 'buildingDetailId': this.mdl.buildId, }).then((res) => {
this.roomList = res.data
})
this.visible = true this.visible = true
this.$nextTick(() => { this.$nextTick(() => {
this.form.setFieldsValue(pick(this.mdl, 'id', 'type', 'equipmentName', 'status', 'createDate', 'equipmentNum','buildId','ip','roomId', 'pic', 'deleteFlag', 'createBy', 'createTime', 'updateBy', 'updateTime')) this.form.setFieldsValue(pick(this.mdl, 'id', 'type', 'equipmentName', 'status', 'createDate',
'equipmentNum', 'ip', 'tenantId', 'parkId', 'buildingId', 'buildId', 'roomId', 'pic',
'deleteFlag', 'createBy', 'createTime', 'updateBy', 'updateTime'))
}) })
}, },
handleSubmit(e) { handleSubmit(e) {