Переглянути джерело

调整移动端查看日报的人员搜索

Lijy 1 рік тому
батько
коміт
c91c82f615

+ 58 - 57
fhKeeper/formulahousekeeper/timesheet_h5/src/views/view/index.vue

@@ -15,7 +15,9 @@
                         </template>
                         <template #default>
                             <span v-if="user.userNameNeedTranslate == '1'">
-                                <ww-open-data type='departmentName' :openid='departmentText'></ww-open-data>
+                                <span v-if="departmentText">
+                                    <ww-open-data type='departmentName' :openid='departmentText'></ww-open-data>
+                                </span>
                             </span>
                             <span v-else>{{ departmentText }}</span>
                         </template>
@@ -25,14 +27,13 @@
                     <van-cell title="选择人员" clickable :value="userNameValue" @click="selectUserShow = true"
                         value-class="userNameValue">
                         <template #extra>
-                            <van-icon v-if="userNameValue" name="close" class="clearSeach"
+                            <van-icon v-if="selectPeopleVal.name" name="close" class="clearSeach"
                                 @click.stop="selectUserClear('user')" />
                         </template>
                         <template #default>
                             <span v-if="user.userNameNeedTranslate == '1'">
-                                <span v-for="item, index in userNameValue.split(',')" :key="item">
-                                    <ww-open-data type='userName' :openid='item'></ww-open-data>
-                                    <span v-if="index != (userNameValue.split(',').length - 1)">,</span>
+                                <span v-if="selectPeopleVal.name">
+                                    <ww-open-data type='userName' :openid='selectPeopleVal.name'></ww-open-data>
                                 </span>
                             </span>
                             <span v-else>{{ userNameValue }}</span>
@@ -192,29 +193,21 @@
             <!-- 人员选择 -->
             <van-popup v-model="selectUserShow" position="bottom" style="height: 90%">
                 <div class="popupDiv">
-                    <div class="popupSearch" v-if="user.userNameNeedTranslate != '1'">
-                        <van-search v-model="searchInputValue" placeholder="输入员工姓名搜索" @search="userListSearch" shape="round"
-                            background="#F4F4F4"></van-search>
+                    <div class="popupSearch">
+                        <van-search v-model.trim="searchInputValue" placeholder="输入员工姓名搜索" @clear="userListSearch" @search="userListSearch"
+                            shape="round" background="#F4F4F4"></van-search>
                     </div>
 
-                    <div class="popupCon conBorder">
-                        <div class="popupConBox" v-if="user.userNameNeedTranslate == '1'">
-                            <van-checkbox class="popupItem marginNone borderNone" v-for="(item) in showUserList"
-                                :key="item.id" v-model="item.isChecked">
-                                <span class="userNameClass_left">
-                                    <ww-open-data type='userName' :openid='item.name'></ww-open-data>
-                                </span>
-                                <span class="userNameClass_right">
-                                    {{ item.jobNumber }}
-                                </span>
-                            </van-checkbox>
-                        </div>
-                        <div class="popupConBox" v-else>
-                            <van-checkbox class="popupItem marginNone borderNone" v-for="(item) in showUserList"
-                                :key="item.id" v-model="item.isChecked">
-                                <span class="userNameClass_left">{{ item.name }}</span>
-                                <span class="userNameClass_right">{{ item.jobNumber }}</span>
-                            </van-checkbox>
+                    <div class="popupCon conBorder" style="flex: 1;background-color: #fff;">
+                        <div class="popupConBox">
+                            <van-radio-group v-model="selectPeopleVal">
+                                <van-radio v-for="uitem in showUserList" :key="uitem.id" :name="uitem" style="padding:10px"
+                                    class="popupItem marginNone borderNone">
+                                    <span v-if="user.userNameNeedTranslate == '1'"><ww-open-data type='userName'
+                                            :openid='uitem.name'></ww-open-data></span>
+                                    <span v-else>{{ uitem.name ? uitem.name : '' }}</span>
+                                </van-radio>
+                            </van-radio-group>
                         </div>
                     </div>
 
@@ -244,12 +237,9 @@
                         <el-tree :data="departmentList" :props="defaultProps" @node-click="treeNodeClick">
                             <span class="custom-tree-node" slot-scope="{ node }">
                                 <span v-if="user.userNameNeedTranslate == '1'">
