|
@@ -0,0 +1,884 @@
|
|
|
+<template>
|
|
|
+ <view id="hardware-add-page">
|
|
|
+ <view class="addForm-max-big-box">
|
|
|
+ <view class="addForm-big-box">
|
|
|
+ <!-- 状态 -->
|
|
|
+ <view class="addForm-input-box">
|
|
|
+ <view class="addForm-input-icon">*</view>
|
|
|
+ <view class="addForm-input-title">启用:</view>
|
|
|
+ <view>
|
|
|
+ <switch :checked="addForm.state" @change="switchChange" color="#0183FA" style="transform:scale(0.8)" />
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
+ <!-- 名称 -->
|
|
|
+ <view class="addForm-input-box">
|
|
|
+ <view class="addForm-input-icon">*</view>
|
|
|
+ <view class="addForm-input-title">名称:</view>
|
|
|
+ <input class="addForm-input" v-model="addForm.hardwareName" style="width:340rpx;" type="text" :maxlength="20"
|
|
|
+ placeholder="输入名称" placeholder-style="color:#999;">
|
|
|
+ </view>
|
|
|
+ <!-- 编号 -->
|
|
|
+ <view class="addForm-input-box">
|
|
|
+ <view class="addForm-input-icon">*</view>
|
|
|
+ <view class="addForm-input-title">编号:</view>
|
|
|
+ <input class="addForm-input" :disabled="!!addForm.id" v-model="addForm.hardwareNo" style="width:340rpx;"
|
|
|
+ type="text" :maxlength="20" placeholder="输入编号" placeholder-style="color:#999;">
|
|
|
+ </view>
|
|
|
+ <!-- 类型 -->
|
|
|
+ <view class="addForm-input-box">
|
|
|
+ <view class="addForm-input-icon">*</view>
|
|
|
+ <view class="addForm-input-title">类型:</view>
|
|
|
+ <picker @change="typeChange" :value="typeIndex" :range="typeNameList">
|
|
|
+ <view class="addForm-input" style="width:340rpx;" :class="!typeName?'addForm-input-placeholder':''">
|
|
|
+ {{typeName?typeName:'选择类型'}}
|
|
|
+ </view>
|
|
|
+ </picker>
|
|
|
+ </view>
|
|
|
+ <!-- 校区 -->
|
|
|
+ <view class="addForm-input-box">
|
|
|
+ <view class="addForm-input-icon">*</view>
|
|
|
+ <view class="addForm-input-title">校区:</view>
|
|
|
+ <picker @change="schoolChange" :value="schoolIndex" :range="schoolNameList">
|
|
|
+ <view class="addForm-input" style="width:340rpx;"
|
|
|
+ :class="!schoolName?'addForm-input-placeholder':''">
|
|
|
+ {{schoolName?schoolName:'选择校区'}}
|
|
|
+ </view>
|
|
|
+ </picker>
|
|
|
+ </view>
|
|
|
+ <!-- 楼栋 -->
|
|
|
+ <view class="addForm-input-box">
|
|
|
+ <view class="addForm-input-icon">*</view>
|
|
|
+ <view class="addForm-input-title">楼栋:</view>
|
|
|
+ <picker @change="buildChange" :value="buildIndex" :range="buildNameList">
|
|
|
+ <view class="addForm-input" style="width:340rpx;"
|
|
|
+ :class="!buildName?'addForm-input-placeholder':''">
|
|
|
+ {{buildName?buildName:'选择楼栋'}}
|
|
|
+ </view>
|
|
|
+ </picker>
|
|
|
+ </view>
|
|
|
+ <!-- 楼层 -->
|
|
|
+ <view class="addForm-input-box">
|
|
|
+ <view class="addForm-input-icon">*</view>
|
|
|
+ <view class="addForm-input-title">楼层:</view>
|
|
|
+ <picker @change="floorChange" :value="floorIndex" :range="floorNameList">
|
|
|
+ <view class="addForm-input" style="width:340rpx;"
|
|
|
+ :class="!floorName?'addForm-input-placeholder':''">
|
|
|
+ {{floorName?floorName:'选择楼层'}}
|
|
|
+ </view>
|
|
|
+ </picker>
|
|
|
+ </view>
|
|
|
+ <!-- 实验室 -->
|
|
|
+ <view class="addForm-input-box">
|
|
|
+ <view class="addForm-input-icon"></view>
|
|
|
+ <view class="addForm-input-title">实验室:</view>
|
|
|
+ <picker @change="subChange" :value="subIndex" :range="subNameList">
|
|
|
+ <view class="addForm-input" style="width:340rpx;"
|
|
|
+ :class="!subName?'addForm-input-placeholder':''">
|
|
|
+ {{subName?subName:'选择实验室'}}
|
|
|
+ </view>
|
|
|
+ </picker>
|
|
|
+ </view>
|
|
|
+ <!-- 物联设备 -->
|
|
|
+ <view class="addForm-input-box">
|
|
|
+ <view class="addForm-input-icon">*</view>
|
|
|
+ <view class="addForm-input-title">物联设备:</view>
|
|
|
+ <picker @change="relayChange" :value="relayIndex" :range="relayNameList">
|
|
|
+ <view class="addForm-input" style="width:340rpx;" :class="!relayName?'addForm-input-placeholder':''">
|
|
|
+ {{relayName?relayName:'选择物联设备'}}
|
|
|
+ </view>
|
|
|
+ </picker>
|
|
|
+ </view>
|
|
|
+ <!-- 参数A -->
|
|
|
+ <view class="addForm-input-box" v-if="reservedTypeOne">
|
|
|
+ <view class="addForm-input-icon">*</view>
|
|
|
+ <view class="addForm-input-title">{{reservedNameOne}}:</view>
|
|
|
+ <input class="addForm-input" v-model="addForm.reservedOne" style="width:340rpx;" type="text" :maxlength="20"
|
|
|
+ :placeholder="'请输入'+reservedNameOne" placeholder-style="color:#999;">
|
|
|
+ </view>
|
|
|
+ <!-- 参数B -->
|
|
|
+ <view class="addForm-input-box" v-if="reservedTypeTwo">
|
|
|
+ <view class="addForm-input-icon">*</view>
|
|
|
+ <view class="addForm-input-title">{{reservedNameTwo}}:</view>
|
|
|
+ <input class="addForm-input" v-model="addForm.reservedTwo" style="width:340rpx;" type="text" :maxlength="20"
|
|
|
+ :placeholder="'请输入'+reservedNameTwo" placeholder-style="color:#999;">
|
|
|
+ </view>
|
|
|
+ <!-- 参数C -->
|
|
|
+ <view class="addForm-input-box" v-if="reservedTypeThree">
|
|
|
+ <view class="addForm-input-icon">*</view>
|
|
|
+ <view class="addForm-input-title">{{reservedNameThree}}:</view>
|
|
|
+ <input class="addForm-input" v-model="addForm.reservedThree" style="width:340rpx;" type="text" :maxlength="20"
|
|
|
+ :placeholder="'请输入'+reservedNameThree" placeholder-style="color:#999;">
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
+ <view class="addForm-button-box">
|
|
|
+ <view class="button-null"></view>
|
|
|
+ <view class="button-view" @click="submitForm">提交</view>
|
|
|
+ <view class="button-null"></view>
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+ import {
|
|
|
+ systemBuildingGetTreeList,
|
|
|
+ laboratorySubRelInfoGetListByFloor,
|
|
|
+ iotHardwareFindHardwareType,
|
|
|
+ iotDeviceFindByType,
|
|
|
+ iotHardwareAdd,
|
|
|
+ iotHardwareUpdate,
|
|
|
+ iotAttributeDetail
|
|
|
+ } from '@/api/index.js'
|
|
|
+ export default {
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ addForm: {
|
|
|
+ hardwareName: "",
|
|
|
+ hardwareNo: "",
|
|
|
+ hardwareTypeId: "",
|
|
|
+ hardwareTypeKey: "",
|
|
|
+ hardwareTypeName: "",
|
|
|
+ deviceTypeKey: "",
|
|
|
+ deviceId: "",
|
|
|
+ deviceNo: "",
|
|
|
+ attributeId: "",
|
|
|
+ schoolId: '',
|
|
|
+ schoolName: '',
|
|
|
+ buildId: '',
|
|
|
+ buildName: '',
|
|
|
+ floorId: '',
|
|
|
+ floorName: '',
|
|
|
+ subjectId: '',
|
|
|
+ subjectName: '',
|
|
|
+ state: true,
|
|
|
+ reservedOne: "",
|
|
|
+ reservedTwo: "",
|
|
|
+ reservedThree: "",
|
|
|
+ },
|
|
|
+ //硬件类型下拉列表
|
|
|
+ typeList: [],
|
|
|
+ typeNameList: [],
|
|
|
+ typeIndex: 0,
|
|
|
+ typeName: '',
|
|
|
+ //继电器下拉列表
|
|
|
+ relayList: [],
|
|
|
+ relayNameList: [],
|
|
|
+ relayIndex: 0,
|
|
|
+ relayName: '',
|
|
|
+ //硬件参数数据
|
|
|
+ reservedNameOne: '',
|
|
|
+ reservedTypeOne: false,
|
|
|
+ reservedNameTwo: '',
|
|
|
+ reservedTypeTwo: false,
|
|
|
+ reservedNameThree: '',
|
|
|
+ reservedTypeThree: false,
|
|
|
+ //校区/楼栋/楼层树
|
|
|
+ treeOptions: [],
|
|
|
+ //校区
|
|
|
+ schoolList: [],
|
|
|
+ schoolNameList: [],
|
|
|
+ schoolIndex: 0,
|
|
|
+ schoolName: '',
|
|
|
+ //楼栋
|
|
|
+ buildList: [],
|
|
|
+ buildNameList: [],
|
|
|
+ buildIndex: 0,
|
|
|
+ buildName: '',
|
|
|
+ //楼层
|
|
|
+ floorList: [],
|
|
|
+ floorNameList: [],
|
|
|
+ floorIndex: 0,
|
|
|
+ floorName: '',
|
|
|
+ //实验室
|
|
|
+ subList: [],
|
|
|
+ subNameList: [],
|
|
|
+ subIndex: 0,
|
|
|
+ subName: '',
|
|
|
+ }
|
|
|
+ },
|
|
|
+ onLoad(option) {
|
|
|
+ Promise.all([
|
|
|
+ this.systemBuildingGetTreeList(),
|
|
|
+ this.iotHardwareFindHardwareType(),
|
|
|
+ ]).then((result) => {
|
|
|
+ if (option.item) {
|
|
|
+ this.initialize(option.item);
|
|
|
+ }
|
|
|
+ }).catch((error) => {
|
|
|
+ wx.showToast({
|
|
|
+ title: '数据异常,请稍候再试!',
|
|
|
+ icon: "none",
|
|
|
+ duration: 3000
|
|
|
+ });
|
|
|
+ })
|
|
|
+ },
|
|
|
+ onShow() {
|
|
|
+
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ //编辑-初始化
|
|
|
+ initialize(item) {
|
|
|
+ let obj = JSON.parse(decodeURIComponent(item));
|
|
|
+ this.$set(this, 'addForm', {
|
|
|
+ id: obj.id,
|
|
|
+ state: obj.state,
|
|
|
+ hardwareName: obj.hardwareName,
|
|
|
+ hardwareNo: obj.hardwareNo,
|
|
|
+ hardwareTypeId: obj.hardwareTypeId,
|
|
|
+ hardwareTypeKey: obj.hardwareTypeKey,
|
|
|
+ hardwareTypeName: obj.hardwareTypeName,
|
|
|
+ deviceTypeKey: obj.deviceTypeKey,
|
|
|
+ schoolId: obj.schoolId,
|
|
|
+ schoolName: obj.schoolName,
|
|
|
+ buildId: obj.buildId,
|
|
|
+ buildName: obj.buildName,
|
|
|
+ floorId: obj.floorId,
|
|
|
+ floorName: obj.floorName,
|
|
|
+ subjectId: obj.subjectId,
|
|
|
+ subjectName: obj.subjectName,
|
|
|
+ deviceId: obj.deviceId,
|
|
|
+ deviceNo: obj.deviceNo,
|
|
|
+ attributeId: obj.attributeId,
|
|
|
+ reservedOne: obj.reservedOne,
|
|
|
+ reservedTwo: obj.reservedTwo,
|
|
|
+ reservedThree: obj.reservedThree,
|
|
|
+ });
|
|
|
+ this.typeList.forEach((item) => {
|
|
|
+ if (obj.hardwareTypeId == item.hardwareTypeId) {
|
|
|
+ this.$set(this, 'typeName', item.hardwareTypeName);
|
|
|
+ }
|
|
|
+ })
|
|
|
+ this.iotAttributeDetail(obj.attributeId);
|
|
|
+ this.getAddress(obj);
|
|
|
+ },
|
|
|
+ //编辑匹配位置数据
|
|
|
+ async getAddress(item){
|
|
|
+ if(item.schoolId){
|
|
|
+ this.$set(this, 'schoolName', item.schoolName);
|
|
|
+ let buildList = [];
|
|
|
+ let buildNameList = [];
|
|
|
+ let floorList = [];
|
|
|
+ let floorNameList = [];
|
|
|
+ this.treeOptions.forEach((maxItem) => {
|
|
|
+ if (item.schoolId == maxItem.id && maxItem.buildFloorVoList[0]) {
|
|
|
+ maxItem.buildFloorVoList.forEach((bigItem) => {
|
|
|
+ buildList.push({
|
|
|
+ id: bigItem.id,
|
|
|
+ name: bigItem.name
|
|
|
+ })
|
|
|
+ buildNameList.push(bigItem.name);
|
|
|
+ if(item.buildId){
|
|
|
+ this.$set(this, 'buildName', item.buildName);
|
|
|
+ if(item.buildId == bigItem.id && bigItem.buildFloorVoList[0]){
|
|
|
+ bigItem.buildFloorVoList.forEach((minItem) => {
|
|
|
+ floorList.push({
|
|
|
+ id: minItem.id,
|
|
|
+ name: minItem.name
|
|
|
+ })
|
|
|
+ floorNameList.push(minItem.name);
|
|
|
+ })
|
|
|
+ if(item.floorId){
|
|
|
+ this.$set(this, 'floorName', item.floorName);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ this.$set(this, 'buildList', buildList);
|
|
|
+ this.$set(this, 'buildNameList', buildNameList);
|
|
|
+ this.$set(this, 'floorList', floorList);
|
|
|
+ this.$set(this, 'floorNameList', floorNameList);
|
|
|
+ if(item.schoolId && item.buildId && item.floorId){
|
|
|
+ const {
|
|
|
+ data
|
|
|
+ } = await laboratorySubRelInfoGetListByFloor({
|
|
|
+ floorId: item.floorId
|
|
|
+ });
|
|
|
+ if (data.code == 200) {
|
|
|
+ this.$set(this, 'subList', data.data);
|
|
|
+ let list = [];
|
|
|
+ data.data.forEach((subItem) => {
|
|
|
+ list.push(subItem.subName);
|
|
|
+ })
|
|
|
+ this.$set(this, 'subNameList', list);
|
|
|
+ this.$set(this, 'subIndex', 0);
|
|
|
+ if(item.subjectId){
|
|
|
+ this.$set(this, 'subName', item.subjectName);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ this.$nextTick(()=>{
|
|
|
+ this.iotDeviceFindByType(item.deviceId);
|
|
|
+ })
|
|
|
+ },
|
|
|
+ async iotAttributeDetail(attributeId){
|
|
|
+ const {
|
|
|
+ data
|
|
|
+ } = await iotAttributeDetail({id:attributeId});
|
|
|
+ if (data.code == 200) {
|
|
|
+ let list = data.data.relateField?JSON.parse(data.data.relateField):[];
|
|
|
+ list.forEach((item,index)=>{
|
|
|
+ if(index == 0){
|
|
|
+ if(item.state){
|
|
|
+ this.$set(this, 'reservedNameOne', item.relateFieldName)
|
|
|
+ this.$set(this, 'reservedTypeOne', true)
|
|
|
+ }else{
|
|
|
+ this.$set(this, 'reservedNameOne', '')
|
|
|
+ this.$set(this, 'reservedTypeOne', false)
|
|
|
+ }
|
|
|
+ }else if(index == 1){
|
|
|
+ if(item.state){
|
|
|
+ this.$set(this, 'reservedNameTwo', item.relateFieldName)
|
|
|
+ this.$set(this, 'reservedTypeTwo', true)
|
|
|
+ }else{
|
|
|
+ this.$set(this, 'reservedNameTwo', '')
|
|
|
+ this.$set(this, 'reservedTypeTwo', false)
|
|
|
+ }
|
|
|
+ }else if(index == 2){
|
|
|
+ if(item.state){
|
|
|
+ this.$set(this, 'reservedNameThree', item.relateFieldName)
|
|
|
+ this.$set(this, 'reservedTypeThree', true)
|
|
|
+ }else{
|
|
|
+ this.$set(this, 'reservedNameThree', '')
|
|
|
+ this.$set(this, 'reservedTypeThree', false)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ },
|
|
|
+ /***************** 地址查询相关 *****************/
|
|
|
+ //楼栋tree列表
|
|
|
+ async systemBuildingGetTreeList() {
|
|
|
+ const {
|
|
|
+ data
|
|
|
+ } = await systemBuildingGetTreeList();
|
|
|
+ if (data.code == 200) {
|
|
|
+ this.$set(this, 'treeOptions', data.data);
|
|
|
+ let list = [];
|
|
|
+ let nameList = [];
|
|
|
+ data.data.forEach((item) => {
|
|
|
+ list.push({
|
|
|
+ id: item.id,
|
|
|
+ name: item.name
|
|
|
+ })
|
|
|
+ nameList.push(item.name);
|
|
|
+ })
|
|
|
+ this.$set(this, 'schoolList', list);
|
|
|
+ this.$set(this, 'schoolNameList', nameList);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ //校区选中
|
|
|
+ schoolChange(event) {
|
|
|
+ if (this.schoolList[0]) {
|
|
|
+ this.$set(this, 'schoolIndex', event.target.value);
|
|
|
+ this.$set(this, 'schoolName', this.schoolList[event.target.value].name);
|
|
|
+ this.$set(this.addForm, 'schoolId', this.schoolList[event.target.value].id);
|
|
|
+ this.$set(this.addForm, 'schoolName', this.schoolList[event.target.value].name);
|
|
|
+ this.$set(this.addForm, 'buildId', '');
|
|
|
+ this.$set(this.addForm, 'buildName', '');
|
|
|
+ this.$set(this.addForm, 'floorId', '');
|
|
|
+ this.$set(this.addForm, 'floorName', '');
|
|
|
+ this.$set(this.addForm, 'subjectId', '');
|
|
|
+ this.$set(this.addForm, 'subjectName', '');
|
|
|
+ let list = [];
|
|
|
+ let nameList = [];
|
|
|
+ this.treeOptions.forEach((item) => {
|
|
|
+ if (this.schoolList[event.target.value].id == item.id && item.buildFloorVoList[0]) {
|
|
|
+ item.buildFloorVoList.forEach((minItem) => {
|
|
|
+ list.push({
|
|
|
+ id: minItem.id,
|
|
|
+ name: minItem.name
|
|
|
+ })
|
|
|
+ nameList.push(minItem.name);
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ this.$set(this, 'buildList', list);
|
|
|
+ this.$set(this, 'buildNameList', nameList);
|
|
|
+ this.$set(this, 'buildIndex', 0);
|
|
|
+ this.$set(this, 'buildName', '');
|
|
|
+ this.$set(this, 'floorList', []);
|
|
|
+ this.$set(this, 'floorNameList', []);
|
|
|
+ this.$set(this, 'floorIndex', 0);
|
|
|
+ this.$set(this, 'floorName', '');
|
|
|
+ this.$set(this, 'subList', []);
|
|
|
+ this.$set(this, 'subNameList', []);
|
|
|
+ this.$set(this, 'subIndex', 0);
|
|
|
+ this.$set(this, 'subName', '');
|
|
|
+ this.$set(this, 'relayIndex', 0);
|
|
|
+ this.$set(this, 'relayName', '');
|
|
|
+ this.$set(this.addForm, 'deviceId', '');
|
|
|
+ this.$set(this.addForm, 'deviceNo', '');
|
|
|
+ this.$set(this.addForm, 'attributeId', '');
|
|
|
+ this.$set(this, 'reservedNameOne', '')
|
|
|
+ this.$set(this, 'reservedTypeOne', false)
|
|
|
+ this.$set(this, 'reservedNameTwo', '')
|
|
|
+ this.$set(this, 'reservedTypeTwo', false)
|
|
|
+ this.$set(this, 'reservedNameThree', '')
|
|
|
+ this.$set(this, 'reservedTypeThree', false)
|
|
|
+ this.$nextTick(()=>{
|
|
|
+ this.iotDeviceFindByType();
|
|
|
+ })
|
|
|
+ }
|
|
|
+ },
|
|
|
+ //楼栋选中
|
|
|
+ buildChange(event) {
|
|
|
+ if (this.buildList[0]) {
|
|
|
+ this.$set(this, 'buildIndex', event.target.value);
|
|
|
+ this.$set(this, 'buildName', this.buildList[event.target.value].name);
|
|
|
+ this.$set(this.addForm, 'buildId', this.buildList[event.target.value].id);
|
|
|
+ this.$set(this.addForm, 'buildName', this.buildList[event.target.value].name);
|
|
|
+ this.$set(this.addForm, 'floorId', '');
|
|
|
+ this.$set(this.addForm, 'floorName', '');
|
|
|
+ this.$set(this.addForm, 'subjectId', '');
|
|
|
+ this.$set(this.addForm, 'subjectName', '');
|
|
|
+ let list = [];
|
|
|
+ let nameList = [];
|
|
|
+ this.treeOptions.forEach((item) => {
|
|
|
+ if (this.addForm.schoolId == item.id && item.buildFloorVoList[0]) {
|
|
|
+ item.buildFloorVoList.forEach((maxItem) => {
|
|
|
+ if (this.buildList[event.target.value].id == maxItem.id && maxItem.buildFloorVoList[0]) {
|
|
|
+ maxItem.buildFloorVoList.forEach((minItem) => {
|
|
|
+ list.push({
|
|
|
+ id: minItem.id,
|
|
|
+ name: minItem.name
|
|
|
+ })
|
|
|
+ nameList.push(minItem.name);
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ this.$set(this, 'floorList', list);
|
|
|
+ this.$set(this, 'floorNameList', nameList);
|
|
|
+ this.$set(this, 'floorIndex', 0);
|
|
|
+ this.$set(this, 'floorName', '');
|
|
|
+ this.$set(this, 'subList', []);
|
|
|
+ this.$set(this, 'subNameList', []);
|
|
|
+ this.$set(this, 'subIndex', 0);
|
|
|
+ this.$set(this, 'subName', '');
|
|
|
+ this.$set(this, 'relayIndex', 0);
|
|
|
+ this.$set(this, 'relayName', '');
|
|
|
+ this.$set(this.addForm, 'deviceId', '');
|
|
|
+ this.$set(this.addForm, 'deviceNo', '');
|
|
|
+ this.$set(this.addForm, 'attributeId', '');
|
|
|
+ this.$set(this, 'reservedNameOne', '')
|
|
|
+ this.$set(this, 'reservedTypeOne', false)
|
|
|
+ this.$set(this, 'reservedNameTwo', '')
|
|
|
+ this.$set(this, 'reservedTypeTwo', false)
|
|
|
+ this.$set(this, 'reservedNameThree', '')
|
|
|
+ this.$set(this, 'reservedTypeThree', false)
|
|
|
+ this.$nextTick(()=>{
|
|
|
+ this.iotDeviceFindByType();
|
|
|
+ })
|
|
|
+ }
|
|
|
+ },
|
|
|
+ //楼层选中
|
|
|
+ floorChange(event) {
|
|
|
+ if (this.floorList[0]) {
|
|
|
+ this.$set(this, 'floorIndex', event.target.value);
|
|
|
+ this.$set(this, 'floorName', this.floorList[event.target.value].name);
|
|
|
+ this.$set(this.addForm, 'floorId', this.floorList[event.target.value].id);
|
|
|
+ this.$set(this.addForm, 'floorName', this.floorList[event.target.value].name);
|
|
|
+ this.$set(this.addForm, 'subjectId', '');
|
|
|
+ this.$set(this.addForm, 'subjectName', '');
|
|
|
+ this.laboratorySubRelInfoGetListByFloor(this.floorList[event.target.value].id);
|
|
|
+ this.$set(this, 'relayIndex', 0);
|
|
|
+ this.$set(this, 'relayName', '');
|
|
|
+ this.$set(this.addForm, 'deviceId', '');
|
|
|
+ this.$set(this.addForm, 'deviceNo', '');
|
|
|
+ this.$set(this.addForm, 'attributeId', '');
|
|
|
+ this.$set(this, 'reservedNameOne', '')
|
|
|
+ this.$set(this, 'reservedTypeOne', false)
|
|
|
+ this.$set(this, 'reservedNameTwo', '')
|
|
|
+ this.$set(this, 'reservedTypeTwo', false)
|
|
|
+ this.$set(this, 'reservedNameThree', '')
|
|
|
+ this.$set(this, 'reservedTypeThree', false)
|
|
|
+ this.$nextTick(()=>{
|
|
|
+ this.iotDeviceFindByType();
|
|
|
+ })
|
|
|
+ }
|
|
|
+ },
|
|
|
+ //实验室选中
|
|
|
+ subChange(event) {
|
|
|
+ if (this.subList[0]) {
|
|
|
+ this.$set(this, 'subIndex', event.target.value);
|
|
|
+ this.$set(this, 'subName', this.subList[event.target.value].subName);
|
|
|
+ this.$set(this.addForm, 'subjectId', this.subList[event.target.value].subId);
|
|
|
+ this.$set(this.addForm, 'subjectName', this.subList[event.target.value].subName);
|
|
|
+ this.$set(this, 'relayIndex', 0);
|
|
|
+ this.$set(this, 'relayName', '');
|
|
|
+ this.$set(this.addForm, 'deviceId', '');
|
|
|
+ this.$set(this.addForm, 'deviceNo', '');
|
|
|
+ this.$set(this.addForm, 'attributeId', '');
|
|
|
+ this.$set(this, 'reservedNameOne', '')
|
|
|
+ this.$set(this, 'reservedTypeOne', false)
|
|
|
+ this.$set(this, 'reservedNameTwo', '')
|
|
|
+ this.$set(this, 'reservedTypeTwo', false)
|
|
|
+ this.$set(this, 'reservedNameThree', '')
|
|
|
+ this.$set(this, 'reservedTypeThree', false)
|
|
|
+ this.$nextTick(()=>{
|
|
|
+ this.iotDeviceFindByType();
|
|
|
+ })
|
|
|
+ }
|
|
|
+ },
|
|
|
+ //查询实验室
|
|
|
+ async laboratorySubRelInfoGetListByFloor(floorId) {
|
|
|
+ const {
|
|
|
+ data
|
|
|
+ } = await laboratorySubRelInfoGetListByFloor({
|
|
|
+ floorId: floorId
|
|
|
+ });
|
|
|
+ if (data.code == 200) {
|
|
|
+ this.$set(this, 'subList', data.data);
|
|
|
+ let list = [];
|
|
|
+ data.data.forEach((item) => {
|
|
|
+ list.push(item.subName);
|
|
|
+ })
|
|
|
+ this.$set(this, 'subNameList', list);
|
|
|
+ this.$set(this, 'subIndex', 0);
|
|
|
+ this.$set(this, 'subName', '');
|
|
|
+ }
|
|
|
+ },
|
|
|
+ //数据提交
|
|
|
+ submitForm() {
|
|
|
+ let self = this;
|
|
|
+ if (!this.addForm.hardwareName) {
|
|
|
+ uni.showToast({
|
|
|
+ mask: true,
|
|
|
+ icon: "none",
|
|
|
+ position: "center",
|
|
|
+ title: '请输入名称',
|
|
|
+ duration: 1000
|
|
|
+ });
|
|
|
+ return
|
|
|
+ } else if (!this.addForm.hardwareNo) {
|
|
|
+ uni.showToast({
|
|
|
+ mask: true,
|
|
|
+ icon: "none",
|
|
|
+ position: "center",
|
|
|
+ title: '请输入编号',
|
|
|
+ duration: 1000
|
|
|
+ });
|
|
|
+ return
|
|
|
+ } else if (!this.addForm.hardwareTypeId) {
|
|
|
+ uni.showToast({
|
|
|
+ mask: true,
|
|
|
+ icon: "none",
|
|
|
+ position: "center",
|
|
|
+ title: '请选择设备类型',
|
|
|
+ duration: 1000
|
|
|
+ });
|
|
|
+ return
|
|
|
+ } else if (!this.addForm.deviceId) {
|
|
|
+ uni.showToast({
|
|
|
+ mask: true,
|
|
|
+ icon: "none",
|
|
|
+ position: "center",
|
|
|
+ title: '请选择物联设备',
|
|
|
+ duration: 1000
|
|
|
+ });
|
|
|
+ return
|
|
|
+ }else if(!this.addForm.schoolId){
|
|
|
+ uni.showToast({
|
|
|
+ mask: true,
|
|
|
+ icon: "none",
|
|
|
+ position: "center",
|
|
|
+ title: '请选择校区',
|
|
|
+ duration: 1000
|
|
|
+ });
|
|
|
+ return
|
|
|
+ }else if(!this.addForm.buildId){
|
|
|
+ uni.showToast({
|
|
|
+ mask: true,
|
|
|
+ icon: "none",
|
|
|
+ position: "center",
|
|
|
+ title: '请选择楼栋',
|
|
|
+ duration: 1000
|
|
|
+ });
|
|
|
+ return
|
|
|
+ }else if(!this.addForm.floorId){
|
|
|
+ uni.showToast({
|
|
|
+ mask: true,
|
|
|
+ icon: "none",
|
|
|
+ position: "center",
|
|
|
+ title: '请选择楼层',
|
|
|
+ duration: 1000
|
|
|
+ });
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if(this.reservedTypeOne){
|
|
|
+ if(!this.addForm.reservedOne){
|
|
|
+ uni.showToast({
|
|
|
+ mask: true,
|
|
|
+ icon: "none",
|
|
|
+ position: "center",
|
|
|
+ title: '请选输入'+this.reservedNameOne,
|
|
|
+ duration: 1000
|
|
|
+ });
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(this.reservedTypeTwo){
|
|
|
+ if(!this.addForm.reservedTwo){
|
|
|
+ uni.showToast({
|
|
|
+ mask: true,
|
|
|
+ icon: "none",
|
|
|
+ position: "center",
|
|
|
+ title: '请选输入'+this.reservedNameTwo,
|
|
|
+ duration: 1000
|
|
|
+ });
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(this.reservedTypeThree){
|
|
|
+ if(!this.addForm.reservedThree){
|
|
|
+ uni.showToast({
|
|
|
+ mask: true,
|
|
|
+ icon: "none",
|
|
|
+ position: "center",
|
|
|
+ title: '请选输入'+this.reservedNameThree,
|
|
|
+ duration: 1000
|
|
|
+ });
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+ let obj = {
|
|
|
+ state: this.addForm.state,
|
|
|
+ hardwareName: this.addForm.hardwareName,
|
|
|
+ hardwareNo: this.addForm.hardwareNo,
|
|
|
+ hardwareTypeId: this.addForm.hardwareTypeId,
|
|
|
+ hardwareTypeKey: this.addForm.hardwareTypeKey,
|
|
|
+ hardwareTypeName: this.addForm.hardwareTypeName,
|
|
|
+ deviceTypeKey: this.addForm.deviceTypeKey,
|
|
|
+ schoolId:this.addForm.schoolId,
|
|
|
+ schoolName:this.addForm.schoolName,
|
|
|
+ buildId:this.addForm.buildId,
|
|
|
+ buildName:this.addForm.buildName,
|
|
|
+ floorId:this.addForm.floorId,
|
|
|
+ floorName:this.addForm.floorName,
|
|
|
+ subjectId:this.addForm.subjectId,
|
|
|
+ subjectName:this.addForm.subjectName,
|
|
|
+ deviceId: this.addForm.deviceId,
|
|
|
+ deviceNo: this.addForm.deviceNo,
|
|
|
+ attributeId: this.addForm.attributeId,
|
|
|
+ reservedOne: this.reservedTypeOne?this.addForm.reservedOne:'',
|
|
|
+ reservedTwo: this.reservedTypeTwo?this.addForm.reservedTwo:'',
|
|
|
+ reservedThree: this.reservedTypeThree?this.addForm.reservedThree:'',
|
|
|
+ }
|
|
|
+ uni.showModal({
|
|
|
+ title: '警告',
|
|
|
+ content: '是否确认提交?',
|
|
|
+ showCancel: true,
|
|
|
+ cancelColor: '#999999,',
|
|
|
+ confirmColor: '#0183FA',
|
|
|
+ success: (res) => {
|
|
|
+ if (res.confirm) {
|
|
|
+ if (self.addForm.id) {
|
|
|
+ obj.id = self.addForm.id;
|
|
|
+ self.iotHardwareUpdate(obj);
|
|
|
+ } else {
|
|
|
+ self.iotHardwareAdd(obj);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ fail: (res) => {}
|
|
|
+ })
|
|
|
+ },
|
|
|
+ //状态开关
|
|
|
+ switchChange(event) {
|
|
|
+ this.$set(this.addForm, 'state', event.target.value);
|
|
|
+ },
|
|
|
+ //设备类型选中
|
|
|
+ typeChange(event) {
|
|
|
+ if (this.typeList[0]) {
|
|
|
+ this.$set(this, 'typeIndex', event.target.value);
|
|
|
+ this.$set(this, 'typeName', this.typeList[event.target.value].hardwareTypeName);
|
|
|
+ this.$set(this.addForm, 'hardwareTypeId', this.typeList[event.target.value].hardwareTypeId);
|
|
|
+ this.$set(this.addForm, 'hardwareTypeKey', this.typeList[event.target.value].hardwareTypeKey);
|
|
|
+ this.$set(this.addForm, 'hardwareTypeName', this.typeList[event.target.value].hardwareTypeName);
|
|
|
+ this.$set(this.addForm, 'deviceTypeKey', this.typeList[event.target.value].deviceTypeKey);
|
|
|
+ this.$set(this, 'relayIndex', 0);
|
|
|
+ this.$set(this, 'relayName', '');
|
|
|
+ this.$set(this.addForm, 'deviceId', '');
|
|
|
+ this.$set(this.addForm, 'deviceNo', '');
|
|
|
+ this.$set(this.addForm, 'attributeId', '');
|
|
|
+ this.$set(this, 'reservedNameOne', '')
|
|
|
+ this.$set(this, 'reservedTypeOne', false)
|
|
|
+ this.$set(this, 'reservedNameTwo', '')
|
|
|
+ this.$set(this, 'reservedTypeTwo', false)
|
|
|
+ this.$set(this, 'reservedNameThree', '')
|
|
|
+ this.$set(this, 'reservedTypeThree', false)
|
|
|
+ this.$nextTick(()=>{
|
|
|
+ this.iotDeviceFindByType();
|
|
|
+ })
|
|
|
+ }
|
|
|
+ },
|
|
|
+ //物联设备选中
|
|
|
+ relayChange(event) {
|
|
|
+ if (this.relayList[0]) {
|
|
|
+ this.$set(this, 'relayIndex', event.target.value);
|
|
|
+ this.$set(this, 'relayName', this.relayList[event.target.value].deviceName);
|
|
|
+ this.$set(this.addForm, 'deviceId', this.relayList[event.target.value].id);
|
|
|
+ this.$set(this.addForm, 'deviceNo', this.relayList[event.target.value].deviceNo);
|
|
|
+ this.$set(this.addForm, 'attributeId', this.relayList[event.target.value].attributeId);
|
|
|
+ this.iotAttributeDetail(this.relayList[event.target.value].attributeId);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ //获取硬件类型
|
|
|
+ async iotHardwareFindHardwareType() {
|
|
|
+ const {
|
|
|
+ data
|
|
|
+ } = await iotHardwareFindHardwareType();
|
|
|
+ if (data.code == 200) {
|
|
|
+ this.$set(this, 'typeList', data.data);
|
|
|
+ let list = [];
|
|
|
+ data.data.forEach((item) => {
|
|
|
+ list.push(item.hardwareTypeName);
|
|
|
+ })
|
|
|
+ this.$set(this, 'typeNameList', list);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ //获取物联设备列表
|
|
|
+ async iotDeviceFindByType(deviceId) {
|
|
|
+ if(this.addForm.floorId&&this.addForm.deviceTypeKey){
|
|
|
+ const {
|
|
|
+ data
|
|
|
+ } = await iotDeviceFindByType({
|
|
|
+ floorId: this.addForm.floorId,
|
|
|
+ subjectId: this.addForm.subjectId,
|
|
|
+ typeKeyList: [this.addForm.deviceTypeKey]
|
|
|
+ });
|
|
|
+ if (data.code == 200) {
|
|
|
+ this.$set(this, 'relayList', data.data);
|
|
|
+ let list = [];
|
|
|
+ data.data.forEach((item) => {
|
|
|
+ list.push(item.deviceName);
|
|
|
+ if (deviceId) {
|
|
|
+ if (item.id == deviceId) {
|
|
|
+ this.$set(this, 'relayName', item.deviceName);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ this.$set(this, 'relayNameList', list);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ //新增
|
|
|
+ async iotHardwareAdd(obj) {
|
|
|
+ const {
|
|
|
+ data
|
|
|
+ } = await iotHardwareAdd(obj);
|
|
|
+ if (data.code == 200) {
|
|
|
+ uni.showToast({
|
|
|
+ mask: true,
|
|
|
+ icon: "none",
|
|
|
+ position: "center",
|
|
|
+ title: data.message,
|
|
|
+ duration: 2000
|
|
|
+ });
|
|
|
+ setTimeout(function() {
|
|
|
+ uni.navigateBack();
|
|
|
+ }, 1800);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ //编辑
|
|
|
+ async iotHardwareUpdate(obj) {
|
|
|
+ const {
|
|
|
+ data
|
|
|
+ } = await iotHardwareUpdate(obj);
|
|
|
+ if (data.code == 200) {
|
|
|
+ uni.showToast({
|
|
|
+ mask: true,
|
|
|
+ icon: "none",
|
|
|
+ position: "center",
|
|
|
+ title: data.message,
|
|
|
+ duration: 2000
|
|
|
+ });
|
|
|
+ setTimeout(function() {
|
|
|
+ uni.navigateBack();
|
|
|
+ }, 1800);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ }
|
|
|
+ }
|
|
|
+</script>
|
|
|
+
|
|
|
+<style lang="stylus" scoped>
|
|
|
+ #hardware-add-page {
|
|
|
+ display: flex;
|
|
|
+ flex: 1;
|
|
|
+ flex-direction: column;
|
|
|
+ overflow: hidden;
|
|
|
+
|
|
|
+ .addForm-max-big-box {
|
|
|
+ flex: 1;
|
|
|
+ overflow-x: hidden;
|
|
|
+ overflow-y: scroll;
|
|
|
+
|
|
|
+ .addForm-big-box {
|
|
|
+ background-color: #fff;
|
|
|
+ margin: 20rpx;
|
|
|
+ border-radius: 12rpx;
|
|
|
+ padding: 0 0 30rpx;
|
|
|
+
|
|
|
+ .addForm-input-box {
|
|
|
+ display: flex;
|
|
|
+ margin: 10rpx 0 0 10rpx;
|
|
|
+ font-size: 28rpx;
|
|
|
+ padding: 20rpx 0 0 0;
|
|
|
+
|
|
|
+ .addForm-input-icon {
|
|
|
+ color: #FF6666;
|
|
|
+ width: 40rpx;
|
|
|
+ margin-right: 10rpx;
|
|
|
+ text-align: right;
|
|
|
+ line-height: 60rpx;
|
|
|
+ }
|
|
|
+
|
|
|
+ .addForm-input-title {
|
|
|
+ width: 200rpx;
|
|
|
+ color: #333;
|
|
|
+ line-height: 60rpx;
|
|
|
+ }
|
|
|
+
|
|
|
+ .addForm-input {
|
|
|
+ padding: 0 20rpx;
|
|
|
+ height: 60rpx;
|
|
|
+ line-height: 60rpx;
|
|
|
+ font-size: 26rpx;
|
|
|
+ border-radius: 8rpx;
|
|
|
+ border: 1px solid #dedede;
|
|
|
+ }
|
|
|
+
|
|
|
+ .addForm-input-placeholder {
|
|
|
+ color: #999 !important;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ .addForm-button-box {
|
|
|
+ height: 80rpx;
|
|
|
+ display: flex;
|
|
|
+
|
|
|
+ .button-null {
|
|
|
+ flex: 1;
|
|
|
+ }
|
|
|
+
|
|
|
+ .button-view {
|
|
|
+ width: 260rpx;
|
|
|
+ margin: 10rpx 0 0 0;
|
|
|
+ background-color: #0183FA;
|
|
|
+ color: #fff;
|
|
|
+ font-size: 26rpx;
|
|
|
+ text-align: center;
|
|
|
+ line-height: 60rpx;
|
|
|
+ height: 60rpx;
|
|
|
+ border-radius: 12rpx;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+</style>
|