<template>
  <div class="eibs-tab">

       <c-col :span="24">
          <el-form-item label="待处理交易的类型" prop="" class="checkbox-left">
              <c-checkbox v-model="model.chkinc" disabled>Incoming</c-checkbox>
              <c-checkbox v-model="model.chkrim" >Registered</c-checkbox>
              <c-checkbox v-model="model.chkpen" disabled>Pending</c-checkbox>
              <c-checkbox v-model="model.chkcor" disabled>Correction</c-checkbox>
              <c-checkbox v-model="model.chkaut" disabled>Automatic</c-checkbox>
           </el-form-item>
       </c-col>


       <c-col :span="24">
            <!-------------左边---------------->
            <c-col :span="12" style="padding-right: 20px">
                <c-col :span="24">
                    <el-form-item label="业务编号" prop="selobj">
                        <c-input  v-model="model.selobj" maxlength="32"  placeholder="请输入业务编号"></c-input>
                    </el-form-item>
               </c-col>
                <c-col :span="24">
                    <c-col :span="20">
                        <el-form-item label="用户选择" prop="usfmod.flt">
                            <c-select v-model="model.usfmod.flt" style="width:100%" placeholder="请选择用户选择">
                                  <el-option
                                    v-for="item in codes.flt"
                                    :key="item.value"
                                    :label="item.label"
                                    :value="item.value"
                                  ></el-option>
                              </c-select>
                        </el-form-item>
                   </c-col>
                  <c-col :span="4">
                   <c-button size="small" type="primary"  @click="onUsfmodShwflt">
                       显示
                   </c-button>
                  </c-col>
               </c-col>

               <c-col :span="24">
                <el-form-item label="所选用户" prop="usfmod.usr.extkey" v-if="model.usfmod.flt ==='<SELU>'">
                    <c-input  v-model="model.usfmod.usr.extkey" maxlength="8"  placeholder="请输入所选用户"></c-input>
                </el-form-item>
               </c-col>


               <c-col :span="24">
                <el-form-item label="所选分支" prop="usfmod.selusb" v-if="model.usfmod.flt ==='<SELB>'">
                    <c-select v-model="model.usfmod.selusb" style="width:100%" placeholder="请选择所选分支" :code="codes.selusg">
                      </c-select>
                </el-form-item>
               </c-col>

            </c-col>
             <!-------------右边---------------->
            <c-col :span="12" style="padding-left: 20px">
                   <c-col :span="24">
                        <el-form-item label="交易关键字名称" prop="seltxt">
                            <c-input  v-model="model.seltxt" maxlength="32"  placeholder="请输入交易关键字名称"></c-input>
                        </el-form-item>
                   </c-col>
                <c-col :span="24">
                    <br>
                </c-col>
                  <c-col :span="24" style="text-align: right" >
                   <c-button size="small" type="primary"
                        @click="showGridPromptDialog('negcnt', null, null,{COD: 'cptp.draweecountcode'}, {COD: true},'doxpDialog')"
                   >
                       未分配业务
                   </c-button>
                      <c-button size="small" type="primary"
                           @click="onButreg"
                      >
                          分配获取
                      </c-button>
                  </c-col>

            </c-col>

              <!-------------隐藏---------------->
            <c-col :span="24" v-show="false">
                     <c-col :span="12">
                        <span  v-text="model.usfmod.usftxt"   data-path=".usfmod.usftxt" > </span>
                    </c-col>
                    <c-col :span="12">
                        <span  v-text="model.usfmod.labtxt"   data-path=".usfmod.labtxt" > </span>
                    </c-col>

                    <c-col :span="12">
                     <el-form-item label="Selected User Group Set" prop="usfmod.selusgset">
                         <c-select v-model="model.usfmod.selusgset" style="width:100%" placeholder="请选择Selected User Group Set">
                           </c-select>
                     </el-form-item>
                    </c-col>
                    <c-col :span="12">
                     <el-form-item label="Selected User Group" prop="usfmod.selusg">
                         <c-select v-model="model.usfmod.selusg" style="width:100%" placeholder="请选择Selected User Group">
                           </c-select>
                     </el-form-item>
                    </c-col>
            </c-col>

       </c-col>

        <c-col :span="24">

              <c-istream-table :list="stmData.data" :columns="stmData.columns">
               <el-table-column fixed="right" prop="op" label="操作" width="140px">
                    <template slot-scope="scope">
                        <c-button
                           style="margin-left: 0"
                           size="small"
                           type="primary"
                            @click="getButtons(scope.row)"
                       >
                           详情
                       </c-button>
                       <c-button
                         style="margin-left: 2"
                         size="small"
                         type="primary"
                          @click="getButtons(scope.row)"
                       >
                         处理
                       </c-button>
                   </template>
               </el-table-column>
             </c-istream-table>
           </c-col>
              <el-dialog
                    :visible.sync="initdialog"
                    :title="'操作列表'"
                    append-to-body
                  >
                    <div class="m-list-btns">
                      <div class="busnavbar">
                        <div class="busnavbar-items">
                          <c-button
                            style="margin-left: 7px"
                            size="medium"
                            type="primary"
                            class="medium_bcs"
                            @click.native="onButpan('rettocus')"
                            :disabled=this.flag
                            title="butpan">
                                退回
                            </c-button>
                            <c-button
                              style="margin-left: 7px"
                              size="medium"
                              type="primary"
                              class="medium_bcs"
                              @click.native="onOperate('rou')"
                              :disabled=this.flag
                              title="ReRouting">
                                    ReRouting
                              </c-button>
                            <c-button
                                style="margin-left: 7px"
                                size="medium"
                                type="primary"
                                class="medium_bcs"
                                @click.native="onOperate('Connect11111')"
                                title="Connect"
                                disabled=false >
                                    Connect
                            </c-button>
                                <c-button
                                    style="margin-left: 7px"
                                    size="medium"
                                    type="primary"
                                    class="medium_bcs"
                                    @click.native="onOperate('Infotext11111')"
                                    title="Infotext"
                                    disabled=false >
                                        Infotext
                                </c-button>
                                <c-button
                                    style="margin-left: 7px"
                                    size="medium"
                                    type="primary"
                                    class="medium_bcs"
                                    @click.native="onOperate('inc11111')"
                                    title="Inc"
                                    disabled=false >
                                        Show Inc.
                                </c-button>
                             <!--   <c-button
                                    style="margin-left: 7px"
                                    size="medium"
                                    type="primary"
                                    class="medium_bcs"
                                    @click.native="onShow()"
                                    title="Remove"
                                    :disabled=this.flag >
                                        Remove
                                </c-button>  -->
                                <c-button
                                    style="margin-left: 7px"
                                    size="medium"
                                    type="primary"
                                    class="medium_bcs"
                                    @click.native="onShow()"
                                    title="Show2"
                                    :disabled=this.flag >
                                        Show
                                </c-button>
                                   <c-button
                                        style="margin-left: 7px"
                                        size="medium"
                                        type="primary"
                                        class="medium_bcs"
                                        @click.native="onOperate('Reject111111')"
                                        title="Reject"
                                        disabled=false >
                                            Reject
                                    </c-button>
                        </div>
                      </div>
                    </div>
                  </el-dialog>

            <m-sptp0 ref="childs" :model="model" :codes="codes" @onSptp="onSptpButord"></m-sptp0>
            <m-ordp0 ref="childs2" :model="model" :codes="codes"></m-ordp0>
  </div>
