<template>
    <div class="content-main">
        <el-row>
            <el-form :inline="true" :model="formInline" class="search-bm-boder" ref="formInline">
                <el-form-item label="申报单位：">
                    <el-input type="text" v-model="formInline.dwmc" clearable class="inputWidth"></el-input>
                </el-form-item>
                <el-form-item label="填报时间：">
                    <el-date-picker
                            v-model="tbsj"
                            style="width:250px"
                            type="daterange"
                            value-format="yyyy-MM-dd"
                            range-separator="至"
                            start-placeholder="开始日期"
                            end-placeholder="结束日期">
                    </el-date-picker>
                </el-form-item>
                <el-form-item>
                    <div class="search-button">
                        <span class="search-line"></span>
                        <el-button type="primary" plain @click="isShowSelect = !isShowSelect">
                            更多条件
                            <i :class="!isShowSelect?'el-icon-arrow-up':'el-icon-arrow-down' "></i>
                        </el-button>
                        <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>
                <div v-show="isShowSelect">
                    <div>
                        <el-form-item label="轮换数量：">
                            <el-input type="text" v-model="formInline.lhslMin" clearable class="inputWidth"></el-input> -
                            <el-input type="text" v-model="formInline.lhslMax" clearable class="inputWidth"></el-input>
                        </el-form-item>
                        <el-form-item label="状态：">
                            <el-select
                                    placeholder="不限"
                                    v-model="formInline.lczt"
                                    clearable
                                    style="width: 180px !important;"
                            >
                                <el-option
                                        v-for="item in ztList"
                                        :key="item.value"
                                        :label="item.label"
                                        :value="item.value"
                                ></el-option>
                            </el-select>
                        </el-form-item>
                    </div>
                    <el-form-item label="应拨付补贴：">
                        <el-input type="text" v-model="formInline.ybfbtMin" clearable class="inputWidth"></el-input> -
                        <el-input type="text" v-model="formInline.ybfbtMax" clearable class="inputWidth"></el-input>
                    </el-form-item>
                    <el-form-item label="预申请补贴：">
                        <el-input type="text" v-model="formInline.ysqbtMin" clearable class="inputWidth"></el-input> -
                        <el-input type="text" v-model="formInline.ysqbtMax" clearable class="inputWidth"></el-input>
                    </el-form-item>
                </div>

            </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="tbsj" label="填报时间" align="center"></el-table-column>
                <el-table-column prop="lhsl" label="轮换数量" align="center"></el-table-column>
                <el-table-column prop="ybfbt" label="应拨付补贴" align="center"></el-table-column>
                <el-table-column prop="ysqbt" label="预申请补贴" align="center"></el-table-column>
                <el-table-column prop="zt" label="状态" align="center">
                    <template slot-scope="scope">
                        <span v-if="!scope.row.lczt">审批通过</span>
                        <span v-else-if="scope.row.lczt === '1'">等待审批</span>
                        <span v-else-if="scope.row.lczt === '2'">审批进行中</span>
                        <span v-else-if="scope.row.lczt === '3'">已驳回</span>
                    </template>
                </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 iconchuli operate_edit_btn"
                                    @click="handledetail(scope.row, 'dealWith')"
                            ></el-button>
                        </el-tooltip>
                        <el-tooltip class="item" effect="light" content="处理结果" placement="top">
                            <el-button
                                    type="primary"
                                    size="small"
                                    class="iconfont iconchuli operate_edit_btn"
                                    @click="handledetail(scope.row, 'dealWithJg')"
                            ></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 { preApplicationSubsidyPage } from "@/api/bordereaux/index"
    export default {
        data() {
            return {
                isShowSelect: false,
                formInline: {},
                tbsj:"",
                ztList: [
                    {
                        value: 0,
                        label: "未上报"
                    },
                    {
                        value: 1,
                        label: "已上报"
                    },
                ],
                options:[],
                listLoading: false,
                tableData: [],
                pageForm: {
                    pageNum: 1,
                    pageSize: 10,
                    total: 0
                },
                pickerOptions:{
                    disabledDate(time) {
                        return time.getTime() > Date.now()-8.64e7;
                    },
                },
            }
        },
        created() {
            this.getList()
        },
        methods: {
            //重置
            resetInfo(){
                this.pageForm.pageNum = 1;
                this.pageForm.pageSize = 10;
                this.formInline.tbnd = null
                this.tbnd = this.formInline.tbnd
                this.getList()
            },
            //查询
            doSearch(){
                this.pageForm.pageNum = 1
                this.getList()
            },
            //获取列表
            getList() {
                this.formInline.tbsjMin = this.tbsj ? this.tbsj[0] : ""
                this.formInline.tbsjMax = this.tbsj ? this.tbsj[1] : ""
                preApplicationSubsidyPage(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 = '{441234F4-DEA4-4656-BCFA-98DAEF12A88E}'
                    let bbq = '任意报'
                    let bbqVal = row.tbqs
                    let path = '/ywbb/cwbb/budgetApplication'
                    this.$router.push({ path: '/ywbb/common/detail', query: { userid: row.userid, task: task, bbq: bbq, bbqVal: bbqVal, path: path} });
                    
                    //查看
                }else if(type == 'dealWith'){
                    //处理
                }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>
