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

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>
<div style='display: flex;margin-bottom: 20px'>
<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>
<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-col :span='11'>
<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-col>
<a-col :span='11'>
<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-col>
</a-row>
<a-row>
<a-col :span='11'>
<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>
@ -49,32 +107,11 @@
</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="['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-col :span='11'>
<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>
@ -120,7 +157,7 @@
ref='table'
style='width: 800px;margin-left: 20px'
:data-source='loadData'
>
>
<a slot='name' slot-scope='text'>{{ text }}</a>
</a-table>
@ -128,11 +165,16 @@
</a-modal>
</template>
<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 { getFloorList } from '@/api/admin/meeting/roomContent'
import { getFloorList, getRoomListByFloorId } from '@/api/admin/meeting/roomContent'
import storage from 'store'
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 {
name: 'EquipmentModal',
@ -145,7 +187,7 @@ export default {
xs: { span: 24 },
sm: { span: 5 }
},
loadData:[],
loadData: [],
loading: false,
wrapperCol: {
xs: { span: 24 },
@ -159,8 +201,6 @@ export default {
confirmLoading: false,
mdl: {},
form: this.$form.createForm(this),
floorList: [],
roomList: [],
columns: [
{
title: '开门时间',
@ -168,34 +208,145 @@ export default {
},
{
title: '开门方式',
dataIndex: 'type',
dataIndex: 'type'
},
{
title: '开门人',
dataIndex: 'userName'
},
}
],
//
userDetail: {},
tenantList: [], //
parkList: [], //
buildingList: [], //
buildingDetailList: [], //
roomList: [], //
tenantEnable: false,
parkEnable: false
}
},
beforeCreate() {
},
created() {
this.getFloorList()
},
methods: {
getFloorList() {
getFloorList().then((res) => {
this.floorList = res.data
//
getUserDetail() {
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
})
},
//
beforeUpload(file) {
const isJpgOrPng = file.type === 'image/jpeg' || file.type === 'image/png'
if (!isJpgOrPng) {
@ -234,32 +385,53 @@ export default {
this.edit({ id: 0 })
},
edit(record) {
if (record.id != 0){
get(record.id).then((res) => {
this.form.setFieldsValue({
})
//
this.getTenantData()
//
this.mdl = Object.assign(this.mdl, record)
let copyMdl = JSON.parse(JSON.stringify(this.mdl))
//
this.getUserDetail()
//
if (record.id) {
//
recordByDeviceId(record.id).then(res => {
this.loadData = res.data
})
recordByDeviceId(record.id).then(res =>{
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) {
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.$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) {