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,5 +1,5 @@
import { defHttp } from '/@/utils/http/axios';
import { useMessage } from "/@/hooks/web/useMessage";
import { useMessage } from '/@/hooks/web/useMessage';
const { createConfirm } = useMessage();
@ -39,7 +39,7 @@ export const deleteOne = (params,handleSuccess) => {
return defHttp.delete({ url: Api.deleteOne, params }, { joinParamsToUrl: true }).then(() => {
handleSuccess();
});
}
};
/**
*
@ -57,9 +57,9 @@ export const batchDelete = (params, handleSuccess) => {
return defHttp.delete({ url: Api.deleteBatch, data: params }, { joinParamsToUrl: true }).then(() => {
handleSuccess();
});
}
},
});
}
};
/**
*
@ -69,4 +69,5 @@ export const batchDelete = (params, handleSuccess) => {
export const saveOrUpdate = (params, isUpdate) => {
let url = isUpdate ? Api.edit : Api.save;
return defHttp.post({ url: url, params }, { isTransformResponse: false });
}
};

View File

@ -22,6 +22,7 @@ enum Api {
refreshCache = '/sys/dict/refleshCache',
queryAllDictItems = '/sys/dict/queryAllDictItems',
async = '/sys/dict/async',
listByType = '/asyncmain/asyncMain/listByType',
}
/**
* api
@ -163,3 +164,12 @@ export const queryAllDictItems = () => defHttp.get({ url: Api.queryAllDictItems
export const asyncData = (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" />
<!--回收站弹窗-->
<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>
<script lang="ts" name="system-dict" setup>
//ts
import { ref, computed, unref } from 'vue';
import { ref, computed, unref, nextTick } from 'vue';
import { BasicTable, TableAction } from '/src/components/Table';
import { useDrawer } from '/src/components/Drawer';
import { useModal } from '/src/components/Modal';
@ -48,10 +65,33 @@ import DictRecycleBinModal from './components/DictRecycleBinModal.vue';
import { useMessage } from '/src/hooks/web/useMessage';
import { removeAuthCache, setAuthCache } from '/src/utils/auth';
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 { 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();
//model
const [registerModal, { openModal }] = useModal();
@ -212,12 +252,26 @@ function handleAsync(record) {
createMessage.success("操作成功,请在同步结果中进行查看!")
})
}
/**
* 同步结果
*/
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>