Bladeren bron

优化昵称显示

kuaifan 5 jaren geleden
bovenliggende
commit
e45e7f17d9

+ 2 - 2
resources/assets/js/main/app.js

@@ -14,12 +14,12 @@ Vue.use(Language);
 
 import Title from '../_components/Title.vue'
 import sreachTitle from '../_components/sreachTitle.vue'
-import UseridInput from './components/UseridInput'
+import UserInput from './components/UserInput'
 import UserView from './components/UserView'
 
 Vue.component('VTitle', Title);
 Vue.component('sreachTitle', sreachTitle);
-Vue.component('UseridInput', UseridInput);
+Vue.component('UserInput', UserInput);
 Vue.component('UserView', UserView);
 
 import TaskDetail from './components/project/task/detail'

+ 2 - 2
resources/assets/js/main/components/UseridInput.vue

@@ -1,7 +1,7 @@
 <template>
     <div v-clickoutside="handleClose" @click="handleClose">
         <div v-if="multipleLists.length > 0" class="user-id-multiple">
-            <Tag v-for="(item, index) in multipleLists" :key="index" @on-close="() => { multipleLists.splice(index, 1); callMultipleLists() }" closable>{{item.nickname || item.username}}</Tag>
+            <Tag v-for="(item, index) in multipleLists" :key="index" @on-close="() => { multipleLists.splice(index, 1); callMultipleLists() }" closable><UserView :username="item.username"/></Tag>
         </div>
 
         <div class="user-id-input" ref="reference">
