2024-02-25 11:17:48 +08:00
|
|
|
|
<template>
|
|
|
|
|
<a-modal
|
2024-03-12 16:23:34 +08:00
|
|
|
|
title='操作'
|
|
|
|
|
style='top: 20px;'
|
2024-03-22 08:42:24 +08:00
|
|
|
|
:width='1000'
|
2024-03-12 16:23:34 +08:00
|
|
|
|
v-model='visible'
|
|
|
|
|
:confirmLoading='confirmLoading'
|
|
|
|
|
@ok='handleSubmit'
|
2024-02-25 11:17:48 +08:00
|
|
|
|
>
|
2024-03-12 16:23:34 +08:00
|
|
|
|
<a-form :form='form'>
|
|
|
|
|
<a-form-item style='display:none'>
|
|
|
|
|
<a-input v-decorator="['id']" />
|
2024-02-25 11:17:48 +08:00
|
|
|
|
</a-form-item>
|
2024-03-12 16:23:34 +08:00
|
|
|
|
<a-form-item style='display:none'>
|
|
|
|
|
<a-input v-decorator="['version']" />
|
2024-02-25 11:17:48 +08:00
|
|
|
|
</a-form-item>
|
2024-03-22 08:42:24 +08:00
|
|
|
|
<div style='display: flex;margin-bottom: 20px'>
|
|
|
|
|
<span style='width: 20px;display: block;font-size: 25px;color: #1890ff;font-weight: bold;'>|</span>
|
2024-04-04 16:07:46 +08:00
|
|
|
|
<span style='display: block;margin-top: 11px;font-size: 15px'>设备管理</span>
|
2024-03-22 08:42:24 +08:00
|
|
|
|
</div>
|
|
|
|
|
<a-row>
|
|
|
|
|
<a-col :span='11'>
|
2024-04-04 16:07:46 +08:00
|
|
|
|
<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>
|
2024-03-22 08:42:24 +08:00
|
|
|
|
</a-form-item>
|
|
|
|
|
</a-col>
|
|
|
|
|
<a-col :span='11'>
|
2024-04-04 16:07:46 +08:00
|
|
|
|
<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>
|
2024-03-22 08:42:24 +08:00
|
|
|
|
</a-form-item>
|
|
|
|
|
</a-col>
|
|
|
|
|
</a-row>
|
2024-04-04 16:07:46 +08:00
|
|
|
|
|
2024-03-22 08:42:24 +08:00
|
|
|
|
<a-row>
|
|
|
|
|
<a-col :span='11'>
|
2024-04-04 16:07:46 +08:00
|
|
|
|
<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>
|
2024-03-22 08:42:24 +08:00
|
|
|
|
</a-select>
|
|
|
|
|
</a-form-item>
|
|
|
|
|
</a-col>
|
|
|
|
|
<a-col :span='11'>
|
2024-04-04 16:07:46 +08:00
|
|
|
|
<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>
|
2024-03-22 08:42:24 +08:00
|
|
|
|
</a-form-item>
|
|
|
|
|
</a-col>
|
|
|
|
|
</a-row>
|
|
|
|
|
<a-row>
|
|
|
|
|
<a-col :span='11'>
|
2024-04-04 16:07:46 +08:00
|
|
|
|
<a-form-item :labelCol='labelCol' :wrapperCol='wrapperCol' label='所属房间'>
|
2024-04-12 11:17:41 +08:00
|
|
|
|
<a-select v-decorator="['roomId']"
|
2024-04-04 16:07:46 +08:00
|
|
|
|
placeholder='所属房间'
|
|
|
|
|
@change='selectRoom'>
|
|
|
|
|
<a-select-option v-for='item in roomList' :key='item.id' :value='item.id'>
|
|
|
|
|
{{ item.name }}
|
2024-03-22 08:42:24 +08:00
|
|
|
|
</a-select-option>
|
|
|
|
|
</a-select>
|
|
|
|
|
</a-form-item>
|
|
|
|
|
</a-col>
|
2024-04-04 16:07:46 +08:00
|
|
|
|
</a-row>
|
|
|
|
|
<a-row>
|
2024-03-22 08:42:24 +08:00
|
|
|
|
<a-col :span='11'>
|
2024-04-04 16:07:46 +08:00
|
|
|
|
<a-form-item :labelCol='labelCol' :wrapperCol='wrapperCol' label='设备编号'>
|
|
|
|
|
<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-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-option :value='0'>
|
|
|
|
|
门禁
|
|
|
|
|
</a-select-option>
|
|
|
|
|
<a-select-option :value='1'>
|
|
|
|
|
开门控制器
|
2024-03-22 08:42:24 +08:00
|
|
|
|
</a-select-option>
|
|
|
|
|
</a-select>
|
|
|
|
|
</a-form-item>
|
|
|
|
|
</a-col>
|
2024-04-04 16:07:46 +08:00
|
|
|
|
<a-col :span='11'>
|
|
|
|
|
<a-form-item :labelCol='labelCol' :wrapperCol='wrapperCol' label='设备ip'>
|
|
|
|
|
<a-input placeholder='设备ip' v-decorator="['ip',{rules: [{required: true, message: '请输入设备ip'}]}]" />
|
|
|
|
|
</a-form-item>
|
|
|
|
|
</a-col>
|
2024-03-22 08:42:24 +08:00
|
|
|
|
</a-row>
|
|
|
|
|
<a-row>
|
|
|
|
|
<a-col :span='11'>
|
|
|
|
|
<a-form-item :labelCol='labelCol' :wrapperCol='wrapperCol' label='设备状态'>
|
2024-04-04 16:07:46 +08:00
|
|
|
|
<a-select v-decorator="['status',{rules: [{ required: true, message: '请选择设备状态'}]}]"
|
|
|
|
|
placeholder='请选择设备状态'>
|
2024-03-26 13:46:30 +08:00
|
|
|
|
<a-select-option :value='0'>
|
2024-03-22 08:42:24 +08:00
|
|
|
|
开启
|
|
|
|
|
</a-select-option>
|
2024-03-26 13:46:30 +08:00
|
|
|
|
<a-select-option :value='1'>
|
2024-03-22 08:42:24 +08:00
|
|
|
|
损坏
|
|
|
|
|
</a-select-option>
|
2024-03-26 13:46:30 +08:00
|
|
|
|
<a-select-option :value='2'>
|
2024-03-22 08:42:24 +08:00
|
|
|
|
离线
|
|
|
|
|
</a-select-option>
|
|
|
|
|
</a-select>
|
|
|
|
|
</a-form-item>
|
|
|
|
|
</a-col>
|
|
|
|
|
<a-col :span='11'>
|
|
|
|
|
<a-form-item :labelCol='labelCol' :wrapperCol='wrapperCol' label='设备图片'>
|
|
|
|
|
<!-- <a-input placeholder="设备图片" v-decorator="['pic',{rules: [{required: true, message: '请输入设备图片'}]}]"/>-->
|
|
|
|
|
<a-upload
|
|
|
|
|
v-decorator="['pic']"
|
|
|
|
|
list-type='picture-card'
|
|
|
|
|
class='avatar-uploader'
|
|
|
|
|
:show-upload-list='false'
|
|
|
|
|
:action='uploadUrl'
|
|
|
|
|
:headers='headers'
|
|
|
|
|
:before-upload='beforeUpload'
|
|
|
|
|
@change='handleChange'
|
|
|
|
|
>
|
|
|
|
|
<img v-if='imageUrl' :src='imageUrl' style='width: 102px; height: 102px' />
|
|
|
|
|
<div v-else>
|
|
|
|
|
<a-icon :type="loading ? 'loading' : 'plus'" />
|
|
|
|
|
<div class='ant-upload-text'> 上传</div>
|
|
|
|
|
</div>
|
|
|
|
|
</a-upload>
|
|
|
|
|
</a-form-item>
|
|
|
|
|
</a-col>
|
|
|
|
|
</a-row>
|
2024-02-25 11:17:48 +08:00
|
|
|
|
</a-form>
|
2024-03-22 08:42:24 +08:00
|
|
|
|
|
|
|
|
|
<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>
|
|
|
|
|
</div>
|
|
|
|
|
<a-table :columns='columns'
|
|
|
|
|
size='default'
|
|
|
|
|
ref='table'
|
|
|
|
|
style='width: 800px;margin-left: 20px'
|
|
|
|
|
:data-source='loadData'
|
2024-04-04 16:07:46 +08:00
|
|
|
|
>
|
2024-03-22 08:42:24 +08:00
|
|
|
|
<a slot='name' slot-scope='text'>{{ text }}</a>
|
|
|
|
|
|
|
|
|
|
</a-table>
|
|
|
|
|
|
2024-02-25 11:17:48 +08:00
|
|
|
|
</a-modal>
|
|
|
|
|
</template>
|
|
|
|
|
<script>
|
2024-04-04 16:07:46 +08:00
|
|
|
|
import { saveEquipment, get, recordByDeviceId, getRoomList } from '@/api/admin/meeting/equipment'
|
2024-03-12 16:23:34 +08:00
|
|
|
|
import pick from 'lodash.pick'
|
2024-04-04 16:07:46 +08:00
|
|
|
|
import { getFloorList, getRoomListByFloorId } from '@/api/admin/meeting/roomContent'
|
2024-03-12 16:23:34 +08:00
|
|
|
|
import storage from 'store'
|
|
|
|
|
import { ACCESS_TOKEN } from '@/store/mutation-types'
|
2024-04-04 16:07:46 +08:00
|
|
|
|
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'
|
2024-02-25 11:17:48 +08:00
|
|
|
|
|
2024-03-12 16:23:34 +08:00
|
|
|
|
export default {
|
2024-02-25 11:17:48 +08:00
|
|
|
|
name: 'EquipmentModal',
|
2024-03-12 16:23:34 +08:00
|
|
|
|
props: {},
|
|
|
|
|
components: {},
|
|
|
|
|
data() {
|
2024-02-25 11:17:48 +08:00
|
|
|
|
return {
|
|
|
|
|
visible: false,
|
|
|
|
|
labelCol: {
|
|
|
|
|
xs: { span: 24 },
|
|
|
|
|
sm: { span: 5 }
|
|
|
|
|
},
|
2024-04-04 16:07:46 +08:00
|
|
|
|
loadData: [],
|
2024-03-12 16:23:34 +08:00
|
|
|
|
loading: false,
|
2024-02-25 11:17:48 +08:00
|
|
|
|
wrapperCol: {
|
|
|
|
|
xs: { span: 24 },
|
|
|
|
|
sm: { span: 16 }
|
|
|
|
|
},
|
2024-03-12 16:23:34 +08:00
|
|
|
|
uploadUrl: process.env.VUE_APP_API_BASE_URL + '/api/dfs/upload',
|
|
|
|
|
imageUrl: '',
|
|
|
|
|
headers: {
|
|
|
|
|
Authorization: 'Bearer ' + storage.get(ACCESS_TOKEN)
|
|
|
|
|
},
|
2024-02-25 11:17:48 +08:00
|
|
|
|
confirmLoading: false,
|
|
|
|
|
mdl: {},
|
2024-03-09 15:48:19 +08:00
|
|
|
|
form: this.$form.createForm(this),
|
2024-03-22 08:42:24 +08:00
|
|
|
|
columns: [
|
|
|
|
|
{
|
|
|
|
|
title: '开门时间',
|
|
|
|
|
dataIndex: 'createTime'
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: '开门方式',
|
2024-04-08 13:50:14 +08:00
|
|
|
|
dataIndex: 'type',
|
|
|
|
|
scopedSlots: {customRender: 'type'}
|
|
|
|
|
|
2024-03-22 08:42:24 +08:00
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: '开门人',
|
|
|
|
|
dataIndex: 'userName'
|
2024-04-04 16:07:46 +08:00
|
|
|
|
}
|
2024-03-22 08:42:24 +08:00
|
|
|
|
],
|
2024-04-04 16:07:46 +08:00
|
|
|
|
//
|
|
|
|
|
userDetail: {},
|
|
|
|
|
tenantList: [], // 地区
|
|
|
|
|
parkList: [], // 园区
|
|
|
|
|
buildingList: [], // 楼宇
|
|
|
|
|
buildingDetailList: [], // 楼层
|
|
|
|
|
roomList: [], // 房间
|
|
|
|
|
tenantEnable: false,
|
|
|
|
|
parkEnable: false
|
2024-02-25 11:17:48 +08:00
|
|
|
|
}
|
|
|
|
|
},
|
2024-03-12 16:23:34 +08:00
|
|
|
|
beforeCreate() {
|
2024-02-25 11:17:48 +08:00
|
|
|
|
},
|
2024-03-12 16:23:34 +08:00
|
|
|
|
created() {
|
2024-04-04 16:07:46 +08:00
|
|
|
|
|
2024-02-25 11:17:48 +08:00
|
|
|
|
},
|
|
|
|
|
methods: {
|
2024-04-04 16:07:46 +08:00
|
|
|
|
// 获取用户详细信息
|
|
|
|
|
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
|
|
|
|
|
})
|
|
|
|
|
}
|
2024-03-09 15:48:19 +08:00
|
|
|
|
})
|
|
|
|
|
},
|
2024-04-04 16:07:46 +08:00
|
|
|
|
// 查询地区
|
|
|
|
|
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
|
2024-03-09 15:48:19 +08:00
|
|
|
|
})
|
|
|
|
|
},
|
2024-04-04 16:07:46 +08:00
|
|
|
|
// 选择园区 -> 查询楼宇
|
|
|
|
|
selectPark(id) {
|
|
|
|
|
// 清空数据
|
|
|
|
|
this.mdl.buildingId = null // 楼宇
|
|
|
|
|
this.mdl.buildId = null // 楼层
|
|
|
|
|
this.mdl.roomId = null // 所属房间
|
2024-03-22 08:42:24 +08:00
|
|
|
|
|
2024-04-04 16:07:46 +08:00
|
|
|
|
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 // 所属房间
|
2024-03-22 08:42:24 +08:00
|
|
|
|
|
2024-04-04 16:07:46 +08:00
|
|
|
|
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
|
|
|
|
|
})
|
|
|
|
|
},
|
2024-03-12 16:23:34 +08:00
|
|
|
|
beforeUpload(file) {
|
|
|
|
|
const isJpgOrPng = file.type === 'image/jpeg' || file.type === 'image/png'
|
|
|
|
|
if (!isJpgOrPng) {
|
|
|
|
|
this.$message.error('You can only upload JPG file!')
|
|
|
|
|
}
|
|
|
|
|
const isLt2M = file.size / 1024 < 500
|
|
|
|
|
if (!isLt2M) {
|
|
|
|
|
this.$message.error('图片必须小于 500kb!')
|
|
|
|
|
}
|
|
|
|
|
return isJpgOrPng && isLt2M
|
|
|
|
|
},
|
|
|
|
|
handleChange(info) {
|
|
|
|
|
if (info.file.status === 'uploading') {
|
|
|
|
|
this.loading = true
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
if (info.file.status === 'done') {
|
|
|
|
|
const { form: { setFieldsValue } } = this
|
|
|
|
|
const result = info.file.response
|
|
|
|
|
// 设置值
|
|
|
|
|
this.$nextTick(() => {
|
|
|
|
|
setFieldsValue({
|
|
|
|
|
// 设置相对路径
|
|
|
|
|
pic: result.fileName
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
// Get this url from response in real world.
|
|
|
|
|
getBase64(info.file.originFileObj, imageUrl => {
|
|
|
|
|
this.imageUrl = imageUrl
|
|
|
|
|
this.loading = false
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
add() {
|
2024-02-25 11:17:48 +08:00
|
|
|
|
this.form.resetFields()
|
2024-04-15 11:29:56 +08:00
|
|
|
|
this.mdl = {}
|
2024-02-25 11:17:48 +08:00
|
|
|
|
this.edit({ id: 0 })
|
|
|
|
|
},
|
2024-03-12 16:23:34 +08:00
|
|
|
|
edit(record) {
|
2024-04-04 16:07:46 +08:00
|
|
|
|
// 查询地区
|
|
|
|
|
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
|
2024-03-22 08:42:24 +08:00
|
|
|
|
})
|
2024-04-04 16:07:46 +08:00
|
|
|
|
// 选择地区 -> 查询园区
|
|
|
|
|
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))
|
2024-03-12 16:23:34 +08:00
|
|
|
|
}
|
2024-03-22 17:34:16 +08:00
|
|
|
|
if (this.mdl.pic) {
|
|
|
|
|
this.imageUrl = process.env.VUE_APP_API_BASE_URL + this.mdl.pic
|
2024-04-04 16:07:46 +08:00
|
|
|
|
} else {
|
|
|
|
|
this.imageUrl = ''
|
2024-03-22 17:34:16 +08:00
|
|
|
|
}
|
2024-04-04 16:07:46 +08:00
|
|
|
|
//
|
2024-02-25 11:17:48 +08:00
|
|
|
|
this.visible = true
|
|
|
|
|
this.$nextTick(() => {
|
2024-04-04 16:07:46 +08:00
|
|
|
|
this.form.setFieldsValue(pick(this.mdl, 'id', 'type', 'equipmentName', 'status', 'createDate',
|
|
|
|
|
'equipmentNum', 'ip', 'tenantId', 'parkId', 'buildingId', 'buildId', 'roomId', 'pic',
|
|
|
|
|
'deleteFlag', 'createBy', 'createTime', 'updateBy', 'updateTime'))
|
2024-02-25 11:17:48 +08:00
|
|
|
|
})
|
|
|
|
|
},
|
2024-03-12 16:23:34 +08:00
|
|
|
|
handleSubmit(e) {
|
2024-02-25 11:17:48 +08:00
|
|
|
|
e.preventDefault()
|
|
|
|
|
this.form.validateFields((err, values) => {
|
|
|
|
|
if (!err) {
|
|
|
|
|
console.log('Received values of form: ', values)
|
|
|
|
|
this.confirmLoading = true
|
|
|
|
|
saveEquipment(values).then(res => {
|
|
|
|
|
if (res.code === 0) {
|
|
|
|
|
this.$message.success('保存成功')
|
|
|
|
|
this.$emit('ok')
|
|
|
|
|
this.visible = false
|
|
|
|
|
} else {
|
|
|
|
|
this.$message.error(res.msg)
|
|
|
|
|
}
|
|
|
|
|
}).catch(() => {
|
|
|
|
|
this.$message.error('系统错误,请稍后再试')
|
|
|
|
|
}).finally(() => {
|
|
|
|
|
this.confirmLoading = false
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
watch: {
|
|
|
|
|
/*
|
|
|
|
|
'selectedRows': function (selectedRows) {
|
|
|
|
|
this.needTotalList = this.needTotalList.map(item => {
|
|
|
|
|
return {
|
|
|
|
|
...item,
|
|
|
|
|
total: selectedRows.reduce( (sum, val) => {
|
|
|
|
|
return sum + val[item.dataIndex]
|
|
|
|
|
}, 0)
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
*/
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-03-12 16:23:34 +08:00
|
|
|
|
|
|
|
|
|
function getBase64(img, callback) {
|
|
|
|
|
const reader = new FileReader()
|
|
|
|
|
reader.addEventListener('load', () => callback(reader.result))
|
|
|
|
|
reader.readAsDataURL(img)
|
|
|
|
|
}
|
2024-02-25 11:17:48 +08:00
|
|
|
|
</script>
|