BusNavbar.vue 5.93 KB
Newer Older
niewei committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147
<template>
  <div class="busnavbar">
     <div class="busnavbar-items">
          <c-button style="margin-left:7px;" size="medium" type="primary" class="medium_bcs" v-for="(item,index)  in codeList" v-bind:key="index" @click.native="onNarBtnClick(item.code,index)"   :title="item.title" :disabled="item.isDis==='N'">{{item.label}}</c-button>
     </div>
  </div>
</template>
<script>
import Api from "~/service/Api"
import CodeTable from "~/config/CodeTable"
import Letsel from "~/model/Detsel"
import commonProcess from "~/mixin/commonProcess"


export default { 
    props:["ownref"],
    components:{
        
    },
    mixins: [commonProcess],    // 里面包含了Default、Check等的公共处理
    data(){
        return {
            trnName:'detsel',
            model:new Letsel().data,
            navcode:[
               // {code:"",label:"",isDis:"",title:""},            
            ],
        }
    },
    methods:{
         //各入口按钮请求
     async  onNarBtnClick(code,i){
            this.model.cfgfil.subtrn1= code  
            let rtnmsg = await this.executeRule("cfgfil.hotsub3")
            console.log("cfgfil.code:" +  this.model.cfgfil.subtrn1);
            if(rtnmsg.respCode == SUCCESS){
               this.navcode = []
               this.$emit("onChoose",code.toLowerCase());
            }else{
               this.$notify.error({ title: "错误", message: "服务请求失败!" });
            }
            
        },
    
     },
    computed:{
         codeList(){
              //将model中的数据映射成数组
              return this.navcode.map(item=>{
                  let entireItem = {...item}
                  this.navcode = [];
                  //TODO 根据数据判断当前的code,是否可以继续
               //    entireItem.enable = item.isDis
                  return entireItem
              })
         }
     },
     watch:{
        "ownref":async function(n, o){
            if(!this.ownref){
                 console.log("11111")
               //   onTigger()
                 return;
            }
        }
    },
    
    mounted(){
         this.$nextTick(function(){
              this.$on('childmethods',async function(){
                   this.navcode = []
                  //请求按钮数据
                  this.model.bfdgrp.rec.ownref = this.ownref  
                  console.log("ownref:" + this.ownref  );
                  
                    let rtnmsg0 = await this.executeRule("bfdgrp.rec.ownref");//bfdgrp_rec_ownref
                    if(rtnmsg0.respCode == SUCCESS){
                          this.updateModel(rtnmsg0.data)
                          let rtnmsg = await this.executeRule("cfgfil.hotreg3");//cfgfil.hotreg3
                          if(rtnmsg.respCode == SUCCESS){  
                              //重置数组
                              this.navcode = []
                              this.updateModel(rtnmsg.data)
                              //this.model.cfgfil.btnstm = rtnmsg.data.cfgfil_btnstm.rows
                              //给inr赋值,后面弹窗里面的按钮请求会用到
                              //this.model.bfdgrp.rec.inr = rtnmsg.data.bfdgrp_rec_inr
                              console.log("ownref:" + this.ownref  );
                              const length = this.model.cfgfil.btnstm.rows.length
                              let btnStr = this.model.cfgfil.btnstm.rows
                              //let j = 0;
                              //let m = 0;
                              //const buttonIndex = ['国内证通知','国内证修改通知','收单']
                              for(let i=0;  i < length; i++){
                              //获取数组中每行的数据
                                   let arr = btnStr[i].split("\t");                        
                                   let newList = {
                                        code:arr[0],
                                        label:arr[1],
                                        isDis:arr[2],
                                        //isDis:'Y',
                                        title:arr[3]                       
                                   }
                                      //添加到navcode数组中
                                      this.navcode.splice(i,0,newList)
                                   /*
                                   if(!( btnStr[i].indexOf("保证金") >= 0) && !(btnStr[i].indexOf("开立信用证") >= 0)){
                                        let arr = btnStr[i].split("\t");
                                        let newList = {
                                        code:arr[0],
                                        label:arr[1],
                                        isDis:arr[2],
                                        title:arr[3]                       
                                      }
                                      m++;
                                      j = buttonIndex.indexOf(arr[1].replace(/(^\s*)|(\s*$)/g, ""));
                                      if(j<0){
                                           j = m;
                                      }
                                      //添加到navcode数组中
                                      this.navcode.splice(j,0,newList)
                                   }
                                   */
                                   
                               }

                        
                         }else{
                              this.navcode = [] 
                              this.$notify.error({ title: "错误", message: "服务请求失败!" });
                         }
                        
                    }
                    else{
                              this.navcode = [] 
                              this.$notify.error({ title: "错误", message: "服务请求失败!" });
                         }
              })
              })
         }
    

}
</script>
<style>


</style>