<template>
  <el-dialog v-model="modelValue" title="情报列表" width="70%" @close="closeDialog" destroy-on-close>
    <Search :searchArr="searchConfiger" @submit="onSearch" :key="pageData.keyCount"></Search>
    <MyTable customClass="zdy_peo_table" :tableData="pageData.tableData" :tableColumn="pageData.tableColumn"
      :tableHeight="pageData.tableHeight" :key="pageData.keyCount" :tableConfiger="pageData.tableConfiger"
      :controlsWidth="pageData.controlsWidth">
      <template #qblx="{ row }">
        <DictTag :tag="false" :value="row.qblx" :options="D_GS_XS_LX" />
      </template>
      <template #qbly="{ row }">
        <DictTag :tag="false" :value="row.qbly" :options="D_GS_XS_LY" />
      </template>

      <template #shzt="{ row }">
        <!-- 采纳（将这条信息推送到情报管理）,退回！ -->
        <DictTag :tag="false" :value="row.shzt" :options="D_BZ_XSSHZT" @clickTag="clickTag(row.shzt)" />
      </template>
      <template #controls="{ row }">
          <el-link size="small" type="primary" @click="showDetail(row)">详情</el-link>
        </template>
    </MyTable>
    <Pages @changeNo="changeNo" @changeSize="changeSize" :tableHeight="pageData.tableHeight" :pageConfiger="{
      ...pageData.pageConfiger,
      total: pageData.total
    }"></Pages>
    <template #footer>
      <div class="dialog-footer">
        <el-button @click="closeDialog">取消</el-button>
        <el-button type="primary" @click="closeDialog">确认 </el-button>
      </div>
    </template>
  </el-dialog>
</template>

<script setup>
import MyTable from "@/components/aboutTable/MyTable.vue";
import Search from "@/components/aboutTable/Search.vue";
import Pages from "@/components/aboutTable/Pages.vue";
import { qbcjSelectPage } from "@/api/Intelligence.js";
import {xxcjSelectPage,xxcjXxzsx} from '@/api/xxcj.js'
import { ref, reactive, getCurrentInstance, watch } from "vue";
import { useRoute,useRouter } from 'vue-router'
const route = useRoute()
const router = useRouter()
const { proxy } = getCurrentInstance()
const { D_BZ_QBSBLY,D_GS_XS_LX,D_GS_XS_LY ,D_BZ_XSSHZT} = proxy.$dict("D_BZ_QBSBLY","D_GS_XS_LX","D_GS_XS_LY","D_BZ_XSSHZT")
const props = defineProps({
  modelValue: {
    type: Boolean,
    default: false
  },
  dict: {
    type: Object,
    default: () => ({})
  }
})
const searchConfiger = ref([
  {
    label: "情报标题",
    prop: 'qbmc',
    placeholder: "请输入情报标题",
    showType: "input"
  },
  {
    label: "上报来源",
    prop: "sjLy",
    placeholder: "请选择上报来源",
    showType: "select",
    options: D_BZ_QBSBLY
  }, {
    label: "上报时间",
    prop: "startTime",
    placeholder: "请选择时间",
    showType: "datetimerange"
  },



]);
const emit = defineEmits(['update:modelValue'])
const closeDialog = () => {
  emit('update:modelValue', false)
}
const pageData = reactive({
  tableData: [],
  keyCount: 0,
  tableConfiger: {
    loading: false,
    rowHieght: 40,
    haveControls: false,
  },
  controlsWidth: 160, //操作栏宽度
  total: 0,
  pageConfiger: {
    pageSize: 20,
    pageCurrent: 1
  }, //分页
  tableColumn: [
    { label: "上报人姓名", prop: "xssbr" },
    { label: "情报编号", prop: "xsBh" },
    { label: "情报标题", prop: "qbmc" },
    { label: "情报类型", prop: "qblx", showSolt: true },
    { label: "情报来源", prop: "qbly", showSolt: true },
    { label: "情报上报时间", prop: "sxsbsj" },
    { label: "指向地点", prop: "zxdz" },
    { label: "情报内容", prop: "qbnr" },
  ],
  tableHeight: "50vh",
});
const parameter = ref()
const onSearch = (val) => {
  const promes = {
    startTime: val.startTime && val.startTime.length > 0 ? val.startTime[0] : '',
    endTime: val.startTime && val.startTime.length > 0 ? val.startTime[1] : '',
  }
  parameter.value = { ...val, ...promes }
  pageData.pageConfiger.pageCurrent = 1;
  changePage()
}
watch(() => props.modelValue, (val) => {
  if (val) {
    changePage()
  }
})
const changePage = () => {
  pageData.tableConfiger.loading = true;
  let data = { ...pageData.pageConfiger, ...parameter.value,qbjb:'01' };
  xxcjSelectPage(data).then(res => {
    pageData.tableData = res.records || [];
    pageData.total = res.total;
    pageData.tableConfiger.loading = false;
  }).catch(() => { pageData.tableConfiger.loading = false; })
}

// 查看详情
const showDetail = (item) => {
  router.push({
    path: '/CollectCrculate',
    query: {
      id: item.id
    }
  })
}

const changeNo = (val) => {
  pageData.pageConfiger.pageCurrent = val;
  changePage()
}
const changeSize = (val) => {
  pageData.pageConfiger.pageSize = val;
  changePage()
}
</script>

<style scoped></style>
