<template>
  <c-page title="业务详情">
    <el-form :model="model" :rules="rules" ref="modelForm" label-width="100px" size="small">
       

        <c-col :span="12">
        <el-form-item label="业务参考号">
            <c-input  v-model="model.trn.ownref" maxlength="16" :readonly="true"  placeholder="请输入业务参考号"></c-input>
        </el-form-item>
       </c-col>             
	
        <c-col :span="12">
        <el-form-item label="索引">
            <c-input  v-model="model.trn.inr" maxlength="8"  :readonly="true" placeholder="请输入索引"></c-input>
        </el-form-item>
       </c-col>             
        <c-col :span="12">
        <el-form-item label="交易描述">
            <c-input  v-model="model.trn.objnam" maxlength="40" :readonly="true" placeholder="请输入交易描述"></c-input>
        </el-form-item>
       </c-col>             
 
        <c-col :span="12">
        <el-form-item label="交易编码">
            <c-input  v-model="model.trn.inifrm" maxlength="6" :readonly="true" placeholder="请输入交易编码"></c-input>
        </el-form-item>
       </c-col>             
	
        <c-col :span="12">
        <el-form-item label="业务币种金额">
            <c-select v-model="model.trn.reloricur" style="width:100%" :disabled="true" placeholder="请选择业务币种金额">
                <el-option
                  v-for="item in codes.curtxt"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value">
                </el-option>
              </c-select>
        </el-form-item>
       </c-col>
        <c-col :span="12">
        <el-form-item label="换算金额">
            <c-input  v-model="model.trn.reloriamt" :readonly="true"  placeholder="请输入换算金额"></c-input>
        </el-form-item>
       </c-col>                 
 
	
        <c-col :span="12">
        <el-form-item label="交易状态">
            <c-select v-model="model.trn.relflg" style="width:100%" :disabled="true" placeholder="请选择交易状态">
                <el-option
                  v-for="item in codes.relflg"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value">
                </el-option>
              </c-select>
        </el-form-item>
       </c-col>
 
	
        <c-col :span="12">
        <el-form-item label="经办柜员">
            <c-input  v-model="model.trn.usr" maxlength="8" :readonly="true" placeholder="请输入经办柜员"></c-input>
        </el-form-item>
       </c-col>             
 
	
        <c-col :span="12">
        <el-form-item label="用户组">
            <c-input  v-model="model.trn.usg" maxlength="6" :readonly="true"  placeholder="请输入用户组"></c-input>
        </el-form-item>
       </c-col>             
	
        <c-col :span="12">
        <el-form-item label="前手流水号">
            <c-input  v-model="model.trn.cortrninr" maxlength="8" :readonly="true" placeholder="请输入前手流水号"></c-input>
        </el-form-item>
       </c-col>             
 
	
        <c-col :span="12">
        <el-form-item label="执行日期">
            <c-date-picker type="date"  v-model="model.trn.exedat" style="width:100%" :readonly="true" placeholder="请选择执行日期"></c-date-picker>
        </el-form-item>
       </c-col>
 
	
        <c-col :span="12">
        <el-form-item label="提交柜员">
            <c-input  v-model="model.recpan.cretrs.usr" maxlength="8" :readonly="true" placeholder="请输入提交柜员"></c-input>
        </el-form-item>
       </c-col>             
 
	
        <c-col :span="12">
        <el-form-item label="提交时间">
            <c-input  :value="dateFormat(model.recpan.cretrs.dattim,'yyyy/MM/dd hh:mm:ss')"   :readonly="true" placeholder="请输入提交时间"></c-input>
        </el-form-item>
       </c-col>             
 
        <c-col :span="22" :offset="1">
            <p>面函报文</p>
            <c-table
                :data="model.recpan.smhlst"
                style="width: 100%"
                >
                <el-table-column
                  prop="cortyp"
                  label="传送方式"
                  sortable
                  >
                </el-table-column>
                <el-table-column
                  prop="extkey"
                  label="面函/报文"
                  sortable
                  >
                </el-table-column>
                <el-table-column
                  prop="nam"
                  label="面函/报文名称"
                  sortable
                  >
                </el-table-column>
                <el-table-column
                    prop="op"
                    label="操作"
                >
                    <template slot-scope="scope">
                    <m-pager :path="scope.row.docpth" />
                    </template>
                </el-table-column>
              </c-table>
       </c-col>
        <!-- <c-col :span="12">
        <c-button size="small" type="primary"  @click="onRecpanIncall">
            Show all inc
        </c-button>
       </c-col>
        <c-col :span="12">
        <c-button size="small" type="primary"  @click="onRecpanButord">
            订单信息
        </c-button>
       </c-col>
        <c-col :span="12">
        <c-button size="small" type="primary"  @click="onRecpanButspt">
            Pending item
        </c-button>
       </c-col> -->
 
	
        
       
 
	
        <!-- <c-col :span="12">
        <el-form-item label="报文信息">
            <c-input type="textarea" v-model="model.recpan.docinf" maxlength="200" show-word-limit placeholder="请输入报文信息" ></c-input>
        </el-form-item>
        </c-col> -->
 
	
        <c-col :span="22" :offset="1">
            <p>工作服务流程</p>
            <c-table
                :data="model.recpan.wfelst"
                style="width: 100%"
                >
               
                <el-table-column
                  prop="srvsub"
                  label="服务码"
                  sortable
                  >
                </el-table-column>
                <el-table-column
                  prop="srvnam"
                  label="服务名"
                  sortable
                  >
                </el-table-column>
                <el-table-column
                  prop="sta"
                  label="状态"
                  sortable
                  >
                  <template slot-scope="scope">
                    <span>{{ findCodeLabel(codes.oratyp,scope.row.typ) }}</span>
                  </template>
                </el-table-column>
                
                <el-table-column
                  prop="rtycnt"
                  label="重调次数"
                  sortable
                  >
                </el-table-column>
                <el-table-column
                  prop="lev"
                  label="优先级"
                  sortable
                  >
                </el-table-column>
                <el-table-column
                  prop="txt"
                  label="返回信息"
                  sortable
                  >
                </el-table-column>
              </c-table>
              
       </c-col>
        <c-col :span="22" :offset="1">
            <p>签字列表</p>
            <c-table
                :data="model.recpan.trslst"
                style="width: 100%"
                >
                <el-table-column
                  prop="sigidx"
                  label="签名顺序"
                  sortable
                  >
                </el-table-column>
                <el-table-column
                  prop="usr"
                  label="柜员"
                  sortable
                  >
                </el-table-column>
                <el-table-column
                  prop="dattim"
                  label="日期/时间"
                  sortable
                  >
                  <template slot-scope="scope">
                  {{dateFormat(scope.row.dattim)}}
                  </template>
                </el-table-column>
                <el-table-column
                  prop="flg"
                  label="操作"
                  sortable
                  >
                  <template slot-scope="scope">
                    <span>{{ findCodeLabel(codes.oratyp,scope.row.typ) }}</span>
                  </template>
                </el-table-column>
              </c-table>
       </c-col>
       <c-col :span="22" :offset="1" style="margin:2em 0">
        <el-form-item label="操作意见">
            <c-input type="textarea" v-model="model.trn.inftxt" maxlength="65"  show-word-limit placeholder="请输入意见" ></c-input>
        </el-form-item>
        </c-col>
       <c-col :span="22" :offset="1" style="text-align:center">
            <c-button size="small" type="primary"  @click="onDsp">
                明细
            </c-button>
            <c-button size="small" type="primary"  @click="onRelrow">
                复核
            </c-button>
            <c-button size="small" type="primary"  @click="onReprow">
                退回更正
            </c-button>
            <c-button size="small" type="primary"  @click="onExi">
                退出
            </c-button>
        </c-col>
    </el-form>
     
  </c-page>
