import { http } from "@/utils/https"; import { yaMessage, yaErrorMessage, yaConfirmMessage } from '@/utils/message' import { useRouter } from "vue-router"; const GET_TABLE_API = '' export const useFileHashList = () => { const page = ref(1) const pageSize = ref(20) const total = ref(0) const tableData = ref([]) as any const router = useRouter() // 查询 formData const searchFormData = reactive({ fileType: '', // 文件类型 source: '',// 来源 maliciousTypes: '' // 恶意类型 }) // 查询 form 列数据 const searchFormColumns = reactive([ { key: 'fileType', type: 'select', label: '文件类型', option: [], col: 8 }, { key: 'source', type: 'select', label: '来源', option: [], col: 8 }, { key: 'maliciousTypes', type: 'select', label: '恶意类型', option: [], col: 8 }, ]) // 表格列 const tableColumn = [ { width: "80px", label: "ID", prop: "id", }, { prop: "hash", label: "hash值", minWidth: '250px' }, { prop: "fileType", label: "文件类型", minWidth: '130px', }, { prop: "maliciousTypes", label: "恶意类型", minWidth: '130px', }, { 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, hash: '0fd894f62c1d4d337610', fileType: 'exe', maliciousTypes: '勒索病毒', source: '奇安信威胁情报中心', time: '2022-07-28 17:11:07', } }) 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/fileHashDetail' }) } 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, } }