多个输入框实现串联筛选

需求描述:调接口获取数据,前端通过条件进行模糊筛选,效果图如下:

在这里插入图片描述
在这里插入图片描述

在这里插入图片描述

<template>
<div>
    <el-table border class="search-table" :data="tableData2">
        <el-table-column align="center" fixed type="selection" width="50" />
        <el-table-column fixed label="序号" type="index">
            <template #header>
                <div class="th-head">序号</div>
            </template>
            <template slot-scope="scope">
                {{ scope.$index + 1 }}
            </template>
        </el-table-column>
        <el-table-column fixed label="物料名称" prop="name" width="150">
            <template #header>
                <div class="th-head">物料名称</div>
                <el-input v-model="query.name" placeholder="输入物料名称查询" />
            </template>
        </el-table-column>
        <el-table-column label="规格说明" prop="desc" width="150">
            <template #header>
                <div class="th-head">规格说明</div>
                <el-input v-model="query.desc" placeholder="输入规格说明查询" />
            </template>
        </el-table-column>
        <el-table-column label="单位" prop="unit" width="120">
            <template #header>
                <div class="th-head">单位</div>
                <el-input v-model="query.unit" placeholder="输入单位查询" />
            </template>
        </el-table-column>
        <el-table-column align="right" header-align="left" label="不含税单价" prop="price" width="120">
            <template #header>
                <div class="th-head">不含税单价</div>
                <el-input v-model="query.price" placeholder="输入不含税单价查询" />
            </template>
        </el-table-column>
        <el-table-column align="right" header-align="left" label="含税单价" prop="pricevat" width="120">
            <template #header>
                <div class="th-head">含税单价</div>
                <el-input v-model="query.pricevat" placeholder="输入含税单价查询" />
            </template>
        </el-table-column>
        <el-table-column label="订单量" prop="quantity" width="300">
            <template #header>
                <div class="th-head">订单量</div>
                <el-input v-model="query.quantity" placeholder="输入订单量查询" />
            </template>
        </el-table-column>
        <el-table-column label="到货量" prop="zip" width="300">
            <template #header>
                <div class="th-head">到货量</div>
                <el-input v-model="query.zip" placeholder="输入到货量查询" />
            </template>
        </el-table-column>
        <el-table-column label="收获单位" prop="city" width="300">
            <template #header>
                <div class="th-head">收获单位</div>
                <el-input v-model="query.city" placeholder="输入收获单位查询" />
            </template>
        </el-table-column>
        <el-table-column fixed="right" label="操作" width="100">
            <template #header>
                <div class="th-head">操作</div>
            </template>
            <template #default="{ row }">
                <el-button size="small" type="text" @click="handleClick(row)">
                    查看
                </el-button>
            </template>
        </el-table-column>
    </el-table>
</div>
</template>

<script>
export default {
    data() {
        return {
            tableData: [{
                    date: '2016-05-02',
                    name: '张小虎',
                    province: '上海',
                    city: '地方接电话',
                    address: '上海市普陀区金沙江路 1518 弄',
                    zip: '地方共和国股份回购',
                    desc: '哈哈哈哈',
                    price: '125',
                    pricevat: '230'
                },
                {
                    date: '2016-05-04',
                    name: '王大虎',
                    province: '上海',
                    city: '是经典款待付款',
                    address: '上海市普陀区金沙江路 1517 弄',
                    zip: '大结局几篇',
                    price: '125',
                    pricevat: '120,344,000.27',
                    desc: '信息已想哈',
                },
                {
                    date: '2016-05-01',
                    name: '李小虎',
                    province: '上海',
                    city: '近段时间',
                    address: '上海市普陀区金沙江路 1519 弄',
                    zip: '的会计考试',
                    price: '1,001,230,000.25',
                    pricevat: '120',
                    desc: '黑乎乎啥啥啥',
                },
                {
                    date: '2016-05-03',
                    name: '陈大虎',
                    province: '上海',
                    city: '普陀区',
                    address: '上海市普陀区金沙江路 1516 弄',
                    zip: '豆腐鱼页面快乐',
                    price: '10,023,000.25',
                    pricevat: '12',
                    desc: '就是调平看一眼2',
                },
                {
                    date: '2016-05-03',
                    name: '陈大王',
                    province: '上海',
                    city: '普陀区',
                    address: '上海市普陀区金沙江路 1516 弄',
                    zip: '豆腐鱼页面快乐3',
                    price: '20.25',
                    pricevat: '12,008,900.27',
                    desc: '就是调平看三眼',
                },
                {
                    date: '2016-05-03',
                    name: '陈大事',
                    province: '上海',
                    city: '普陀区',
                    address: '上海市普陀区金沙江路 1516 弄',
                    zip: '豆腐鱼页面快乐3',
                    price: '10',
                    pricevat: '12,008,900.27',
                    desc: '就是调平看二眼',
                },
            ],
            query: {
                name: '',
                desc: '',
                unit: '',
                price: '',
                pricevat: '',
                quantity: '',
                arrived: '',
                arrivedcompany: '',
            },
        }
    },
    computed: {
        //俩input输入值筛选
        tableData2() {
            return this.tableData.filter(
                //name,desc是要筛选的两个属性,this.query.name,this.query.dec是两个input框里v-model绑定的输入的两个值
                item =>
                item.name.includes(this.query.name) && item.desc.includes(this.query.desc) &&
                item.price.includes(this.query.price) && item.pricevat.includes(this.query.pricevat)

            )
        },
    },
}
</script>

<style lang="less" scoped>
.el-table th.el-table__cell.el-table__cell,
.el-table th.el-table__cell .cell {
    background: #cccd;
    color: #666;
}

.search-table {
    th.el-table__cell {
        vertical-align: top;
        padding-top: 0;
        padding-bottom: 0;
    }

    .th-head {
        background: #cccd;
        border-bottom: 1px solid #e6ecf6;
        padding: 8px 10px;
        // height: 40px;
        box-sizing: border-box;
    }

    th.el-table__cell>.cell.cell {
        font-weight: 500;
        color: #282828;
        padding-left: 0;
        padding-right: 0;
    }

    th.el-table-column--selection .cell {
        background: #cccd;
        border-bottom: 1px solid #e6ecf6;
        padding-left: 10px;
        padding-right: 10px;
        padding-top: 8px;
        padding-bottom: 8px;
        height: 40px;
        box-sizing: border-box;
    }

    tr td.el-table__cell:first-child .cell .el-checkbox {
        padding-left: 4px;
    }

    // 输入框
    th .el-input__inner {
        border-color: transparent;
        padding-left: 10px;
    }

    th .el-input__inner:focus {
        border-color: #1890ff;
    }
}
</style>


在这里插入图片描述

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

吃葡萄不吐葡萄皮嘻嘻

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值