<template>
  <div class="dialog" v-if="dialogVisible">
    <div class="head_box">
      <span class="title">{{ title }}</span>
      <div>
        <!-- <el-button size="small" @click="save" type="primary" :loading="loading">保存</el-button> -->
        <el-button size="small" @click="close">关闭</el-button>
      </div>
    </div>
    <div class="cntinfo">
      <el-descriptions column="2" border label-width="180px">
        <el-descriptions-item label="单位名称(营业执照登记名称)">{{ formData.xm }}</el-descriptions-item>
        <el-descriptions-item label="统一社会信用代码">{{ formData.sfzh }}</el-descriptions-item>
        <el-descriptions-item label="保安单位类型">{{ formData.lxdh }}</el-descriptions-item>
        <el-descriptions-item label="场所名称">{{ formData.jzdz }}</el-descriptions-item>
        <el-descriptions-item label="场所代码">{{ formData.rzsj }}</el-descriptions-item>
        <el-descriptions-item label="场所联系电话">{{ formData.ssbmdm }}</el-descriptions-item>
        <el-descriptions-item label="经营状况">{{ formData.ssbmdm }}</el-descriptions-item>
        <el-descriptions-item label="开业日期">{{ formData.ssbmdm }}</el-descriptions-item>
        <el-descriptions-item label="单位注册地址" :span="2">{{ formData.ssbmdm }}</el-descriptions-item>
        <el-descriptions-item label="场所经营地址" :span="2">{{ formData.ssbmdm }}</el-descriptions-item>
        <el-descriptions-item label="法定代表人">{{ formData.ssbmdm }}</el-descriptions-item>
        <el-descriptions-item label="法定代表人证件号码">{{ formData.ssbmdm }}</el-descriptions-item>
        <el-descriptions-item label="经营法定代表人联系电话">{{ formData.ssbmdm }}</el-descriptions-item>
        <el-descriptions-item label="经营法定代表人居住地址">{{ formData.ssbmdm }}</el-descriptions-item>
        <el-descriptions-item label="场所负责人">{{ formData.ssbmdm }}</el-descriptions-item>
        <el-descriptions-item label="场所负责人身份证号">{{ formData.ssbmdm }}</el-descriptions-item>
        <el-descriptions-item label="场所负责人联系方式">{{ formData.ssbmdm }}</el-descriptions-item>
        <el-descriptions-item label="场所负责人居住地址">{{ formData.ssbmdm }}</el-descriptions-item>
        <el-descriptions-item label="场所负责人身份证号">{{ formData.ssbmdm }}</el-descriptions-item>
        <el-descriptions-item label="保安服务公司名称" :span="2">{{ formData.ssbmdm }}</el-descriptions-item>
        <el-descriptions-item label="保安负责人">{{ formData.ssbmdm }}</el-descriptions-item>
        <el-descriptions-item label="保安负责人身份证号码">{{ formData.ssbmdm }}</el-descriptions-item>
        <el-descriptions-item label="保安负责人联系方式">{{ formData.ssbmdm }}</el-descriptions-item>
        <el-descriptions-item label="保安人员数量">{{ formData.ssbmdm }}</el-descriptions-item>
        <el-descriptions-item label="场所面积" :span="2">{{ formData.ssbmdm }}</el-descriptions-item>
        <el-descriptions-item label="营业执照照片">{{ formData.ssbmdm }}</el-descriptions-item>
        <el-descriptions-item label="武装押运证书">{{ formData.ssbmdm }}</el-descriptions-item>
        <el-descriptions-item label="备案编号">{{ formData.ssbmdm }}</el-descriptions-item>
        <el-descriptions-item label="备案机构名称">{{ formData.ssbmdm }}</el-descriptions-item>
        <el-descriptions-item label="经营许可证号码">{{ formData.ssbmdm }}</el-descriptions-item>
        <el-descriptions-item label="经营许可证发证机构">{{ formData.ssbmdm }}</el-descriptions-item>
      </el-descriptions>
    </div>
  </div>
</template>

<script setup>
import { ref, computed, reactive, getCurrentInstance } from 'vue'
import { qcckPost } from "@/api/qcckApi.js";
import MyTable from '@/components/aboutTable/MyTable.vue';

const { proxy } = getCurrentInstance()
const title = ref('保安培训项目新增')
const loading = ref(false)
const disabled = ref(false)
const FormRef = ref(null)
const visible = ref(true)
const viewAndUploadRef = ref(null)
const viewAndUploadVisible = ref(false)

const props = defineProps({
  modelValue: {
    type: Boolean,
    default: false
  },
  dic: {
    type: Object,
    default: () => ({})
  }
})

const emits = defineEmits(['update:modelValue'])

const dialogVisible = computed({
  get() {
    return props.modelValue
  },
  set(val) {
    emits('update:modelValue', val)
  }
})

const pageData = reactive({
  tableData: [{}],
  keyCount: 0,
  tableConfiger: {
    rowHieght: 61,
    showSelectType: "null",
    loading: false
  },
  total: 0,
  pageConfiger: {
    pageSize: 10,
    pageCurrent: 1
  },
  controlsWidth: 180,
  tableColumn: [
    { label: "姓名", prop: "xm" },
    { label: "证件号码", prop: "sfzh" },
    { label: "联系号码", prop: "lxdh" },
    { label: "线上培训时长", prop: "sfzh" },
    { label: "所属单位", prop: "lxdh" },
  ]
});

const formData = ref({})

const close = () => {
  dialogVisible.value = false
}

const open = (row = {}, type = 'add') => {
  disabled.value = false
  dialogVisible.value = true
  formData.value = { ...row }
  if (type === 'view') {
    title.value = '查看详情'
    visible.value = true
  } else if (type === 'edit') {
    title.value = '保安证申请'
    visible.value = false
  }
}

const save = () => {
  FormRef.value.submit(() => {
    loading.value = true;
    const url = !formData.value?.id ? `/mosty-base/baxx/cyry/add` : `/mosty-base/baxx/cyry/edit`;
    qcckPost(formData.value, url).then(() => {
      loading.value = false;
      proxy.$message.success("保存成功");
      emits("refresh");
      close();
    }).catch(() => {
      loading.value = false;
    })
  });
}

const addEdit = (type, row) => {
  viewAndUploadRef.value?.open(row, type)
}

defineExpose({ open })
</script>

<style lang="scss" scoped>
@import "@/assets/css/layout.scss";

.label {
  margin-top: 20px;
  color: #000;
}

.cntinfo {
  padding: 2rem 12rem 0rem 12rem;
  height: calc(100% - 270px);
  overflow-y: auto;
}

.mapBox {
  width: 100%;
  height: 400px;
  overflow: hidden;
}
</style>
