<script name="fundsAllocation" setup>
import { ref } from 'vue'
const formData = ref({}),
  formRef = ref(),
  rules = {
    softwareDevelopmentAmount: [{ required: true, message: '请输入软件开发', trigger: 'blur' }],
    cloudHardwarePurchaseAmount: [
      { required: true, message: '请输入云资源、硬件配置', trigger: 'blur' }
    ],
    thirdPartyAmount: [{ required: true, message: '请输入第三方服务', trigger: 'blur' }]
  },
  // 校验
  validForm = (callback) => {
    formRef.value.validate(valid => {
      callback(valid)
    })
  },
  // 回显
  setFormData = (data) => {
    formData.value = {
      softwareDevelopmentAmount: data.softwareDevelopmentAmount,
      cloudHardwarePurchaseAmount: data.cloudHardwarePurchaseAmount,
      thirdPartyAmount: data.thirdPartyAmount
    }
  }
defineExpose({ validForm, formData, setFormData })
</script>

<template>
  <el-form
    ref="formRef"
    :model="formData"
    :rules="rules"
    label-position="right"
    label-width="180px"
    label-suffix=":"
    scroll-to-error
  >
    <el-row :gutter="40">
      <el-col :span="8">
        <el-form-item label="软件开发" prop="softwareDevelopmentAmount">
          <el-input-number
            v-model="formData.softwareDevelopmentAmount"
            placeholder="请填写"
            :min="0"
            :controls="false"
            @mousewheel.prevent
          />
        </el-form-item>
      </el-col>
      <el-col :span="8">
        <el-form-item label="云资源、硬件配置" prop="cloudHardwarePurchaseAmount">
          <el-input-number
            v-model="formData.cloudHardwarePurchaseAmount"
            placeholder="请填写"
            :min="0"
            :controls="false"
            @mousewheel.prevent
          />
        </el-form-item>
      </el-col>
      <el-col :span="8">
        <el-form-item label="第三方服务" prop="thirdPartyAmount">
          <el-input-number
            v-model="formData.thirdPartyAmount"
            placeholder="请填写"
            :min="0"
            :controls="false"
            @mousewheel.prevent
          />
        </el-form-item>
      </el-col>
    </el-row>
  </el-form>
</template>

<style lang="less">
.el-upload-list{
  width: 100%;
}
</style>
