<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">
        <el-divider content-position="left">基础信息</el-divider>
        <div class="form-row">
          <el-form-item label="线索名称">
            <el-input v-model="listQuery.xsmc" placeholder="请输入线索名称" />
          </el-form-item>
          <el-form-item label="线索来源">
            <el-input v-model="listQuery.xsly" placeholder="请输入线索来源" />
          </el-form-item>
          <el-form-item label="线索编号">
            <el-input v-model="listQuery.xsbh" placeholder="请输入线索编号" />
          </el-form-item>
          <el-form-item label="所属专题">
            <el-input v-model="listQuery.xszt" 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-select v-model="listQuery.xsdj" placeholder="请选择线索等级">
              <el-option label="一级" value="1"/>
              <el-option label="二级" value="2"/>
            </el-select>
          </el-form-item> -->
        </div>

        <el-divider content-position="left">线索描述</el-divider>
        <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-select
              v-model="listQuery.bqdl"
              placeholder="请选择线索标签大类"
            >
              <el-option label="类型1" value="1" />
              <el-option label="类型2" value="2" />
            </el-select>
          </el-form-item>
          <el-form-item label="线索标签细类">
            <el-select
              v-model="listQuery.bqxl"
              placeholder="请选择线索标签细类"
            >
              <el-option label="一级" value="1" />
              <el-option label="二级" value="2" />
            </el-select>
          </el-form-item>
          <el-form-item label="线索标签二级系类">
            <el-select
              v-model="listQuery.bqxl"
              placeholder="请选择线索标签二级系类"
            >
              <el-option label="一级" value="1" />
              <el-option label="二级" value="2" />
            </el-select>
          </el-form-item>
          <el-form-item label="线索来源">
            <el-select v-model="listQuery.xsly" placeholder="请选择线线索来源">
              <el-option label="一级" value="1" />
              <el-option label="二级" value="2" />
            </el-select>
          </el-form-item>
        </div>
        <div class="form-row">
          <el-form-item label="线索风险等级">
            <el-select
              v-model="listQuery.xsfxdj"
              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.xsbz" placeholder="请输入线索备注" />
          </el-form-item>
          <el-form-item label="市内外">
            <el-input v-model="listQuery.snw" placeholder="请输入市内外" />
          </el-form-item>
          <el-form-item label="是否涉及外地">
            <el-select
              v-model="listQuery.fxdj"
              placeholder="请选择线索风险等级"
            >
              <el-option label="是" value="1" />
              <el-option label="否" value="0" />
            </el-select>
          </el-form-item>
          <el-form-item label="指向地点">
            <el-select v-model="listQuery.zxdd" placeholder="请选择指向地点">
              <el-option label="一级" value="1" />
              <el-option label="二级" value="2" />
            </el-select>
          </el-form-item>
        </div>

        <el-divider content-position="left">相关人员</el-divider>
        <div class="mt10 mb10">
          <el-button type="primary" size="small">添加人员</el-button>
        </div>
        <div class="form-row">
          <MyTable
            :tableData="pageForm.tableData"
            :tableColumn="pageForm.tableColumn"
            :tableHeight="pageForm.tableHeight"
            :key="pageForm.keyCount"
            :tableConfiger="pageForm.tableConfiger"
            :controlsWidth="pageForm.controlsWidth"
            @chooseData="chooseData"
          >
            <!-- 操作 -->
            <template #controls="{ row }">
              <el-link
                size="small"
                type="primary"
                @click="addEdit('detail', row)"
                >详情</el-link
              >
              <el-link size="small" type="success" @click="addEdit('edit', row)"
                >编辑</el-link
              >
              <el-link size="small" type="danger" @click="deleteRow(row)"
                >删除</el-link
              >
            </template>
          </MyTable>
        </div>

        <el-divider content-position="left">申请人</el-divider>
        <div class="form-row">
          <el-form-item label="申请单位">
            <el-input v-model="listQuery.sqdw" placeholder="请输入申请单位" />
          </el-form-item>
          <el-form-item label="申请人">
            <el-input v-model="listQuery.sqr" placeholder="请输入申请人" />
          </el-form-item>
          <el-form-item label="审核单位">
            <el-input v-model="listQuery.shdw" 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.spdw" placeholder="请输入审批单位" />
          </el-form-item>
          <el-form-item label="审批人">
            <el-input v-model="listQuery.spr" placeholder="请输入审批人" />
          </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>
