1、系统级别数据字典同步

This commit is contained in:
1378012178@qq.com 2025-05-08 16:22:07 +08:00
parent b2c1554aab
commit a504218a39
3 changed files with 78 additions and 13 deletions

View File

@ -1,12 +1,12 @@
import { defHttp } from '/@/utils/http/axios'; import { defHttp } from '/@/utils/http/axios';
import { useMessage } from "/@/hooks/web/useMessage"; import { useMessage } from '/@/hooks/web/useMessage';
const { createConfirm } = useMessage(); const { createConfirm } = useMessage();
enum Api { enum Api {
list = '/asyncmain/asyncMain/list', list = '/asyncmain/asyncMain/list',
save='/asyncmain/asyncMain/add', save = '/asyncmain/asyncMain/add',
edit='/asyncmain/asyncMain/edit', edit = '/asyncmain/asyncMain/edit',
deleteOne = '/asyncmain/asyncMain/delete', deleteOne = '/asyncmain/asyncMain/delete',
deleteBatch = '/asyncmain/asyncMain/deleteBatch', deleteBatch = '/asyncmain/asyncMain/deleteBatch',
importExcel = '/asyncmain/asyncMain/importExcel', importExcel = '/asyncmain/asyncMain/importExcel',
@ -35,11 +35,11 @@ export const list = (params) => defHttp.get({ url: Api.list, params });
* @param params * @param params
* @param handleSuccess * @param handleSuccess
*/ */
export const deleteOne = (params,handleSuccess) => { export const deleteOne = (params, handleSuccess) => {
return defHttp.delete({url: Api.deleteOne, params}, {joinParamsToUrl: true}).then(() => { return defHttp.delete({ url: Api.deleteOne, params }, { joinParamsToUrl: true }).then(() => {
handleSuccess(); handleSuccess();
}); });
} };
/** /**
* *
@ -54,12 +54,12 @@ export const batchDelete = (params, handleSuccess) => {
okText: '确认', okText: '确认',
cancelText: '取消', cancelText: '取消',
onOk: () => { onOk: () => {
return defHttp.delete({url: Api.deleteBatch, data: params}, {joinParamsToUrl: true}).then(() => { return defHttp.delete({ url: Api.deleteBatch, data: params }, { joinParamsToUrl: true }).then(() => {
handleSuccess(); handleSuccess();
}); });
} },
}); });
} };
/** /**
* *
@ -69,4 +69,5 @@ export const batchDelete = (params, handleSuccess) => {
export const saveOrUpdate = (params, isUpdate) => { export const saveOrUpdate = (params, isUpdate) => {
let url = isUpdate ? Api.edit : Api.save; let url = isUpdate ? Api.edit : Api.save;
return defHttp.post({ url: url, params }, { isTransformResponse: false }); return defHttp.post({ url: url, params }, { isTransformResponse: false });
} };

View File

@ -22,6 +22,7 @@ enum Api {
refreshCache = '/sys/dict/refleshCache', refreshCache = '/sys/dict/refleshCache',
queryAllDictItems = '/sys/dict/queryAllDictItems', queryAllDictItems = '/sys/dict/queryAllDictItems',
async = '/sys/dict/async', async = '/sys/dict/async',
listByType = '/asyncmain/asyncMain/listByType',
} }
/** /**
* api * api
@ -163,3 +164,12 @@ export const queryAllDictItems = () => defHttp.get({ url: Api.queryAllDictItems
export const asyncData = (params) => { export const asyncData = (params) => {
return defHttp.post({ url: Api.async, params }); return defHttp.post({ url: Api.async, params });
}; };
/**
*
* @param params
* @returns
*/
export const listByType = (params) => {
return defHttp.post({ url: Api.listByType, params });
};

View File

@ -34,11 +34,28 @@
<DictItemList @register="registerDrawer" /> <DictItemList @register="registerDrawer" />
<!--回收站弹窗--> <!--回收站弹窗-->
<DictRecycleBinModal @register="registerModal1" @success="reload" /> <DictRecycleBinModal @register="registerModal1" @success="reload" />
<a-modal v-model:open="showAsyncResult" title="同步结果" @ok="showAsyncResult = false" width="70vw">
<a-tabs v-model:activeKey="activeTabKey" style="margin-left: 10px;margin-right: 10px;margin-bottom: 10px;">
<a-tab-pane key="error" :tab="`同步异常 (${errorList.length})`">
<a-table :dataSource="errorList" :columns="resultColumns" :pagination="false" size="small" bordered
:scroll="{ y: '50vh' }" />
</a-tab-pane>
<a-tab-pane key="processing" :tab="`同步中/待同步 (${processingList.length})`">
<a-table :dataSource="processingList" :columns="resultColumns" :pagination="false" size="small" bordered
:scroll="{ y: '50vh' }" />
</a-tab-pane>
<a-tab-pane key="success" :tab="`同步完成 (${successList.length})`">
<a-table :dataSource="successList" :columns="resultColumns" :pagination="false" size="small" bordered
:scroll="{ y: '50vh' }" />
</a-tab-pane>
</a-tabs>
</a-modal>
</template> </template>
<script lang="ts" name="system-dict" setup> <script lang="ts" name="system-dict" setup>
//ts //ts
import { ref, computed, unref } from 'vue'; import { ref, computed, unref, nextTick } from 'vue';
import { BasicTable, TableAction } from '/src/components/Table'; import { BasicTable, TableAction } from '/src/components/Table';
import { useDrawer } from '/src/components/Drawer'; import { useDrawer } from '/src/components/Drawer';
import { useModal } from '/src/components/Modal'; import { useModal } from '/src/components/Modal';
@ -48,10 +65,33 @@ import DictRecycleBinModal from './components/DictRecycleBinModal.vue';
import { useMessage } from '/src/hooks/web/useMessage'; import { useMessage } from '/src/hooks/web/useMessage';
import { removeAuthCache, setAuthCache } from '/src/utils/auth'; import { removeAuthCache, setAuthCache } from '/src/utils/auth';
import { columns, searchFormSchema } from './dict.data'; import { columns, searchFormSchema } from './dict.data';
import { list, deleteDict, batchDeleteDict, getExportUrl, getImportUrl, refreshCache, queryAllDictItems, asyncData } from './dict.api'; import { list, deleteDict, batchDeleteDict, getExportUrl, getImportUrl, refreshCache, queryAllDictItems, asyncData, listByType } from './dict.api';
import { DB_DICT_DATA_KEY } from '/src/enums/cacheEnum'; import { DB_DICT_DATA_KEY } from '/src/enums/cacheEnum';
import { useUserStore } from '/@/store/modules/user'; import { useUserStore } from '/@/store/modules/user';
const showAsyncResult = ref(false)
const activeTabKey = ref('error');
const errorList = ref<Recordable[]>([]);
const processingList = ref<Recordable[]>([]);
const successList = ref<Recordable[]>([]);
const resultColumns = [
{
title: '机构名称',
dataIndex: 'orgName',
key: 'orgName',
},
{
title: '机构编码',
dataIndex: 'orgCode',
key: 'orgCode',
},
{
title: '备注',
dataIndex: 'descr',
key: 'descr',
}
];
const { createMessage } = useMessage(); const { createMessage } = useMessage();
//model //model
const [registerModal, { openModal }] = useModal(); const [registerModal, { openModal }] = useModal();
@ -212,12 +252,26 @@ function handleAsync(record) {
createMessage.success("操作成功,请在同步结果中进行查看!") createMessage.success("操作成功,请在同步结果中进行查看!")
}) })
} }
/** /**
* 同步结果 * 同步结果
*/ */
function AsyncResultFunc(record) { function AsyncResultFunc(record) {
console.log("🌊 ~ AsyncResultFunc ~ record:", record) showAsyncResult.value = true;
activeTabKey.value = 'error';
//
errorList.value = [];
processingList.value = [];
successList.value = [];
listByType({ primaryKey: record.id }).then(res => {
if (res) {
errorList.value = res.errorList || [];
processingList.value = res.processingList || [];
successList.value = res.successList || [];
}
});
} }
</script> </script>