<template>
  <ExeTaskVue ref="demandRef" :actionList="actionList"> </ExeTaskVue>
  <CreateWorkTime
    operateType="editWork"
    :taskInfo="taskInfo"
    v-model:show-dialog="showCreateWorkTimeVisible"
  ></CreateWorkTime>
</template>
<script lang="ts" setup>
import { reactive, ref } from 'vue';
import ExeTaskVue from '@/views/task/simulationTask/executeTask/index.vue';
import CreateWorkTime from './components/createWorkTime.vue';
import { CommonStore } from '@/stores/common';
import { NODE_TYPE } from '@/utils/enum/node';
import { disposeTagName } from '@/views/task/simulationTask/taskPage';

const taskInfo = reactive({
  uuid: '',
  taskName: '',
  workspace: '',
  description: '',
  workName: '',
});

const commonStore = CommonStore();
const tagTypeMapList = commonStore.getDictData('TAG_TYPE_MAP_LIST')?.A || [];

const showCreateWorkTimeVisible = ref(false);

const actionList = ref([
  {
    title: '报工',
    type: 'primary',
    click: (row: any) => {
      showCreateWorkTimeVisible.value = true;
      taskInfo.uuid = row.uuid;
      taskInfo.taskName = row.taskName;
      taskInfo.description = row.description;
      taskInfo.workName = disposeTagName(row, NODE_TYPE.PROJECT) + '-' + row.taskName;
      tagTypeMapList.forEach((item: any) => {
        if (item.value === NODE_TYPE.WORKSPACE) {
          taskInfo.workspace = row[item.label];
        }
      });
    },
  },
]);
</script>
<style lang="scss" scoped></style>
