<template>
  <div>
    <div class="titleBox">
      <PageTitle title="人力情报信息采集流转">
        <el-button type="primary" @click="showHome = true">情报研判分析</el-button>
        <el-button type="primary" @click="handleHB">线索串联</el-button>
      </PageTitle>
    </div>
    <!-- 搜索 -->
    <div ref="searchBox">
      <Search :searchArr="searchConfiger" @submit="onSearch" :key="pageData.keyCount"/>
    </div>
    <!-- 表格 -->
    <div class="tabBox">
      <MyTable
        :tableData="pageData.tableData"
        :tableColumn="pageData.tableColumn"
        :tableHeight="pageData.tableHeight"
        :key="pageData.keyCount"
        :tableConfiger="pageData.tableConfiger"
        :controlsWidth="pageData.controlsWidth">

        <template #xlLx="{row}">
          <DictTag :tag="false" :value="row.xlLx" :options="D_GS_XS_LX" />
        </template>
        <template #qbLy="{row}">
          <DictTag :tag="false" :value="row.qbLy" :options="D_GS_XS_LY" />
        </template>
        <template #czzt="{row}">
          <DictTag :tag="false" :value="row.czzt" :options="D_GS_XS_CZZT" />
        </template>
        <template #shzt="{row}">
          <DictTag :tag="false" :value="row.shzt" :options="D_BZ_XSSHZT" />
        </template>
        <template #zxkssj="{row}">
          <span>{{ row.zxkssj }}</span> 至
          <span>{{ row.zxjssj }}</span> 
        </template>

        <!-- 操作 -->
        <template #controls="{ row }">
          <el-link size="small" type="primary" @click="handleZL(row)">转为指令</el-link>
          <el-link size="small" type="primary" @click="addEdit('detail', row)">详情</el-link>
        </template>
      </MyTable>
      <Pages
        @changeNo="changeNo"
        @changeSize="changeSize"
        :tableHeight="pageData.tableHeight"
        :pageConfiger="{
          ...pageData.pageConfiger,
          total: pageData.total
        }"
      ></Pages>
    </div>
    <!-- 新增 -->
   <AddForm ref="detailDiloag" v-if="isShow" :dic="{D_BZ_SF,D_BZ_XB,D_GS_XS_LY,D_BZ_SSZT,D_GS_XS_LX ,D_GS_XS_QTLX}" />
   <ZlForm ref="zlDialog" v-if="isShow" :dic="{D_GS_XS_ZLLX,D_GS_ZDQT_FXDJ}"></ZlForm>
   <HbForm ref="isShowhB" :dic="{D_GS_XS_LX,D_GS_XS_LY,D_GS_XS_CZZT,D_BZ_XSSHZT,D_GS_XS_QTLX}"></HbForm>
    <teleport to="#app">
      <Qbypfx v-if="showHome" @close="showHome = false"></Qbypfx>
    </teleport>
  </div>
</template>

