Lijy 2 роки тому
батько
коміт
d05e9769e8

+ 41 - 30
fhKeeper/formulahousekeeper/timesheet/src/views/project/projectInside.vue

@@ -748,13 +748,13 @@
             <div slot="title" >
                 <el-tabs v-model="createGroupWay">
                 <el-tab-pane label="新建分组" name="new">
-                    <el-form ref="form2" :model="groupForm" :rules="rules" style="margin-top:40px;">
-                    <el-form-item prop="name">
-                        <el-input v-model="groupForm.name" placeholder="请输入分组名称" maxlength="50"
-                            show-word-limit clearable></el-input>
-                    </el-form-item>
-                    <el-button type="primary" @click="addGroup" style="width:100%;" >创建</el-button>
-                </el-form>
+                    <el-form ref="formGrouping" :model="groupForm" :rules="formGrouping" style="margin-top:40px;">
+                        <el-form-item prop="name">
+                            <el-input v-model.trim="groupForm.name" placeholder="请输入分组名称" maxlength="50"
+                                show-word-limit clearable></el-input>
+                        </el-form-item>
+                        <el-button type="primary" @click="addGroup('formGrouping')" style="width:100%;" >创建</el-button>
+                    </el-form>
                 </el-tab-pane>
                 <el-tab-pane label="从模板创建" name="template">
                     <el-card class="template_box" :style="t.selected?'border: 1px solid #409eff;':''" v-for="(t,tIndex) in groupTemplateList" :key="t.id"  @click.native="choseTemplate(tIndex)">
@@ -1001,6 +1001,9 @@ import delete$ from 'dingtalk-jsapi/api/biz/cspace/delete';
                 taskRules : {
                     name: [{ required: true, message: "请输入任务内容", trigger: "blur" }],
                 },
+                formGrouping: {
+                    name: [{ required: true, message: "请输入分组名称", trigger: "blur" }],
+                },
                 sleectId: null,
                 sleectProjectId: null,
                 sidebarIndex: 0, // 侧边栏索引
@@ -2609,31 +2612,39 @@ import delete$ from 'dingtalk-jsapi/api/biz/cspace/delete';
             },
 
             // 重新定义了 addGroup 方法
-             addGroup() {
-                this.http.post('/task-group/save',this.groupForm,
-                res => {
-                    if (res.code == "ok") {
-                        this.groupList = res.data;
-                        this.addGroupDialog = false;
-                        this.modGroupDialog = false;
-                        if (this.selectedGroup.id !== this.groupForm.id) {
-                            this.selectedGroup = this.groupList.filter(g=>g.new)[0];
-                        }
-                        this.defaultGroupId = this.groupList[this.groupList.length - 1].id
-                        // this.getTaskGroup();
-                        this.getStageList()
-                    } else {
-                        this.$message({
-                        message: res.msg,
-                        type: "error"
+             addGroup(formName) {
+                // return
+                this.$refs[formName].validate((valid) => {
+                    if (valid) {
+                        this.http.post('/task-group/save',this.groupForm,
+                        res => {
+                            if (res.code == "ok") {
+                                this.groupList = res.data;
+                                this.addGroupDialog = false;
+                                this.modGroupDialog = false;
+                                if (this.selectedGroup.id !== this.groupForm.id) {
+                                    this.selectedGroup = this.groupList.filter(g=>g.new)[0];
+                                }
+                                this.defaultGroupId = this.groupList[this.groupList.length - 1].id
+                                // this.getTaskGroup();
+                                this.getStageList()
+                            } else {
+                                this.$message({
+                                message: res.msg,
+                                type: "error"
+                                });
+                            }
+                        },
+                        error => {
+                            this.$message({
+                                message: error,
+                                type: "error"
+                            });
                         });
+                    } else {
+                        console.log('error submit!!');
+                        return false;
                     }
-                },
-                error => {
-                    this.$message({
-                        message: error,
-                        type: "error"
-                    });
                 });
             },