<template>
    <div>
        <table width="2500" border="1" cellpadding="0" cellspacing="0" class="tableContent">
            <tr>
                <td height="60" colspan="3">单位:</td>
                <td colspan="3">{{formQuery.qymc}}</td>
                <td colspan="2">总库容:{{kdyxcrValue}}</td>
                <td colspan="3"></td>
                <td colspan="2">总仓房数:{{cfsValue}}</td>
                <td colspan="8" style="text-indent: 10px; text-align: left;">单位地址:{{formQuery.qytxdz}}</td>
                <td colspan="2">单位负责人:{{formQuery.fddbr}}</td>
                <td colspan="2"></td>
                <td colspan="2">填表日期:</td>
                <td colspan="3">{{formQuery.createDate}}</td>
            </tr>
            <tr>
                <td rowspan="2" width="30">编号</td>
                <td rowspan="2" width="50">编码</td>
                <td rowspan="2" width="50">仓号</td>
                <td colspan="10" height="30">仓房基本情况</td>
                <td colspan="17">仓内设施情况</td>
            </tr>
            <tr>
                <td width="120" height="30">仓型</td>
                <td width="120">仓容(吨)</td>
                <td width="120">低温仓</td>
                <td width="120">建设年份</td>
                <td width="80">用途</td>
                <td width="120">内长</td>
                <td width="100">内宽</td>
                <td width="100">内径</td>
                <td width="100">设计量线高度</td>
                <td width="100">储存方式</td>
                <td width="100">保温门</td>
                <td width="100">保温窗</td>
                <td width="100">双层保温窗</td>
                <td width="100">外控内开窗</td>
                <td width="50">仓内吊顶</td>
                <td width="120">仓内保温吊顶</td>
                <td width="100">隔层排积热</td>
                <td width="100">仓顶外隔热层</td>
                <td width="100">保温墙体</td>
                <td width="100">保温涂料</td>
                <td width="100">制冷设备</td>
                <td width="100">地笼通风</td>
                <td width="100">轴流风机</td>
                <td width="50">电子测温</td>
                <td width="100">自动流粮口</td>
                <td width="50">环流熏蒸</td>
                <td width="50">仓内环流</td>
            </tr>
            <!-- <tr class="small">
                        <td></td>
                        <td></td>
                        <td>与统计库存账相符合</td>
                        <td>高大平房仓、楼房仓、立筒仓、浅圆仓、半地下仓、门架仓、钢板仓、简易仓、其他</td>
                        <td>仓房设计单位设计（单仓）容量</td>
                        <td>低温仓、准低温仓、普通仓、保温仓（见备注）</td>
                        <td>验收竣工年份（xxxx年xx月）</td>
                        <td>储粮、机械设备存放、闲置等</td>
                        <td>仓内使用体积净长</td>
                        <td>仓内使用体积净宽</td>
                        <td>立筒仓、浅圆仓、油罐内直径</td>
                        <td>仓房设计单位设计装粮高度</td>
                        <td>包存、散存、围包散存</td>
                        <td>仓房大门有隔热保温材料的</td>
                        <td>仓房窗户有隔热保温材料的</td>
                        <td>仓房有双层保温窗的</td>
                        <td>仓房有仓外控制仓内窗户开启的</td>
                        <td>仓内有吊顶隔层的</td>
                        <td>仓内吊顶隔层采用保温材料的</td>
                        <td>仓顶与吊顶间的空间有排风或换气设备的</td>
                        <td>仓顶有隔热顶（二层顶）</td>
                        <td>仓房墙体有保温材料围护的</td>
                        <td>仓房外墙涂刷保温涂料的</td>
                        <td>仓房有机械制冷的设备（空调）</td>
                        <td>仓房有地笼通风口，有配套风机的</td>
                        <td>仓房墙壁装有轴流风机的</td>
                        <td>仓房装有联网电脑测温系统的</td>
                        <td>仓房墙壁装有自动流粮口的</td>
                        <td>装有环流熏蒸管路并配套环流熏蒸机的</td>
                        <td>仓房装有气体内部环流的</td>
            </tr>-->
            <tr v-for="(item, index) in warehouseData" :key="index">
                <td height="80">{{index + 1}}</td>
                <td>{{item.cfbh}}</td>
                <td>{{item.cfmc}}</td>
                <td>{{item.cflx}}</td>
                <td>{{item.sjcr01}}</td>
                <td>{{getStatusName('dwc', item.dwc)}}</td>
                <td>{{item.jsnd}}</td>
                <td>{{item.cfyt}}</td>
                <td>{{item.cfnc}}</td>
                <td>{{item.cfnk}}</td>
                <td>{{item.cfnj}}</td>
                <td>{{item.zlxgd}}</td>
                <td>{{item.ccfs}}</td>
                <td>{{getStatusName('bwm', item.bwm)}}</td>
                <td>{{getStatusName('bwc', item.bwc)}}</td>
                <td>{{getStatusName('scbwc', item.scbwc)}}</td>
                <td>{{getStatusName('wknkc', item.wknkc)}}</td>
                <td>{{getStatusName('cndd', item.cndd)}}</td>
                <td>{{getStatusName('cdbwdd', item.cdbwdd)}}</td>
                <td>{{getStatusName('gcpjr', item.gcpjr)}}</td>
                <td>{{getStatusName('cdwgrc', item.cdwgrc)}}</td>
                <td>{{getStatusName('bwqt', item.bwqt)}}</td>
                <td>{{getStatusName('bwtl', item.bwtl)}}</td>
                <td>{{getStatusName('zlsb', item.zlsb)}}</td>
                <td>{{getStatusName('dltf', item.dltf)}}</td>
                <td>{{getStatusName('zltf', item.zltf)}}</td>
                <td>{{getStatusName('dzcw', item.dzcw)}}</td>
                <td>{{getStatusName('zdllk', item.zdllk)}}</td>
                <td>{{getStatusName('hlxz', item.hlxz)}}</td>
                <td>{{getStatusName('cnhl', item.cnhl)}}</td>
            </tr>
        </table>
        <div style="margin-top: 10px;text-align:center;">
            <el-button type="primary" icon="iconfont iconfanhui" @click="cancel">返回</el-button>
        </div>
    </div>

