<template>
  <div>
    <div class="titleBox">
      <PageTitle title="重点人员深度发掘"></PageTitle>
    </div>
    <!-- 搜索 -->
    <div ref="searchBox">
      <Search :searchArr="searchConfiger" @submit="onSearch" />
    </div>
    <!-- 表格 -->
    <div class="tabBox">
      <MyTable
        :tableData="pageData.tableData"
        :tableColumn="pageData.tableColumn"
        :tableHeight="pageData.tableHeight"
        :key="pageData.keyCount"
        :tableConfiger="pageData.tableConfiger"
        :controlsWidth="pageData.controlsWidth"
      >
        <template #ryXm="{ row }">
            <div class="one_text_detail">姓名：{{ row.ryXm }}  &nbsp;；</div>
            <div class="one_text_detail">电话：{{ row.rySjhm }} &nbsp;；</div>
            <div class="one_text_detail">身份证：{{ row.rySfzh }} </div>
          </template>
          <template #fxDj="{ row }">
            <DictTag :tag="false" :value="row.fxDj" :options="D_GS_RQFJ_FXDJ"/>
          </template>
          <template #fxLb="{ row }">
            <DictTag :tag="false" :value="row.fxLb" :options="D_GS_RQFJ_FXLB"/>
          </template>
          <template #bqList="{ row }">
            <div v-if="row.bqList">
              <el-tag v-for="(it,idx) in row.bqList" :key="idx">{{ it.bqMc }}、</el-tag>
            </div>
          </template>
        <!-- 操作 -->
        <template #controls="{ row }">
          <el-link type="primary"  size="small" @click="showDetail(row)">指令下发</el-link>
          <el-link type="primary" v-if="roleList.includes('BK_SH_RY')" size="small" @click="createProcess(row)">审核</el-link>
          <el-link type="primary" size="small" @click="opeshow(row)">详情</el-link>
          <!-- <el-link type="primary" v-if="roleList.includes('BK_SH_RY')" size="small" @click="handleDetail(row,'审核')">审核</el-link> -->
        </template>
      </MyTable>
      <Pages
        @changeNo="changeNo"
        @changeSize="changeSize"
        :tableHeight="pageData.tableHeight"
        :pageConfiger="{
          ...pageData.pageConfiger,
          total: pageData.total
        }"
      ></Pages>
    </div>
    <Model v-model="isShow" :data="chooeRow" @change="getList" :dic="{D_BZ_RCSHZT}"></Model>
    <Details ref="details"/>
  </div>
  <SubmissionProcess v-model="showSp" :data="rowData"
   :userData="{ ajmc: '重点人员深度发掘审批', flowType: 'ZDRYSDFJDP',modelName:'重点人' }"
  :path="fixedValue" @getList="getList" />
  <Information v-model="showDialog" title="发送指令" @submit='submit' @close='close'>
   <SemdFqzl ref="semdFqzlRef" :itemData="itemData" @handleClose="handleClose" identification="zdrfj" :tacitly="tacitly"/>
  </Information>
</template>

<script setup>
import { ElMessage } from "element-plus";
import Model from "./model.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 { qcckGet, qcckPost, qcckDelete } from "@/api/qcckApi.js";
import { reactive, ref, onMounted, getCurrentInstance } from "vue";
import SubmissionProcess from '@/components/flowPath/submissionProcess.vue'
import Details from './details.vue'
import Information from "@/views/home/model/information.vue";
import SemdFqzl from '@/components/instructionHasBeen/sendFqzl.vue'
const { proxy } = getCurrentInstance();
const { D_BZ_RCSHZT, D_GS_RQFJ_LX, D_GS_RQFJ_FXDJ, D_BZ_SF, D_GS_RQFJ_FXLB } =
  proxy.$dict(
    "D_BZ_RCSHZT",
    "D_GS_RQFJ_LX",
    "D_GS_RQFJ_FXDJ",
    "D_BZ_SF",
    "D_GS_RQFJ_FXLB"
  );

const isShow = ref(false)
const chooeRow = ref({})

const searchBox = ref(); //搜索框

