<template>
    <el-dialog id="tableBody" title="人工打款单审核" :visible.sync="dialogVisible" width="35%"   center :before-close="handleClose">
        <div style="margin-left:20%">
            <h3>请确认打款信息：</h3>
            <br/>
            <div>
                <el-row :gutter="20" style="margin-left:5%;line-height: 23px;">
                    <el-col :span="16"><div class="grid-content bg-purple">打款批次：{{  this.client.batchNo }}</div></el-col>
                    <el-col :span="16"><div class="grid-content bg-purple">打款数量：{{  this.client.totalCount }}</div></el-col>
                    <el-col :span="16"><div class="grid-content bg-purple">总金额：{{  this.client.totalAmt }}</div></el-col>
                </el-row>
               
            </div>
             <!-- 打款密码和打款渠道选择 -->
             <p>
            <el-form :model="form" ref="form"  label-width="120px" class="demo-ruleForm">
                <el-form-item label="请选择打款渠道" prop="payChannelApi">
                    
                    <el-radio-group v-model="form.payChannelApi">
                        <el-radio
                        v-for="(item,index) in options"
                        :key="index"
                        :label="item.payChannelApi"
                        >{{ item.channelName }}</el-radio>
                    </el-radio-group>
                </el-form-item>
                 <el-form-item label="请输入交易密码" prop="password">
                    <el-input placeholder="请输入交易密码" v-model="form.password" style="width:245px" show-password></el-input>
                 </el-form-item>
            </el-form>
            </p>
            <br/>

            <div slot="footer" style="margin-right:30%">
                <el-button type="info" plain @click="handleClose">取 消</el-button>
                <el-button type="primary" @click="submitMarket" style="margin-left:150px">确 定</el-button>
            </div>
        </div>
    </el-dialog>
</template>

<script>
    export default {
        name: "byhPassMoney",
        props: {
            dialogVisible: {
                type: Boolean
            },
            batchNo: {
                type: String
            },
            totalCount: {
                type: Number
            },
            totalAmt: {
                type: Number
            },
        },
        data () {
            return {
                client: {
                    batchNo:'',
                    totalAmt:'',
                    totalCount:'',
                },
                form: {
                    password:'',
                    payChannelApi:'',
                },
                options:[]
            }
        },
        created() {
            this.client = {
                batchNo: this.batchNo,
                totalAmt: this.totalAmt,
                totalCount: this.totalCount,
            }
        },
        methods: {

            /** 关闭处理 */
            handleClose () {
                this.visible = false
                setTimeout(() => {
                    this.$emit('update:dialogVisible', false)
                }, 100)
            },

            submitMarket() {
                 if (this.form.password == '') {
                    this.$message({message: '密码不能为空', type: 'error'});
                    return;
                }
                this.$$get('/raise/raiseApproval', this.buildParam()).then(res => {

                    if (res.data.code != 200) {
                        this.$message.error(res.data.message);
                        return
                    }
                    
                    this.$message({message: '审核通过', type: 'success'});
                    this.handleClose();
                    window.location.reload()

                })
                .catch(error => {
                    this.$Message.error(error || '系统异常');
                });
            },
            // 加载渠道
            getChannel(){
                 this.$$post('/channel/getCnlRelationList', this.buildParam()).then(res => {
                    if (res.data.code != 200) {
                        this.$message.error(res.data.message);
                        return
                    }
                    this.options = res.data.result;
                }).catch(error => {
                    this.$Message.error(error || '系统异常');
                });
            },
                //参数
            buildParam() {
                var return_hash = {
                    approvalStatus:'SUCCESS',
                };

                if (this.client.batchNo != '') {
                    return_hash['batchNo'] = this.client.batchNo
                }
                 if (this.form.payChannelApi != '') {
                    return_hash['channel'] = this.form.payChannelApi
                }
                 if (this.form.password != '') {
                    return_hash['password'] = this.form.password
                }
                return return_hash;
            },

        },
         mounted: function () {
             this.getChannel()
        },
    }
</script>

<style scoped lang="stylus" >

#tableBody{
    text-align:center;
}
 .el-row {
    margin-bottom: 20px;
    &:last-child {
      margin-bottom: 0;
    }
  }
</style>