<!-- 维保 -->
<template>
    <div class='wb-list'>
        <div class='eq-list-top'>
            <el-input
                placeholder='搜索设备名称、编号'
                size='small'
                @change='getList'
                prefix-icon='el-icon-search'
                v-model='keyword'
                style='width:192px;margin-right:12px'
            ></el-input>
            <el-input
                placeholder='搜索重要事项记录、描述'
                size='small'
                @change='getList'
                prefix-icon='el-icon-search'
                v-model='keyword'
                style='width:192px;margin-right:12px'
            ></el-input>
            <el-input
                placeholder='搜索任务编号'
                size='small'
                @change='getList'
                prefix-icon='el-icon-search'
                v-model='keyword'
                style='width:192px;margin-right:12px'
            ></el-input>
            <el-date-picker
                size='small'
                v-model='reportdate'
                type='date'
                placeholder='选择填报时间'
                @change='getList'
                style='width:180px;margin-right:12px'
            ></el-date-picker>
            <el-date-picker size='small' v-model='sjjssj' type='date' placeholder='选择验收时间' @change='getList' style='width:180px;margin-right:12px'></el-date-picker>
            <Select @change='getList' v-model='ischange' width='180' tipPlace='top' caption='是否更换配件信息 ：' :selectdata='changeOption'></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='设备名称' show-overflow-tooltip resizable>
                <template slot-scope='{row}'>{{row.sbjc || '--'}}</template>
            </el-table-column>
            <el-table-column prop='sbjbm' label='设备编码' show-overflow-tooltip resizable>
                <template slot-scope='{row}'>{{row.sbjbm || '--'}}</template>
            </el-table-column>
            <el-table-column prop='matters' label='重要事项记录' show-overflow-tooltip resizable>
                <template slot-scope='{row}'>{{row.matters || '--'}}</template>
            </el-table-column>
            <el-table-column prop='description' label='描述' show-overflow-tooltip resizable>
                <template slot-scope='{row}'>{{row.description || '--'}}</template>
            </el-table-column>
            <el-table-column label='更换配件信息' align='center'>
                <el-table-column prop='ischangepj' label='是/否更换'>
                    <template slot-scope='{row}'>{{row.ischangepj || '--'}}</template>
                </el-table-column>
                <el-table-column prop='model' label='配件名称型号' show-overflow-tooltip resizable>
                    <template slot-scope='{row}'>{{row.model || '--'}}</template>
                </el-table-column>
                <el-table-column prop='sl' label='数量'>
                    <template slot-scope='{row}'>{{row.sl || '--'}}</template>
                </el-table-column>
                <el-table-column prop='cost' label='费用(万元)'>
                    <template slot-scope='{row}'>{{row.cost || '--'}}</template>
                </el-table-column>
                <el-table-column prop='source' label='费用出处' show-overflow-tooltip resizable>
                    <template slot-scope='{row}'>{{number_format(row.source,2) || '--'}}</template>
                </el-table-column>
            </el-table-column>
            <el-table-column prop='brand' label='现场照片'>
                <template slot-scope='{row}'>{{row.brand || '--'}}</template>
            </el-table-column>
            <el-table-column prop='reportdate' label='填报时间'>
                <template slot-scope='{row}'>{{row.reportdate?formatter(row.reportdate):'--'}}</template>
            </el-table-column>
            <el-table-column prop='sjjssj' label='验收时间'>
                <template slot-scope='{row}'>{{row.sjjssj?formatter(row.sjjssj): '--'}}</template>
            </el-table-column>
            <el-table-column prop='wonum' label='工单编号' show-overflow-tooltip resizable>
                <template slot-scope='{row}'>{{row.wonum || '--'}}</template>
            </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 { queryWbsms } from '@/api/equipmentList.js'
import { mapGetters } from 'vuex'
import Select from '@/components/Select/Select.vue'
import { formatter, number_format } from '@/utils/format.js'
export default {
    components: { Select },
    data() {
        return {
            tableData: [],
            total: 0,
            currentPage: 1,
            size: 10,
            sjjssj: '',
            reportdate: '',
            ischange: '',
            formatter,
            number_format,
            changeOption: [
                {
                    id: '1',
                    name: '是'
                },
                {
                    id: ' 0',
                    name: '否'
                }
            ],
            keyword: ''
        }
    },
    props: ['smsxt', 'major'],
    computed: {
        ...mapGetters(['floorSelect'])
    },
    methods: {
        pageChanged(page) {
            this.currentPage = page
            this.getList()
        },
        getList() {
            let getParams = {
                data: {
                    smsxt: this.smsxt,
                    // tab: this.major,
                    // plazaId: this.$store.state.plazaId,
                    plazaId: '1000287',
                    page: this.currentPage,
                    size: this.size
                }
            }
            queryWbsms(getParams).then(res => {
                this.tableData = res.data || []
                this.total = res.count
            })
        }
    },
    watch: {
        smsxt(newV, oldV) {
            if (newV !== oldV) {
                this.getList()
            }
        }
    },
    mounted() {
        this.getList()
    }
}
</script>
<style lang="less" scoped>
.wb-list {
    .eq-list-top {
        display: flex;
        margin-bottom: 12px;
    }
    td {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    .foot {
        height: 32px;
        display: flex;
        justify-content: flex-end;
        margin-top: 28px;
    }
}
</style>