<template>
  <div class="app-container">
    <el-card shadow="never">
      <template #header>
        <div class="card-header">
          <span>新增整改进展</span>
          <el-button plain icon="ArrowLeft" @click="goBack">返回</el-button>
        </div>
      </template>
      <el-form :model="form" :rules="rules" ref="rectProgRef" label-width="120px">
        <el-row>
          <el-col :span="24">
            <el-form-item label="整改进展" prop="rectProg">
              <el-input v-model="form.rectProg" type="textarea" :rows="4" placeholder="请输入整改进展情况" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item label="备注" prop="note">
              <el-input v-model="form.note" type="textarea" :rows="2" placeholder="请输入备注" />
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <div class="form-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="goBack">取 消</el-button>
      </div>
    </el-card>
  </div>
</template>

<script setup name="HiddRectProgAdd">
import { addBisHiddRectProg } from "@/api/slaj/hidd"

const { proxy } = getCurrentInstance()
const route = useRoute()
const router = useRouter()

const form = ref({
  hiddGuid: route.query.hiddGuid,
  rectProg: undefined,
  note: undefined
})

const rules = {
  rectProg: [{ required: true, message: "整改进展不能为空", trigger: "blur" }]
}

function submitForm() {
  proxy.$refs["rectProgRef"].validate(valid => {
    if (valid) {
      addBisHiddRectProg(form.value).then(() => {
        proxy.$modal.msgSuccess("新增成功")
        goBack()
      })
    }
  })
}

function goBack() {
  router.push({ path: '/slaj/hidd/detail', query: { guid: form.value.hiddGuid } })
}
</script>

<style scoped>
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.form-footer {
  text-align: center;
  padding-top: 20px;
}
</style>
