|
@@ -1,9 +1,11 @@
|
|
|
import { sendFetch, PageProps } from './index'
|
|
|
-import { ResPage } from './type'
|
|
|
+import { ResPage, ResResult } from './type'
|
|
|
import { organizationTypeEnum } from '@/store/organization'
|
|
|
import * as URL from "./URL";
|
|
|
-
|
|
|
-//
|
|
|
+import { ElMessage } from "element-plus";
|
|
|
+import { throttle } from "@/util";
|
|
|
+const error = throttle((msg: string) => ElMessage.error(msg), 2000);
|
|
|
+const success = throttle((msg: string) => ElMessage.success(msg), 2000);
|
|
|
|
|
|
export type OrganizationType = {
|
|
|
ancestors: string
|
|
@@ -20,11 +22,27 @@ export type OrganizationType = {
|
|
|
|
|
|
}
|
|
|
|
|
|
-export const addOrgFetch = (params: Partial<OrganizationType>) =>
|
|
|
- sendFetch<PageProps<OrganizationType>>(URL.addOrganization, {
|
|
|
+export const addOrgFetch = async (params: Partial<OrganizationType>) => {
|
|
|
+ const api = await sendFetch<ResResult>(URL.addOrganization, {
|
|
|
method: "post",
|
|
|
body: JSON.stringify(params),
|
|
|
+ }, {
|
|
|
+ useResult: true
|
|
|
});
|
|
|
+ if (api.code === 0) {
|
|
|
+ success('添加成功')
|
|
|
+ } else {
|
|
|
+ if (api.code === 2008) {
|
|
|
+ success(api.message)
|
|
|
+ } else {
|
|
|
+ error(api.message)
|
|
|
+ throw (api.message)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
export const alterOrgFetch = (params: Partial<OrganizationType>) =>
|
|
|
sendFetch<PageProps<OrganizationType>>(URL.alterOrganization, {
|
|
|
method: "post",
|