<!-- 维修-->
<template>
    <div class='wb-list'>
        <div class='eq-list-top'>
            <a-input-search
                placeholder='按照设备名称、设备编号、重要事项记录、描述、任务编号等搜索'
                style='width: 192px;margin-bottom:12px;height:32px;margin-right:12px'
                @search='onSearch'
            />
            <el-date-picker size='small' v-model='startDate' type='date' placeholder='选择填报时间' @change='getList' style='margin-right:12px'></el-date-picker>
            <el-date-picker size='small' v-model='endDate' type='date' placeholder='选择验收时间' @change='getList' style='margin-right:12px'></el-date-picker>
            <Select @change='getList' width='120' tipPlace='top' caption='是否更换配件信息 ：' :selectdata='floorSelect'></Select>
            <Select @change='getList' width='120' tipPlace='top' caption='楼层 ：' :selectdata='floorSelect'></Select>
        </div>
        <el-table :data='tableData' style='width: 100%'>
            <el-table-column type='index' label='序号' width='80'></el-table-column>
            <el-table-column prop='sbjc' label='设备名称' width='160'></el-table-column>
            <el-table-column prop='sbjbm' label='设备编码'></el-table-column>
            <el-table-column prop='matters' label='重要事项记录'></el-table-column>
            <el-table-column prop='description' label='描述'></el-table-column>
            <el-table-column label='更换配件信息'>
                <el-table-column prop='ischangepj' label='是/否更换' width='120'></el-table-column>
                <el-table-column prop='model' label='配件名称型号' width='120'></el-table-column>
                <el-table-column prop='address' label='数量' width='300'></el-table-column>
                <el-table-column prop='cost' label='费用(万元)' width='120'></el-table-column>
                <el-table-column prop='source' label='费用出处' width='120'></el-table-column>
            </el-table-column>
            <el-table-column prop='brand' label='现场照片'></el-table-column>
            <el-table-column prop='startDate' label='填报时间'></el-table-column>
            <el-table-column prop='enddate' label='验收时间'></el-table-column>
            <el-table-column prop='wonum' 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 { queryWx } from '@/api/equipmentList.js'
import { mapGetters } from 'vuex'
export default {
    data() {
        return {
            pageSize: 10,
            tableData: [],
            total: 0,
            currentPage: 1,
            size: 10,
            floorSelect: [],
            startDate: '',
            endDate: ''
        }
    },
    computed: {
        ...mapGetters(['floorsArr'])
    },
    props: ['smsxt', 'major'],
    methods: {
        onSearch() {},
        pageChanged(page, size) {
            this.currentPage = page
            this.size = size
            this.getList()
        },
        getList() {
            let getParams = {
                data: {
                    smsxt: this.smsxt,
                    tab: this.major,
                    // plazaId: this.$store.state.plazaId,
                    plazaId: '1000303',
                    page: this.currentPage,
                    size: this.size
                }
            }
            queryWx(getParams).then(res => {
                this.tableData = res.data || []
                this.total = res.count
            })
        },
        init() {
            this.floorSelect = []
            if (this.floorsArr.length > 0) {
                this.floorsArr.forEach(e => {
                    let obj = {
                        id: e,
                        name: e
                    }
                    this.floorSelect.push(obj)
                })
            }
        }
    },
    watch: {
        smsxt(newV, oldV) {
            if (newV !== oldV) {
                this.init()
                this.getList()
            }
        }
    },
    mounted() {
        this.init()
        this.getList()
    }
}
</script>
<style lang="less" scoped>
.wb-list {
    .eq-list-top {
        display: flex;
    }
    .foot {
        position: absolute;
        height: 32px;
        right: 26px;
    }
    td {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
}
</style>