<template>
  <c-page title="经办夹">
    <el-form :model="model" :rules="rules" ref="modelForm" label-width="100px" size="mini">
         <el-col :span="12">
        <el-form-item label="交易名" prop="sptp.frm">
            <el-input  v-model="model.sptp.frm" maxlength="6"  placeholder="请输入交易"></el-input>
        </el-form-item>
       </el-col>             
 
	<!--
        <el-col :span="12">
        <el-form-item label="对象类型">
            <el-input  v-model="model.sptp.objtyp" maxlength="6"  placeholder="请输入对象类型"></el-input>
        </el-form-item>
       </el-col>             
 
	-->
        <el-col :span="12">
        <el-form-item label="业务编号" prop="sptp.objref">
            <el-input  v-model="model.sptp.objref" maxlength="20"  placeholder="请输入业务编号"></el-input>
        </el-form-item>
       </el-col>  
        <el-col :span="12">
        <el-form-item label="经办柜员" prop="sptp.usr">
            <el-input  v-model="model.sptp.usr" maxlength="20"  placeholder="请输入操作员"></el-input>
        </el-form-item>
       </el-col>             
 
	
        <el-col :span="12">
        <el-form-item label="状态" prop="sptp.sta">
            <el-select v-model="model.sptp.sta" style="width:100%" placeholder="请选择类型">
                <el-option
                  v-for="item in codes.sptsta"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value">
                </el-option>
              </el-select>
        </el-form-item>
       </el-col>
 
	
        <el-col :span="12">
            <el-col :span="12">
                <el-form-item label="起始日期" prop="sptp.datsta">
                    <el-date-picker type="date"  v-model="model.sptp.datsta" style="width:100%"  placeholder="请选择起始日期"></el-date-picker>
                </el-form-item>
            </el-col>
        
            <el-col :span="12">
                <el-form-item label="至" prop="sptp.datend">
                    <el-date-picker type="date"  v-model="model.sptp.datend" style="width:100%"  placeholder="请选择至"></el-date-picker>
                </el-form-item>
            </el-col>
        </el-col>
 
	
 
	
                  
        <el-col :span="24" style="text-align:right;">
            <el-button size="small" type="primary" icon="el-icon-search" @click="onSel">
                查询
            </el-button>
            <el-button size="small" type="primary"  @click="onReset">
                重置
            </el-button>
       </el-col>
                
        <el-col :span=24>
            <el-pagination
                 layout="prev, pager, next"
                 :total="pager.sptp_lst.total">
              </el-pagination>
            <el-table
                :data="model.sptp.lst"
                style="width: 100%;height:400px;"
                size="mini"
                max-height="400"
                >
                <el-table-column
                  prop="frm"
                  label="交易名"
                  sortable
                  width="100">
                </el-table-column>
                <el-table-column
                  prop="credattim"
                  label="创建时间"
                  sortable
                  width="100">
                  <template slot-scope="scope">
                      {{dateFormat(scope.row.credattim)}}
                  </template>
                </el-table-column>
                <el-table-column
                  prop="objtyp"
                  label="对象类型"
                  sortable
                  width="100">
                </el-table-column>
                <el-table-column
                  prop="objnam"
                  label="关联名称"
                  sortable
                  width="100">
                </el-table-column>
                <el-table-column
                  prop="objref"
                  label="参考号"
                  sortable
                  width="150">
                </el-table-column>
                <el-table-column
                  prop="sta"
                  label="状态"
                  sortable
                  width="100">
                  <template slot-scope="scope">
                    <span>{{ findCodeLabel(codes.sptsta,scope.row.sta) }}</span>
                  </template>
                </el-table-column>
                <el-table-column
                  prop="creusr"
                  label="经办柜员"
                  sortable
                  width="100">
                </el-table-column>
                <el-table-column
                  prop="relcur"
                  label="币种"
                  sortable
                  width="100">
                </el-table-column>
                <el-table-column
                  prop="relamt"
                  label="金额"
                  sortable
                  width="100">
                </el-table-column>
                <el-table-column
                  prop="ownbchkey"
                  label="所属机构"
                  sortable
                  width="100">
                </el-table-column>
                <el-table-column
                  prop="op"
                  fixed="right"
                  label="操作"
                  width="150">
                  <template slot-scope="scope">
                      <div>
                        <div v-if="scope.row.frm">
                                <el-link icon="el-icon-edit" type="primary" @click="onDeal(scope.row)">处理</el-link>
                                <el-divider direction="vertical"></el-divider>
                                <el-link icon="el-icon-delete" type="primary" @click="onSptpDel(scope.row)">删除</el-link>
                                <span v-if="scope.row.smhinr">
                                    <el-divider direction="vertical"></el-divider>
                                    <el-link icon="el-icon-view" type="primary" @click="onInc(scope.row)">显示报文</el-link>
                                </span>

                        </div>
                        <div v-if="!scope.row.frm">
                                <el-link icon="el-icon-delete" type="primary" @click="onSptpDel(scope.row)">删除</el-link>
                                <span v-if="scope.row.smhinr">
                                    <el-divider direction="vertical"></el-divider>
                                    <el-link icon="el-icon-view" type="primary"  @click="onInc(scope.row)">显示报文</el-link>
                                </span>
                        </div>
                      </div>
                  </template>
                </el-table-column>
              </el-table>
              
       
       </el-col>
    </el-form>
  </c-page>
</template>
<script>
import Api from "~/service/Api"
import CodeTable from "~/config/CodeTable"
import Utils from "~/utils"

