<template>
  <el-dialog title="项目申报提交" :visible.sync="open" width="500px" append-to-body>
    <el-form ref="form" :model="form" :rules="rules" label-width="140px">
        <el-form-item label="项目资料选择" prop="projectData">
          <el-select v-model="form.projectData">
            <el-option value="1" label="财务数据">财务数据</el-option>
          </el-select>
        </el-form-item>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button type="primary" :disabled="disabled" @click="submitForm">确 定</el-button>
      <el-button @click="cancel">取 消</el-button>
    </div>
  </el-dialog>
</template>

<script>
  import {submitDeclareApi} from "@/api/enterprise/declare/declare"
  export default {
    data () {
      return {
        open: false,
        disabled: false,
        form: {
          projectData: ''
        },
        rules: {
          projectData: [
            {required: true, message: '请选择项目资料', trigger: 'change'}
          ]
        }
      }
    },
    methods: {
      init(id) {
        this.open = true;
        this.form.id = id;
        this.resetForm("form");
      },
      submitForm() {
        this.$refs.form.validate(valid => {
          if (valid) {
            this.disabled = true
            submitDeclareApi(this.form.id).then(res => {
              this.disabled = false;
              if(res.code == 200) {
                this.$message({
                  message: '项目申报成功',
                  type: 'success'
                });
              }
              this.open = false;
              this.$emit('refreshData');
            })
          }
        })
      },
      cancel() {
        this.open = false
      },
    },
  }
</script>

<style>
</style>
