瀏覽代碼

Fix: 用户id显示问题

chris 3 年之前
父節點
當前提交
20b768e2a1

+ 1 - 0
src/views/modules/common/user-component-all.vue

@@ -1,3 +1,4 @@
+<!-- 用户组件(返回更多信息) -->
 <template>
     <div>
       <el-select

+ 31 - 1
src/views/modules/common/user-component.vue

@@ -1,3 +1,4 @@
+<!-- 用户组件(单选) -->
 <template>
     <div>
       <el-select
@@ -36,6 +37,13 @@
       prop: 'userId',
       event: 'userSelected'
     },
+    watch: {
+      userId (value) {
+        this.value = value
+        // 检查缺失item
+        this.checkItem(value)
+      }
+    },
     data () {
       return {
         value: '',
@@ -77,7 +85,9 @@
             data.data.records.forEach(item => {
               this.options.push({
                 label: item.name + ' (' + item.orgName + ')',
-                value: item.userId
+                value: item.userId,
+                name: item.name,
+                phone: item.mobile
               })
             })
           } else {
@@ -98,6 +108,26 @@
         }
         this.$emit('userSelected', item)
       },
+      checkItem (code) {
+        console.log('code = ' + code)
+        // console.log(this.options)
+        if (!code || !this.options) return
+        let i = this.options.findIndex(item => item.value === code)
+        console.log('i = ' + i)
+        if (i > -1) return
+        // info
+        this.$http({
+          url: this.$http.adornUrl(`/user-service/user/info/${code}`),
+          method: 'get'
+        }).then(({data}) => {
+          if (data && data.code === '200' && data.data) {
+            this.options.push({
+              label: data.data.name + ' (' + data.data.orgName + ')',
+              value: data.data.userId
+            })
+          }
+        })
+      },
       cancelReadOnly (onOff) {
         this.$nextTick(() => {
           if (!onOff) {

+ 11 - 6
src/views/modules/common/user-components.vue

@@ -1,3 +1,4 @@
+<!-- 用户组件(多选) -->
 <template>
     <div>
       <el-select
@@ -27,7 +28,7 @@
 
 <script>
   export default {
-    name: 'user-component',
+    name: 'user-components',
     props: {
       userIds: {
         type: Array,
@@ -52,6 +53,8 @@
     watch: {
       userIds (value) {
         this.value = value
+        // 检查缺失item
+        // this.checkItem(value)
       }
     },
     mounted () {
@@ -81,11 +84,7 @@
             if (this.current > data.data.pages) {
               return
             }
-            if (data.data.records.length < 10) {
-              this.noMore = false
-            } else {
-              this.noMore = true
-            }
+            this.noMore = data.data.records.length >= 10
             data.data.records.forEach(item => {
               this.options.push({
                 label: item.name + ' (' + item.orgName + ')',
@@ -104,6 +103,12 @@
         this.current ++
         this.getList()
       },
+      // checkItem (code) {
+      //   if (!code || !this.options) return
+      //   let i = this.options.findIndex(item => item.value === code)
+      //   if (i < 0) return
+      //   // todo
+      // },
       onChange (item) {
         this.$emit('change', item)
       },

+ 3 - 3
src/views/modules/cus/customer-add-or-update.vue

@@ -66,7 +66,7 @@
         <el-input v-model="dataForm.contactEmail" :disabled="display" placeholder="邮箱"></el-input>
       </el-form-item>
       <el-form-item label="对接业务员" prop="bizManager">
-        <user-component-all v-model="dataForm.bizManager" :disabled="display" :userId="dataForm.bizManager" @change="change"/>
+        <user-component v-model="dataForm.bizManager" :disabled="display" :user-id.sync="dataForm.bizManager" @userSelected="change"/>
         <!-- <el-input v-model="dataForm.bizManager"  placeholder="对接业务员"></el-input> -->
       </el-form-item>
       <h4>财务信息</h4>
@@ -94,10 +94,10 @@
 </template>
 
 <script>
-  import UserComponentAll from '../common/user-component-all'
+  import UserComponent from '../common/user-component'
   import { getLevel } from '@/api/cus'
   export default {
-    components: { UserComponentAll },
+    components: { UserComponent },
     computed: {
       orgId: {
         get () { return this.$store.state.user.orgId }

+ 4 - 2
src/views/modules/sys/user.vue

@@ -49,7 +49,8 @@
         prop="orgName"
         header-align="center"
         align="center"
-        min-width="100"
+        min-width="140"
+        :show-tooltip-when-overflow="true"
         label="所属机构">
       </el-table-column>
       <el-table-column
@@ -64,6 +65,7 @@
         header-align="center"
         align="center"
         min-width="120"
+        :show-tooltip-when-overflow="true"
         label="邮箱">
       </el-table-column>
       <el-table-column
@@ -80,7 +82,7 @@
         prop="createTime"
         header-align="center"
         align="center"
-        width="180"
+        width="160"
         label="创建时间">
       </el-table-column>
       <el-table-column