caseFile.ts 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. import {
  2. caseFileTypes,
  3. caseFiles,
  4. insertCaseFile,
  5. deleteCaseFile,
  6. updateCaseFile,
  7. axios,
  8. caseFileInfo,
  9. saveCaseFileInfo,
  10. } from "@/request";
  11. // 可以绘画的fileType
  12. export enum BoardType {
  13. map = "0",
  14. scene = "1",
  15. }
  16. export interface CaseFileType {
  17. filesTypeId: number;
  18. filesTypeName: string;
  19. tbStatus: number;
  20. childKey?: string;
  21. filesTypeKey?: string;
  22. createTime: string;
  23. updateTime: string;
  24. }
  25. export interface CaseFile {
  26. filesId: number;
  27. caseId: number;
  28. filesTypeId: number;
  29. filesTitle: string;
  30. filesUrl: string;
  31. tbStatus: number;
  32. createTime: string;
  33. updateTime: string;
  34. imgType?: BoardType;
  35. content: BoardData;
  36. }
  37. export const getCaseFileTypes = async () =>
  38. (await axios.get<CaseFileType[]>(caseFileTypes)).data;
  39. export const getCaseFileTypesQuery = async (key: string) =>
  40. (await axios.get<CaseFileType[]>(`${caseFileTypes}?fileTypeKey=${key}`)).data;
  41. export const getCaseFiles = async (props: {
  42. caseId: number;
  43. filesTypeId?: number;
  44. }) => (await axios.get<CaseFile[]>(caseFiles, { params: props })).data;
  45. export const addCaseFile = (
  46. data: Pick<CaseFile, "caseId" | "filesTitle" | "filesTypeId"> & { file: File }
  47. ) => axios.post(insertCaseFile, data);
  48. export const setCaseFile = (props: Pick<CaseFile, "filesId" | "filesTitle">) =>
  49. axios.post(updateCaseFile, props);
  50. export const delCaseFile = (props: Pick<CaseFile, "caseId" | "filesId">) =>
  51. axios.post(deleteCaseFile, props);
  52. export const getCaseFileImageInfo = async (fileId: number) => {
  53. const data = (
  54. await axios.get<CaseFile | null>(caseFileInfo, {
  55. params: { filesId: fileId },
  56. })
  57. ).data;
  58. return (
  59. data &&
  60. ({
  61. ...data,
  62. content: JSON.parse(data.content as any),
  63. } as CaseFile)
  64. );
  65. };
  66. export type SaveCaseFileImageInfo = Pick<CaseFile, "caseId" | "filesTitle"> & {
  67. filesId?: number;
  68. imgType: BoardType;
  69. content: BoardData;
  70. file: File;
  71. };
  72. export const saveCaseFileImageInfo = async (props: SaveCaseFileImageInfo) =>
  73. (
  74. await axios.post<Required<SaveCaseFileImageInfo>>(saveCaseFileInfo, {
  75. filesTypeId: 1,
  76. ...props,
  77. content: JSON.stringify(props.content),
  78. })
  79. ).data;
  80. import type {
  81. brokenLine,
  82. text,
  83. table,
  84. rect,
  85. circular,
  86. arrow,
  87. icon,
  88. cigarette,
  89. fireoint,
  90. footPrint,
  91. shoePrint,
  92. fingerPrint,
  93. corpse,
  94. theBlood,
  95. compass,
  96. title,
  97. bgImage,
  98. } from "@/view/case/draw/board";
  99. export interface Pos {
  100. x: number;
  101. y: number;
  102. }
  103. interface ShapeData {
  104. color: string;
  105. }
  106. interface CurrencyShapeData extends ShapeData {
  107. pos: Pos;
  108. width: number;
  109. height: number;
  110. }
  111. export interface TitleShapeData extends ShapeData {
  112. text: string;
  113. type: typeof title;
  114. }
  115. export interface BgImageShapeData extends ShapeData {
  116. url: string;
  117. type: typeof bgImage;
  118. }
  119. export interface CompassShapeData extends ShapeData {
  120. rotate: number;
  121. type: typeof compass;
  122. }
  123. export interface BrokenLineShapeData extends ShapeData {
  124. type: typeof brokenLine;
  125. points: Pos[];
  126. }
  127. export interface TextShapeData extends ShapeData {
  128. type: typeof text;
  129. text: string;
  130. fontSize: number;
  131. }
  132. export type TableShapeContentItem = {
  133. width: number;
  134. height: number;
  135. value: string;
  136. rowIndex: number;
  137. colIndex: number;
  138. };
  139. export interface TableShapeData extends CurrencyShapeData {
  140. type: typeof table;
  141. content: TableShapeContentItem[];
  142. }
  143. export interface RectShapeData extends CurrencyShapeData {
  144. type: typeof rect;
  145. }
  146. export interface CircularShapeData extends CurrencyShapeData {
  147. type: typeof circular;
  148. }
  149. export interface ArrowShapeData extends CurrencyShapeData {
  150. type: typeof arrow;
  151. direction: number;
  152. }
  153. export interface IconShapeData extends CurrencyShapeData {
  154. type: typeof icon;
  155. index: number;
  156. }
  157. export interface CigaretteShapeData extends CurrencyShapeData {
  158. type: typeof cigarette;
  159. }
  160. export interface FireointShapeData extends CurrencyShapeData {
  161. type: typeof fireoint;
  162. }
  163. export interface FootPrintShapeData extends CurrencyShapeData {
  164. type: typeof footPrint;
  165. }
  166. export interface ShoePrintShapeData extends CurrencyShapeData {
  167. type: typeof shoePrint;
  168. }
  169. export interface FingerPrintShapeData extends CurrencyShapeData {
  170. type: typeof fingerPrint;
  171. }
  172. export interface CorpseShapeData extends CurrencyShapeData {
  173. type: typeof corpse;
  174. }
  175. export interface TheBloodShapeData extends CurrencyShapeData {
  176. type: typeof theBlood;
  177. }
  178. export interface FootPrintShapeData extends CurrencyShapeData {
  179. type: typeof footPrint;
  180. }
  181. export type BoardShapeData =
  182. | BrokenLineShapeData
  183. | TextShapeData
  184. | TableShapeData
  185. | RectShapeData
  186. | CircularShapeData
  187. | ArrowShapeData
  188. | IconShapeData
  189. | CigaretteShapeData
  190. | FireointShapeData
  191. | FootPrintShapeData
  192. | ShoePrintShapeData
  193. | FingerPrintShapeData
  194. | CorpseShapeData
  195. | TheBloodShapeData
  196. | TitleShapeData
  197. | BgImageShapeData
  198. | CompassShapeData;
  199. export interface BoardData {
  200. id: number;
  201. shapes: BoardShapeData[];
  202. }