BusNavbar.vue 3.32 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
<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 navcode"
        v-bind:key="index"
        @click.native="onNarBtnClick(item.code, item.index)"
        :title="item.title"
        :disabled="item.isDis === 'N'"
        >{{ item.label }}</c-button
      >
    </div>
  </div>
</template>
<script>
import Api from "~/service/Api";
import commonProcess from "~/mixin/commonProcess";

export default {
liuxin committed
24 25 26 27 28 29 30 31 32 33 34 35 36
  props: {
    "ownref": {
        required: true,
    }, 
    "trnCode": {
        required: true,
    }, 
    "model": {
        required: true,
    }, 
    "ownrefPath": {
        required: false,
        default: "didgrp"
37 38 39 40 41
    },
    "tabIndex": {
        required: false,
        default: 1
    },
liuxin committed
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
  components: {},
  mixins: [commonProcess], // 里面包含了Default、Check等的公共处理
  data() {
    return {
      navcode: [
        // {code:"",label:"",isDis:"",title:""},
      ],
    };
  },
  methods: {
    //各入口按钮请求
    async onNarBtnClick(code, i) {
      this.model.cfgfil[`subtrn${i}`] = code;
      let rtnmsg = await this.executeRule(`cfgfil.hotsub${i}`);
      if (rtnmsg.respCode == SUCCESS) {
        this.navcode = [];
        this.$emit("onChoose", code.toLowerCase());
      } else {
        this.$notify.error({ title: "错误", message: "服务请求失败!" });
      }
    },
    getIndex(module) {
      for (let i = 1; i <= 12; i++) {
        var temp = this.model.cfgfil[`subtxt${i}`];
        if (module == temp) {
          return i;
        }
      }
      return 0;
    },
  },
  mounted() {
liuxin committed
75
    this.trnName = this.trnCode
76 77
    this.$nextTick(function () {
      this.$on("childmethods", async function () {
78 79 80 81 82 83 84 85 86 87 88

        let res = await this.executeRule(`cfgfil.hotreg${this.tabIndex}`);
        if (res.respCode == SUCCESS) {
            this.updateModel(res.data);
        } else {
            this.$notify.error({
                title: "错误",
                message: "服务请求失败!",
            });
        }

89 90
        this.navcode = [];
        //请求按钮数据
liuxin committed
91 92
        this.model[this.ownrefPath].rec.ownref = this.ownref;
        let rtnmsg = await this.executeRule(this.ownrefPath+".rec.ownref"); //didgrp_rec_ownref
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107
        if (rtnmsg.respCode == SUCCESS) {
          //重置数组
          this.navcode = [];
          this.updateModel(rtnmsg.data);
          //this.model.cfgfil.btnstm = rtnmsg.data.cfgfil_btnstm.rows
          //给inr赋值,后面弹窗里面的按钮请求会用到
          //this.model.didgrp.rec.inr = rtnmsg.data.didgrp_rec_inr
          const length = this.model.cfgfil.btnstm.rows.length;
          let btnStr = this.model.cfgfil.btnstm.rows;
          for (let i = 0; i < length; i++) {
            let arr = btnStr[i].split("\t");
            var index = this.getIndex(arr[1]);
            let newList = {
              code: arr[0],
              label: arr[1],
108
              isDis: arr[2],
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124
              title: arr[3],
              index: index,
            };
            this.navcode.push(newList);
          }
        } else {
          this.navcode = [];
          this.$notify.error({ title: "错误", message: "服务请求失败!" });
        }
      });
    });
  },
};
</script>
<style>
</style>