• elementUI-select 远程搜索


    设置三个远程属性,调用模糊接口<br><template>

      <ui-select
        v-model="dataId"
        filterable
        remote
        reserve-keyword
        placeholder="请输入人名进行搜索"
        :remote-method="userSearch"
        :loading="userSearchLoading"
        @change="userSelected">
        <ui-option
          v-for="item in userResult"
          :key="item.id"
          :label="item.userName"
          :value="item.id">
        </ui-option>
      </ui-select>
    </template>
     
    <script>
      import api from '@/api/user'
     
      export default {
        components: {},
        // 父组件构建user对象传入(内容id和userName)
        props: ['user'],
        methods: {
          userSearch(query) {
            if (query !== '') {
              this.userSearchLoading = true
              api.pageQueryOnJobUsers({
                userName: query
              })
              .then(r => {
                this.userResult = r.data.data.list
                this.userSearchLoading = false
              })
              .catch(r => {
                this.userSearchLoading = false
              })
            }
          },
          // 触发selectedUserId绑定的事件
          userSelected(value) {
            this.$emit('selectedUserId', value)
          }
        },
        mounted() {
        },
        data() {
          return {
            userSearchLoading: false,
            // 调用父组件的至进行填充(如有)
            userResult: this.user ? [this.user] : null,
            dataId: this.user ? this.user.id : null
          }
        }
      }
    </script>
     
    <!-- Add "scoped" attribute to limit CSS to this component only -->
    <style scoped lang="scss">
     
    </style>
  • 相关阅读:
    Activiti服务类- HistoryService服务类
    Activiti服务类- FormService服务类
    Activiti工作流学习(一)——Activiti服务类
    Java中实现短信发送
    Windows Server 2016 搭建 SMB 共享文件
    QT安装简介
    C# MD5加密解密类 winform
    git版本控制系统--git客户端
    git版本控制系统--git远程仓库(局域网windows)
    git版本控制系统--git远程仓库(局域网linux)
  • 原文地址:https://www.cnblogs.com/soonK/p/9518165.html
Copyright © 2020-2023  润新知