<!-- 围栏管理表单组件 -->
|
<template>
|
<view class="m-form">
|
<view class="m-form-head"><u-icon name="close-circle" color="#fff" size="40" @click="cancel"></u-icon></view>
|
<!-- 修改 -->
|
<view class="m-form-label" v-if="railType=='update'">
|
<u--form labelPosition="left" labelAlign="right" :model="model" :rules="rules" ref="form" labelWidth="100" :labelStyle="{'color':'rgb(129, 129, 129)'}">
|
<u-form-item label="围栏名称" prop="name" borderBottom ref="item">
|
<u--input :customStyle="{ 'background-color': 'rgb(233, 233, 233)','box-shadow':'inset 2px 1.464px 5px 0px #ccccc4, 1.464px 1.464px 5px 0px rgba(255, 255, 255, 0.75)'}" placeholderStyle="color:#000" color="#000" v-model="model.name" border="none"></u--input>
|
</u-form-item>
|
<u-form-item label="关联部门" prop="bumen" borderBottom ref="item">
|
<uni-data-select v-model="value_bumen" :localdata="rangeBuMen" @change="changeRangeBuMen"></uni-data-select>
|
</u-form-item>
|
<u-form-item label="告警高度" prop="baoliu1" borderBottom ref="item">
|
<u--input :customStyle="{ 'background-color': 'rgb(233, 233, 233)','box-shadow':'inset 2px 1.464px 5px 0px #ccccc4, 1.464px 1.464px 5px 0px rgba(255, 255, 255, 0.75)'}" placeholderStyle="color:#000" color="#000" v-model="model.baoliu1" border="none"></u--input>
|
</u-form-item>
|
<!-- <u-form-item label="启用围栏" prop="valueSwitch" borderBottom ref="item">
|
<u-switch v-model="model.valueSwitch" asyncChange @change="asyncChange"></u-switch>
|
</u-form-item> -->
|
</u--form>
|
</view>
|
<view class="m-form-button-list">
|
<u-button type="primary" text="确定" @click="save"></u-button>
|
</view>
|
</view>
|
</template>
|
|
<script>
|
import { connChart } from '@/common/utils.js';
|
export default {
|
props: {
|
railType:String,
|
railFormData:Object
|
},
|
data() {
|
return {
|
model: {
|
valueSwitch:false,
|
baoliu1:'',
|
name:'',
|
id:'',
|
bumen:'',
|
zuobiao:null,
|
start:null,
|
stop:null
|
},
|
rules: {
|
baoliu1: {
|
validator: (rule, value, callback) => {
|
// 返回true表示校验通过,返回false表示不通过
|
var pattern=/^\d+(\.\d{1,2})?$/;
|
return pattern.test(value);
|
},
|
required: true,
|
message: '精度0.01m',
|
trigger: ['blur', 'change']
|
},
|
},
|
value_bumen:'',
|
rangeBuMen: [],
|
};
|
},
|
methods: {
|
//保存
|
save() {
|
var labelModel = connChart('fence');
|
labelModel.update(`id=${this.model.id}`,{
|
bumen:this.model.bumen,
|
name:this.model.name,
|
baoliu1:this.model.baoliu1
|
},(err,results)=>{
|
console.log(results);
|
this.$emit('submitRailForm');
|
});
|
},
|
//取消
|
cancel() {
|
this.$emit('cancelRailForm');
|
},
|
//启用围栏-开关
|
asyncChange(e) {
|
this.model.valueSwitch = e;
|
// uni.showModal({
|
// content: e ? '确定要打开吗' : '确定要关闭吗',
|
// confirmColor:"#68B0FE",
|
// cancelColor:"#68B0FE",
|
// success: res => {
|
// if (res.confirm) {
|
// this.model.valueSwitch = e;
|
// }
|
// }
|
// });
|
},
|
//部门查询
|
jiedepartment(){
|
var labelModel = connChart('department');
|
labelModel.find((e,r)=>{
|
console.log(e,r)
|
if(r.length!=0){
|
r.forEach(e => {
|
this.rangeBuMen.push({
|
text: e.department_name,
|
value: e.department_name
|
});
|
});
|
}
|
})
|
},
|
changeRangeBuMen(e){
|
this.value_bumen=e
|
this.model.bumen=e
|
},
|
},
|
mounted() {
|
if(this.railType=='update'){
|
this.model=this.railFormData
|
this.value_bumen=this.model.bumen
|
}
|
this.jiedepartment()
|
}
|
};
|
</script>
|
|
<style lang="scss" scoped>
|
.m-form {
|
position: fixed;
|
top: 50%;
|
left: 50%;
|
transform: translate(-50%, -50%);
|
background-color: rgba(233, 233, 233,0.8);
|
width: 60%;
|
display: flex;
|
flex-direction: column;
|
z-index: 99999;
|
}
|
.m-form-head {
|
width: 100%;
|
border-bottom: 1px solid #fff;
|
}
|
.m-form-head .u-icon {
|
float: right;
|
}
|
/deep/ .u-form-item__body__left__content__label {
|
color: #fff;
|
}
|
.m-form-label {
|
width: 80%;
|
margin: 0 auto;
|
margin-bottom: 0.5em;
|
}
|
input{
|
width: 50px;
|
}
|
.m-form-button-list {
|
width: 100%;
|
display: flex;
|
flex-direction: column;
|
align-items: center;
|
justify-content: center;
|
margin-bottom: 1em;
|
}
|
.m-form-button-list .u-button {
|
width: 5em;
|
}
|
.m-form-button-list .u-button:nth-child(2),
|
.m-form-button-list .u-button:nth-child(3),
|
.m-form-button-list .u-button:nth-child(4) {
|
margin-top: 2em;
|
}
|
</style>
|