@@ -110,7 +110,7 @@
     import WLoading from "./WLoading";
 
     export default {
-        name: 'UseridInput',
+        name: 'UserInput',
         components: {WLoading},
         directives: {clickoutside, TransferDom},
         mixins: [Popper],

+ 14 - 10
resources/assets/js/main/components/UserView.vue

@@ -1,6 +1,6 @@
 <template>
     <div class="user-view-inline">
-        <Tooltip :disabled="!nickname" :delay="delay" :transfer="transfer">
+        <Tooltip :disabled="nickname === null" :delay="delay" :transfer="transfer" @on-popper-show="popperShow">
             {{nickname || username}}
             <div slot="content">
                 <div>用户名:{{username}}</div>
@@ -34,26 +34,30 @@
         },
         data() {
             return {
-                nickname: '',
+                nickname: null,
                 profession: ''
             }
         },
         mounted() {
-            this.getUserData(0);
+            this.getUserData(0, 300);
         },
         watch: {
             username() {
-                this.getUserData(0);
+                this.getUserData(0, 300);
             }
         },
         methods: {
-            getUserData(num) {
+            popperShow() {
+                this.getUserData(0, 60)
+            },
+
+            getUserData(num, cacheTime) {
                 let keyName = '__name:' + this.username.substring(0, 1) + '__';
                 let localData = $A.jsonParse(window.localStorage[keyName]);
                 if (localData.__loadIng === true) {
                     if (num < 100) {
                         setTimeout(() => {
-                            this.getUserData(num + 1)
+                            this.getUserData(num + 1, cacheTime)
                         }, 500);
                     }
                     return;
@@ -64,7 +68,7 @@
                 }
                 //
                 if (localData[this.username].success === true
-                    && localData[this.username].exptime > Math.round(new Date().getTime() / 1000)) {
+                    && localData[this.username].update + cacheTime > Math.round(new Date().getTime() / 1000)) {
                     this.nickname = localData[this.username].data.nickname;
                     this.profession = localData[this.username].data.profession;
                     return;
@@ -78,7 +82,7 @@
                     },
                     error: () => {
                         localData[this.username].success = false;
-                        localData[this.username].exptime = 0;
+                        localData[this.username].update = 0;
                         localData[this.username].data = {};
                         localData.__loadIng = false;
                         window.localStorage[keyName] = $A.jsonStringify(localData);
@@ -88,13 +92,13 @@
                             this.nickname = res.data.nickname;
                             this.profession = res.data.profession;
                             localData[this.username].success = true;
-                            localData[this.username].exptime = Math.round(new Date().getTime() / 1000) + 300;
+                            localData[this.username].update = Math.round(new Date().getTime() / 1000);
                             localData[this.username].data = res.data;
                         } else {
                             this.nickname = '';
                             this.profession = '';
                             localData[this.username].success = false;
-                            localData[this.username].exptime = 0;
+                            localData[this.username].update = 0;
                             localData[this.username].data = {};
                         }
                         localData.__loadIng = false;

+ 14 - 0
resources/assets/js/main/components/project/archived.vue

@@ -65,10 +65,24 @@
                 "title": this.$L("创建人"),
                 "key": 'createuser',
                 "minWidth": 80,
+                render: (h, params) => {
+                    return h('UserView', {
+                        props: {
+                            username: params.row.createuser
+                        }
+                    });
+                }
             }, {
                 "title": this.$L("负责人"),
                 "key": 'username',
                 "minWidth": 80,
+                render: (h, params) => {
+                    return h('UserView', {
+                        props: {
+                            username: params.row.username
+                        }
+                    });
+                }
             }, {
                 "title": this.$L("完成"),
                 "minWidth": 70,

+ 14 - 0
resources/assets/js/main/components/project/header/archived.vue

@@ -62,10 +62,24 @@
                 "title": this.$L("创建人"),
                 "key": 'createuser',
                 "minWidth": 80,
+                render: (h, params) => {
+                    return h('UserView', {
+                        props: {
+                            username: params.row.createuser
+                        }
+                    });
+                }
             }, {
                 "title": this.$L("负责人"),
                 "key": 'username',
                 "minWidth": 80,
+                render: (h, params) => {
+                    return h('UserView', {
+                        props: {
+                            username: params.row.username
+                        }
+                    });
+                }
             }, {
                 "title": this.$L("完成"),
                 "minWidth": 70,

+ 7 - 0
resources/assets/js/main/components/project/header/create.vue

@@ -62,6 +62,13 @@
                 "title": this.$L("负责人"),
                 "key": 'username',
                 "minWidth": 80,
+                render: (h, params) => {
+                    return h('UserView', {
+                        props: {
+                            username: params.row.username
+                        }
+                    });
+                }
             }, {
                 "title": this.$L("完成"),
                 "minWidth": 70,

+ 14 - 0
resources/assets/js/main/components/project/statistics.vue

@@ -176,10 +176,24 @@
                 "title": this.$L("创建人"),
                 "key": 'createuser',
                 "minWidth": 80,
+                render: (h, params) => {
+                    return h('UserView', {
+                        props: {
+                            username: params.row.createuser
+                        }
+                    });
+                }
             }, {
                 "title": this.$L("负责人"),
                 "key": 'username',
                 "minWidth": 80,
+                render: (h, params) => {
+                    return h('UserView', {
+                        props: {
+                            username: params.row.username
+                        }
+                    });
+                }
             }, {
                 "title": this.$L("完成"),
                 "minWidth": 70,

+ 1 - 1
resources/assets/js/main/components/project/task/add.vue

@@ -31,7 +31,7 @@
                     <div slot="content">
                         <div style="width:240px">
                             {{$L('选择负责人')}}
-                            <UseridInput v-model="addUsername" :projectid="projectid" @change="changeUser" :placeholder="$L('留空默认: 自己')" style="margin:5px 0 3px"></UseridInput>
+                            <UserInput v-model="addUsername" :projectid="projectid" @change="changeUser" :placeholder="$L('留空默认: 自己')" style="margin:5px 0 3px"></UserInput>
                         </div>
                     </div>
                 </Poptip>

+ 3 - 3
resources/assets/js/main/components/project/task/detail/detail.vue

@@ -27,7 +27,7 @@
                     <li v-if="followerLength(detail.follower) > 0" class="text-follower detail-icon">
                         <span>{{$L('关注者:')}}</span>
                         <em>
-                            <Tag v-for="(fname, findex) in detail.follower" :key="findex" closable @on-close="handleTask('unattention', {username:fname,uisynch:true})">{{fname}}</Tag>
+                            <Tag v-for="(fname, findex) in detail.follower" :key="findex" closable @on-close="handleTask('unattention', {username:fname,uisynch:true})"><UserView :username="fname"/></Tag>
                         </em>
                     </li>
                     <li class="text-level detail-icon">
@@ -74,7 +74,7 @@
                     <div slot="content">
                         <div style="width:280px">
                             {{$L('选择负责人')}}
-                            <UseridInput :projectid="detail.projectid" :nousername="detail.username" :transfer="false" @change="handleTask('usernameb', $event)" :placeholder="$L('输入关键词搜索')" style="margin:5px 0 3px"></UseridInput>
+                            <UserInput :projectid="detail.projectid" :nousername="detail.username" :transfer="false" @change="handleTask('usernameb', $event)" :placeholder="$L('输入关键词搜索')" style="margin:5px 0 3px"></UserInput>
                         </div>
                     </div>
                 </Poptip>
@@ -102,7 +102,7 @@
                     <div slot="content">
                         <div style="width:280px">
                             {{$L('选择关注人')}}
-                            <UseridInput :multiple="true" :transfer="false" v-model="detail.attentionLists" :placeholder="$L('输入关键词搜索')" style="margin:5px 0 3px"></UseridInput>
+                            <UserInput :multiple="true" :transfer="false" v-model="detail.attentionLists" :placeholder="$L('输入关键词搜索')" style="margin:5px 0 3px"></UserInput>
                             <Button :loading="!!loadData.attention" :disabled="!detail.attentionLists" class="btn" type="primary" style="text-align:center;width:72px;height:28px;font-size:13px" @click="handleTask('attention')">确 定</Button>
                         </div>
                     </div>

+ 7 - 0
resources/assets/js/main/components/project/task/files.vue

@@ -183,6 +183,13 @@
                     "minWidth": 90,
                     "maxWidth": 130,
                     "sortable": true,
+                    render: (h, params) => {
+                        return h('UserView', {
+                            props: {
+                                username: params.row.username
+                            }
+                        });
+                    }
                 });
                 columns.push({
                     "title": this.$L("上传时间"),

+ 7 - 0
resources/assets/js/main/components/project/task/lists.vue

@@ -150,6 +150,13 @@
                 "key": 'username',
                 "minWidth": 90,
                 "sortable": true,
+                render: (h, params) => {
+                    return h('UserView', {
+                        props: {
+                            username: params.row.username
+                        }
+                    });
+                }
             }, {
                 "title": this.$L("优先级"),
                 "key": 'level',

+ 1 - 1
resources/assets/js/main/components/project/task/logs.vue

@@ -11,7 +11,7 @@
                                     <img :src="item.userimg"/>
                                 </div>
                                 <div class="log-summary">
-                                    <span class="log-creator">{{item.username}}</span>
+                                    <span class="log-creator"><UserView :username="item.username"/></span>
                                     <span class="log-text-secondary">{{item.detail}}</span>
                                     <span v-if="item.other.type=='task' && taskid == 0" class="log-text-link" @click="taskDetail(item.other.id)">{{item.other.title}}</span>
                                     <a v-if="item.other.type=='file'" class="log-text-link" target="_blank" :href="fileDownUrl(item.other.id)">{{item.other.name}}</a>

+ 14 - 0
resources/assets/js/main/components/project/todo/attention.vue

@@ -62,10 +62,24 @@
                 "title": this.$L("创建人"),
                 "key": 'createuser',
                 "minWidth": 80,
+                render: (h, params) => {
+                    return h('UserView', {
+                        props: {
+                            username: params.row.createuser
+                        }
+                    });
+                }
             }, {
                 "title": this.$L("负责人"),
                 "key": 'username',
                 "minWidth": 80,
+                render: (h, params) => {
+                    return h('UserView', {
+                        props: {
+                            username: params.row.username
+                        }
+                    });
+                }
             }, {
                 "title": this.$L("完成"),
                 "minWidth": 70,

+ 14 - 0
resources/assets/js/main/components/project/todo/complete.vue

@@ -62,10 +62,24 @@
                 "title": this.$L("创建人"),
                 "key": 'createuser',
                 "minWidth": 80,
+                render: (h, params) => {
+                    return h('UserView', {
+                        props: {
+                            username: params.row.createuser
+                        }
+                    });
+                }
             }, {
                 "title": this.$L("负责人"),
                 "key": 'username',
                 "minWidth": 80,
+                render: (h, params) => {
+                    return h('UserView', {
+                        props: {
+                            username: params.row.username
+                        }
+                    });
+                }
             }, {
                 "title": this.$L("完成时间"),
                 "width": 160,

+ 1 - 1
resources/assets/js/main/components/project/users.vue

@@ -235,7 +235,7 @@
                                     marginBottom: '20px',
                                 }
                             }, this.$L('添加成员')),
