assign.vue 2.02 KB
<template>
  <div class="">
    <el-tabs v-model="activeTabs">
      <el-tab-pane label="选择数据" name="1">
        <select-info ref="selectInfoCom" :id="id" :key="id"></select-info>
      </el-tab-pane>
      <el-tab-pane label="导入数据" name="2">
        <import-vehicle ref="importVehicleCom" :id="id" :key="id" @monitorFlag="monitorFlag" @monitorChangeFlag="monitorChangeFlag"></import-vehicle>
      </el-tab-pane>
      <el-tab-pane label="按组织授权" name="3">
        <authorization-info ref="authorizationInfoCom" :id="id" :key="id"></authorization-info>
      </el-tab-pane>
    </el-tabs>
  </div>
</template>
<script>
import SelectInfo from "./select.vue";
import ImportVehicle from "./import.vue";
import AuthorizationInfo from "./authorization";
export default {
  name: "AssignInfo",
  components: {
    SelectInfo,
    ImportVehicle,
    AuthorizationInfo,
  },
  props: {
    id: {
      type: [String, Number],
      default: "",
    },
  },
  data() {
    return {
      activeTabs: "1",
      userId: "",
      randomKey: "",
      monitorFlags: false,
      showBtnFlag: true
    };
  },
  watch: {
    id: {
      handler: function () {
        console.log("key:", Math.random());
        this.randomKey = Math.random();
      },
    },
  },
  mounted() {
    this.userId = this.id;
  },
  methods: {
    // 保存数据
    saveInfo() {
      let _id = this.activeTabs;
      if (_id == 1) {
        this.$refs.selectInfoCom.saveInfo();
        return false;
      }

      if (_id == 3) {
        this.$refs.authorizationInfoCom.saveInfo();
        return false;
      }
      this.$refs.importVehicleCom.saveInfo();
    },
    monitorFlag(val) {
      this.monitorFlags = val
    },
    monitorChangeFlag(val) {
       if (val && !this.monitorFlags) {
         this.showBtnFlag = true
       }
       if (this.monitorFlags) {
         this.showBtnFlag = false
         this.monitorFlags = !this.monitorFlags
       }
       this.$emit('showBtnFlags', this.showBtnFlag)
    }
  },
};
</script>
<style lang="scss" scoped>
</style>