<template>
    <div class="deliveryRoom">
        <section class="section">
            <ul class="ul">

                <li @click="toDetail(item.type, '产房00'+(index+1))" class="li" v-for="(item, index) in list" :key="index">
                    <h5>产房00{{ index+1 }}</h5>
                    <img class="img" :src="typeImgUrl[item.type - 1]" />
                    <p v-if="item.type == 1" class="info fontC">空床时间{{ 4 }}天</p>
                    <div class="info" v-if="item.type == 2">
                        <p class="p">
                            <span class="title">母猪耳标：</span>
                            <span class="content">{{ item.id }}</span>
                        </p>
                        <p class="p">
                            <span class="title">入床时间：</span>
                            <span class="content">2020-07-25</span>
                        </p>
                        <p class="p">
                            <span class="title">预计产仔：</span>
                            <span class="content">2020-08-1</span>
                        </p>
                    </div>
                    <div class="info" v-else-if="item.type == 3">
                        <p class="p">
                            <span class="title">母猪耳标：</span>
                            <span class="content">{{ item.id }}</span>
                        </p>
                       <p class="p">
                            <span class="title">产子时间：</span>
                            <span class="content">2020-07-20</span>
                        </p>
                        <p class="p">
                            <span class="title">仔猪日龄：</span>
                            <span class="content">10天</span>
                            
                        </p>
                        <p class="p">
                            <span class="title">产仔数：</span>
                            <span class="content">9</span>
                        </p>
                    </div>
                    <div class="info" v-else-if="item.type == 4">
                        <p class="p">
                            <span class="title">母猪耳标：</span>
                            <span class="content">{{ item.id }}</span>
                        </p>
                        <p class="p">
                            <span class="title">断奶时间：</span>
                            <span class="content">2020-07-20</span>
                        </p>
                        <p class="p">
                            <span class="title">断奶活仔数：</span>
                            <span class="content">8</span>
                        </p>
                        <p class="p">
                            <span class="title">断奶活仔率：</span>
                            <span class="content">98%</span>
                        </p>
                    </div>
                </li>

            </ul>
            <el-row type="flex" justify="center">
                <el-col :span="8" class="pagination">
                    <el-pagination
                        @current-change="pageChange"
                        background
                        layout="prev, pager, next"
                        :page-count="1"
                    ></el-pagination>
                </el-col>
            </el-row>
        </section>
    </div>
</template>


<script>
import typeImgUrl_1 from "@/assets/deliveryRoom_1.jpg";
import typeImgUrl_2 from "@/assets/deliveryRoom_2.jpg";
import typeImgUrl_3 from "@/assets/deliveryRoom_3.jpg";
import typeImgUrl_4 from "@/assets/deliveryRoom_4.jpg";

// import { reqDeliveryRoomList } from "@/api/deliveryRoomManagement.js"

// 每页数据条数
const pageSize = 10;

let list = [
    {
        type: 1,
        id: 16532
    },
    {
        type: 4,
        id: 16546
    },
    {
        type: 3,
        id: 16548
    },
    {
        type: 4,
        id: 16566
    },
    {
        type: 2,
        id: 16596
    },
    {
        type: 3,
        id: 16540
    },
    {
        type: 3,
        id: 16551
    }
];

export default {
    name: "deliveryRoom",
    data() {
        return {
            list,
            typeImgUrl: [
                typeImgUrl_1,
                typeImgUrl_2,
                typeImgUrl_3,
                typeImgUrl_4
            ],
            pageSize,
            page: 1
        };
    },
    created() {
    },
    methods: {
        
        toDetail(type, roomNum) {
            // if(type == 1) {
            //     this.$message.warning("产床为空！")
            //     return
            // }
            this.$router.push({path: "Detail",query: {type,roomNum}})
        },
        pageChange(p) {
            console.log(p);
            this.page = p;
            // this.getDeviceList();
        }
    }
};
</script>

<style lang="scss" scoped>
.deliveryRoom {
    .section {
        background-color: #eee;
        .ul {
            display: flex;
            flex-direction: row;
            flex-wrap: wrap;
            
            .li {
                background-color: #fff;
                border: 2px solid #fff;
                padding: 5px;
                margin: 6px;
                display: flex;
                flex-direction: column;
                width: 200px;
                height: 420px;
                
                
                h5 {
                    text-align: center;
                    font-size: 30px;
                    color: #424242;
                    background-color: #D2E4F0;
                }
                .img {
                    width: 100%;
                }
                .info {
                    flex: 1;
                    display: flex;
                    padding-left: 20px;
                    flex-direction: column;
                    justify-content: space-around;
                    .p {
                        .title {
                            font-size: 14px;
                            font-weight: 600;
                            color: rgb(136, 127, 127);
                        }
                        .content {
                            color: #777;
                        }
                    }
                }
                .fontC {
                    align-items: center;
                    padding-left: 0px;
                    color: rgb(80, 183, 231);
                    font-size: 20px;
                    font-weight: 600;
                }
            }
            .li:hover{
                border: 2px solid #32ADF4;
            }
        }
    }
}

// border: 1px solid #00f;

.pagination {
    margin-top: 5px;
}
</style>