123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150 |
- import axios from './instance'
- import { DELETE_DRAW_FILE, GET_DRAW_FILE, INSERT_DRAW_FILE, UPDATE_DRAW_FILE } from 'constant'
- import type {
- brokenLine,
- text,
- table,
- rect,
- circular,
- arrow,
- icon,
- cigarette,
- fireoint,
- footPrint,
- shoePrint,
- fingerPrint,
- corpse,
- theBlood,
- } from 'views/draw-file/board'
- export interface Pos {
- x: number,
- y: number
- }
- interface ShapeData {
- color: string
- }
- interface CurrencyShapeData extends ShapeData {
- pos: Pos,
- width: number,
- height: number
- }
- export interface BrokenLineShapeData extends ShapeData {
- type: typeof brokenLine
- points: Pos[]
- }
- export interface TextShapeData extends ShapeData {
- type: typeof text
- text: string
- fontSize: number
- }
- export type TableShapeContentItem = { width: number, height: number, value: string, rowIndex: number, colIndex: number }
- export interface TableShapeData extends CurrencyShapeData {
- type: typeof table
- fontSize: number
- content: TableShapeContentItem[]
- }
- export interface RectShapeData extends CurrencyShapeData {
- type: typeof rect
- }
- export interface CircularShapeData extends CurrencyShapeData {
- type: typeof circular
- }
- export interface ArrowShapeData extends CurrencyShapeData {
- type: typeof arrow
- direction: number
- }
- export interface IconShapeData extends CurrencyShapeData {
- type: typeof icon
- index: number
- }
- export interface CigaretteShapeData extends CurrencyShapeData {
- type: typeof cigarette
- }
- export interface FireointShapeData extends CurrencyShapeData {
- type: typeof fireoint
- }
- export interface FootPrintShapeData extends CurrencyShapeData {
- type: typeof footPrint
- }
- export interface ShoePrintShapeData extends CurrencyShapeData {
- type: typeof shoePrint
- }
- export interface FingerPrintShapeData extends CurrencyShapeData {
- type: typeof fingerPrint
- }
- export interface CorpseShapeData extends CurrencyShapeData {
- type: typeof corpse
- }
- export interface TheBloodShapeData extends CurrencyShapeData {
- type: typeof theBlood
- }
- export interface FootPrintShapeData extends CurrencyShapeData {
- type: typeof footPrint
- }
- export type BoardShapeData = BrokenLineShapeData | TextShapeData | TableShapeData | RectShapeData | CircularShapeData
- | ArrowShapeData | IconShapeData | CigaretteShapeData | FireointShapeData | FootPrintShapeData | ShoePrintShapeData
- | FingerPrintShapeData | CorpseShapeData | TheBloodShapeData
- export interface BoardData {
- id: number
- bgImage: string | null
- shapes: BoardShapeData[]
- }
- export enum BoardType {
- map = '0',
- scene = '1'
- }
- export const BoardTypeDesc = {
- [BoardType.map]: '方位图',
- [BoardType.scene]: '现场图',
- }
- export const getBoardById = (params: { id: number, type: BoardType }) => {
- axios.get<BoardData>(GET_DRAW_FILE, { params: params })
- return {
- id: params.id,
- shapes: [],
- bgImage: null
- }
- }
- export const delBoard = (params: { id: number }) => {
- axios.post<undefined>(DELETE_DRAW_FILE, params)
- }
-
- export const addBoard = (params: { type: BoardType, data: BoardData }) => {
- axios.post<BoardData>(INSERT_DRAW_FILE, params)
- return {
- ...params.data,
- id: 1,
- }
- }
- export const setBoard = (params: {id: number, data: BoardData}) => {
- axios.post<undefined>(UPDATE_DRAW_FILE, params)
- return params.data
- }
|