瀏覽代碼

Fix: 用户id显示问题

chris 3 年之前
父節點
當前提交
819c687409
共有 2 個文件被更改,包括 24 次插入10 次删除
  1. 0 3
      src/views/modules/common/user-component.vue
  2. 24 7
      src/views/modules/common/user-components.vue

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

@@ -109,11 +109,8 @@
         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({

+ 24 - 7
src/views/modules/common/user-components.vue

@@ -54,7 +54,7 @@
       userIds (value) {
         this.value = value
         // 检查缺失item
-        // this.checkItem(value)
+        this.checkItems(value)
       }
     },
     mounted () {
@@ -103,12 +103,29 @@
         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
-      // },
+      checkItem (code) {
+        if (!code || !this.options) return
+        let i = this.options.findIndex(item => item.value === code)
+        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
+            })
+          }
+        })
+      },
+      checkItems (ids) {
+        if (!ids) return
+        ids.forEach(id => {
+          this.checkItem(id)
+        })
+      },
       onChange (item) {
         this.$emit('change', item)
       },