
<template>
    <!-- 详情页面 -->
    <div class='gdqd-dialog'>
        <div class='top'></div>
        <div class='gdqd-dialog-top'>
            <el-input
                placeholder='请输入设备简称、设备编号、品牌、型号、安装位置、生产厂商、服务商搜索'
                style='width:490px;margin-right:12px'
                size='small'
                prefix-icon='el-icon-search'
                v-model='input'
            ></el-input>
            <Select width='120' style='margin-right:12px' tipPlace='top' caption='楼层：' size='small' :selectdata='floorSelect'></Select>
            <Select width='224' style='margin-right:12px' tipPlace='top' caption='管理归属' size='small' :selectdata='dataSelect2'></Select>
            <Select width='224' tipPlace='top' caption='设备状态' size='small' :selectdata='dataSelect2'></Select>
        </div>
        <el-table :data='tableData' :border='true' style='width: 100%;amrgin-bottom:30px'>
            <el-table-column type='index' label='序号' width='50'></el-table-column>
            <el-table-column prop='sbjc' label='设备简称' width='140'></el-table-column>
            <el-table-column prop='sbbh' label='设备编号'></el-table-column>
            <el-table-column prop='sl' label='数量'></el-table-column>
            <el-table-column prop='glgs' label='管理归属'></el-table-column>
            <el-table-column prop='sbbh' label='设备状态'></el-table-column>
            <el-table-column prop='brand' label='品牌'></el-table-column>
            <el-table-column prop='sbxh' label='型号'></el-table-column>
            <el-table-column prop='floor' label='楼层'></el-table-column>
            <el-table-column prop='azwz' label='安装位置' resizable></el-table-column>
            <el-table-column prop='manufacturer' label='生产厂商' width='240'></el-table-column>
            <el-table-column prop='fws' label='服务商' width='240'></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 Select from '@/components/Select/Select.vue'
import { mapGetters } from 'vuex'
import { queryAsset } from '@/api/equipmentList.js'
import { querySelect, queryTab } from '@/api/public.js'
export default {
    data() {
        return {
            tableData: [],
            dataSelect2: [
                { id: 'test1', name: '选择项' },
                { id: 'test2', name: '单平米' },
                { id: 'test3', name: '下级分项' },
                { id: 'test4', name: '滑动平均滑动平均' }
            ],
            input: '',
            page: 1,
            size: 10,
            total: 1,
            keyword: '',
            floorSelect: []
        }
    },
    components: {
        Select
    },
    computed: {
        ...mapGetters(['floorsArr'])
    },
    props: ['row', 'major'],
    mounted() {
        this.queryTableList()
        this.init()
        this.tabFind()
    },
    methods: {
        //下拉框查询
        tabFind() {
            let postParams = [
                {
                    params: {
                        type_code: this.row.type_code
                    },
                    tableName: 'glsms_asset' //视图名称
                }
            ]

            let data = {
                major: this.major,
                plazaId: this.$store.state.plazaId
            }
            queryTab({ data, postParams }).then(res => {
                console.log(res)
            })
        },

        pageChanged(page) {
            this.page = page
            this.queryTableList()
        },
        queryTableList() {
            let major
            if (this.major.slice(0, 2) == 'GD') {
                major = '供电'
            } else if (this.major.slice(0, 2) == 'XF') {
                major = '消防'
            } else if (this.major.slice(0, 2) == 'GPS') {
                major = '给排水'
            } else if (this.major.slice(0, 2) == 'DT') {
                major = '电梯'
            } else if (this.major.slice(0, 2) == 'RQ') {
                major = '燃气'
            } else {
                major = this.major
            }
            let data = {
                major: major,
                plazaId: this.$store.state.plazaId,
                page: this.page,
                size: this.size,
                keyword: this.keyword
            }
            let postParams = {
                type_code: this.row.type_code,
                manufacturer: this.row.manufacturer,
                sbxh: this.row.sbxh,
                // floor: '--',
                brand: '--'
            }
            queryAsset({ data, postParams }).then(res => {
                console.log(res)
                this.tableData = res.data.data
                this.total = res.data.count
            })
        },
        init() {
            this.floorSelect = []
            if (this.floorsArr.length > 0) {
                this.floorsArr.forEach(e => {
                    let obj = {
                        id: e,
                        name: e
                    }
                    this.floorSelect.push(obj)
                })
            }
        }
    },
    watch: {
        'row.type_code': {
            handler(newV, oldV) {
                if (newV != oldV) {
                    this.queryTableList()
                    this.init()
                    this.tabFind()
                }
            },
            deep: true
        }
    }
}
</script>
<style lang="less" scoped>
.gdqd-dialog {
    padding: 16px 24px 40px;
    .gdqd-dialog-top {
        display: flex;
        margin-bottom: 20px;
    }
    .foot {
        position: absolute;
        height: 32px;
        right: 26px;
    }
    td {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
}
</style>
<style lang="less">
</style>