<template>
    <div class="app-container">
        <div class="flexBet searchTop">
            <div class="title flex m20">
                <div class="bar"></div>
                <div class="text">后台修改余额记录</div>
            </div>
            <el-row :gutter="10" class="mb8">
                <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
            </el-row>
        </div>
        <div class="bg">
            <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="86px"
                class="flex form" style="padding:0 20px">
                <el-form-item label="用户名称" prop="userName">
                    <el-input size="medium" v-model="queryParams.userName" placeholder="请输入用户名称"
                        @keyup.enter.native="handleQuery" style="width: 215px;border-color: #E6F1FF;" />
                </el-form-item>
                <el-form-item label="账号编号" prop="accountNo">
                    <el-input size="medium" v-model="queryParams.accountNo" placeholder="请输入账号编号"
                        @keyup.enter.native="handleQuery" style="width: 215px;border-color: #E6F1FF;" />
                </el-form-item>
                <el-form-item label="业务编号" prop="witNo">
                    <el-input size="medium" v-model="queryParams.witNo" placeholder="请输入业务编号"
                        @keyup.enter.native="handleQuery" style="width: 215px;border-color: #E6F1FF;" />
                </el-form-item>
                <el-form-item label="渠道类型" prop="channelType">
                    <el-select v-model="queryParams.channelType" placeholder="请选择渠道类型" clearable size="medium">
                        <el-option v-for="(item, i) in payChannelCon" :key="i" :label="item.channelName"
                            :value="item.payChannel"></el-option>
                    </el-select>
                </el-form-item>
                <el-form-item label="支付类型" prop="payType">
          <el-select v-model="queryParams.payType" placeholder="请选择支付类型" clearable size="medium">
            <el-option v-for="(item, i) in sortLevType" :key="i" :label="item.typeName" :value="item.payType"></el-option>
          </el-select>
        </el-form-item>
                <el-form-item label="业务类型" prop="isIncome">
                    <el-select v-model="queryParams.isIncome" placeholder="请选择业务类型" clearable size="medium">
                        <el-option v-for="(item, i) in userLevType" :key="i" :label="item.label"
                            :value="item.value"></el-option>
                    </el-select>
                </el-form-item>

                <!-- <el-form-item label="创建时间">
                    <el-date-picker v-model="dateRange" size="small" style="width: 240px" value-format="yyyy-MM-dd"
                        type="daterange" range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期"
                        :unlink-panels="true"></el-date-picker>
                </el-form-item> -->
                <el-form-item>
                    <el-button type="primary" icon="" size="medium" @click="handleQuery">搜索</el-button>
                    <el-button icon="el-icon-refresh" size="medium" @click="resetQuery">重置</el-button>
                </el-form-item>
            </el-form>
            <el-table stripe v-loading="loading" :data="infoList">
                <el-table-column label="账号编号" align="center" prop="accountNo" />
                <el-table-column label="渠道类型" align="center" prop="channelType" />
                <el-table-column label="支付类型" align="center" prop="payType" />
                <el-table-column label="用户名称" align="center" prop="userName" />
                <el-table-column label="业务编号" align="center" prop="witNo" />
                <el-table-column label="变动前金额" align="center" prop="beforeAmt" />
                <el-table-column label="变动金额" align="center" prop="tranAmt" />
                <el-table-column label="变动后金额" align="center" prop="afterAmt" />
                <el-table-column label="业务类型" align="center" prop="userType" min-width="120">
                    <template slot-scope="scope">
                        <el-tag :type="
                            scope.row.isIncome == 'yes'
                                ? 'success' : 'primary'
                        ">
                            {{ scope.row.isIncome == 'yes' ? '增加' : '减少' }}
                        </el-tag>
                    </template>
                </el-table-column>

                <el-table-column label="备注" align="center" prop="remarks" />
                <el-table-column label="修改时间" align="center" prop="updateTime" min-width="180" />
                <el-table-column label="创建时间" align="center" prop="createTime" min-width="180" />

            </el-table>
            <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum"
                :limit.sync="queryParams.pageSize" @pagination="getList" />
        </div>


    </div>
</template>
  
<script>
import { common_api, pkUpdateBalanceRecord } from "@/api/form";

export default {
    name: "PkAdWeiList",
    dicts: ['pay_status'],
    data() {
        return {
            payChannelCon: [],
            sortLevType: [],
            userLevType: [
                {
                    label: '增加',
                    value: 'yes',
                },
                {
                    label: '减少',
                    value: 'no',
                },
            ],
            // 选中数组
            ids: [],
            // 非单个禁用
            single: true,
            // 非多个禁用
            multiple: true,
            dateRange: [],
            // 新增广告图片地址
            imageUrl: "",
            // 遮罩层
            loading: true,
            // 导出遮罩层
            exportLoading: false,
            // 选中数组
            ids: [],
            // 非单个禁用
            single: true,
            // 非多个禁用
            multiple: true,
            // 显示搜索条件
            showSearch: true,
            // 总条数
            total: 0,
            // 广告表格数据
            infoList: [],
            // 弹出层标题
            title: "",
            // 是否显示弹出层
            open: false,
            // 查询参数
            queryParams: {
                pageNum: 1,
                pageSize: 20,
                isIncome: null,
                witNo: null,
                userName:null,
                accountNo:null,
                channelType:null,
                payType:null
            },

            // 表单参数
            form: {},
            // 表单校验
            rules: {
                positionName: [
                    { required: true, message: "请输入广告名称", trigger: "blur" },
                ]
            }
        };
    },
    created() {
        this.getList();
        this.init();
    },
    methods: {
        init() {
            common_api.payChannelAll().then((response) => {
                this.payChannelCon = response.data
            });
            common_api.payTypeAll().then((response) => {
        this.sortLevType = response.data
      });
        },
        getList() {
            this.loading = true;
            pkUpdateBalanceRecord
                .listInfo(this.addSESDateRange(this.queryParams, this.dateRange))
                .then((response) => {
                    this.infoList = response.data.rows;
                    this.total = Number(response.data.total);
                    this.loading = false;
                }).catch(() => {
                    this.loading = false;
                })
        },
        // 取消按钮
        cancel() {
            this.open = false;
            this.reset();
        },
        // 表单重置
        reset() {
            this.form = {};
            this.resetForm("form");
        },
        /** 搜索按钮操作 */
        handleQuery() {
            this.queryParams.pageNum = 1;
            this.getList();
        },
        /** 重置按钮操作 */
        resetQuery() {
            this.dateRange = [];
            this.resetForm("queryForm");
            this.handleQuery();
        },
        /** 新增按钮操作 */
        handleAdd() {
            this.reset();
            this.open = true;
            this.title = "添加广告位信息";
        },
        /** 修改按钮操作 */
        handleUpdate(row) {
            this.reset();
            const id = row.id || this.ids;
            pkUserInfo.getInfo(id).then((response) => {
                this.form = response.data;
                this.open = true;
                this.title = "修改广告位信息";
            });
        },

    },
};
</script>
<style scoped>
.font {
    padding: 10px;
    border-radius: 10px;
    background: #808080;
    font-size: 12px;
    margin-left: 20px;
    color: #fff;
    margin-bottom: 10px;
    width: 50%;
}
</style>