<!-- 维保 -->
<template>
    <div class='wb-list'>
        <div class='eq-list-top'>
            <el-input
                placeholder='搜索设备名称编号'
                size='small'
                @blur='getList'
                prefix-icon='el-icon-search'
                v-model='sbjc'
                clearable
                style='width:192px;margin-right:12px'
            ></el-input>
            <el-input
                placeholder='搜索重要事项记录描述'
                size='small'
                @blur='getList'
                clearable
                prefix-icon='el-icon-search'
                v-model='matters'
                style='width:192px;margin-right:12px'
            ></el-input>
            <Select
                @change='getList'
                v-model='ischange'
                style='margin-right:12px'
                width='190'
                tipPlace='top'
                caption='是否更换配件信息 ：'
                :selectdata='changeOption'
            ></Select>
            <!-- placeholder='选择填报时间' -->
            <div class='picker-box'>
                <span class='picker-span'>填报日期：</span>
                <el-date-picker
                    style='width:190px'
                    v-model='reportdate'
                    value-format='yyyyMMdd'
                    type='daterange'
                    @change='getList'
                    size='mini'
                    range-separator='-'
                    start-placeholder
                    end-placeholder
                ></el-date-picker>
            </div>

            <!-- placeholder='选择验收时间' -->
            <div class='picker-box'>
                <span class='picker-span'>验收日期：</span>
                <el-date-picker
                    style='width:190px'
                    v-model='sjjssj'
                    value-format='yyyyMMdd'
                    type='daterange'
                    @change='getList'
                    size='mini'
                    range-separator='-'
                    start-placeholder
                    end-placeholder
                ></el-date-picker>
            </div>
            <input-dialog :type='2' @confirm='confirm'></input-dialog>
        </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}'>
                    <div style='cursor:pointer;color: #0091ff;' @click='clickPic(row.glsmsImage)'>{{row.glsmsImage?row.glsmsImage.length+'张':'--'}}</div>
                </template>
            </el-table-column>
            <el-table-column prop='reportdate' label='填报时间' width='140'>
                <template slot-scope='{row}'>{{row.reportdate?formatter(row.reportdate):'--'}}</template>
            </el-table-column>
            <el-table-column prop='sjjssj' label='验收时间' width='140'>
                <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.wb_gzglid || '--'}}</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>
            <pic-large :imgUrl='imgUrl' ref='picLargeOpen'></pic-large>
        </div>
    </div>
</template>
<script>
import { queryWbsms } from '@/api/equipmentList.js'
import { mapGetters } from 'vuex'
import Select from '@/components/Select/Select.vue'
import inputDialog from './inputDIalog'
import { formatter, number_format } from '@/utils/format.js'
export default {
    components: { Select, inputDialog },
    data() {
        return {
            tableData: [],
            total: 0,
            currentPage: 1,
            size: 10,
            sjjssj: '',
            reportdate: '',
            ischange: '',
            sbjc: '',
            formatter,
            number_format,
            changeOption: [
                {
                    id: '是',
                    name: '是'
                },
                {
                    id: ' 否',
                    name: '否'
                }
            ],
            imgUrl: [],
            shjc: '',
            gzglid: '',
            matters: ''
        }
    },
    props: ['smsxt', 'major', 'difference', 'tabLabel'],
    computed: {
        ...mapGetters(['floorSelect'])
    },
    methods: {
        //多余输入框监听
        confirm(gzglid) {
            this.gzglid = gzglid
            this.getList()
        },
        pageChanged(page) {
            this.currentPage = page
            this.getList()
        },
        getList() {
            let getParams = {
                data: {
                    smsxt: this.smsxt,
                    difference: this.difference,
                    plazaId: this.$store.state.plazaId,
                    page: this.currentPage,
                    size: this.size,
                    orderBy: `wb_gzglid,0;sbjbm,1;reportdate,0;`
                }
            }
            //下拉
            if (this.ischange) {
                getParams.data.ischangepj = this.ischange
            }
            if (this.sjjssj) {
                getParams.data.sjjssjStartDate = this.sjjssj[0] + '000000'
                getParams.data.sjjssjEndDate = this.sjjssj[1] + '000000'
            }
            if (this.reportdate) {
                getParams.data.reportdateStartDate = this.reportdate[0] + '000000'
                getParams.data.reportdateEndDate = this.reportdate[1] + '000000'
            }
            //输入框
            getParams.data.keyword = ''
            if (this.sbjx) {
                getParams.data.keyword += `${this.sbjc}:sbjc,sbjbm;`
            }
            if (this.matters) {
                getParams.data.keyword += `${this.matters}:matters,description;`
            }
            if (this.gzglid) {
                getParams.data.keyword += `${this.gzglid}:wb_gzglid;`
            }
            if (getParams.data.keyword == '') {
                delete getParams.data.keyword
            }
            queryWbsms(getParams).then(res => {
                this.tableData = res.data || []
                console.log(this.tableData)
                this.total = res.count
            })
        },
        clickPic(row) {
            this.imgUrl = []
            if (row) {
                row.forEach(el => {
                    let obj = {
                        name: el.description,
                        url: el.urlname
                    }
                    this.imgUrl.push(obj)
                })
            }
            this.$refs.picLargeOpen.open(this.imgUrl)
        }
    },
    watch: {
        difference(newV, oldV) {
            if (newV !== oldV) {
                this.getList()
            }
        },
        tabLabel(newV, oldV) {
            if (newV !== oldV) {
                this.tabFind()
                this.getList()
            }
        }
    },
    mounted() {
        this.getList()
    }
}
</script>
<style lang="less" scoped>
.wb-list {
    .eq-list-top {
        display: flex;
        margin-bottom: 12px;
        .picker-box {
            display: flex;
            align-items: center;
            background: #fff;
            padding: 0 6px;
            border: 1px solid #dcdfe6;
            border-radius: 4px;
            height: 32px;
            box-sizing: border-box;
            margin-right: 12px;
            .picker-span {
                margin-right: 6px;
                color: rgba(0, 0, 0, 0.65);
            }
        }
    }
    td {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    .foot {
        height: 32px;
        display: flex;
        justify-content: flex-end;
        margin-top: 28px;
    }
}
</style>
<style lang="less" >
.wb-list {
    .picker-box {
        .el-input__inner {
            border: none;
        }
        .el-range-editor.el-input__inner {
            padding: 3px 0px;
        }
        .el-icon-date {
            display: none;
        }
        .el-range__close-icon {
            position: absolute;
            right: 0px;
            top: 2px;
        }
        .el-range-editor--mini .el-range-input {
            font-size: 14px;
            color: rgb(31, 36, 41);
        }
    }
}
</style>