<template>
  <div class="group-box" :style="{height:height}">
    <div class="group-title">
      工作任务
      <el-link @click="linkTo">更多 <i class="el-icon-caret-right" /></el-link>
    </div>
    <vuescroll v-if="data" :ops="ops" style="height: calc(100% - 40px)">
      <div class="task-management">
        <div
          v-for="(item, index) in dataList"
          :key="index"
          class="item"
          @click="linkTo"
        >
          <div class="icon">
            <i class="el-icon-tickets" />
          </div>
          <div class="info">
            <div class="lf">
              <h4 class="taskTitle">{{ item.taskTitle }}</h4>
              <span v-if="item.handleAccountId" style="font-size: 8px;color:#c4c1c1;">
                <i class="el-icon-user" />
                <span style="padding:0 6px;">{{ item.status===0?item.curAccountName:item.handleAccountName }}</span>
              </span>
            </div>
            <div class="rt">
              <div class="el-tag-taskCat">
                <el-tag size="mini" class="custom-tag" :class="'tag-'+item.taskCatId">{{ item.taskCatTitle }}</el-tag>
              </div>
              <template v-if="item.taskStatus===0">
                <vac :end-time="item.expectedEndTime">
                  <p
                    slot="process"
                    slot-scope="{ timeObj }"
                  >
                    <i class="el-icon-time" />
                    <span style="padding-left:6px;">{{ `${timeObj.d}天${timeObj.h}:${timeObj.m}:${timeObj.s}` }}</span>
                  </p>
                  <p slot="finish">过期</p>
                </vac>
              </template>
              <template v-else>
                <span style="font-size: 8px;color:#868282;">{{ item.status | taskStatusFilter }}</span>
              </template>

            </div>
          </div>
        </div>
      </div>
    </vuescroll>
  </div>
</template>
<script>
import commonMixin from '@/mixin/commonMethodMixin'
import vuescroll from 'vuescroll'
import { getTaskByList } from '@/api/system/taskApi'
export default {
  name: 'WorkTask',
  components: {
    vuescroll
  },
  mixins: [commonMixin],
  props: {
    more: {
      type: String,
      default: undefined
    },
    height: {
      type: [String],
      default: 'calc(100vh - 85px)'
    }
  },
  data() {
    return {
      ops: {
        bar: {
          keepShow: false,
          background: 'rgba(144, 147, 153, 0.4)',
          onlyShowBarOnScroll: false
        }
      },
      dataList: [],
      conditions: {}
    }
  },
  mounted() {
    this.getData()
  },
  methods: {
    linkTo() {
      if (this.more) {
        this.$router.push({
          path: this.more
        })
      }
    },

    // Fetch Data
    getData() {
      this.listLoading = true
      getTaskByList(this.conditions).then((resp) => {
        const { code, data, total, msg } = resp
        this.listLoading = false
        if (code === 200) {
          this.total = total
          this.dataList = data
        } else {
          this.$message.error(msg)
        }
      }).catch((error) => {
        console.log(error)
      })
    }
  }
}
</script>
<style lang="scss">
.group-box {
  width: calc(100% - 15px);
  background-color: #0C3242;
  border-top: 4px solid #1F3C51;
  border-radius: 5px 5px 0 0;
  padding: 15px;
  .group-title {
    font-size: 16px;
    color: #FFF;
    margin-bottom: 15px;
    font-weight: bold;
    .el-link {
      float: right;
      font-size: 14px;
      color: #C1C6C8;
      -webkit-text-fill-color: #C1C6C8;
    }
  }
  .group-content{
    height: 80%;
    overflow: auto;
  }
}
.task-management{
  margin-top: 20px;
  .item{
    display: flex;
    justify-content: flex-start;
    line-height: 1;
    margin-bottom: 20px;
    position: relative;
    cursor: pointer;
    .info{
      flex: 1;
      &::after{
        display: block;
        content: "";
        clear: both;
      }
      .lf{
        float: left;
      }
      .rt{
        float: right;
        .el-tag-taskCat{
          text-align: right;
          margin-top: 5px;
          .custom-tag{
            color:#fff;
            border-color:#eaeaea;
            background-color:transparent;
            &.tag-2{color: #b97741;border-color:#b97741;}
            &.tag-3{color: #97cd38;border-color:#97cd38;}
            &.tag-4{color: #dc5a2c;border-color:#dc5a2c;}
            &.tag-5{color: #414ab9;border-color:#414ab9;}
            &.tag-6{color: #c13ac9;border-color:#c13ac9;}
            &.tag-7{color: #29c761;border-color:#29c761;}
          }

        }
      }
    }
    .tag{
      height: 22px;
      display: inline-block;
      position: absolute;
      right: 0;
      padding: 0 5px;
      line-height: 20px;
      font-size: 12px;
      color: #fff;
      border-radius: 4px;
      box-sizing: border-box;
      white-space: nowrap;
      // background-color: #c78148;
      border: 1px solid #868282;
      &.none{
        background-color: transparent;
        border-color: transparent;
      }
    }
    p,h4{
      margin: 0;
      font-size: 14px;
    }
    p{
      padding-top: 6px;
      font-size: 8px;
      color: #f5f5f5;
    }
    h4{
      .status{
        font-size: 12px;
      }
      &.taskTitle{
        padding-bottom: 6px;
      }
    }
    .icon{
      width: 36px;
      height: 36px;
      font-size: 20px;
    }
  }
}
</style>
