<template>
  <div class="dialog" v-if="dialogForm">
    <div class="head_box">
      <span class="title">爆破事故登记{{ title }}</span>
      <div>
        <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.ywlsh" placeholder="请输入业务流水号"/>
          </el-form-item>
          <el-form-item label="发生时间">
            <el-date-picker v-model="listQuery.fssj" type="datetime" style="width:100%" placeholder="请选择发生时间"/>
          </el-form-item>
        </div>

        <div class="form-row">
          <el-form-item label="民用爆炸物品发生环节">
            <el-input v-model="listQuery.mybzwpfshj" placeholder="请输入发生环节"/>
          </el-form-item>
          <el-form-item label="事故发生地">
            <el-input v-model="listQuery.sgfsd" placeholder="请输入事故发生地"/>
          </el-form-item>
        </div>

        <div class="form-row">
          <el-form-item label="死亡人数">
            <el-input-number v-model="listQuery.swrs" :min="0" style="width:100%;" placeholder="请输入死亡人数"/>
          </el-form-item>
          <el-form-item label="受伤人数">
            <el-input-number v-model="listQuery.ssrs" :min="0" style="width:100%;" placeholder="请输入受伤人数"/>
          </el-form-item>
        </div>

        <div class="form-row">
          <el-form-item label="损失价值（人民币万元）">
            <el-input-number v-model="listQuery.ssjz" :min="0" style="width:100%;" :precision="2" placeholder="请输入损失价值"/>
          </el-form-item>
          <el-form-item label="民用爆炸物品爆炸事故原因">
            <el-input v-model="listQuery.mybzwpbzsgyy" placeholder="请输入事故原因"/>
          </el-form-item>
        </div>

        <div class="form-row">
          <el-form-item label="民用爆炸物品爆炸事故发生区域">
            <el-input v-model="listQuery.mybzwpbzsgfsqy" placeholder="请输入事故发生区域"/>
          </el-form-item>
          <el-form-item label="民用爆炸物品爆炸事故性质">
            <el-input v-model="listQuery.mybzwpbzsgxz" placeholder="请输入事故性质"/>
          </el-form-item>
        </div>

        <div class="form-row">
          <el-form-item label="登记人姓名">
            <el-input v-model="listQuery.djrxm" placeholder="请输入登记人姓名"/>
          </el-form-item>
          <el-form-item label="登记单位名称">
            <el-input v-model="listQuery.djdwmc" placeholder="请输入登记单位名称"/>
          </el-form-item>
        </div>

        <div class="form-row">
          <el-form-item label="发生场所部位详细情况">
            <el-input type="textarea" v-model="listQuery.fscsxq" :rows="3" placeholder="请输入详细情况"/>
          </el-form-item>
        </div>


      </el-form>
    </div>
  </div>
</template>

<script setup>
import { ref } from 'vue';

const dialogForm = ref(false);
const listQuery = ref({});
const title = ref('');
// 初始化数据
const init = (type, row) => {
  dialogForm.value = true;
  if (row) {
    title.value = type === 'edit' ? '编辑' : '详情';
    listQuery.value = { ...row };
  } else {
    title.value = '新增';
    listQuery.value = {};
  }
};

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

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;
  }

  .form-row {
    display: flex;
    
    .el-form-item {
      flex: 1;
    }
    .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%;
        }
      }
    }
  }

   ::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>
