import { http } from "@/utils/https"; import { yaMessage, yaErrorMessage, yaConfirmMessage } from "@/utils/message"; import { useRouter } from "vue-router"; const GET_TABLE_API = ""; export const useEmailList = () => { const page = ref(1); const pageSize = ref(20); const total = ref(0); const tableData = ref([]) as any; const router = useRouter(); // 查询 formData const searchFormData = reactive({ geographicPosition: "", // 地理位置 intelligenceSources: "", // 情报来源 degreeMalicious: "", // 恶意程度 }); // 查询 form 列数据 const searchFormColumns = reactive([ { key: "geographicPosition", type: "select", label: "地理位置", placeholder: "请选择地理位置", option: [], col: 8, }, { key: "intelligenceSources", type: "select", label: "情报来源", placeholder: "请选择情报来源", option: [], col: 8, }, { key: "type", type: "select", label: "类型", placeholder: "请选择类型", option: [], col: 8, }, ]); // 表格列 const tableColumn = [ { width: "80px", label: "ID", prop: "id", }, { prop: "address", label: "地址", minWidth: "200px", }, { prop: "geographicPosition", label: "地理位置", minWidth: "250px", slotName: "geoPosition", }, { prop: "type", label: "类型", minWidth: "200px", }, { prop: "source", label: "来源", }, { prop: "time", label: "时间", }, { label: "操作", width: "150px", buttons: [ { title: "详情", }, { title: "删除", }, ], }, ]; const getTableData = async (init) => { if (init) { page.value = 1; } // const pageParam = { // pageNum: page.value, // pageSize: pageSize.value, // } // const res = await http.post(GET_TABLE_API, pageParam) // if (res.data?.rows && res.data?.rows.length > 0) { // tableData.value = res.data.rows // total.value = res.data.total // } else { // tableData.value = [] // total.value = 0 // } tableData.value = Array.from({ length: 20 }).map((_, index) => { return { id: index + 1, address: "xydxz@webmine.cz" + index, geographicPosition: "地理位置" + index, type: "类型" + index, source: "来源" + index, time: "时间" + index, countryName: "中国", countryCode: "156", }; }); total.value = 20; }; const handleSearchBlockSearch = (form) => { console.log("查询区域:", form); getTableData(true); }; const handleSearchBlockReset = () => { console.log("查询区域重置点击"); getTableData(true); }; const handleQuickSearch = (searchValue) => { console.log("快速搜索", searchValue); }; const tableBtnClick = (btn, row) => { console.log("表格按钮点击", btn, row); if (btn.title === "详情") { console.log("表格-详情点击"); router.push({ path: "/threatIntelligence/management/emailDetail", }); } if (btn.title === "删除") { console.log("表格-删除点击"); } }; const sizeChange = function (val) { pageSize.value = val; getTableData(true); }; const currentChange = function (val) { page.value = val; getTableData(false); }; function init() { getTableData(true); } onMounted(() => { init(); }); return { page, pageSize, total, tableData, searchFormData, searchFormColumns, tableColumn, handleSearchBlockSearch, handleSearchBlockReset, handleQuickSearch, tableBtnClick, sizeChange, currentChange, }; };