2019-12-18 17:00:44 +08:00
|
|
|
<template>
|
2021-01-18 18:58:57 +08:00
|
|
|
<div class="right-box right-box-project" v-clickoutside="{obj:editProject,func:clickOutside}">
|
2021-04-23 11:47:38 +08:00
|
|
|
<div class="right-box__header">
|
|
|
|
|
<!-- begin--标题-->
|
2021-05-21 19:28:50 +08:00
|
|
|
<div class="header__title">{{editProject.id ? $t("project.project.editProject") : $t("overall.createProject")}}</div>
|
2021-04-23 11:47:38 +08:00
|
|
|
<!-- end--标题-->
|
|
|
|
|
|
2021-04-25 14:58:03 +08:00
|
|
|
<div class="header__operation">
|
|
|
|
|
<span v-cancel="{obj: editProject, func: esc}"><i class="nz-icon nz-icon-close"></i></span>
|
2021-04-23 11:47:38 +08:00
|
|
|
</div>
|
|
|
|
|
</div>
|
2021-05-21 19:28:50 +08:00
|
|
|
<div class="right-box__container">
|
|
|
|
|
<div class="container__form">
|
|
|
|
|
<el-form ref="projectForm" :model="editProject" :rules="rules" label-position = "top" label-width="120px">
|
|
|
|
|
<el-form-item :label='$t("project.project.project")' prop="name">
|
|
|
|
|
<el-input id="project-box-input-name" v-model="editProject.name" maxlength="64" show-word-limit size="small"></el-input>
|
|
|
|
|
</el-form-item>
|
2021-06-07 18:28:07 +08:00
|
|
|
<el-form-item :label='$t("overall.remark")'>
|
2021-05-28 10:43:41 +08:00
|
|
|
<el-input id="project-box-input-remark" v-model="editProject.remark" maxlength="256" show-word-limit size="small" type="textarea"></el-input>
|
2021-05-21 19:28:50 +08:00
|
|
|
</el-form-item>
|
|
|
|
|
</el-form>
|
|
|
|
|
</div>
|
2020-12-14 20:25:24 +08:00
|
|
|
</div>
|
2019-12-25 17:15:09 +08:00
|
|
|
|
2020-07-30 18:37:04 +08:00
|
|
|
<!--底部按钮-->
|
2021-05-11 10:37:58 +08:00
|
|
|
<div class="right-box__footer">
|
|
|
|
|
<button v-cancel="{obj:editProject,func:esc}" id="project-esc" class="footer__btn footer__btn--light">
|
2020-07-30 18:37:04 +08:00
|
|
|
<span>{{$t('overall.cancel')}}</span>
|
|
|
|
|
</button>
|
2021-05-11 10:37:58 +08:00
|
|
|
<button :class="{'nz-btn-disabled':prevent_opt.save}" v-has="'project_add'" :disabled="prevent_opt.save" @click="save" class="footer__btn" id="project-save">
|
2020-07-30 18:37:04 +08:00
|
|
|
<span>{{$t('overall.save')}}</span>
|
|
|
|
|
</button>
|
2019-12-18 17:00:44 +08:00
|
|
|
</div>
|
2020-07-30 18:37:04 +08:00
|
|
|
</div>
|
2019-12-18 17:00:44 +08:00
|
|
|
</template>
|
|
|
|
|
<script>
|
2021-03-19 18:52:19 +08:00
|
|
|
import { noSpecialChar } from '../../common/js/validate'
|
|
|
|
|
export default {
|
|
|
|
|
name: 'projectBox',
|
|
|
|
|
props: {
|
|
|
|
|
project: Object
|
|
|
|
|
},
|
|
|
|
|
data () {
|
|
|
|
|
return {
|
|
|
|
|
editProject: {},
|
|
|
|
|
rules: {
|
|
|
|
|
name: [
|
|
|
|
|
{ required: true, message: this.$t('validate.required'), trigger: 'blur' },
|
|
|
|
|
{ validator: noSpecialChar, trigger: 'change' }
|
|
|
|
|
]
|
2019-12-18 17:00:44 +08:00
|
|
|
}
|
2021-03-19 18:52:19 +08:00
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
methods: {
|
|
|
|
|
clickOutside () {
|
|
|
|
|
this.esc(false)
|
2019-12-18 17:00:44 +08:00
|
|
|
},
|
2020-02-26 18:26:55 +08:00
|
|
|
|
2021-03-19 18:52:19 +08:00
|
|
|
/* 关闭弹框 */
|
|
|
|
|
esc (refresh) {
|
|
|
|
|
this.$emit('close', refresh)
|
|
|
|
|
},
|
2019-12-18 17:00:44 +08:00
|
|
|
|
2021-03-19 18:52:19 +08:00
|
|
|
/* 保存 */
|
|
|
|
|
save () {
|
|
|
|
|
this.$refs.projectForm.validate((valid) => {
|
|
|
|
|
if (valid) {
|
|
|
|
|
this.prevent_opt.save = true
|
|
|
|
|
if (this.editProject.id) {
|
2021-04-13 10:03:49 +08:00
|
|
|
this.$put('monitor/project', this.editProject).then(response => {
|
2021-03-19 18:52:19 +08:00
|
|
|
if (response.code === 200) {
|
|
|
|
|
this.$message({ duration: 1000, type: 'success', message: this.$t('tip.saveSuccess') })
|
|
|
|
|
this.$store.commit('projectListChange')
|
|
|
|
|
this.$store.commit('setProject', this.project)
|
|
|
|
|
this.esc(true)
|
|
|
|
|
} else {
|
|
|
|
|
this.$message.error(response.msg)
|
|
|
|
|
}
|
|
|
|
|
this.prevent_opt.save = false
|
|
|
|
|
})
|
2019-12-27 17:53:17 +08:00
|
|
|
} else {
|
2021-04-13 10:03:49 +08:00
|
|
|
this.$post('monitor/project', this.editProject).then(response => {
|
2021-03-19 18:52:19 +08:00
|
|
|
if (response.code === 200) {
|
|
|
|
|
this.$message({ duration: 1000, type: 'success', message: this.$t('tip.saveSuccess') })
|
|
|
|
|
this.$store.commit('projectListChange')
|
|
|
|
|
this.esc(true)
|
|
|
|
|
} else {
|
|
|
|
|
this.$message.error(response.msg)
|
|
|
|
|
}
|
|
|
|
|
this.prevent_opt.save = false
|
|
|
|
|
})
|
2019-12-27 17:53:17 +08:00
|
|
|
}
|
2021-03-19 18:52:19 +08:00
|
|
|
} else {
|
|
|
|
|
console.log('error submit!!')
|
|
|
|
|
return false
|
2019-12-18 17:00:44 +08:00
|
|
|
}
|
2021-03-19 18:52:19 +08:00
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
/* 删除 */
|
|
|
|
|
del () {
|
|
|
|
|
this.$confirm(this.$t('tip.confirmDelete'), {
|
|
|
|
|
confirmButtonText: this.$t('tip.yes'),
|
|
|
|
|
cancelButtonText: this.$t('tip.no'),
|
|
|
|
|
type: 'warning'
|
|
|
|
|
}).then(() => {
|
2021-04-13 10:03:49 +08:00
|
|
|
this.$delete('monitor/project?ids=' + this.editProject.id).then(response => {
|
2021-03-19 18:52:19 +08:00
|
|
|
if (response.code === 200) {
|
|
|
|
|
this.$message({ duration: 1000, type: 'success', message: this.$t('tip.deleteSuccess') })
|
|
|
|
|
this.$store.commit('projectListChange')
|
|
|
|
|
this.esc(true)
|
|
|
|
|
} else {
|
|
|
|
|
this.$message.error(response.msg)
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
watch: {
|
|
|
|
|
project: {
|
|
|
|
|
immediate: true,
|
|
|
|
|
handler (n, o) {
|
|
|
|
|
this.editProject = JSON.parse(JSON.stringify(n))
|
2019-12-18 17:00:44 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-03-19 18:52:19 +08:00
|
|
|
}
|
2019-12-18 17:00:44 +08:00
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
|
|
|
|
|
|
</style>
|