<template>
  <div class="dialog" v-if="dialogForm">
    <div class="head_box">
      <span class="title"> {{ title == '新增' ? '年检上传资料新增' : '人员年检详情' }}</span>
      <div>
        <el-button size="small" v-if="title == '新增'" @click="save" type="primary"  :loading="loading">保存</el-button>
        <el-button size="small" @click="close">关闭</el-button>
      </div>
    </div>
    <div class="cntinfo">
      <FormMessage ref="FormRef" v-model="listQuery" :disabled="title == '新增' ? false:true" :labelWidth="120" :formList="formList">
      </FormMessage>
    </div>
    <div class="flex just-center mt10" v-if="title == '详情'">
      <el-button type="primary" @click="submit">通过</el-button>
      <el-button type="danger" @click="submit">不通过</el-button>
    </div>
  </div>
</template>

<script setup>
import { qcckPost , qcckGet} from "@/api/qcckApi.js";
import FormMessage from "@/components/aboutTable/FormMessage.vue";
import { ref, reactive,defineEmits,getCurrentInstance } from 'vue';
const emit = defineEmits(["refresh"]);
const { proxy } = getCurrentInstance();
const dialogForm = ref(false);
const FormRef = ref();
const listQuery = ref({});
const loading = ref(false);
const title = ref('新增');

const rules = reactive({
  pxlx: [{ required: true, message: "请输入视频标题", trigger: "blur" }],
});
const formList = reactive([
  [
    { label: "姓名", prop: "name", type: "input" },
    { label: "证件号码", prop: "idNumber", type: "input" },
    { label: "联系电话", prop: "contactInfo", type: "input" },
  ],
  [
    { label: "是否年检", prop: "isUploaded", type: "input" },
    { label: "培训项目", prop: "trainingProject", type: "input" },
    { label: "年检时间", prop: "inspectionTime", type: "input" },
  ],
  [
    { label: "体检报告", prop: "inspectionReport", type: "upload" },
    { label: "无犯罪记录证明", prop: "wfzjlzm", type: "upload" },
    { label: "保安证证", prop: "bazzj", type: "upload" },
  ],
])


// 初始化数据
const init = (type, id,) => {
  dialogForm.value = true;
  title.value = type == 'add' ? '新增' : '详情';
};

const save = () => {
  FormRef.value.submit(()=>{
    // loading.value = true;
    // let url = title.value == '新增' ? `/mosty-jbld/jbldzsd/add` : `/mosty-jbld/jbldzsd/update`;
    // qcckPost(listQuery.value, url).then(() => {
    //   loading.value = false;
      proxy.$message.success("保存成功");
    //   emit("refresh");
      close();
    // }).catch(() => {
    //   loading.value = false;
    // })
  });
}


const close = () => {
  dialogForm.value = false;
  FormRef.value.reset()
};;

defineExpose({init})
</script>

<style lang="scss" scoped>
@import "@/assets/css/layout.scss";
.mapBox{
  width: calc(100% - 24rem);
  height:500px;
  overflow: hidden;
  margin: 0 12rem;
}
</style>
