1、系统级别数据字典同步
This commit is contained in:
parent
b2c1554aab
commit
a504218a39
|
@ -1,12 +1,12 @@
|
|||
import { defHttp } from '/@/utils/http/axios';
|
||||
import { useMessage } from "/@/hooks/web/useMessage";
|
||||
import { useMessage } from '/@/hooks/web/useMessage';
|
||||
|
||||
const { createConfirm } = useMessage();
|
||||
|
||||
enum Api {
|
||||
list = '/asyncmain/asyncMain/list',
|
||||
save='/asyncmain/asyncMain/add',
|
||||
edit='/asyncmain/asyncMain/edit',
|
||||
save = '/asyncmain/asyncMain/add',
|
||||
edit = '/asyncmain/asyncMain/edit',
|
||||
deleteOne = '/asyncmain/asyncMain/delete',
|
||||
deleteBatch = '/asyncmain/asyncMain/deleteBatch',
|
||||
importExcel = '/asyncmain/asyncMain/importExcel',
|
||||
|
@ -35,11 +35,11 @@ export const list = (params) => defHttp.get({ url: Api.list, params });
|
|||
* @param params
|
||||
* @param handleSuccess
|
||||
*/
|
||||
export const deleteOne = (params,handleSuccess) => {
|
||||
return defHttp.delete({url: Api.deleteOne, params}, {joinParamsToUrl: true}).then(() => {
|
||||
export const deleteOne = (params, handleSuccess) => {
|
||||
return defHttp.delete({ url: Api.deleteOne, params }, { joinParamsToUrl: true }).then(() => {
|
||||
handleSuccess();
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 批量删除
|
||||
|
@ -54,12 +54,12 @@ export const batchDelete = (params, handleSuccess) => {
|
|||
okText: '确认',
|
||||
cancelText: '取消',
|
||||
onOk: () => {
|
||||
return defHttp.delete({url: Api.deleteBatch, data: params}, {joinParamsToUrl: true}).then(() => {
|
||||
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 });
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@ enum Api {
|
|||
refreshCache = '/sys/dict/refleshCache',
|
||||
queryAllDictItems = '/sys/dict/queryAllDictItems',
|
||||
async = '/sys/dict/async',
|
||||
listByType = '/asyncmain/asyncMain/listByType',
|
||||
}
|
||||
/**
|
||||
* 导出api
|
||||
|
@ -162,4 +163,13 @@ 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 });
|
||||
};
|
|
@ -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>
|
||||
|
||||
|
|
Loading…
Reference in New Issue