</template>
<script>
import Api from "~/service/Api"
import CodeTable from "~/config/CodeTable"
import Utils from "~/utils"
import PaperShow from "./PaperShow"

export default {
    components:{
        "m-pager":PaperShow
    },
    computed: {

    },
    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,
                        flg:CodeTable.flg,
                        sta:CodeTable.sta,
                        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:{
						trncorco:{
							inidatfro:"",			//  查询区间		.trncorco.inidatfro
							inidattil:"",			//  Date of entry of Transaction until		.trncorco.inidattil
							ownref:"",			//  业务编号		.trncorco.ownref
							relflg:"",			//  复核状态		.trncorco.relflg
							iniusr:"",			//  Userid entering the Transaction		.trncorco.iniusr
						},
						atp:{
							cod:"",			//  Transaction  ID		.atp.cod
						},
						atptxt:"",			//  交易名		.atptxt
						recpan:{
							trnlst:[],			//  		.recpan.trnlst
							cretrs:{
								usr:"",			//  提交柜员		.recpan.cretrs.usr
								dattim:"",			//  提交时间		.recpan.cretrs.dattim
							},
							smhlst:[],			//  		.recpan.smhlst
							trslst:[],			//  		.recpan.trslst
							wfelst:[],			//  		.recpan.wfelst
							docinf:"",			//  报文信息		.recpan.docinf
						},
						trn:{
							ownref:"",			//  业务参考号		.trn.ownref
							inr:"",			//  索引		.trn.inr
							objnam:"",			//  交易描述		.trn.objnam
							reloricur:"",			//  业务币种金额		.trn.reloricur
							reloriamt:"",			//  换算金额		.trn.reloriamt
							relflg:"",			//  交易状态		.trn.relflg
							usr:"",			//  经办柜员		.trn.usr
							usg:"",			//  用户组		.trn.usg
							cortrninr:"",			//  前手流水号		.trn.cortrninr
							exedat:"",			//  执行日期		.trn.exedat
							inftxt:"",			//  意见		.trn.inftxt
							inifrm:"",			//  交易编码		.trn.inifrm
						},
				},
                  pager:{
                       "recpan_trnlst":{total:0,curIdx:0},
                       "recpan_smhlst":{total:0,curIdx:0},
                       "recpan_trslst":{total:0,curIdx:0},
                       "recpan_wfelst":{total:0,curIdx:0},
                    },
                  rules:{
                       "trncorco.iniusr":[{type: "string", required: false, len: 8, message: "输入不合法"}],
                       "trncorco.ownref":[{type: "string", required: false, len: 16, message: "输入不合法"}],
                       "atp.cod":[{type: "string", required: false, len: 6, message: "输入不合法"}],
                       "atptxt":[{type: "string", required: false, len: 37, message: "输入不合法"}],
                       "trncorco.inidatfro":[{type: "date", required: false, message: "输入正确的日期"}],
                       "trncorco.inidattil":[{type: "date", required: false, message: "输入正确的日期"}],
                       "trn.ownref":[{type: "string", required: false, len: 16, message: "输入不合法"}],
                       "trn.inr":[{type: "string", required: false, len: 8, message: "输入不合法"}],
                       "trn.objnam":[{type: "string", required: false, len: 40, message: "输入不合法"}],
                       "trn.inifrm":[{type: "string", required: false, len: 6, message: "输入不合法"}],
                       "trn.reloriamt":[{type: "number", required: false, message: "输入不合法"}],
                       "trn.usr":[{type: "string", required: false, len: 8, message: "输入不合法"}],
                       "trn.usg":[{type: "string", required: false, len: 6, message: "输入不合法"}],
                       "trn.cortrninr":[{type: "string", required: false, len: 8, message: "输入不合法"}],
                       "trn.exedat":[{type: "date", required: false, message: "输入正确的日期"}],
                       "recpan.cretrs.usr":[{type: "string", required: false, len: 8, message: "输入不合法"}],
                       "recpan.cretrs.dattim":[{type: "string", required: false, len: 8, message: "输入不合法"}],
                       "trn.inftxt":[{type: "string", required: true, len: 65, message: "输入超长"}],
                       "recpan.docinf":[{type: "string", required: true, len: 200, message: "输入超长"}],
                    }
        }
    },
    methods:{
            onDsp(){
                this.$refs.modelForm.validate(async valid => {
                    if(!valid)
                        return;
                    let rtnmsg = await Api.post("trnrel/dsp",{data:this.model})
                    if(rtnmsg.code == SUCCESS)
                    {
                        //TODO 处理数据逻辑
                                              
                    }
                    else
                    {
                       this.$notify.error({title: '错误',message: '服务请求失败!'});
                    }
                })
            },
            onRelrow(){
              alert(this.$route.query.ownref);
                this.$refs.modelForm.validate(async valid => {
                    if(!valid)
                        return;
                    let rtnmsg = await Api.post("trnrel/relrow",{data:this.model})
                    if(rtnmsg.code == SUCCESS)
                    {
                        //TODO 处理数据逻辑

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

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

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

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

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

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

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

                    }
                    else
                    {
                       this.$notify.error({title: '错误',message: '服务请求失败!'});
                    }
                })
            },
    },
    mounted:async function(){
        console.log("进入trndtl交易");
        console.log("param:"+this.$route.query.ownref);
        var trninr = this.$route.query.inr
        let rtnmsg = await Api.post("trnrel/init",{params:{trninr}})
        if(rtnmsg.code == SUCCESS)
        {
           //TODO 处理数据逻辑
            // this.model.recpan.trn=rtnmsg.data
            Utils.copyValueFromVO(this.model,rtnmsg.data)
        }
        else
        {
            this.$notify.error({title: '错误',message: '服务请求失败!'});
        }
    }
}
</script>