const searchConfiger = ref([
  {
    label: "所属部门",
    prop: "department",
    placeholder: "请选择所属部门",
    showType: "department"
  },
  {
    label: "是否关注",
    prop: "isFollowed",
    placeholder: "请选择是否关注",
    showType: "select",
    options: [
      { label: "是", value: true },
      { label: "否", value: false }
    ]
  }
]);

const queryFrom = ref({
  myNote: false,
  myCheck: false,
  myApprove: false
});

const pageData = reactive({
  tableData: [],
  keyCount: 0,
  tableConfiger: {
    rowHieght: 61,
    showSelectType: "null",
    loading: false
  },
  total: 0,
  pageConfiger: {
    pageSize: 20,
    pageCurrent: 1
  },
  controlsWidth: 240,
  tableColumn: [
    { label: "个人信息", prop: "ryXm",showOverflowTooltip:true ,showSolt: true},
    { label: "户籍地址", prop: "ryHjdz" ,showOverflowTooltip:true},
    { label: "护照号码", prop: "ryHzhm" ,showOverflowTooltip:true},
    { label: "现住地址", prop: "ryXzdz" ,showOverflowTooltip:true},
    { label: "附件照片", prop: "ryFjZp" ,showOverflowTooltip:true},
    { label: "管辖单位", prop: "gxDwDm" ,showOverflowTooltip:true},
    { label: "责任部门", prop: "ssbm",showOverflowTooltip:true},
    { label: "标签", prop: "bqList",showOverflowTooltip:true,showSolt: true},
    { label: "风险积分", prop: "fxjf",showOverflowTooltip:true},
    { label: "风险等级", prop: "fxDj",showOverflowTooltip:true, showSolt: true },
    { label: "风险类别", prop: "fxLb",showOverflowTooltip:true, showSolt: true },
    { label: "处置方式", prop: "czfs",showOverflowTooltip:true, showSolt: true },
  ]
});
const roleList = ref([])

onMounted(() => {
  let qx = JSON.parse(localStorage.getItem('roleList')) || [];
  roleList.value = qx.map(item => item.roleCode);
  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 = { sfZbkry: 1, ...pageData.pageConfiger, ...queryFrom.value };
  qcckGet(data, "/mosty-gsxt/tbGsxtRqfjRy/selectPage").then((res) => {
    pageData.tableData = res.records || [];
    pageData.total = res.total;
    pageData.tableConfiger.loading = false;
  })
  .catch(() => {
    pageData.tableConfiger.loading = false;
  });
};


// 处理数据
const handleDetail = (val,type) =>{
  chooeRow.value = val;
  isShow.value = true;
}
// 表格高度计算
const tabHeightFn = () => {
  pageData.tableHeight = window.innerHeight - searchBox.value.offsetHeight - 250;
  window.onresize = function () {
    tabHeightFn();
  };
};
// 审批流
// 固定值
const fixedValue = {
  clueVerification:'focusExploration',
  byMeansOf: 'tbGsxtRqfjRy/callback',
  nobyMeansOf: 'tbGsxtRqfjRy/callback',
  recycle:'tbGsxtRqfjRy/callback',

}
const showSp = ref(false);
const rowData = ref()
const createProcess = (row) => {
  showSp.value = true;
  rowData.value = row
}
const details=ref()
const opeshow = (row) => {
  details.value.init(row)
}
//下发指令
const showDialog = ref(false)
const itemData = ref()
const semdFqzlRef=ref()
const handleClose = () => {
  showDialog.value = false;
}
const showDetail = (item) => {
  showDialog.value = true;
  itemData.value=item
}
const submit=()=>{
  semdFqzlRef.value.getsendFqzl()
}
const close = () => {
  semdFqzlRef.value.close()
}
const tacitly = {
  title:'ryXm'
}
</script>

<style lang="scss" scoped>
.checkbox-group {
  display: flex;
  gap: 20px;
}

.basic-info {
  display: flex;
  gap: 15px;

  .avatar {
    width: 80px;
    height: 80px;
    overflow: hidden;
    border-radius: 4px;

    img {
      width: 100%;
      height: 100%;
      object-fit: cover;
    }
  }

  .info-list {
    display: flex;
    flex-direction: column;
    gap: 5px;
  }
}

.control-buttons {
  display: flex;
  gap: 10px;
}
</style>
