<template>
  <view class="px-3 pb-10">
    <view :key="index" v-for="(item, index) in tasks">
      <view class="flex items-center">
        <TimeStatus :content="JSON.stringify(item.state)" :status="item.state" />
        <view class="flex-1 ml-2 flex justify-between">
          <view>任务时间栏</view>
          <view>
            <view class="flex justify-between" style="min-width: 180rpx">
              <u-icon custom-prefix="custom-icon" name="C-bxl-redux" size="34"></u-icon>
              <u-icon custom-prefix="custom-icon" name="attachment" size="42"></u-icon>
              <u-icon custom-prefix="custom-icon" name="moneycollect" size="40"></u-icon>
            </view>
          </view>
        </view>
      </view>
      <view class="border-l-2 border-gray-300 ml-3.5 my-2">
        <view class="ml-4 shadow-lg task-box overflow-hidden">
          <u-card
            :show-foot="false"
            :show-head="false"
            :style="{ height: item.panel.height + 'px' }"
            class="h-16"
            margin="0"
            v-if="item.panel.height"
          >
            <view slot="body">
              <view :key="pluginIndex" class="u-col-between p-0 u-skeleton" v-for="(plugin, pluginIndex) in item.plugins">
                <view :key="p.pluginId" v-for="p in plugin">
                  <component
                    :is="$t.plugin.defaults.find(item => item.id === p.pluginId).component"
                    :item="item"
                    v-if="$t.plugin.defaults.find(item => item.id === p.pluginId)"
                  ></component>
                </view>
                <!-- <view :key="p.pluginId" v-for="p in plugin">
                  <text v-if="p.pluginId === 4">这是个基准线</text>
                  <component :is="currentComponent"></component>
                  <task-title v-if="p.pluginId === 1" />
                  <task-description v-if="p.pluginId === 2" />
                  <task-duration-delay v-if="p.pluginId === 3" />
                </view>-->
              </view>
            </view>
          </u-card>
        </view>
      </view>
    </view>
    <Tips />
  </view>
</template>

<script>
import { mapState, mapMutations } from 'vuex';
import TaskDescription from '@/plugins/TaskDescription/TaskDescription.vue';
import TaskTitle from '@/plugins/TaskTitle/TaskTitle.vue';
import TimeStatus from './TimeStatus.vue';
import TaskDurationDelay from '@/plugins/TaskDurationDelay/TaskDurationDelay.vue';

export default {
  name: 'TimeBox',
  components: { TimeStatus, TaskTitle, TaskDescription, TaskDurationDelay },
  data() {
    return {
      currentComponent: '',

      addList: [
        {
          state: 0,
          plugins: [[{ pluginId: 1 }], [{ pluginId: 2 }]],
          panel: { height: '100' },
        },
        {
          state: 0,
          plugins: [[{ pluginId: 1 }], [{ pluginId: 2 }]],
          panel: { height: '100' },
        },
        {
          state: 0,
          plugins: [[{ pluginId: 1 }], [{ pluginId: 3 }]],
          panel: { height: '100' },
        },
      ],
    };
  },

  computed: mapState('home', ['roleId', 'timeNode', 'timeUnit', 'tasks']),

  created() {},

  methods: {
    ...mapMutations('home', ['setTipsContent', 'setTipsContent']),

    addTopList() {
      this.tasks = this.addList.concat(this.tasks);
    },

    addBottomList() {
      this.tasks = this.tasks.concat(this.addList);
    },
  },
};
</script>

<style scoped lang="scss">
.task-box {
  border-radius: 24rpx;
}
</style>
