recordEdit.vue 6.35 KB
<template>
  <div class="app-content" style="height:50vh;overflow:auto;">
    <a-spin :spinning="loading" style="width: 100%;height: 100%;">
      <a-form-model ref="form" :model="formData" :rules="rules" class="from-table">
        <a-row type="flex">
          <a-col :span="4" class="bg-gray">
            <div class="special-middle">
              <div class="required">年度</div>
            </div>
          </a-col>
          <a-col :span="20">
            <a-form-model-item prop="reportYear">
              <a-input placeholder="年度" v-model="formData.reportYear" :maxLength="4" style="width: 250px;" />
            </a-form-model-item>
          </a-col>
        </a-row>
        <a-row>
          <a-col :span="4" class="bg-gray">
            <div class="required">审核单位</div>
          </a-col>
          <a-col :span="20">
            <a-form-model-item ref="auditUnitId" prop="auditUnitId">
              <unit-select v-model="formData.auditUnitId" :typeId="2" />
              <span style="color: rgb(56, 188, 213);margin-left:5px">※ 请输入单位名称查找到单位</span>
            </a-form-model-item>
          </a-col>
        </a-row>
        <!-- <a-row>
          <a-col :span="4" class="bg-gray">
            <div class="required">审核人</div>
          </a-col>
          <a-col :span="20">
            <a-form-model-item ref="personName" prop="personName">
              <unit-select v-model="formData.personName" />
              <span style="color: rgb(56, 188, 213);margin-left:5px">※ 请输入单位名称查找到单位</span>
            </a-form-model-item>
          </a-col>
        </a-row> -->
        <a-row type="flex">
          <a-col :span="4" class="bg-gray">
            <div class="special-middle">
              <div class="required">审核类型</div>
            </div>
          </a-col>
          <a-col :span="20">
            <a-form-model-item prop="auditType">
              <base-select v-model="formData.auditType" :type="13" :isAll="true" :width="250" />
            </a-form-model-item>
          </a-col>
        </a-row>
        <a-row type="flex">
          <a-col :span="4" class="bg-gray">
            <div class="special-middle">
              <div class="required">审核方式</div>
            </div>
          </a-col>
          <a-col :span="20">
            <a-form-model-item prop="auditMethod">
              <base-select v-model="formData.auditMethod" :type="14" :isAll="true" :width="250" />
            </a-form-model-item>
          </a-col>
        </a-row>
        <a-row type="flex">
          <a-col :span="4" class="bg-gray">
            <div class="special-middle">
              <div>审核内容</div>
            </div>
          </a-col>
          <a-col :span="20">
            <a-form-model-item prop="auditContent">
              <a-input placeholder="审核内容" v-model="formData.auditContent" :maxLength="10" style="width: 250px;" />
            </a-form-model-item>
          </a-col>
        </a-row>
        <a-row type="flex">
          <a-col :span="4" class="bg-gray">
            <div class="special-middle">
              <div class="required">排序</div>
            </div>
          </a-col>
          <a-col :span="20">
            <a-form-model-item prop="showIndex">
              <a-input placeholder="排序" v-model="formData.showIndex" :maxLength="10" style="width: 250px;" />
            </a-form-model-item>
          </a-col>
        </a-row>
        <a-row type="flex">
          <a-col :span="4" class="bg-gray">
            <div class="special-middle">
              <div class="required">审核结果</div>
            </div>
          </a-col>
          <a-col :span="20">
            <a-form-model-item prop="auditResult">
              <base-select v-model="formData.auditResult" :type="15" :isAll="true" :width="250" />
            </a-form-model-item>
          </a-col>
        </a-row>
        <a-row>
          <a-col :span="24" style="text-align:center;">
            <a-button type="primary" style="margin-right:50px;" @click="submit">保存</a-button>
          </a-col>
        </a-row>
      </a-form-model>
    </a-spin>
  </div>
</template>

<script>
import moment from 'moment'
import { isEmptyParams } from '@/views/utils/common'
import unitSelect from '@/views/components/common/unitSelect'
import baseSelect from '@/views/components/common/baseSelect'

export default {
  name: 'recordEdit',
  components: {
    unitSelect, baseSelect
  },
  data () {
    return {
      formData: {
        id: null,
        auditObjectId: null,
        reportYear: null,
        auditUnitId: null,
        auditType: null,
        auditMethod: null,
        auditContent: null,
        showIndex: null,
        auditResult: null
      },
      rules: {
        reportYear: [{ required: true, message: '请输入审核年度', trigger: 'blur' }],
        auditUnitId: [{ required: true, message: '请输入审核单位', trigger: 'change' }],
        auditType: [{ required: true, message: '请选择审核类型', trigger: 'change' }],
        auditMethod: [{ required: true, message: '请选择审核方式', trigger: 'change' }],
        auditContent: [{ required: false, message: '请输入审核内容', trigger: 'blur' }],
        showIndex: [{ required: true, message: '请输入排序', trigger: 'blur' }],
        auditResult: [{ required: true, message: '请选择审核结果', trigger: 'change' }],
      },
      loading: false,
    }
  },
  props: {
    value: {
      type: String,
      default: () => {
        return null
      }
    },
    obj: {
      type: Object,
      default: () => {
        return null
      }
    }
  },
  created () {
    this.getObj()
  },
  methods: {
    moment,
    getObj () {
      if (this.obj)
        this.formData = this.obj
      else
        this.formData.auditObjectId = this.value
    },
    submit () {
      this.$refs.form.validate(valid => {
        if (valid) {
          this.loading = true
          let pars = isEmptyParams(this.formData)
          let par = { ...pars }
          this.$api.auditManager.save(par).then(({ data = {} }) => {
            if (data) {
              this.$message.success('成功!')
              this.$emit('close', 'edit')
            }
            this.loading = false
          }).catch(() => { this.loading = false })
        } else {
          this.$message.error('信息未填写完整!')
          return false
        }
      })
    }
  }
}
</script>