caseFile.ts 4.6 KB

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