2020-02-21 17:57:19 +08:00
|
|
|
|
<template>
|
2020-07-16 17:33:20 +08:00
|
|
|
|
<div class="right-box right-box-dc" v-clickoutside="clickOutside">
|
2020-02-21 17:57:19 +08:00
|
|
|
|
<!-- begin--顶部按钮-->
|
2020-10-15 14:27:46 +08:00
|
|
|
|
<div class="right-box-top-btns right-box-form-delete">
|
|
|
|
|
|
<button id="dc-del" type="button" v-if="editDc.id" @click="del" class="nz-btn nz-btn-size-normal nz-btn-size-alien">
|
2020-09-10 17:00:32 +08:00
|
|
|
|
<span class="right-box-top-btn-icon"><i class="nz-icon nz-icon-delete"></i></span>
|
2020-02-21 17:57:19 +08:00
|
|
|
|
<span class="right-box-top-btn-txt">{{$t('overall.delete')}}</span>
|
|
|
|
|
|
</button>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<!-- end--顶部按钮-->
|
|
|
|
|
|
|
|
|
|
|
|
<!-- begin--标题-->
|
2020-07-30 18:58:25 +08:00
|
|
|
|
<div class="right-box-title">{{editDc.id ? ($t("config.dc.editDc") + " ID:" + editDc.id) : $t("config.dc.createDc")}}</div>
|
2020-02-21 17:57:19 +08:00
|
|
|
|
<!-- end--标题-->
|
|
|
|
|
|
|
|
|
|
|
|
<!-- begin--表单-->
|
|
|
|
|
|
<el-scrollbar class="right-box-form-box">
|
2020-07-16 17:33:20 +08:00
|
|
|
|
<el-form class="right-box-form right-box-form-left" label-width="120px" :model="editDc" label-position="right" :rules="rules" ref="dcForm">
|
2020-02-21 17:57:19 +08:00
|
|
|
|
<el-form-item :label='$t("overall.name")' prop="name">
|
2020-07-16 17:33:20 +08:00
|
|
|
|
<el-input placeholder="" maxlength="64" show-word-limit v-model="editDc.name" size="small"></el-input>
|
2020-02-21 17:57:19 +08:00
|
|
|
|
</el-form-item>
|
2020-07-24 19:22:52 +08:00
|
|
|
|
<el-form-item :label='$t("asset.location")' prop="location">
|
2020-07-16 17:33:20 +08:00
|
|
|
|
<el-input placeholder="" v-model="editDc.location" size="small"></el-input>
|
2020-02-21 17:57:19 +08:00
|
|
|
|
</el-form-item>
|
2020-07-24 19:22:52 +08:00
|
|
|
|
<el-form-item :label='$t("asset.tel")' prop="tel">
|
2020-07-16 17:33:20 +08:00
|
|
|
|
<el-input placeholder="" v-model="editDc.tel" size="small"></el-input>
|
2020-02-24 15:26:51 +08:00
|
|
|
|
</el-form-item>
|
2020-07-24 19:22:52 +08:00
|
|
|
|
<el-form-item :label='$t("asset.principal")' prop="principal">
|
2020-07-16 17:33:20 +08:00
|
|
|
|
<el-select value-key="id" popper-class="config-dropdown" v-model="editDc.principal" placeholder="" size="small">
|
|
|
|
|
|
<el-option @click.native="" v-for="item in userData" :key="item.userId" :label="item.username" :value="item.userId" :id="'dc-principal-op-'+item.userId">
|
2020-02-24 15:26:51 +08:00
|
|
|
|
<span>{{item.username}}</span>
|
|
|
|
|
|
</el-option>
|
|
|
|
|
|
</el-select>
|
|
|
|
|
|
</el-form-item>
|
2020-11-11 13:59:37 +08:00
|
|
|
|
<!--<el-form-item :label='$t("config.dc.area")' prop="area">-->
|
|
|
|
|
|
<!--<select-area ref="selectArea" :areaData="areaData" :placement="'bottom-start'" @selectArea="selectArea" :currentArea="editDc.area.id">-->
|
|
|
|
|
|
<!--<template v-slot:trigger>-->
|
|
|
|
|
|
<!--<el-input placeholder="" v-model="editDc.area.name" size="small" readonly="readonly" @click.native="toSelectArea"></el-input>-->
|
|
|
|
|
|
<!--</template>-->
|
|
|
|
|
|
<!--</select-area>-->
|
|
|
|
|
|
<!--</el-form-item>-->
|
|
|
|
|
|
<el-form-item :label='$t("config.dc.state")' prop="state">
|
2020-11-11 14:30:34 +08:00
|
|
|
|
<el-switch
|
|
|
|
|
|
v-model="editDc.state"
|
|
|
|
|
|
active-value="ON"
|
|
|
|
|
|
inactive-value="OFF"
|
|
|
|
|
|
active-color="#ee9d3f"
|
|
|
|
|
|
>
|
|
|
|
|
|
</el-switch>
|
2020-11-11 13:59:37 +08:00
|
|
|
|
</el-form-item>
|
2020-11-12 10:42:49 +08:00
|
|
|
|
<el-form-item :label='$t("config.dc.longitude")' prop="longitude" :rules="[{required:coordinateFlag,trigger:'blur'}]">
|
2020-11-11 13:59:37 +08:00
|
|
|
|
<el-input-number
|
|
|
|
|
|
placeholder=""
|
|
|
|
|
|
v-model="editDc.longitude"
|
|
|
|
|
|
size="small"
|
|
|
|
|
|
controls-position="right"
|
|
|
|
|
|
:min="-180"
|
|
|
|
|
|
:max="180"
|
|
|
|
|
|
:step="0.00001"
|
|
|
|
|
|
:precision="5"
|
2020-11-12 10:42:49 +08:00
|
|
|
|
@change="(val)=>{coordinateChange(val,'longitude')}"
|
2020-11-11 13:59:37 +08:00
|
|
|
|
/>
|
|
|
|
|
|
</el-form-item>
|
2020-11-12 10:42:49 +08:00
|
|
|
|
<el-form-item :label='$t("config.dc.latitude")' prop="latitude" :rules="[{required:coordinateFlag,trigger:'blur'}]">
|
2020-11-11 13:59:37 +08:00
|
|
|
|
<el-input-number
|
|
|
|
|
|
placeholder=""
|
|
|
|
|
|
v-model="editDc.latitude"
|
|
|
|
|
|
size="small"
|
|
|
|
|
|
controls-position="right"
|
|
|
|
|
|
:min="-90"
|
|
|
|
|
|
:max="90"
|
|
|
|
|
|
:step="0.00001"
|
|
|
|
|
|
:precision="5"
|
2020-11-12 10:42:49 +08:00
|
|
|
|
@change="(val)=>{coordinateChange(val,'latitude')}"
|
2020-11-11 13:59:37 +08:00
|
|
|
|
/>
|
2020-02-24 15:26:51 +08:00
|
|
|
|
</el-form-item>
|
2020-02-21 17:57:19 +08:00
|
|
|
|
</el-form>
|
|
|
|
|
|
</el-scrollbar>
|
|
|
|
|
|
|
|
|
|
|
|
<!--底部按钮-->
|
|
|
|
|
|
<div class="right-box-bottom-btns">
|
2020-10-13 14:30:57 +08:00
|
|
|
|
<button @click="esc" id="dc-box-esc" class="nz-btn nz-btn-size-normal-new nz-btn-style-light-new">
|
2020-02-21 17:57:19 +08:00
|
|
|
|
<span>{{$t('overall.cancel')}}</span>
|
|
|
|
|
|
</button>
|
2020-10-13 14:30:57 +08:00
|
|
|
|
<button @click="save" id="dc-box-save" class="nz-btn nz-btn-size-normal-new nz-btn-style-normal-new">
|
2020-02-21 17:57:19 +08:00
|
|
|
|
<span>{{$t('overall.save')}}</span>
|
|
|
|
|
|
</button>
|
|
|
|
|
|
</div>
|
2020-02-24 20:27:14 +08:00
|
|
|
|
|
2020-02-21 17:57:19 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<script>
|
2020-07-16 17:33:20 +08:00
|
|
|
|
import selectArea from "../popBox/selectArea"; //dc弹框
|
2020-11-11 13:59:37 +08:00
|
|
|
|
var regNum = /^[0-9]+.?[0-9]*/;
|
2020-02-21 17:57:19 +08:00
|
|
|
|
export default {
|
|
|
|
|
|
name: "dcBox",
|
|
|
|
|
|
props: {
|
2020-02-24 15:26:51 +08:00
|
|
|
|
dc: Object,
|
|
|
|
|
|
userData: Array
|
2020-02-21 17:57:19 +08:00
|
|
|
|
},
|
2020-07-16 17:33:20 +08:00
|
|
|
|
components:{
|
|
|
|
|
|
'select-area': selectArea
|
|
|
|
|
|
},
|
2020-02-21 17:57:19 +08:00
|
|
|
|
data() {
|
|
|
|
|
|
return {
|
2020-07-16 17:33:20 +08:00
|
|
|
|
editDc: {},
|
2020-02-21 17:57:19 +08:00
|
|
|
|
rules: {
|
|
|
|
|
|
name: [
|
2020-02-24 20:27:14 +08:00
|
|
|
|
{required: true, message: this.$t('validate.required'), trigger: 'blur'}
|
2020-02-21 17:57:19 +08:00
|
|
|
|
],
|
2020-11-11 13:59:37 +08:00
|
|
|
|
state:[
|
|
|
|
|
|
{required: true, message: this.$t('validate.required'), trigger: 'blur'}
|
|
|
|
|
|
]
|
2020-02-21 17:57:19 +08:00
|
|
|
|
},
|
2020-02-24 15:26:51 +08:00
|
|
|
|
areaData: [],
|
2020-11-12 10:42:49 +08:00
|
|
|
|
coordinateFlag:false,
|
2020-02-21 17:57:19 +08:00
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
methods: {
|
|
|
|
|
|
/*关闭弹框*/
|
2020-07-16 17:33:20 +08:00
|
|
|
|
esc(refresh) {
|
|
|
|
|
|
this.$emit("close", refresh);
|
|
|
|
|
|
},
|
|
|
|
|
|
clickOutside() {
|
|
|
|
|
|
this.esc(false);
|
2020-02-21 17:57:19 +08:00
|
|
|
|
},
|
2020-02-24 20:27:14 +08:00
|
|
|
|
/*弹出选择area弹框*/
|
|
|
|
|
|
toSelectArea() {
|
2020-07-16 17:33:20 +08:00
|
|
|
|
this.$refs.selectArea.openBox(this.editDc.area);
|
2020-02-24 20:27:14 +08:00
|
|
|
|
},
|
|
|
|
|
|
|
2020-02-21 17:57:19 +08:00
|
|
|
|
/*保存*/
|
|
|
|
|
|
save() {
|
|
|
|
|
|
this.$refs.dcForm.validate((valid) => {
|
|
|
|
|
|
if (valid) {
|
2020-07-16 17:33:20 +08:00
|
|
|
|
if (this.editDc.id) {
|
2020-11-11 13:59:37 +08:00
|
|
|
|
let param={...this.editDc};
|
|
|
|
|
|
if (param.area) {
|
|
|
|
|
|
param.areaId = param.area.id;
|
|
|
|
|
|
}
|
|
|
|
|
|
if(!regNum.test(param.longitude)){
|
2020-11-11 14:30:34 +08:00
|
|
|
|
param.longitude=null
|
2020-11-11 13:59:37 +08:00
|
|
|
|
}
|
|
|
|
|
|
if(!regNum.test(param.latitude)){
|
2020-11-11 14:30:34 +08:00
|
|
|
|
param.latitude=null
|
2020-02-24 20:27:14 +08:00
|
|
|
|
}
|
2020-11-11 13:59:37 +08:00
|
|
|
|
|
|
|
|
|
|
this.$put('idc', param).then(response => {
|
2020-02-21 17:57:19 +08:00
|
|
|
|
if (response.code === 200) {
|
|
|
|
|
|
this.$message({duration: 1000, type: 'success', message: this.$t("tip.saveSuccess")});
|
2020-07-16 17:33:20 +08:00
|
|
|
|
this.esc(true);
|
2020-02-21 17:57:19 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
this.$message.error(response.msg);
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
} else {
|
2020-11-11 13:59:37 +08:00
|
|
|
|
let param={...this.editDc}
|
|
|
|
|
|
if (param.area) {
|
|
|
|
|
|
param.areaId = param.area.id;
|
|
|
|
|
|
}
|
|
|
|
|
|
if(!regNum.test(param.longitude)){
|
2020-11-11 14:30:34 +08:00
|
|
|
|
param.longitude=null;
|
2020-11-11 13:59:37 +08:00
|
|
|
|
}
|
|
|
|
|
|
if(!regNum.test(param.latitude)){
|
2020-11-11 14:30:34 +08:00
|
|
|
|
param.latitude=null;
|
2020-02-24 20:27:14 +08:00
|
|
|
|
}
|
2020-11-11 13:59:37 +08:00
|
|
|
|
this.$post('idc', param).then(response => {
|
2020-02-21 17:57:19 +08:00
|
|
|
|
if (response.code === 200) {
|
|
|
|
|
|
this.$message({duration: 1000, type: 'success', message: this.$t("tip.saveSuccess")});
|
2020-07-16 17:33:20 +08:00
|
|
|
|
this.esc(true);
|
2020-02-21 17:57:19 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
this.$message.error(response.msg);
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
} else {
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
},
|
|
|
|
|
|
/*删除*/
|
|
|
|
|
|
del() {
|
|
|
|
|
|
this.$confirm(this.$t("tip.confirmDelete"), {
|
|
|
|
|
|
confirmButtonText: this.$t("tip.yes"),
|
|
|
|
|
|
cancelButtonText: this.$t("tip.no"),
|
|
|
|
|
|
type: 'warning'
|
|
|
|
|
|
}).then(() => {
|
2020-07-16 17:33:20 +08:00
|
|
|
|
this.$delete("idc?ids=" + this.editDc.id).then(response => {
|
2020-02-21 17:57:19 +08:00
|
|
|
|
if (response.code === 200) {
|
|
|
|
|
|
this.$message({duration: 1000, type: 'success', message: this.$t("tip.deleteSuccess")});
|
2020-07-16 17:33:20 +08:00
|
|
|
|
this.esc(true);
|
2020-02-21 17:57:19 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
this.$message.error(response.msg);
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
});
|
|
|
|
|
|
},
|
2020-11-11 13:59:37 +08:00
|
|
|
|
// getAreaData() {
|
|
|
|
|
|
// this.$get('area', {pid: 0}).then(response => {
|
|
|
|
|
|
// if (response.code === 200) {
|
|
|
|
|
|
// this.areaData = response.data.list;
|
|
|
|
|
|
// }
|
|
|
|
|
|
// });
|
|
|
|
|
|
// },
|
2020-02-24 15:26:51 +08:00
|
|
|
|
|
2020-02-24 20:27:14 +08:00
|
|
|
|
selectArea(area) {
|
2020-07-16 17:33:20 +08:00
|
|
|
|
this.editDc.area.id = area.id;
|
|
|
|
|
|
this.editDc.area.name = area.name;
|
2020-11-12 10:42:49 +08:00
|
|
|
|
},
|
|
|
|
|
|
coordinateChange(val,str){//经纬度改变
|
|
|
|
|
|
if(regNum.test(this.editDc.longitude) || regNum.test(this.editDc.latitude)){
|
|
|
|
|
|
this.coordinateFlag=true
|
|
|
|
|
|
}else{
|
|
|
|
|
|
this.coordinateFlag=false;
|
|
|
|
|
|
this.$refs['dcForm'].clearValidate(['longitude','latitude'])
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
2020-02-21 17:57:19 +08:00
|
|
|
|
},
|
2020-02-24 15:26:51 +08:00
|
|
|
|
mounted() {
|
2020-11-11 13:59:37 +08:00
|
|
|
|
// this.getAreaData();
|
2020-02-21 17:57:19 +08:00
|
|
|
|
},
|
|
|
|
|
|
watch: {
|
|
|
|
|
|
dc: {
|
|
|
|
|
|
immediate: true,
|
|
|
|
|
|
deep:true,
|
|
|
|
|
|
handler(n, o) {
|
2020-07-16 17:33:20 +08:00
|
|
|
|
this.editDc = JSON.parse(JSON.stringify(n));
|
2020-02-21 17:57:19 +08:00
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
</script>
|