caseFile.ts 4.7 KB

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