export default {
    data(){
        return {
                  codes:{
                        dsp:CodeTable.dsp,
                        busflg:CodeTable.busflg,
                        actiontype:CodeTable.actiontype,
                        cur:CodeTable.cur,
                        ptytyp:CodeTable.ptytyp,
                        staflg:CodeTable.staflg,
                        paytyp:CodeTable.paytyp,
                        payattr:CodeTable.payattr,
                        balancemode:CodeTable.balancemode,
                        bopcustype:CodeTable.bopcustype,
                        payeeattr:CodeTable.payeeattr,
                        boppaytype:CodeTable.boppaytype,
                        debcdtflg:CodeTable.debcdtflg,
                        acttyp:CodeTable.acttyp,
                        payflg:CodeTable.payflg,
                        sptsta:CodeTable.sptsta,
                        buscod:CodeTable.buscod,
                        datsrc:CodeTable.datsrc,
                        sndselflg:CodeTable.sndselflg,
                        relflg:CodeTable.relflg,
                        payacttyp:CodeTable.payacttyp,
                        curtxt:CodeTable.curtxt,
                        dbfmethod:CodeTable.dbfmethod,
                        bustyp:CodeTable.bustyp,
                        todo:CodeTable.todo,
                        swftyp:CodeTable.swftyp,
                        payeraccttype:CodeTable.payeraccttype,
                        oratyp:CodeTable.oratyp,
                        chato:CodeTable.chato,
                        opertype:CodeTable.opertype,
                        bopyesno:CodeTable.bopyesno,
                        custyp:CodeTable.custyp,
                        selten:CodeTable.selten,
                        dsp2:CodeTable.dsp2,
                        liqtyp:CodeTable.liqtyp,
                   },
                  model:{
						sptp:{
							frm:"",			//  交易		.sptp.frm
							objtyp:"",			//  对象类型		.sptp.objtyp
							usr:"",			//  操作员		.sptp.usr
							sta:"",			//  类型		.sptp.sta
							datsta:"",			//  起始日期		.sptp.datsta
							datend:"",			//  至		.sptp.datend
							objref:"",			//  业务编号		.sptp.objref
							lst:[],			//  		.sptp.lst
						},
						mtabut:{
							cortyp:"",			//  NewField		.mtabut.cortyp
							msgtyp:"",			//  Message Type Optional		.mtabut.msgtyp
							docinf:"",			//  报文信息		.mtabut.docinf
						},
				},
                  pager:{
                       "sptp_lst":{total:0,curIdx:0},
                    },
                  rules:{
                       "sptp.frm":[{type: "string", required: false, max:6,min: 1, message: "输入不合法"}],
                       "sptp.objtyp":[{type: "string", required: false, max:6,min: 1, message: "输入不合法"}],
                       "sptp.usr":[{type: "string", required: false, max:20,min: 0, message: "输入不合法"}],
                       //"sptp.datsta":[{type: "date", required: false, message: "输入正确的日期"}],
                       //"sptp.datend":[{type: "date", required: false, message: "输入正确的日期"}],
                       "sptp.objref":[{type: "string", required: false, max:20,min: 1, message: "输入不合法"}],
                       "mtabut.cortyp":[{type: "string", required: false, len: 3, message: "输入不合法"}],
                       "mtabut.msgtyp":[{type: "string", required: false, max:100,min: 1, message: "输入不合法"}],
                       "mtabut.docinf":[{type: "string", required: true, max:200,min: 1, message: "输入超长"}],
                    }
        }
    },
    methods:{
            onSel(){
                this.$refs.modelForm.validate(async valid => {
                    if(!valid)
                        return;
                    let rtnmsg = await Api.post("sptsel/sel",{data:Utils.flatObject(this.model)})
                    if(rtnmsg.code == SUCCESS)
                    {
                        //TODO 处理数据逻辑
                        //this.
                        //this.model.sptp.lst = rtnmsg.data.sptp_lst
                        Utils.copyValueFromVO(this.model,rtnmsg.data)
                    }
                    else
                    {
                       this.$notify.error({title: '错误',message: '服务请求失败！'});
                    }
                })
            },
            onReset(){
                this.$refs.modelForm.resetFields()
            },
            onSptpDel(row){
                this.$refs.modelForm.validate(async valid => {
                    if(!valid)
                        return;
                    let rtnmsg = await Api.post("sptsel/sptp_del",{data:this.model})
                    if(rtnmsg.code == SUCCESS)
                    {
                        //TODO 处理数据逻辑

                    }
                    else
                    {
                       this.$notify.error({title: '错误',message: '服务请求失败！'});
                    }
                })
            },
            onInc(row){
                this.$refs.modelForm.validate(async valid => {
                    if(!valid)
                        return;
                    let rtnmsg = await Api.post("sptsel/inc",{data:this.model})
                    if(rtnmsg.code == SUCCESS)
                    {
                        //TODO 处理数据逻辑

                    }
                    else
                    {
                       this.$notify.error({title: '错误',message: '服务请求失败！'});
                    }
                })
            },
    },
    created:async function(){
        console.log("进入sptsel交易");
        let rtnmsg = await Api.post("sptsel/init",{params:{}})
        if(rtnmsg.code == SUCCESS)
        {
           //TODO 处理数据逻辑

        }
        else
        {
            this.$notify.error({title: '错误',message: '服务请求失败！'});
        }
    }
}
</script>
<style>

</style>
