优化样式

This commit is contained in:
2betop 2020-08-18 10:50:06 +08:00
parent 6086053b3c
commit 5bba0c9766
5 changed files with 28 additions and 26 deletions

View File

@ -260,12 +260,11 @@ order: 54
{ {
"label": "A", "label": "A",
"name": "a", "name": "a",
"quickEdit": true "quickEdit": false
}, },
{ {
"label": "B", "label": "B",
"name": "b", "name": "b"
"quickEdit": true
} }
] ]
} }

View File

@ -56,17 +56,12 @@ export default {
label: 'Color', label: 'Color',
name: 'color', name: 'color',
quickEdit: { quickEdit: {
type: 'color', type: 'color'
mode: 'inline'
} }
}, },
{ {
label: '说明文字', label: '说明文字',
name: 'name', name: 'name'
quickEdit: {
type: 'text',
mode: 'inline'
}
} }
] ]
}, },

View File

@ -243,10 +243,10 @@
font-weight: $fontWeightNormal; font-weight: $fontWeightNormal;
white-space: nowrap; white-space: nowrap;
.#{$ns}TableCell--title { // .#{$ns}TableCell--title {
display: flex; // display: flex;
align-items: center; // align-items: center;
} // }
.#{$ns}Remark { .#{$ns}Remark {
margin-left: $gap-xs; margin-left: $gap-xs;
} }

View File

@ -328,3 +328,7 @@
} }
} }
} }
.#{$ns}Form--quickEdit {
min-width: $Form-control-widthSm;
}

View File

@ -211,14 +211,19 @@ export default class FormTable extends React.Component<TableProps, TableState> {
} }
addItem(index: number, payload: any = this.props.scaffold) { 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() : []; let newValue = Array.isArray(value) ? value.concat() : [];
newValue.splice(index + 1, 0, { newValue.splice(index + 1, 0, {
...payload ...payload
}); });
onChange(newValue); onChange(newValue);
index = Math.min(index + 1, newValue.length - 1); 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) { startEdit(index: number, editting?: any, isCreate: boolean = false) {
@ -544,9 +549,11 @@ export default class FormTable extends React.Component<TableProps, TableState> {
columns.push({ columns.push({
type: 'operation', type: 'operation',
buttons: btns, buttons: btns,
width: 150,
label: __('操作'), 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<TableProps, TableState> {
const newValue = Array.isArray(value) ? value.concat() : []; const newValue = Array.isArray(value) ? value.concat() : [];
if (~this.state.editIndex) { if (~this.state.editIndex) {
this.setState( this.setState({
{ editting: this.editting = {
editting: this.editting = { ...rows
...rows }
} });
},
needConfirm === false ? this.confirmEdit : undefined
);
return; return;
} else if (Array.isArray(rows)) { } else if (Array.isArray(rows)) {
(rowIndexes as Array<number>).forEach((rowIndex, index) => { (rowIndexes as Array<number>).forEach((rowIndex, index) => {