<template>
    <div class='tj-list'>
        <div class='eq-list-top'>
            <el-input
                placeholder='请输入类别或品牌搜索'
                size='small'
                @change='getList'
                prefix-icon='el-icon-search'
                v-model='keyword'
                style='width:200px;margin-right:12px'
            ></el-input>
        </div>
        <el-table :data='tableData' style='width: 100%'>
            <el-table-column type='index' label='序号' width='80'></el-table-column>
            <el-table-column prop='lb' label='类别' width='160'></el-table-column>
            <el-table-column prop='sl' label='数量'></el-table-column>
            <el-table-column prop='brand' label='品牌'></el-table-column>
            <el-table-column prop='unit' label='单位'></el-table-column>
        </el-table>
        <div class='foot'>
            <el-pagination
                background
                layout='prev, pager, next'
                :total='total'
                :page-size='size'
                @prev-click='pageChanged'
                @next-click='pageChanged'
                @current-change='pageChanged'
            ></el-pagination>
        </div>
    </div>
</template>
<script>
import { queryEquipmentList } from '@/api/equipmentList.js'
export default {
    data() {
        return {
            pageSize: 10,
            tableData: [],
            total: 0,
            currentPage: 1,
            size: 10,
            keyword: ''
        }
    },
    props: ['major', 'param'],
    methods: {
        pageChanged(page, size) {
            this.currentPage = page
            this.getList()
        },
        getList() {
            let postParams = {
                tab_code: this.param
            }
            let data = {
                page: this.currentPage,
                size: this.size,
                plazaId: this.$store.state.plazaId,
                major: this.major,
                keyword: this.keyword
            }
            queryEquipmentList({ data, postParams }).then(res => {
                this.tableData = res.data.data
                this.total = res.data.count
            })
        }
    },
    watch: {
        param(newV, oldV) {
            if (newV !== oldV) {
                this.getList()
            }
        }
    },
    mounted() {
        this.getList()
    }
}
</script>
<style lang="less" scoped>
.tj-list {
    .eq-list-top {
        display: flex;
    }
    .foot {
        position: absolute;
        height: 32px;
        right: 26px;
    }
    td {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
}
</style>