2019-12-18 17:00:44 +08:00
|
|
|
|
<template>
|
|
|
|
|
|
<transition name="right-box">
|
2020-02-26 18:26:55 +08:00
|
|
|
|
<div class="right-box right-box-project" v-if="rightBox.show" v-clickoutside="clickos">
|
2019-12-18 17:00:44 +08:00
|
|
|
|
<!-- begin--顶部按钮-->
|
|
|
|
|
|
<div class="right-box-top-btns">
|
2020-01-17 09:54:01 +08:00
|
|
|
|
<button id="project-del" type="button" v-if="project.id != '' && rightBox.isEdit" @click="del" class="nz-btn nz-btn-size-normal nz-btn-size-alien nz-btn-style-light nz-btn-min-width-82">
|
|
|
|
|
|
<span class="right-box-top-btn-icon"><i class="el-icon-delete"></i></span>
|
|
|
|
|
|
<span class="right-box-top-btn-txt">{{$t('overall.delete')}}</span>
|
2019-12-27 17:53:17 +08:00
|
|
|
|
</button>
|
2020-01-17 09:54:01 +08:00
|
|
|
|
<button v-if="!rightBox.isEdit" id="project-edit" type="button" @click="saveOrToEdit" class="nz-btn nz-btn-size-normal nz-btn-size-alien nz-btn-style-light nz-btn-min-width-82">
|
|
|
|
|
|
<span class="right-box-top-btn-icon"><i class="nz-icon nz-icon-edit"></i></span>
|
|
|
|
|
|
<span class="right-box-top-btn-txt">{{$t('overall.edit')}}</span>
|
2019-12-27 17:53:17 +08:00
|
|
|
|
</button>
|
2019-12-18 17:00:44 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
<!-- end--顶部按钮-->
|
|
|
|
|
|
|
|
|
|
|
|
<!-- begin--标题-->
|
|
|
|
|
|
<div class="right-box-title">{{rightBox.title}}</div>
|
|
|
|
|
|
<!-- end--标题-->
|
2019-12-27 17:53:17 +08:00
|
|
|
|
<el-scrollbar class="right-box-form-box">
|
|
|
|
|
|
<el-form class="right-box-form" :model="project" label-position="top" :rules="rules" ref="projectForm">
|
|
|
|
|
|
<el-form-item :label='$t("project.project.projectName")' prop="name">
|
2020-01-06 19:03:38 +08:00
|
|
|
|
<el-input v-if="rightBox.isEdit" size="mini" maxlength="64" show-word-limit v-model="project.name"></el-input>
|
|
|
|
|
|
<div v-if="!rightBox.isEdit" class="right-box-form-content-txt">{{project.name}}</div>
|
2019-12-27 17:53:17 +08:00
|
|
|
|
</el-form-item>
|
|
|
|
|
|
<el-form-item :label='$t("project.project.description")'>
|
2020-01-06 19:03:38 +08:00
|
|
|
|
<el-input v-if="rightBox.isEdit" size="mini" type="textarea" maxlength="1024" show-word-limit v-model="project.remark"></el-input>
|
|
|
|
|
|
<div v-if="!rightBox.isEdit" class="right-box-form-content-txt">{{project.remark}}</div>
|
2019-12-27 17:53:17 +08:00
|
|
|
|
</el-form-item>
|
|
|
|
|
|
</el-form>
|
|
|
|
|
|
</el-scrollbar>
|
2019-12-25 17:15:09 +08:00
|
|
|
|
|
2020-01-16 18:11:15 +08:00
|
|
|
|
<!--底部按钮-->
|
|
|
|
|
|
<div class="right-box-bottom-btns">
|
2020-02-17 17:29:15 +08:00
|
|
|
|
<button @click="esc" id="project-esc" class="nz-btn nz-btn-size-normal nz-btn-style-light nz-btn-min-width-100">
|
2020-01-16 18:11:15 +08:00
|
|
|
|
<span>{{$t('overall.cancel')}}</span>
|
|
|
|
|
|
</button>
|
2020-02-17 17:29:15 +08:00
|
|
|
|
<button v-if="rightBox.isEdit" @click="saveOrToEdit" id="project-save" class="nz-btn nz-btn-size-normal nz-btn-style-normal nz-btn-min-width-100">
|
2020-01-16 18:11:15 +08:00
|
|
|
|
<span>{{$t('overall.save')}}</span>
|
|
|
|
|
|
</button>
|
|
|
|
|
|
</div>
|
2019-12-18 17:00:44 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
</transition>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
<script>
|
2020-01-17 10:35:09 +08:00
|
|
|
|
import {noSpecialChar} from '../../common/js/validate';
|
2019-12-18 17:00:44 +08:00
|
|
|
|
export default {
|
|
|
|
|
|
name: "projectBox",
|
|
|
|
|
|
props: {
|
|
|
|
|
|
project: Object
|
|
|
|
|
|
},
|
|
|
|
|
|
data() {
|
|
|
|
|
|
return {
|
|
|
|
|
|
rightBox: {
|
|
|
|
|
|
show: false,
|
|
|
|
|
|
title: '',
|
2020-01-06 19:03:38 +08:00
|
|
|
|
isCreate: false,
|
|
|
|
|
|
isEdit:false
|
2019-12-27 17:53:17 +08:00
|
|
|
|
},
|
|
|
|
|
|
rules: {
|
|
|
|
|
|
name: [
|
2020-01-17 10:35:09 +08:00
|
|
|
|
{required: true, message: this.$t('validate.required'), trigger: 'blur'},
|
|
|
|
|
|
{validator:noSpecialChar,trigger: "change"}
|
2019-12-27 17:53:17 +08:00
|
|
|
|
]
|
2019-12-18 17:00:44 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
methods: {
|
2020-01-06 19:03:38 +08:00
|
|
|
|
show(show,isEdit) {
|
2019-12-18 17:00:44 +08:00
|
|
|
|
this.rightBox.show = show;
|
2020-01-06 19:03:38 +08:00
|
|
|
|
this.rightBox.isEdit=isEdit;
|
2019-12-18 17:00:44 +08:00
|
|
|
|
},
|
|
|
|
|
|
|
2020-02-26 18:26:55 +08:00
|
|
|
|
clickos() {
|
|
|
|
|
|
this.esc();
|
|
|
|
|
|
},
|
|
|
|
|
|
|
2019-12-18 17:00:44 +08:00
|
|
|
|
/*关闭弹框*/
|
|
|
|
|
|
esc() {
|
|
|
|
|
|
this.rightBox.show = false;
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
/*保存*/
|
|
|
|
|
|
save() {
|
2019-12-27 17:53:17 +08:00
|
|
|
|
this.$refs['projectForm'].validate((valid) => {
|
|
|
|
|
|
if (valid) {
|
|
|
|
|
|
if (this.project.id) {
|
|
|
|
|
|
this.$put('project', this.project).then(response => {
|
|
|
|
|
|
if (response.code === 200) {
|
|
|
|
|
|
this.$message({duration: 1000, type: 'success', message: this.$t("tip.saveSuccess")});
|
|
|
|
|
|
this.rightBox.show = false;
|
2019-12-31 19:02:58 +08:00
|
|
|
|
this.$store.commit('projectListChange');
|
|
|
|
|
|
this.$store.commit('setProject', this.project);
|
2020-01-06 20:57:49 +08:00
|
|
|
|
this.$emit('reload');
|
2019-12-27 17:53:17 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
this.$message.error(response.msg);
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
2019-12-18 17:00:44 +08:00
|
|
|
|
} else {
|
2019-12-27 17:53:17 +08:00
|
|
|
|
this.$post('project', this.project).then(response => {
|
|
|
|
|
|
if (response.code === 200) {
|
|
|
|
|
|
this.$message({duration: 1000, type: 'success', message: this.$t("tip.saveSuccess")});
|
2019-12-31 19:02:58 +08:00
|
|
|
|
this.$store.commit('projectListChange');
|
2019-12-27 17:53:17 +08:00
|
|
|
|
this.rightBox.show = false;
|
|
|
|
|
|
} else {
|
|
|
|
|
|
this.$message.error(response.msg);
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
2019-12-18 17:00:44 +08:00
|
|
|
|
}
|
2019-12-27 17:53:17 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
console.log('error submit!!');
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
2019-12-18 17:00:44 +08:00
|
|
|
|
},
|
2020-01-06 19:03:38 +08:00
|
|
|
|
saveOrToEdit: function() {
|
|
|
|
|
|
if (!this.rightBox.isEdit) {
|
|
|
|
|
|
this.rightBox.isEdit = true;
|
2020-01-06 20:57:49 +08:00
|
|
|
|
this.rightBox.title = this.$t("project.project.editProject") + " ID:" + this.project.id;
|
2020-01-06 19:03:38 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
this.save();
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
2019-12-18 17:00:44 +08:00
|
|
|
|
/*删除*/
|
|
|
|
|
|
del() {
|
|
|
|
|
|
this.$confirm(this.$t("tip.confirmDelete"), {
|
|
|
|
|
|
confirmButtonText: this.$t("tip.yes"),
|
|
|
|
|
|
cancelButtonText: this.$t("tip.no"),
|
|
|
|
|
|
type: 'warning'
|
|
|
|
|
|
}).then(() => {
|
|
|
|
|
|
this.$delete("project?ids=" + this.project.id).then(response => {
|
|
|
|
|
|
if (response.code === 200) {
|
2019-12-19 17:22:18 +08:00
|
|
|
|
this.$message({duration: 1000, type: 'success', message: this.$t("tip.deleteSuccess")});
|
2019-12-18 17:00:44 +08:00
|
|
|
|
this.rightBox.show = false;
|
2019-12-31 19:02:58 +08:00
|
|
|
|
this.$store.commit('projectListChange');
|
2019-12-18 17:00:44 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
this.$message.error(response.msg);
|
|
|
|
|
|
}
|
2019-12-24 17:31:51 +08:00
|
|
|
|
});
|
2019-12-18 17:00:44 +08:00
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
watch: {
|
|
|
|
|
|
project: {
|
|
|
|
|
|
immediate: true,
|
|
|
|
|
|
handler(n, o) {
|
|
|
|
|
|
if (n && n.id) {
|
2020-01-06 19:03:38 +08:00
|
|
|
|
this.rightBox.title =this.rightBox.isEdit? this.$t("project.project.editProject") + " ID:" + n.id : this.$t("project.project.project") + " ID:" + n.id;
|
2019-12-18 17:00:44 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
this.rightBox.title = this.$t("project.project.createProject");
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
|
|
|
|
|
|
|
|
</style>
|