| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103 |
- import { sendFetch, PageProps } from './index'
- import { ResPage, ResResult } from './type'
- import { organizationTypeEnum } from '@/store/organization'
- import * as URL from "./URL";
- import { ElMessage } from "element-plus";
- import { throttle, encodePwd } 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
- contact: string
- orderNum: number
- orgId: number
- parentId: number
- orgName: string
- password: string
- type: organizationTypeEnum | null
- userName: string
- confirmPwd?: string,
- msgAuthCode?: string
- cityId?: number
- areaId?: number
- provinceId?: number
- }
- 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",
- body: JSON.stringify(params),
- });
- export const delOrgFetch = (params: Partial<OrganizationType>) =>
- sendFetch<PageProps<OrganizationType>>(URL.delOrganization, {
- method: "post",
- body: JSON.stringify(params),
- });
- export const getOrgListFetch = (params: PageProps<Partial<OrganizationType>>) =>
- sendFetch<ResPage<PageProps<OrganizationType>>>(URL.organizationPage, {
- method: "post",
- body: JSON.stringify(params),
- });
- export const getOrgListFetchList = () =>
- sendFetch<ResPage<PageProps<OrganizationType>>>(URL.organizationPageList, {
- method: "post",
- body: JSON.stringify({}),
- });
- export const registerOrganization = (params: any) => {
- const password = encodePwd(params.password)
- return sendFetch<ResResult>(URL.registerOrganization, {
- method: "post",
- body: JSON.stringify({ ...params, password, confirmPwd: password }),
- }, {
- noToken: true
- });
- }
- export const getProvinces = () => {
- return sendFetch<ResResult>(URL.getProvinces, {
- method: "get",
- });
- }
- export const getCities = (provinceCode: string) => {
- return sendFetch<ResResult>(URL.getCities + "?provinceCode=" + provinceCode, {
- method: "get",
- });
- }
- export const getAreas = (provinceCode: string, cityCode: string, zx?: boolean) => {
- const url = zx ? URL.getAreas + `?provinceCode=${provinceCode}&cityCode=${cityCode}` : URL.getAreas + `?provinceCode=${provinceCode}&cityCode=${cityCode}&zx=true`
- return sendFetch<ResResult>(url, {
- method: "get",
- });
- }
|