
<template>
    <!-- 详情页面 -->
    <div class='gdqd-dialog'>
        <div class='top'></div>
        <div class='gdqd-dialog-top'>
            <el-input placeholder='搜索设备简称、编号' style='width:192px;margin-right:12px' size='small' prefix-icon='el-icon-search' v-model='input'></el-input>
            <el-input placeholder='搜索品牌、型号' style='width:192px;margin-right:12px' size='small' prefix-icon='el-icon-search' v-model='input'></el-input>
            <el-input placeholder='搜索生产厂商' style='width:192px;margin-right:12px' size='small' prefix-icon='el-icon-search' v-model='input'></el-input>
            <el-input placeholder='搜索安装位置' style='width:192px;margin-right:12px' size='small' prefix-icon='el-icon-search' v-model='input'></el-input>
            <el-input placeholder='搜索服务商' style='width:192px;margin-right:12px' size='small' prefix-icon='el-icon-search' v-model='input'></el-input>
            <Select width='120' v-model='floor' tipPlace='top' caption='楼层：' size='small' :selectdata='floorSelect'></Select>
            <Select v-model='sbglgs' width='180' tipPlace='top' style='margin-top:12px;' caption='管理归属' size='small' :selectdata='sbglgsOption'></Select>
            <Select
                width='146'
                style='margin-left:12px;margin-top:12px;'
                v-model='status'
                tipPlace='top'
                caption='设备状态'
                size='small'
                :selectdata='statusOption'
            ></Select>
        </div>
        <el-table :data='tableData' :border='true' style='width: 100%;amrgin-bottom:30px'>
            <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='assetnum' label='设备编号' show-overflow-tooltip resizable>
                <template slot-scope='{row}'>{{row.assetnum || '--'}}</template>
            </el-table-column>
            <el-table-column prop='sl' label='数量'>
                <template slot-scope='{row}'>{{row.sl || '--'}}</template>
            </el-table-column>
            <el-table-column prop='sbglgs' label='管理归属' show-overflow-tooltip resizable>
                <template slot-scope='{row}'>{{row.sbglgs || '--'}}</template>
            </el-table-column>
            <el-table-column prop='sb_status' label='设备状态'>
                <template slot-scope='{row}'>{{row.sb_status || '--'}}</template>
            </el-table-column>
            <el-table-column prop='brand' label='品牌' show-overflow-tooltip resizable>
                <template slot-scope='{row}'>{{row.brand || '--'}}</template>
            </el-table-column>
            <el-table-column prop='sbxh' label='型号' show-overflow-tooltip resizable>
                <template slot-scope='{row}'>{{row.sbxh || '--'}}</template>
            </el-table-column>
            <el-table-column prop='floor' label='楼层'>
                <template slot-scope='{row}'>{{row.floor || '--'}}</template>
            </el-table-column>
            <el-table-column prop='wzjc' label='安装位置' show-overflow-tooltip resizable>
                <template slot-scope='{row}'>{{row.wzjc || '--'}}</template>
            </el-table-column>
            <el-table-column prop='manufacturer' label='生产厂商' show-overflow-tooltip resizable>
                <template slot-scope='{row}'>{{row.manufacturer || '--'}}</template>
            </el-table-column>
            <el-table-column prop='fws' label='服务商' show-overflow-tooltip resizable>
                <template slot-scope='{row}'>{{row.fws || '--'}}</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 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: '',
            floor: '',
            status: '',
            sbglgs: '',
            sbglgsOption: [],
            statusOption: []
        }
    },
    components: {
        Select
    },
    computed: {
        ...mapGetters(['floorSelect'])
    },
    props: ['row', 'major'],
    mounted() {
        this.queryTableList()
        this.tabFind()
    },
    methods: {
        //下拉框查询
        tabFind() {
            let postParams = [
                {
                    columnName: { sbglgs: 'sbglgs', sb_status: 'sb_status' },
                    params: {
                        type_code: this.row.type_code
                    },
                    tableName: 'glsms_asset' //视图名称
                }
            ]
            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
            }
            querySelect({ data, postParams }).then(res => {
                console.log(res)
                let sb_status = res.data.data.glsms_asset.sb_status
                let sbglgs = res.data.data.glsms_asset.sbglgs
                this.sbglgsOption = []
                this.statusOption = []
                sb_status.forEach(el => {
                    this.statusOption.push({
                        name: el.value,
                        id: el.key
                    })
                })
                sbglgs.forEach(el => {
                    this.sbglgsOption.push({
                        name: el.value,
                        id: el.key
                    })
                })
            })
        },

        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
                // sbglgs:this.sbglgs,
                // floor:this.floor,
                // status:this.status
            }
            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
            })
        }
    },
    watch: {
        'row.type_code': {
            handler(newV, oldV) {
                if (newV != oldV) {
                    this.queryTableList()
                    this.tabFind()
                }
            },
            deep: true
        }
    }
}
</script>
<style lang="less" scoped>
.gdqd-dialog {
    padding: 16px 24px 40px;
    .gdqd-dialog-top {
        display: flex;
        flex-wrap: wrap;
        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>
<style lang="less">
</style>