</template>

<script>
    import {
        warehouseList,
        warehouseDictionary,
        getDetail,
        qywarehouseList
    } from "@/api/enterpriseInformationBase/index";

    export default {
        name: "warehouseBasicInformation",
        props: ["formQuery"],
        data() {
            return {
                // formQuery: this.$route.query.formQuery,
                warehouseData: [],
                warehouseStatus: {
                    dwc: {
                        "0": "低温仓",
                        "1": "准低温仓",
                        "2": "普通仓",
                        "3": "保温仓"
                    },
                    bwm: {
                        "0": "无",
                        "1": "有"
                    },
                    bwc: {
                        "0": "无",
                        "1": "有"
                    },
                    scbwc: {
                        "0": "无",
                        "1": "有"
                    },
                    wknkc: {
                        "0": "无",
                        "1": "有"
                    },
                    cndd: {
                        "0": "无",
                        "1": "有"
                    },
                    cdbwdd: {
                        "0": "无",
                        "1": "有"
                    },
                    gcpjr: {
                        "0": "无",
                        "1": "有"
                    },
                    cdwgrc: {
                        "0": "无",
                        "1": "有"
                    },
                    bwqt: {
                        "0": "无",
                        "1": "有"
                    },
                    bwtl: {
                        "0": "无",
                        "1": "有"
                    },
                    zlsb: {
                        "0": "无",
                        "1": "有"
                    },
                    dltf: {
                        "0": "无",
                        "1": "有"
                    },
                    zltf: {
                        "0": "无",
                        "1": "有"
                    },
                    dzcw: {
                        "0": "无",
                        "1": "有"
                    },
                    zdllk: {
                        "0": "无",
                        "1": "有"
                    },
                    hlxz: {
                        "0": "无",
                        "1": "有"
                    },
                    cnhl: {
                        "0": "无",
                        "1": "有"
                    }
                },
                kdyxcrValue: "",
                cfsValue: ""
            };
        },
        watch: {
            formQuery(val, oldVal) {
                if (val !== oldVal) {
                    this.getInfo();
                }
            }
        },
        methods: {
            cancel() {
                this.$router.go(-1)
            },
            getInfo() {
                console.log(this.formQuery.tyshxydm)
                let params = {
                    // 目前根据现有的组织机构编码查询不出结果，暂时使用下面写死的编码
                    kddm: this.formQuery.tyshxydm
                };
                warehouseList(params).then(res => {
                    console.log('WarehouseBasicInformation params:', params);
                    if (res.infoCode == 200) {
                        console.log(res);
                        this.warehouseData = res.data;
                        this.warehouseData.forEach((item, index, arr) => {
                            this.kdyxcrValue = this.warehouseData[0].kdyxcr;
                            this.cfsValue = this.warehouseData[0].cfs;
                        })
                    }
                });
                // let params = {
                //     qyjgdm: this.formQuery.qyjgdm
                // };
                // qywarehouseList(params).then(res => {
                //     console.log('WarehouseBasicInformation params:', params);
                //     if (res.infoCode == 200) {
                //         console.log(res);
                //         this.warehouseData = res.data;
                //         this.warehouseData.forEach((item, index, arr) => {
                //             this.kdyxcrValue = this.warehouseData[0].kdyxcr;
                //             this.cfsValue = this.warehouseData[0].cfs;
                //         })
                //     }
                // });
            },
            getStatusName(name, value) {
                let statusName = "";
                for (let key in this.warehouseStatus) {
                    if (name == key) {
                        for (let index in this.warehouseStatus[key]) {
                            if (value == index) {
                                statusName = this.warehouseStatus[key][index];
                            }
                        }
                    }
                }
                return statusName;
            },
            returnBack() {
                this.$router.back(-1);
            }
        },
        created() {
            // this.getInfo();
        }
    };
</script>

<style scoped lang="scss">
    .content-main {
        margin: 10px 10px 0;
        overflow-x: auto;
    }
    .tableContent {
        margin-bottom: 20px;
        td {
            text-align: center;
        }
        .small td {
            font-size: 12px;
        }
    }
</style>
