From 5bba0c97665d4a3fe1b3dd38cf7d08880e0fe8eb Mon Sep 17 00:00:00 2001 From: 2betop <2betop.cn@gmail.com> Date: Tue, 18 Aug 2020 10:50:06 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=A0=B7=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/components/form/table.md | 5 ++--- examples/components/Form/Table.jsx | 9 ++------- scss/components/_table.scss | 8 ++++---- scss/components/form/_form.scss | 4 ++++ src/renderers/Form/Table.tsx | 28 ++++++++++++++++------------ 5 files changed, 28 insertions(+), 26 deletions(-) diff --git a/docs/components/form/table.md b/docs/components/form/table.md index e5def560..b437d72c 100755 --- a/docs/components/form/table.md +++ b/docs/components/form/table.md @@ -260,12 +260,11 @@ order: 54 { "label": "A", "name": "a", - "quickEdit": true + "quickEdit": false }, { "label": "B", - "name": "b", - "quickEdit": true + "name": "b" } ] } diff --git a/examples/components/Form/Table.jsx b/examples/components/Form/Table.jsx index 85bd1189..2f58acf1 100644 --- a/examples/components/Form/Table.jsx +++ b/examples/components/Form/Table.jsx @@ -56,17 +56,12 @@ export default { label: 'Color', name: 'color', quickEdit: { - type: 'color', - mode: 'inline' + type: 'color' } }, { label: '说明文字', - name: 'name', - quickEdit: { - type: 'text', - mode: 'inline' - } + name: 'name' } ] }, diff --git a/scss/components/_table.scss b/scss/components/_table.scss index 2face37d..a382d4e1 100644 --- a/scss/components/_table.scss +++ b/scss/components/_table.scss @@ -243,10 +243,10 @@ font-weight: $fontWeightNormal; white-space: nowrap; - .#{$ns}TableCell--title { - display: flex; - align-items: center; - } + // .#{$ns}TableCell--title { + // display: flex; + // align-items: center; + // } .#{$ns}Remark { margin-left: $gap-xs; } diff --git a/scss/components/form/_form.scss b/scss/components/form/_form.scss index 25e15764..55cabbc9 100644 --- a/scss/components/form/_form.scss +++ b/scss/components/form/_form.scss @@ -328,3 +328,7 @@ } } } + +.#{$ns}Form--quickEdit { + min-width: $Form-control-widthSm; +} diff --git a/src/renderers/Form/Table.tsx b/src/renderers/Form/Table.tsx index 641e11ca..87c21f96 100644 --- a/src/renderers/Form/Table.tsx +++ b/src/renderers/Form/Table.tsx @@ -211,14 +211,19 @@ export default class FormTable extends React.Component { } addItem(index: number, payload: any = this.props.scaffold) { - const {value, onChange} = this.props; + const {value, onChange, needConfirm} = this.props; let newValue = Array.isArray(value) ? value.concat() : []; newValue.splice(index + 1, 0, { ...payload }); onChange(newValue); index = Math.min(index + 1, newValue.length - 1); - this.startEdit(index, newValue[index], true); + + if (needConfirm === false) { + onChange(newValue); + } else { + this.startEdit(index, newValue[index], true); + } } startEdit(index: number, editting?: any, isCreate: boolean = false) { @@ -544,9 +549,11 @@ export default class FormTable extends React.Component { columns.push({ type: 'operation', buttons: btns, - width: 150, label: __('操作'), - className: 'v-middle' + className: 'v-middle nowrap', + fixed: 'right', + width: '1%', + innerClassName: 'm-n' }); } @@ -563,14 +570,11 @@ export default class FormTable extends React.Component { const newValue = Array.isArray(value) ? value.concat() : []; if (~this.state.editIndex) { - this.setState( - { - editting: this.editting = { - ...rows - } - }, - needConfirm === false ? this.confirmEdit : undefined - ); + this.setState({ + editting: this.editting = { + ...rows + } + }); return; } else if (Array.isArray(rows)) { (rowIndexes as Array).forEach((rowIndex, index) => {