DsMain.vue 4.18 KB
Newer Older
Tippi.Rao 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 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182
<template>
  <div
    v-loading="$store.getters.loadingMap[$store.getters.currentPath]"
    class="de-ds-container"
    :class="[{ 'is-driver-mgm': currentMgm === 'driverMgm' }]"
  >
    <div
      v-if="currentMgm === 'driverMgm'"
      class="dsr-route-title"
    >
      <div>
        <i
          class="el-icon-arrow-left back-button"
          @click="jump"
        />
        <span>{{ $t('driver.mgm') }}</span>
      </div>
      <deBtn
        type="primary"
        icon="el-icon-plus"
        @click="addDriver"
      >{{ $t("driver.add") }}
      </deBtn>
    </div>
    <de-aside-container
      style="padding: 0 0"
      type="datasource"
    >
      <ds-tree
        ref="dsTree"
        :datasource="datasource"
        @switch-mgm="switchMgm"
        @switch-main="switchMain"
      />
    </de-aside-container>
    <de-main-container>
      <component
        :is="component"
        v-if="!!component"
        :params="param"
        :t-data="tData"
        :ds-types="dsTypes"
        @DataUpdate="dataUpdate"
        @refresh-type="refreshType"
        @switch-component="switchMain"
      />
      <el-empty
        v-else
        :image-size="125"
        :description="$t(`datasource.${swTips}`)"
        :image="image"
      />
    </de-main-container>
  </div>
</template>

<script>
import DeMainContainer from '@/components/dataease/DeMainContainer'
import DeAsideContainer from '@/components/dataease/DeAsideContainer'
import DsTree from './DsTree'
import DsForm from './DsForm'
import dsTable from './DsTable'
import DriverForm from './DriverFormDetail'
export default {
  name: 'DsMain',
  components: { DeMainContainer, DeAsideContainer, DsTree },
  data() {
    return {
      image: require('@/assets/None_Select_ds.png'),
      component: '',
      datasource: {},
      param: null,
      tData: null,
      currentMgm: 'dsMgm',
      dsTypes: []
    }
  },
  computed: {
    swTips() {
      return this.currentMgm === 'driverMgm' ? 'diver_on_the_left' : 'on_the_left'
    }
  },
  methods: {
    dataUpdate(row) {
      this.$refs.dsTree.dataUpdate(row)
    },
    jump() {
      this.$refs.dsTree.dsMgm()
      this.switchMgm('dsMgm')
    },
    switchMgm(type) {
      this.currentMgm = type
    },
    addDriver() {
      this.$refs.dsTree.addDriver()
    },
    // 切换main区内容
    switchMain(param) {
      const { component, componentParam, tData, dsTypes } = param
      this.component = ''
      this.param = null
      this.$nextTick(() => {
        switch (component) {
          case 'DsForm':
            this.component = DsForm
            this.param = componentParam
            this.tData = tData
            this.dsTypes = dsTypes
            break
          case 'DriverForm':
            this.component = DriverForm
            this.param = componentParam
            this.tData = tData
            this.dsTypes = dsTypes
            break
          case 'dsTable':
            this.component = dsTable
            this.param = componentParam
            break
          default:
            this.component = ''
            this.param = null
            break
        }
      })
    },
    refreshType(datasource) {
      this.datasource = datasource
      this.$refs.dsTree && this.$refs.dsTree.refreshType(datasource)
    },
    msg2Current(sourceParam) {
      this.$refs.dsTree && this.$refs.dsTree.markInvalid(sourceParam)
    }
  }
}
</script>

<style scoped lang="scss">
.de-ds-container {
  height: 100%;
  width: 100%;
  overflow: hidden;
  display: flex;
  flex-wrap: nowrap;
  box-sizing: border-box;
  .el-empty {
    padding-top: 202px;
  }
}
.ms-aside-container {
  height: calc(100vh - 56px);
  padding: 0px;
  min-width: 260px;
  max-width: 460px;
}
.dsr-route-title {
  width: 100%;
  margin: -2px 0 22px 0;
  display: flex;
  justify-content: space-between;
  align-content: center;
}
.is-driver-mgm {
  height: calc(100vh - 56px);
  background-color: var(--MainBG, #f5f6f7);
  padding: 24px;
  flex-wrap: wrap;
  .ms-aside-container,
  .ms-main-container {
    height: calc(100vh - 170px);
    background-color: var(--ContentBG, #ffffff);
    .tree-style {
      padding-top: 24px;
    }
  }
  .ms-main-container {
    flex: 1;
    position: relative;
    padding: 24px 0 70px 24px;
  }
}
</style>