随笔 - 16,  文章 - 0,  评论 - 6,  阅读 - 4685
复制代码
    <el-form-item label="工序">
            <el-autocomplete placeholder=""
                             ref="el_auto"
                             v-model="searchForm.processName"
                             class="inline-input"
                             :fetch-suggestions="querySearch"
                             clearable
                             :debounce="10"
                             v-on:clear="clearSelect"
                             :popper-class="noData ? 'platform-auto-complete' : ''"
                             :popper-append-to-body="false"
                             :trigger-on-focus="true">
                <template v-if="noData" slot-scope="{ item }">
                    <div class="default">{{ item.default }}</div>
                </template>
            </el-autocomplete>
        </el-form-item>
复制代码

Js部分代码:

复制代码
 querySearch(queryString, callback) {
            var list = [];
            if (queryString && queryString.length > 0) {
                list = this.processNodeList.map(item => {
                    return {
                        id: `${item.id}`,
                        value: `${item.process_node_name}` //注意必须要用value,不然下拉框显示空白
                    }
                })
                list = list.filter(p => p.value.indexOf(queryString) > -1);
                if (list.length === 0) {
                    list = [{ default: '无匹配数据' }]
                    this.noData = true
                } else {
                    this.noData = false
                }
                callback(list);
            }
            else {
                list = this.processNodeList.slice(0, 10).map(item => {
                    return {
                        id: `${item.id}`,
                        value: `${item.process_node_name}`  
                    }
                });
                callback(list);
            }
        },
        handleSelect(item) {
            //console.log("item", item);
            this.searchForm.processId = item.id;
        },
        clearSelect() {
            this.$refs.el_auto.activated = true
        }
复制代码

CSS 部分代码:

复制代码
        .el-popper[x-placement^=bottom] {
            width: auto !important;
        }

        .platform-auto-complete {
            .el-autocomplete-suggestion__wrap
            {
                padding: 5px 0;
                pointer-events: none;
                .default{
                    text-align: center;
                    color: #999;
            }
            &:hover {
                background-color: #fff;
            }
            }
        }
复制代码

 

posted on   不讲武德的小趴菜  阅读(454)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 分享4款.NET开源、免费、实用的商城系统
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
· 记一次.NET内存居高不下排查解决与启示
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

点击右上角即可分享
微信分享提示