Переглянути джерело

Merge branch 'dev' of http://192.168.0.115:3000/bill/fuse into dev

xushiting 2 роки тому
батько
коміт
e8ae0c4176

+ 6 - 3
src/layout/header/FilesHeader.tsx

@@ -1,5 +1,5 @@
 import { getExample } from 'api'
-import { useEffect, useState } from 'react'
+import { useEffect, useMemo, useState } from 'react'
 import { usePathData } from 'router'
 import { HeaderContent } from './index'
 import style from './style.module.scss'
@@ -11,11 +11,14 @@ export const FilesHeader = () => {
   useEffect(() => {
     getExample({caseId}).then(example => setTitle(example.caseTitle))
   }, [caseId])
-  
+  const bodyTitle = useMemo(() => `${title} | 卷宗管理`, [title])
+  useEffect(() => {
+    document.title = bodyTitle
+  }, [bodyTitle])
   
   return (
     <HeaderContent>
-      <div className={style['file-title']}>{title} | 卷宗管理</div>
+      <div className={style['file-title']}>{bodyTitle}</div>
     </HeaderContent>
   )
 }

+ 1 - 1
src/version.json

@@ -2,5 +2,5 @@
   "env": "dev",
   "main": 1.2,
   "append": "alpha",
-  "version": 9
+  "version": 11
 }

+ 2 - 2
src/views/draw-file/board/shape.js

@@ -50,10 +50,10 @@ export const images = [
   cigarette,
   fireoint,
   footPrint,
+  footPrintRever,
   shoePrint,
-  fingerPrint,
   shoePrintRever,
-  footPrintRever,
+  fingerPrint,
   corpse,
   theBlood
 ]

+ 18 - 10
src/views/draw-file/eshape.tsx

@@ -4,6 +4,7 @@ import { CloseOutlined, PlusOutlined, RotateRightOutlined } from '@ant-design/ic
 import style from './style.module.scss'
 import { title, compass } from './board'
 import ReactEditeTable, { InputEditor } from 'react-edit-table'
+import { alert } from 'utils'
 
 import type { Board, BoardShape, ShapeType, ExtractShape } from "./board"
 import type { ComponentType } from 'react'
@@ -39,10 +40,10 @@ import { usePathData } from "router"
 const TextInput = ({ shape }: { shape: ExtractShape<'text'> }) => {
   const [text, setText] = useState(shape.data.text)
   const onChang = () => {
-    console.log('text', text, shape.data.text)
-    if (text !== shape.data.text) {
-      shape.setText(text)
-    }
+    shape.setText(text)
+    // if (text !== shape.data.text) {
+    //   shape.setText(text)
+    // }
   }
   return (
     <Form.Item label="内容">
@@ -111,6 +112,9 @@ const ContentInput = ({ shape }: { shape: ExtractShape<'content'> }) => {
     setContent(newContent)
   }
   const onDelete = (data: any) => {
+    if (content.length <= 2) {
+      return alert("表格最少需要保留一行!")
+    }
     const newContent = sortContent()
     const startIndex = newContent.findIndex(item => item.rowIndex === data.rowIndex)
     const endIndex = startIndex + refer.length
@@ -141,6 +145,7 @@ const ContentInput = ({ shape }: { shape: ExtractShape<'content'> }) => {
     }).flat()
     setContent(bound)
     shape.setContent(bound)
+    console.log(bound)
     setEdit(false)
   }, [content, shape])
 
