feat:【代码优化】减少部分模块的 import * 的 API

This commit is contained in:
YunaiV
2025-10-27 09:13:32 +08:00
parent b7d32e315b
commit d2db16c8c6
16 changed files with 115 additions and 94 deletions

View File

@@ -22,6 +22,7 @@ export namespace IoTOtaTaskRecordApi {
}
}
// TODO @AI这里应该拿到 IoTOtaTaskRecordApi 里
/** IoT OTA 升级任务记录 */
export interface OtaTaskRecord {
id?: number;

View File

@@ -26,7 +26,7 @@ import {
} from 'ant-design-vue';
import dayjs from 'dayjs';
import * as FormApi from '#/api/bpm/form';
import { getForm } from '#/api/bpm/form';
import {
HttpRequestSetting,
parseFormFields,
@@ -229,7 +229,7 @@ watch(
() => modelData.value.formId,
async (newFormId) => {
if (newFormId && modelData.value.formType === BpmModelFormType.NORMAL) {
const data = await FormApi.getForm(newFormId);
const data = await getForm(newFormId);
const result: Array<{ field: string; title: string }> = [];
if (data.fields) {
unParsedFormFields.value = data.fields;

View File

@@ -4,6 +4,7 @@ import type { FormInstance } from 'ant-design-vue';
import type { Rule } from 'ant-design-vue/es/form';
import type { BpmProcessInstanceApi } from '#/api/bpm/processInstance';
import type { SystemUserApi } from '#/api/system/user';
import { computed, nextTick, reactive, ref, watch } from 'vue';
import { useRouter } from 'vue-router';
@@ -42,8 +43,17 @@ import {
cancelProcessInstanceByStartUser,
getNextApprovalNodes,
} from '#/api/bpm/processInstance';
import * as TaskApi from '#/api/bpm/task';
import * as UserApi from '#/api/system/user';
import {
approveTask,
copyTask,
delegateTask,
getTaskListByReturn,
rejectTask,
returnTask,
signCreateTask,
signDeleteTask,
transferTask,
} from '#/api/bpm/task';
import { setConfAndFields2 } from '#/components/form-create';
import { $t } from '#/locales';
@@ -57,7 +67,7 @@ const props = defineProps<{
normalFormApi: any; // 流程表单 formCreate Api
processDefinition: any; // 流程定义信息
processInstance: any; // 流程实例信息
userOptions: UserApi.SystemUserApi.User[];
userOptions: SystemUserApi.User[];
writableFields: string[]; // 流程表单可以编辑的字段
}>(); // 当前登录的编号
const emit = defineEmits(['success']);
@@ -249,7 +259,7 @@ async function openPopover(type: string) {
}
if (type === 'return') {
// 获取退回节点
returnList.value = await TaskApi.getTaskListByReturn(runningTask.value.id);
returnList.value = await getTaskListByReturn(runningTask.value.id);
if (returnList.value.length === 0) {
message.warning('当前没有可退回的节点');
return;
@@ -375,7 +385,7 @@ async function handleAudit(pass: boolean, formRef: FormInstance | undefined) {
await formCreateApi.validate();
data.variables = approveForm.value.value;
}
await TaskApi.approveTask(data);
await approveTask(data);
popOverVisible.value.approve = false;
nextAssigneesActivityNode.value = [];
// 清理 Timeline 组件中的自定义审批人数据
@@ -389,7 +399,7 @@ async function handleAudit(pass: boolean, formRef: FormInstance | undefined) {
id: runningTask.value.id,
reason: rejectReasonForm.reason,
};
await TaskApi.rejectTask(data);
await rejectTask(data);
popOverVisible.value.reject = false;
message.success('审批不通过成功');
}
@@ -415,7 +425,7 @@ async function handleCopy() {
reason: copyForm.copyReason,
copyUserIds: copyForm.copyUserIds,
};
await TaskApi.copyTask(data);
await copyTask(data);
copyFormRef.value.resetFields();
popOverVisible.value.copy = false;
message.success($t('ui.actionMessage.operationSuccess'));
@@ -439,7 +449,7 @@ async function handleTransfer() {
reason: transferForm.reason,
assigneeUserId: transferForm.assigneeUserId,
};
await TaskApi.transferTask(data);
await transferTask(data);
transferFormRef.value.resetFields();
popOverVisible.value.transfer = false;
message.success($t('ui.actionMessage.operationSuccess'));
@@ -463,7 +473,7 @@ async function handleDelegate() {
reason: delegateForm.reason,
delegateUserId: delegateForm.delegateUserId,
};
await TaskApi.delegateTask(data);
await delegateTask(data);
popOverVisible.value.delegate = false;
delegateFormRef.value.resetFields();
message.success($t('ui.actionMessage.operationSuccess'));
@@ -488,7 +498,7 @@ async function handlerAddSign(type: string) {
reason: addSignForm.reason,
userIds: addSignForm.addSignUserIds,
};
await TaskApi.signCreateTask(data);
await signCreateTask(data);
message.success($t('ui.actionMessage.operationSuccess'));
addSignFormRef.value.resetFields();
popOverVisible.value.addSign = false;
@@ -512,7 +522,7 @@ async function handleReturn() {
reason: returnForm.returnReason,
targetTaskDefinitionKey: returnForm.targetTaskDefinitionKey,
};
await TaskApi.returnTask(data);
await returnTask(data);
popOverVisible.value.return = false;
returnFormRef.value.resetFields();
message.success($t('ui.actionMessage.operationSuccess'));
@@ -574,7 +584,7 @@ async function handlerDeleteSign() {
id: deleteSignForm.deleteSignTaskId,
reason: deleteSignForm.reason,
};
await TaskApi.signDeleteTask(data);
await signDeleteTask(data);
message.success('减签成功');
deleteSignFormRef.value.resetFields();
popOverVisible.value.deleteSign = false;

View File

@@ -5,11 +5,18 @@ import { Page } from '@vben/common-ui';
import { Badge, Card, List } from 'ant-design-vue';
import * as ClueApi from '#/api/crm/clue';
import * as ContractApi from '#/api/crm/contract';
import * as CustomerApi from '#/api/crm/customer';
import * as ReceivableApi from '#/api/crm/receivable';
import * as ReceivablePlanApi from '#/api/crm/receivable/plan';
import { getFollowClueCount } from '#/api/crm/clue';
import {
getAuditContractCount,
getRemindContractCount,
} from '#/api/crm/contract';
import {
getFollowCustomerCount,
getPutPoolRemindCustomerCount,
getTodayContactCustomerCount,
} from '#/api/crm/customer';
import { getAuditReceivableCount } from '#/api/crm/receivable';
import { getReceivablePlanRemindCount } from '#/api/crm/receivable/plan';
import { useLeftSides } from './data';
import ClueFollowList from './modules/clue-follow-list.vue';
@@ -64,17 +71,14 @@ function sideClick(item: { menu: string }) {
/** 获取数量 */
async function getCount() {
customerTodayContactCount.value =
await CustomerApi.getTodayContactCustomerCount();
customerPutPoolRemindCount.value =
await CustomerApi.getPutPoolRemindCustomerCount();
customerFollowCount.value = await CustomerApi.getFollowCustomerCount();
clueFollowCount.value = await ClueApi.getFollowClueCount();
contractAuditCount.value = await ContractApi.getAuditContractCount();
contractRemindCount.value = await ContractApi.getRemindContractCount();
receivableAuditCount.value = await ReceivableApi.getAuditReceivableCount();
receivablePlanRemindCount.value =
await ReceivablePlanApi.getReceivablePlanRemindCount();
customerTodayContactCount.value = await getTodayContactCustomerCount();
customerPutPoolRemindCount.value = await getPutPoolRemindCustomerCount();
customerFollowCount.value = await getFollowCustomerCount();
clueFollowCount.value = await getFollowClueCount();
contractAuditCount.value = await getAuditContractCount();
contractRemindCount.value = await getRemindContractCount();
receivableAuditCount.value = await getAuditReceivableCount();
receivablePlanRemindCount.value = await getReceivablePlanRemindCount();
}
/** 激活时 */

View File

@@ -8,8 +8,8 @@ import { formatDate } from '@vben/utils';
import { Card, Col, Descriptions, Row } from 'ant-design-vue';
import * as IoTOtaFirmwareApi from '#/api/iot/ota/firmware';
import * as IoTOtaTaskRecordApi from '#/api/iot/ota/task/record';
import { getOtaFirmware } from '#/api/iot/ota/firmware';
import { getOtaTaskRecordStatusStatistics } from '#/api/iot/ota/task/record';
import { IoTOtaTaskRecordStatusEnum } from '#/views/iot/utils/constants';
import OtaTaskList from '../task/OtaTaskList.vue';
@@ -30,7 +30,7 @@ const firmwareStatistics = ref<Record<string, number>>({});
async function getFirmwareInfo() {
firmwareLoading.value = true;
try {
firmware.value = await IoTOtaFirmwareApi.getOtaFirmware(firmwareId.value);
firmware.value = await getOtaFirmware(firmwareId.value);
} finally {
firmwareLoading.value = false;
}
@@ -40,10 +40,9 @@ async function getFirmwareInfo() {
async function getStatistics() {
firmwareStatisticsLoading.value = true;
try {
firmwareStatistics.value =
await IoTOtaTaskRecordApi.getOtaTaskRecordStatusStatistics(
firmwareId.value,
);
firmwareStatistics.value = await getOtaTaskRecordStatusStatistics(
firmwareId.value,
);
} finally {
firmwareStatisticsLoading.value = false;
}

View File

@@ -8,8 +8,8 @@ import { formatDate } from '@vben/utils';
import { Card, Col, Descriptions, Row } from 'ant-design-vue';
import * as IoTOtaFirmwareApi from '#/api/iot/ota/firmware';
import * as IoTOtaTaskRecordApi from '#/api/iot/ota/task/record';
import { getOtaFirmware } from '#/api/iot/ota/firmware';
import { getOtaTaskRecordStatusStatistics } from '#/api/iot/ota/task/record';
import { IoTOtaTaskRecordStatusEnum } from '#/views/iot/utils/constants';
import OtaTaskList from '../task/OtaTaskList.vue';
@@ -30,7 +30,7 @@ const firmwareStatistics = ref<Record<string, number>>({});
async function getFirmwareInfo() {
firmwareLoading.value = true;
try {
firmware.value = await IoTOtaFirmwareApi.getOtaFirmware(firmwareId.value);
firmware.value = await getOtaFirmware(firmwareId.value);
} finally {
firmwareLoading.value = false;
}
@@ -40,10 +40,9 @@ async function getFirmwareInfo() {
async function getStatistics() {
firmwareStatisticsLoading.value = true;
try {
firmwareStatistics.value =
await IoTOtaTaskRecordApi.getOtaTaskRecordStatusStatistics(
firmwareId.value,
);
firmwareStatistics.value = await getOtaTaskRecordStatusStatistics(
firmwareId.value,
);
} finally {
firmwareStatisticsLoading.value = false;
}

View File

@@ -21,8 +21,12 @@ import {
Tag,
} from 'ant-design-vue';
import * as IoTOtaTaskApi from '#/api/iot/ota/task';
import * as IoTOtaTaskRecordApi from '#/api/iot/ota/task/record';
import { getOtaTask } from '#/api/iot/ota/task';
import {
cancelOtaTaskRecord,
getOtaTaskRecordPage,
getOtaTaskRecordStatusStatistics,
} from '#/api/iot/ota/task/record';
import { IoTOtaTaskRecordStatusEnum } from '#/views/iot/utils/constants';
/** OTA 任务详情组件 */
@@ -119,7 +123,7 @@ async function getTaskInfo() {
}
taskLoading.value = true;
try {
task.value = await IoTOtaTaskApi.getOtaTask(taskId.value);
task.value = await getOtaTask(taskId.value);
} finally {
taskLoading.value = false;
}
@@ -132,11 +136,10 @@ async function getStatistics() {
}
taskStatisticsLoading.value = true;
try {
taskStatistics.value =
await IoTOtaTaskRecordApi.getOtaTaskRecordStatusStatistics(
undefined,
taskId.value,
);
taskStatistics.value = await getOtaTaskRecordStatusStatistics(
undefined,
taskId.value,
);
} finally {
taskStatisticsLoading.value = false;
}
@@ -150,7 +153,7 @@ async function getRecordList() {
recordLoading.value = true;
try {
queryParams.taskId = taskId.value;
const data = await IoTOtaTaskRecordApi.getOtaTaskRecordPage(queryParams);
const data = await getOtaTaskRecordPage(queryParams);
recordList.value = data.list || [];
recordTotal.value = data.total || 0;
} finally {
@@ -181,7 +184,7 @@ async function handleCancelUpgrade(record: OtaTaskRecord) {
content: '确认要取消该设备的升级任务吗?',
async onOk() {
try {
await IoTOtaTaskRecordApi.cancelOtaTaskRecord(record.id!);
await cancelOtaTaskRecord(record.id!);
message.success('取消成功');
await getRecordList();
await getStatistics();

View File

@@ -8,8 +8,8 @@ import { useVbenModal } from '@vben/common-ui';
import { Form, Input, message, Select, Spin } from 'ant-design-vue';
import * as DeviceApi from '#/api/iot/device/device';
import * as IoTOtaTaskApi from '#/api/iot/ota/task';
import { getDeviceListByProductId } from '#/api/iot/device/device';
import { createOtaTask } from '#/api/iot/ota/task';
import { IoTOtaTaskDeviceScopeEnum } from '#/views/iot/utils/constants';
/** IoT OTA 升级任务表单 */
@@ -82,7 +82,7 @@ const [Modal, modalApi] = useVbenModal({
try {
await formRef.value.validate();
modalApi.lock();
await IoTOtaTaskApi.createOtaTask(formData.value);
await createOtaTask(formData.value);
message.success('创建成功');
await modalApi.close();
emit('success');
@@ -98,8 +98,7 @@ const [Modal, modalApi] = useVbenModal({
// 加载设备列表
formLoading.value = true;
try {
devices.value =
(await DeviceApi.getDeviceListByProductId(props.productId)) || [];
devices.value = (await getDeviceListByProductId(props.productId)) || [];
} finally {
formLoading.value = false;
}

View File

@@ -19,7 +19,7 @@ import {
Tag,
} from 'ant-design-vue';
import * as IoTOtaTaskApi from '#/api/iot/ota/task';
import { getOtaTaskPage } from '#/api/iot/ota/task';
import { IoTOtaTaskStatusEnum } from '#/views/iot/utils/constants';
import OtaTaskDetail from './OtaTaskDetail.vue';
@@ -52,7 +52,7 @@ const taskDetailRef = ref(); // 任务详情引用
async function getTaskList() {
taskLoading.value = true;
try {
const data = await IoTOtaTaskApi.getOtaTaskPage(queryParams);
const data = await getOtaTaskPage(queryParams);
taskList.value = data.list;
taskTotal.value = data.total;
} finally {

View File

@@ -3,7 +3,7 @@ import { computed, onMounted, ref } from 'vue';
import { handleTree } from '@vben/utils';
import * as ProductCategoryApi from '#/api/mall/product/category';
import { getCategoryList } from '#/api/mall/product/category';
/** 商品分类选择组件 */
defineOptions({ name: 'ProductCategorySelect' });
@@ -43,7 +43,7 @@ const selectCategoryId = computed({
const categoryList = ref<any[]>([]); // 分类树
onMounted(async () => {
// 获得分类树
const data = await ProductCategoryApi.getCategoryList({
const data = await getCategoryList({
parentId: props.parentId,
});
categoryList.value = handleTree(data, 'id', 'parentId');

View File

@@ -6,7 +6,10 @@ import { useRoute } from 'vue-router';
import { message } from 'ant-design-vue';
import * as DiyPageApi from '#/api/mall/promotion/diy/page';
import {
getDiyPageProperty,
updateDiyPageProperty,
} from '#/api/mall/promotion/diy/page';
import { DiyEditor, PAGE_LIBS } from '#/views/mall/promotion/components';
/** 装修页面表单 */
@@ -23,7 +26,7 @@ async function getPageDetail(id: any) {
duration: 0,
});
try {
formData.value = await DiyPageApi.getDiyPageProperty(id);
formData.value = await getDiyPageProperty(id);
} finally {
hideLoading();
}
@@ -36,7 +39,7 @@ async function submitForm() {
duration: 0,
});
try {
await DiyPageApi.updateDiyPageProperty(unref(formData)!);
await updateDiyPageProperty(unref(formData)!);
message.success('保存成功');
} finally {
hideLoading();

View File

@@ -13,8 +13,11 @@ import { isEmpty } from '@vben/utils';
import { message, Radio, RadioGroup, Tooltip } from 'ant-design-vue';
import * as DiyPageApi from '#/api/mall/promotion/diy/page';
import * as DiyTemplateApi from '#/api/mall/promotion/diy/template';
import { updateDiyPageProperty } from '#/api/mall/promotion/diy/page';
import {
getDiyTemplateProperty,
updateDiyTemplateProperty,
} from '#/api/mall/promotion/diy/template';
import { DiyEditor, PAGE_LIBS } from '#/views/mall/promotion/components';
/** 装修模板表单 */
@@ -54,7 +57,7 @@ async function getPageDetail(id: any) {
duration: 0,
});
try {
formData.value = await DiyTemplateApi.getDiyTemplateProperty(id);
formData.value = await getDiyTemplateProperty(id);
// 拼接手机预览链接
const domain = import.meta.env.VITE_MALL_H5_DOMAIN;
@@ -112,20 +115,18 @@ async function submitForm() {
// 情况一:基础设置
if (i === 0) {
// 提交模板属性
await DiyTemplateApi.updateDiyTemplateProperty(
isEmpty(data) ? formData.value! : data,
);
await updateDiyTemplateProperty(isEmpty(data) ? formData.value! : data);
continue;
}
// 提交页面属性
// 情况二:提交当前正在编辑的页面
if (currentFormData.value?.name.includes(templateItem.name)) {
await DiyPageApi.updateDiyPageProperty(currentFormData.value!);
await updateDiyPageProperty(currentFormData.value!);
continue;
}
// 情况三:提交页面编辑缓存
if (!isEmpty(data)) {
await DiyPageApi.updateDiyPageProperty(data!);
await updateDiyPageProperty(data!);
}
}
message.success('保存成功');

View File

@@ -11,7 +11,7 @@ import { formatDateTime } from '@vben/utils';
import { Card } from 'ant-design-vue';
import { useVbenVxeGrid } from '#/adapter/vxe-table';
import * as ProductStatisticsApi from '#/api/mall/statistics/product';
import { getProductStatisticsRankPage } from '#/api/mall/statistics/product';
import ShortcutDateRangePicker from '#/components/shortcut-date-range-picker/shortcut-date-range-picker.vue';
/** 商品排行 */
@@ -104,7 +104,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
proxyConfig: {
ajax: {
query: async ({ page, sorts }) => {
return await ProductStatisticsApi.getProductStatisticsRankPage({
return await getProductStatisticsRankPage({
pageNo: page.currentPage,
pageSize: page.pageSize,
times: searchTimes.value.length > 0 ? searchTimes.value : undefined,

View File

@@ -9,7 +9,7 @@ import { $t } from '@vben/locales';
import { message } from 'ant-design-vue';
import { useVbenForm } from '#/adapter/form';
import * as AfterSaleApi from '#/api/mall/trade/afterSale/index';
import { disagreeAfterSale } from '#/api/mall/trade/afterSale';
import { useDisagreeFormSchema } from '../data';
@@ -40,7 +40,7 @@ const [Modal, modalApi] = useVbenModal({
try {
const data =
(await formApi.getValues()) as MallAfterSaleApi.DisagreeRequest;
await AfterSaleApi.disagreeAfterSale(data);
await disagreeAfterSale(data);
// 关闭并提示
await modalApi.close();
emit('success');

View File

@@ -18,9 +18,13 @@ import { useTabs } from '@vben/hooks';
import { Card, message, Tag } from 'ant-design-vue';
import { useVbenVxeGrid } from '#/adapter/vxe-table';
import * as DeliveryExpressApi from '#/api/mall/trade/delivery/express';
import * as DeliveryPickUpStoreApi from '#/api/mall/trade/delivery/pickUpStore';
import * as TradeOrderApi from '#/api/mall/trade/order';
import { getSimpleDeliveryExpressList } from '#/api/mall/trade/delivery/express';
import { getDeliveryPickUpStore } from '#/api/mall/trade/delivery/pickUpStore';
import {
getExpressTrackList,
getOrder,
pickUpOrder,
} from '#/api/mall/trade/order';
import { useDescription } from '#/components/description';
import { DictTag } from '#/components/dict-tag';
import { TableAction } from '#/components/table-action';
@@ -157,7 +161,7 @@ const [PriceFormModal, priceFormModalApi] = useVbenModal({
async function getDetail() {
loading.value = true;
try {
const res = await TradeOrderApi.getOrder(orderId.value);
const res = await getOrder(orderId.value);
if (res === null) {
message.error('交易订单不存在');
handleBack();
@@ -169,12 +173,9 @@ async function getDetail() {
// 如果配送方式为快递,则查询物流公司
if (res.deliveryType === DeliveryTypeEnum.EXPRESS.type) {
deliveryExpressList.value =
await DeliveryExpressApi.getSimpleDeliveryExpressList();
deliveryExpressList.value = await getSimpleDeliveryExpressList();
if (res.logisticsId) {
expressTrackList.value = await TradeOrderApi.getExpressTrackList(
res.id!,
);
expressTrackList.value = await getExpressTrackList(res.id!);
expressTrackGridApi.setGridOptions({
data: expressTrackList.value || [],
});
@@ -183,9 +184,7 @@ async function getDetail() {
res.deliveryType === DeliveryTypeEnum.PICK_UP.type &&
res.pickUpStoreId
) {
pickUpStore.value = await DeliveryPickUpStoreApi.getDeliveryPickUpStore(
res.pickUpStoreId,
);
pickUpStore.value = await getDeliveryPickUpStore(res.pickUpStoreId);
}
} finally {
loading.value = false;
@@ -217,7 +216,7 @@ const handlePickUp = async () => {
duration: 0,
});
try {
await TradeOrderApi.pickUpOrder(order.value.id!);
await pickUpOrder(order.value.id!);
message.success('核销成功');
await getDetail();
} finally {

View File

@@ -6,7 +6,10 @@ import { useRoute } from 'vue-router';
import { ElLoading, ElMessage } from 'element-plus';
import * as DiyPageApi from '#/api/mall/promotion/diy/page';
import {
getDiyPageProperty,
updateDiyPageProperty,
} from '#/api/mall/promotion/diy/page';
import { DiyEditor, PAGE_LIBS } from '#/views/mall/promotion/components';
/** 装修页面表单 */
@@ -22,7 +25,7 @@ async function getPageDetail(id: any) {
text: '加载中...',
});
try {
formData.value = await DiyPageApi.getDiyPageProperty(id);
formData.value = await getDiyPageProperty(id);
} finally {
loadingInstance.close();
}
@@ -34,7 +37,7 @@ async function submitForm() {
text: '保存中...',
});
try {
await DiyPageApi.updateDiyPageProperty(unref(formData)!);
await updateDiyPageProperty(unref(formData)!);
ElMessage.success('保存成功');
} finally {
loadingInstance.close();