<!--
 * @Descripttion: 上账情况
 * @version: 1.0
 * @Author: zzx
 * @Date: 2024-11-09 16:08:16
 * @LastEditors: zzx
 * @LastEditTime: 2024-11-19 16:08:16
-->
<template>
    <div class="app-container">
        <el-card class="filter-container" shadow="hover">
            <div>
                <i class="el-icon-search"></i>
                <span>筛选搜索</span>
                <el-button style="float: right" type="primary" @click="handleSearchList()" size="small">
                    查询搜索
                </el-button>
                <el-button style="float: right; margin-right: 15px" @click="handleResetSearch()" size="small">
                    重置
                </el-button>
            </div>
            <div style="margin-top: 15px">
                <el-form :inline="true" :model="listQuery" size="small" label-width="140px">
                    <el-form-item label="渠道名称：">
                        <el-input v-model="listQuery.ecName" class="input-width" placeholder="请输入渠道名称"
                            clearable></el-input>
                    </el-form-item>
                    <el-form-item label="操作时间：">
                        <el-date-picker v-model="date" size="small" value-format="yyyy-MM-dd"
                            class="item-width-350 ml10" type="datetimerange" range-separator="至"
                            start-placeholder="开始日期" end-placeholder="结束日期">
                        </el-date-picker>
                    </el-form-item>
                </el-form>
            </div>
        </el-card>
        <el-card class="operate-container" shadow="hover">
            <i class="el-icon-tickets"></i>
            <span>数据列表</span>
        </el-card>
        <div class="table-container">
            <el-table ref="adminTable" :data="list" style="width: 100%" v-loading="listLoading" border>
                <el-table-column label="渠道编号" width="100" align="center" prop="authCode"></el-table-column>
                <el-table-column label="渠道名称" align="center" prop="ecName"></el-table-column>
                <el-table-column label="渠道上账金额/元" align="center">
                    <template slot-scope="scope">
                        {{ scope.row.money||"--" }}
                    </template>
                </el-table-column>
                <el-table-column label="凭证" align="center" prop="updateBy">
                    <template slot-scope="scope">
                        <img class="icon" :src="scope.row.voucherPic" alt="">
                    </template>
                </el-table-column>
                <el-table-column label="操作人" align="center" prop="updateBy"></el-table-column>
                <el-table-column label="操作时间" width="160" align="center" prop="updateTime"></el-table-column>
            </el-table>
        </div>
        <div class="pagination-container">
            <el-pagination background @size-change="handleSizeChange" @current-change="handleCurrentChange"
                layout="total, sizes,prev, pager, next,jumper" :current-page.sync="listQuery.pageNum"
                :page-size="listQuery.pageSize" :page-sizes="[10, 15, 20]" :total="total">
            </el-pagination>
        </div>
    </div>
</template>
<script>
import { upCheckList } from "@/api/channel";
import { formatDate } from "@/utils/date";

const defaultListQuery = {
    pageNum: 1,
    pageSize: 10,
    ecName: null,
    startTime: '',
    endTime: ''
};
export default {
    name: "upCheck",
    data() {
        return {
            date: "",
            listQuery: Object.assign({}, defaultListQuery),
            list: null,
            total: null,
            listLoading: false,
            isEdit: false,
            allocRoleIds: [],
            allRoleList: [],
            allocAdminId: null,
        };
    },
    watch: {
        date(val) {
            if (val) {
                this.listQuery.startTime = Date.parse(val[0]);
                this.listQuery.endTime = Date.parse(val[1]);
            } else {
                this.listQuery.startTime = "";
                this.listQuery.endTime = "";
            }
        },
    },
    created() {
        this.getList();
    },
    filters: {
        formatDateTime(time) {
            if (time == null || time === "") {
                return "N/A";
            }
            let date = new Date(time);
            return formatDate(date, "yyyy-MM-dd hh:mm:ss");
        },
    },
    methods: {
        handleResetSearch() {
            this.listQuery = Object.assign({}, defaultListQuery);
        },
        handleSearchList() {
            this.listQuery.pageNum = 1;
            this.getList();
        },
        handleSizeChange(val) {
            this.listQuery.pageNum = 1;
            this.listQuery.pageSize = val;
            this.getList();
        },
        handleCurrentChange(val) {
            this.listQuery.pageNum = val;
            this.getList();
        },
        getList() {
            this.listLoading = true;
            upCheckList(this.listQuery).then((response) => {
                this.listLoading = false;
                this.list = response.data.list;
                this.total = response.data.total;
            });
        },
    },
};
</script>
<style scoped>
.icon {
    width: 60px;
    height: 60px;
}
</style>
