<template>
  <div>
    <el-dialog
      title="撤回设置"
      :visible.sync="dialogVisible"
      :close-on-click-modal="false"
    >
      <table cellspacing="0" cellpadding="0" border="0" class="form-table">
        <tbody>
          <tr>
            <th style="width: 100px">
              <span class="xh-star">*</span>撤回原因：
            </th>
            <td colspan="3">
              <OpinionText :text="text" ref="opinionText" />
            </td>
          </tr>
        </tbody>
      </table>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="confirm" size="small"
          >确 定</el-button
        >
        <el-button @click="cancel" size="small">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import OpinionText from "@/components/common/opinionText.vue";
import flow from "@/api/flow.js";
export default {
  props:["instId","taskId"],
  name: "taskToRevoke",
  data() {
    return {
      dialogVisible: false,
      text: "",
      data: {},
      revokeUrl: "",
    };
  },
  components: {
    OpinionText,
  },
  methods: {
    showDialog(revokeUrl, data) {
      this.data = data;
      this.revokeUrl = revokeUrl;
      this.dialogVisible = true;
    },
    confirm() {
      let opinion = this.$refs.opinionText.getOpinion();
      if (!opinion) {
        this.$message({ type: "warning", message: "请输入撤回原因" });
        return;
      }
      this.data.cause = opinion;
      this.$store.dispatch(this.revokeUrl, this.data).then((value) => {
        this.dialogVisible = false;
        if (value) {
          this.$router.push("/task/" + value + "/0");
          setTimeout(() => {
            this.$root.$children[0].reload();
          }, 10);
        } else {
          this.$router.push("/v-flow/v-todo");
        }
      });
    },
    cancel() {
      this.dialogVisible = false;
    }
  },

};
</script>

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