带建议的输入框,显示不全要带tooltip提示,禁止自定义条目

<el-autocomplete style="width: 98%;"
 size="mini"
  v-model="scope.row.Drug.value"
  :fetch-suggestions="
    (queryString, cb) => {
      querySearchAsync(queryString, cb, 1);
    }
  "
  @blur="onInputBlur(scope.row.Drug)"
  placeholder="请输入药品名称"
  @select="(item) => handleSelect(item, 1, scope.row)"
>
 <template slot-scope="{ item }" v-if="item.value.length>20">
    <el-tooltip
      class="item"
      effect="dark"
      :content="item.value"
      placement="right-end"
    >
      <div class="query-item-text" style=" width: 98%;
          overflow: hidden;
          text-overflow: ellipsis;
          white-space: nowrap">
        {{ item.value }}
    </div>
    </el-tooltip>
  </template>
</el-autocomplete>
// 远程搜索方法
    querySearchAsync(val, cb, flag) {
      var list = [{}];
      let params = {
        KeyWord: val,
        LinkageID: 0,
        FunCode: flag,
        PageInfo: {
          PageIndex: 1,
          PageSize: 100,
        },
      };
      Methods.requestData(Api.url.AAA, params)
        .then((data) => {
          console.log(27777, data);
          if (data.StatusCode === 200) {
            if (data.Content.length == 0) {
              this.SearchList = data.Content
              list = data.Content;
            }else {
              list = data.Content;
            }
            cb(list);
          }
        })
        .catch((error) => {
          console.log(error);
        });
    },
//失去焦点的时候,输入的不是数据里面的,自动清空内容
onInputBlur(val){
  console.log(2299, val)
   console.log(2299, this.SearchList)
   if (this.SearchList.length == 0) {
     console.log(3388, val)
     val.value = ''
   }
   console.log(3388, val)
 },

//选中项赋值
handleSelect(item, flag, scope) {
   if (flag === 1) {
     scope.Drug = item;
     scope.ClassName = item.ClassName;
     scope.ClassCode = item.ClassCode;
   }
 },
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值