<template>
    <div class="content-main">
        <el-row>
            <el-form :inline="true" :model="formInline" class="search-bm-boder" ref="formInline">
                <el-form-item label="年度：">
                    <el-date-picker
                            type="year"
                            class="inputWidth"
                            value-format="yyyy"
                            :picker-options="pickerOptions"
                            placeholder="选择日期"
                            v-model="formInline.nd"
                    ></el-date-picker>
                </el-form-item>

                <el-form-item>
                    <div class="search-button">
                        <span class="search-line"></span>
                        <el-button type="primary" size="small" class="iconfont iconchaxun" @click="doSearch">查询</el-button>
                        <el-button type="primary" @click="resetInfo('formInline')" size="small" class="iconfont iconzhongzhi"> 重置</el-button>
                    </div>
                </el-form-item>
            </el-form>
        </el-row>
        <el-row>
            <el-table
                    :data="tableData"
                    stripe
                    v-loading="listLoading"
                    border
                    fit
                    highlight-current-row
                    style="width: 100%">
                <el-table-column type="index" label="序号" width="60" align="center">
                    <template slot-scope="scope">
                        <span>{{scope.$index+1}}</span>
                    </template>
                </el-table-column>
                <el-table-column prop="dwmc" label="申报单位" align="center"></el-table-column>
                <el-table-column prop="nd" label="年度" align="center"></el-table-column>
                <el-table-column prop="tbsj" label="更新时间" align="center"></el-table-column>
                <el-table-column label="操作" align="center" width="60">
                    <template slot-scope="scope">
                        <el-tooltip class="item" effect="light" content="查看" placement="top">
                            <el-button
                                    type="primary"
                                    size="small"
                                    @click="handledetail(scope.row, 'detail')"
                                    class="iconfont iconchakan2 operate_show_btn"
                            ></el-button>
                        </el-tooltip>
                        <!-- <el-tooltip class="item" effect="light" content="导出" placement="top">
                            <el-button
                                    type="primary"
                                    size="small"
                                    class="iconfont icondaochu11 operate_edit_btn"
                                    @click="handledetail(scope.row, 'export')"
                            ></el-button>
                        </el-tooltip> -->
                    </template>
                </el-table-column>
            </el-table>
        </el-row>
        <el-row>
            <el-pagination
                    @size-change="handleSizeChange"
                    @current-change="handleCurrentChange"
                    :current-page.sync="pageForm.pageNum"
                    :page-sizes="[10,20,30,40]"
                    :page-size="pageForm.pageSize"
                    layout="total, sizes, prev, pager, next, jumper"
                    :total="pageForm.total"
            ></el-pagination>
        </el-row>
    </div>
</template>
<script>
    import { storageFeeSubsidyPage } from "@/api/bordereaux/index"
    import { irptLogin } from "@/api/login/login"
    export default {
        data() {
            return {
                formInline: {},
                tbnd: null,
                options:[],
                listLoading: false,
                tableData: [],
                pageForm: {
                    pageNum: 1,
                    pageSize: 10,
                    total: 0
                },
                pickerOptions:{
                    disabledDate(time) {
                        return time.getTime() > Date.now()-8.64e7;
                    },
                },
            }
        },
        created() {
            this.getList()
            if(!sessionStorage.getItem("bi")){
                sessionStorage.setItem("bi", true);
                irptLogin(sessionStorage.getItem("userLoginName"), sessionStorage.getItem("userPassword")).then(res =>{
                    console.log('hhhhh')
                })
                this.irptRefresh()
            }
        },
        methods: {
            irptRefresh() {//i登陆地址定时器
                let needObj = JSON.parse(sessionStorage.getItem("LoginCode"))
                setInterval(() => {
                    irptLogin(needObj.username, needObj.password).then(res =>{
                        console.log('hhhhh')
                    })
                },1200*1000)
            },
            //重置
            resetInfo(){
                this.pageForm.pageNum = 1;
                this.pageForm.pageSize = 10;
                this.formInline = {}
                this.getList()
            },
            //查询
            doSearch(){
                this.pageForm.pageNum = 1
                this.getList()
            },
            //获取列表
            getList() {
                storageFeeSubsidyPage(this.formInline, this.pageForm).then(res => {
                    if (res.infoCode == 200) {
                        this.tableData = res.data.list;
                        this.$set(this.pageForm,"total", Number(res.data.total))
                    } else {
                        this.$message({
                            type: 'error',
                            message: res.msg
                        });
                    }
                }).catch()
            },
            //操作
            handledetail(row, type){
                if(type == 'detail'){
                    let task = '{C03B1B99-3BE4-402D-8F53-14196C4EB5A3}'
                    let bbq = '年报'
                    let bbqVal = row.tbqs
                    let path = '/ywbb/cwbb/subsidySummary'
                    this.$router.push({ path: '/ywbb/common/detail', query: { userid: row.userid, task: task, bbq: bbq, bbqVal: bbqVal, path: path} });
                    
                    //查看
                }else{
                    //导出
                }
            },
            handleSizeChange(val) {
                this.pageForm.pageSize = val
                this.getList()
            },
            handleCurrentChange(val) {
                this.pageForm.pageNum = val
                this.getList()
            },
            formatDateTime(date) {
                let y = date.getFullYear();
                let m = date.getMonth() + 1;
                m = m < 10 ? "0" + m : m;
                let d = date.getDate();
                d = d < 10 ? "0" + d : d;
                let h = date.getHours();
                h = h < 10 ? "0" + h : h;
                let minute = date.getMinutes();
                minute = minute < 10 ? "0" + minute : minute;
                let second = date.getSeconds();
                second = second < 10 ? "0" + second : second;
                return y + '';
            },
        }
    }
</script>
<style scoped lang="scss">
    .content-main {
        margin: 10px 10px 0;
        padding-top: 20px;
    }

    .span-inline-block {
        float: left;
        margin-right: 5px;
        width: 80px;
        text-align: right;
        line-height: 30px;
    }

    .inputWidth {
        width:180px !important
    }

    .h3 {
        width: 98%;
        text-align: center;
        font-size: 1em;
        line-height: 2.5;
        color: #fff;
        background-color: #49a2fa;
        margin-bottom: 20px;
    }

    .el-form {
        overflow: hidden;
        overflow-y: auto;
    }

    .el-row {
        .el-tooltip {
            float: left;
            padding: 0 12px 0 0;
            width: 118px;
            white-space: nowrap;
            text-align: right;
            vertical-align: middle;
            color: #525357;
            font-size: 14px;
            line-height: 40px;
            box-sizing: border-box;
        }
    }
    .chb_box {
        /deep/ .el-checkbox {
            min-width: 150px;
        }
    }
    table {
        margin-bottom: 10px;
        font-size: 14px;
        border-collapse: collapse;
        color: #525357;
    }
    th {
        font-weight: 700;
        font-size: 18px;
    }
    td,
    th {
        padding: 10px;
        text-align: center;
        border: 1px solid #b0b0b0;
    }
</style>
