<template>
    <div>
        <div class="sort">
            <div :class="active == true ? 'active' : ''" @click="onSort(3)">综合顺序</div>
            <div @click="onSort(1)" :class="active != true ? 'active' : ''" class="timesort">
                发布时间
                <div class="icon">
                    <i :class="{ active: isSort == 1 }" class="el-icon-caret-top"></i>
                    <i :class="{ active: isSort == 2 }" class="el-icon-caret-bottom"></i>
                </div>
            </div>
        </div>
        <div class="con_main">
            <ul class="con_card_ul">
                <li
                    class="con_card"
                    v-for="item in tableData"
                    :key="item.id"
                    @click="$router.push({ name: 'resourceRelease', query: { id: item.id, type: 'PRODUCT_SUPPLY' } })"
                >
                    <img :src="item.images[0]" />
                    <h5>{{ item.name }}</h5>
                    <p>{{ item.description }}</p>
                </li>
            </ul>
        </div>
        <el-row style="text-align: center;">
            <el-pagination
                @size-change="onSizeChange"
                @current-change="onCurrentChange"
                :current-page="page"
                :page-sizes="[10, 20, 30, 40, 50]"
                :page-size="pageSize"
                layout="total, sizes, prev, pager, next, jumper"
                :total="totalElements"
            >
            </el-pagination>
        </el-row>
    </div>
</template>

<script>
import pageableTable from '@/mixins/pageableTable';
export default {
    mixins: [pageableTable],
    name: 'productRelease',
    data() {
        return {
            active: true,
            isSort: 2, //1为升序，2为降序
            url: '/resourceSupplyAndDemand/all',
            sortStr: 'createdAt,desc'
        };
    },
    methods: {
        onSort(index) {
            if (index === 1) {
                if (this.isSort === 1) {
                    this.sortStr = 'createdAt,desc';
                    this.isSort = 2;
                } else if (this.isSort === 2) {
                    this.sortStr = 'createdAt,asc';
                    this.isSort = 1;
                }
            } else if (index === 3) {
                this.sortStr = 'name,asc';
            }
            this.getData();
        },
        beforeGetData() {
            return { query: { orgInfo: { id: this.$route.query.id }, type: 'PRODUCT_SUPPLY' } };
        }
    }
};
</script>
<style lang="less" scoped>
.sort {
    height: 60px;
    line-height: 60px;
    display: flex;

    div {
        cursor: pointer;
        margin-right: 40px;
        font-size: 13px;
        color: #818999;
        &.active {
            color: #bf1616;
        }
    }
    .timesort {
        display: flex;
        position: relative;
        // align-items: center;
        // justify-content: center;

        .icon {
            position: absolute;
            top: 19px;
            right: -50px;
            width: 10px;
            display: flex;
            flex-direction: column;
            // height: 60px;
            // line-height: 60px;
            // justify-content: center;
            align-items: center;

            i {
                width: 6px;
                height: 4px;
                &.active {
                    color: #bf1616;
                }
                & + i {
                    margin-top: 5px;
                }
            }
        }
    }
}
.con_main {
    margin-bottom: 40px;
    li {
        overflow: hidden;
        cursor: pointer;
    }
    li + li {
        margin-top: 20px;
    }
    img {
        width: 100px;
        height: 100px;
        float: left;
    }
    .con_main_right {
        float: left;
        width: 840px;
        padding-left: 16px;
        box-sizing: border-box;
        .con_main_tit {
            margin-top: 3px;
            i {
                font-style: normal;
                font-size: 12px;
                color: #22b197;
                background: #ebf9f7;
                padding: 5px 3px;
                margin-right: 6px;
            }
            span {
                font-size: 14px;
                color: #000;
            }
        }
        p {
            font-size: 13px;
            line-height: 22px;
            color: #939599;
            margin: 10px 0 5px;
            overflow: hidden;
            text-overflow: ellipsis;
            display: -webkit-box;
            -webkit-line-clamp: 2;
            -webkit-box-orient: vertical;
        }
        .con_time {
            color: #939599;
            font-size: 13px;
        }
    }
    .con_card_ul {
        overflow: hidden;
    }
    .con_card {
        display: flex;
        flex-direction: column;
        width: 223px;
        float: left;
        margin: 0 16px 20px 0;
        img {
            width: 223px;
            height: 223px;
        }
        h5 {
            font-size: 14px;
            color: #000;
            margin: 10px 0;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }
        p {
            font-size: 12px;
            color: #939599;
            margin: 0;

            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }
    }
    .con_card:nth-child(4n) {
        margin-right: 0;
    }
    .con_info {
        overflow: hidden;
        margin: 15px 0 10px;
        .con_info_item {
            float: left;
            font-size: 13px;
            margin-right: 40px;
            i {
                font-style: normal;
                color: #939599;
                margin-right: 4px;
            }
            span {
                color: #bf1616;
            }
        }
    }
}
</style>
