From b05d6e16ad0f53e69c75098d36357b9c3cd5d15b Mon Sep 17 00:00:00 2001 From: expressgy Date: Mon, 8 Jul 2024 21:38:30 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84=E5=AD=97=E5=85=B8=EF=BC=8C?= =?UTF-8?q?=E5=9F=BA=E6=9C=AC=E5=8A=9F=E8=83=BD=E5=AE=8C=E6=88=90=EF=BC=8C?= =?UTF-8?q?=E4=B8=8B=E4=B8=80=E6=AD=A5=EF=BC=8C=E8=8F=9C=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/http.js | 6 +++++ src/views/Auth/Dict/DictTable.vue | 3 ++- src/views/Auth/Dict/index.vue | 37 ++++++++++++++++++++----------- 3 files changed, 32 insertions(+), 14 deletions(-) diff --git a/src/api/http.js b/src/api/http.js index 3280aea..64c7351 100644 --- a/src/api/http.js +++ b/src/api/http.js @@ -48,6 +48,7 @@ service.interceptors.request.use( } else if (config.url === '/authUser/sign/refresh') { // ! 刷新Token请求,传入RefreshToken config.headers.Authorization = `Bearer ${systemStore.state.refreshToken}`; + config.isRefresh = true; } else { if (isExpired) { // ! 等待刷新token后放行 @@ -73,6 +74,11 @@ service.interceptors.response.use( // ! 正常响应,返回数据 return data.data; } else if (data.statusCode === 403) { + if(response.config.isRefresh === true){ + systemStore.goBackSignin(); + window.pino.fatal('RefreshToken过期'); + return + } // ! WARN ============================================ window.pino.error('Token过期'); diff --git a/src/views/Auth/Dict/DictTable.vue b/src/views/Auth/Dict/DictTable.vue index d0d1eaf..3ad0d7c 100644 --- a/src/views/Auth/Dict/DictTable.vue +++ b/src/views/Auth/Dict/DictTable.vue @@ -49,7 +49,7 @@ const tableColumnObject = { dictIcon: { title: '字典图标', dataIndex: 'dictIcon', - customRender: ({ text, record, index, column }) => (text ? h(IconPool[text], { style: { fontSize: '20px' } }) : null), + customRender: ({ text, record, index, column }) => (text && IconPool[text] ? h(IconPool[text], { style: { fontSize: '20px' } }) : h('div', text)), key: 'dictIcon', }, dictType: { @@ -74,6 +74,7 @@ const tableColumnObject = { dataIndex: 'createtime', key: 'createtime', width: '140px', + sorter: true, }, createName: { title: '创建人', diff --git a/src/views/Auth/Dict/index.vue b/src/views/Auth/Dict/index.vue index f503c06..90082e3 100644 --- a/src/views/Auth/Dict/index.vue +++ b/src/views/Auth/Dict/index.vue @@ -51,7 +51,7 @@ const formData = reactive({ const tableData = reactive({ dataSource: [], methods: { - handleTableChange: () => {}, + handleTableChange, handleRemoveAck, handleUpdate, }, @@ -89,6 +89,7 @@ async function handleCreateAck(data) { clearSearchData(); clearFormData(); getPage(); + baseDataStore.getDictList(); } // ! 确认删除 async function handleRemoveAck(data) { @@ -98,6 +99,7 @@ async function handleRemoveAck(data) { tableData.pageInfo.pageNumber--; } getPage(); + baseDataStore.getDictList(); } // ! 更新数据 async function handleUpdate(data) { @@ -122,6 +124,7 @@ async function handleUpdateAck(data) { Message.success('更新字典成功!'); clearFormData(); getPage(); + baseDataStore.getDictList(); } // ! 监听筛选 watch(tableData.pageInfo, () => { @@ -137,11 +140,20 @@ watch(tableData.pageInfo, () => { }); // ! 获取表格数据 async function getPage() { - baseDataStore.getDictList(); const resd = await CoreDict.getDict(tableData.pageInfo); tableData.dataSource = resd.rowData; tableData.total = Number(resd.total); } +// ! 表格筛选变动 +function handleTableChange(page, filter, sorter){ + if (sorter.order == 'ascend') { + tableData.pageInfo.isAsc = true; + } else if (sorter.order == 'descend') { + tableData.pageInfo.isAsc = false; + } else { + tableData.pageInfo.isAsc = undefined; + } +} // ! 页码变动 const handlePageChange = (page, pageSize) => { tableData.pageInfo.pageSize = pageSize; @@ -150,17 +162,15 @@ const handlePageChange = (page, pageSize) => { }; // ! 清除筛选条件 function clearSearchData() { - tableData.pageInfo = { - pageSize: 10, - pageNumber: 1, - isList: false, - isAsc: false, - dictInfo: undefined, - dictType: undefined, - root: undefined, - serviceKey: undefined, - status: undefined, - }; + tableData.pageInfo.pageSize=10; + tableData.pageInfo.pageNumber= 1; + tableData.pageInfo.isList= false; + tableData.pageInfo.isAsc= false; + tableData.pageInfo.dictInfo= undefined; + tableData.pageInfo.dictType=undefined; + tableData.pageInfo.root=undefined; + tableData.pageInfo.serviceKey=undefined; + tableData.pageInfo.status=undefined; } // ! 清除编辑数据 function clearFormData() { @@ -180,6 +190,7 @@ function clearFormData() { formData.formData.orderNum = 0; } onMounted(() => { + baseDataStore.getDictList(); getPage(); if (baseDataStore.state.serviceList.length == 0) { baseDataStore.getServiceList();