</template>
<script>
import Api from "~/service/Api"
import commonProcess from "~/mixin/commonProcess";
import CodeTable from "~/config/CodeTable"
import Event from "~/model/Sptneg/Event"
import Sptp0 from "./Sptp0"
import Ordp0 from "./Ordp0"


export default {
    inject: ['root'],
    props:["model","codes"],
    mixins: [commonProcess],
     components:{
            "m-sptp0" : Sptp0,
            "m-ordp0" : Ordp0,
        },
    data(){
        return {
             initdialog: false,
             flag:false,
             stmData: {
                columns: [
                  '4 1 "交易代码" 100',
                  '5 2 "业务编号" 150',
                  '6 3 "Name" 150',
                  {index:7,position:5,width:200,pattern:'time',label:'创建时间'},
                  {index:1,position:6,width:120,pattern:'code',label:'交易状态',code:'sptrelstatus'},
                  '8 7 "经办柜员" 100',
                  '14 8 "工作用户" 120',
                  '3 9 "信息" 100',
                  '10 10 "信息文本" 500',
                ],
                data: [],
              },
        }
    },
    watch:{
       "model.chkrim":function(){
          this.executeDefault("sptstm").then((res) => {
               if ((res.respCode == SUCCESS)) {
                  this.stmData.data = res.data.sptstm.rows;
                  this.model.sptstm = res.data.sptstm;
               }
             });
       }
    },
    methods:{...Event,
        onButreg(){
           this.executeRule("butreg").then((res) => {
                   if ((res.respCode == SUCCESS)) {
                      this.stmData.data = res.data.sptstm.rows;
                      this.model.sptstm = res.data.sptstm;
                   }
                 });
        },
        async getButtons(row){
                   let status = row['交易状态'];
                   this.index=row['IDX'];
                   this.initdialog = true
                   let index2 = row['IDX']+1;
                   const selIds = [index2]; //rowno选中行
                   const selDst = "sptstm" //列表对应后台模型中的stream
                   let params = { selDst: selDst, selIds: selIds };
                   this.executeRule("sptstm",params).then((res) => {
                      if ((res.respCode == SUCCESS)) {

                      }
                    });
         },

        //各入口按钮请求
        async onOperate(vul){
            let index = this.index+1;
            const selIds = [index]; //rowno选中行
            const selDst = "sptstm" //列表对应后台模型中的stream
            let params = { selDst: selDst, selIds: selIds };
            let rtnmsg = await this.executeRule(vul,params);
            if (rtnmsg.respCode == SUCCESS) {
              this.initdialog = false
               this.stmData.data = rtnmsg.data.sptstm.rows;
               this.model.sptstm = rtnmsg.data.sptstm;
             } else {
              this.initdialog = false
             }
        },
        onButpan(){
              this.$confirm('确定要返回所选项目吗?','提示',{
                  confirmButtonText: '是',
                  cancelButtonText: '否',
                  type: 'warning',
                  showClose:false
                }).then(async () => {//yes的执行在这里写
                         let index = this.index+1;
                         const selIds = [index]; //rowno选中行
                         const selDst = "sptstm" //列表对应后台模型中的stream
                         let params = { selDst: selDst, selIds: selIds };
                         let rtnmsg = await this.executeRule('rettocus',params);
                         if (rtnmsg.respCode == SUCCESS) {
                            this.initdialog = false
                            this.stmData.data = rtnmsg.data.sptstm.rows;
                            this.model.sptstm = rtnmsg.data.sptstm;
                          } else {
                             this.initdialog = false
                          }

                }).catch(() => {//No的功能在这里写

                });

        },
       async onShow(row){
           this.initdialog = false
           this.$refs.childs.initdialog2 = true
       },
       async onSptpButord(){
         this.$refs.childs2.initdialog3 = true
       }
    },
    created:function(){

    }
}
</script>
<style>

</style>