<template>
    <div class="app-container calendar-list-container exchangeView">
        <!-- 查询和其他操作 -->
        <div class="filter-container">
            <el-input clearable class="filter-item" style="width: 200px;" placeholder="员工名称"
                v-model="listQuery.userName"></el-input>
            <el-select v-model="listQuery.type" placeholder="排行类型" style="top: -4px;width: 200px;">
                <el-option :key="item.type" v-for="item in orderTypeList" :label="item.name" :value="item.type">
                </el-option>
            </el-select>
            <el-button class="filter-item" type="primary" v-waves icon="el-icon-search" @click="handleFilter">查找</el-button>
            <!-- <el-button class="filter-item" type="primary" v-waves icon="el-icon-download" @click="handleDownLoad">导出</el-button> -->

        </div>

        <!-- 查询结果 -->
        <el-table size="small" :data="list" v-loading="listLoading" element-loading-text="正在查询中。。。" border fit
            highlight-current-row>
            <el-table-column type="index" label="排行" header-align="center" align="center">
            </el-table-column>
            <el-table-column align="center" min-width="60px" label="头像">
                <template slot-scope="props">
                    <img style="width: 50px; height: 50px;border-radius: 50%;" :src="httpFile + props.row.headImage">
                </template>
            </el-table-column>
            <el-table-column align="center" min-width="80px" label="员工名称" prop="userName">
            </el-table-column>
            <el-table-column align="center" min-width="160px" label="公司主体" prop="companyName">
            </el-table-column>
            <el-table-column align="center" min-width="150px" label="部门名称" prop="deptName">
            </el-table-column>
            <el-table-column align="center" min-width="120px" label="积分" prop="integral">
            </el-table-column>
        </el-table>

        <!-- 分页 -->
        <div class="pagination-container">
            <el-pagination background @size-change="handleSizeChange" @current-change="handleCurrentChange"
                :current-page="listQuery.page" :page-sizes="[10, 20, 30, 50]" :page-size="listQuery.limit"
                layout="total, sizes, prev, pager, next, jumper" :total="total">
            </el-pagination>
        </div>
    </div>
</template>
  
<style>
.demo-table-expand {
    font-size: 0;
}

.demo-table-expand label {
    width: 200px;
    color: #99a9bf;
}

.demo-table-expand .el-form-item {
    margin-right: 0;
    margin-bottom: 0;
}
</style>
  
<script>
import { list } from "@/api/rankingList";
import waves from "@/directive/waves"; // 水波纹指令
import Tinymce from '@/components/Tinymce'

export default {
    components: { Tinymce },
    directives: { waves },
    data() {
        return {
            httpFile:'',
            orderTypeList: [
                {
                    type: 0,
                    name: '当前积分'
                },
                {
                    type: 1,
                    name: '获取总积分'
                },
            ],
            list: [
                {
                    id:'1',
                    avatarUrl:'https://cube.elemecdn.com/3/7c/3ea6beec64369c2642b92c6726f1epng.png',
                    userName:'张三',
                    company:'神州通誉（洛阳）科技有限公司',
                    deptName:'软件工程院',
                    integral:'12000'
                },
                {
                    id:'2',
                    avatarUrl:'https://cube.elemecdn.com/3/7c/3ea6beec64369c2642b92c6726f1epng.png',
                    userName:'张三',
                    company:'神州通誉（洛阳）科技有限公司',
                    deptName:'软件工程院',
                    integral:'12000'
                },
                {
                    id:'3',
                    avatarUrl:'https://cube.elemecdn.com/3/7c/3ea6beec64369c2642b92c6726f1epng.png',
                    userName:'张三',
                    company:'神州通誉（洛阳）科技有限公司',
                    deptName:'软件工程院',
                    integral:'12000'
                },
            ],
            total: 0,
            listLoading: false,
            listQuery: {
                page: 1,
                limit: 10,
                type: 0,
                userName: '',
            },
        }
    },
    created() {
        this.getList();
    },
    methods: {
        handleDownLoad(){
            window.location.href = process.env.BASE_API + '/mall-order/exportOrderLog?userName=' + this.listQuery.userName + '&orderSeq=' + this.listQuery.orderSeq + '&orderType=' + this.listQuery.orderType + '&title=' + this.listQuery.title;
        },
        getList() {
            this.listLoading = true
            list(this.listQuery).then(response => {
                this.httpFile = response.data.data.httpFile
                this.list = response.data.data.items
                this.total = response.data.data.total
                this.listLoading = false
            }).catch(() => {})
        },
        handleFilter() {
            this.listQuery.page = 1
            this.getList()
        },
        handleSizeChange(val) {
            this.listQuery.limit = val
            this.getList()
        },
        handleCurrentChange(val) {
            this.listQuery.page = val
            this.getList()
        },
    }
}
</script>
<style>
.ad-avatar-uploader .el-upload {
    border: 1px dashed #d9d9d9;
    border-radius: 6px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.ad-avatar-uploader .el-upload:hover {
    border-color: #409EFF;
}

.ad-avatar-uploader-icon {
    font-size: 28px;
    color: #8c939d;
    width: 178px;
    height: 178px;
    line-height: 178px;
    text-align: center;
}

.ad-avatar {
    display: block;
}
</style>
  