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}">
|
2020-07-30 18:37:04 +08:00
|
|
|
|
<!-- begin--顶部按钮-->
|
2020-10-15 14:27:46 +08:00
|
|
|
|
<div class="right-box-top-btns right-box-form-delete">
|
2020-12-08 21:53:37 +08:00
|
|
|
|
<button @click="del" class="nz-btn nz-btn-size-normal nz-btn-size-alien" id="project-del" type="button" v-has="'project_delete'" v-if="project.id">
|
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-07-30 18:37:04 +08:00
|
|
|
|
<span class="right-box-top-btn-txt">{{$t('overall.delete')}}</span>
|
|
|
|
|
|
</button>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<!-- end--顶部按钮-->
|
2019-12-18 17:00:44 +08:00
|
|
|
|
|
2020-07-30 18:37:04 +08:00
|
|
|
|
<!-- begin--标题-->
|
|
|
|
|
|
<div class="right-box-title">{{editProject.id ? $t("project.project.editProject") + " ID:" + editProject.id : $t("overall.createProject")}}</div>
|
|
|
|
|
|
<!-- end--标题-->
|
2020-12-14 20:25:24 +08:00
|
|
|
|
<div class="right-box-form-box">
|
2020-07-30 18:37:04 +08:00
|
|
|
|
<el-form class="right-box-form right-box-form-left" :model="editProject" label-position="right" label-width="120px" :rules="rules" ref="projectForm">
|
|
|
|
|
|
<el-form-item :label='$t("project.project.projectName")' prop="name">
|
2021-02-04 11:21:00 +08:00
|
|
|
|
<el-input size="mini" maxlength="64" show-word-limit v-model="editProject.name" id="project-box-input-name"></el-input>
|
2020-07-30 18:37:04 +08:00
|
|
|
|
</el-form-item>
|
|
|
|
|
|
<el-form-item :label='$t("project.project.description")'>
|
2021-02-04 11:21:00 +08:00
|
|
|
|
<el-input size="mini" type="textarea" maxlength="1024" show-word-limit v-model="editProject.remark" id="project-box-input-remark"></el-input>
|
2020-07-30 18:37:04 +08:00
|
|
|
|
</el-form-item>
|
|
|
|
|
|
</el-form>
|
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
|
|
|
|
<!--底部按钮-->
|
|
|
|
|
|
<div class="right-box-bottom-btns">
|
2021-01-18 18:58:57 +08:00
|
|
|
|
<button v-cancel="{obj:editProject,func:esc}" id="project-esc" class="nz-btn nz-btn-size-normal-new nz-btn-style-light-new">
|
2020-07-30 18:37:04 +08:00
|
|
|
|
<span>{{$t('overall.cancel')}}</span>
|
|
|
|
|
|
</button>
|
2021-01-21 17:29:29 +08:00
|
|
|
|
<button :class="{'nz-btn-disabled':prevent_opt.save}" :disabled="prevent_opt.save" @click="save" class="nz-btn nz-btn-size-normal-new nz-btn-style-normal-new" 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>
|
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 {
|
2020-07-30 18:37:04 +08:00
|
|
|
|
editProject: {},
|
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-07-30 18:37:04 +08:00
|
|
|
|
clickOutside() {
|
|
|
|
|
|
this.esc(false);
|
2020-02-26 18:26:55 +08:00
|
|
|
|
},
|
|
|
|
|
|
|
2019-12-18 17:00:44 +08:00
|
|
|
|
/*关闭弹框*/
|
2020-07-30 18:37:04 +08:00
|
|
|
|
esc(refresh) {
|
|
|
|
|
|
this.$emit("close", refresh);
|
2019-12-18 17:00:44 +08:00
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
/*保存*/
|
|
|
|
|
|
save() {
|
2019-12-27 17:53:17 +08:00
|
|
|
|
this.$refs['projectForm'].validate((valid) => {
|
|
|
|
|
|
if (valid) {
|
2020-12-21 13:56:36 +08:00
|
|
|
|
this.prevent_opt.save=true;
|
2020-07-30 18:37:04 +08:00
|
|
|
|
if (this.editProject.id) {
|
|
|
|
|
|
this.$put('project', this.editProject).then(response => {
|
2019-12-27 17:53:17 +08:00
|
|
|
|
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');
|
|
|
|
|
|
this.$store.commit('setProject', this.project);
|
2020-07-30 18:37:04 +08:00
|
|
|
|
this.esc(true);
|
2019-12-27 17:53:17 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
this.$message.error(response.msg);
|
|
|
|
|
|
}
|
2020-12-21 13:56:36 +08:00
|
|
|
|
this.prevent_opt.save=false;
|
2019-12-27 17:53:17 +08:00
|
|
|
|
});
|
2019-12-18 17:00:44 +08:00
|
|
|
|
} else {
|
2020-07-30 18:37:04 +08:00
|
|
|
|
this.$post('project', this.editProject).then(response => {
|
2019-12-27 17:53:17 +08:00
|
|
|
|
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');
|
2020-07-30 18:37:04 +08:00
|
|
|
|
this.esc(true);
|
2019-12-27 17:53:17 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
this.$message.error(response.msg);
|
|
|
|
|
|
}
|
2020-12-21 13:56:36 +08:00
|
|
|
|
this.prevent_opt.save=false;
|
2019-12-27 17:53:17 +08:00
|
|
|
|
});
|
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
|
|
|
|
},
|
|
|
|
|
|
/*删除*/
|
|
|
|
|
|
del() {
|
|
|
|
|
|
this.$confirm(this.$t("tip.confirmDelete"), {
|
|
|
|
|
|
confirmButtonText: this.$t("tip.yes"),
|
|
|
|
|
|
cancelButtonText: this.$t("tip.no"),
|
|
|
|
|
|
type: 'warning'
|
|
|
|
|
|
}).then(() => {
|
2020-07-30 18:37:04 +08:00
|
|
|
|
this.$delete("project?ids=" + this.editProject.id).then(response => {
|
2019-12-18 17:00:44 +08:00
|
|
|
|
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-31 19:02:58 +08:00
|
|
|
|
this.$store.commit('projectListChange');
|
2020-07-30 18:37:04 +08:00
|
|
|
|
this.esc(true);
|
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) {
|
2020-07-30 18:37:04 +08:00
|
|
|
|
this.editProject = JSON.parse(JSON.stringify(n));
|
2019-12-18 17:00:44 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
|
|
|
|
|
|
|
|
</style>
|