<template>
    <div class="eibs-tab">
        <!-- <c-col :span="12">
        <el-form-item label="Drag  Drop Sender" prop="botp.recget.sdamod.dadsnd">
            <c-input  v-model="model.botp.recget.sdamod.dadsnd"  placeholder="请输入Drag  Drop Sender"></c-input>
        </el-form-item>
       </c-col> -->
        <c-col :span="24">
            <c-col :span="11">
                <el-form-item label="Reference" prop="bodgrp.rec.ownref">
                    <c-fullbox>
                        <c-input v-model="model.bodgrp.rec.ownref" maxlength="16" placeholder="请输入Reference"
                            style="width: 100%" disabled></c-input>
                        <template slot="footer">
                            <c-button style="margin-left:8px; padding: 0 12px" size="small" type="primary" @click="">
                                <span style="font-family: '宋体'; font-weight: bold">i</span>
                            </c-button>
                        </template>
                    </c-fullbox>
                </el-form-item>
            </c-col>
            <c-col :span="11" :offset="1">
                <el-form-item label="Name" prop="bodgrp.rec.nam" style="width: 100%">
                    <c-input v-model="model.bodgrp.rec.nam" maxlength="40" style="width: 100%" placeholder="请输入Name"
                        disabled></c-input>
                </el-form-item>
            </c-col>
        </c-col>

        <!-- <c-col :span="12">
            <el-form-item label="" prop="botp.recget.sdamod.seainf">
                <c-input v-model="model.botp.recget.sdamod.seainf" placeholder="请输入"></c-input>
            </el-form-item>
        </c-col> -->

        <c-col :span="24">
            <c-col :span="11">
                <c-col :span="12">
                    <el-form-item label="Document Amount" prop="bodgrp.cbs.max.cur">
                        <c-input v-model="model.bodgrp.cbs.max.cur" style="width:100%" placeholder="请选择Document Amount"
                            disabled>
                        </c-input>
                    </el-form-item>
                </c-col>
                <c-col :span="11" :offset="1">
                    <el-form-item label="" prop="bodgrp.cbs.max.amt" label-width="0">
                        <c-input v-model.number="model.bodgrp.cbs.max.amt" placeholder="请输入Document Amount" disabled>
                        </c-input>
                    </el-form-item>
                </c-col>
            </c-col>
            <c-col :span="11" :offset="1">
                <el-form-item label="Drawer Ref." prop="bodgrp.drr.pts.ref">
                    <c-input v-model="model.bodgrp.drr.pts.ref" maxlength="16" placeholder="请输入Drawer" disabled>
                    </c-input>
                </el-form-item>
            </c-col>
        </c-col>

        <c-col :span="24">
            <c-col :span="11">
                <c-col :span="12">
                    <el-form-item label="Open Amount" prop="bodgrp.cbs.opn1.cur">
                        <c-input v-model="model.bodgrp.cbs.opn1.cur" style="width:100%"
                            placeholder="请选择Warehouse/Insurance" disabled>
                        </c-input>
                    </el-form-item>
                </c-col>
                <c-col :span="11" :offset="1">
                    <el-form-item label="" label-width="0" prop="bodgrp.cbs.opn1.amt">
                        <c-input v-model.number="model.bodgrp.cbs.opn1.amt" style="width:100%"
                            placeholder="请输入Open Amount" disabled></c-input>
                    </el-form-item>
                </c-col>
            </c-col>
            <c-col :span="11" :offset="1">
                <c-col :span="24">
                    <el-form-item label="" prop="bodgrp.drr.pts.nam">
                        <c-input v-model="model.bodgrp.drr.pts.nam" placeholder="bodgrp.drr.pts.nam" disabled></c-input>
                    </el-form-item>
                </c-col>
            </c-col>
        </c-col>


        <c-col :span="24">
            <c-col :span="11">
                <el-form-item label="Collection Condition" prop="bodgrp.rec.doctypcod">
                    <c-select v-model="model.bodgrp.rec.doctypcod" style="width: 100%"
                        placeholder="请选择Payment Condition" disabled>
                        <el-option v-for="item in codes.doctypcod" :key="item.value" :label="item.label"
                            :value="item.value">
                        </el-option>
                    </c-select>
                </el-form-item>
            </c-col>

            <c-col :span="11" :offset="1">
                <el-form-item label="Collecting Bank Ref." prop="bodgrp.col.pts.ref">
                    <c-input v-model="model.bodgrp.col.pts.ref" maxlength="16" placeholder="请输入Collecting Bank"
                        disabled></c-input>
                </el-form-item>
            </c-col>
        </c-col>

        <c-col :span="24">
            <c-col :span="11">
                <c-col :span="24">
                    <el-form-item label="Document Set Status" prop="bodgrp.rec.docsta">
                        <c-select v-model="model.bodgrp.rec.docsta" style="width: 100%"
                            placeholder="请输入Document Set Status" disabled>
                            <el-option v-for="item in codes.docstabot" :key="item.value" :label="item.label"
                                :value="item.value">
                            </el-option>
                        </c-select>
                    </el-form-item>
                </c-col>
            </c-col>
            <c-col :span="11" :offset="1">
                <c-col :span="24">
                    <el-form-item label="" prop="bodgrp.col.pts.nam">
                        <c-input v-model="model.bodgrp.col.pts.nam" maxlength="40" placeholder="bodgrp.col.pts.nam"
                            disabled>
                        </c-input>
                    </el-form-item>
                </c-col>
            </c-col>
        </c-col>

        <c-col :span="24">
            <c-col :span="11">
                <c-col :span="12">
                    <el-form-item label="Tenor Specification" prop="bodgrp.rec.matdat">
                        <c-input v-model="model.bodgrp.rec.matdat" placeholder="" disabled>
                        </c-input>
                    </el-form-item>
                </c-col>
                <c-col :span="9">
                    <el-form-item label="" prop="bodgrp.rec.matpercnt">
                        <c-input v-model="model.bodgrp.rec.matpercnt" placeholder="请输入Tenor Specification" disabled>
                        </c-input>
                    </el-form-item>
                </c-col>
                <c-col :span="2" :offset="1">
                    <span>Days</span>
                </c-col>
                <c-col :span="24">
                    <el-form-item label="" prop="bodgrp.rec.matperbeg">
                        <c-select v-model="model.bodgrp.rec.matperbeg" style="width: 100%"
                            placeholder="请选择Start of Maturity Period MATBEG" disabled>
                            <el-option v-for="item in codes.matperbeg" :key="item.value" :label="item.label"
                                :value="item.value">
                            </el-option>
                        </c-select>
                    </el-form-item>
                </c-col>
                <!-- <c-col :span="5">
                    <span v-text="model.bodgrp.rec.matpertyp" data-path=".bodgrp.rec.matpertyp"> </span>
                </c-col> -->
            </c-col>

            <c-col :span="11" :offset="1">
                <c-col :span="24">
                    <el-form-item label="Drawee Ref." prop="bodgrp.dre.pts.ref">
                        <c-input v-model="model.bodgrp.dre.pts.ref" maxlength="16" disabled>
                        </c-input>
                    </el-form-item>
                </c-col>
                <c-col :span="24">
                    <el-form-item label="" prop="bodgrp.dre.pts.nam">
                        <c-input v-model="model.bodgrp.dre.pts.nam" maxlength="40" placeholder="bodgrp.dre.pts.nam"
                            disabled>
                        </c-input>
                    </el-form-item>
                </c-col>
            </c-col>
        </c-col>

        <c-col :span="24">
            <c-col :span="11">
                <c-col :span="12">
                    <el-form-item label="Order Date" prop="bodgrp.rec.rcvdat">
                        <c-date-picker type="date" v-model="model.bodgrp.rec.rcvdat" style="width:100%"
                            placeholder="请选择Order Date" disabled></c-date-picker>
                    </el-form-item>
                </c-col>
                <c-col :span="12">
                    <el-form-item label="Presentation Date" prop="bodgrp.rec.predat">
                        <c-date-picker type="date" v-model="model.bodgrp.rec.predat" style="width:100%"
                            placeholder="请选择Presentation Date" disabled></c-date-picker>
                    </el-form-item>
                </c-col>
            </c-col>
        </c-col>

        <c-col :span="24" style="margin-top:15px;border-top:2px solid #ddd;padding-top:15px">
            <c-col :span="11">
                <c-col :span="12">
                    <el-form-item label="Amount Accepted" prop="setmod.doccur">
                        <c-input v-model="model.setmod.doccur" style="width:100%" placeholder="请选择document currency"
                            disabled>
                        </c-input>
                    </el-form-item>
                </c-col>
                <c-col :span="11" :offset="1">
                    <el-form-item label-width="0" prop="setmod.docamt">
                        <c-input v-model.number="model.setmod.docamt" placeholder="请输入document amount" disabled>
                        </c-input>
                    </el-form-item>
                </c-col>
            </c-col>
            <c-col :span="11" :offset="1">
                <c-checkbox v-model="model.mtabut.clsflg" disabled>Close Contract</c-checkbox>
            </c-col>
        </c-col>


        <c-col :span="24">
            <c-col :span="11">
                <c-col :span="12">
                    <el-form-item label="Reduction Amount" prop="setmod.doccur">
                        <c-input v-model="model.setmod.doccur" style="width:100%" placeholder="请选择document currency"
                            disabled>
                        </c-input>
                    </el-form-item>
                </c-col>
                <c-col :span="11" :offset="1">
                    <el-form-item label-width="0" prop="setmod.redamt">
                        <c-input v-model.number="model.setmod.redamt" placeholder="请输入document amount"
                            :disabled="model.bodgrp.rec.focflg == 'X'">
                        </c-input>
                    </el-form-item>
                </c-col>
            </c-col>
            <c-col :span="11" :offset="1">
                <c-checkbox v-model="model.bodgrp.rec.focflg" @change="change">Free of Payment</c-checkbox>
            </c-col>
        </c-col>
        <!-- <c-col :span="12">
            <el-form-item label="currency discount paid back" prop="bptbck.dscbckcur">
                <c-input v-model="model.bptbck.dscbckcur" maxlength="3" placeholder="请输入currency discount paid back">
                </c-input>
            </el-form-item>
        </c-col> -->

        <c-col :span="24" style="margin-top: 30px">
            <span style="font-size:14px">Bills to Pay back:</span>
        </c-col>
        <c-col :span="24" style="margin-top: -10px">
            <c-col :span="12">
                <c-edit-table :model="model" v-bind="docgrd" style="margin-left:-30px">
                </c-edit-table>
            </c-col>
        </c-col>
        <c-col :span="24">
            <c-col :span="11">
                <c-istream-table ref="table" :list="model.liaall.tenstm.rows || []" :columns="stmData.columns"
                    :showSelection="true" v-on:multipleSelect="multipleSelect" prop="liaall.tenstm">
                </c-istream-table>
            </c-col>
        </c-col>

        <!-- <c-col :span="24">
            <div class="e-table-wrapper">
                <el-table :data="model.bptbck.bptbckg" style="width: 100%">
                    <el-table-column prop="ownref" label="" sortable width="100">
                    </el-table-column>
                    <el-table-column prop="opncur" label="" sortable width="100">
                    </el-table-column>
                    <el-table-column prop="opnamt" label="" sortable width="100">
                    </el-table-column>
                    <el-table-column prop="bckamt" label="" sortable width="100">
                    </el-table-column>
                    <el-table-column prop="butcal" label="" sortable width="100">
                    </el-table-column>
                </el-table> -->
        <!-- <el-pagination
                 layout="prev, pager, next"
                 :total="pager.bptbck_bptbckg.total">
              </el-pagination> -->
        <!-- </div>
        </c-col> -->

        <!-- <c-col :span="12">
            <el-form-item label="Tenor Stream" prop="liaall.tenstm">
                <c-input v-model="model.liaall.tenstm" placeholder="请输入Tenor Stream"></c-input>
            </el-form-item>
        </c-col> -->
    </div>
