From 25708e3f81956c1517f495e3303a6c8d08bb730c Mon Sep 17 00:00:00 2001
From: zhengyiming <540361168@qq.com>
Date: 星期四, 25 十二月 2025 16:09:02 +0800
Subject: [PATCH] fix: 甲方小程序
---
packages/hooks/standardOrder.ts | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 54 insertions(+), 0 deletions(-)
diff --git a/packages/hooks/standardOrder.ts b/packages/hooks/standardOrder.ts
index 6c7f9d2..d18be38 100644
--- a/packages/hooks/standardOrder.ts
+++ b/packages/hooks/standardOrder.ts
@@ -1,6 +1,7 @@
import { useQuery, useQueryClient } from '@tanstack/vue-query';
import * as standardServiceServices from '@12333/services/apiV2/standardService';
import { computed, MaybeRef, unref } from 'vue';
+import { groupBy } from 'lodash';
type UseStandardServiceDetailOptions = {
id: MaybeRef<string>;
@@ -41,3 +42,56 @@
minPrice,
};
}
+
+type UseStandardServiceListOptions = {
+ params?: MaybeRef<API.GetOpenStandardServiceListQuery>;
+ onSuccess?: (data: API.GetStandardServicesQueryResultItem[]) => any;
+};
+
+export function useStandardServiceList(options: UseStandardServiceListOptions = {}) {
+ const { params = {}, onSuccess } = options;
+ const {
+ data: standardServiceList,
+ refetch,
+ isLoading,
+ isError,
+ } = useQuery({
+ queryKey: ['standardServiceServices/getOpenStandardServiceList', params],
+ queryFn: async () => {
+ return await standardServiceServices.getOpenStandardServiceList(unref(params), {
+ showLoading: false,
+ });
+ },
+ placeholderData: () => [] as API.GetStandardServicesQueryResultItem[],
+ onSuccess(data) {
+ onSuccess?.(data);
+ },
+ });
+
+ const standardServiceListForCategory = computed(() => {
+ return standardServiceList.value.map((x) => ({
+ ...x,
+ catName: x.name,
+ }));
+ });
+
+ const standardServiceListForCategoryMap = computed(() => {
+ const group = groupBy(standardServiceListForCategory.value, 'jobCode');
+ return group;
+ });
+
+ const queryClient = useQueryClient();
+
+ function ensureStandardServiceList() {
+ return queryClient.ensureQueryData<API.GetStandardServicesQueryResultItem[]>({
+ queryKey: ['standardServiceServices/getOpenStandardServiceList', params],
+ });
+ }
+
+ return {
+ standardServiceList,
+ ensureStandardServiceList,
+ standardServiceListForCategory,
+ standardServiceListForCategoryMap,
+ };
+}
--
Gitblit v1.10.0