<script setup>
import Qbypfx from './qbypfx/index.vue'
import PageTitle from "@/components/aboutTable/PageTitle.vue";
import MyTable from "@/components/aboutTable/MyTable.vue";
import Pages from "@/components/aboutTable/Pages.vue";
import Search from "@/components/aboutTable/Search.vue";
import AddForm from "./components/addForm.vue";
import ZlForm from "./components/zlForm.vue";
import HbForm from "./components/hbForm.vue";
import { qcckGet, qcckPost, qcckDelete } from "@/api/qcckApi.js";
import { reactive, ref, onMounted, getCurrentInstance, nextTick } from "vue";
const { proxy } = getCurrentInstance();
const {D_GS_ZDQT_FXDJ,D_GS_XS_ZLLX,D_GS_XS_CZZT,D_GS_XS_LY, D_BZ_SSZT,D_BZ_SF,D_GS_XS_LX ,D_GS_XS_QTLX,D_BZ_XB,D_BZ_XSSHZT} = proxy.$dict("D_GS_ZDQT_FXDJ","D_GS_XS_ZLLX","D_GS_XS_CZZT","D_GS_XS_LY","D_BZ_SSZT","D_BZ_SF","D_GS_XS_LX","D_GS_XS_QTLX","D_BZ_XB","D_BZ_XSSHZT"); //获取字典数据
const detailDiloag = ref();
const searchBox = ref(); //搜索框
const isShow = ref(false)
const showHome = ref(false)
const zlDialog = ref(false)
const isShowhB = ref()
const searchConfiger = ref([
  { label: "线索名称", prop: 'xsMc', placeholder: "请输入线索名称", showType: "input" },
  { label: "内容关键字", prop: 'xsNr', placeholder: "请输入语义关键字", showType: "input" },
  { label: "线索类型", prop: 'xlLx', placeholder: "请选择线索类型", showType: "select",options:D_GS_XS_LX },
  { label: "线索来源", prop: 'qbLy', placeholder: "请选择线索来源", showType: "select",options:D_GS_XS_LY },
  { label: "指向地点", prop: 'zxdz', placeholder: "请输入指向地点", showType: "input" },
]);

const pageData = reactive({
  tableData: [],
  keyCount: 0,
  tableConfiger: {
    rowHieght: 61,
    showSelectType: "checkBox",
    loading: false
  },
  total: 0,
  pageConfiger: {
    pageSize: 20,
    pageCurrent: 1
  },
  controlsWidth: 150,
  tableColumn: [
    { label: "线索编号", prop: "xsBh" },
    { label: "线索名称", prop: "xsMc" },
    { label: "线索类型", prop: "xlLx",showSolt:true },
    { label: "线索来源", prop: "qbLy",showSolt:true },
    { label: "指向时间", prop: "zxkssj",showSolt:true,showOverflowTooltip:true },
    { label: "上报时间", prop: "sxsbsj",showOverflowTooltip:true },
    { label: "指向地点", prop: "zxdz" },
    { label: "线索内容", prop: "xsNr",showOverflowTooltip:true},
    { label: "处置状态", prop: "czzt",showSolt: true},
    { label: "附件", prop: "fjdz", showSolt: true },
    { label: "审核状态", prop: "shzt", showSolt: true },
  ]
});

const queryFrom = ref({});

onMounted(() => {
  getList()
  tabHeightFn();
});


// 搜索
const onSearch = (val) =>{
  queryFrom.value = {...val}
  pageData.pageConfiger.pageCurrent = 1;
  getList()
}

const changeNo = (val) =>{
  pageData.pageConfiger.pageCurrent = val;
  getList()
}
const changeSize = (val) =>{
  pageData.pageConfiger.pageSize = val;
  getList()
}

// 获取列表
const getList = () =>{
  pageData.tableConfiger.loading = true;
  let data = { ...pageData.pageConfiger, ...queryFrom.value };
  qcckGet(data,'/mosty-gsxt/qbcj/selectPage').then(res=>{
    pageData.tableData = res.records || [];
    pageData.total = res.total;
    pageData.tableConfiger.loading = false;
  }).catch(()=>{ pageData.tableConfiger.loading = false; })
}


// 转为指令
const handleZL = (val) =>{
  isShow.value = true;
  setTimeout(()=>{
    zlDialog.value.init(val)
  },500)
}

// 详情
const addEdit = (type, row) => {
  isShow.value = true;
  setTimeout(()=>{
    detailDiloag.value.init(type, row);
  },500)
};

const handleHB = () =>{
  isShowhB.value.init()
}

// 表格高度计算
const tabHeightFn = () => {
  pageData.tableHeight = window.innerHeight - searchBox.value.offsetHeight - 250;
  window.onresize = function () {
    tabHeightFn();
  };
};
</script>

<style>
.el-loading-mask {
  background: rgba(0, 0, 0, 0.5) !important;
}

</style>