-                                    <span v-if="node.data.children">
+                                    <span>
                                         <ww-open-data type='departmentName' :openid='node.label'></ww-open-data>
                                     </span>
-                                    <span v-else>
-                                        <ww-open-data type='userName' :openid='node.label'></ww-open-data>
-                                    </span>
                                 </span>
                                 <span v-if="user.userNameNeedTranslate != '1'">
                                     {{ node.label }}
@@ -294,6 +284,7 @@ export default {
             showUserList: '',
             userIdList: '',
             userNameValue: '',
+            selectPeopleVal: {},
 
             selectDepartmentShow: false,
             selectDepartmentText: [],
@@ -344,35 +335,45 @@ export default {
                 }).catch(err => { this.$toast.clear(); });
         },
         userListSearch(val) {
-            this.showUserList = [];
-            this.userList.forEach(u => {
-                if (u.name.startsWith(val)) {
-                    this.showUserList.push(u);
-                }
-            })
+            const { userNameNeedTranslate } = this.user
+            if(!this.searchInputValue) {
+                this.showUserList = JSON.parse(JSON.stringify(this.userList))
+                return
+            }
+
+            if (userNameNeedTranslate != 1) {
+                const newUserList = JSON.parse(JSON.stringify(this.userList))
+                this.showUserList = newUserList.filter(item => item.name.indexOf(this.searchInputValue) != -1)
+            }
+
+            if (userNameNeedTranslate == 1) {
+                this.$axios.post("/user/getEmployeeList", {
+                    departmentId: -1, pageIndex: 1, pageSize: 200,
+                    keyword: this.searchInputValue, status: '',
+                    roleId: '', cursor: '', onlyDirect: 0, matchingType: 0
+                })
+                    .then(res => {
+                        if (res.code == "ok") {
+                            const dataList = res.data.records
+                            const userNameList = dataList.map(item => item.name)
+                            const newUserList = JSON.parse(JSON.stringify(this.userList))
+                            this.showUserList = newUserList.filter(item => userNameList.some(uItem => uItem.includes(item.name)))
+                            console.log(userNameList)
+                        } else {
+                            this.$toast.fail('搜索失败');
+                        }
+                    }).catch(err => { this.$toast.clear(); });
+            }
         },
         selectUserConfirm() {
-            this.userNameValue = '';
-            var that = this;
-            that.userIdList = '';
-            this.userList.filter(u => u.isChecked).forEach(u => {
-                that.userNameValue += (u.name + ',');
-                that.userIdList += u.id + ','
-            });
-            if (this.userNameValue.length > 0) {
-                this.userNameValue = this.userNameValue.substring(0, this.userNameValue.length - 1);
-                this.userIdList = this.userIdList.substring(0, this.userIdList.length - 1);
-            }
-            this.$forceUpdate()
+            console.log(this.selectPeopleVal)
+
             this.selectUserShow = false
             this.getReport()
         },
         selectUserClear(str) {
             if (str == 'user') {
-                this.userNameValue = ''
-                this.userIdList = []
-                this.userList.forEach(item => { delete item.isChecked })
-                this.showUserList = this.userList
+                this.selectPeopleVal = {}
             }
             if (str == 'dept') {
                 this.departmentText = '',
@@ -433,8 +434,8 @@ export default {
             let pames = {
                 date: this.nowTime,
             }
-            if (this.userIdList) {
-                pames.userId = this.userIdList
+            if (this.selectPeopleVal.id) {
+                pames.userId = this.selectPeopleVal.id
             }
             if (this.departmentText && this.selectDepartmentText.length > 0) {
                 pames.deptId = this.selectDepartmentText[0].id
@@ -492,11 +493,11 @@ export default {
             sessionStorage.removeItem('targetDate');
         }
         const { functionList } = this.user
-        for(var i in functionList) {
-            if(functionList[i].name == '查看全公司工时') {
+        for (var i in functionList) {
+            if (functionList[i].name == '查看全公司工时') {
                 this.reportsCompany = true
             }
-            if(functionList[i].name == '查看本部门工时') {
+            if (functionList[i].name == '查看本部门工时') {
                 this.查看本部门工时 = true
             }
         }