<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>
          <tr>
            <th style="width: 100px">附件上传：</th>
            <td colspan="3">
              <FileUpload ref="FileUpload" />
            </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 FileUpload from "@/components/common/fileUpload.vue";
export default {
  name: "taskToFeeBack",
  props: ["instId", "taskId"],
  data() {
    return {
      dialogVisible: false,
      text: "",
    };
  },
  components: {
    OpinionText,
    FileUpload,
  },
  methods: {
    showDialog() {
      this.dialogVisible = true;
    },
    confirm() {
      let opinion = this.$refs.opinionText.getOpinion();
      if (!opinion) {
        this.$message({ type: "warning", message: "请输入反馈意见" });
        return;
      }
      let files = this.$refs.FileUpload.getFiles();
      let zfiles = "";
      this.$refs.FileUpload.isFinishUpload();
      if(files && files!=""){
          files = JSON.stringify(files);
      }
      let data = {
        instId: this.instId,
        taskId: this.taskId,
        opinion: opinion,
        files: files,
        zfiles: zfiles,
      };
      this.$store.dispatch("storeProcess/doNextcommu", data).then(() => {
          if (this.token != null) {
            window.close();
          } else {
            this.$router.go(-1);
          }
        });
    },
    cancel(){
        this.dialogVisible = false;
    }
  },
};
</script>

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