caseFile.ts 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  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. ognFileUrl?: string;
  69. };
  70. export const saveCaseFileImageInfo = async (props: SaveCaseFileImageInfo) =>
  71. (
  72. await axios.post<Required<SaveCaseFileImageInfo>>(saveCaseFileInfo, {
  73. filesTypeId: 1,
  74. ...props,
  75. content: JSON.stringify(props.content),
  76. })
  77. ).data;
  78. import type {
  79. brokenLine,
  80. text,
  81. table,
  82. rect,
  83. circular,
  84. arrow,
  85. icon,
  86. cigarette,
  87. fireoint,
  88. footPrint,
  89. shoePrint,
  90. fingerPrint,
  91. corpse,
  92. theBlood,
  93. compass,
  94. title,
  95. bgImage,
  96. } from "@/view/case/draw/board";
  97. export interface Pos {
  98. x: number;
  99. y: number;
  100. }
  101. interface ShapeData {
  102. color: string;
  103. }
  104. interface CurrencyShapeData extends ShapeData {
  105. pos: Pos;
  106. width: number;
  107. height: number;
  108. }
  109. export interface TitleShapeData extends ShapeData {
  110. text: string;
  111. type: typeof title;
  112. }
  113. export interface BgImageShapeData extends ShapeData {
  114. url: string;
  115. type: typeof bgImage;
  116. }
  117. export interface CompassShapeData extends ShapeData {
  118. rotate: number;
  119. type: typeof compass;
  120. }
  121. export interface BrokenLineShapeData extends ShapeData {
  122. type: typeof brokenLine;
  123. points: Pos[];
  124. }
  125. export interface TextShapeData extends ShapeData {
  126. type: typeof text;
  127. text: string;
  128. fontSize: number;
  129. }
  130. export type TableShapeContentItem = {
  131. width: number;
  132. height: number;
  133. value: string;
  134. rowIndex: number;
  135. colIndex: number;
  136. };
  137. export interface TableShapeData extends CurrencyShapeData {
  138. type: typeof table;
  139. content: TableShapeContentItem[];
  140. }
  141. export interface RectShapeData extends CurrencyShapeData {
  142. type: typeof rect;
  143. }
  144. export interface CircularShapeData extends CurrencyShapeData {
  145. type: typeof circular;
  146. }
  147. export interface ArrowShapeData extends CurrencyShapeData {
  148. type: typeof arrow;
  149. direction: number;
  150. }
  151. export interface IconShapeData extends CurrencyShapeData {
  152. type: typeof icon;
  153. index: number;
  154. }
  155. export interface CigaretteShapeData extends CurrencyShapeData {
  156. type: typeof cigarette;
  157. }
  158. export interface FireointShapeData extends CurrencyShapeData {
  159. type: typeof fireoint;
  160. }
  161. export interface FootPrintShapeData extends CurrencyShapeData {
  162. type: typeof footPrint;
  163. }
  164. export interface ShoePrintShapeData extends CurrencyShapeData {
  165. type: typeof shoePrint;
  166. }
  167. export interface FingerPrintShapeData extends CurrencyShapeData {
  168. type: typeof fingerPrint;
  169. }
  170. export interface CorpseShapeData extends CurrencyShapeData {
  171. type: typeof corpse;
  172. }
  173. export interface TheBloodShapeData extends CurrencyShapeData {
  174. type: typeof theBlood;
  175. }
  176. export interface FootPrintShapeData extends CurrencyShapeData {
  177. type: typeof footPrint;
  178. }
  179. export type BoardShapeData =
  180. | BrokenLineShapeData
  181. | TextShapeData
  182. | TableShapeData
  183. | RectShapeData
  184. | CircularShapeData
  185. | ArrowShapeData
  186. | IconShapeData
  187. | CigaretteShapeData
  188. | FireointShapeData
  189. | FootPrintShapeData
  190. | ShoePrintShapeData
  191. | FingerPrintShapeData
  192. | CorpseShapeData
  193. | TheBloodShapeData
  194. | TitleShapeData
  195. | BgImageShapeData
  196. | CompassShapeData;
  197. export interface BoardData {
  198. id: number;
  199. ognFilesUrl: string | null;
  200. shapes: BoardShapeData[];
  201. }