Browse Source

提交移动端执行人加搜索

Lijy 2 years ago
parent
commit
12305f7b01
1 changed files with 47 additions and 8 deletions
  1. 47 8
      fhKeeper/formulahousekeeper/timesheet_h5/src/views/task/editask.vue

+ 47 - 8
fhKeeper/formulahousekeeper/timesheet_h5/src/views/task/editask.vue

@@ -70,7 +70,7 @@
                     <van-icon v-if="index != 0 && canEdit" class="delete_executor" name="delete-o" @click.stop="deleteExecutor(index)" />
                 </div>
                 <van-popup v-model="executor.show" position="bottom" v-if="canEdit">
-                    <van-search v-model="executor.searchText" placeholder="输入员工姓名搜索" @search="onSearch" v-if="user.userNameNeedTranslate != '1'"></van-search>
+                    <van-search v-model="executor.searchText" placeholder="输入员工姓名搜索" @input="onSearch" v-if="user.userNameNeedTranslate != '1'"></van-search>
                     <div style="minHeight:300px;">
                         <van-radio-group v-model="executor.item">
                             <van-radio v-for="uitem in executor.searchList" :key="uitem.id" :name="uitem" style="padding:10px">
@@ -101,7 +101,7 @@
             </van-form>
             <div class="form_btn" style="position:fixed; bottom:0px;width:100%;">
                 <div style="padding-bottom:10px;">
-                    <van-button square block type="info" @click="submitTask" native-type="submit" style="width:100%;float:left;" :disabled="!canEdit">
+                    <van-button square block type="info" loading-text="保存中..." @click="submitTask" native-type="submit" :loading="submitTaskBtn" style="width:100%;float:left;" :disabled="!canEdit">
                         <div v-if="canEdit">保存</div>
                         <div v-else>暂无权限编辑</div>
                     </van-button>
@@ -125,6 +125,7 @@ export default {
             minDate: new Date(2020,0,1),
             maxDate: new Date(2025,11,31),
             canEdit: true,
+            onSearchTime: null,
             taskform:{      // 表单
                 taskType: 0,
                 name: '',
@@ -142,6 +143,9 @@ export default {
             startDateShow: false,
             endDateShow: false,
             finishDateShow: false,
+
+            submitTaskBtn: false,
+
             taskLevel:{
                 show: false,
                 list: ['一般','重要','紧急']
@@ -172,6 +176,7 @@ export default {
                 startDate: null,
                 endDate: null,
                 finishDate: null,
+                taskDesc: '',
                 taskLevel: 0,
                 executorList: [{executorName: '',executorId: '',planHours: this.user.timeType.allday}]
             }
@@ -228,11 +233,39 @@ export default {
             this.$forceUpdate();
         },
         onSearch(val) {
-            console.log(val);
-            this.executor.searchList = [];
-            this.executor.list.forEach(u=>{if (u.name.startsWith(val)) {
-                this.executor.searchList.push(u);
-            }})
+            if(this.user.userNameNeedTranslate != 1) {
+                this.executor.searchList = [];
+                this.executor.list.forEach(u=>{if (u.name.startsWith(val)) {
+                    this.executor.searchList.push(u);
+                }})
+            } else {
+                if (this.onSearchTime != null) {
+                    clearTimeout(this.onSearchTime)
+                }
+                var that = this
+                this.onSearchTime = setTimeout(() => {
+                    that.getOnSearch(val)
+                }, 500)
+            }
+        },
+        getOnSearch(val) {
+            this.$axios.post("/user/getEmployeeList", {
+                departmentId: -1,
+                pageIndex: 1,
+                pageSize: 200,
+                keyword: val,
+                status: 1,
+                roleId: '',
+                cursor: '',
+                onlyDirect: 0,
+            })
+            .then(res => {
+                if(res.code == "ok") {
+                    this.executor.searchList = res.data.nextCursor
+                } else {
+                    this.$toast.fail('搜索失败');
+                }
+            }).catch(err=> {this.$toast.clear();console.log(err)});
         },
         searchExecutor(){
             this.taskform.executorList[this.executor.index].executorId = this.executor.item.id
@@ -272,15 +305,18 @@ export default {
             delete this.taskform.subTaskList;
             delete this.taskform.refTaskList;
             delete this.taskform.progress;
+            this.submitTaskBtn = true
+            // return
             this.$axios.post("/task/save", this.taskform)
             .then(res => {
+                this.submitTaskBtn = false
                 if(res.code == "ok") {
                     this.$toast.success('保存成功');
                     this.back()
                 } else {
                     this.$toast.fail('保存失败');
                 }
-            }).catch(err=> {this.$toast.clear();console.log(err)});
+            }).catch(err=> {this.$toast.clear();console.log(err);this.submitTaskBtn = false});
 
         },
         htmleditor(e) {
@@ -296,6 +332,9 @@ export default {
                     this.taskform.createDate = null;
                     this.taskform.indate = null;
                     let projectManagement = false
+                    if(!this.taskform.taskDesc){
+                        this.taskform.taskDesc = ''
+                    }
                     if(this.taskform.startDate){
                         this.currentDate1 = new Date(this.taskform.startDate)
                     }