<template>
  <el-dialog
    title="选择任务节点"
    :visible.sync="dialogVisible"
    width="50%"
    append-to-body
    :close-on-click-modal="false"
    :close-on-press-escape="false"
    @close="handleClose"
  >
    <el-table :data="tableData">
      <el-table-column prop="id" label="任务id" width="180"></el-table-column>
      <el-table-column prop="subject" label="任务名称"></el-table-column>
      <el-table-column prop="name" label="节点" width="180"></el-table-column>
      <el-table-column label="操作" width="80">
        <template #default="{ row }">
          <el-button type="text" size="small" @click="handleTask(row)">
            处理
          </el-button>
        </template>
      </el-table-column>
    </el-table>
  </el-dialog>
</template>

<script>
  import { mapState } from 'vuex'
  export default {
    name: 'TodoTaskDialog',
    props: {
      tableData: {
        type: Array,
        default: () => {
          return []
        },
      },
    },
    data() {
      return {
        dialogVisible: false,
      }
    },
    computed: {
      ...mapState('routes', ['fullScreenState']),
    },
    methods: {
      handleClose() {
        this.dialogVisible = false
        if(this.fullScreenState){
          this.$router.go(-1)
        } else {
          this.$tabs.close()
        }
      },
      openDialog() {
        this.dialogVisible = true
      },
      handleTask(row) {
        this.$router.push({
          path: '/matter/approvalForm',
          query: {
            taskId: row.id,
            isGetApprovalBtn: true,
          },
        })
      },
    },
  }
</script>

<style lang="scss" scoped></style>
