|  | @@ -1,138 +1,125 @@
 | 
	
		
			
				|  |  |  <!-- 用户组件(返回更多信息) -->
 | 
	
		
			
				|  |  |  <template>
 | 
	
		
			
				|  |  | -    <div>
 | 
	
		
			
				|  |  | -      <el-select
 | 
	
		
			
				|  |  | -        v-model="value"
 | 
	
		
			
				|  |  | -        ref="select"
 | 
	
		
			
				|  |  | -        placeholder="请输入姓名"
 | 
	
		
			
				|  |  | -        clearable
 | 
	
		
			
				|  |  | -        filterable
 | 
	
		
			
				|  |  | -        remote
 | 
	
		
			
				|  |  | -        :disabled="disabled"
 | 
	
		
			
				|  |  | -        :remote-method="remoteMethod"
 | 
	
		
			
				|  |  | -        @change="onChange"
 | 
	
		
			
				|  |  | -        @focus="cancelReadOnly"
 | 
	
		
			
				|  |  | -        @hook:mounted="cancelReadOnly"
 | 
	
		
			
				|  |  | -        @visible-change="cancelReadOnly">
 | 
	
		
			
				|  |  | -        <el-option
 | 
	
		
			
				|  |  | -          v-for="item in options"
 | 
	
		
			
				|  |  | -          :key="item.value"
 | 
	
		
			
				|  |  | -          :label="item.label"
 | 
	
		
			
				|  |  | -          :value="item.value">
 | 
	
		
			
				|  |  | -        </el-option>
 | 
	
		
			
				|  |  | -        <el-option v-if="noMore" label="加载更多" disabled style="font-style: italic; color: #8a979e" value="undefined" @click.native="handleClick()"></el-option>
 | 
	
		
			
				|  |  | -      </el-select>
 | 
	
		
			
				|  |  | -    </div>
 | 
	
		
			
				|  |  | +  <div>
 | 
	
		
			
				|  |  | +    <el-select v-model="value" ref="select" placeholder="请输入姓名" clearable filterable remote :disabled="disabled"
 | 
	
		
			
				|  |  | +      :remote-method="remoteMethod" @change="onChange" @focus="cancelReadOnly" @hook:mounted="cancelReadOnly"
 | 
	
		
			
				|  |  | +      @visible-change="cancelReadOnly">
 | 
	
		
			
				|  |  | +      <el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value">
 | 
	
		
			
				|  |  | +      </el-option>
 | 
	
		
			
				|  |  | +      <el-option v-if="noMore" label="加载更多" disabled style="font-style: italic; color: #8a979e" value="undefined"
 | 
	
		
			
				|  |  | +        @click.native="handleClick()"></el-option>
 | 
	
		
			
				|  |  | +    </el-select>
 | 
	
		
			
				|  |  | +  </div>
 | 
	
		
			
				|  |  |  </template>
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  <script>
 | 
	
		
			
				|  |  | -  export default {
 | 
	
		
			
				|  |  | -    name: 'user-component',
 | 
	
		
			
				|  |  | -    props: {
 | 
	
		
			
				|  |  | -      userId: {
 | 
	
		
			
				|  |  | -        type: String,
 | 
	
		
			
				|  |  | -        default: ''
 | 
	
		
			
				|  |  | -      },
 | 
	
		
			
				|  |  | -      disabled: {
 | 
	
		
			
				|  |  | -        type: Boolean,
 | 
	
		
			
				|  |  | -        default: false
 | 
	
		
			
				|  |  | -      }
 | 
	
		
			
				|  |  | -    },
 | 
	
		
			
				|  |  | -    data () {
 | 
	
		
			
				|  |  | -      return {
 | 
	
		
			
				|  |  | -        value: '',
 | 
	
		
			
				|  |  | -        current: 1,
 | 
	
		
			
				|  |  | -        size: 10,
 | 
	
		
			
				|  |  | -        name: '',
 | 
	
		
			
				|  |  | -        options: [],
 | 
	
		
			
				|  |  | -        loading: false,
 | 
	
		
			
				|  |  | -        noMore: false
 | 
	
		
			
				|  |  | -      }
 | 
	
		
			
				|  |  | +export default {
 | 
	
		
			
				|  |  | +  name: 'user-component',
 | 
	
		
			
				|  |  | +  props: {
 | 
	
		
			
				|  |  | +    userId: {
 | 
	
		
			
				|  |  | +      type: String,
 | 
	
		
			
				|  |  | +      default: ''
 | 
	
		
			
				|  |  |      },
 | 
	
		
			
				|  |  | -    watch: {
 | 
	
		
			
				|  |  | -      // userId (value) {
 | 
	
		
			
				|  |  | -      //   this.value = value
 | 
	
		
			
				|  |  | -      // }
 | 
	
		
			
				|  |  | -      userId:{
 | 
	
		
			
				|  |  | -        immediate:true,
 | 
	
		
			
				|  |  | -        handler(newUserId){
 | 
	
		
			
				|  |  | -          this.value = newUserId
 | 
	
		
			
				|  |  | -          this.checkItem(newUserId)
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | +    disabled: {
 | 
	
		
			
				|  |  | +      type: Boolean,
 | 
	
		
			
				|  |  | +      default: false
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +  },
 | 
	
		
			
				|  |  | +  data() {
 | 
	
		
			
				|  |  | +    return {
 | 
	
		
			
				|  |  | +      value: '',
 | 
	
		
			
				|  |  | +      current: 1,
 | 
	
		
			
				|  |  | +      size: 10,
 | 
	
		
			
				|  |  | +      name: '',
 | 
	
		
			
				|  |  | +      options: [],
 | 
	
		
			
				|  |  | +      loading: false,
 | 
	
		
			
				|  |  | +      noMore: false
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +  },
 | 
	
		
			
				|  |  | +  watch: {
 | 
	
		
			
				|  |  | +    // userId (value) {
 | 
	
		
			
				|  |  | +    //   this.value = value
 | 
	
		
			
				|  |  | +    // }
 | 
	
		
			
				|  |  | +    userId: {
 | 
	
		
			
				|  |  | +      immediate: true,
 | 
	
		
			
				|  |  | +      handler(newUserId) {
 | 
	
		
			
				|  |  | +        this.value = newUserId
 | 
	
		
			
				|  |  | +        this.checkItem(newUserId)
 | 
	
		
			
				|  |  |        }
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +  },
 | 
	
		
			
				|  |  | +  mounted() {
 | 
	
		
			
				|  |  | +    this.init()
 | 
	
		
			
				|  |  | +  },
 | 
	
		
			
				|  |  | +  methods: {
 | 
	
		
			
				|  |  | +    async init() {
 | 
	
		
			
				|  |  | +      this.getList()
 | 
	
		
			
				|  |  |      },
 | 
	
		
			
				|  |  | -    mounted () {
 | 
	
		
			
				|  |  | -      this.init()
 | 
	
		
			
				|  |  | +    remoteMethod(query) {
 | 
	
		
			
				|  |  | +      this.options = []
 | 
	
		
			
				|  |  | +      this.current = 1
 | 
	
		
			
				|  |  | +      this.name = query
 | 
	
		
			
				|  |  | +      this.getList()
 | 
	
		
			
				|  |  |      },
 | 
	
		
			
				|  |  | -    methods: {
 | 
	
		
			
				|  |  | -      async init () {
 | 
	
		
			
				|  |  | -        this.getList()
 | 
	
		
			
				|  |  | -      },
 | 
	
		
			
				|  |  | -      remoteMethod (query) {
 | 
	
		
			
				|  |  | -        this.options = []
 | 
	
		
			
				|  |  | -        this.current = 1
 | 
	
		
			
				|  |  | -        this.name = query
 | 
	
		
			
				|  |  | -        this.getList()
 | 
	
		
			
				|  |  | -      },
 | 
	
		
			
				|  |  | -      getList () {
 | 
	
		
			
				|  |  | -        this.$http({
 | 
	
		
			
				|  |  | -          url: this.$http.adornUrl(`/user-service/user/list`),
 | 
	
		
			
				|  |  | -          method: 'get',
 | 
	
		
			
				|  |  | -          params: this.$http.adornParams({
 | 
	
		
			
				|  |  | -            'current': this.current,
 | 
	
		
			
				|  |  | -            'size': this.size,
 | 
	
		
			
				|  |  | -            'name': this.name
 | 
	
		
			
				|  |  | -          })
 | 
	
		
			
				|  |  | -        }).then(({data}) => {
 | 
	
		
			
				|  |  | -          if (data && data.code === '200') {
 | 
	
		
			
				|  |  | -            if (this.current > data.data.pages) {
 | 
	
		
			
				|  |  | -              return
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | -            this.noMore = data.data.records.length >= 10
 | 
	
		
			
				|  |  | -            data.data.records.forEach(item => {
 | 
	
		
			
				|  |  | -              this.options.push({
 | 
	
		
			
				|  |  | -                label: item.name + ' (' + item.orgName + ')',
 | 
	
		
			
				|  |  | -                value: item.userId,
 | 
	
		
			
				|  |  | -                name: item.name,
 | 
	
		
			
				|  |  | -                phone: item.mobile
 | 
	
		
			
				|  |  | -              })
 | 
	
		
			
				|  |  | -            })
 | 
	
		
			
				|  |  | -          } else {
 | 
	
		
			
				|  |  | -            this.options = []
 | 
	
		
			
				|  |  | -          }
 | 
	
		
			
				|  |  | -        })
 | 
	
		
			
				|  |  | -      },
 | 
	
		
			
				|  |  | -      handleClick () {
 | 
	
		
			
				|  |  | -        this.loadMore()
 | 
	
		
			
				|  |  | -      },
 | 
	
		
			
				|  |  | -      loadMore () {
 | 
	
		
			
				|  |  | -        this.current ++
 | 
	
		
			
				|  |  | -        this.getList()
 | 
	
		
			
				|  |  | -      },
 | 
	
		
			
				|  |  | -      onChange (item) {
 | 
	
		
			
				|  |  | -        this.options.forEach(val => {
 | 
	
		
			
				|  |  | -          if (val.value === item) {
 | 
	
		
			
				|  |  | -            this.$emit('change', val)
 | 
	
		
			
				|  |  | -          }
 | 
	
		
			
				|  |  | +    getList() {
 | 
	
		
			
				|  |  | +      this.$http({
 | 
	
		
			
				|  |  | +        url: this.$http.adornUrl(`/user-service/user/list`),
 | 
	
		
			
				|  |  | +        method: 'get',
 | 
	
		
			
				|  |  | +        params: this.$http.adornParams({
 | 
	
		
			
				|  |  | +          'current': this.current,
 | 
	
		
			
				|  |  | +          'size': this.size,
 | 
	
		
			
				|  |  | +          'name': this.name
 | 
	
		
			
				|  |  |          })
 | 
	
		
			
				|  |  | -      },
 | 
	
		
			
				|  |  | -      cancelReadOnly (onOff) {
 | 
	
		
			
				|  |  | -        this.$nextTick(() => {
 | 
	
		
			
				|  |  | -          if (!onOff) {
 | 
	
		
			
				|  |  | -            const input = this.$refs.select.$el.querySelector('.el-input__inner')
 | 
	
		
			
				|  |  | -            const timer = setTimeout(() => {
 | 
	
		
			
				|  |  | -              input.removeAttribute('readonly')
 | 
	
		
			
				|  |  | -              clearTimeout(timer)
 | 
	
		
			
				|  |  | -            }, 200)
 | 
	
		
			
				|  |  | +      }).then(({ data }) => {
 | 
	
		
			
				|  |  | +        if (data && data.code === '200') {
 | 
	
		
			
				|  |  | +          if (this.current > data.data.pages) {
 | 
	
		
			
				|  |  | +            return
 | 
	
		
			
				|  |  |            }
 | 
	
		
			
				|  |  | -        })
 | 
	
		
			
				|  |  | -      }
 | 
	
		
			
				|  |  | +          this.noMore = data.data.records.length >= 10
 | 
	
		
			
				|  |  | +          data.data.records.forEach(item => {
 | 
	
		
			
				|  |  | +            this.options.push({
 | 
	
		
			
				|  |  | +              label: item.name + ' (' + item.orgName + ')',
 | 
	
		
			
				|  |  | +              value: item.userId,
 | 
	
		
			
				|  |  | +              name: item.name,
 | 
	
		
			
				|  |  | +              phone: item.mobile
 | 
	
		
			
				|  |  | +            })
 | 
	
		
			
				|  |  | +          })
 | 
	
		
			
				|  |  | +        } else {
 | 
	
		
			
				|  |  | +          this.options = []
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +      })
 | 
	
		
			
				|  |  | +    },
 | 
	
		
			
				|  |  | +    handleClick() {
 | 
	
		
			
				|  |  | +      this.loadMore()
 | 
	
		
			
				|  |  | +    },
 | 
	
		
			
				|  |  | +    loadMore() {
 | 
	
		
			
				|  |  | +      this.current++
 | 
	
		
			
				|  |  | +      this.getList()
 | 
	
		
			
				|  |  | +    },
 | 
	
		
			
				|  |  | +    onChange(item) {
 | 
	
		
			
				|  |  | +      this.options.forEach(val => {
 | 
	
		
			
				|  |  | +        if (val.value === item) {
 | 
	
		
			
				|  |  | +          this.$emit('change', val)
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +      })
 | 
	
		
			
				|  |  | +    },
 | 
	
		
			
				|  |  | +    cancelReadOnly(onOff) {
 | 
	
		
			
				|  |  | +      this.$nextTick(() => {
 | 
	
		
			
				|  |  | +        if (!onOff) {
 | 
	
		
			
				|  |  | +          const input = this.$refs.select.$el.querySelector('.el-input__inner')
 | 
	
		
			
				|  |  | +          const timer = setTimeout(() => {
 | 
	
		
			
				|  |  | +            input.removeAttribute('readonly')
 | 
	
		
			
				|  |  | +            clearTimeout(timer)
 | 
	
		
			
				|  |  | +          }, 200)
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +      })
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |    }
 | 
	
		
			
				|  |  | +}
 | 
	
		
			
				|  |  |  </script>
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  <style scoped>
 | 
	
		
			
				|  |  | -.el-select{
 | 
	
		
			
				|  |  | +.el-select {
 | 
	
		
			
				|  |  |    width: 100%;
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  </style>
 |