<template>
  <div class="dialog" v-if="dialogForm">
    <div class="head_box">
      <span class="title">从业人员详情 {{ title }}</span>
      <div>
        <el-button type="primary" v-if="title != '详情'" size="small" :loading="loading" @click="submit">保存</el-button>
        <el-button size="small" @click="close">关闭</el-button>
      </div>
    </div>
    <div class="cntinfo">
      <el-form :model="listQuery" :label-width="230" label-position="left">
        <div class="form-row">
          <el-form-item label="场所代码">
            <el-input v-model="listQuery.csdm" placeholder="01"/>
          </el-form-item>
          <el-form-item label="场所名称">
            <el-input v-model="listQuery.csmc" placeholder="天上人间ktv"/>
          </el-form-item>
        </div>

        <div class="form-row">
          <el-form-item label="姓名">
            <el-input v-model="listQuery.xm" placeholder="张三"/>
          </el-form-item>
          <el-form-item label="证件号码">
            <el-input v-model="listQuery.zjhm" placeholder="511123456789654125"/>
          </el-form-item>
        </div>

        <div class="form-row">
          <el-form-item label="职业类别代码">
            <el-input v-model="listQuery.zylbdm" placeholder="123456"/>
          </el-form-item>
          <el-form-item label="居住地址">
            <el-input v-model="listQuery.jzdz" placeholder="林芝市巴宜区区政府路119号"/>
          </el-form-item>
        </div>

        <div class="form-row">
          <el-form-item label="入职时间">
            <el-date-picker v-model="listQuery.rzsj" type="date" placeholder="2025/1/20" style="width: 100%;" />
          </el-form-item>
          <el-form-item label="离职时间">
            <el-date-picker v-model="listQuery.lzsj" type="date" placeholder="请选择" style="width: 100%;" />
          </el-form-item>
        </div>

        <div class="form-row">
          <el-form-item label="联系电话">
            <el-input v-model="listQuery.lxdh" placeholder="15222222222"/>
          </el-form-item>
          <el-form-item label="执业许可证编号">
            <el-input v-model="listQuery.zyxkzbh" placeholder=""/>
          </el-form-item>
        </div>

        <div class="form-row">
          <el-form-item label="岗位">
            <el-input v-model="listQuery.gw" placeholder=""/>
          </el-form-item>
          <el-form-item label="资格证类型">
            <el-input v-model="listQuery.zgzlx" placeholder=""/>
          </el-form-item>
        </div>

        <div class="form-row">
          <el-form-item label="资格证编号">
            <el-input v-model="listQuery.zgzbh" placeholder=""/>
          </el-form-item>
          <el-form-item label="资格证有效期截止日期">
            <el-date-picker v-model="listQuery.zgzyxqjzrq" type="date" placeholder="请选择" style="width: 100%;" />
          </el-form-item>
        </div>

        <el-form-item label="资格证有效期起始日期">
          <el-date-picker v-model="listQuery.zgzyxqqsrq" type="date" placeholder="请选择" style="width: 100%;" />
        </el-form-item>

        <el-form-item label="抓拍图片" >
          <div class="image-group">
            <div class="image-item" v-for="(item, index) in listQuery.captureImages" :key="index">
              <el-image :src="item.img" fit="cover"></el-image>
            </div>
          </div>
        </el-form-item>
      </el-form>
    </div>
    
  </div>
</template>

<script setup>
import { ref, reactive } from 'vue';
import { Plus } from '@element-plus/icons-vue';

const dialogForm = ref(false);
const activeName = ref('basic');
const title = ref('详情');
const listQuery = ref({
  captureImages: [
    {img:require('@/assets/images/person.png')},
    {img:require('@/assets/images/person.png')},
    {img:require('@/assets/images/person.png')},
  ],
  list: [
    {xm:'张三',zjhm:'510183199626565555'},
    {xm:'张三',zjhm:'510183199626565555'},
    {xm:'张三',zjhm:'510183199626565555'},
    {xm:'张三',zjhm:'510183199626565555'},
    {xm:'张三',zjhm:'510183199626565555'},
  ]
});

const areaOptions = ref([]); // 区域选项数据

// 提交
const submit = ()=>{
  elform.value.validate((valid) => {
    if (!valid) return false;
    // loading.value = true;
    let params = { ...listQuery.value}
    let url = title.value == '新增' ? '/mosty-lzcj/tbDwYy/insert' :'/mosty-lzcj/tbDwYy/update'
    // qcckPost(params, url).then((res) => {
    //   proxy.$message({ type: "success", message: title.value+'成功'});
    //   close()
    //   emit("updateDate",modelLx.value);
    // }).catch(()=>{
    //   loading.value = false;
    // });
  });
}

// 初始化数据
const init = (type, row,) => {
  dialogForm.value = true;
  title.value = type == 'add' ? '新增' : type == 'eidt' ? '编辑' : '详情'
  // 根据type和row初始化表单数据
};

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

defineExpose({init})
</script>

<style lang="scss" scoped>
.dialog {
  padding: 20px;

  :deep(.el-form-item__label) {
    background-color: #F7FAFB;
    padding: 0px 8px;
    color: #000;
    font-weight: 500;
    border: 1px solid #E3E7ED;
  }

  .head_box {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
  }
  .cntinfo{
    height: calc(100% - 70px);
    overflow: hidden;
    overflow-y: auto;
  }

  .labelTileile{
    background-color: #F7FAFB;
    border: 1px solid #E3E7ED;
    line-height: 30px;
    padding-left: 8px;
    // text-align: center;
    margin-top: 10px;
  }
  .image-group {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
  
    
    .image-item {
      width: 150px;
      height: 150px;
      border: 1px solid #dcdfe6;
      
      .el-image {
        width: 100%;
        height: 100%;
      }
    }
  }

  .form-row {
    display: flex;
    
    .el-form-item {
      flex: 1;
    }
  }

  .upload-group {
    display: flex;
    // gap: 20px;
    
    .el-form-item {
      flex: 1;
    }
  }

  .unit {
    margin-left: 5px;
  }
   ::v-deep .el-input__inner{
    height: 36px !important;
    line-height: 36px !important;
    border-radius: 0;
    color: #777575;
  }
}
.el-form-item--default{
  margin-bottom: 0px;
}
</style>