@@ -163,11 +168,14 @@ const ContentInput = ({ shape }: { shape: ExtractShape<'content'> }) => {
       <Button type="primary" onClick={() => setEdit(true)}>编辑</Button>
       <Modal open={edit} onCancel={() => setEdit(false)} onOk={onSubmit} width="430px" className="edit-table-layout">
         <div id="edit-table" onKeyDown={ev => ev.stopPropagation()}>
-          <ReactEditeTable 
-            {...tableAttrs}
-            onDelete={onDelete}
-            onChange={onChange} 
-          />
+          { tableAttrs.dataSource.length &&
+              <ReactEditeTable 
+                {...tableAttrs}
+                onDelete={onDelete}
+                onChange={onChange} 
+              />
+          }
+          
           <div className={style['add-table-row']}>
             <Button onClick={onInsert} type="primary">
               <PlusOutlined className="icon" /> 行
@@ -204,7 +212,7 @@ export const EShape = ({ board }: EShapeProps) => {
   const Edit = shape && shapeCompontes[shape.data.type]
   const disabledDelete: boolean = ([title, compass] as any).includes(shape?.data.type)
   const renderDelete = !disabledDelete && (
-    <Form.Item label="形状">
+    <Form.Item label="删除">
       <Button type="primary" onClick={() => shape!.delete()}>删除</Button>
     </Form.Item>
   )

+ 15 - 7
src/views/draw-file/header.tsx

@@ -10,7 +10,7 @@ import {
   TitleShapeData,
 } from 'api'
 
-import { useEffect, useState } from "react"
+import { useEffect, useMemo, useState } from "react"
 import { Board, title } from "./board"
 import type { SaveBoardProps } from 'api'
 
@@ -44,17 +44,25 @@ const Header = ({ board, type }: HeaderProps) => {
   const pathId = Number(path!.id)
   const pathType = path!.type as BoardType
   const navigate = useNavigate()
+  const isNew = useMemo(() => pathId === -1, [pathId])
+  const back = () => {
+    navigate(fillRoutePath(RoutePath.files, { id: caseId }))
+  }
   const exportPng = async () => {
+    const { titleShape } = await getStore();
     const blob = await board.export()
-    saveAs(blob, `${BoardTypeDesc[type]}.png`)
+    saveAs(blob, `${titleShape.text}.png`)
+  }
+  const getStore = async () => {
+    const store = await board.getStore()
+    const titleShape = store.shapes.find(shape => shape.type === title) as TitleShapeData
+    return { store, titleShape }
   }
 
   
   const save = async () => {
-    const store = await board.getStore()
-    const titleShape = store.shapes.find(shape => shape.type === title) as TitleShapeData
+    const { store, titleShape } = await getStore();
     const blob = await board.export()
-    const isNew = pathId === -1
     const body: SaveBoardProps = {
       caseId, 
       imgType: pathType,
@@ -117,13 +125,13 @@ const Header = ({ board, type }: HeaderProps) => {
   return (
     <>
       <div className={style['df-header-left']}>
-        <span className={`${style['df-header-back']} icon`} onClick={() => navigate(-1)}>
+        <span className={`${style['df-header-back']} icon`} onClick={back}>
           <ArrowLeftOutlined />
           返回
         </span>
       </div>
       <h1 className={style['df-header-center']}>
-        创建{ BoardTypeDesc[type] }
+        { isNew ? '创建' : '修改' }{ BoardTypeDesc[type] }
       </h1>
       <div className={style['df-header-right']}>
         <div className={style['df-header-action']}>

+ 2 - 2
src/views/draw-file/slider.tsx

@@ -38,8 +38,8 @@ export const DfSlider = ({ board, type, caseId }: SliderProps) => {
     if (taggings.length) {
       const table = await board.calcTableShape(
         [
-          ["图例", "说明"],
-          ...taggings.map((tag, index) => [`图例${index + 1}`, tag.tagTitle])
+          ["图例", "标注"],
+          ...taggings.map((tag, index) => [`序号${index + 1}`, tag.tagTitle])
         ]
         
       )

+ 9 - 0
src/views/draw-file/style.module.scss

@@ -348,4 +348,13 @@ body {
 :global(.edit-table-layout .ant-modal-body) {
   max-height: 451px;
   overflow-y: auto;
+  
+}
+
+:global(.body-container .row-container:first-child:last-child .cell:last-child) {
+  min-height: 24px;
+}
+
+:global(.body-container .row-container:first-child:last-child .cell:last-child .delete-container) {
+  display: none;
 }

+ 7 - 2
src/views/files/upload.tsx

@@ -1,4 +1,4 @@
-import { useRef } from 'react'
+import { useMemo, useRef } from 'react'
 import { addExampleFile, ExampleFile } from 'api'
 import { UploadOutlined } from '@ant-design/icons'
 import { onlyOpenWindow } from 'utils'
@@ -57,7 +57,9 @@ export const AddExampleFile = (props: AddExampleFileProps) => {
   const onSubmit = () => {
     from.current?.submit()
   }
-  const accpets = [".pdf", ".doc", ".docx", ".jpg"]
+  const accpets = useMemo(() => 
+    props.type !== 1 ? [".pdf", ".doc", ".docx"] : [".jpg", ".png"]
+  , [props.type])
 
   const uploadProps: UploadProps = {
     async customRequest(option) {
@@ -74,6 +76,9 @@ export const AddExampleFile = (props: AddExampleFileProps) => {
         option.onError &&  option.onError(new Error(`上传文件不能超过100M`))
         return
       }
+      // if (!from.current?.getFieldValue("filesTitle")) {
+        from.current?.setFieldValue("filesTitle", file.name)
+      // }
       option.onSuccess &&  option.onSuccess(file.name)
     },
     listType: 'picture',