</template>
<script>
import Api from "~/service/Api"
import commonProcess from "~/mixin/commonProcess";
import CodeTable from "~/config/CodeTable"
import Event from "~/model/Botpay/Event"

export default {
    inject: ['root'],
    props: ["model", "codes"],
    mixins: [commonProcess],
    data() {
        return {
            stmData: {
                columns: [
                    '1 1 "Type" 80',
                    '2 2 "Dbt" 80',
                    '3 3 "Cdt" 80',
                    '4 4 "Cur" 80',
                    '5 5 "Amt" 113 2 8 1 4',
                    // '6 6 "Mat.Dat." 80 4 7 1',
                    { index: 6, position: 6, width: 113, render: (item, scope) => { return scope.row[item.prop] === 'null' ? '' : scope.row[item.prop] }, label: 'Mat.Dat.' },
                ],
            },
            docgrd: {
                columns: [{
                    title: "Reference",
                    width: "80px",
                    dataIndex: "ownref",
                    show: "input",
                },
                {
                    title: "Cur",
                    width: "80px",
                    dataIndex: "opncur",
                    show: "input",
                },
                {
                    title: "Open Amount",
                    width: "100px",
                    dataIndex: "opnamt",
                    show: "input",
                },
                {
                    title: "Amount Paid",
                    width: "100px",
                    dataIndex: "bckamt",
                    show: "input",
                },
                {
                    title: "Button",
                    width: "100px",
                    dataIndex: "butcal",
                    show: "button",
                },

                ],
                urls: "bptbck.bptbckg.docgrd",
            },

        }
    },
    methods: {
        ...Event,
        async change() {
            if (this.model.bodgrp.rec.focflg === "X") {
                this.model.setmod.redamt = this.model.setmod.docamt;

            } else {
                this.model.setmod.redamt = "0.00";
            }
            let rtnmsg = await this.executeDefault("liaall.tenstm");
            this.model.bodgrp.rec.docsta = rtnmsg.data.bodgrp_rec_docsta;
        },
        async multipleSelect(selection) {
            let rtnmsg = await this.executeDefault("executeNotify");
            if (selection.length > 1) {
                this.$notify({
                    title: "error",
                    message: "You cannot select more than one tenor",
                    type: "error",
                });
            } else {
                let chkIds;
                if (selection.length === 0) {
                    chkIds = [];
                    this.model.liaall.tensetstm.rows = [];
                } else {
                    chkIds = [selection[0] + 1];
                }
                //
                console.log(this.model.liaall.tensetstm);
                let params = { chkDst: "liaall.tenstm", chkIds };
                console.log(params);
                const rtnmsg = await this.executeRule("liaall.tenstm", params);
                console.log(rtnmsg);
                if (rtnmsg.respCode == SUCCESS) {
                    this.updateModel(rtnmsg.data);
                } else {
                    this.$notify.error({ title: "错误", message: "服务请求失败!" });
                }
            }
        },
    },
    created: function () {

    }
}
</script>
<style>
</style>