|  |  | 
 |  |  | import { logout } from '@/config.js'; | 
 |  |  | import EditView from './edit.vue' | 
 |  |  | import { formatMessage } from '@/utils/localeUtils.js'; | 
 |  |  | import useTableSearch from '@/utils/tableUtils.jsx'; | 
 |  |  | const context = getCurrentInstance()?.appContext.config.globalProperties; | 
 |  |  |  | 
 |  |  | const router = useRouter(); | 
 |  |  |  | 
 |  |  | const TABLE_KEY = 'table-userLogin'; | 
 |  |  | let currentPage = 1; | 
 |  |  | let pageSize = 10; | 
 |  |  | const searchInput = ref("") | 
 |  |  | const editChild = ref(null) | 
 |  |  |  | 
 |  |  | let tableData = ref([]); | 
 |  |  | getPage(); | 
 |  |  |  | 
 |  |  | const columns = [ | 
 |  |  |   { | 
 |  |  |     title: 'ID', | 
 |  |  |     name: 'id', | 
 |  |  |     dataIndex: 'id', | 
 |  |  |     key: 'id', | 
 |  |  |   }, | 
 |  |  |   { | 
 |  |  |     title: '用户', | 
 |  |  |     name: 'userId$', | 
 |  |  |     dataIndex: 'userId$', | 
 |  |  |     key: 'userId$', | 
 |  |  |   }, | 
 |  |  |   { | 
 |  |  |     title: '密钥', | 
 |  |  |     name: 'token', | 
 |  |  |     dataIndex: 'token', | 
 |  |  |     key: 'token', | 
 |  |  |     ellipsis: true, | 
 |  |  |   }, | 
 |  |  |   { | 
 |  |  |     title: '登录ip', | 
 |  |  |     name: 'ip', | 
 |  |  |     dataIndex: 'ip', | 
 |  |  |     key: 'ip', | 
 |  |  |   }, | 
 |  |  |   { | 
 |  |  |     title: '类型', | 
 |  |  |     name: 'type', | 
 |  |  |     dataIndex: 'type', | 
 |  |  |     key: 'type', | 
 |  |  |     customRender: (column) => { | 
 |  |  |       let typeMap = { | 
 |  |  |         0: { | 
 |  |  |           text: formatMessage('login.success', '登录成功'), | 
 |  |  |         }, | 
 |  |  |         1: { | 
 |  |  |           text: formatMessage('login.fail', '登录失败'), | 
 |  |  |         }, | 
 |  |  |         2: { | 
 |  |  |           text: formatMessage('login.logout', '退出登录'), | 
 |  |  |         }, | 
 |  |  |         3: { | 
 |  |  |           text: formatMessage('login.retoken', '续签token'), | 
 |  |  |         }, | 
 |  |  |       }; | 
 |  |  |       return typeMap[column.value].text; | 
 |  |  |     } | 
 |  |  |   }, | 
 |  |  |   { | 
 |  |  |     title: '添加时间', | 
 |  |  |     name: 'createTime$', | 
 |  |  |     dataIndex: 'createTime$', | 
 |  |  |     key: 'createTime$', | 
 |  |  |   }, | 
 |  |  |   { | 
 |  |  |     title: '备注', | 
 |  |  |     name: 'memo', | 
 |  |  |     dataIndex: 'memo', | 
 |  |  |     key: 'memo', | 
 |  |  |   }, | 
 |  |  |   { | 
 |  |  |     title: '操作', | 
 |  |  |     name: 'oper', | 
 |  |  |     dataIndex: 'oper', | 
 |  |  |     key: 'oper', | 
 |  |  |   }, | 
 |  |  | ]; | 
 |  |  |  | 
 |  |  | const state = reactive({ | 
 |  |  |   selectedRowKeys: [], | 
 |  |  |   loading: false, | 
 |  |  | }); | 
 |  |  |  | 
 |  |  | let tableData = ref([]); | 
 |  |  | getPage(); | 
 |  |  |  | 
 |  |  | const { | 
 |  |  |   getColumnSearchProps, | 
 |  |  | } = useTableSearch(); | 
 |  |  |  | 
 |  |  | const columns = [ | 
 |  |  |   { | 
 |  |  |     title: formatMessage('db.sys_user_login.user_id', '用户'), | 
 |  |  |     dataIndex: 'userId$', | 
 |  |  |     width: 140, | 
 |  |  |     ...getColumnSearchProps('userId$'), | 
 |  |  |   }, | 
 |  |  |   { | 
 |  |  |     title: formatMessage('db.sys_user_login.token', '密钥'), | 
 |  |  |     dataIndex: 'token', | 
 |  |  |     width: 140, | 
 |  |  |     ellipsis: true, | 
 |  |  |     ...getColumnSearchProps('token'), | 
 |  |  |   }, | 
 |  |  |   { | 
 |  |  |     title: formatMessage('db.sys_user_login.ip', '登录ip'), | 
 |  |  |     dataIndex: 'ip', | 
 |  |  |     width: 140, | 
 |  |  |     ...getColumnSearchProps('ip'), | 
 |  |  |   }, | 
 |  |  |   { | 
 |  |  |     title: formatMessage('db.sys_user_login.type', '类型'), | 
 |  |  |     dataIndex: 'type$', | 
 |  |  |     width: 140, | 
 |  |  |     ...getColumnSearchProps('type$'), | 
 |  |  |   }, | 
 |  |  |   { | 
 |  |  |     title: formatMessage('db.sys_user_login.create_time', '添加时间'), | 
 |  |  |     dataIndex: 'createTime$', | 
 |  |  |     width: 140, | 
 |  |  |     ...getColumnSearchProps('createTime$'), | 
 |  |  |   }, | 
 |  |  |   { | 
 |  |  |     title: formatMessage('db.sys_user_login.system', '登录系统'), | 
 |  |  |     dataIndex: 'system', | 
 |  |  |     width: 140, | 
 |  |  |     ...getColumnSearchProps('system'), | 
 |  |  |   }, | 
 |  |  |   { | 
 |  |  |     title: formatMessage('db.sys_user_login.memo', '备注'), | 
 |  |  |     dataIndex: 'memo', | 
 |  |  |     width: 140, | 
 |  |  |     ...getColumnSearchProps('memo'), | 
 |  |  |   }, | 
 |  |  |  | 
 |  |  |   { | 
 |  |  |     title: formatMessage('common.operation', '操作'), | 
 |  |  |     name: 'oper', | 
 |  |  |     dataIndex: 'oper', | 
 |  |  |     key: 'oper', | 
 |  |  |     width: 140, | 
 |  |  |   }, | 
 |  |  | ]; | 
 |  |  |  | 
 |  |  | const hasSelected = computed(() => state.selectedRowKeys.length > 0); | 
 |  |  | const start = () => { | 
 |  |  |   state.loading = true; | 
 |  |  | 
 |  |  | }; | 
 |  |  |  | 
 |  |  | function getPage() { | 
 |  |  |   state.loading = true; | 
 |  |  |  | 
 |  |  |   post('/api/userLogin/page', { | 
 |  |  |     current: currentPage, | 
 |  |  |     pageSize: pageSize, | 
 |  |  | 
 |  |  |     if (result.code == 200) { | 
 |  |  |       let data = result.data; | 
 |  |  |       tableData.value = data; | 
 |  |  |  | 
 |  |  |       state.loading = false; | 
 |  |  |     } else if (result.code === 401) { | 
 |  |  |       message.error(result.msg); | 
 |  |  |       logout() | 
 |  |  | 
 |  |  |     content: formatMessage('page.delete.confirm', '确定删除该项吗?'), | 
 |  |  |     maskClosable: true, | 
 |  |  |     onOk: async () => { | 
 |  |  |       post('/api/userLogin/remove/' + rows.map((row) => row.id).join(','), {}).then(resp => { | 
 |  |  |         let result = resp.data; | 
 |  |  |         if (result.code === 200) { | 
 |  |  |           message.success(result.msg); | 
 |  |  |         } else { | 
 |  |  |           message.error(result.msg); | 
 |  |  |         } | 
 |  |  |         getPage() | 
 |  |  |       }) | 
 |  |  |       const hide = message.loading(formatMessage('common.loading', '请求中')); | 
 |  |  |       try { | 
 |  |  |         post('/api/userLogin/remove/' + rows.map((row) => row.id).join(','), {}).then(resp => { | 
 |  |  |           let result = resp.data; | 
 |  |  |           if (result.code === 200) { | 
 |  |  |             message.success(result.msg); | 
 |  |  |           } else { | 
 |  |  |             message.error(result.msg); | 
 |  |  |           } | 
 |  |  |           getPage() | 
 |  |  |           hide() | 
 |  |  |         }) | 
 |  |  |       } catch (error) { | 
 |  |  |         message.error(formatMessage('common.fail', '请求失败')); | 
 |  |  |       } | 
 |  |  |     }, | 
 |  |  |   }); | 
 |  |  | } | 
 |  |  |  | 
 |  |  | const handleExport = async (intl) => { | 
 |  |  |   postBlob('/api/userLogin/export', {}).then(result => { | 
 |  |  |   postBlob('/api/userLogin/export', { | 
 |  |  |     condition: searchInput.value | 
 |  |  |   }).then(result => { | 
 |  |  |     const blob = new Blob([result.data], { type: 'application/vnd.ms-excel' }); | 
 |  |  |     window.location.href = window.URL.createObjectURL(blob); | 
 |  |  |     return true; | 
 |  |  | 
 |  |  |     <a-table :row-selection="{ selectedRowKeys: state.selectedRowKeys, onChange: onSelectChange }" | 
 |  |  |       :data-source="tableData.records" :defaultExpandAllRows="false" :key="TABLE_KEY" rowKey="id" | 
 |  |  |       :pagination="{ total: tableData.total, onChange: onPageChange }" | 
 |  |  |       :scroll="{ y: 768, scrollToFirstRowOnChange: true }" :columns="columns"> | 
 |  |  |       :scroll="{ y: 768, scrollToFirstRowOnChange: true }" :columns="columns" :loading="state.loading"> | 
 |  |  |       <template #bodyCell="{ column, text, record }"> | 
 |  |  |         <template v-if="column.dataIndex === 'oper'"> | 
 |  |  |           <div style="display: flex;justify-content: space-evenly;"> | 
 |  |  | 
 |  |  |   </div> | 
 |  |  | </template> | 
 |  |  |  | 
 |  |  | <style></style> | 
 |  |  | <style></style> |