ソースを参照

调整日报左边部门的搜索

Lijy 1 年間 前
コミット
9946bb1281

+ 48 - 13
fhKeeper/formulahousekeeper/timesheet/src/views/workReport/daily.vue

@@ -31,16 +31,16 @@
                             
                             </div> -->
                             <div style="width: 100%;box-sizing: border-box;padding-right: 10px;">
-                                <el-input :placeholder="$t('defaultText.PleaseEnterYourName')" v-if="user.userNameNeedTranslate != 1" size="small" v-model="seluserText" style="width:100%;margin-bottom:10px" clearable>
+                                <el-input :placeholder="$t('defaultText.PleaseEnterYourName')" size="small" v-model="seluserText" style="width:100%;margin-bottom:10px" clearable>
                                     <el-button slot="append" icon="el-icon-search" @click="seluserforText()"></el-button>
                                 </el-input>
                                 <el-select v-model="selectState" size="small" @change="stateChange" style="width:100%">
-                                <el-option value="-1" :label="$t('state.allState')">{{$t('state.allState')}}</el-option>
-                                <el-option value="-2" :label="$t('state.DidNotFillIn')">{{$t('state.DidNotFillIn')}}</el-option>
-                                <el-option value="1" :label="$t('state.alreadyPassed')">{{$t('state.alreadyPassed')}}</el-option>
-                                <el-option value="0" :label="$t('state.WaitingAudit')">{{$t('state.WaitingAudit')}}</el-option>
-                                <el-option value="2" :label="$t('state.notThrough')">{{$t('state.notThrough')}}</el-option>
-                                <el-option value="3" :label="$t('state.waitingsubmit')">{{$t('state.waitingsubmit')}}</el-option>
+                                    <el-option value="-1" :label="$t('state.allState')">{{$t('state.allState')}}</el-option>
+                                    <el-option value="-2" :label="$t('state.DidNotFillIn')">{{$t('state.DidNotFillIn')}}</el-option>
+                                    <el-option value="1" :label="$t('state.alreadyPassed')">{{$t('state.alreadyPassed')}}</el-option>
+                                    <el-option value="0" :label="$t('state.WaitingAudit')">{{$t('state.WaitingAudit')}}</el-option>
+                                    <el-option value="2" :label="$t('state.notThrough')">{{$t('state.notThrough')}}</el-option>
+                                    <el-option value="3" :label="$t('state.waitingsubmit')">{{$t('state.waitingsubmit')}}</el-option>
                                 </el-select>
                             </div>
                             <div>
@@ -4612,21 +4612,40 @@
                 }
             },
             //a按名称过滤部门人员
-            
-            seluserforText(){
+            async seluserforText(){
+                const { userNameNeedTranslate } = this.user
                 this.membCount = 0;
                 var newData = JSON.parse(JSON.stringify(this.allData));
-                this.seluserforTextin(this.seluserText, newData)
+                let textList = [this.seluserText]
+                if(userNameNeedTranslate == 1) {
+                    this.dataLoading = true
+                    let res = await this.postData('/user/getEmployeeList', {
+                        keyword: this.seluserText,
+                        cursor: '',
+                        departmentId: -1,
+                        pageIndex: 1,
+                        pageSize: 1000
+                    })
+                    textList = res.data.records.map(item => item.name)
+                    this.dataLoading = false
+                }
+                // return
+                console.log(textList, '<=== textList')
+                this.seluserforTextin(this.seluserText, newData, textList)
+                console.log(newData, 'Data')
                 this.data = newData;
                 this.calculateMembCount(this.data);
                 this.data[0].membCount = this.membCount;//总人数
             },
-            seluserforTextin(text, list){
+                seluserforTextin(text, list, textList = []){
                 for (var i =0;i<list.length; i++) {
                     var obj = list[i];
                     if (obj.isUser == 1) {
                         var match = false;
-                        if (obj.label.indexOf(text) != -1) {
+                        // if (obj.label.indexOf(text) != -1) {
+                        //     match = true
+                        // }
+                        if(textList.some(item => item.includes(obj.label))) {
                             match = true
                         }
                         if (!match) {
@@ -4636,7 +4655,7 @@
                         }
                     } else {
                         if (obj.children != null) {
-                            this.seluserforTextin(text, obj.children);
+                            this.seluserforTextin(text, obj.children, textList);
                         }
                     }
                 }
@@ -7804,6 +7823,22 @@
                     })
                 })
             },
+            // 封装 post 请求
+            postData(url, params) {
+                return new Promise((resolve, reject) => {
+                    this.http.post(url, { ...params },
+                    res => {
+                        resolve(res)
+                    },
+                    error => {
+                        this.$message({
+                            message: error,
+                            type: "error"
+                        });
+                        reject(error)
+                    })
+                })
+            },
             // 自定义事件
             selectCal(obj) {
                 console.log(obj, '传数据来源')