|
@@ -0,0 +1,204 @@
|
|
|
+<template>
|
|
|
+ <section >
|
|
|
+ <el-col :span="24" class="toolbar" style="padding-bottom: 0px;">
|
|
|
+ <el-form :inline="true">
|
|
|
+ <el-form-item label="研究中心管理">
|
|
|
+ </el-form-item>
|
|
|
+ <el-link icon="el-icon-circle-plus-outline" type="primary" :underline="false" class="tanjia" @click="addNewSubProject()">添加研究中心</el-link>
|
|
|
+ </el-form>
|
|
|
+ </el-col>
|
|
|
+ <el-table :data="subProjectList" highlight-current-row v-loading="listLoading" :height="heightDoms" style="width: 100%;">
|
|
|
+ <el-table-column prop="id" width="200" label="序号" align="center">
|
|
|
+ <template slot-scope="scope" >
|
|
|
+ {{scope.$index + 1}}
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column prop="name" label="名称" ></el-table-column>
|
|
|
+ <el-table-column label="操作" width="150">
|
|
|
+ <template slot-scope="scope" >
|
|
|
+ <el-button size="small" type="primary" @click="addNewSubProject(scope.row)">编辑</el-button>
|
|
|
+ <el-button size="small" type="danger" @click="deleteSubPro(scope.row)">删除</el-button>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ </el-table>
|
|
|
+ <el-dialog title="新增/修改维护数据" v-if="addSubProject" :visible.sync="addSubProject" :close-on-click-modal="false" customClass="customWidth" width="500px">
|
|
|
+ <el-form ref="form2" :model="addfm" :rules="ruless" label-width="100px">
|
|
|
+ <el-form-item label="名称" prop="name">
|
|
|
+ <el-input v-model="addfm.name" placeholder="请输入名称" clearable></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+ <div slot="footer" class="dialog-footer">
|
|
|
+ <el-button @click.native="addSubProject = false">取消</el-button>
|
|
|
+ <el-button type="primary" @click="submitInsertSubProject" :loading="addLoading">提交</el-button>
|
|
|
+ </div>
|
|
|
+ </el-dialog>
|
|
|
+ </section>
|
|
|
+</template>
|
|
|
+<script>
|
|
|
+ export default {
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ subProjectList: [],//子项目列表
|
|
|
+ listLoading: false,
|
|
|
+ addfm: {
|
|
|
+ name: '',
|
|
|
+ },
|
|
|
+ addSubProject: false,
|
|
|
+ ruless: {
|
|
|
+ name: [{ required: true, message: "请输入名称", trigger: "blur" }],
|
|
|
+ },
|
|
|
+ heightDoms: document.documentElement.clientHeight - 140,
|
|
|
+ };
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ getSub() {
|
|
|
+ this.listLoading = true;
|
|
|
+ this.http.post('/report-extra-degree/getAll ',{},
|
|
|
+ res => {
|
|
|
+ this.listLoading = false;
|
|
|
+ if (res.code == "ok") {
|
|
|
+ console.log(res, '看看')
|
|
|
+ this.subProjectList = res.data
|
|
|
+ } else {
|
|
|
+ this.$message({
|
|
|
+ message: res.msg,
|
|
|
+ type: "error"
|
|
|
+ });
|
|
|
+ }
|
|
|
+ },
|
|
|
+ error => {
|
|
|
+ this.listLoading = false;
|
|
|
+ this.$message({
|
|
|
+ message: error,
|
|
|
+ type: "error"
|
|
|
+ });
|
|
|
+ }
|
|
|
+ );
|
|
|
+ },
|
|
|
+ addNewSubProject(subProject) {
|
|
|
+ // console.log(1234)
|
|
|
+ // if (subProject == null) {
|
|
|
+ // this.addForm = {projectId: this.currentProject.id, level:1}
|
|
|
+ // }
|
|
|
+ // else {
|
|
|
+ // this.addForm = subProject;
|
|
|
+ // }
|
|
|
+ if(subProject) {
|
|
|
+ this.addfm.name = subProject.name
|
|
|
+ this.addfm.id = subProject.id
|
|
|
+ }
|
|
|
+ this.addSubProject = true;
|
|
|
+ },
|
|
|
+ deleteSubPro(subProject) {
|
|
|
+ this.$confirm("确定要这条" + subProject.name + "数据吗?","删除", {
|
|
|
+ confirmButtonText: "确定",
|
|
|
+ cancelButtonText: "取消",
|
|
|
+ type: "warning"
|
|
|
+ })
|
|
|
+ .then(() => {
|
|
|
+ this.listLoading = true;
|
|
|
+ this.http.post('/report-extra-degree/delete',{
|
|
|
+ id: subProject.id
|
|
|
+ },
|
|
|
+ res => {
|
|
|
+ this.listLoading = false;
|
|
|
+ if (res.code == "ok") {
|
|
|
+ this.$message({
|
|
|
+ message: "删除成功",
|
|
|
+ type: "success"
|
|
|
+ });
|
|
|
+ this.getSub();
|
|
|
+ } else {
|
|
|
+ if(res.msg.indexOf("无法删除1") == '-1') {
|
|
|
+ this.$message({
|
|
|
+ message: '该数据正在使用,无法删除',
|
|
|
+ type: "error"
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ this.$message({
|
|
|
+ message: res.msg,
|
|
|
+ type: "error"
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ error => {
|
|
|
+ this.listLoading = false;
|
|
|
+ this.$message({
|
|
|
+ message: error,
|
|
|
+ type: "error"
|
|
|
+ });
|
|
|
+ }
|
|
|
+ );
|
|
|
+ })
|
|
|
+ .catch(() => {});
|
|
|
+ },
|
|
|
+ submitInsertSubProject() {
|
|
|
+ this.$refs.form2.validate(valid => {
|
|
|
+ if (valid) {
|
|
|
+ var slp = this.addfm
|
|
|
+ this.http.post('/report-extra-degree/addOrMod',slp,
|
|
|
+ res => {
|
|
|
+ this.listLoading = false;
|
|
|
+ if (res.code == "ok") {
|
|
|
+ this.$message({
|
|
|
+ message: '成功',
|
|
|
+ type: "success"
|
|
|
+ });
|
|
|
+ this.addfm = {name: ''}
|
|
|
+ this.addSubProject = false
|
|
|
+ this.getSub()
|
|
|
+ } else {
|
|
|
+ this.$message({
|
|
|
+ message: res.msg,
|
|
|
+ type: "error"
|
|
|
+ });
|
|
|
+ }
|
|
|
+ },
|
|
|
+ error => {
|
|
|
+ this.listLoading = false;
|
|
|
+ this.$message({
|
|
|
+ message: error,
|
|
|
+ type: "error"
|
|
|
+ });
|
|
|
+ }
|
|
|
+ );
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ },
|
|
|
+ created() {
|
|
|
+ this.getSub()
|
|
|
+ },
|
|
|
+ mounted() {
|
|
|
+
|
|
|
+ }
|
|
|
+ };
|
|
|
+</script>
|
|
|
+
|
|
|
+<style lang="scss" scoped>
|
|
|
+.addNode {
|
|
|
+ cursor:pointer;
|
|
|
+}
|
|
|
+.addNode:hover {
|
|
|
+ color:#20a0ff;
|
|
|
+}
|
|
|
+
|
|
|
+.panel {
|
|
|
+ padding:30px 15px ;box-shadow: 0 2px 4px rgba(3, 3, 3, 0.12), 0 0 6px rgba(0, 0, 0, .04);
|
|
|
+
|
|
|
+}
|
|
|
+.sample {
|
|
|
+ margin-top:30px;
|
|
|
+ color: #999;
|
|
|
+}
|
|
|
+.tip {
|
|
|
+ margin-left:10px; color:gray;
|
|
|
+
|
|
|
+}
|
|
|
+.tanjia {
|
|
|
+ float: right;
|
|
|
+ box-sizing: border-box;
|
|
|
+ margin: 10px 28px;
|
|
|
+}
|
|
|
+</style>
|