<template>
  <div class="dialog" v-if="dialogForm">
    <div class="head_box">
      <span class="title">重点群体管理 </span>
      <div>
        <el-button type="primary" size="small" :loading="loading" @click="submit" >保存</el-button>
        <el-button size="small" @click="close">关闭</el-button>
      </div>
    </div>
    <div class="form_cnt">
      <FormMessage :formList="formData" ref="elform" :rules="rules"></FormMessage>
    </div>
  </div>
</template>

<script setup>
import FormMessage from '@/components/aboutTable/FormMessage.vue'
import { qcckGet, qcckPost, qcckPut } from "@/api/qcckApi.js";
import * as rule from "@/utils/rules.js";
import { ref, defineExpose, reactive, onMounted, defineEmits, getCurrentInstance, nextTick } from "vue";
const emit = defineEmits(["updateDate"]);
const props = defineProps({
  dic: Object
});
const { proxy } = getCurrentInstance();
const dialogForm = ref(false); //弹窗
const formData = ref([
  { label: "姓名", prop: "xm", type: "input", },
  { label: "身份证号", prop: "sfzh",  type: "input" },
  { label: "户籍地", prop: "hjd",  type: "input"},
  { label: "户籍地派出所", prop: "hjdpcs",  type: "input" },
  { label: "入库开始时间", prop: "kssj",  type: "datetime"},
  { label: "入库结束时间", prop: "jssj",  type: "datetime"},
  { label: "人员级别", prop: "ryjb",  type: "select",options:[] },
  { label: "所属警种", prop: "ssjz",  type: "input"  },
  { label: "管辖单位", prop: "gxdw",  type: "input"  },
  { label: "涉及警种", prop: "sjjz",  type: "input"  },
  { label: "管控民警姓名", prop: "njxm",  type: "input"  },
  { label: "管控民警警号", prop: "mjjh",  type: "input"  },
  { label: "管控原因", prop: "gkyy",  type: "textarea",width: '100%' },
  { label: "被管控人联系方式", prop: "lxfs",  type: "input",},
  { label: "责任单位", prop: "zedw",  type: "input",},
  { label: "人员标签大类", prop: "bqdl",  type: "select",options:[]},
  { label: "人员标签细类", prop: "bqxl",  type: "select",options:[]},
]);
const listQuery = ref({
  sfbqdj: []
}); //表单
const loading = ref(false);
const elform = ref();
const title = ref("");
const rules = reactive({
  xsbt: [{ required: true, message: "请输入线索标题", trigger: "blur" }]
});
const editpeo = ref();
onMounted(() => {});
// 初始化数据
const init = (type, row,) => {
  dialogForm.value = true;
  title.value = type == 'add' ? "新增" : "编辑";
  if (row) getDataById(row.id);
};
// 根据id查询详情
const getDataById = (id) => {
  // qcckGet({}, '/mosty-gsxt/tbGsxtBqgl/'+id).then((res) => {
  //   listQuery.value = res;
  // });
};

// 提交
const submit = () => {
  elform.value.submit((data)=>{
    // let url =  title.value == "新增" ? '/mosty-gsxt/tbGsxtBqgl/save':'/mosty-gsxt/tbGsxtBqgl/update';
    // let params = { ...data }
    // qcckPost(params, url).then((res) => {
    //   proxy.$message({ type: "success", message: title.value + "成功" });
    //   emit("updateDate");
    //   close();
    // }).catch(() => {});
  });
};

// 关闭
const close = () => {
  listQuery.value = {};
  dialogForm.value = false;
  loading.value = false;
};
defineExpose({ init });
</script>

<style lang="scss" scoped>
@import "~@/assets/css/layout.scss";
@import "~@/assets/css/element-plus.scss";
::v-deep .el-tabs--card>.el-tabs__header .el-tabs__item.is-active{
  color: #0072ff;
  background: rgba(0, 114, 255, 0.3);
}
</style>
