1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- import { UPLOAD_FILE, UPLOAD_HEADS, CASE_INFO, AUTH_PWD } from "./constant";
- import { axios } from "./instance";
- import { jsonToForm } from "@/utils";
- import { params } from "@/env";
- type UploadFile = LocalFile | string;
- export const blobToFile = (blob: Blob, suffix = ".png") =>
- new File([blob], `aaa${suffix}`);
- export const uploadFile = async (file: UploadFile, suffix = ".png") => {
- if (typeof file === "string") {
- return file;
- } else {
- const uploadFile =
- file.blob instanceof File ? file.blob : blobToFile(file.blob, suffix);
- console.log(uploadFile)
- const url = await axios<string>({
- method: "POST",
- url: UPLOAD_FILE,
- data: jsonToForm({ file: uploadFile }),
- headers: { ...UPLOAD_HEADS },
- });
- return url;
- }
- };
- export enum FireStatus {
- incomplete = 0,
- complete = 1,
- }
- export type FireProject = {
- accidentDate: string;
- createTime: string;
- creatorDeptId: string;
- caseId: number;
- creatorId: string;
- creatorName: string;
- deptId: string;
- editTime: string;
- editorId: string;
- editorName: string;
- fireReason: string;
- id: string;
- isTeached: number;
- organizerDeptName: string;
- organizerUsers: string;
- projectAddress: string;
- projectName: string;
- projectSite: string;
- projectSiteCode: string;
- projectSn: string;
- status: FireStatus;
- statusDesc: string;
- updateTime: string;
- isDelete?: number;
- latlng?: string
- field1: string;
- field2: string;
- field3: string;
- field4: string;
- field5: string;
- field6: string;
- field7: string;
- field8: string;
- field9: string;
- field10: string;
- };
- export interface Case {
- caseTitle: string;
- tmProject?: FireProject;
- }
- export const getCaseInfo = () =>
- axios.get<Case>(CASE_INFO, { params: { caseId: params.caseId } });
- // 校验密码
- export const authSharePassword = (randCode: string) =>
- axios<boolean>(AUTH_PWD, { params: { randCode, caseId: params.caseId } });
|