<template>
  <el-form :model="examineForm" label-width="100px">
    <el-form-item label="工程名称">
      <el-input type="text" placeholder="请输入内容" v-model="examineForm.objName" readonly>
      </el-input>
    </el-form-item>
    <el-form-item label="阶段信息" style="text-align:left">
      <el-input type="text" placeholder="请输入内容" :model-value="planProcessName" readonly>
      </el-input>
    </el-form-item>
    <el-form-item label="是否通过审定" style="text-align:left">
      <el-radio v-model="examineForm.stageStatus" label="1">是</el-radio>
      <el-radio v-model="examineForm.stageStatus" label="2">否</el-radio>
    </el-form-item>
    <el-form-item label="审定意见">
      <el-input type="textarea" :rows="2" placeholder="请输入内容" v-model="examineForm.stageStatusReson">
      </el-input>
    </el-form-item>
    <el-form-item style="margin-top: 50px">
      <el-button type="primary" @click="examineVisible">保存</el-button>
      <el-button @click="examineVisiblefalse">取消</el-button>
    </el-form-item>
  </el-form>
</template>
<script>
import request from '@/utils/gw_ajax_request.js';
export default {
  props: ['rgstrId', 'planProcessId', 'planProcessName'],
  data() {
    return {
      examineForm: {
        objName: '',
        rgstrId: '',
        planProcessId: '',
        stageStatusReson: '',
        stageStatus: '',
      },
    };
  },
  mounted() {
    this.getByExamine();
  },
  methods: {
    getByExamine() {
      const data = {
        rgstrId: this.rgstrId,
        planProcessId: this.planProcessId,
      };
      request.post(`/tac/province/examine/getBy`, data).then((res) => {
        if (res.success) {
          this.examineForm = res.data;
        } else {
          this.$message.error(res.message);
        }
      });
    },
    examineVisible() {
      this.examineForm.planProcessId = this.planProcessId;
      this.examineForm.rgstrId = this.rgstrId;
      if (this.rgstrId && this.planProcessId) {
        request
          .post(`/tac/province/examRecord/insertExamine`, this.examineForm)
          .then((res) => {
            if (res.success) {
              this.$message.success('审定提交成功');
              this.$emit('dialogClose');
            } else {
              this.$message.error(res.message);
            }
          })
          .catch((err) => {
            this.$message.error(err);
          });
      } else {
        this.$message.warning('项目名称以及阶段不能为空');
      }
    },
    examineVisiblefalse() {
      this.$emit('dialogClose');
    },
  },
  watch: {
    rgstrId() {
      this.getByExamine();
    },
    planProcessId() {
      this.getByExamine();
    },
  },
};
</script>
<style>

</style>
