<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="130" label-position="right">
        <div class="form-row">
          <el-form-item label="线索标题">
            <el-input v-model="listQuery.xsbt" placeholder="请输入线索标题" />
          </el-form-item>
          <el-form-item label="线索编号">
            <el-input v-model="listQuery.xsbh" placeholder="请输入线索编号" />
          </el-form-item>
          <el-form-item label="线索类型">
            <el-select v-model="listQuery.xslx" placeholder="请选择线索类型">
              <el-option label="类型1" value="1" />
              <el-option label="类型2" value="2" />
            </el-select>
          </el-form-item>
          <el-form-item label="线索来源">
            <el-input v-model="listQuery.xsly" placeholder="请输入线索来源" />
          </el-form-item>
        </div>

        <div class="form-row">
          <el-form-item label="开始时间">
            <el-date-picker v-model="listQuery.kssj" type="datetime" placeholder="请选择开始时间" />
          </el-form-item>
          <el-form-item label="结束时间">
            <el-date-picker v-model="listQuery.jssj" type="datetime" placeholder="请选择结束时间" />
          </el-form-item>
          <el-form-item label="指向地点">
            <el-input v-model="listQuery.zxdd" placeholder="请输入指向地点" />
          </el-form-item>
          <el-form-item label="群体名称">
            <el-input v-model="listQuery.qtmc" placeholder="请输入群体名称" />
          </el-form-item>
        </div>

        <div class="form-row">
          <el-form-item label="群体类型">
            <el-input v-model="listQuery.qtlx" placeholder="请输入群体类型" />
          </el-form-item>
          <el-form-item label="线索细类">
            <el-input v-model="listQuery.xslx" placeholder="请输入线索细类" />
          </el-form-item>
          <el-form-item label="风险等级">
            <el-input v-model="listQuery.fxdj" placeholder="请输入风险等级" />
          </el-form-item>
          <el-form-item label="是否初报">
            <el-input v-model="listQuery.qtmc" placeholder="请输入是否初报" />
          </el-form-item>
        </div>

        <div class="form-row">
          <el-form-item label="线索内容" class="full-width">
            <el-input type="textarea" v-model="listQuery.xsnr" :rows="4" placeholder="请输入线索内容" />
          </el-form-item>
        </div>

        <div class="form-row">
          <el-form-item label="报送编号">
            <el-input v-model="listQuery.bsbh" placeholder="请输入报送编号" />
          </el-form-item>
          <el-form-item label="编制单位">
            <el-input v-model="listQuery.bzdw" placeholder="请输入编制单位" />
          </el-form-item>
          <el-form-item label="上报单位">
            <el-input v-model="listQuery.sbdw" placeholder="请输入上报单位" />
          </el-form-item>
          <el-form-item label="抄送单位">
            <el-input v-model="listQuery.csdw" placeholder="请输入抄送单位" />
          </el-form-item>
        </div>
        <div class="form-row">
          <el-form-item label="承办人">
            <el-input v-model="listQuery.cbr" placeholder="请输入承办人" />
          </el-form-item>
          <el-form-item label="审核人">
            <el-input v-model="listQuery.shr" placeholder="请输入审核人" />
          </el-form-item>
          <el-form-item label="签发人">
            <el-input v-model="listQuery.qfr" placeholder="请输入签发人" />
          </el-form-item>
          <el-form-item label=""></el-form-item>
        </div>
      </el-form>
    </div>
  </div>
</template>

<script setup>
import MyTable from "@/components/aboutTable/MyTable.vue";
import { ref,reactive } from "vue";

const dialogForm = ref(false);
const title = ref("");
const listQuery = ref({
  xgry: []
});
const pageForm = reactive({
  tableData: [
    {
      xm: "张三",
      xb: "男",
      sfzh: "51018319969699999",
      hjd: "",
      hjdpcs: "",
      bq: "重点人员"
    }
  ],
  keyCount: 0,
  tableConfiger: {
    rowHieght: 61,
    showSelectType: "checkBox",
    loading: false
  },
  controlsWidth: 220,
  tableColumn: [
    { label: "姓名", prop: "xm" },
    { label: "性别", prop: "xb" },
    { label: "身份证号", prop: "sfzh" },
    { label: "户籍地", prop: "hjd" },
    { label: "户籍地派出所", prop: "hjdpcs" },
    { label: "标签", prop: "bq" }
  ]
});

// 初始化数据
const init = (type, row) => {
  dialogForm.value = true;
  title.value = type === "add" ? "新增" : "编辑";
  if (type === "edit" && row) {
    listQuery.value = { ...row };
  } else {
    listQuery.value = {
      xgry: []
    };
  }
};

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

const handleAdd = () => {
  listQuery.value.xgry.push({
    xm: "",
    zjhm: "",
    lxdh: ""
  });
};

const handleDelete = (index) => {
  listQuery.value.xgry.splice(index, 1);
};

defineExpose({ init });
</script>

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

  .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;
    flex-wrap: wrap;
    margin-bottom: 20px;

    .el-form-item {
      flex: 1;
      min-width: 300px;
      margin-right: 20px;

      &.full-width {
        flex: 0 0 100%;
      }
    }
  }

  :deep(.el-divider__text) {
    font-size: 16px;
    font-weight: bold;
  }
}
</style>