-                            h('UseridInput', {
+                            h('UserInput', {
                                 props: {
                                     value: this.userValue,
                                     multiple: true,

+ 7 - 0
resources/assets/js/main/components/report/receive.vue

@@ -107,6 +107,13 @@
                 "sortable": true,
                 "minWidth": 80,
                 "maxWidth": 130,
+                render: (h, params) => {
+                    return h('UserView', {
+                        props: {
+                            username: params.row.username
+                        }
+                    });
+                }
             }, {
                 "title": this.$L("类型"),
                 "key": 'type',

+ 7 - 0
resources/assets/js/main/pages/docs/edit.vue

@@ -212,6 +212,13 @@
                 "key": 'username',
                 "minWidth": 80,
                 "maxWidth": 130,
+                render: (h, params) => {
+                    return h('UserView', {
+                        props: {
+                            username: params.row.username
+                        }
+                    });
+                }
             }, {
                 "title": " ",
                 "key": 'action',

+ 1 - 1
resources/assets/js/main/pages/project.vue

@@ -614,7 +614,7 @@
                                     marginBottom: '20px',
                                 }
                             }, this.$L('移交项目')),
-                            h('UseridInput', {
+                            h('UserInput', {
                                 props: {
                                     value: this.transferValue,
                                     nousername: item.username,