index.vue 3.2 KB
<template>
  <div v-if="show" class="my-custom-module" @click="goModule(module)">
    <div class="custom-module-title">{{ module.name }}</div>
    <div class="custom-module-content">
      <div class="custom-module-content-item">
        <img :src="module.icon" alt="">
      </div>
      <div class="custom-module-content-item custom-module-content-item-total">
        {{ module.total }}
      </div>
    </div>
    <div v-if="module.list" class="custom-module-bottom">
      <div
        v-for="item in module.list"
        :key="item.name"
        class="custom-module-bottom-item"
        style="justify-content: flex-end;"
      >
        <span class="custom-module-bottom-item-name">{{ item.name }}</span><span>{{ item.value }}</span>
      </div>
    </div>
  </div>
</template>

<script>
import { getTaskCount } from '@/api/workspace.js'
export default {
  props: {
    module: {
      type: Object,
      default: null
    }
  },
  data() {
    return {
      show: false
    }
  },
  watch: {
    'module.name': {
      immediate: true,
      handler: function(val) {
        if (val) {
          this.getCustomModules(val)
        }
      }
    }
  },
  // mounted() {
  //   this.getCustomModules()
  // },
  methods: {
    getCustomModules(data) {
      const params = {}
      if (data === '装配任务') {
        params.type = 'FitOut'
        this.module.appId = 'myTaskReceive'
      } else if (data === '检验任务') {
        params.type = 'CheckOut'
        this.module.appId = 'myCheckTaskReceive'
      } else {
        params.type = 'DMIR'
        this.module.appId = 'myAirTaskReceive'
      }
      getTaskCount(params).then(res => {
        this.module.icon = '/images/navagations/task-icon.png'
        this.module.total = res.items.count
        this.module.list = [{
          name: '待办',
          value: res.items.count
        }]
        this.module.serverOriginName = 'dee-mes'
        this.module.originRoute = 'dee-mes/taskReception'
        this.module.showMenu = false
        this.show = true
      })
    },
    async goModule(module) {
      this.$router.push({
        path: module.originRoute,
        query: {
          title: module.name,
          showMenu: module.showMenu,
          showTag: 'false'
        }
      })
      this.$store.dispatch('menu/activeModel', {
        appId: this.module.appId,
        pageInfo: {
          title: this.module.name,
          path: '/dee-mes/taskReception'
        }
      })
      this.$store.dispatch('app/closeSideBar', false)
    }
  }
}
</script>

<style lang="scss">
.my-custom-module {
  height: 173px;
  min-width: 179px;
  background-color: #fff;
  padding: 20px;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
  border-radius: 4px;
  .custom-module-title {
    color: #6f6f6f;
    font-size: 24px;
    font-weight: 500;
    text-align: left;
  }
  .custom-module-content {
    display: flex;
    align-items: center;
    .custom-module-content-item {
      flex: 1;
      text-align: right;
      img {
        height: 28px;
      }
    }
    .custom-module-content-item-total {
      color: #329d25;
      font-size: 38px;
      font-weight: 500;
    }
  }
}
</style>