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