<template>
    <div class="eibs-tab">
        <c-col :span="8" class="col-left">
            <c-col :span="24">
                <el-form-item label="申报号码" prop="argmod.rptno">
                    <c-input maxlength="22" placeholder="请输入申报号码" v-model="model.argmod.rptno"></c-input>
                </el-form-item>
            </c-col>
            <c-col :span="24">
                <el-form-item label="业务号码" prop="argmod.extinfbop">
                    <c-input maxlength="22" placeholder="请输入业务号码" v-model="model.argmod.extinfbop"></c-input>
                </el-form-item>
            </c-col>
            <c-col :span="24">
                <el-form-item label="数据来源" prop="argmod.datsrc">
                    <c-select dbCode="datsrc" placeholder="请输入数据来源" style="width: 100%" v-model="model.argmod.datsrc">
                    </c-select>
                </el-form-item>
            </c-col>
            <c-col :span="24">
                <el-form-item label="员工号" prop="argmod.usr">
                    <c-input maxlength="8" placeholder="请输入员工号" v-model="model.argmod.usr"></c-input>
                </el-form-item>
            </c-col>
            <c-col :span="24">
                <el-form-item label="申报主体名称" prop="argmod.custnm">
                    <c-input maxlength="128" placeholder="请输入申报主体名称" v-model="model.argmod.custnm"></c-input>
                </el-form-item>
            </c-col>
        </c-col>
        <c-col :span="8">
            <c-col :span="24">
                <el-form-item label="数据状态" prop="argmod.selsta">
                    <c-select dbCode="schsta" placeholder="请选择数据状态" style="width: 100%" v-model="model.argmod.selsta">
                    </c-select>
                </el-form-item>
            </c-col>

            <c-col :span="24">
                <el-form-item label="日期类型" prop="argmod.selectdat">
                    <c-select dbCode="dattyp" placeholder="请输入日期类型" style="width: 100%"
                              v-model="model.argmod.selectdat">
                    </c-select>
                </el-form-item>
            </c-col>
            <c-col :span="24">
                <el-form-item label="起始日" prop="argmod.ywcredat">
                    <c-date-picker placeholder="请输入起始日" style="width: 100%" type="date"
                                   v-model="model.argmod.ywcredat"></c-date-picker>
                </el-form-item>
            </c-col>
            <c-col :span="24">
                <el-form-item label="结束日" prop="argmod.ywtildat">
                    <c-date-picker placeholder="请输入结束日" style="width: 100%" type="date"
                                   v-model="model.argmod.ywtildat"></c-date-picker>
                </el-form-item>
            </c-col>
            <c-col :span="24">
                <el-form-item label="导入申报日期" prop="argmod.impdat">
                    <c-date-picker placeholder="请输入导入申报日期" style="width: 100%" type="date"
                                   v-model="model.argmod.impdat"></c-date-picker>
                </el-form-item>
            </c-col>
        </c-col>
        <!-- LT000021 : 申报号码 -->
        <!-- LT000043 : 数据状态 -->
        <!-- LT000028 : 收付汇币种 -->
        <c-col :span="8" class="col-right">
            <c-col :span="24">
                <el-form-item label="收付汇币种" prop="argmod.txccy">
                    <c-select dbCode="curtxt" placeholder="请输入收付汇币种" style="width: 100%" v-model="model.argmod.txccy">
                    </c-select>
                </el-form-item>
            </c-col>
            <c-col :span="24">
                <el-form-item label="主体标识码" prop="argmod.custcod">
                    <c-input maxlength="18" placeholder="请输入主体标识码" v-model="model.argmod.custcod"></c-input>
                </el-form-item>
            </c-col>
            <!-- LT000047 : 日期类型 -->
            <!-- LT000020 : 业务号码 -->

            <!-- LT000040 : 主体标识码 -->

            <c-col :span="24">
                <el-form-item label="机构号" prop="argmod.branch">
                    <c-select maxlength="9" placeholder="请输入机构号" v-model="model.argmod.branch">
                        <el-option :key="item.branch" :label="item.branch+' '+item.bchname" :value="item.branch"
                                   v-for="item in model.bchtypList">
                        </el-option>
                    </c-select>
                </el-form-item>
            </c-col>
            <!-- LT000044 : 起始日 -->
            <!-- LT000036 : 机构号 -->
            <!-- LT000033 : 数据来源 -->

            <c-col :span="24">
                <el-form-item label="金融机构标识码" prop="argmod.bchcod">
                    <c-select placeholder="请输入金融机构标识码" style="width: 100%" v-model="model.argmod.bchcod">
                        <el-option :key="index" :label="item.decnum+' '+item.bchname" :value="item.decnum+'-'+item.bchname"
                                   v-for="(item,index) in model.bchtypList">
                        </el-option>
                    </c-select>
                </el-form-item>
            </c-col>
            <!-- LT000048 : 员工号 -->
            <!-- LT000045 : 到期日 -->
            <!-- LT000037 : 金融机构标识码 -->

            <c-col :span="24">
                <el-form-item label="导入所属机构" prop="argmod.bchinr">
                    <c-select placeholder="请输入导入所属机构" style="width: 100%" v-model="model.argmod.bchinr">
                        <el-option :key="item.inr" :label="item.branch+' '+item.decnum+' '+item.bchname" :value="item.inr"
                                   v-for="item in model.bchtypList">
                        </el-option>
                    </c-select>
                </el-form-item>
            </c-col>
        </c-col>
        <!-- LT000053 : 申报主体名称 -->
        <!-- LT000052 : 导入申报日期 -->
        <!-- LT000051 : 导入所属机构 -->
        <c-col :span="24">
            <c-col :span="12">
                <el-form-item></el-form-item>
            </c-col>
            <c-col :span="12">
                <c-col :span="12">
                    <el-form-item>
                        <c-button @click="query" icon="el-icon-search" size="small" type="primary">
                            查询
                        </c-button>
                    </el-form-item>
                </c-col>
                <c-col :span="12">
                    <el-form-item>
                        <c-button @click="chongzhi" size="small" type="primary"> 重置</c-button>
                    </el-form-item>
                </c-col>
            </c-col>
        </c-col>

        <el-col :span="24" style="margin-top: 10px;margin-bottom: 10px;">
            <div class="button-container">
                <c-button :disabled="model.enableflg == 'N' " @click="go('dbbadd')" size="medium" type="primary">新增</c-button>
                <c-button :disabled="model.enableflg == 'N' " @click="chkbop" size="medium" type="primary">数据检核</c-button>
                <el-upload :before-upload="beforeUpload" :data="model.argmod" :file-list="fileList"
                           :on-success="handleSucess" :show-file-list="false" action="/webapi/report/dbbsel/upload"
                           class="upload-button">
                    <el-button :disabled="model.enableflg == 'N' " size="medium" slot="trigger" type="primary">导入</el-button>
                </el-upload>
                <c-button @click="exportExcel" size="medium" type="primary">导出</c-button>
                <c-button :disabled="model.enableflg == 'N' " @click="piliangchexiao" size="medium" type="primary">批量撤销</c-button>
                <c-button @click="downloadTemplate" size="medium" type="primary">下载模板</c-button>
            </div>
        </el-col>

        <c-col :span="24">
            <div class="e-table-wrapper">
                <el-table :data="model.reclst" :highlight-current-row="true" style="width: 100%" @selection-change="handleSelectionChange" row-key="inr" ref="table">
                    <el-table-column :selectable="selectableFn" type="selection" width="55" align="center" fixed="left" :resizable="false" :reserve-selection="true"  >
                    </el-table-column>
                    <!-- <el-table-column :show-overflow-tooltip="true" align="left" label="" min-width="150" prop="checkinf"
                                     sortable>
                    </el-table-column> -->
                    <el-table-column :show-overflow-tooltip="true" align="left" label="申报号码" min-width="150"
                                     prop="rptno" sortable>
                    </el-table-column>
                    <el-table-column :show-overflow-tooltip="true" align="left" label="银行业务编号" min-width="200"
                                     prop="buscode" sortable>
                    </el-table-column>
                    <el-table-column :show-overflow-tooltip="true" align="left" label="汇款人名称" min-width="210"
                                     prop="custnm" sortable>
                    </el-table-column>
                    <el-table-column :show-overflow-tooltip="true" align="left" label="机构名称" min-width="210"
                                     prop="bchnam" sortable>
                    </el-table-column>
                    <el-table-column :show-overflow-tooltip="true" align="left" label="收付汇日期" min-width="150"
                                     prop="sfhdat" sortable>
                    </el-table-column>
                    <el-table-column :show-overflow-tooltip="true" align="left" label="检核状态" min-width="150"
                                     prop="sndflg" sortable>
                        <template slot-scope="scope">
							<span> {{getCodelabel(scope.row.sndflg,"bpschklabels") }}
							</span>
                        </template>
                    </el-table-column>
                    <el-table-column :show-overflow-tooltip="true" align="left" label="基础信息" min-width="150"
                                     prop="bassta" sortable>
                        <template slot-scope="scope">
							<span> {{getCodelabel(scope.row.bassta,"bpsstalabels") }}
							</span>
                        </template>
                    </el-table-column>
                    <el-table-column :show-overflow-tooltip="true" align="left" label="基础操作类型" min-width="150"
                                     prop="actiontype" sortable>
                        <template slot-scope="scope">
							<span> {{getCodelabel(scope.row.actiontype,"actionlabels") }}
							</span>
                        </template>
                    </el-table-column>
                    <el-table-column :show-overflow-tooltip="true" align="left" label="申报信息" min-width="150"
                                     prop="dclsta" sortable>
                        <template slot-scope="scope">
							<span> {{getCodelabel(scope.row.dclsta,"bpsstalabels") }}
							</span>
                        </template>
                    </el-table-column>
                    <el-table-column :show-overflow-tooltip="true" align="left" label="管理信息" min-width="150"
                                     prop="vrfsta" sortable>
                        <template slot-scope="scope">
							<span> {{getCodelabel(scope.row.vrfsta,"bpsstalabels") }}
							</span>
                        </template>
                    </el-table-column>
                    <el-table-column :show-overflow-tooltip="true" align="left" label="员工号" min-width="150"
                                     prop="ownusr" sortable>
                    </el-table-column>
                    <el-table-column :show-overflow-tooltip="true" align="left" label="汇款人类型" min-width="150"
                                     prop="custype" sortable>
                        <template slot-scope="scope">
							<span> {{getCodelabel(scope.row.custype,"scutyplabels") }}
							</span>
                        </template>
                    </el-table-column>
                    <el-table-column :show-overflow-tooltip="true" align="left" label="主体标识码" min-width="150"
                                     prop="custcod" sortable>
                    </el-table-column>
                    <el-table-column :show-overflow-tooltip="true" align="left" label="收款人名称" min-width="150"
                                     prop="oppuser" sortable>
                    </el-table-column>
                    <el-table-column label="汇款币种" prop="txccy" sortable width="150">
                    </el-table-column>
                    <el-table-column :show-overflow-tooltip="true" align="left" label="汇款金额" min-width="150"
                                     prop="txamt" sortable>
                    </el-table-column>
                    <el-table-column :show-overflow-tooltip="true" align="left" label="经办日期" min-width="150"
                                     prop="credat" sortable>
                    </el-table-column>
                    <el-table-column :show-overflow-tooltip="true" align="left" label="数据来源" min-width="150"
                                     prop="datsrc" sortable>
                        <template slot-scope="scope">
							<span> {{getCodelabel(scope.row.datsrc,"datsrclabels") }}
							</span>
                        </template>
                    </el-table-column>
                    <el-table-column :show-overflow-tooltip="true" align="left" label="人民币账号" min-width="200"
                                     prop="lcyacc" sortable>
                    </el-table-column>
                    <el-table-column :show-overflow-tooltip="true" align="left" label="外汇账号" min-width="200"
                                     prop="fcyacc" sortable>
                    </el-table-column>
                    <el-table-column :show-overflow-tooltip="true" align="left" label="其他账号" min-width="200"
                                     prop="othacc" sortable>
                    </el-table-column>
                    <el-table-column fixed="right" label="操作" width="240px">
                        <template slot-scope="scope">
                            <c-button @click="go('dbbinf',{'inr':scope.row.inr})" size="small" style="margin-left: 0"
                                      type='text'>查看
                            </c-button>
                            <c-button @click="go('dbbpnt',{'inr':scope.row.inr})" size="small" style="margin-left: 0"
                                      type='text'>打印
                            </c-button>
                            <c-button :disabled="model.enableflg == 'N' " @click="ame(scope.row.bassta,scope.row.dclsta,scope.row.vrfsta,scope.row.actiontype,scope.row.inr)" size="small" style="margin-left: 0"
                                      type='text'>修改
                            </c-button>
                            <c-button :disabled="model.enableflg == 'N' " @click="del(scope.row.bassta,scope.row.dclsta,scope.row.vrfsta,scope.row.actiontype,scope.row.inr)" size="small" style="margin-left: 0"
                                      type='text'>删除
                            </c-button>
                            <c-button :disabled="model.enableflg == 'N' " @click="reb(scope.row.bassta,scope.row.dclsta,scope.row.vrfsta,scope.row.actiontype,scope.row.inr)" size="small" style="margin-left: 0"
                                      type='text'>历史数据重建
                            </c-button>
                        </template>
                    </el-table-column>
                </el-table>
                <el-pagination
                    @size-change="handleSizeChange"
                    @current-change="handleCurrentChange"
                    :current-page.sync="pagination.pageNum"
                    :page-sizes="[10, 20, 50, 100, 500]"
                    :page-size="pagination.pageSize"
                    layout="total, sizes, prev, pager, next, jumper"
                    :total="pagination.total">
                </el-pagination>
            </div>
        </c-col>

        <!-- 弹出框 -->
        <el-dialog :visible.sync="dialogVisible" title="导入日志信息">
            <el-table :data="tableData">
                <el-table-column label="交易类型" prop="objtyp"></el-table-column>
                <el-table-column label="错误行数" prop="linnum"></el-table-column>
                <el-table-column label="错误详情" prop="errdet"></el-table-column>
                <el-table-column label="导入时间" prop="impdat"></el-table-column>
                <el-table-column label="文件名称" prop="filnam"></el-table-column>
            </el-table>
        </el-dialog>
    </div>
</template>
<script>
    import commonProcess from "~/mixin/commonProcess";
    import event from "../event";
    import upload from "../../common/event/upload";

    export default {
        inject: ["root"],
        props: ["model", "codes"],
        mixins: [commonProcess, event, upload],
        data() {
            return {
                multipleSelection: [],
                pagination: {
                    pageNum: 1,
                    pageSize: 10,
                    total: 0
                },
                dbCodes: {
                    actionlabels: [],
                    scutyplabels: [],
                    datsrclabels: [],
                    bpsstalabels: [],
                    bpschklabels: []
                },
            };
        },
        mounted() {
            this.getdbCode("action", "CN", "actionlabels");
            this.getdbCode("scutyp", "CN", "scutyplabels");
            this.getdbCode("datsrc", "CN", "datsrclabels");
            this.getdbCode("bpssta", "CN", "bpsstalabels");
            this.getdbCode("bpschk", "CN", "bpschklabels");
        },

    };
</script>
<style>
  .button-container {
    display: flex;
    align-items: flex-start;
  }

  .upload-button {
    margin-left: 7px;
    margin-right: 7px;
  }
</style>