NEZ-602 perf: 向导大部分内容
This commit is contained in:
@@ -1,126 +1,130 @@
|
||||
<template>
|
||||
<transition name="right-box-580">
|
||||
<div class="right-box right-box-panel z-top" v-if="rightBox.show" v-clickoutside="{obj:panel,func:clickos}">
|
||||
<!-- begin--标题-->
|
||||
<div class="right-box-title right-box__header">{{rightBox.title}}</div>
|
||||
<!-- end--标题-->
|
||||
|
||||
<!-- begin--表单-->
|
||||
<div class="right-box-form-box right-box__container">
|
||||
<el-form class="right-box-form right-box-form-left" label-width="120px" :model="panel" label-position = "top" ref="panelForm">
|
||||
<el-form-item :label='$t("overall.name")' prop="name" :rules="{required: true, message: $t('validate.required'), trigger: 'blur'}">
|
||||
<el-input placeholder="" maxlength="64" show-word-limit v-model="panel.name" size="small" id="panel-box-input-name"></el-input>
|
||||
<div v-clickoutside="{obj:editPanel,func:clickOutside}" class="right-box right-box-panel">
|
||||
<!-- begin--标题-->
|
||||
<div class="right-box__header">
|
||||
<div class="header__title">{{editPanel.id ? ($t("config.dc.editPanel")) : $t("config.dc.createDc")}}</div>
|
||||
<div class="header__operation">
|
||||
<span v-cancel="{obj: editPanel, func: esc}"><i class="nz-icon nz-icon-close"></i></span>
|
||||
</div>
|
||||
</div>
|
||||
<!-- begin--表单-->
|
||||
<div class="right-box__container">
|
||||
<div class="container__form">
|
||||
<el-form ref="form" :model="editPanel" :rules="rules" label-position = "top" label-width="120px" size="small">
|
||||
<el-form-item :label='$t("overall.name")' prop="name">
|
||||
<el-input id="dc-box-input-name" v-model="editPanel.name" maxlength="64" placeholder="" show-word-limit size="small"></el-input>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</div>
|
||||
<!-- end--表单-->
|
||||
|
||||
<!-- begin--底部按钮-->
|
||||
<div class="right-box__footer">
|
||||
<button v-cancel="{obj:panel,func:esc}" id="panel-box-esc" class="footer__btn footer__btn--light">
|
||||
<span>{{$t('overall.cancel')}}</span>
|
||||
</button>
|
||||
<button :class="{'nz-btn-disabled':prevent_opt.save}" :disabled="prevent_opt.save" @click="save" class="footer__btn" id="panel-box-save">
|
||||
<span>{{$t('overall.save')}}</span>
|
||||
</button>
|
||||
</div>
|
||||
<!-- end--底部按钮-->
|
||||
|
||||
</div>
|
||||
</transition>
|
||||
<!--底部按钮-->
|
||||
<div class="right-box__footer">
|
||||
<button id="dc-box-esc" v-cancel="{obj:editPanel, func:esc}" class="footer__btn footer__btn--light">
|
||||
<span>{{$t('overall.cancel')}}</span>
|
||||
</button>
|
||||
<button id="dc-box-save" :class="{'nz-btn-disabled':prevent_opt.save}" :disabled="prevent_opt.save" class="footer__btn" @click="save">
|
||||
<span>{{$t('overall.save')}}</span>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: 'panelBox',
|
||||
props: {
|
||||
panel: Object
|
||||
obj: {
|
||||
type: Object
|
||||
}
|
||||
},
|
||||
data () {
|
||||
return {
|
||||
rightBox: { // 面板弹出框相关
|
||||
show: false,
|
||||
title: this.$t('dashboard.panel.createPanelTitle')
|
||||
url: '/panel',
|
||||
editPanel: {},
|
||||
rules: {
|
||||
name: [
|
||||
{ required: true, message: this.$t('validate.required'), trigger: 'blur' }
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
show (show) {
|
||||
this.rightBox.show = show
|
||||
/* 关闭弹框 */
|
||||
esc (refresh) {
|
||||
this.prevent_opt.save = false
|
||||
this.$emit('close', refresh)
|
||||
},
|
||||
setTitle (title) {
|
||||
this.rightBox.title = title
|
||||
clickOutside () {
|
||||
this.esc(false)
|
||||
},
|
||||
clickos () {
|
||||
this.esc()
|
||||
|
||||
/* 保存 */
|
||||
save () {
|
||||
if (this.prevent_opt.save) {
|
||||
return
|
||||
}
|
||||
this.prevent_opt.save = true
|
||||
this.$refs.form.validate((valid) => {
|
||||
if (valid) {
|
||||
if (this.editPanel.id) {
|
||||
this.$put(this.url, this.editPanel).then(response => {
|
||||
this.prevent_opt.save = false
|
||||
if (response.code === 200) {
|
||||
this.$message({ duration: 1000, type: 'success', message: this.$t('tip.saveSuccess') })
|
||||
this.esc(true)
|
||||
} else {
|
||||
this.$message.error(response.msg)
|
||||
}
|
||||
})
|
||||
} else {
|
||||
this.$post(this.url, this.editPanel).then(response => {
|
||||
this.prevent_opt.save = false
|
||||
if (response.code === 200) {
|
||||
this.$message({ duration: 1000, type: 'success', message: this.$t('tip.saveSuccess') })
|
||||
this.esc(true)
|
||||
} else {
|
||||
this.$message.error(response.msg)
|
||||
}
|
||||
})
|
||||
}
|
||||
} else {
|
||||
this.prevent_opt.save = false
|
||||
return false
|
||||
}
|
||||
})
|
||||
},
|
||||
// 面板相关方法
|
||||
del: function (u) {
|
||||
/* 删除 */
|
||||
del () {
|
||||
if (this.prevent_opt.save) { return } ;
|
||||
this.prevent_opt.save = true
|
||||
this.$confirm(this.$t('tip.confirmDelete'), {
|
||||
confirmButtonText: this.$t('tip.yes'),
|
||||
cancelButtonText: this.$t('tip.no'),
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
this.$delete('visual/panel?ids=' + u.id).then(response => {
|
||||
this.$delete(`${this.url}?ids=${this.editPanel.id}`).then(response => {
|
||||
this.prevent_opt.save = false
|
||||
if (response.code === 200) {
|
||||
this.esc()
|
||||
this.$message({ duration: 1000, type: 'success', message: this.$t('tip.deleteSuccess') })
|
||||
this.$emit('reloadForDel')
|
||||
this.esc(true)
|
||||
} else {
|
||||
this.$message.error(response.msg)
|
||||
}
|
||||
})
|
||||
}).catch(() => {
|
||||
this.prevent_opt.save = false
|
||||
})
|
||||
},
|
||||
save: function () {
|
||||
this.$refs.panelForm.validate((valid) => {
|
||||
if (valid) {
|
||||
this.prevent_opt.save = true
|
||||
if (this.panel.id) {
|
||||
this.$put('visual/panel', this.panel).then(response => {
|
||||
if (response.code === 200) {
|
||||
this.esc()
|
||||
this.$message({ duration: 1000, type: 'success', message: this.$t('tip.saveSuccess') })
|
||||
this.$emit('reload')
|
||||
} else {
|
||||
this.$message.error(response.msg)
|
||||
}
|
||||
this.prevent_opt.save = false
|
||||
})
|
||||
} else {
|
||||
this.$post('visual/panel', this.panel).then(response => {
|
||||
if (response.code === 200) {
|
||||
this.esc()
|
||||
this.$message({ duration: 1000, type: 'success', message: this.$t('tip.saveSuccess') })
|
||||
this.$emit('reload', this.panel.name)
|
||||
} else {
|
||||
this.$message.error(response.msg)
|
||||
}
|
||||
this.prevent_opt.save = false
|
||||
})
|
||||
}
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
})
|
||||
},
|
||||
esc: function () {
|
||||
this.rightBox.show = false
|
||||
}
|
||||
},
|
||||
created () {
|
||||
|
||||
},
|
||||
mounted: function () {
|
||||
|
||||
},
|
||||
watch: {
|
||||
|
||||
obj: {
|
||||
immediate: true,
|
||||
deep: true,
|
||||
handler (n, o) {
|
||||
this.editPanel = JSON.parse(JSON.stringify(n))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.z-top{
|
||||
z-index: 3000 !important;
|
||||
}
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user