<template>
  <a-modal
    v-model:visible="dialogVisible"
    @ok="saveMonthlyReportInfo"
    @cancel="closeDialog"
    :confirm-loading="loadingStat"
    title="整改进度月报"
    width="60%"
    class="outerDialog custom_dialog">
    <a-form :model="MonthlyReportInfo" :rules="rules" :label-col="{span: 8}" :wrapper-col="{span: 15}" ref="MonthlyReportInfoForm">
      <a-form-item label="整改描述" prop="zgZgxx">
        <a-textarea v-model:value="MonthlyReportInfo.rectifyDesc" :rows="8" />
      </a-form-item>
      <a-form-item label="预计完成日期" prop="expectDate">
        <a-date-picker v-model:value="MonthlyReportInfo.expectDate" show-time placeholder="选择整改截止日期" style="width: 100%;" />
      </a-form-item>
    </a-form>
    <span slot="okText">{{ loadingStatText }}</span>
  </a-modal>
</template>

<script>
import { hostUrl } from '../../../utils/global_variable';
import request from '../../../utils/gw_ajax_request';
import upload from '../../../widgets/uploadFileWithType';

export default {
  props: ['pblmId'],
  components: {
    upload,
  },
  data() {
    return {
      MonthlyReportInfo: {
        id: '',
        rectifyDesc: '',
        expectDate: '',
      },
      loadingStat: false,
      loadingStatText: '提交',
      rules: {
        rectifyDesc: [
          { required: true, message: '请输入整改描述', trigger: 'blur' },
        ],
        expectDate: [
          {
            required: true,
            message: '请输入整改预计完成日期',
            trigger: 'blur',
          },
        ],
      },
      uuid: '',
      persId: localStorage.getItem('persId'),
      uploadFileUrl: '',
      dialogImageUrl: '',
      dialogVisible: true,
    };
  },
  computed: {
    hostUrl() {
      return hostUrl;
    },
  },
  created() {},
  methods: {
    saveMonthlyReportInfo() {
      this.$refs.MonthlyReportInfoForm.validate((valid) => {
        if (valid) {
          if (this.MonthlyReportInfo.expectDate) {
            this.$emit('saveMonthlyReportInfo', this.MonthlyReportInfo);
          } else {
            this.$message.warning('请填写整改描述!');
            return false;
          }
        } else {
          return false;
        }
      });
    },
    closeDialog() {
      this.$emit('closePblmMonthlyReportInfoDialog');
    },
    beforeClose(done) {
      /* this.$confirm('确认关闭？')
        .then(_ => {
          this.$emit("saveMonthlyReportInfo", this.MonthlyReportInfo);
          //sthis.dialogVisible = false;
          done();
        })
        .catch(_ => {
        }); */
      // this.dialogVisible = false;
      done();
    },
  },
};
</script>

<style lang='less' scoped>

</style>
