2020-01-03 16:04:23 +08:00
|
|
|
|
<template>
|
2020-01-17 10:43:35 +08:00
|
|
|
|
<el-popover :placement="placement" @show="afterShow" width="400" @hide="hidePop" ref="popBox" v-model="popBox.show" popper-class="nz-pop">
|
2020-01-09 19:30:43 +08:00
|
|
|
|
<div class="">
|
2020-01-07 17:41:46 +08:00
|
|
|
|
<!-- begin--顶部按钮-->
|
|
|
|
|
|
<div class="pop-top-btns">
|
2020-01-17 15:06:09 +08:00
|
|
|
|
<button type="button" v-if="idc.id && idc.id != ''&& popBox.isEdit" @click="del" class="nz-btn nz-btn-size-small nz-btn-size-alien nz-btn-style-light nz-btn-min-width-60" id="dc-del">
|
2020-01-17 09:54:01 +08:00
|
|
|
|
<span class="pop-top-btn-icon"><i class="el-icon-delete"></i></span>
|
|
|
|
|
|
<span class="pop-top-btn-txt">{{$t('overall.delete')}}</span>
|
2020-01-07 17:41:46 +08:00
|
|
|
|
</button>
|
2020-01-17 09:54:01 +08:00
|
|
|
|
<button type="button" @click="saveOrToEdit" class="nz-btn nz-btn-size-alien nz-btn-size-small nz-btn-style-light nz-btn-min-width-60" id="dc-save">
|
|
|
|
|
|
<span class="pop-top-btn-icon"><i class="nz-icon nz-icon-edit"></i></span>
|
|
|
|
|
|
<span class="pop-top-btn-txt" v-if="popBox.isEdit">{{$t('overall.save')}}</span>
|
|
|
|
|
|
<span class="pop-top-btn-txt" v-else>{{$t('overall.edit')}}</span>
|
2020-01-07 17:41:46 +08:00
|
|
|
|
</button>
|
2020-01-03 16:04:23 +08:00
|
|
|
|
|
2020-01-17 09:54:01 +08:00
|
|
|
|
<button type="button" @click="esc" class="nz-btn nz-btn-size-alien nz-btn-size-small nz-btn-style-light nz-btn-min-width-35" id="dc-esc">
|
|
|
|
|
|
<span class="pop-top-btn-icon"><i class="el-icon-close"></i></span>
|
|
|
|
|
|
<span class="pop-top-btn-txt">{{$t('overall.esc')}}</span>
|
2020-01-07 17:41:46 +08:00
|
|
|
|
</button>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<!-- end--顶部按钮-->
|
|
|
|
|
|
<div class="pop-title">{{title}}</div>
|
|
|
|
|
|
|
|
|
|
|
|
<div class="pop-item-wider">
|
|
|
|
|
|
<el-form class="right-box-form" :model="idc" label-position="left" label-width="150px" :rules="rules" ref="idcForm">
|
|
|
|
|
|
<el-form-item :label="$t('asset.createAssetTab.dcName')" prop="name">
|
2020-01-10 18:16:25 +08:00
|
|
|
|
<el-input type="text" placeholder="" v-model="idc.name" size="mini" maxlength="64" v-if="popBox.isEdit"></el-input>
|
|
|
|
|
|
<div class="right-box-form-content-txt" v-if="!popBox.isEdit">{{idc.name}}</div>
|
2020-01-07 17:41:46 +08:00
|
|
|
|
</el-form-item>
|
|
|
|
|
|
<el-form-item :label="$t('asset.createAssetTab.location')" prop="location">
|
2020-01-10 18:16:25 +08:00
|
|
|
|
<el-input type="text" placeholder="" v-model="idc.location" size="mini" v-if="popBox.isEdit"></el-input>
|
|
|
|
|
|
<div class="right-box-form-content-txt" v-if="!popBox.isEdit">{{idc.location}}</div>
|
2020-01-07 17:41:46 +08:00
|
|
|
|
</el-form-item>
|
|
|
|
|
|
<el-form-item :label="$t('asset.createAssetTab.principal')" prop="principal">
|
2020-01-10 18:16:25 +08:00
|
|
|
|
<el-select v-model="idc.principal" clearable size="mini" placeholder="" v-if="popBox.isEdit">
|
2020-01-07 17:41:46 +08:00
|
|
|
|
<el-option v-for="item in principals" :key="item.id" :label="item.username" :value="item.userId"></el-option>
|
|
|
|
|
|
</el-select>
|
2020-01-10 18:16:25 +08:00
|
|
|
|
<div class="right-box-form-content-txt" v-if="!popBox.isEdit">{{idc.principal}}</div>
|
2020-01-07 17:41:46 +08:00
|
|
|
|
</el-form-item>
|
2020-01-10 18:16:25 +08:00
|
|
|
|
<el-form-item :label="$t('asset.createAssetTab.tel')" prop="tel" >
|
|
|
|
|
|
<el-input type="text" placeholder="" v-model="idc.tel" size="mini" v-if="popBox.isEdit"></el-input>
|
|
|
|
|
|
<div class="right-box-form-content-txt" v-if="!popBox.isEdit">{{idc.tel}}</div>
|
2020-01-07 17:41:46 +08:00
|
|
|
|
</el-form-item>
|
|
|
|
|
|
</el-form>
|
|
|
|
|
|
</div>
|
2020-01-03 16:04:23 +08:00
|
|
|
|
</div>
|
2020-01-13 18:48:25 +08:00
|
|
|
|
<span :class="buttonClass" @click.prevent.stop="" slot="reference" :id="'edit-idc-'+Math.random().toString(36).slice(-8)">
|
2020-01-09 19:30:43 +08:00
|
|
|
|
<slot name="optionZone">
|
2020-01-13 18:48:25 +08:00
|
|
|
|
<i class="el-icon-plus" id="dc-plus"></i>
|
2020-01-03 16:04:23 +08:00
|
|
|
|
</slot>
|
|
|
|
|
|
</span>
|
|
|
|
|
|
</el-popover>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<script>
|
2020-01-16 17:54:04 +08:00
|
|
|
|
import {phone} from '../../common/js/validate'
|
2020-01-03 16:04:23 +08:00
|
|
|
|
export default {
|
|
|
|
|
|
name: "dcConfig",
|
|
|
|
|
|
props:{
|
|
|
|
|
|
postIdc:{type:Object},
|
|
|
|
|
|
placement:{type:String},
|
2020-01-10 18:16:25 +08:00
|
|
|
|
buttonClass:{type:String},
|
2020-02-06 12:35:29 +08:00
|
|
|
|
isEdit:{type:Boolean,default:true},
|
|
|
|
|
|
userData:{type:Array}
|
2020-01-03 16:04:23 +08:00
|
|
|
|
},
|
|
|
|
|
|
created() {
|
|
|
|
|
|
this.init();
|
|
|
|
|
|
},
|
|
|
|
|
|
data(){
|
|
|
|
|
|
return {
|
|
|
|
|
|
title:"",
|
|
|
|
|
|
rules:{
|
|
|
|
|
|
name:[
|
|
|
|
|
|
{required:true,message:this.$t('validate.required'),trigger:'blur'}
|
|
|
|
|
|
],
|
|
|
|
|
|
location:[
|
|
|
|
|
|
],
|
|
|
|
|
|
principal:[
|
|
|
|
|
|
],
|
|
|
|
|
|
tel:[
|
2020-01-16 17:54:04 +08:00
|
|
|
|
{ validator: phone, trigger: 'blur'}
|
2020-01-03 16:04:23 +08:00
|
|
|
|
]
|
|
|
|
|
|
},
|
|
|
|
|
|
idc:{},
|
|
|
|
|
|
principals:[],
|
2020-01-10 18:16:25 +08:00
|
|
|
|
popBox:{isEdit:true,show:false}
|
2020-01-03 16:04:23 +08:00
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
methods:{
|
|
|
|
|
|
init:function(){
|
|
|
|
|
|
let temp=this;
|
|
|
|
|
|
temp.getUserData();
|
|
|
|
|
|
},
|
|
|
|
|
|
resetData:function(){
|
|
|
|
|
|
let temp=this;
|
|
|
|
|
|
temp.idc={
|
|
|
|
|
|
name:"",
|
|
|
|
|
|
location: "",
|
|
|
|
|
|
principal: null,
|
|
|
|
|
|
tel:""
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
openBox:function(){
|
|
|
|
|
|
this.popBox.show=true;
|
|
|
|
|
|
},
|
2020-01-15 16:22:17 +08:00
|
|
|
|
afterShow:function(){
|
|
|
|
|
|
if(!this.popBox.isEdit){
|
|
|
|
|
|
this.popBox.isEdit=this.isEdit;
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
2020-01-03 16:04:23 +08:00
|
|
|
|
getUserData() {
|
|
|
|
|
|
let temp=this;
|
2020-02-06 17:44:07 +08:00
|
|
|
|
if(temp.userData&&temp.userData.length>0){
|
|
|
|
|
|
temp.principals=temp.userData;
|
|
|
|
|
|
return;
|
2020-02-06 12:35:29 +08:00
|
|
|
|
}
|
2020-02-06 17:44:07 +08:00
|
|
|
|
temp.$get('sys/user/list').then(response => {
|
|
|
|
|
|
if (response.code === 200) {
|
|
|
|
|
|
temp.principals = response.data.list
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
2020-01-03 16:04:23 +08:00
|
|
|
|
},
|
2020-01-10 18:16:25 +08:00
|
|
|
|
saveOrToEdit:function(){
|
|
|
|
|
|
if (!this.popBox.isEdit) {
|
|
|
|
|
|
this.toEdit(this.idc);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
this.save();
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
2020-01-03 16:04:23 +08:00
|
|
|
|
save:function(){
|
|
|
|
|
|
let temp=this;
|
|
|
|
|
|
temp.$refs.idcForm.validate((valide)=>{
|
|
|
|
|
|
if(valide){
|
|
|
|
|
|
const h = temp.$createElement;
|
|
|
|
|
|
if(!temp.idc.id){
|
|
|
|
|
|
temp.$post('idc', temp.idc).then(response => {
|
|
|
|
|
|
if (response.code === 200) {
|
2020-01-10 18:16:25 +08:00
|
|
|
|
temp.$message({duration: 1000, type: 'success', message: temp.$t("tip.saveSuccess")});
|
2020-01-03 16:04:23 +08:00
|
|
|
|
temp.$emit("after");
|
2020-01-10 18:16:25 +08:00
|
|
|
|
temp.$store.commit('assetDcListChange');
|
2020-01-03 16:04:23 +08:00
|
|
|
|
temp.esc();
|
|
|
|
|
|
} else {
|
2020-01-07 17:54:45 +08:00
|
|
|
|
this.$message.error(response.msg);
|
2020-01-03 16:04:23 +08:00
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
}else{
|
|
|
|
|
|
this.$put('idc', temp.idc).then(response => {
|
|
|
|
|
|
if (response.code === 200) {
|
2020-01-10 18:16:25 +08:00
|
|
|
|
temp.$message({duration: 1000, type: 'success', message: temp.$t("tip.saveSuccess")});
|
2020-01-03 16:04:23 +08:00
|
|
|
|
temp.$emit("after");
|
2020-01-10 18:16:25 +08:00
|
|
|
|
temp.$store.commit('assetDcListChange');
|
2020-01-03 16:04:23 +08:00
|
|
|
|
temp.esc();
|
|
|
|
|
|
} else {
|
2020-01-07 17:54:45 +08:00
|
|
|
|
this.$message.error(response.msg);
|
2020-01-03 16:04:23 +08:00
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
},
|
2020-01-10 18:16:25 +08:00
|
|
|
|
toEdit:function(u){
|
|
|
|
|
|
this.idc = Object.assign({}, u);
|
|
|
|
|
|
this.popBox.isEdit = true;
|
|
|
|
|
|
this.title = this.$t('asset.createAssetTab.editIdcTab.title') + " ID:" + this.idc.id
|
|
|
|
|
|
this.popBox.show = true;
|
|
|
|
|
|
},
|
|
|
|
|
|
show:function(isShow,isEdit){
|
|
|
|
|
|
this.popBox.show=isShow;
|
|
|
|
|
|
this.popBox.isEdit=isEdit;
|
|
|
|
|
|
},
|
2020-01-03 16:04:23 +08:00
|
|
|
|
esc:function(){
|
|
|
|
|
|
this.popBox.show=false;
|
|
|
|
|
|
},
|
|
|
|
|
|
del:function(){
|
|
|
|
|
|
let temp=this;
|
|
|
|
|
|
temp.$confirm(temp.$t("tip.confirmDelete"), {
|
|
|
|
|
|
confirmButtonText: temp.$t("tip.yes"),
|
|
|
|
|
|
cancelButtonText: temp.$t("tip.no"),
|
|
|
|
|
|
type: 'warning'
|
|
|
|
|
|
}).then(() => {
|
|
|
|
|
|
temp.$delete("idc?ids=" + temp.idc.id).then(response => {
|
|
|
|
|
|
if (response.code === 200) {
|
|
|
|
|
|
temp.$message({duration: 1000, type: 'success', message: temp.$t("tip.deleteSuccess")});
|
|
|
|
|
|
temp.$emit("after");
|
2020-01-15 14:31:28 +08:00
|
|
|
|
temp.$store.commit('assetDcListChange');
|
2020-01-03 16:04:23 +08:00
|
|
|
|
temp.esc();
|
|
|
|
|
|
} else {
|
|
|
|
|
|
this.$message.error(response.msg);
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
hidePop:function(){//隐藏事件触发方法
|
|
|
|
|
|
if(this.postIdc&&this.postIdc.id){
|
|
|
|
|
|
this.idc=this.postIdc
|
|
|
|
|
|
}else{
|
|
|
|
|
|
this.resetData();
|
|
|
|
|
|
}
|
|
|
|
|
|
this.clearValidate();
|
|
|
|
|
|
},
|
|
|
|
|
|
clearValidate:function(){
|
|
|
|
|
|
this.$refs.idcForm.clearValidate();
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
watch:{
|
|
|
|
|
|
postIdc: {
|
|
|
|
|
|
immediate: true,
|
2020-01-07 17:54:45 +08:00
|
|
|
|
deep: true,
|
2020-01-03 16:04:23 +08:00
|
|
|
|
handler(n, o) {
|
|
|
|
|
|
if (n && n.id) {
|
2020-01-15 16:22:17 +08:00
|
|
|
|
this.title = this.popBox.isEdit?this.$t('asset.createAssetTab.editIdcTab.title') + " ID:" + n.id:this.$t('asset.createAssetTab.dc') + " ID:" + n.id;
|
2020-01-03 16:04:23 +08:00
|
|
|
|
this.idc=n;
|
|
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
this.title = this.$t('asset.createAssetTab.AddIdcTab.title');
|
|
|
|
|
|
this.resetData();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
2020-01-10 18:16:25 +08:00
|
|
|
|
isEdit:{
|
|
|
|
|
|
immediate: true,
|
|
|
|
|
|
handler(n, o) {
|
|
|
|
|
|
this.popBox.isEdit=n;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2020-01-03 16:04:23 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
|
|
|
|
|
|
|
|
</style>
|