<template>
  <el-dialog title="附件审查" :close-on-click-modal="false" :visible.sync="visible" custom-class="" width="40%" append-to-body>
    <el-form>
      <el-row>
        <el-col :span="24">
          <el-form-item label="需要审查的文件">
            <el-table :data="needReviewFiles">
              <el-table-column prop="fileName" label="文件名称"></el-table-column>
              <el-table-column prop="fileSize" label="大小（单位Byte）"></el-table-column>
            </el-table>
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="文件说明">
            <el-input type="textarea" :autosize="{ minRows: 3 }" placeholder="请对当前审查的文件进行说明" v-model="remark"></el-input>
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>

    <span slot="footer" class="dialog-footer">
      <el-button @click="visible = false">取消</el-button>
      <el-button type="primary" @click="confirmHandle">确定</el-button>
    </span>
  </el-dialog>
</template>

<script>
export default {
  name: "AddReviewDialog",
  props: {
    needReviewFiles: {
      type: Array,
      default: function () {
        return [];
      },
    },
  },
  data() {
    return {
      visible: false,
      remark: "",
    };
  },
  inject: ["upload"],
  methods: {
    confirmHandle() {
      this.$http({
        url: this.$http.adornUrl("/fileserver/fileUpload/reviewFile", false),
        method: "post",
        params: {
          uploadFormId: this.upload.formId,
        },
      }).then(({ data }) => {
        if (data.code == 40000) {
          let formId = data.formId;
          this.$http({
            url: this.$http.adornWorkFlowUrl("bpm/createReviewFile"),
            method: "post",
            data: {
              Id: data.formId,
              flowCode: "fileReview",
              remark: this.remark,
            },
          }).then((result) => {
            if (result.data.code === 40000) {
              this.$message({
                message: result.data.msg,
                type: "success",
              });
              this.visible = false;
              this.upload.refresh();
              this.$router.openTaskWindow({
                formId: formId,
                flowCode: "fileReview",
              });
            }
          });
        } else {
          this.$alert(data.msg, "错误提示", {
            confirmButtonText: "确定",
          });
        }
      });
    },
  },
};
</script>

<style scoped></style>
