From 386ece8e6384ec081dc599a817ad4f809f1a2497 Mon Sep 17 00:00:00 2001 From: leexs Date: Tue, 21 Mar 2023 09:15:27 +0800 Subject: [PATCH 01/33] =?UTF-8?q?=E5=8D=95=E4=BD=8D=E5=92=8C=E6=8F=8F?= =?UTF-8?q?=E8=BF=B0=E7=9A=84=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/field/modify/bit_select.js | 2 +- lib/field/modify/date_time.js | 2 +- lib/field/modify/digit.js | 19 +++++++++-------- lib/field/modify/select.js | 6 +++--- lib/field/modify/switch.js | 4 ++-- lib/field/modify/text.js | 4 ++-- lib/field/modify/tree_select.js | 2 +- lib/field/util/render.js | 6 +++--- src/field/modify/bit_select.tsx | 2 +- src/field/modify/date_time.tsx | 2 +- src/field/modify/digit.tsx | 36 +++++++++++++++++--------------- src/field/modify/select.tsx | 6 +++--- src/field/modify/switch.tsx | 4 ++-- src/field/modify/text.tsx | 4 ++-- src/field/modify/tree_select.tsx | 2 +- src/field/util/render.tsx | 6 +++--- 16 files changed, 55 insertions(+), 52 deletions(-) diff --git a/lib/field/modify/bit_select.js b/lib/field/modify/bit_select.js index c6fa445..70a251a 100644 --- a/lib/field/modify/bit_select.js +++ b/lib/field/modify/bit_select.js @@ -30,7 +30,7 @@ class BitSelect extends React.PureComponent { }], initialValue: this._getDefaultValue(option), })(React.createElement(antd_1.Radio.Group, { name: this._bitFieldName(option), onChange: this._onChange.bind(this, option) }, option.values.map((v, i) => (React.createElement(antd_1.Radio, { key: v, value: v }, option.labels[i]))))), - Render.description(option.description, option.showTag === undefined ? true : option.showTag))))); + Render.description(option.description, option.showTag))))); }; this._onChange = (option, e) => { const { form } = this.props; diff --git a/lib/field/modify/date_time.js b/lib/field/modify/date_time.js index 19aca07..0ef1e8c 100644 --- a/lib/field/modify/date_time.js +++ b/lib/field/modify/date_time.js @@ -92,7 +92,7 @@ class DateTime extends React.PureComponent { message: "请填写" + label, }] })(onlyTime ? (React.createElement(antd_1.TimePicker, { placeholder: field.options.placeholder, format: field.options.dateFormat, style: { width: field.options.valueWidth || 200 }, onChange: this._onChange })) : (React.createElement(antd_1.DatePicker, { showTime: field.options.hasTime, placeholder: field.options.placeholder, format: field.options.dateFormat, style: { width: field.options.valueWidth || 200 }, onChange: this._onChange }))), - Render.description(field.options.description, field.options.showTag === undefined ? true : field.options.showTag))); + Render.description(field.options.description, field.options.showTag))); } } Storage.set(Field.DateTime.Type, (option) => React.createElement(DateTime, Object.assign({}, option))); diff --git a/lib/field/modify/digit.js b/lib/field/modify/digit.js index 1ad7dd3..551c0a8 100644 --- a/lib/field/modify/digit.js +++ b/lib/field/modify/digit.js @@ -48,15 +48,16 @@ class Digit extends React.PureComponent { } } return (React.createElement(antd_1.Form.Item, { className: "xc-modify-content", label: label }, - form.getFieldDecorator(Storage.Prefix + field.name, { - rules: [{ - required: field.options.required, - message: "请填写" + label, - }], - initialValue: initialValue, - })(React.createElement(antd_1.InputNumber, { max: field.options.max, min: field.options.min, step: field.options.step, style: { width: field.options.valueWidth || 200 }, onChange: this._onChange })), - Render.unit(field.options.unitLabel, field.options.showTag === undefined ? true : field.options.showTag, field.options.unitWidth), - Render.description(field.options.description, field.options.showTag === undefined ? true : field.options.showTag))); + React.createElement("div", null, + form.getFieldDecorator(Storage.Prefix + field.name, { + rules: [{ + required: field.options.required, + message: "请填写" + label, + }], + initialValue: initialValue, + })(React.createElement(antd_1.InputNumber, { max: field.options.max, min: field.options.min, step: field.options.step, style: { width: field.options.valueWidth || 200 }, onChange: this._onChange })), + Render.unit(field.options.unitLabel, field.options.showTag, field.options.unitWidth)), + Render.description(field.options.description, field.options.showTag))); } } Storage.set(Field.Digit.Type, (option) => React.createElement(Digit, Object.assign({}, option))); diff --git a/lib/field/modify/select.js b/lib/field/modify/select.js index ca32d35..aae68da 100644 --- a/lib/field/modify/select.js +++ b/lib/field/modify/select.js @@ -59,9 +59,9 @@ class SelectView extends React.PureComponent { ? (value, option) => { return option.props.children.indexOf(value) >= 0; } - : undefined, onChange: this._onChange }, this.state.dataSource !== undefined ? this.state.dataSource.map(this._renderSelectOption) : undefined)), - Render.unit(field.options.unitLabel, field.options.showTag === undefined ? true : field.options.showTag, field.options.unitWidth), - Render.description(field.options.description, field.options.showTag === undefined ? true : field.options.showTag))); + : undefined, onChange: this._onChange }, this.state.dataSource === undefined ? undefined : this.state.dataSource.map(this._renderSelectOption))), + Render.unit(field.options.unitLabel, field.options.showTag, field.options.unitWidth), + Render.description(field.options.description, field.options.showTag))); } } Storage.set(Field.Select.Type, (option) => React.createElement(SelectView, Object.assign({}, option))); diff --git a/lib/field/modify/switch.js b/lib/field/modify/switch.js index 15eed88..2170a48 100644 --- a/lib/field/modify/switch.js +++ b/lib/field/modify/switch.js @@ -43,8 +43,8 @@ class SwitchView extends React.PureComponent { React.createElement(antd_1.Radio, { value: true }, field.options.trueLabel), React.createElement(antd_1.Radio, { value: false }, field.options.falseLabel)) : React.createElement(antd_1.Switch, { checkedChildren: field.options.trueLabel, unCheckedChildren: field.options.falseLabel, style: { width: field.options.valueWidth || "auto" }, onChange: this._onSwitchChange })), - useRadio ? null : Render.unit(field.options.unitLabel, field.options.showTag === undefined ? true : field.options.showTag, field.options.unitWidth), - Render.description(field.options.description, field.options.showTag === undefined ? true : field.options.showTag))); + useRadio ? null : Render.unit(field.options.unitLabel, field.options.showTag, field.options.unitWidth), + Render.description(field.options.description, field.options.showTag))); } } Storage.set(Field.Switch.Type, (option) => React.createElement(SwitchView, Object.assign({}, option))); diff --git a/lib/field/modify/text.js b/lib/field/modify/text.js index bda6e73..f8e2610 100644 --- a/lib/field/modify/text.js +++ b/lib/field/modify/text.js @@ -27,8 +27,8 @@ class TextView extends React.PureComponent { }], initialValue: this.props.initialValue || "", })(React.createElement(antd_1.Input, { placeholder: field.options.placeholder, style: { width: field.options.valueWidth || 200 } })), - Render.unit(field.options.unitLabel, field.options.showTag === undefined ? true : field.options.showTag, field.options.unitWidth), - Render.description(field.options.description, field.options.showTag === undefined ? true : field.options.showTag))); + Render.unit(field.options.unitLabel, field.options.showTag, field.options.unitWidth), + Render.description(field.options.description, field.options.showTag))); } } Storage.set(Field.Text.Type, (option) => React.createElement(TextView, Object.assign({}, option))); diff --git a/lib/field/modify/tree_select.js b/lib/field/modify/tree_select.js index a11fe57..fe97e55 100644 --- a/lib/field/modify/tree_select.js +++ b/lib/field/modify/tree_select.js @@ -51,7 +51,7 @@ class TreeSelectView extends React.PureComponent { maxHeight: field.options.maxHeight, overflow: 'auto', }, multiple: field.options.multiple, treeData: this.state.tree, placeholder: field.options.placeholder, treeDefaultExpandAll: field.options.defaultExpandAll, style: { width: field.options.valueWidth || 500 }, onChange: this._onChange })), - Render.description(field.options.description, field.options.showTag === undefined ? true : field.options.showTag))); + Render.description(field.options.description, field.options.showTag))); } } Storage.set(Field.TreeSelect.Type, (option) => React.createElement(TreeSelectView, Object.assign({}, option))); diff --git a/lib/field/util/render.js b/lib/field/util/render.js index b104626..baa694c 100644 --- a/lib/field/util/render.js +++ b/lib/field/util/render.js @@ -11,15 +11,15 @@ const React = __importStar(require("react")); const antd_1 = require("antd"); function unit(unit, tag, witdh) { return unit - ? (tag === true + ? (tag === undefined || tag === true ? React.createElement(antd_1.Tag, { color: "#2db7f5", style: { width: witdh || "auto", textAlign: "center" } }, unit) : React.createElement("span", null, unit)) : null; } exports.unit = unit; function description(desc, tag) { return desc - ? (tag === true + ? (tag === undefined || tag === true ? React.createElement(antd_1.Tag, { color: "blue" }, desc) - : React.createElement("span", null, unit)) : null; + : React.createElement("span", null, desc)) : null; } exports.description = description; diff --git a/src/field/modify/bit_select.tsx b/src/field/modify/bit_select.tsx index 855f998..d929fe9 100644 --- a/src/field/modify/bit_select.tsx +++ b/src/field/modify/bit_select.tsx @@ -58,7 +58,7 @@ class BitSelect extends React.PureComponent { ))} )} - {Render.description(option.description, option.showTag === undefined ? true : option.showTag)} + {Render.description(option.description, option.showTag)} diff --git a/src/field/modify/date_time.tsx b/src/field/modify/date_time.tsx index 13eb42e..f081749 100644 --- a/src/field/modify/date_time.tsx +++ b/src/field/modify/date_time.tsx @@ -50,7 +50,7 @@ class DateTime extends React.PureComponent { /> ) )} - {Render.description(field.options.description, field.options.showTag === undefined ? true : field.options.showTag)} + {Render.description(field.options.description, field.options.showTag)} ); } diff --git a/src/field/modify/digit.tsx b/src/field/modify/digit.tsx index 5aa25d9..106ab03 100644 --- a/src/field/modify/digit.tsx +++ b/src/field/modify/digit.tsx @@ -26,23 +26,25 @@ class Digit extends React.PureComponent { } return ( - {form.getFieldDecorator(Storage.Prefix + field.name, { - rules: [{ - required: field.options.required, - message: "请填写" + label, - }], - initialValue: initialValue, - })( - - )} - {Render.unit(field.options.unitLabel, field.options.showTag === undefined ? true : field.options.showTag, field.options.unitWidth)} - {Render.description(field.options.description, field.options.showTag === undefined ? true : field.options.showTag)} +
+ {form.getFieldDecorator(Storage.Prefix + field.name, { + rules: [{ + required: field.options.required, + message: "请填写" + label, + }], + initialValue: initialValue, + })( + + )} + {Render.unit(field.options.unitLabel, field.options.showTag, field.options.unitWidth)} +
+ {Render.description(field.options.description, field.options.showTag)}
); } diff --git a/src/field/modify/select.tsx b/src/field/modify/select.tsx index 503b521..ae38a0d 100644 --- a/src/field/modify/select.tsx +++ b/src/field/modify/select.tsx @@ -64,11 +64,11 @@ class SelectView extends React.PureComponent { } onChange={this._onChange} > - {this.state.dataSource !== undefined ? this.state.dataSource.map(this._renderSelectOption) : undefined} + {this.state.dataSource === undefined ? undefined : this.state.dataSource.map(this._renderSelectOption)} )} - {Render.unit(field.options.unitLabel, field.options.showTag === undefined ? true : field.options.showTag, field.options.unitWidth)} - {Render.description(field.options.description, field.options.showTag === undefined ? true : field.options.showTag)} + {Render.unit(field.options.unitLabel, field.options.showTag, field.options.unitWidth)} + {Render.description(field.options.description, field.options.showTag)} ); } diff --git a/src/field/modify/switch.tsx b/src/field/modify/switch.tsx index 101397e..e53e46f 100644 --- a/src/field/modify/switch.tsx +++ b/src/field/modify/switch.tsx @@ -43,8 +43,8 @@ class SwitchView extends React.PureComponent { onChange={this._onSwitchChange} /> )} - {useRadio ? null : Render.unit(field.options.unitLabel, field.options.showTag === undefined ? true : field.options.showTag, field.options.unitWidth)} - {Render.description(field.options.description, field.options.showTag === undefined ? true : field.options.showTag)} + {useRadio ? null : Render.unit(field.options.unitLabel, field.options.showTag, field.options.unitWidth)} + {Render.description(field.options.description, field.options.showTag)} ); } diff --git a/src/field/modify/text.tsx b/src/field/modify/text.tsx index 866c040..e282dc2 100644 --- a/src/field/modify/text.tsx +++ b/src/field/modify/text.tsx @@ -27,8 +27,8 @@ class TextView extends React.PureComponent { style={{ width: field.options.valueWidth || 200 }} /> )} - {Render.unit(field.options.unitLabel, field.options.showTag === undefined ? true : field.options.showTag, field.options.unitWidth)} - {Render.description(field.options.description, field.options.showTag === undefined ? true : field.options.showTag)} + {Render.unit(field.options.unitLabel, field.options.showTag, field.options.unitWidth)} + {Render.description(field.options.description, field.options.showTag)} ); } diff --git a/src/field/modify/tree_select.tsx b/src/field/modify/tree_select.tsx index e50f4c2..1e9d879 100644 --- a/src/field/modify/tree_select.tsx +++ b/src/field/modify/tree_select.tsx @@ -46,7 +46,7 @@ class TreeSelectView extends React.PureComponent { onChange={this._onChange} /> )} - {Render.description(field.options.description, field.options.showTag === undefined ? true : field.options.showTag)} + {Render.description(field.options.description, field.options.showTag)} ); } diff --git a/src/field/util/render.tsx b/src/field/util/render.tsx index 8fc359b..81d8b3a 100644 --- a/src/field/util/render.tsx +++ b/src/field/util/render.tsx @@ -3,7 +3,7 @@ import { Tag } from 'antd'; export function unit(unit?: string, tag?: boolean, witdh?: number) { return unit - ? (tag === true + ? (tag === undefined || tag === true ? {desc} - : {unit} + : {desc} ) : null; } -- Gitee From a49d85ed025f22c89b308089bc900d5694ffebf2 Mon Sep 17 00:00:00 2001 From: leexs Date: Tue, 21 Mar 2023 09:32:36 +0800 Subject: [PATCH 02/33] =?UTF-8?q?=E7=BC=96=E8=BE=91=E5=AD=97=E6=AE=B5?= =?UTF-8?q?=E7=9A=84=E8=BE=93=E5=85=A5=E6=8E=A7=E4=BB=B6=E3=80=81=E5=8D=95?= =?UTF-8?q?=E4=BD=8D=E5=92=8C=E6=8F=8F=E8=BF=B0=E5=88=86=E6=88=90=E4=B8=A4?= =?UTF-8?q?=E9=83=A8=E5=88=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/field/modify/bit_select.js | 6 ++-- lib/field/modify/date_time.js | 4 +-- lib/field/modify/select.js | 27 +++++++------- lib/field/modify/switch.js | 27 +++++++------- lib/field/modify/text.js | 19 +++++----- src/field/modify/bit_select.tsx | 40 +++++++++++---------- src/field/modify/date_time.tsx | 50 +++++++++++++------------- src/field/modify/select.tsx | 52 ++++++++++++++------------- src/field/modify/switch.tsx | 62 +++++++++++++++++---------------- src/field/modify/text.tsx | 30 ++++++++-------- 10 files changed, 165 insertions(+), 152 deletions(-) diff --git a/lib/field/modify/bit_select.js b/lib/field/modify/bit_select.js index 70a251a..d3b9bd0 100644 --- a/lib/field/modify/bit_select.js +++ b/lib/field/modify/bit_select.js @@ -22,14 +22,14 @@ class BitSelect extends React.PureComponent { return (React.createElement(antd_1.Row, { className: "xc-bit-select-row", key: idx.toString() }, React.createElement(antd_1.Col, { span: field.options.colSpan }, option.fieldLabel), React.createElement(antd_1.Col, { span: 24 - field.options.colSpan }, - React.createElement(antd_1.Form.Item, null, - form.getFieldDecorator(this._bitFieldName(option), { + React.createElement(antd_1.Form.Item, { className: "xc-modify-content" }, + React.createElement("div", null, form.getFieldDecorator(this._bitFieldName(option), { rules: [{ required: field.options.required, message: "请填写" + option.fieldLabel, }], initialValue: this._getDefaultValue(option), - })(React.createElement(antd_1.Radio.Group, { name: this._bitFieldName(option), onChange: this._onChange.bind(this, option) }, option.values.map((v, i) => (React.createElement(antd_1.Radio, { key: v, value: v }, option.labels[i]))))), + })(React.createElement(antd_1.Radio.Group, { name: this._bitFieldName(option), onChange: this._onChange.bind(this, option) }, option.values.map((v, i) => (React.createElement(antd_1.Radio, { key: v, value: v }, option.labels[i])))))), Render.description(option.description, option.showTag))))); }; this._onChange = (option, e) => { diff --git a/lib/field/modify/date_time.js b/lib/field/modify/date_time.js index 0ef1e8c..8622788 100644 --- a/lib/field/modify/date_time.js +++ b/lib/field/modify/date_time.js @@ -85,13 +85,13 @@ class DateTime extends React.PureComponent { } } return (React.createElement(antd_1.Form.Item, { className: "xc-modify-content", label: label }, - form.getFieldDecorator(Storage.Prefix + field.name, { + React.createElement("div", null, form.getFieldDecorator(Storage.Prefix + field.name, { initialValue: initialValue, rules: [{ required: field.options.required, message: "请填写" + label, }] - })(onlyTime ? (React.createElement(antd_1.TimePicker, { placeholder: field.options.placeholder, format: field.options.dateFormat, style: { width: field.options.valueWidth || 200 }, onChange: this._onChange })) : (React.createElement(antd_1.DatePicker, { showTime: field.options.hasTime, placeholder: field.options.placeholder, format: field.options.dateFormat, style: { width: field.options.valueWidth || 200 }, onChange: this._onChange }))), + })(onlyTime ? (React.createElement(antd_1.TimePicker, { placeholder: field.options.placeholder, format: field.options.dateFormat, style: { width: field.options.valueWidth || 200 }, onChange: this._onChange })) : (React.createElement(antd_1.DatePicker, { showTime: field.options.hasTime, placeholder: field.options.placeholder, format: field.options.dateFormat, style: { width: field.options.valueWidth || 200 }, onChange: this._onChange })))), Render.description(field.options.description, field.options.showTag))); } } diff --git a/lib/field/modify/select.js b/lib/field/modify/select.js index aae68da..31e6a3b 100644 --- a/lib/field/modify/select.js +++ b/lib/field/modify/select.js @@ -48,19 +48,20 @@ class SelectView extends React.PureComponent { const label = field.options.label || field.label; const mul = field.options.multiple; return (React.createElement(antd_1.Form.Item, { className: "xc-modify-content", label: label, hasFeedback: !mul }, - form.getFieldDecorator(field.name, { - initialValue: this.props.initialValue, - rules: [{ - required: field.options.required, - message: "请填写" + label, - type: mul ? "array" : field.options.valueType, - }], - })(React.createElement(antd_1.Select, { mode: mul ? "multiple" : "default", placeholder: field.options.placeholder, style: { width: field.options.valueWidth || 200 }, showSearch: field.options.filtered, showArrow: field.options.filtered, filterOption: field.options.filtered - ? (value, option) => { - return option.props.children.indexOf(value) >= 0; - } - : undefined, onChange: this._onChange }, this.state.dataSource === undefined ? undefined : this.state.dataSource.map(this._renderSelectOption))), - Render.unit(field.options.unitLabel, field.options.showTag, field.options.unitWidth), + React.createElement("div", null, + form.getFieldDecorator(field.name, { + initialValue: this.props.initialValue, + rules: [{ + required: field.options.required, + message: "请填写" + label, + type: mul ? "array" : field.options.valueType, + }], + })(React.createElement(antd_1.Select, { mode: mul ? "multiple" : "default", placeholder: field.options.placeholder, style: { width: field.options.valueWidth || 200 }, showSearch: field.options.filtered, showArrow: field.options.filtered, filterOption: field.options.filtered + ? (value, option) => { + return option.props.children.indexOf(value) >= 0; + } + : undefined, onChange: this._onChange }, this.state.dataSource === undefined ? undefined : this.state.dataSource.map(this._renderSelectOption))), + Render.unit(field.options.unitLabel, field.options.showTag, field.options.unitWidth)), Render.description(field.options.description, field.options.showTag))); } } diff --git a/lib/field/modify/switch.js b/lib/field/modify/switch.js index 2170a48..f17d567 100644 --- a/lib/field/modify/switch.js +++ b/lib/field/modify/switch.js @@ -31,19 +31,20 @@ class SwitchView extends React.PureComponent { const useRadio = field.options.useRadio; const initialValue = this.props.initialValue || false; return (React.createElement(antd_1.Form.Item, { className: "xc-modify-content", label: label }, - form.getFieldDecorator(field.name, { - initialValue: initialValue, - valuePropName: "checked", - rules: [{ - required: field.options.required, - message: "请填写" + label, - }], - })(useRadio - ? React.createElement(antd_1.Radio.Group, { name: field.name, defaultValue: initialValue, style: { width: field.options.valueWidth || 200 }, onChange: this._onRadioChange }, - React.createElement(antd_1.Radio, { value: true }, field.options.trueLabel), - React.createElement(antd_1.Radio, { value: false }, field.options.falseLabel)) - : React.createElement(antd_1.Switch, { checkedChildren: field.options.trueLabel, unCheckedChildren: field.options.falseLabel, style: { width: field.options.valueWidth || "auto" }, onChange: this._onSwitchChange })), - useRadio ? null : Render.unit(field.options.unitLabel, field.options.showTag, field.options.unitWidth), + React.createElement("div", null, + form.getFieldDecorator(field.name, { + initialValue: initialValue, + valuePropName: "checked", + rules: [{ + required: field.options.required, + message: "请填写" + label, + }], + })(useRadio + ? React.createElement(antd_1.Radio.Group, { name: field.name, defaultValue: initialValue, style: { width: field.options.valueWidth || 200 }, onChange: this._onRadioChange }, + React.createElement(antd_1.Radio, { value: true }, field.options.trueLabel), + React.createElement(antd_1.Radio, { value: false }, field.options.falseLabel)) + : React.createElement(antd_1.Switch, { checkedChildren: field.options.trueLabel, unCheckedChildren: field.options.falseLabel, style: { width: field.options.valueWidth || "auto" }, onChange: this._onSwitchChange })), + useRadio ? null : Render.unit(field.options.unitLabel, field.options.showTag, field.options.unitWidth)), Render.description(field.options.description, field.options.showTag))); } } diff --git a/lib/field/modify/text.js b/lib/field/modify/text.js index f8e2610..fe197bf 100644 --- a/lib/field/modify/text.js +++ b/lib/field/modify/text.js @@ -19,15 +19,16 @@ class TextView extends React.PureComponent { const form = this.props.form; const label = field.options.label || field.label; return (React.createElement(antd_1.Form.Item, { className: "xc-modify-content", label: label }, - form.getFieldDecorator(field.name, { - rules: [{ - required: field.options.required, - message: "请填写" + label, - max: field.options.maxLength > 0 ? field.options.maxLength : undefined, - }], - initialValue: this.props.initialValue || "", - })(React.createElement(antd_1.Input, { placeholder: field.options.placeholder, style: { width: field.options.valueWidth || 200 } })), - Render.unit(field.options.unitLabel, field.options.showTag, field.options.unitWidth), + React.createElement("div", null, + form.getFieldDecorator(field.name, { + rules: [{ + required: field.options.required, + message: "请填写" + label, + max: field.options.maxLength > 0 ? field.options.maxLength : undefined, + }], + initialValue: this.props.initialValue || "", + })(React.createElement(antd_1.Input, { placeholder: field.options.placeholder, style: { width: field.options.valueWidth || 200 } })), + Render.unit(field.options.unitLabel, field.options.showTag, field.options.unitWidth)), Render.description(field.options.description, field.options.showTag))); } } diff --git a/src/field/modify/bit_select.tsx b/src/field/modify/bit_select.tsx index d929fe9..377de13 100644 --- a/src/field/modify/bit_select.tsx +++ b/src/field/modify/bit_select.tsx @@ -39,25 +39,27 @@ class BitSelect extends React.PureComponent { {option.fieldLabel} - - {form.getFieldDecorator(this._bitFieldName(option), { - rules: [{ - required: field.options.required, - message: "请填写" + option.fieldLabel, - }], - initialValue: this._getDefaultValue(option), - })( - - {option.values.map((v, i) => ( - - {option.labels[i]} - - ))} - - )} + +
+ {form.getFieldDecorator(this._bitFieldName(option), { + rules: [{ + required: field.options.required, + message: "请填写" + option.fieldLabel, + }], + initialValue: this._getDefaultValue(option), + })( + + {option.values.map((v, i) => ( + + {option.labels[i]} + + ))} + + )} +
{Render.description(option.description, option.showTag)}
diff --git a/src/field/modify/date_time.tsx b/src/field/modify/date_time.tsx index f081749..d923d29 100644 --- a/src/field/modify/date_time.tsx +++ b/src/field/modify/date_time.tsx @@ -26,30 +26,32 @@ class DateTime extends React.PureComponent { } return ( - {form.getFieldDecorator(Storage.Prefix + field.name, { - initialValue: initialValue, - rules: [{ - required: field.options.required, - message: "请填写" + label, - }] - })( - onlyTime ? ( - - ) : ( - - ) - )} +
+ {form.getFieldDecorator(Storage.Prefix + field.name, { + initialValue: initialValue, + rules: [{ + required: field.options.required, + message: "请填写" + label, + }] + })( + onlyTime ? ( + + ) : ( + + ) + )} +
{Render.description(field.options.description, field.options.showTag)}
); diff --git a/src/field/modify/select.tsx b/src/field/modify/select.tsx index ae38a0d..18dad39 100644 --- a/src/field/modify/select.tsx +++ b/src/field/modify/select.tsx @@ -42,32 +42,34 @@ class SelectView extends React.PureComponent { const mul = field.options.multiple; return ( - {form.getFieldDecorator(field.name, { - initialValue: this.props.initialValue, - rules: [{ - required: field.options.required, - message: "请填写" + label, - type: mul ? "array" : field.options.valueType, - }], - })( - { + return option.props.children.indexOf(value) >= 0; + } + : undefined } - : undefined - } - onChange={this._onChange} - > - {this.state.dataSource === undefined ? undefined : this.state.dataSource.map(this._renderSelectOption)} - - )} - {Render.unit(field.options.unitLabel, field.options.showTag, field.options.unitWidth)} + onChange={this._onChange} + > + {this.state.dataSource === undefined ? undefined : this.state.dataSource.map(this._renderSelectOption)} + + )} + {Render.unit(field.options.unitLabel, field.options.showTag, field.options.unitWidth)} + {Render.description(field.options.description, field.options.showTag)} ); diff --git a/src/field/modify/switch.tsx b/src/field/modify/switch.tsx index e53e46f..3e2b93d 100644 --- a/src/field/modify/switch.tsx +++ b/src/field/modify/switch.tsx @@ -15,36 +15,38 @@ class SwitchView extends React.PureComponent { const initialValue = this.props.initialValue || false; return ( - {form.getFieldDecorator(field.name, { - initialValue: initialValue, - valuePropName: "checked", - rules: [{ - required: field.options.required, - message: "请填写" + label, - }], - })(useRadio - ? - - {field.options.trueLabel} - - - {field.options.falseLabel} - - - : - )} - {useRadio ? null : Render.unit(field.options.unitLabel, field.options.showTag, field.options.unitWidth)} - {Render.description(field.options.description, field.options.showTag)} +
+ {form.getFieldDecorator(field.name, { + initialValue: initialValue, + valuePropName: "checked", + rules: [{ + required: field.options.required, + message: "请填写" + label, + }], + })(useRadio + ? + + {field.options.trueLabel} + + + {field.options.falseLabel} + + + : + )} + {useRadio ? null : Render.unit(field.options.unitLabel, field.options.showTag, field.options.unitWidth)} +
+ {Render.description(field.options.description, field.options.showTag)}
); } diff --git a/src/field/modify/text.tsx b/src/field/modify/text.tsx index e282dc2..38b3f8b 100644 --- a/src/field/modify/text.tsx +++ b/src/field/modify/text.tsx @@ -14,20 +14,22 @@ class TextView extends React.PureComponent { const label = field.options.label || field.label; return ( - {form.getFieldDecorator(field.name, { - rules: [{ - required: field.options.required, - message: "请填写" + label, - max: field.options.maxLength > 0 ? field.options.maxLength : undefined, - }], - initialValue: this.props.initialValue || "", - })( - - )} - {Render.unit(field.options.unitLabel, field.options.showTag, field.options.unitWidth)} +
+ {form.getFieldDecorator(field.name, { + rules: [{ + required: field.options.required, + message: "请填写" + label, + max: field.options.maxLength > 0 ? field.options.maxLength : undefined, + }], + initialValue: this.props.initialValue || "", + })( + + )} + {Render.unit(field.options.unitLabel, field.options.showTag, field.options.unitWidth)} +
{Render.description(field.options.description, field.options.showTag)}
); -- Gitee From 02ced4d7e1137feb5849287fe12f9a4b848a4f29 Mon Sep 17 00:00:00 2001 From: leexs Date: Tue, 21 Mar 2023 09:59:47 +0800 Subject: [PATCH 03/33] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=A1=A8=E5=8D=95?= =?UTF-8?q?=E5=92=8C=E9=AA=8C=E8=AF=81=E7=BB=93=E6=9E=9C=E7=9A=84=E5=88=86?= =?UTF-8?q?=E9=9A=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/field/modify/bit_select.js | 17 ++++----- lib/field/modify/date_time.js | 17 ++++----- lib/field/modify/digit.js | 19 +++++----- lib/field/modify/select.js | 29 +++++++-------- lib/field/modify/switch.js | 29 +++++++-------- lib/field/modify/text.js | 21 +++++------ src/field/modify/bit_select.tsx | 42 +++++++++++----------- src/field/modify/date_time.tsx | 54 ++++++++++++++-------------- src/field/modify/digit.tsx | 38 ++++++++++---------- src/field/modify/select.tsx | 56 +++++++++++++++-------------- src/field/modify/switch.tsx | 64 +++++++++++++++++---------------- src/field/modify/text.tsx | 34 +++++++++--------- 12 files changed, 219 insertions(+), 201 deletions(-) diff --git a/lib/field/modify/bit_select.js b/lib/field/modify/bit_select.js index d3b9bd0..5174fe6 100644 --- a/lib/field/modify/bit_select.js +++ b/lib/field/modify/bit_select.js @@ -23,14 +23,15 @@ class BitSelect extends React.PureComponent { React.createElement(antd_1.Col, { span: field.options.colSpan }, option.fieldLabel), React.createElement(antd_1.Col, { span: 24 - field.options.colSpan }, React.createElement(antd_1.Form.Item, { className: "xc-modify-content" }, - React.createElement("div", null, form.getFieldDecorator(this._bitFieldName(option), { - rules: [{ - required: field.options.required, - message: "请填写" + option.fieldLabel, - }], - initialValue: this._getDefaultValue(option), - })(React.createElement(antd_1.Radio.Group, { name: this._bitFieldName(option), onChange: this._onChange.bind(this, option) }, option.values.map((v, i) => (React.createElement(antd_1.Radio, { key: v, value: v }, option.labels[i])))))), - Render.description(option.description, option.showTag))))); + React.createElement("div", null, + React.createElement("div", null, form.getFieldDecorator(this._bitFieldName(option), { + rules: [{ + required: field.options.required, + message: "请填写" + option.fieldLabel, + }], + initialValue: this._getDefaultValue(option), + })(React.createElement(antd_1.Radio.Group, { name: this._bitFieldName(option), onChange: this._onChange.bind(this, option) }, option.values.map((v, i) => (React.createElement(antd_1.Radio, { key: v, value: v }, option.labels[i])))))), + Render.description(option.description, option.showTag)))))); }; this._onChange = (option, e) => { const { form } = this.props; diff --git a/lib/field/modify/date_time.js b/lib/field/modify/date_time.js index 8622788..969b286 100644 --- a/lib/field/modify/date_time.js +++ b/lib/field/modify/date_time.js @@ -85,14 +85,15 @@ class DateTime extends React.PureComponent { } } return (React.createElement(antd_1.Form.Item, { className: "xc-modify-content", label: label }, - React.createElement("div", null, form.getFieldDecorator(Storage.Prefix + field.name, { - initialValue: initialValue, - rules: [{ - required: field.options.required, - message: "请填写" + label, - }] - })(onlyTime ? (React.createElement(antd_1.TimePicker, { placeholder: field.options.placeholder, format: field.options.dateFormat, style: { width: field.options.valueWidth || 200 }, onChange: this._onChange })) : (React.createElement(antd_1.DatePicker, { showTime: field.options.hasTime, placeholder: field.options.placeholder, format: field.options.dateFormat, style: { width: field.options.valueWidth || 200 }, onChange: this._onChange })))), - Render.description(field.options.description, field.options.showTag))); + React.createElement("div", null, + React.createElement("div", null, form.getFieldDecorator(Storage.Prefix + field.name, { + initialValue: initialValue, + rules: [{ + required: field.options.required, + message: "请填写" + label, + }] + })(onlyTime ? (React.createElement(antd_1.TimePicker, { placeholder: field.options.placeholder, format: field.options.dateFormat, style: { width: field.options.valueWidth || 200 }, onChange: this._onChange })) : (React.createElement(antd_1.DatePicker, { showTime: field.options.hasTime, placeholder: field.options.placeholder, format: field.options.dateFormat, style: { width: field.options.valueWidth || 200 }, onChange: this._onChange })))), + Render.description(field.options.description, field.options.showTag)))); } } Storage.set(Field.DateTime.Type, (option) => React.createElement(DateTime, Object.assign({}, option))); diff --git a/lib/field/modify/digit.js b/lib/field/modify/digit.js index 551c0a8..534f4a3 100644 --- a/lib/field/modify/digit.js +++ b/lib/field/modify/digit.js @@ -49,15 +49,16 @@ class Digit extends React.PureComponent { } return (React.createElement(antd_1.Form.Item, { className: "xc-modify-content", label: label }, React.createElement("div", null, - form.getFieldDecorator(Storage.Prefix + field.name, { - rules: [{ - required: field.options.required, - message: "请填写" + label, - }], - initialValue: initialValue, - })(React.createElement(antd_1.InputNumber, { max: field.options.max, min: field.options.min, step: field.options.step, style: { width: field.options.valueWidth || 200 }, onChange: this._onChange })), - Render.unit(field.options.unitLabel, field.options.showTag, field.options.unitWidth)), - Render.description(field.options.description, field.options.showTag))); + React.createElement("div", null, + form.getFieldDecorator(Storage.Prefix + field.name, { + rules: [{ + required: field.options.required, + message: "请填写" + label, + }], + initialValue: initialValue, + })(React.createElement(antd_1.InputNumber, { max: field.options.max, min: field.options.min, step: field.options.step, style: { width: field.options.valueWidth || 200 }, onChange: this._onChange })), + Render.unit(field.options.unitLabel, field.options.showTag, field.options.unitWidth)), + Render.description(field.options.description, field.options.showTag)))); } } Storage.set(Field.Digit.Type, (option) => React.createElement(Digit, Object.assign({}, option))); diff --git a/lib/field/modify/select.js b/lib/field/modify/select.js index 31e6a3b..c964e6c 100644 --- a/lib/field/modify/select.js +++ b/lib/field/modify/select.js @@ -49,20 +49,21 @@ class SelectView extends React.PureComponent { const mul = field.options.multiple; return (React.createElement(antd_1.Form.Item, { className: "xc-modify-content", label: label, hasFeedback: !mul }, React.createElement("div", null, - form.getFieldDecorator(field.name, { - initialValue: this.props.initialValue, - rules: [{ - required: field.options.required, - message: "请填写" + label, - type: mul ? "array" : field.options.valueType, - }], - })(React.createElement(antd_1.Select, { mode: mul ? "multiple" : "default", placeholder: field.options.placeholder, style: { width: field.options.valueWidth || 200 }, showSearch: field.options.filtered, showArrow: field.options.filtered, filterOption: field.options.filtered - ? (value, option) => { - return option.props.children.indexOf(value) >= 0; - } - : undefined, onChange: this._onChange }, this.state.dataSource === undefined ? undefined : this.state.dataSource.map(this._renderSelectOption))), - Render.unit(field.options.unitLabel, field.options.showTag, field.options.unitWidth)), - Render.description(field.options.description, field.options.showTag))); + React.createElement("div", null, + form.getFieldDecorator(field.name, { + initialValue: this.props.initialValue, + rules: [{ + required: field.options.required, + message: "请填写" + label, + type: mul ? "array" : field.options.valueType, + }], + })(React.createElement(antd_1.Select, { mode: mul ? "multiple" : "default", placeholder: field.options.placeholder, style: { width: field.options.valueWidth || 200 }, showSearch: field.options.filtered, showArrow: field.options.filtered, filterOption: field.options.filtered + ? (value, option) => { + return option.props.children.indexOf(value) >= 0; + } + : undefined, onChange: this._onChange }, this.state.dataSource === undefined ? undefined : this.state.dataSource.map(this._renderSelectOption))), + Render.unit(field.options.unitLabel, field.options.showTag, field.options.unitWidth)), + Render.description(field.options.description, field.options.showTag)))); } } Storage.set(Field.Select.Type, (option) => React.createElement(SelectView, Object.assign({}, option))); diff --git a/lib/field/modify/switch.js b/lib/field/modify/switch.js index f17d567..213f71c 100644 --- a/lib/field/modify/switch.js +++ b/lib/field/modify/switch.js @@ -32,20 +32,21 @@ class SwitchView extends React.PureComponent { const initialValue = this.props.initialValue || false; return (React.createElement(antd_1.Form.Item, { className: "xc-modify-content", label: label }, React.createElement("div", null, - form.getFieldDecorator(field.name, { - initialValue: initialValue, - valuePropName: "checked", - rules: [{ - required: field.options.required, - message: "请填写" + label, - }], - })(useRadio - ? React.createElement(antd_1.Radio.Group, { name: field.name, defaultValue: initialValue, style: { width: field.options.valueWidth || 200 }, onChange: this._onRadioChange }, - React.createElement(antd_1.Radio, { value: true }, field.options.trueLabel), - React.createElement(antd_1.Radio, { value: false }, field.options.falseLabel)) - : React.createElement(antd_1.Switch, { checkedChildren: field.options.trueLabel, unCheckedChildren: field.options.falseLabel, style: { width: field.options.valueWidth || "auto" }, onChange: this._onSwitchChange })), - useRadio ? null : Render.unit(field.options.unitLabel, field.options.showTag, field.options.unitWidth)), - Render.description(field.options.description, field.options.showTag))); + React.createElement("div", null, + form.getFieldDecorator(field.name, { + initialValue: initialValue, + valuePropName: "checked", + rules: [{ + required: field.options.required, + message: "请填写" + label, + }], + })(useRadio + ? React.createElement(antd_1.Radio.Group, { name: field.name, defaultValue: initialValue, style: { width: field.options.valueWidth || 200 }, onChange: this._onRadioChange }, + React.createElement(antd_1.Radio, { value: true }, field.options.trueLabel), + React.createElement(antd_1.Radio, { value: false }, field.options.falseLabel)) + : React.createElement(antd_1.Switch, { checkedChildren: field.options.trueLabel, unCheckedChildren: field.options.falseLabel, style: { width: field.options.valueWidth || "auto" }, onChange: this._onSwitchChange })), + useRadio ? null : Render.unit(field.options.unitLabel, field.options.showTag, field.options.unitWidth)), + Render.description(field.options.description, field.options.showTag)))); } } Storage.set(Field.Switch.Type, (option) => React.createElement(SwitchView, Object.assign({}, option))); diff --git a/lib/field/modify/text.js b/lib/field/modify/text.js index fe197bf..852d03b 100644 --- a/lib/field/modify/text.js +++ b/lib/field/modify/text.js @@ -20,16 +20,17 @@ class TextView extends React.PureComponent { const label = field.options.label || field.label; return (React.createElement(antd_1.Form.Item, { className: "xc-modify-content", label: label }, React.createElement("div", null, - form.getFieldDecorator(field.name, { - rules: [{ - required: field.options.required, - message: "请填写" + label, - max: field.options.maxLength > 0 ? field.options.maxLength : undefined, - }], - initialValue: this.props.initialValue || "", - })(React.createElement(antd_1.Input, { placeholder: field.options.placeholder, style: { width: field.options.valueWidth || 200 } })), - Render.unit(field.options.unitLabel, field.options.showTag, field.options.unitWidth)), - Render.description(field.options.description, field.options.showTag))); + React.createElement("div", null, + form.getFieldDecorator(field.name, { + rules: [{ + required: field.options.required, + message: "请填写" + label, + max: field.options.maxLength > 0 ? field.options.maxLength : undefined, + }], + initialValue: this.props.initialValue || "", + })(React.createElement(antd_1.Input, { placeholder: field.options.placeholder, style: { width: field.options.valueWidth || 200 } })), + Render.unit(field.options.unitLabel, field.options.showTag, field.options.unitWidth)), + Render.description(field.options.description, field.options.showTag)))); } } Storage.set(Field.Text.Type, (option) => React.createElement(TextView, Object.assign({}, option))); diff --git a/src/field/modify/bit_select.tsx b/src/field/modify/bit_select.tsx index 377de13..7666fdd 100644 --- a/src/field/modify/bit_select.tsx +++ b/src/field/modify/bit_select.tsx @@ -40,27 +40,29 @@ class BitSelect extends React.PureComponent { -
- {form.getFieldDecorator(this._bitFieldName(option), { - rules: [{ - required: field.options.required, - message: "请填写" + option.fieldLabel, - }], - initialValue: this._getDefaultValue(option), - })( - - {option.values.map((v, i) => ( - - {option.labels[i]} - - ))} - - )} +
{/* 第一层分隔表单控件和验证结果 */} +
{/* 第二层分隔控件,单位和描述 */} + {form.getFieldDecorator(this._bitFieldName(option), { + rules: [{ + required: field.options.required, + message: "请填写" + option.fieldLabel, + }], + initialValue: this._getDefaultValue(option), + })( + + {option.values.map((v, i) => ( + + {option.labels[i]} + + ))} + + )} +
+ {Render.description(option.description, option.showTag)}
- {Render.description(option.description, option.showTag)} diff --git a/src/field/modify/date_time.tsx b/src/field/modify/date_time.tsx index d923d29..258b9ee 100644 --- a/src/field/modify/date_time.tsx +++ b/src/field/modify/date_time.tsx @@ -26,33 +26,35 @@ class DateTime extends React.PureComponent { } return ( -
- {form.getFieldDecorator(Storage.Prefix + field.name, { - initialValue: initialValue, - rules: [{ - required: field.options.required, - message: "请填写" + label, - }] - })( - onlyTime ? ( - - ) : ( - - ) - )} +
{/* 第一层分隔表单控件和验证结果 */} +
{/* 第二层分隔控件,单位和描述 */} + {form.getFieldDecorator(Storage.Prefix + field.name, { + initialValue: initialValue, + rules: [{ + required: field.options.required, + message: "请填写" + label, + }] + })( + onlyTime ? ( + + ) : ( + + ) + )} +
+ {Render.description(field.options.description, field.options.showTag)}
- {Render.description(field.options.description, field.options.showTag)} ); } diff --git a/src/field/modify/digit.tsx b/src/field/modify/digit.tsx index 106ab03..82489a2 100644 --- a/src/field/modify/digit.tsx +++ b/src/field/modify/digit.tsx @@ -26,25 +26,27 @@ class Digit extends React.PureComponent { } return ( -
- {form.getFieldDecorator(Storage.Prefix + field.name, { - rules: [{ - required: field.options.required, - message: "请填写" + label, - }], - initialValue: initialValue, - })( - - )} - {Render.unit(field.options.unitLabel, field.options.showTag, field.options.unitWidth)} +
{/* 第一层分隔表单控件和验证结果 */} +
{/* 第二层分隔控件,单位和描述 */} + {form.getFieldDecorator(Storage.Prefix + field.name, { + rules: [{ + required: field.options.required, + message: "请填写" + label, + }], + initialValue: initialValue, + })( + + )} + {Render.unit(field.options.unitLabel, field.options.showTag, field.options.unitWidth)} +
+ {Render.description(field.options.description, field.options.showTag)}
- {Render.description(field.options.description, field.options.showTag)} ); } diff --git a/src/field/modify/select.tsx b/src/field/modify/select.tsx index 18dad39..f32be5d 100644 --- a/src/field/modify/select.tsx +++ b/src/field/modify/select.tsx @@ -42,35 +42,37 @@ class SelectView extends React.PureComponent { const mul = field.options.multiple; return ( -
- {form.getFieldDecorator(field.name, { - initialValue: this.props.initialValue, - rules: [{ - required: field.options.required, - message: "请填写" + label, - type: mul ? "array" : field.options.valueType, - }], - })( - { + return option.props.children.indexOf(value) >= 0; + } + : undefined } - : undefined - } - onChange={this._onChange} - > - {this.state.dataSource === undefined ? undefined : this.state.dataSource.map(this._renderSelectOption)} - - )} - {Render.unit(field.options.unitLabel, field.options.showTag, field.options.unitWidth)} + onChange={this._onChange} + > + {this.state.dataSource === undefined ? undefined : this.state.dataSource.map(this._renderSelectOption)} + + )} + {Render.unit(field.options.unitLabel, field.options.showTag, field.options.unitWidth)} +
+ {Render.description(field.options.description, field.options.showTag)}
- {Render.description(field.options.description, field.options.showTag)}
); } diff --git a/src/field/modify/switch.tsx b/src/field/modify/switch.tsx index 3e2b93d..63a5173 100644 --- a/src/field/modify/switch.tsx +++ b/src/field/modify/switch.tsx @@ -15,38 +15,40 @@ class SwitchView extends React.PureComponent { const initialValue = this.props.initialValue || false; return ( -
- {form.getFieldDecorator(field.name, { - initialValue: initialValue, - valuePropName: "checked", - rules: [{ - required: field.options.required, - message: "请填写" + label, - }], - })(useRadio - ? - - {field.options.trueLabel} - - - {field.options.falseLabel} - - - : - )} - {useRadio ? null : Render.unit(field.options.unitLabel, field.options.showTag, field.options.unitWidth)} +
{/* 第一层分隔表单控件和验证结果 */} +
{/* 第二层分隔控件,单位和描述 */} + {form.getFieldDecorator(field.name, { + initialValue: initialValue, + valuePropName: "checked", + rules: [{ + required: field.options.required, + message: "请填写" + label, + }], + })(useRadio + ? + + {field.options.trueLabel} + + + {field.options.falseLabel} + + + : + )} + {useRadio ? null : Render.unit(field.options.unitLabel, field.options.showTag, field.options.unitWidth)} +
+ {Render.description(field.options.description, field.options.showTag)}
- {Render.description(field.options.description, field.options.showTag)} ); } diff --git a/src/field/modify/text.tsx b/src/field/modify/text.tsx index 38b3f8b..97885fc 100644 --- a/src/field/modify/text.tsx +++ b/src/field/modify/text.tsx @@ -14,23 +14,25 @@ class TextView extends React.PureComponent { const label = field.options.label || field.label; return ( -
- {form.getFieldDecorator(field.name, { - rules: [{ - required: field.options.required, - message: "请填写" + label, - max: field.options.maxLength > 0 ? field.options.maxLength : undefined, - }], - initialValue: this.props.initialValue || "", - })( - - )} - {Render.unit(field.options.unitLabel, field.options.showTag, field.options.unitWidth)} +
{/* 第一层分隔表单控件和验证结果 */} +
{/* 第二层分隔控件,单位和描述 */} + {form.getFieldDecorator(field.name, { + rules: [{ + required: field.options.required, + message: "请填写" + label, + max: field.options.maxLength > 0 ? field.options.maxLength : undefined, + }], + initialValue: this.props.initialValue || "", + })( + + )} + {Render.unit(field.options.unitLabel, field.options.showTag, field.options.unitWidth)} +
+ {Render.description(field.options.description, field.options.showTag)}
- {Render.description(field.options.description, field.options.showTag)} ); } -- Gitee From 75425f61a9c553af86cbedd78cdd81c345cd6aa5 Mon Sep 17 00:00:00 2001 From: leexs Date: Tue, 21 Mar 2023 11:52:06 +0800 Subject: [PATCH 04/33] =?UTF-8?q?=E5=8D=95=E4=BD=8D=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E6=81=A2=E5=A4=8D=E4=B8=BAundefined=E4=B8=8D=E6=98=BE=E7=A4=BA?= =?UTF-8?q?tag?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/field/detail/digit.js | 2 +- lib/field/detail/select.js | 2 +- lib/field/detail/switch.js | 2 +- lib/field/detail/text.js | 2 +- lib/field/modify/digit.js | 2 +- lib/field/modify/select.js | 2 +- lib/field/modify/switch.js | 2 +- lib/field/modify/text.js | 2 +- lib/field/util/render.js | 2 +- src/field/detail/digit.tsx | 2 +- src/field/detail/select.tsx | 2 +- src/field/detail/switch.tsx | 2 +- src/field/detail/text.tsx | 2 +- src/field/modify/digit.tsx | 2 +- src/field/modify/select.tsx | 2 +- src/field/modify/switch.tsx | 2 +- src/field/modify/text.tsx | 2 +- src/field/util/render.tsx | 2 +- 18 files changed, 18 insertions(+), 18 deletions(-) diff --git a/lib/field/detail/digit.js b/lib/field/detail/digit.js index bc202b7..ff96ec2 100644 --- a/lib/field/detail/digit.js +++ b/lib/field/detail/digit.js @@ -29,7 +29,7 @@ class DigitView extends React.PureComponent { ? React.createElement("div", { className: "xc-detail-content" }) : React.createElement("div", { className: "xc-detail-content" }, React.createElement("span", { style: { width: field.options.valueWidth || "auto" } }, value), - Render.unit(field.options.unitLabel, field.options.showTag, field.options.unitWidth), + Render.unit(field.options.unitLabel, false, field.options.unitWidth), Render.description(field.options.description, field.options.showTag)); } } diff --git a/lib/field/detail/select.js b/lib/field/detail/select.js index 6f79359..1f14d82 100644 --- a/lib/field/detail/select.js +++ b/lib/field/detail/select.js @@ -56,7 +56,7 @@ class Select extends React.PureComponent { ? React.createElement("div", { className: "xc-detail-content" }) : React.createElement("div", { className: "xc-detail-content" }, React.createElement("span", { style: { width: field.options.valueWidth || "auto" } }, value), - Render.unit(field.options.unitLabel, field.options.showTag, field.options.unitWidth), + Render.unit(field.options.unitLabel, false, field.options.unitWidth), Render.description(field.options.description, field.options.showTag)); } } diff --git a/lib/field/detail/switch.js b/lib/field/detail/switch.js index b0c7e7f..e549e56 100644 --- a/lib/field/detail/switch.js +++ b/lib/field/detail/switch.js @@ -32,7 +32,7 @@ class Switch extends React.PureComponent { ? (b ? React.createElement("span", { style: { width: "15px", height: "15px", backgroundColor: "green", borderRadius: "50%" } }) : React.createElement("span", { style: { width: "15px", height: "15px", backgroundColor: "red", borderRadius: "50%" } })) - : Render.unit(field.options.unitLabel, field.options.showTag, field.options.unitWidth), + : Render.unit(field.options.unitLabel, false, field.options.unitWidth), Render.description(field.options.description, field.options.showTag)); } ; diff --git a/lib/field/detail/text.js b/lib/field/detail/text.js index 0f05143..398a380 100644 --- a/lib/field/detail/text.js +++ b/lib/field/detail/text.js @@ -25,7 +25,7 @@ class TextView extends React.PureComponent { field.options.render === undefined ? React.createElement("span", { style: { width: field.options.valueWidth || "auto" } }, value) : field.options.render(value), - Render.unit(field.options.unitLabel, field.options.showTag, field.options.unitWidth), + Render.unit(field.options.unitLabel, false, field.options.unitWidth), Render.description(field.options.description, field.options.showTag)); } } diff --git a/lib/field/modify/digit.js b/lib/field/modify/digit.js index 534f4a3..dd6b117 100644 --- a/lib/field/modify/digit.js +++ b/lib/field/modify/digit.js @@ -57,7 +57,7 @@ class Digit extends React.PureComponent { }], initialValue: initialValue, })(React.createElement(antd_1.InputNumber, { max: field.options.max, min: field.options.min, step: field.options.step, style: { width: field.options.valueWidth || 200 }, onChange: this._onChange })), - Render.unit(field.options.unitLabel, field.options.showTag, field.options.unitWidth)), + Render.unit(field.options.unitLabel, true, field.options.unitWidth)), Render.description(field.options.description, field.options.showTag)))); } } diff --git a/lib/field/modify/select.js b/lib/field/modify/select.js index c964e6c..3a22cd6 100644 --- a/lib/field/modify/select.js +++ b/lib/field/modify/select.js @@ -62,7 +62,7 @@ class SelectView extends React.PureComponent { return option.props.children.indexOf(value) >= 0; } : undefined, onChange: this._onChange }, this.state.dataSource === undefined ? undefined : this.state.dataSource.map(this._renderSelectOption))), - Render.unit(field.options.unitLabel, field.options.showTag, field.options.unitWidth)), + Render.unit(field.options.unitLabel, true, field.options.unitWidth)), Render.description(field.options.description, field.options.showTag)))); } } diff --git a/lib/field/modify/switch.js b/lib/field/modify/switch.js index 213f71c..fbf6299 100644 --- a/lib/field/modify/switch.js +++ b/lib/field/modify/switch.js @@ -45,7 +45,7 @@ class SwitchView extends React.PureComponent { React.createElement(antd_1.Radio, { value: true }, field.options.trueLabel), React.createElement(antd_1.Radio, { value: false }, field.options.falseLabel)) : React.createElement(antd_1.Switch, { checkedChildren: field.options.trueLabel, unCheckedChildren: field.options.falseLabel, style: { width: field.options.valueWidth || "auto" }, onChange: this._onSwitchChange })), - useRadio ? null : Render.unit(field.options.unitLabel, field.options.showTag, field.options.unitWidth)), + useRadio ? null : Render.unit(field.options.unitLabel, true, field.options.unitWidth)), Render.description(field.options.description, field.options.showTag)))); } } diff --git a/lib/field/modify/text.js b/lib/field/modify/text.js index 852d03b..c391620 100644 --- a/lib/field/modify/text.js +++ b/lib/field/modify/text.js @@ -29,7 +29,7 @@ class TextView extends React.PureComponent { }], initialValue: this.props.initialValue || "", })(React.createElement(antd_1.Input, { placeholder: field.options.placeholder, style: { width: field.options.valueWidth || 200 } })), - Render.unit(field.options.unitLabel, field.options.showTag, field.options.unitWidth)), + Render.unit(field.options.unitLabel, true, field.options.unitWidth)), Render.description(field.options.description, field.options.showTag)))); } } diff --git a/lib/field/util/render.js b/lib/field/util/render.js index baa694c..ce9647b 100644 --- a/lib/field/util/render.js +++ b/lib/field/util/render.js @@ -11,7 +11,7 @@ const React = __importStar(require("react")); const antd_1 = require("antd"); function unit(unit, tag, witdh) { return unit - ? (tag === undefined || tag === true + ? (tag === true ? React.createElement(antd_1.Tag, { color: "#2db7f5", style: { width: witdh || "auto", textAlign: "center" } }, unit) : React.createElement("span", null, unit)) : null; } diff --git a/src/field/detail/digit.tsx b/src/field/detail/digit.tsx index 18e5f9c..4ebbd1c 100644 --- a/src/field/detail/digit.tsx +++ b/src/field/detail/digit.tsx @@ -24,7 +24,7 @@ class DigitView extends React.PureComponent { {value} - {Render.unit(field.options.unitLabel, field.options.showTag, field.options.unitWidth)} + {Render.unit(field.options.unitLabel, false, field.options.unitWidth)} {Render.description(field.options.description, field.options.showTag)}
; } diff --git a/src/field/detail/select.tsx b/src/field/detail/select.tsx index cf36b4b..d694ab1 100644 --- a/src/field/detail/select.tsx +++ b/src/field/detail/select.tsx @@ -57,7 +57,7 @@ class Select extends React.PureComponent { {value} - {Render.unit(field.options.unitLabel, field.options.showTag, field.options.unitWidth)} + {Render.unit(field.options.unitLabel, false, field.options.unitWidth)} {Render.description(field.options.description, field.options.showTag)}
; } diff --git a/src/field/detail/switch.tsx b/src/field/detail/switch.tsx index 98d8169..36a956c 100644 --- a/src/field/detail/switch.tsx +++ b/src/field/detail/switch.tsx @@ -29,7 +29,7 @@ class Switch extends React.PureComponent { ? : ) - : Render.unit(field.options.unitLabel, field.options.showTag, field.options.unitWidth) + : Render.unit(field.options.unitLabel, false, field.options.unitWidth) } {Render.description(field.options.description, field.options.showTag)}
; diff --git a/src/field/detail/text.tsx b/src/field/detail/text.tsx index 674ff28..ea7296a 100644 --- a/src/field/detail/text.tsx +++ b/src/field/detail/text.tsx @@ -22,7 +22,7 @@ class TextView extends React.PureComponent { : field.options.render(value) } - {Render.unit(field.options.unitLabel, field.options.showTag, field.options.unitWidth)} + {Render.unit(field.options.unitLabel, false, field.options.unitWidth)} {Render.description(field.options.description, field.options.showTag)}
; } diff --git a/src/field/modify/digit.tsx b/src/field/modify/digit.tsx index 82489a2..7b894bd 100644 --- a/src/field/modify/digit.tsx +++ b/src/field/modify/digit.tsx @@ -43,7 +43,7 @@ class Digit extends React.PureComponent { onChange={this._onChange} /> )} - {Render.unit(field.options.unitLabel, field.options.showTag, field.options.unitWidth)} + {Render.unit(field.options.unitLabel, true, field.options.unitWidth)} {Render.description(field.options.description, field.options.showTag)} diff --git a/src/field/modify/select.tsx b/src/field/modify/select.tsx index f32be5d..46e7e3b 100644 --- a/src/field/modify/select.tsx +++ b/src/field/modify/select.tsx @@ -69,7 +69,7 @@ class SelectView extends React.PureComponent { {this.state.dataSource === undefined ? undefined : this.state.dataSource.map(this._renderSelectOption)} )} - {Render.unit(field.options.unitLabel, field.options.showTag, field.options.unitWidth)} + {Render.unit(field.options.unitLabel, true, field.options.unitWidth)} {Render.description(field.options.description, field.options.showTag)} diff --git a/src/field/modify/switch.tsx b/src/field/modify/switch.tsx index 63a5173..c1f2ccf 100644 --- a/src/field/modify/switch.tsx +++ b/src/field/modify/switch.tsx @@ -45,7 +45,7 @@ class SwitchView extends React.PureComponent { onChange={this._onSwitchChange} /> )} - {useRadio ? null : Render.unit(field.options.unitLabel, field.options.showTag, field.options.unitWidth)} + {useRadio ? null : Render.unit(field.options.unitLabel, true, field.options.unitWidth)} {Render.description(field.options.description, field.options.showTag)} diff --git a/src/field/modify/text.tsx b/src/field/modify/text.tsx index 97885fc..ff8f37b 100644 --- a/src/field/modify/text.tsx +++ b/src/field/modify/text.tsx @@ -29,7 +29,7 @@ class TextView extends React.PureComponent { style={{ width: field.options.valueWidth || 200 }} /> )} - {Render.unit(field.options.unitLabel, field.options.showTag, field.options.unitWidth)} + {Render.unit(field.options.unitLabel, true, field.options.unitWidth)} {Render.description(field.options.description, field.options.showTag)} diff --git a/src/field/util/render.tsx b/src/field/util/render.tsx index 81d8b3a..7a82ad5 100644 --- a/src/field/util/render.tsx +++ b/src/field/util/render.tsx @@ -3,7 +3,7 @@ import { Tag } from 'antd'; export function unit(unit?: string, tag?: boolean, witdh?: number) { return unit - ? (tag === undefined || tag === true + ? (tag === true ? Date: Tue, 21 Mar 2023 14:30:09 +0800 Subject: [PATCH 05/33] =?UTF-8?q?detail=E7=9A=84=E6=8F=90=E7=A4=BA?= =?UTF-8?q?=E6=94=B9=E5=9C=A8label=E5=A4=84=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/field/detail/bit_select.js | 8 ++------ lib/field/detail/date_time.js | 4 +--- lib/field/detail/digit.js | 3 +-- lib/field/detail/select.js | 3 +-- lib/field/detail/switch.js | 3 +-- lib/field/detail/text.js | 3 +-- lib/field/detail/tree_select.js | 4 +--- lib/page/detail.d.ts | 1 + lib/page/detail.js | 15 +++++++++++++-- src/field/detail/bit_select.tsx | 2 -- src/field/detail/date_time.tsx | 1 - src/field/detail/digit.tsx | 1 - src/field/detail/select.tsx | 1 - src/field/detail/switch.tsx | 1 - src/field/detail/text.tsx | 1 - src/field/detail/tree_select.tsx | 1 - src/page/detail.tsx | 15 ++++++++++++++- 17 files changed, 36 insertions(+), 31 deletions(-) diff --git a/lib/field/detail/bit_select.js b/lib/field/detail/bit_select.js index 6d72c6d..6b3d024 100644 --- a/lib/field/detail/bit_select.js +++ b/lib/field/detail/bit_select.js @@ -9,7 +9,6 @@ var __importStar = (this && this.__importStar) || function (mod) { Object.defineProperty(exports, "__esModule", { value: true }); const React = __importStar(require("react")); const Storage = __importStar(require("./storage")); -const Render = __importStar(require("../util/render")); const Field = __importStar(require("../../config")); class BitSelect extends React.PureComponent { constructor() { @@ -31,9 +30,7 @@ class BitSelect extends React.PureComponent { }; this._renderLine = (item, key) => { const valueLabel = this._getValueLabel(item); - return valueLabel === null ? null : (React.createElement("div", { key: key, className: "xc-bit-select-view" }, - item.fieldLabel + ": " + valueLabel, - Render.description(item.description, item.showTag))); + return valueLabel === null ? null : (React.createElement("div", { key: key, className: "xc-bit-select-view" }, item.fieldLabel + ": " + valueLabel)); }; } render() { @@ -48,8 +45,7 @@ class BitSelect extends React.PureComponent { const item = field.options.dataSource[idx]; const valueLabel = this._getValueLabel(item); return (React.createElement("div", { className: "xc-detail-content" }, - React.createElement("span", { style: { width: field.options.valueWidth || "auto" } }, valueLabel), - Render.description(item.description, item.showTag))); + React.createElement("span", { style: { width: field.options.valueWidth || "auto" } }, valueLabel))); } return (React.createElement("div", null, field.options.dataSource.map(this._renderLine))); } diff --git a/lib/field/detail/date_time.js b/lib/field/detail/date_time.js index ec59bf0..2515739 100644 --- a/lib/field/detail/date_time.js +++ b/lib/field/detail/date_time.js @@ -13,7 +13,6 @@ Object.defineProperty(exports, "__esModule", { value: true }); const React = __importStar(require("react")); const moment_1 = __importDefault(require("moment")); const Storage = __importStar(require("./storage")); -const Render = __importStar(require("../util/render")); const Field = __importStar(require("../../config")); class DateTime extends React.PureComponent { constructor() { @@ -57,8 +56,7 @@ class DateTime extends React.PureComponent { return value === "" ? React.createElement("div", { className: "xc-detail-content" }) : React.createElement("div", { className: "xc-detail-content" }, - React.createElement("span", { style: { width: field.options.valueWidth || "auto" } }, value), - Render.description(field.options.description, field.options.showTag)); + React.createElement("span", { style: { width: field.options.valueWidth || "auto" } }, value)); } } Storage.set(Field.DateTime.Type, (option) => React.createElement(DateTime, Object.assign({}, option))); diff --git a/lib/field/detail/digit.js b/lib/field/detail/digit.js index ff96ec2..55d0c2c 100644 --- a/lib/field/detail/digit.js +++ b/lib/field/detail/digit.js @@ -29,8 +29,7 @@ class DigitView extends React.PureComponent { ? React.createElement("div", { className: "xc-detail-content" }) : React.createElement("div", { className: "xc-detail-content" }, React.createElement("span", { style: { width: field.options.valueWidth || "auto" } }, value), - Render.unit(field.options.unitLabel, false, field.options.unitWidth), - Render.description(field.options.description, field.options.showTag)); + Render.unit(field.options.unitLabel, false, field.options.unitWidth)); } } Storage.set(Field.Digit.Type, (option) => React.createElement(DigitView, Object.assign({}, option))); diff --git a/lib/field/detail/select.js b/lib/field/detail/select.js index 1f14d82..6cf79e5 100644 --- a/lib/field/detail/select.js +++ b/lib/field/detail/select.js @@ -56,8 +56,7 @@ class Select extends React.PureComponent { ? React.createElement("div", { className: "xc-detail-content" }) : React.createElement("div", { className: "xc-detail-content" }, React.createElement("span", { style: { width: field.options.valueWidth || "auto" } }, value), - Render.unit(field.options.unitLabel, false, field.options.unitWidth), - Render.description(field.options.description, field.options.showTag)); + Render.unit(field.options.unitLabel, false, field.options.unitWidth)); } } Storage.set(Field.Select.Type, (option) => React.createElement(Select, Object.assign({}, option))); diff --git a/lib/field/detail/switch.js b/lib/field/detail/switch.js index e549e56..b2703a8 100644 --- a/lib/field/detail/switch.js +++ b/lib/field/detail/switch.js @@ -32,8 +32,7 @@ class Switch extends React.PureComponent { ? (b ? React.createElement("span", { style: { width: "15px", height: "15px", backgroundColor: "green", borderRadius: "50%" } }) : React.createElement("span", { style: { width: "15px", height: "15px", backgroundColor: "red", borderRadius: "50%" } })) - : Render.unit(field.options.unitLabel, false, field.options.unitWidth), - Render.description(field.options.description, field.options.showTag)); + : Render.unit(field.options.unitLabel, false, field.options.unitWidth)); } ; } diff --git a/lib/field/detail/text.js b/lib/field/detail/text.js index 398a380..4c737e0 100644 --- a/lib/field/detail/text.js +++ b/lib/field/detail/text.js @@ -25,8 +25,7 @@ class TextView extends React.PureComponent { field.options.render === undefined ? React.createElement("span", { style: { width: field.options.valueWidth || "auto" } }, value) : field.options.render(value), - Render.unit(field.options.unitLabel, false, field.options.unitWidth), - Render.description(field.options.description, field.options.showTag)); + Render.unit(field.options.unitLabel, false, field.options.unitWidth)); } } Storage.set(Field.Text.Type, (option) => React.createElement(TextView, Object.assign({}, option))); diff --git a/lib/field/detail/tree_select.js b/lib/field/detail/tree_select.js index 77d69f2..e80954e 100644 --- a/lib/field/detail/tree_select.js +++ b/lib/field/detail/tree_select.js @@ -9,7 +9,6 @@ var __importStar = (this && this.__importStar) || function (mod) { Object.defineProperty(exports, "__esModule", { value: true }); const React = __importStar(require("react")); const Storage = __importStar(require("./storage")); -const Render = __importStar(require("../util/render")); const Field = __importStar(require("../../config")); class TreeSelectView extends React.PureComponent { constructor() { @@ -59,8 +58,7 @@ class TreeSelectView extends React.PureComponent { return value === "" ? React.createElement("div", { className: "xc-detail-content" }) : React.createElement("div", { className: "xc-detail-content" }, - React.createElement("span", { style: { width: field.options.valueWidth || "auto" } }, value), - Render.description(field.options.description, field.options.showTag)); + React.createElement("span", { style: { width: field.options.valueWidth || "auto" } }, value)); } } Storage.set(Field.TreeSelect.Type, (option) => React.createElement(TreeSelectView, Object.assign({}, option))); diff --git a/lib/page/detail.d.ts b/lib/page/detail.d.ts index 0774440..59bc356 100644 --- a/lib/page/detail.d.ts +++ b/lib/page/detail.d.ts @@ -45,6 +45,7 @@ export default class extends React.PureComponent { _renderWithTitle: () => JSX.Element; _renderWithoutTitle: () => JSX.Element; _renderField: (field: Field.Base.DetailConfig) => React.ReactNode[] | JSX.Element; + _renderDescription: (desc?: string | undefined) => JSX.Element | null; _renderAction: () => JSX.Element | null; } export {}; diff --git a/lib/page/detail.js b/lib/page/detail.js index 6de7bf0..e27ee87 100644 --- a/lib/page/detail.js +++ b/lib/page/detail.js @@ -48,7 +48,9 @@ class default_1 extends React.PureComponent { data: this.props.data, }; const DetailFieldNode = DetailFields.get(option); - items.push(React.createElement(antd_1.Descriptions.Item, { key: idx, label: (React.createElement("div", { style: { width: labelWidth } }, item.fieldLabel)), span: field.options.span }, + items.push(React.createElement(antd_1.Descriptions.Item, { key: idx, label: (React.createElement("div", { style: { width: labelWidth } }, + item.fieldLabel, + this._renderDescription(item.description))), span: field.options.span }, React.createElement("div", { style: { width: dataWidth } }, DetailFieldNode))); }); return items; @@ -58,10 +60,19 @@ class default_1 extends React.PureComponent { const option = { field, data: this.props.data }; const label = field.options.label || field.label; const DetailFieldNode = DetailFields.get(option); - return (React.createElement(antd_1.Descriptions.Item, { key: field.name, label: (React.createElement("div", { style: { width: labelWidth } }, label)), span: field.options.span }, + return (React.createElement(antd_1.Descriptions.Item, { key: field.name, label: (React.createElement("div", { style: { width: labelWidth } }, + label, + this._renderDescription(field.options.description))), span: field.options.span }, React.createElement("div", { style: { width: dataWidth } }, DetailFieldNode))); } }; + this._renderDescription = (desc) => { + if (desc === undefined || desc === "") { + return null; + } + return (React.createElement(antd_1.Tooltip, { placement: "top", title: desc, arrowPointAtCenter: true }, + React.createElement(antd_1.Icon, { type: "question-circle" }))); + }; // 渲染按钮 this._renderAction = () => { const labelWidth = this.props.labelWidth || 118; diff --git a/src/field/detail/bit_select.tsx b/src/field/detail/bit_select.tsx index c728298..c541902 100644 --- a/src/field/detail/bit_select.tsx +++ b/src/field/detail/bit_select.tsx @@ -22,7 +22,6 @@ class BitSelect extends React.PureComponent { {valueLabel} - {Render.description(item.description, item.showTag)} ); } @@ -54,7 +53,6 @@ class BitSelect extends React.PureComponent { return valueLabel === null ? null : (
{item.fieldLabel + ": " + valueLabel} - {Render.description(item.description, item.showTag)}
); }; diff --git a/src/field/detail/date_time.tsx b/src/field/detail/date_time.tsx index 61c73fb..ffc92b4 100644 --- a/src/field/detail/date_time.tsx +++ b/src/field/detail/date_time.tsx @@ -16,7 +16,6 @@ class DateTime extends React.PureComponent { {value} - {Render.description(field.options.description, field.options.showTag)} ; } diff --git a/src/field/detail/digit.tsx b/src/field/detail/digit.tsx index 4ebbd1c..269f251 100644 --- a/src/field/detail/digit.tsx +++ b/src/field/detail/digit.tsx @@ -25,7 +25,6 @@ class DigitView extends React.PureComponent { {value} {Render.unit(field.options.unitLabel, false, field.options.unitWidth)} - {Render.description(field.options.description, field.options.showTag)} ; } } diff --git a/src/field/detail/select.tsx b/src/field/detail/select.tsx index d694ab1..646c276 100644 --- a/src/field/detail/select.tsx +++ b/src/field/detail/select.tsx @@ -58,7 +58,6 @@ class Select extends React.PureComponent { {value} {Render.unit(field.options.unitLabel, false, field.options.unitWidth)} - {Render.description(field.options.description, field.options.showTag)} ; } } diff --git a/src/field/detail/switch.tsx b/src/field/detail/switch.tsx index 36a956c..6e8918c 100644 --- a/src/field/detail/switch.tsx +++ b/src/field/detail/switch.tsx @@ -31,7 +31,6 @@ class Switch extends React.PureComponent { ) : Render.unit(field.options.unitLabel, false, field.options.unitWidth) } - {Render.description(field.options.description, field.options.showTag)} ; }; } diff --git a/src/field/detail/text.tsx b/src/field/detail/text.tsx index ea7296a..9bd2acc 100644 --- a/src/field/detail/text.tsx +++ b/src/field/detail/text.tsx @@ -23,7 +23,6 @@ class TextView extends React.PureComponent { : field.options.render(value) } {Render.unit(field.options.unitLabel, false, field.options.unitWidth)} - {Render.description(field.options.description, field.options.showTag)} ; } } diff --git a/src/field/detail/tree_select.tsx b/src/field/detail/tree_select.tsx index 8b5abdd..f524f87 100644 --- a/src/field/detail/tree_select.tsx +++ b/src/field/detail/tree_select.tsx @@ -49,7 +49,6 @@ class TreeSelectView extends React.PureComponent { {value} - {Render.description(field.options.description, field.options.showTag)} ; } diff --git a/src/page/detail.tsx b/src/page/detail.tsx index d2158ae..4fea85c 100644 --- a/src/page/detail.tsx +++ b/src/page/detail.tsx @@ -3,7 +3,7 @@ */ import * as React from 'react'; -import { Tabs, Descriptions } from 'antd'; +import { Tabs, Descriptions, Tooltip, Icon } from 'antd'; import { DescriptionsProps } from 'antd/lib/descriptions'; import * as Field from '../config'; import * as DetailFields from '../field/detail'; @@ -118,6 +118,7 @@ export default class extends React.PureComponent { label={(
{item.fieldLabel} + {this._renderDescription(item.description)}
)} span={field.options.span} @@ -140,6 +141,7 @@ export default class extends React.PureComponent { label={(
{label} + {this._renderDescription(field.options.description)}
)} span={field.options.span} @@ -152,6 +154,17 @@ export default class extends React.PureComponent { } }; + _renderDescription = (desc?: string) => { + if (desc === undefined || desc === "") { + return null; + } + return ( + + + + ); + }; + // 渲染按钮 _renderAction = () => { const labelWidth = this.props.labelWidth || 118; -- Gitee From 0beb5d45a252bdb08ce8b51ce6b905a3a58bec86 Mon Sep 17 00:00:00 2001 From: leexs Date: Tue, 21 Mar 2023 14:36:23 +0800 Subject: [PATCH 06/33] =?UTF-8?q?=E8=AF=A6=E6=83=85=E9=A1=B5=E5=AD=97?= =?UTF-8?q?=E6=AE=B5=E7=9A=84=E6=8F=8F=E8=BF=B0=E6=A0=B7=E5=BC=8F=E8=B0=83?= =?UTF-8?q?=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/page/detail.js | 4 ++-- src/page/detail.tsx | 11 +++++++++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/lib/page/detail.js b/lib/page/detail.js index e27ee87..eb6f753 100644 --- a/lib/page/detail.js +++ b/lib/page/detail.js @@ -70,8 +70,8 @@ class default_1 extends React.PureComponent { if (desc === undefined || desc === "") { return null; } - return (React.createElement(antd_1.Tooltip, { placement: "top", title: desc, arrowPointAtCenter: true }, - React.createElement(antd_1.Icon, { type: "question-circle" }))); + return (React.createElement(antd_1.Tooltip, { title: desc, placement: "top", arrowPointAtCenter: true }, + React.createElement(antd_1.Icon, { type: "question-circle", style: { marginLeft: "4px", color: "#f50" } }))); }; // 渲染按钮 this._renderAction = () => { diff --git a/src/page/detail.tsx b/src/page/detail.tsx index 4fea85c..d20a7b7 100644 --- a/src/page/detail.tsx +++ b/src/page/detail.tsx @@ -159,8 +159,15 @@ export default class extends React.PureComponent { return null; } return ( - - + + ); }; -- Gitee From 774e847475a80b617dd6fd0449c4c648b1024ce1 Mon Sep 17 00:00:00 2001 From: leexs Date: Tue, 21 Mar 2023 14:43:00 +0800 Subject: [PATCH 07/33] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=AD=97=E6=AE=B5?= =?UTF-8?q?=E6=8F=8F=E8=BF=B0=E7=9A=84=E9=BC=A0=E6=A0=87=E6=A0=B7=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/page/detail.js | 2 +- src/page/detail.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/page/detail.js b/lib/page/detail.js index eb6f753..4a497a5 100644 --- a/lib/page/detail.js +++ b/lib/page/detail.js @@ -71,7 +71,7 @@ class default_1 extends React.PureComponent { return null; } return (React.createElement(antd_1.Tooltip, { title: desc, placement: "top", arrowPointAtCenter: true }, - React.createElement(antd_1.Icon, { type: "question-circle", style: { marginLeft: "4px", color: "#f50" } }))); + React.createElement(antd_1.Icon, { type: "question-circle", style: { marginLeft: "4px", color: "#f50", cursor: "pointer" } }))); }; // 渲染按钮 this._renderAction = () => { diff --git a/src/page/detail.tsx b/src/page/detail.tsx index d20a7b7..7ae27c8 100644 --- a/src/page/detail.tsx +++ b/src/page/detail.tsx @@ -166,7 +166,7 @@ export default class extends React.PureComponent { > ); -- Gitee From f73134278ae7ad50fc61de19d431278806594b5e Mon Sep 17 00:00:00 2001 From: leexs Date: Tue, 21 Mar 2023 15:27:00 +0800 Subject: [PATCH 08/33] =?UTF-8?q?=E6=8F=8F=E8=BF=B0=E6=8F=90=E7=A4=BA?= =?UTF-8?q?=E5=BC=BA=E5=88=B6=E4=B8=8D=E6=8D=A2=E8=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/page/detail.js | 2 +- src/page/detail.tsx | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/page/detail.js b/lib/page/detail.js index 4a497a5..c558731 100644 --- a/lib/page/detail.js +++ b/lib/page/detail.js @@ -70,7 +70,7 @@ class default_1 extends React.PureComponent { if (desc === undefined || desc === "") { return null; } - return (React.createElement(antd_1.Tooltip, { title: desc, placement: "top", arrowPointAtCenter: true }, + return (React.createElement(antd_1.Tooltip, { title: desc, placement: "top", arrowPointAtCenter: true, style: { maxWidth: "auto", whiteSpace: "nowrap" } }, React.createElement(antd_1.Icon, { type: "question-circle", style: { marginLeft: "4px", color: "#f50", cursor: "pointer" } }))); }; // 渲染按钮 diff --git a/src/page/detail.tsx b/src/page/detail.tsx index 7ae27c8..a89ddd9 100644 --- a/src/page/detail.tsx +++ b/src/page/detail.tsx @@ -163,6 +163,7 @@ export default class extends React.PureComponent { title={desc} placement="top" arrowPointAtCenter={true} + style={{ maxWidth: "auto", whiteSpace: "nowrap" }} > Date: Tue, 21 Mar 2023 15:40:33 +0800 Subject: [PATCH 09/33] =?UTF-8?q?=E5=AD=97=E6=AE=B5=E6=8F=8F=E8=BF=B0?= =?UTF-8?q?=E7=9A=84=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/page/detail.js | 4 ++-- src/page/detail.tsx | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/page/detail.js b/lib/page/detail.js index c558731..baed12d 100644 --- a/lib/page/detail.js +++ b/lib/page/detail.js @@ -70,8 +70,8 @@ class default_1 extends React.PureComponent { if (desc === undefined || desc === "") { return null; } - return (React.createElement(antd_1.Tooltip, { title: desc, placement: "top", arrowPointAtCenter: true, style: { maxWidth: "auto", whiteSpace: "nowrap" } }, - React.createElement(antd_1.Icon, { type: "question-circle", style: { marginLeft: "4px", color: "#f50", cursor: "pointer" } }))); + return (React.createElement(antd_1.Tooltip, { title: desc, placement: "top", arrowPointAtCenter: true, className: "xc-detail-description" }, + React.createElement(antd_1.Icon, { type: "question-circle", style: { padding: "0 4px", color: "#f50", cursor: "pointer" } }))); }; // 渲染按钮 this._renderAction = () => { diff --git a/src/page/detail.tsx b/src/page/detail.tsx index a89ddd9..1a85884 100644 --- a/src/page/detail.tsx +++ b/src/page/detail.tsx @@ -163,11 +163,11 @@ export default class extends React.PureComponent { title={desc} placement="top" arrowPointAtCenter={true} - style={{ maxWidth: "auto", whiteSpace: "nowrap" }} + className="xc-detail-description" > ); -- Gitee From 93d892f9827fd06b0ac629f0d9b73ee5a558a851 Mon Sep 17 00:00:00 2001 From: leexs Date: Tue, 21 Mar 2023 15:51:38 +0800 Subject: [PATCH 10/33] =?UTF-8?q?=E9=87=87=E7=94=A8overlayClassName?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/page/detail.js | 2 +- src/page/detail.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/page/detail.js b/lib/page/detail.js index baed12d..cd27446 100644 --- a/lib/page/detail.js +++ b/lib/page/detail.js @@ -70,7 +70,7 @@ class default_1 extends React.PureComponent { if (desc === undefined || desc === "") { return null; } - return (React.createElement(antd_1.Tooltip, { title: desc, placement: "top", arrowPointAtCenter: true, className: "xc-detail-description" }, + return (React.createElement(antd_1.Tooltip, { title: desc, placement: "top", arrowPointAtCenter: true, overlayClassName: "xc-detail-description" }, React.createElement(antd_1.Icon, { type: "question-circle", style: { padding: "0 4px", color: "#f50", cursor: "pointer" } }))); }; // 渲染按钮 diff --git a/src/page/detail.tsx b/src/page/detail.tsx index 1a85884..02a52b6 100644 --- a/src/page/detail.tsx +++ b/src/page/detail.tsx @@ -163,7 +163,7 @@ export default class extends React.PureComponent { title={desc} placement="top" arrowPointAtCenter={true} - className="xc-detail-description" + overlayClassName="xc-detail-description" > Date: Tue, 21 Mar 2023 16:17:02 +0800 Subject: [PATCH 11/33] =?UTF-8?q?=E5=AD=97=E6=AE=B5=E6=8F=8F=E8=BF=B0?= =?UTF-8?q?=E6=94=B9=E4=B8=BA=5FrenderLabel=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/page/detail.d.ts | 2 +- lib/page/detail.js | 20 +++++++---------- src/page/detail.tsx | 53 ++++++++++++++++++++------------------------ 3 files changed, 33 insertions(+), 42 deletions(-) diff --git a/lib/page/detail.d.ts b/lib/page/detail.d.ts index 59bc356..cd77297 100644 --- a/lib/page/detail.d.ts +++ b/lib/page/detail.d.ts @@ -45,7 +45,7 @@ export default class extends React.PureComponent { _renderWithTitle: () => JSX.Element; _renderWithoutTitle: () => JSX.Element; _renderField: (field: Field.Base.DetailConfig) => React.ReactNode[] | JSX.Element; - _renderDescription: (desc?: string | undefined) => JSX.Element | null; + _renderLabel: (label: string, width: number, desc?: string | undefined) => JSX.Element; _renderAction: () => JSX.Element | null; } export {}; diff --git a/lib/page/detail.js b/lib/page/detail.js index cd27446..2a0a4a8 100644 --- a/lib/page/detail.js +++ b/lib/page/detail.js @@ -48,9 +48,7 @@ class default_1 extends React.PureComponent { data: this.props.data, }; const DetailFieldNode = DetailFields.get(option); - items.push(React.createElement(antd_1.Descriptions.Item, { key: idx, label: (React.createElement("div", { style: { width: labelWidth } }, - item.fieldLabel, - this._renderDescription(item.description))), span: field.options.span }, + items.push(React.createElement(antd_1.Descriptions.Item, { key: idx, label: this._renderLabel(item.fieldLabel, labelWidth, item.description), span: field.options.span }, React.createElement("div", { style: { width: dataWidth } }, DetailFieldNode))); }); return items; @@ -60,18 +58,16 @@ class default_1 extends React.PureComponent { const option = { field, data: this.props.data }; const label = field.options.label || field.label; const DetailFieldNode = DetailFields.get(option); - return (React.createElement(antd_1.Descriptions.Item, { key: field.name, label: (React.createElement("div", { style: { width: labelWidth } }, - label, - this._renderDescription(field.options.description))), span: field.options.span }, + return (React.createElement(antd_1.Descriptions.Item, { key: field.name, label: this._renderLabel(label, labelWidth, field.options.description), span: field.options.span }, React.createElement("div", { style: { width: dataWidth } }, DetailFieldNode))); } }; - this._renderDescription = (desc) => { - if (desc === undefined || desc === "") { - return null; - } - return (React.createElement(antd_1.Tooltip, { title: desc, placement: "top", arrowPointAtCenter: true, overlayClassName: "xc-detail-description" }, - React.createElement(antd_1.Icon, { type: "question-circle", style: { padding: "0 4px", color: "#f50", cursor: "pointer" } }))); + this._renderLabel = (label, width, desc) => { + return desc === undefined || desc === "" + ? (React.createElement("div", { style: { width: width } }, label)) : (React.createElement(antd_1.Tooltip, { title: desc, placement: "top", arrowPointAtCenter: true, overlayClassName: "xc-detail-description" }, + React.createElement("div", { style: { width: width, cursor: "pointer" } }, + label, + React.createElement(antd_1.Icon, { type: "question-circle", style: { marginLeft: "4px", color: "#f50" } })))); }; // 渲染按钮 this._renderAction = () => { diff --git a/src/page/detail.tsx b/src/page/detail.tsx index 02a52b6..7120c04 100644 --- a/src/page/detail.tsx +++ b/src/page/detail.tsx @@ -115,12 +115,7 @@ export default class extends React.PureComponent { items.push( - {item.fieldLabel} - {this._renderDescription(item.description)} - - )} + label={this._renderLabel(item.fieldLabel, labelWidth, item.description)} span={field.options.span} >
@@ -138,12 +133,7 @@ export default class extends React.PureComponent { return ( - {label} - {this._renderDescription(field.options.description)} -
- )} + label={this._renderLabel(label, labelWidth, field.options.description)} span={field.options.span} >
@@ -154,23 +144,28 @@ export default class extends React.PureComponent { } }; - _renderDescription = (desc?: string) => { - if (desc === undefined || desc === "") { - return null; - } - return ( - - - - ); + _renderLabel = (label: string, width: number, desc?: string) => { + return desc === undefined || desc === "" + ? ( +
+ {label} +
+ ) : ( + +
+ {label} + +
+
+ ); }; // 渲染按钮 -- Gitee From 210c40464233302bc74a22fd37113f9a57cd575c Mon Sep 17 00:00:00 2001 From: leexs Date: Tue, 21 Mar 2023 20:08:15 +0800 Subject: [PATCH 12/33] =?UTF-8?q?=E5=88=97=E8=A1=A8=E7=9A=84=E6=93=8D?= =?UTF-8?q?=E4=BD=9C=E5=88=97=E6=94=B9=E4=B8=BA=E5=BC=B9=E5=87=BA=E8=8F=9C?= =?UTF-8?q?=E5=8D=95=E6=A8=A1=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/page/list.js | 19 +++++++++++-------- src/page/list.tsx | 33 ++++++++++++++++++--------------- 2 files changed, 29 insertions(+), 23 deletions(-) diff --git a/lib/page/list.js b/lib/page/list.js index febbd92..b590a31 100644 --- a/lib/page/list.js +++ b/lib/page/list.js @@ -38,7 +38,7 @@ class ListPage extends React.PureComponent { showTotal: (total) => "共 " + total + " 条", }; }; - // 表格切换页的回调 + // 列表翻页,过滤和排序的操作 this._onTableChange = (pagination, filters, sorter) => { const pageNumber = pagination.current; this._fetchData(pageNumber, filters, sorter); @@ -115,20 +115,22 @@ class ListPage extends React.PureComponent { // 渲染表格"操作"列 this._renderColumnAction = (text, record) => { const actions = this._actions(); - const views = []; + const menus = []; actions.forEach((item, index) => { const enabled = item.enable ? item.enable(record, this.props.mainKey) : true; if (!enabled) { return; } const label = this._getActionLabel(item, "未知", record, this.props.mainKey); - views.push(React.createElement("a", { key: index * 2, onClick: (e) => { - item.onClick && item.onClick(record, this.props.mainKey); - e.stopPropagation(); - } }, label)); - views.push(React.createElement(antd_1.Divider, { key: index * 2 + 1, type: "vertical" })); + menus.push(React.createElement(antd_1.Menu.Item, { key: index }, + React.createElement("span", { onClick: (e) => { + item.onClick && item.onClick(record, this.props.mainKey); + e.stopPropagation(); + } }, label))); + menus.push(React.createElement(antd_1.Menu.Divider, { key: index + actions.length + 1 })); }); - return (React.createElement("span", null, views.slice(0, views.length - 1))); + return (React.createElement(antd_1.Dropdown, { overlay: React.createElement(antd_1.Menu, null, menus.slice(0, menus.length - 1)), trigger: ['click'] }, + React.createElement(antd_1.Icon, { type: "ellipsis", style: { cursor: "pointer" } }))); }; // 获取操作标签 this._getActionLabel = (action, defaultValue, data, mainKey) => { @@ -221,6 +223,7 @@ class ListPage extends React.PureComponent { this.props.deleteAction.onClick(data, mainKey); } }; + // 执行操作 this._onAction = (action, data, mainKey, pn, success, error) => { // 先执行操作再重新加载列表 action(data, mainKey).then(() => { diff --git a/src/page/list.tsx b/src/page/list.tsx index 7bfff6c..a179462 100644 --- a/src/page/list.tsx +++ b/src/page/list.tsx @@ -2,7 +2,7 @@ * 通用的列表页。 */ import * as React from 'react'; -import { Table, Divider, Modal, Alert, message } from 'antd'; +import { Table, Modal, Alert, Dropdown, Menu, Icon, message } from 'antd'; import { PaginationConfig } from 'antd/lib/pagination'; import { TableEventListeners, TableProps, ColumnProps } from 'antd/lib/table'; import * as Field from '../config'; @@ -202,7 +202,7 @@ export default class ListPage extends React.PureComponent { }; }; - // 表格切换页的回调 + // 列表翻页,过滤和排序的操作 _onTableChange = (pagination: PaginationConfig, filters: any, sorter: any) => { const pageNumber = pagination.current as number; this._fetchData(pageNumber, filters, sorter); @@ -313,30 +313,32 @@ export default class ListPage extends React.PureComponent { // 渲染表格"操作"列 _renderColumnAction = (text: string, record: { [key: string]: any }) => { const actions = this._actions(); - const views: React.ReactNode[] = []; + const menus: React.ReactNode[] = []; actions.forEach((item, index) => { const enabled = item.enable ? item.enable(record, this.props.mainKey) : true; if (!enabled) { return; } const label = this._getActionLabel(item, "未知", record, this.props.mainKey); - views.push( - ) => { + menus.push( + + ) => { item.onClick && item.onClick(record, this.props.mainKey); e.stopPropagation(); - }} - > - {label} - + }}> + {label} + + ); - views.push(); + menus.push(); }); return ( - - {views.slice(0, views.length - 1)} - + {menus.slice(0, menus.length - 1)}} + trigger={['click']} + > + + ); }; @@ -432,6 +434,7 @@ export default class ListPage extends React.PureComponent { } }; + // 执行操作 _onAction = (action: (data: any, mainKey: string) => Promise, data: any, mainKey: string, pn: number, success: string, error: string) => { // 先执行操作再重新加载列表 action(data, mainKey).then(() => { -- Gitee From 7e4b494cf21200340341784790a78ac153bcae0e Mon Sep 17 00:00:00 2001 From: leexs Date: Tue, 21 Mar 2023 20:23:18 +0800 Subject: [PATCH 13/33] =?UTF-8?q?=E5=BC=B9=E5=87=BA=E8=8F=9C=E5=8D=95?= =?UTF-8?q?=E9=98=BB=E6=AD=A2=E4=BA=8B=E4=BB=B6=E5=86=92=E6=B3=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/page/list.js | 4 +++- src/page/list.tsx | 8 +++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/page/list.js b/lib/page/list.js index b590a31..a260ccc 100644 --- a/lib/page/list.js +++ b/lib/page/list.js @@ -130,7 +130,9 @@ class ListPage extends React.PureComponent { menus.push(React.createElement(antd_1.Menu.Divider, { key: index + actions.length + 1 })); }); return (React.createElement(antd_1.Dropdown, { overlay: React.createElement(antd_1.Menu, null, menus.slice(0, menus.length - 1)), trigger: ['click'] }, - React.createElement(antd_1.Icon, { type: "ellipsis", style: { cursor: "pointer" } }))); + React.createElement(antd_1.Icon, { type: "ellipsis", style: { cursor: "pointer" }, onClick: (e) => { + e.stopPropagation(); + } }))); }; // 获取操作标签 this._getActionLabel = (action, defaultValue, data, mainKey) => { diff --git a/src/page/list.tsx b/src/page/list.tsx index a179462..333384c 100644 --- a/src/page/list.tsx +++ b/src/page/list.tsx @@ -337,7 +337,13 @@ export default class ListPage extends React.PureComponent { overlay={{menus.slice(0, menus.length - 1)}} trigger={['click']} > - + ) => { + e.stopPropagation(); + }} + /> ); }; -- Gitee From d9c49853a71851781274a07e44a1307b7cc10713 Mon Sep 17 00:00:00 2001 From: leexs Date: Tue, 21 Mar 2023 20:47:47 +0800 Subject: [PATCH 14/33] =?UTF-8?q?=E6=97=A0=E8=8F=9C=E5=8D=95=E6=97=B6?= =?UTF-8?q?=E4=B8=8D=E6=98=BE=E7=A4=BA...=EF=BC=8C=E6=93=8D=E4=BD=9C?= =?UTF-8?q?=E9=A1=B9=E5=A2=9E=E5=8A=A0icon=E5=B1=9E=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/page/list.d.ts | 26 +++++++++++++++----------- lib/page/list.js | 8 +++++++- src/page/list.tsx | 31 +++++++++++++++++++++---------- 3 files changed, 43 insertions(+), 22 deletions(-) diff --git a/lib/page/list.d.ts b/lib/page/list.d.ts index 08311ea..72b77ea 100644 --- a/lib/page/list.d.ts +++ b/lib/page/list.d.ts @@ -18,6 +18,10 @@ export interface FetchDataResult { count: number; } export interface Action { + /** + * 图标类型。 + */ + icon?: string; /** * 文字内容。 */ @@ -35,24 +39,24 @@ export interface Action { */ modalClick?: (data: any, mainKey: string) => Promise; /** - * 弹框模式的标题栏(优先modalField)。 - */ + * 弹框模式的标题栏(优先modalField)。 + */ modalTitle?: string; /** - * 弹框模式标题栏的取值字段(如果modalField和modalTitle都未设置,则不是弹框)。 - */ + * 弹框模式标题栏的取值字段(如果modalField和modalTitle都未设置,则不是弹框)。 + */ modalField?: string; /** - * 弹框模式的内容。 - */ + * 弹框模式的内容。 + */ modalContent?: string; /** - * 弹框模式的操作成功提示。 - */ + * 弹框模式的操作成功提示。 + */ modalSuccessInfo?: string; /** - * 弹框模式的操作错误提示。 - */ + * 弹框模式的操作错误提示。 + */ modalErrorInfo?: string; } interface Props { @@ -161,7 +165,7 @@ export default class ListPage extends React.PureComponent { _actions: () => Action[]; _renderColumnAction: (text: string, record: { [key: string]: any; - }) => JSX.Element; + }) => JSX.Element | null; _getActionLabel: (action: Action, defaultValue: string, data: any, mainKey: string) => any; _onModalClick: (act: Action, data: any, mainKey: string) => void; _onDeleteClick: (data: any, mainKey: string) => void; diff --git a/lib/page/list.js b/lib/page/list.js index a260ccc..bdcb196 100644 --- a/lib/page/list.js +++ b/lib/page/list.js @@ -91,11 +91,12 @@ class ListPage extends React.PureComponent { this._actions = () => { const actions = []; if (this.props.editAction) { - const action = Object.assign(Object.assign({}, this.props.editAction), { label: this.props.editAction.label || "编辑" }); + const action = Object.assign(Object.assign({}, this.props.editAction), { icon: this.props.editAction.icon || "edit", label: this.props.editAction.label || "编辑" }); actions.push(action); } this.props.otherActions.forEach((act) => { const action = { + icon: act.icon || "right", label: act.label, enable: act.enable, onClick: this._onModalClick.bind(this, act), @@ -104,6 +105,7 @@ class ListPage extends React.PureComponent { }); if (this.props.deleteAction) { const action = { + icon: this.props.deleteAction.icon || "delete", label: this.props.deleteAction.label || "删除", enable: this.props.deleteAction.enable, onClick: this._onDeleteClick, @@ -115,6 +117,9 @@ class ListPage extends React.PureComponent { // 渲染表格"操作"列 this._renderColumnAction = (text, record) => { const actions = this._actions(); + if (actions.length === 0) { + return null; + } const menus = []; actions.forEach((item, index) => { const enabled = item.enable ? item.enable(record, this.props.mainKey) : true; @@ -123,6 +128,7 @@ class ListPage extends React.PureComponent { } const label = this._getActionLabel(item, "未知", record, this.props.mainKey); menus.push(React.createElement(antd_1.Menu.Item, { key: index }, + React.createElement(antd_1.Icon, { type: item.icon, style: { marginRight: "12px" } }), React.createElement("span", { onClick: (e) => { item.onClick && item.onClick(record, this.props.mainKey); e.stopPropagation(); diff --git a/src/page/list.tsx b/src/page/list.tsx index 333384c..b66cc39 100644 --- a/src/page/list.tsx +++ b/src/page/list.tsx @@ -20,6 +20,10 @@ export interface FetchDataResult { } export interface Action { + /** + * 图标类型。 + */ + icon?: string; /** * 文字内容。 */ @@ -37,24 +41,24 @@ export interface Action { */ modalClick?: (data: any, mainKey: string) => Promise; /** - * 弹框模式的标题栏(优先modalField)。 - */ + * 弹框模式的标题栏(优先modalField)。 + */ modalTitle?: string; /** - * 弹框模式标题栏的取值字段(如果modalField和modalTitle都未设置,则不是弹框)。 - */ + * 弹框模式标题栏的取值字段(如果modalField和modalTitle都未设置,则不是弹框)。 + */ modalField?: string; /** - * 弹框模式的内容。 - */ + * 弹框模式的内容。 + */ modalContent?: string; /** - * 弹框模式的操作成功提示。 - */ + * 弹框模式的操作成功提示。 + */ modalSuccessInfo?: string; /** - * 弹框模式的操作错误提示。 - */ + * 弹框模式的操作错误提示。 + */ modalErrorInfo?: string; } @@ -287,12 +291,14 @@ export default class ListPage extends React.PureComponent { if (this.props.editAction) { const action: Action = { ...this.props.editAction, + icon: this.props.editAction.icon || "edit", label: this.props.editAction.label || "编辑", }; actions.push(action); } this.props.otherActions.forEach((act) => { const action: Action = { + icon: act.icon || "right", label: act.label, enable: act.enable, onClick: this._onModalClick.bind(this, act), @@ -301,6 +307,7 @@ export default class ListPage extends React.PureComponent { }); if (this.props.deleteAction) { const action: Action = { + icon: this.props.deleteAction.icon || "delete", label: this.props.deleteAction.label || "删除", enable: this.props.deleteAction.enable, onClick: this._onDeleteClick, @@ -313,6 +320,9 @@ export default class ListPage extends React.PureComponent { // 渲染表格"操作"列 _renderColumnAction = (text: string, record: { [key: string]: any }) => { const actions = this._actions(); + if (actions.length === 0) { + return null; + } const menus: React.ReactNode[] = []; actions.forEach((item, index) => { const enabled = item.enable ? item.enable(record, this.props.mainKey) : true; @@ -322,6 +332,7 @@ export default class ListPage extends React.PureComponent { const label = this._getActionLabel(item, "未知", record, this.props.mainKey); menus.push( + ) => { item.onClick && item.onClick(record, this.props.mainKey); e.stopPropagation(); -- Gitee From 7a39fa2daee2388d9debbc2a3a14fdfb9cbdf3e9 Mon Sep 17 00:00:00 2001 From: leexs Date: Tue, 21 Mar 2023 20:56:27 +0800 Subject: [PATCH 15/33] =?UTF-8?q?=E6=93=8D=E4=BD=9C=E9=A1=B9=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E5=92=8C=E7=82=B9=E5=87=BB=E7=9A=84=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/page/list.js | 18 +++++++----------- src/page/list.tsx | 19 ++++++++----------- 2 files changed, 15 insertions(+), 22 deletions(-) diff --git a/lib/page/list.js b/lib/page/list.js index bdcb196..58e4337 100644 --- a/lib/page/list.js +++ b/lib/page/list.js @@ -116,23 +116,19 @@ class ListPage extends React.PureComponent { }; // 渲染表格"操作"列 this._renderColumnAction = (text, record) => { - const actions = this._actions(); + const actions = this._actions().filter((a) => a.enable ? a.enable(record, this.props.mainKey) : true); if (actions.length === 0) { return null; } const menus = []; actions.forEach((item, index) => { - const enabled = item.enable ? item.enable(record, this.props.mainKey) : true; - if (!enabled) { - return; - } const label = this._getActionLabel(item, "未知", record, this.props.mainKey); - menus.push(React.createElement(antd_1.Menu.Item, { key: index }, - React.createElement(antd_1.Icon, { type: item.icon, style: { marginRight: "12px" } }), - React.createElement("span", { onClick: (e) => { - item.onClick && item.onClick(record, this.props.mainKey); - e.stopPropagation(); - } }, label))); + menus.push(React.createElement(antd_1.Menu.Item, { key: index, onClick: (e) => { + item.onClick && item.onClick(record, this.props.mainKey); + e.stopPropagation(); + } }, + React.createElement(antd_1.Icon, { type: item.icon, style: { marginRight: "16px" } }), + React.createElement("span", null, label))); menus.push(React.createElement(antd_1.Menu.Divider, { key: index + actions.length + 1 })); }); return (React.createElement(antd_1.Dropdown, { overlay: React.createElement(antd_1.Menu, null, menus.slice(0, menus.length - 1)), trigger: ['click'] }, diff --git a/src/page/list.tsx b/src/page/list.tsx index b66cc39..e2d2d2a 100644 --- a/src/page/list.tsx +++ b/src/page/list.tsx @@ -319,26 +319,23 @@ export default class ListPage extends React.PureComponent { // 渲染表格"操作"列 _renderColumnAction = (text: string, record: { [key: string]: any }) => { - const actions = this._actions(); + const actions = this._actions().filter((a) => a.enable ? a.enable(record, this.props.mainKey) : true); if (actions.length === 0) { return null; } const menus: React.ReactNode[] = []; actions.forEach((item, index) => { - const enabled = item.enable ? item.enable(record, this.props.mainKey) : true; - if (!enabled) { - return; - } const label = this._getActionLabel(item, "未知", record, this.props.mainKey); menus.push( - - - ) => { + { item.onClick && item.onClick(record, this.props.mainKey); e.stopPropagation(); - }}> - {label} - + }} + > + + {label} ); menus.push(); -- Gitee From 1c2388e9126433a384371d9ef693079e39fd473f Mon Sep 17 00:00:00 2001 From: leexs Date: Tue, 21 Mar 2023 21:03:01 +0800 Subject: [PATCH 16/33] =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E8=8F=9C=E5=8D=95?= =?UTF-8?q?=E5=BC=B9=E5=87=BA=E4=BD=8D=E7=BD=AE=E4=B8=BAibottomRight?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/page/list.js | 4 ++-- src/page/list.tsx | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/page/list.js b/lib/page/list.js index 58e4337..713f2e1 100644 --- a/lib/page/list.js +++ b/lib/page/list.js @@ -131,8 +131,8 @@ class ListPage extends React.PureComponent { React.createElement("span", null, label))); menus.push(React.createElement(antd_1.Menu.Divider, { key: index + actions.length + 1 })); }); - return (React.createElement(antd_1.Dropdown, { overlay: React.createElement(antd_1.Menu, null, menus.slice(0, menus.length - 1)), trigger: ['click'] }, - React.createElement(antd_1.Icon, { type: "ellipsis", style: { cursor: "pointer" }, onClick: (e) => { + return (React.createElement(antd_1.Dropdown, { overlay: React.createElement(antd_1.Menu, null, menus.slice(0, menus.length - 1)), trigger: ['click'], placement: "bottomRight" }, + React.createElement(antd_1.Icon, { type: "ellipsis", style: { padding: "0 12px", cursor: "pointer" }, onClick: (e) => { e.stopPropagation(); } }))); }; diff --git a/src/page/list.tsx b/src/page/list.tsx index e2d2d2a..356539f 100644 --- a/src/page/list.tsx +++ b/src/page/list.tsx @@ -344,10 +344,11 @@ export default class ListPage extends React.PureComponent { {menus.slice(0, menus.length - 1)}} trigger={['click']} + placement={"bottomRight"} > ) => { e.stopPropagation(); }} -- Gitee From 7f2adf3bdb3fc4ab9f0ab688e810b8cce4ef4d55 Mon Sep 17 00:00:00 2001 From: leexs Date: Wed, 22 Mar 2023 11:50:05 +0800 Subject: [PATCH 17/33] =?UTF-8?q?=E6=93=8D=E4=BD=9C=E9=A1=B9=E5=8D=95?= =?UTF-8?q?=E7=8B=AC=E7=94=9F=E6=88=90=E6=8E=A7=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/page/list.d.ts | 3 +- lib/page/list.js | 39 +++------------ lib/page/list_col_action.d.ts | 32 +++++++++++++ lib/page/list_col_action.js | 62 ++++++++++++++++++++++++ src/page/list.tsx | 56 ++++------------------ src/page/list_col_action.tsx | 90 +++++++++++++++++++++++++++++++++++ 6 files changed, 199 insertions(+), 83 deletions(-) create mode 100644 lib/page/list_col_action.d.ts create mode 100644 lib/page/list_col_action.js create mode 100644 src/page/list_col_action.tsx diff --git a/lib/page/list.d.ts b/lib/page/list.d.ts index 72b77ea..d12e16e 100644 --- a/lib/page/list.d.ts +++ b/lib/page/list.d.ts @@ -165,8 +165,7 @@ export default class ListPage extends React.PureComponent { _actions: () => Action[]; _renderColumnAction: (text: string, record: { [key: string]: any; - }) => JSX.Element | null; - _getActionLabel: (action: Action, defaultValue: string, data: any, mainKey: string) => any; + }) => JSX.Element; _onModalClick: (act: Action, data: any, mainKey: string) => void; _onDeleteClick: (data: any, mainKey: string) => void; _onAction: (action: (data: any, mainKey: string) => Promise, data: any, mainKey: string, pn: number, success: string, error: string) => void; diff --git a/lib/page/list.js b/lib/page/list.js index 713f2e1..d55f012 100644 --- a/lib/page/list.js +++ b/lib/page/list.js @@ -6,12 +6,16 @@ var __importStar = (this && this.__importStar) || function (mod) { result["default"] = mod; return result; }; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; Object.defineProperty(exports, "__esModule", { value: true }); /** * 通用的列表页。 */ const React = __importStar(require("react")); const antd_1 = require("antd"); +const list_col_action_1 = __importDefault(require("./list_col_action")); const DetailFields = __importStar(require("../field/detail")); class ListPage extends React.PureComponent { constructor() { @@ -96,7 +100,7 @@ class ListPage extends React.PureComponent { } this.props.otherActions.forEach((act) => { const action = { - icon: act.icon || "right", + icon: act.icon, label: act.label, enable: act.enable, onClick: this._onModalClick.bind(this, act), @@ -116,38 +120,7 @@ class ListPage extends React.PureComponent { }; // 渲染表格"操作"列 this._renderColumnAction = (text, record) => { - const actions = this._actions().filter((a) => a.enable ? a.enable(record, this.props.mainKey) : true); - if (actions.length === 0) { - return null; - } - const menus = []; - actions.forEach((item, index) => { - const label = this._getActionLabel(item, "未知", record, this.props.mainKey); - menus.push(React.createElement(antd_1.Menu.Item, { key: index, onClick: (e) => { - item.onClick && item.onClick(record, this.props.mainKey); - e.stopPropagation(); - } }, - React.createElement(antd_1.Icon, { type: item.icon, style: { marginRight: "16px" } }), - React.createElement("span", null, label))); - menus.push(React.createElement(antd_1.Menu.Divider, { key: index + actions.length + 1 })); - }); - return (React.createElement(antd_1.Dropdown, { overlay: React.createElement(antd_1.Menu, null, menus.slice(0, menus.length - 1)), trigger: ['click'], placement: "bottomRight" }, - React.createElement(antd_1.Icon, { type: "ellipsis", style: { padding: "0 12px", cursor: "pointer" }, onClick: (e) => { - e.stopPropagation(); - } }))); - }; - // 获取操作标签 - this._getActionLabel = (action, defaultValue, data, mainKey) => { - const label = action.label; - if (typeof label === "function") { - return label && label(data, mainKey); - } - else if (label) { - return label; - } - else { - return defaultValue; - } + return (React.createElement(list_col_action_1.default, { record: record, mainKey: this.props.mainKey, actions: this._actions() })); }; // 其他操作的弹框模式兼容(操作后刷新数据并保留在当前页) this._onModalClick = (act, data, mainKey) => { diff --git a/lib/page/list_col_action.d.ts b/lib/page/list_col_action.d.ts new file mode 100644 index 0000000..e5a4f8d --- /dev/null +++ b/lib/page/list_col_action.d.ts @@ -0,0 +1,32 @@ +/** + * 通用的列表。 + */ +import * as React from 'react'; +import { Action } from './list'; +interface Props { + /** + * 字段列表。 + */ + record: { + [key: string]: any; + }; + /** + * 数据主键名称。 + */ + mainKey: string; + /** + * 操作项。 + */ + actions: Action[]; +} +interface State { + visible: boolean; +} +export default class extends React.PureComponent { + state: State; + render(): JSX.Element | null; + getActionLabel: (action: Action, defaultValue: string, data: any, mainKey: string) => any; + onMenuClick: () => void; + onDropdownVisibleChange: (visible: boolean) => void; +} +export {}; diff --git a/lib/page/list_col_action.js b/lib/page/list_col_action.js new file mode 100644 index 0000000..e25cc8e --- /dev/null +++ b/lib/page/list_col_action.js @@ -0,0 +1,62 @@ +"use strict"; +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; + result["default"] = mod; + return result; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +/** + * 通用的列表。 + */ +const React = __importStar(require("react")); +const antd_1 = require("antd"); +class default_1 extends React.PureComponent { + constructor() { + super(...arguments); + this.state = { visible: false }; + // 获取操作标签 + this.getActionLabel = (action, defaultValue, data, mainKey) => { + const label = action.label; + if (typeof label === "function") { + return label && label(data, mainKey); + } + else if (label) { + return label; + } + else { + return defaultValue; + } + }; + this.onMenuClick = () => { + this.setState({ visible: false }); + }; + this.onDropdownVisibleChange = (visible) => { + this.setState({ visible: visible }); + }; + } + render() { + const actions = this.props.actions.filter((a) => a.enable ? a.enable(this.props.record, this.props.mainKey) : true); + if (actions.length === 0) { + return null; + } + const menus = []; + actions.forEach((item, index) => { + const label = this.getActionLabel(item, "未知", this.props.record, this.props.mainKey); + menus.push(React.createElement(antd_1.Menu.Item, { key: index, onClick: (e) => { + item.onClick && item.onClick(this.props.record, this.props.mainKey); + e.stopPropagation(); + } }, + React.createElement(antd_1.Icon, { type: item.icon, style: { marginRight: "16px" } }), + React.createElement("span", null, label))); + menus.push(React.createElement(antd_1.Menu.Divider, { key: index + actions.length + 1 })); + }); + return (React.createElement(antd_1.Dropdown, { overlay: React.createElement(antd_1.Menu, { onClick: this.onMenuClick }, menus.slice(0, menus.length - 1)), trigger: ['click'], placement: "bottomRight", visible: this.state.visible, onVisibleChange: this.onDropdownVisibleChange }, + React.createElement(antd_1.Icon, { type: "ellipsis", style: { padding: "0 12px", cursor: "pointer" }, onClick: (e) => { + e.stopPropagation(); + } }))); + } + ; +} +exports.default = default_1; diff --git a/src/page/list.tsx b/src/page/list.tsx index 356539f..cef7589 100644 --- a/src/page/list.tsx +++ b/src/page/list.tsx @@ -2,9 +2,10 @@ * 通用的列表页。 */ import * as React from 'react'; -import { Table, Modal, Alert, Dropdown, Menu, Icon, message } from 'antd'; +import { Table, Modal, Alert, message } from 'antd'; import { PaginationConfig } from 'antd/lib/pagination'; import { TableEventListeners, TableProps, ColumnProps } from 'antd/lib/table'; +import ActionColumn from './list_col_action'; import * as Field from '../config'; import * as DetailFields from '../field/detail'; @@ -298,7 +299,7 @@ export default class ListPage extends React.PureComponent { } this.props.otherActions.forEach((act) => { const action: Action = { - icon: act.icon || "right", + icon: act.icon, label: act.label, enable: act.enable, onClick: this._onModalClick.bind(this, act), @@ -319,56 +320,15 @@ export default class ListPage extends React.PureComponent { // 渲染表格"操作"列 _renderColumnAction = (text: string, record: { [key: string]: any }) => { - const actions = this._actions().filter((a) => a.enable ? a.enable(record, this.props.mainKey) : true); - if (actions.length === 0) { - return null; - } - const menus: React.ReactNode[] = []; - actions.forEach((item, index) => { - const label = this._getActionLabel(item, "未知", record, this.props.mainKey); - menus.push( - { - item.onClick && item.onClick(record, this.props.mainKey); - e.stopPropagation(); - }} - > - - {label} - - ); - menus.push(); - }); return ( - {menus.slice(0, menus.length - 1)}} - trigger={['click']} - placement={"bottomRight"} - > - ) => { - e.stopPropagation(); - }} - /> - + ); }; - // 获取操作标签 - _getActionLabel = (action: Action, defaultValue: string, data: any, mainKey: string) => { - const label = action.label; - if (typeof label === "function") { - return label && label(data, mainKey); - } else if (label) { - return label; - } else { - return defaultValue; - } - }; - // 其他操作的弹框模式兼容(操作后刷新数据并保留在当前页) _onModalClick = (act: Action, data: any, mainKey: string) => { if (act.modalClick) { diff --git a/src/page/list_col_action.tsx b/src/page/list_col_action.tsx new file mode 100644 index 0000000..56ef2a0 --- /dev/null +++ b/src/page/list_col_action.tsx @@ -0,0 +1,90 @@ +/** + * 通用的列表。 + */ +import * as React from 'react'; +import { Dropdown, Menu, Icon } from 'antd'; +import { Action } from './list'; + +interface Props { + /** + * 字段列表。 + */ + record: { [key: string]: any } + /** + * 数据主键名称。 + */ + mainKey: string; + /** + * 操作项。 + */ + actions: Action[]; +} + +interface State { + visible: boolean; +} + +export default class extends React.PureComponent { + state: State = { visible: false }; + + render() { + const actions = this.props.actions.filter((a) => a.enable ? a.enable(this.props.record, this.props.mainKey) : true); + if (actions.length === 0) { + return null; + } + const menus: React.ReactNode[] = []; + actions.forEach((item, index) => { + const label = this.getActionLabel(item, "未知", this.props.record, this.props.mainKey); + menus.push( + { + item.onClick && item.onClick(this.props.record, this.props.mainKey); + e.stopPropagation(); + }} + > + + {label} + + ); + menus.push(); + }); + return ( + {menus.slice(0, menus.length - 1)}} + trigger={['click']} + placement={"bottomRight"} + visible={this.state.visible} + onVisibleChange={this.onDropdownVisibleChange} + > + ) => { + e.stopPropagation(); + }} + /> + + ); + }; + + // 获取操作标签 + getActionLabel = (action: Action, defaultValue: string, data: any, mainKey: string) => { + const label = action.label; + if (typeof label === "function") { + return label && label(data, mainKey); + } else if (label) { + return label; + } else { + return defaultValue; + } + }; + + onMenuClick = () => { + this.setState({ visible: false }); + }; + + onDropdownVisibleChange = (visible: boolean) => { + this.setState({ visible: visible }); + }; +} -- Gitee From a6a9284e9e4de01950fdc9590a9388ff790297ec Mon Sep 17 00:00:00 2001 From: leexs Date: Wed, 22 Mar 2023 11:52:15 +0800 Subject: [PATCH 18/33] =?UTF-8?q?=E6=93=8D=E4=BD=9C=E9=A1=B9=E5=9B=BE?= =?UTF-8?q?=E6=A0=87=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/page/list_col_action.js | 2 +- src/page/list_col_action.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/page/list_col_action.js b/lib/page/list_col_action.js index e25cc8e..57d7a0d 100644 --- a/lib/page/list_col_action.js +++ b/lib/page/list_col_action.js @@ -53,7 +53,7 @@ class default_1 extends React.PureComponent { menus.push(React.createElement(antd_1.Menu.Divider, { key: index + actions.length + 1 })); }); return (React.createElement(antd_1.Dropdown, { overlay: React.createElement(antd_1.Menu, { onClick: this.onMenuClick }, menus.slice(0, menus.length - 1)), trigger: ['click'], placement: "bottomRight", visible: this.state.visible, onVisibleChange: this.onDropdownVisibleChange }, - React.createElement(antd_1.Icon, { type: "ellipsis", style: { padding: "0 12px", cursor: "pointer" }, onClick: (e) => { + React.createElement(antd_1.Icon, { type: "more", style: { padding: "0 12px", cursor: "pointer" }, onClick: (e) => { e.stopPropagation(); } }))); } diff --git a/src/page/list_col_action.tsx b/src/page/list_col_action.tsx index 56ef2a0..ae66b0d 100644 --- a/src/page/list_col_action.tsx +++ b/src/page/list_col_action.tsx @@ -58,7 +58,7 @@ export default class extends React.PureComponent { onVisibleChange={this.onDropdownVisibleChange} > ) => { e.stopPropagation(); -- Gitee From c234d3a31768172e1bbe4257b1d6abda32cdd320 Mon Sep 17 00:00:00 2001 From: leexs Date: Wed, 22 Mar 2023 12:55:31 +0800 Subject: [PATCH 19/33] =?UTF-8?q?=E8=8F=9C=E5=8D=95=E4=BA=8B=E4=BB=B6?= =?UTF-8?q?=E5=86=92=E6=B3=A1=E7=9A=84=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/page/list_col_action.d.ts | 3 ++- lib/page/list_col_action.js | 4 ++-- src/page/list_col_action.tsx | 5 +++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/page/list_col_action.d.ts b/lib/page/list_col_action.d.ts index e5a4f8d..64caff2 100644 --- a/lib/page/list_col_action.d.ts +++ b/lib/page/list_col_action.d.ts @@ -2,6 +2,7 @@ * 通用的列表。 */ import * as React from 'react'; +import { ClickParam } from 'antd/lib/menu'; import { Action } from './list'; interface Props { /** @@ -26,7 +27,7 @@ export default class extends React.PureComponent { state: State; render(): JSX.Element | null; getActionLabel: (action: Action, defaultValue: string, data: any, mainKey: string) => any; - onMenuClick: () => void; + onMenuClick: (param: ClickParam) => void; onDropdownVisibleChange: (visible: boolean) => void; } export {}; diff --git a/lib/page/list_col_action.js b/lib/page/list_col_action.js index 57d7a0d..9fe99fb 100644 --- a/lib/page/list_col_action.js +++ b/lib/page/list_col_action.js @@ -29,7 +29,8 @@ class default_1 extends React.PureComponent { return defaultValue; } }; - this.onMenuClick = () => { + this.onMenuClick = (param) => { + param.domEvent.stopPropagation(); this.setState({ visible: false }); }; this.onDropdownVisibleChange = (visible) => { @@ -46,7 +47,6 @@ class default_1 extends React.PureComponent { const label = this.getActionLabel(item, "未知", this.props.record, this.props.mainKey); menus.push(React.createElement(antd_1.Menu.Item, { key: index, onClick: (e) => { item.onClick && item.onClick(this.props.record, this.props.mainKey); - e.stopPropagation(); } }, React.createElement(antd_1.Icon, { type: item.icon, style: { marginRight: "16px" } }), React.createElement("span", null, label))); diff --git a/src/page/list_col_action.tsx b/src/page/list_col_action.tsx index ae66b0d..30a3f6e 100644 --- a/src/page/list_col_action.tsx +++ b/src/page/list_col_action.tsx @@ -3,6 +3,7 @@ */ import * as React from 'react'; import { Dropdown, Menu, Icon } from 'antd'; +import { ClickParam } from 'antd/lib/menu'; import { Action } from './list'; interface Props { @@ -40,7 +41,6 @@ export default class extends React.PureComponent { key={index} onClick={(e: any) => { item.onClick && item.onClick(this.props.record, this.props.mainKey); - e.stopPropagation(); }} > @@ -80,7 +80,8 @@ export default class extends React.PureComponent { } }; - onMenuClick = () => { + onMenuClick = (param: ClickParam) => { + param.domEvent.stopPropagation(); this.setState({ visible: false }); }; -- Gitee From cdd65358618f089a2e1280d29d72463cb7574278 Mon Sep 17 00:00:00 2001 From: leexs Date: Wed, 22 Mar 2023 15:23:47 +0800 Subject: [PATCH 20/33] =?UTF-8?q?=E6=93=8D=E4=BD=9C=E9=A1=B9=E6=94=AF?= =?UTF-8?q?=E6=8C=81tooltip?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/page/list.d.ts | 8 ++++-- lib/page/list.js | 32 +++++++++++++--------- lib/page/list_col_action.js | 20 +++++++++----- src/page/list.tsx | 52 +++++++++++++++++++++--------------- src/page/list_col_action.tsx | 42 ++++++++++++++++++++--------- 5 files changed, 99 insertions(+), 55 deletions(-) diff --git a/lib/page/list.d.ts b/lib/page/list.d.ts index d12e16e..afce220 100644 --- a/lib/page/list.d.ts +++ b/lib/page/list.d.ts @@ -26,6 +26,10 @@ export interface Action { * 文字内容。 */ label?: React.ReactNode | ((data: any, mainKey: string) => React.ReactNode); + /** + * 提示内容。 + */ + tooltip?: string; /** * 是否启用。 */ @@ -95,7 +99,7 @@ interface Props { /** * 右侧其他操作。 */ - otherActions: Action[]; + otherActions?: Action[]; /** * 操作列的附加属性。 */ @@ -162,10 +166,10 @@ export default class ListPage extends React.PureComponent { _fetchData: (pageNumber: number, filters: any, sorter: any) => void; _onSelectRows: (selectedKeys: any[]) => void; _renderColumns: () => JSX.Element[]; - _actions: () => Action[]; _renderColumnAction: (text: string, record: { [key: string]: any; }) => JSX.Element; + _actions: () => Action[]; _onModalClick: (act: Action, data: any, mainKey: string) => void; _onDeleteClick: (data: any, mainKey: string) => void; _onAction: (action: (data: any, mainKey: string) => Promise, data: any, mainKey: string, pn: number, success: string, error: string) => void; diff --git a/lib/page/list.js b/lib/page/list.js index d55f012..0c88e85 100644 --- a/lib/page/list.js +++ b/lib/page/list.js @@ -91,26 +91,36 @@ class ListPage extends React.PureComponent { } return columns; }; + // 渲染表格"操作"列 + this._renderColumnAction = (text, record) => { + return (React.createElement(list_col_action_1.default, { record: record, mainKey: this.props.mainKey, actions: this._actions() })); + }; // 生成操作项列表 this._actions = () => { const actions = []; if (this.props.editAction) { const action = Object.assign(Object.assign({}, this.props.editAction), { icon: this.props.editAction.icon || "edit", label: this.props.editAction.label || "编辑" }); actions.push(action); + actions.push({ label: "devide1" }); + } + if (this.props.otherActions && this.props.otherActions.length > 0) { + this.props.otherActions.forEach((act) => { + const action = { + icon: act.icon, + label: act.label, + tooltip: act.tooltip, + enable: act.enable, + onClick: this._onModalClick.bind(this, act), + }; + actions.push(action); + }); + actions.push({ label: "devide2" }); } - this.props.otherActions.forEach((act) => { - const action = { - icon: act.icon, - label: act.label, - enable: act.enable, - onClick: this._onModalClick.bind(this, act), - }; - actions.push(action); - }); if (this.props.deleteAction) { const action = { icon: this.props.deleteAction.icon || "delete", label: this.props.deleteAction.label || "删除", + tooltip: this.props.deleteAction.tooltip, enable: this.props.deleteAction.enable, onClick: this._onDeleteClick, }; @@ -118,10 +128,6 @@ class ListPage extends React.PureComponent { } return actions; }; - // 渲染表格"操作"列 - this._renderColumnAction = (text, record) => { - return (React.createElement(list_col_action_1.default, { record: record, mainKey: this.props.mainKey, actions: this._actions() })); - }; // 其他操作的弹框模式兼容(操作后刷新数据并保留在当前页) this._onModalClick = (act, data, mainKey) => { if (act.modalClick) { diff --git a/lib/page/list_col_action.js b/lib/page/list_col_action.js index 9fe99fb..b60c2d9 100644 --- a/lib/page/list_col_action.js +++ b/lib/page/list_col_action.js @@ -45,12 +45,20 @@ class default_1 extends React.PureComponent { const menus = []; actions.forEach((item, index) => { const label = this.getActionLabel(item, "未知", this.props.record, this.props.mainKey); - menus.push(React.createElement(antd_1.Menu.Item, { key: index, onClick: (e) => { - item.onClick && item.onClick(this.props.record, this.props.mainKey); - } }, - React.createElement(antd_1.Icon, { type: item.icon, style: { marginRight: "16px" } }), - React.createElement("span", null, label))); - menus.push(React.createElement(antd_1.Menu.Divider, { key: index + actions.length + 1 })); + if (label.indexOf("devide") < 0) { + menus.push(React.createElement(antd_1.Menu.Item, { key: index, onClick: (e) => { + item.onClick && item.onClick(this.props.record, this.props.mainKey); + } }, + React.createElement(antd_1.Icon, { type: item.icon, style: { marginRight: "16px" } }), + item.tooltip + ? React.createElement(antd_1.Tooltip, { title: item.tooltip, placement: "top", arrowPointAtCenter: true }, + React.createElement("span", null, label), + React.createElement(antd_1.Icon, { type: "question-circle", style: { marginLeft: "4px", color: "#f50" } })) + : React.createElement("span", null, label))); + } + else { + menus.push(React.createElement(antd_1.Menu.Divider, { key: index + actions.length + 1 })); + } }); return (React.createElement(antd_1.Dropdown, { overlay: React.createElement(antd_1.Menu, { onClick: this.onMenuClick }, menus.slice(0, menus.length - 1)), trigger: ['click'], placement: "bottomRight", visible: this.state.visible, onVisibleChange: this.onDropdownVisibleChange }, React.createElement(antd_1.Icon, { type: "more", style: { padding: "0 12px", cursor: "pointer" }, onClick: (e) => { diff --git a/src/page/list.tsx b/src/page/list.tsx index cef7589..87c15c3 100644 --- a/src/page/list.tsx +++ b/src/page/list.tsx @@ -29,6 +29,10 @@ export interface Action { * 文字内容。 */ label?: React.ReactNode | ((data: any, mainKey: string) => React.ReactNode); + /** + * 提示内容。 + */ + tooltip?: string; /** * 是否启用。 */ @@ -99,7 +103,7 @@ interface Props { /** * 右侧其他操作。 */ - otherActions: Action[]; + otherActions?: Action[]; /** * 操作列的附加属性。 */ @@ -286,6 +290,17 @@ export default class ListPage extends React.PureComponent { return columns; }; + // 渲染表格"操作"列 + _renderColumnAction = (text: string, record: { [key: string]: any }) => { + return ( + + ); + }; + // 生成操作项列表 _actions = () => { const actions: Action[] = []; @@ -296,20 +311,26 @@ export default class ListPage extends React.PureComponent { label: this.props.editAction.label || "编辑", }; actions.push(action); + actions.push({ label: "devide1" }); + } + if (this.props.otherActions && this.props.otherActions.length > 0) { + this.props.otherActions.forEach((act) => { + const action: Action = { + icon: act.icon, + label: act.label, + tooltip: act.tooltip, + enable: act.enable, + onClick: this._onModalClick.bind(this, act), + }; + actions.push(action); + }); + actions.push({ label: "devide2" }); } - this.props.otherActions.forEach((act) => { - const action: Action = { - icon: act.icon, - label: act.label, - enable: act.enable, - onClick: this._onModalClick.bind(this, act), - }; - actions.push(action); - }); if (this.props.deleteAction) { const action: Action = { icon: this.props.deleteAction.icon || "delete", label: this.props.deleteAction.label || "删除", + tooltip: this.props.deleteAction.tooltip, enable: this.props.deleteAction.enable, onClick: this._onDeleteClick, }; @@ -318,17 +339,6 @@ export default class ListPage extends React.PureComponent { return actions; }; - // 渲染表格"操作"列 - _renderColumnAction = (text: string, record: { [key: string]: any }) => { - return ( - - ); - }; - // 其他操作的弹框模式兼容(操作后刷新数据并保留在当前页) _onModalClick = (act: Action, data: any, mainKey: string) => { if (act.modalClick) { diff --git a/src/page/list_col_action.tsx b/src/page/list_col_action.tsx index 30a3f6e..e6a1249 100644 --- a/src/page/list_col_action.tsx +++ b/src/page/list_col_action.tsx @@ -2,7 +2,7 @@ * 通用的列表。 */ import * as React from 'react'; -import { Dropdown, Menu, Icon } from 'antd'; +import { Dropdown, Menu, Icon, Tooltip } from 'antd'; import { ClickParam } from 'antd/lib/menu'; import { Action } from './list'; @@ -36,18 +36,34 @@ export default class extends React.PureComponent { const menus: React.ReactNode[] = []; actions.forEach((item, index) => { const label = this.getActionLabel(item, "未知", this.props.record, this.props.mainKey); - menus.push( - { - item.onClick && item.onClick(this.props.record, this.props.mainKey); - }} - > - - {label} - - ); - menus.push(); + if (label.indexOf("devide") < 0) { + menus.push( + { + item.onClick && item.onClick(this.props.record, this.props.mainKey); + }} + > + + {item.tooltip + ? + {label} + + + : {label} + } + + ); + } else { + menus.push(); + } }); return ( Date: Wed, 22 Mar 2023 15:33:34 +0800 Subject: [PATCH 21/33] =?UTF-8?q?=E6=93=8D=E4=BD=9C=E9=A1=B9label=E6=81=A2?= =?UTF-8?q?=E5=A4=8D=E4=B8=BAstring=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/page/list.d.ts | 2 +- lib/page/list_col_action.d.ts | 1 - lib/page/list_col_action.js | 15 +-------------- src/page/list.tsx | 2 +- src/page/list_col_action.tsx | 14 +------------- 5 files changed, 4 insertions(+), 30 deletions(-) diff --git a/lib/page/list.d.ts b/lib/page/list.d.ts index afce220..66fc5df 100644 --- a/lib/page/list.d.ts +++ b/lib/page/list.d.ts @@ -25,7 +25,7 @@ export interface Action { /** * 文字内容。 */ - label?: React.ReactNode | ((data: any, mainKey: string) => React.ReactNode); + label?: string; /** * 提示内容。 */ diff --git a/lib/page/list_col_action.d.ts b/lib/page/list_col_action.d.ts index 64caff2..2c4ba5c 100644 --- a/lib/page/list_col_action.d.ts +++ b/lib/page/list_col_action.d.ts @@ -26,7 +26,6 @@ interface State { export default class extends React.PureComponent { state: State; render(): JSX.Element | null; - getActionLabel: (action: Action, defaultValue: string, data: any, mainKey: string) => any; onMenuClick: (param: ClickParam) => void; onDropdownVisibleChange: (visible: boolean) => void; } diff --git a/lib/page/list_col_action.js b/lib/page/list_col_action.js index b60c2d9..16f0510 100644 --- a/lib/page/list_col_action.js +++ b/lib/page/list_col_action.js @@ -16,19 +16,6 @@ class default_1 extends React.PureComponent { constructor() { super(...arguments); this.state = { visible: false }; - // 获取操作标签 - this.getActionLabel = (action, defaultValue, data, mainKey) => { - const label = action.label; - if (typeof label === "function") { - return label && label(data, mainKey); - } - else if (label) { - return label; - } - else { - return defaultValue; - } - }; this.onMenuClick = (param) => { param.domEvent.stopPropagation(); this.setState({ visible: false }); @@ -44,7 +31,7 @@ class default_1 extends React.PureComponent { } const menus = []; actions.forEach((item, index) => { - const label = this.getActionLabel(item, "未知", this.props.record, this.props.mainKey); + const label = item.label || "未知"; if (label.indexOf("devide") < 0) { menus.push(React.createElement(antd_1.Menu.Item, { key: index, onClick: (e) => { item.onClick && item.onClick(this.props.record, this.props.mainKey); diff --git a/src/page/list.tsx b/src/page/list.tsx index 87c15c3..97e8f95 100644 --- a/src/page/list.tsx +++ b/src/page/list.tsx @@ -28,7 +28,7 @@ export interface Action { /** * 文字内容。 */ - label?: React.ReactNode | ((data: any, mainKey: string) => React.ReactNode); + label?: string; /** * 提示内容。 */ diff --git a/src/page/list_col_action.tsx b/src/page/list_col_action.tsx index e6a1249..6bd653e 100644 --- a/src/page/list_col_action.tsx +++ b/src/page/list_col_action.tsx @@ -35,7 +35,7 @@ export default class extends React.PureComponent { } const menus: React.ReactNode[] = []; actions.forEach((item, index) => { - const label = this.getActionLabel(item, "未知", this.props.record, this.props.mainKey); + const label = item.label || "未知"; if (label.indexOf("devide") < 0) { menus.push( { ); }; - // 获取操作标签 - getActionLabel = (action: Action, defaultValue: string, data: any, mainKey: string) => { - const label = action.label; - if (typeof label === "function") { - return label && label(data, mainKey); - } else if (label) { - return label; - } else { - return defaultValue; - } - }; - onMenuClick = (param: ClickParam) => { param.domEvent.stopPropagation(); this.setState({ visible: false }); -- Gitee From a571e9b0b24c699d0976a469a3ece4846f7f2df3 Mon Sep 17 00:00:00 2001 From: leexs Date: Wed, 22 Mar 2023 15:44:01 +0800 Subject: [PATCH 22/33] =?UTF-8?q?=E5=8A=A0=E5=85=A5=E6=93=8D=E4=BD=9C?= =?UTF-8?q?=E9=A1=B9=E9=9A=94=E6=96=AD=E7=9A=84=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/page/list.d.ts | 1 - lib/page/list.js | 11 ++++++++--- src/page/list.tsx | 11 ++++++++--- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/lib/page/list.d.ts b/lib/page/list.d.ts index 66fc5df..a15a0b3 100644 --- a/lib/page/list.d.ts +++ b/lib/page/list.d.ts @@ -147,7 +147,6 @@ interface State { } export default class ListPage extends React.PureComponent { static defaultProps: { - otherActions: never[]; actionColumnProps: {}; tableProps: {}; autoLoad: boolean; diff --git a/lib/page/list.js b/lib/page/list.js index 0c88e85..f7bcaae 100644 --- a/lib/page/list.js +++ b/lib/page/list.js @@ -101,7 +101,10 @@ class ListPage extends React.PureComponent { if (this.props.editAction) { const action = Object.assign(Object.assign({}, this.props.editAction), { icon: this.props.editAction.icon || "edit", label: this.props.editAction.label || "编辑" }); actions.push(action); - actions.push({ label: "devide1" }); + if (this.props.otherActions || this.props.deleteAction) { + // 有其他操作或删除操作时增加隔断 + actions.push({ label: "devide1" }); + } } if (this.props.otherActions && this.props.otherActions.length > 0) { this.props.otherActions.forEach((act) => { @@ -114,7 +117,10 @@ class ListPage extends React.PureComponent { }; actions.push(action); }); - actions.push({ label: "devide2" }); + if (this.props.deleteAction) { + // 有删除操作时增加隔断 + actions.push({ label: "devide2" }); + } } if (this.props.deleteAction) { const action = { @@ -234,7 +240,6 @@ class ListPage extends React.PureComponent { } exports.default = ListPage; ListPage.defaultProps = { - otherActions: [], actionColumnProps: {}, tableProps: {}, autoLoad: true, diff --git a/src/page/list.tsx b/src/page/list.tsx index 97e8f95..b364bcd 100644 --- a/src/page/list.tsx +++ b/src/page/list.tsx @@ -151,7 +151,6 @@ interface State { export default class ListPage extends React.PureComponent { static defaultProps = { - otherActions: [], actionColumnProps: {}, tableProps: {}, autoLoad: true, @@ -311,7 +310,10 @@ export default class ListPage extends React.PureComponent { label: this.props.editAction.label || "编辑", }; actions.push(action); - actions.push({ label: "devide1" }); + if (this.props.otherActions || this.props.deleteAction) { + // 有其他操作或删除操作时增加隔断 + actions.push({ label: "devide1" }); + } } if (this.props.otherActions && this.props.otherActions.length > 0) { this.props.otherActions.forEach((act) => { @@ -324,7 +326,10 @@ export default class ListPage extends React.PureComponent { }; actions.push(action); }); - actions.push({ label: "devide2" }); + if (this.props.deleteAction) { + // 有删除操作时增加隔断 + actions.push({ label: "devide2" }); + } } if (this.props.deleteAction) { const action: Action = { -- Gitee From 08c165cb0da8c3003bd9eeb2695e5c2816d63180 Mon Sep 17 00:00:00 2001 From: leexs Date: Wed, 22 Mar 2023 15:56:17 +0800 Subject: [PATCH 23/33] =?UTF-8?q?=E6=B8=B2=E6=9F=93menu=E6=97=B6=E4=B8=8D?= =?UTF-8?q?=E9=9C=80=E8=A6=81=E5=8E=BB=E6=8E=89=E6=9C=80=E5=90=8E=E4=B8=80?= =?UTF-8?q?=E4=B8=AA=E8=8F=9C=E5=8D=95=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/page/list_col_action.js | 2 +- src/page/list_col_action.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/page/list_col_action.js b/lib/page/list_col_action.js index 16f0510..4c3ce6e 100644 --- a/lib/page/list_col_action.js +++ b/lib/page/list_col_action.js @@ -47,7 +47,7 @@ class default_1 extends React.PureComponent { menus.push(React.createElement(antd_1.Menu.Divider, { key: index + actions.length + 1 })); } }); - return (React.createElement(antd_1.Dropdown, { overlay: React.createElement(antd_1.Menu, { onClick: this.onMenuClick }, menus.slice(0, menus.length - 1)), trigger: ['click'], placement: "bottomRight", visible: this.state.visible, onVisibleChange: this.onDropdownVisibleChange }, + return (React.createElement(antd_1.Dropdown, { overlay: React.createElement(antd_1.Menu, { onClick: this.onMenuClick }, menus), trigger: ['click'], placement: "bottomRight", visible: this.state.visible, onVisibleChange: this.onDropdownVisibleChange }, React.createElement(antd_1.Icon, { type: "more", style: { padding: "0 12px", cursor: "pointer" }, onClick: (e) => { e.stopPropagation(); } }))); diff --git a/src/page/list_col_action.tsx b/src/page/list_col_action.tsx index 6bd653e..153b984 100644 --- a/src/page/list_col_action.tsx +++ b/src/page/list_col_action.tsx @@ -67,7 +67,7 @@ export default class extends React.PureComponent { }); return ( {menus.slice(0, menus.length - 1)}} + overlay={{menus}} trigger={['click']} placement={"bottomRight"} visible={this.state.visible} -- Gitee From 2a4dda686b77a0e7df176872ffda1ee3a674bc6e Mon Sep 17 00:00:00 2001 From: leexs Date: Wed, 22 Mar 2023 16:31:33 +0800 Subject: [PATCH 24/33] =?UTF-8?q?=E8=8F=9C=E5=8D=95=E5=88=86=E9=9A=94?= =?UTF-8?q?=E7=AC=A6=E6=98=BE=E7=A4=BA=E9=80=BB=E8=BE=91=E7=9A=84=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/page/list_col_action.js | 25 +++++++++------- src/page/list_col_action.tsx | 58 +++++++++++++++++++----------------- 2 files changed, 45 insertions(+), 38 deletions(-) diff --git a/lib/page/list_col_action.js b/lib/page/list_col_action.js index 4c3ce6e..6527d17 100644 --- a/lib/page/list_col_action.js +++ b/lib/page/list_col_action.js @@ -32,20 +32,23 @@ class default_1 extends React.PureComponent { const menus = []; actions.forEach((item, index) => { const label = item.label || "未知"; - if (label.indexOf("devide") < 0) { - menus.push(React.createElement(antd_1.Menu.Item, { key: index, onClick: (e) => { - item.onClick && item.onClick(this.props.record, this.props.mainKey); - } }, - React.createElement(antd_1.Icon, { type: item.icon, style: { marginRight: "16px" } }), - item.tooltip - ? React.createElement(antd_1.Tooltip, { title: item.tooltip, placement: "top", arrowPointAtCenter: true }, - React.createElement("span", null, label), - React.createElement(antd_1.Icon, { type: "question-circle", style: { marginLeft: "4px", color: "#f50" } })) - : React.createElement("span", null, label))); + if (label.indexOf("devide1") >= 0 && index === 1) { + // 当devide1为第二个元素时,也即有编辑按钮,则显示分隔符 + menus.push(React.createElement(antd_1.Menu.Divider, { key: index + actions.length + 1 })); } - else { + if (label.indexOf("devide2") >= 0 && index === actions.length - 2) { + // 当devide2为倒数第二个元素时,也即有删除2按钮,则显示分隔符 menus.push(React.createElement(antd_1.Menu.Divider, { key: index + actions.length + 1 })); } + menus.push(React.createElement(antd_1.Menu.Item, { key: index, onClick: (e) => { + item.onClick && item.onClick(this.props.record, this.props.mainKey); + } }, + React.createElement(antd_1.Icon, { type: item.icon, style: { marginRight: "16px" } }), + item.tooltip + ? React.createElement(antd_1.Tooltip, { title: item.tooltip, placement: "top", arrowPointAtCenter: true }, + React.createElement("span", null, label), + React.createElement(antd_1.Icon, { type: "question-circle", style: { marginLeft: "4px", color: "#f50" } })) + : React.createElement("span", null, label))); }); return (React.createElement(antd_1.Dropdown, { overlay: React.createElement(antd_1.Menu, { onClick: this.onMenuClick }, menus), trigger: ['click'], placement: "bottomRight", visible: this.state.visible, onVisibleChange: this.onDropdownVisibleChange }, React.createElement(antd_1.Icon, { type: "more", style: { padding: "0 12px", cursor: "pointer" }, onClick: (e) => { diff --git a/src/page/list_col_action.tsx b/src/page/list_col_action.tsx index 153b984..81f3678 100644 --- a/src/page/list_col_action.tsx +++ b/src/page/list_col_action.tsx @@ -36,34 +36,38 @@ export default class extends React.PureComponent { const menus: React.ReactNode[] = []; actions.forEach((item, index) => { const label = item.label || "未知"; - if (label.indexOf("devide") < 0) { - menus.push( - { - item.onClick && item.onClick(this.props.record, this.props.mainKey); - }} - > - - {item.tooltip - ? - {label} - - - : {label} - } - - ); - } else { + if (label.indexOf("devide1") >= 0 && index === 1) { + // 当devide1为第二个元素时,也即有编辑按钮,则显示分隔符 menus.push(); } + if (label.indexOf("devide2") >= 0 && index === actions.length - 2) { + // 当devide2为倒数第二个元素时,也即有删除2按钮,则显示分隔符 + menus.push(); + } + menus.push( + { + item.onClick && item.onClick(this.props.record, this.props.mainKey); + }} + > + + {item.tooltip + ? + {label} + + + : {label} + } + + ); }); return ( { e.stopPropagation(); }} /> - + ); }; -- Gitee From 92638eedc6b06106bcd9d8a512bb89b12c58e324 Mon Sep 17 00:00:00 2001 From: leexs Date: Wed, 22 Mar 2023 16:37:07 +0800 Subject: [PATCH 25/33] =?UTF-8?q?=E6=98=BE=E7=A4=BA=E9=9D=9E=E5=88=86?= =?UTF-8?q?=E9=9A=94=E7=AC=A6=E6=93=8D=E4=BD=9C=E9=A1=B9=E7=9A=84=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/page/list_col_action.js | 37 ++++++++++++-------- src/page/list_col_action.tsx | 67 +++++++++++++++++++----------------- 2 files changed, 58 insertions(+), 46 deletions(-) diff --git a/lib/page/list_col_action.js b/lib/page/list_col_action.js index 6527d17..7edaa49 100644 --- a/lib/page/list_col_action.js +++ b/lib/page/list_col_action.js @@ -32,23 +32,30 @@ class default_1 extends React.PureComponent { const menus = []; actions.forEach((item, index) => { const label = item.label || "未知"; - if (label.indexOf("devide1") >= 0 && index === 1) { - // 当devide1为第二个元素时,也即有编辑按钮,则显示分隔符 - menus.push(React.createElement(antd_1.Menu.Divider, { key: index + actions.length + 1 })); + if (label.indexOf("devide1") >= 0) { + // 当devide1为第二个元素时,也即有编辑按钮,则显示分隔符;否则忽略 + if (index === 1) { + menus.push(React.createElement(antd_1.Menu.Divider, { key: index + actions.length + 1 })); + } } - if (label.indexOf("devide2") >= 0 && index === actions.length - 2) { - // 当devide2为倒数第二个元素时,也即有删除2按钮,则显示分隔符 - menus.push(React.createElement(antd_1.Menu.Divider, { key: index + actions.length + 1 })); + else if (label.indexOf("devide2") >= 0) { + // 当devide2为倒数第二个元素时,也即有删除2按钮,则显示分隔符;否则忽略 + if (index === actions.length - 2) { + menus.push(React.createElement(antd_1.Menu.Divider, { key: index + actions.length + 1 })); + } + } + else { + // 显示非分隔符的操作项 + menus.push(React.createElement(antd_1.Menu.Item, { key: index, onClick: (e) => { + item.onClick && item.onClick(this.props.record, this.props.mainKey); + } }, + React.createElement(antd_1.Icon, { type: item.icon, style: { marginRight: "16px" } }), + item.tooltip + ? React.createElement(antd_1.Tooltip, { title: item.tooltip, placement: "top", arrowPointAtCenter: true }, + React.createElement("span", null, label), + React.createElement(antd_1.Icon, { type: "question-circle", style: { marginLeft: "4px", color: "#f50" } })) + : React.createElement("span", null, label))); } - menus.push(React.createElement(antd_1.Menu.Item, { key: index, onClick: (e) => { - item.onClick && item.onClick(this.props.record, this.props.mainKey); - } }, - React.createElement(antd_1.Icon, { type: item.icon, style: { marginRight: "16px" } }), - item.tooltip - ? React.createElement(antd_1.Tooltip, { title: item.tooltip, placement: "top", arrowPointAtCenter: true }, - React.createElement("span", null, label), - React.createElement(antd_1.Icon, { type: "question-circle", style: { marginLeft: "4px", color: "#f50" } })) - : React.createElement("span", null, label))); }); return (React.createElement(antd_1.Dropdown, { overlay: React.createElement(antd_1.Menu, { onClick: this.onMenuClick }, menus), trigger: ['click'], placement: "bottomRight", visible: this.state.visible, onVisibleChange: this.onDropdownVisibleChange }, React.createElement(antd_1.Icon, { type: "more", style: { padding: "0 12px", cursor: "pointer" }, onClick: (e) => { diff --git a/src/page/list_col_action.tsx b/src/page/list_col_action.tsx index 81f3678..dc2f280 100644 --- a/src/page/list_col_action.tsx +++ b/src/page/list_col_action.tsx @@ -36,38 +36,43 @@ export default class extends React.PureComponent { const menus: React.ReactNode[] = []; actions.forEach((item, index) => { const label = item.label || "未知"; - if (label.indexOf("devide1") >= 0 && index === 1) { - // 当devide1为第二个元素时,也即有编辑按钮,则显示分隔符 - menus.push(); + if (label.indexOf("devide1") >= 0) { + // 当devide1为第二个元素时,也即有编辑按钮,则显示分隔符;否则忽略 + if (index === 1) { + menus.push(); + } + } else if (label.indexOf("devide2") >= 0) { + // 当devide2为倒数第二个元素时,也即有删除2按钮,则显示分隔符;否则忽略 + if (index === actions.length - 2) { + menus.push(); + } + } else { + // 显示非分隔符的操作项 + menus.push( + { + item.onClick && item.onClick(this.props.record, this.props.mainKey); + }} + > + + {item.tooltip + ? + {label} + + + : {label} + } + + ); } - if (label.indexOf("devide2") >= 0 && index === actions.length - 2) { - // 当devide2为倒数第二个元素时,也即有删除2按钮,则显示分隔符 - menus.push(); - } - menus.push( - { - item.onClick && item.onClick(this.props.record, this.props.mainKey); - }} - > - - {item.tooltip - ? - {label} - - - : {label} - } - - ); }); return ( Date: Wed, 22 Mar 2023 18:07:16 +0800 Subject: [PATCH 26/33] =?UTF-8?q?=E6=93=8D=E4=BD=9C=E9=A1=B9=E4=B8=BA?= =?UTF-8?q?=E7=A9=BA=E7=9A=84=E5=88=A4=E6=96=AD=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/page/list_col_action.js | 3 ++- src/page/list_col_action.tsx | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/page/list_col_action.js b/lib/page/list_col_action.js index 7edaa49..b8c4a22 100644 --- a/lib/page/list_col_action.js +++ b/lib/page/list_col_action.js @@ -26,7 +26,8 @@ class default_1 extends React.PureComponent { } render() { const actions = this.props.actions.filter((a) => a.enable ? a.enable(this.props.record, this.props.mainKey) : true); - if (actions.length === 0) { + if (actions.length === 0 || actions.filter((a) => a.label === undefined || a.label.indexOf("devide") < 0).length === 0) { + // 没有操作项或没有除devide之外的操作项,则返回空 return null; } const menus = []; diff --git a/src/page/list_col_action.tsx b/src/page/list_col_action.tsx index dc2f280..31ec1f9 100644 --- a/src/page/list_col_action.tsx +++ b/src/page/list_col_action.tsx @@ -30,7 +30,8 @@ export default class extends React.PureComponent { render() { const actions = this.props.actions.filter((a) => a.enable ? a.enable(this.props.record, this.props.mainKey) : true); - if (actions.length === 0) { + if (actions.length === 0 || actions.filter((a) => a.label === undefined || a.label.indexOf("devide") < 0).length === 0) { + // 没有操作项或没有除devide之外的操作项,则返回空 return null; } const menus: React.ReactNode[] = []; -- Gitee From 7036a76d3856be6ce4dad99de6f44e6bdbd9ecfc Mon Sep 17 00:00:00 2001 From: leexs Date: Wed, 22 Mar 2023 18:12:52 +0800 Subject: [PATCH 27/33] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=93=8D=E4=BD=9C?= =?UTF-8?q?=E5=88=97icon=E7=9A=84=E9=A2=9C=E8=89=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/page/list_col_action.js | 2 +- src/page/list_col_action.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/page/list_col_action.js b/lib/page/list_col_action.js index b8c4a22..1b092a4 100644 --- a/lib/page/list_col_action.js +++ b/lib/page/list_col_action.js @@ -59,7 +59,7 @@ class default_1 extends React.PureComponent { } }); return (React.createElement(antd_1.Dropdown, { overlay: React.createElement(antd_1.Menu, { onClick: this.onMenuClick }, menus), trigger: ['click'], placement: "bottomRight", visible: this.state.visible, onVisibleChange: this.onDropdownVisibleChange }, - React.createElement(antd_1.Icon, { type: "more", style: { padding: "0 12px", cursor: "pointer" }, onClick: (e) => { + React.createElement(antd_1.Icon, { type: "more", style: { padding: "0 12px", cursor: "pointer", color: "#108ee9" }, onClick: (e) => { e.stopPropagation(); } }))); } diff --git a/src/page/list_col_action.tsx b/src/page/list_col_action.tsx index 31ec1f9..69b132d 100644 --- a/src/page/list_col_action.tsx +++ b/src/page/list_col_action.tsx @@ -85,7 +85,7 @@ export default class extends React.PureComponent { > ) => { e.stopPropagation(); }} -- Gitee From e2f7287711bbe939fb7dadb49f5e8d375886382f Mon Sep 17 00:00:00 2001 From: leexs Date: Thu, 23 Mar 2023 09:10:12 +0800 Subject: [PATCH 28/33] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E6=93=8D=E4=BD=9C?= =?UTF-8?q?=E5=88=97=E7=9A=84=E5=9B=BE=E6=A0=87=E9=A2=9C=E8=89=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/page/list_col_action.js | 4 ++-- src/page/list_col_action.tsx | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/page/list_col_action.js b/lib/page/list_col_action.js index 1b092a4..8a6d3f5 100644 --- a/lib/page/list_col_action.js +++ b/lib/page/list_col_action.js @@ -50,7 +50,7 @@ class default_1 extends React.PureComponent { menus.push(React.createElement(antd_1.Menu.Item, { key: index, onClick: (e) => { item.onClick && item.onClick(this.props.record, this.props.mainKey); } }, - React.createElement(antd_1.Icon, { type: item.icon, style: { marginRight: "16px" } }), + React.createElement(antd_1.Icon, { type: item.icon, style: { marginRight: "12px", color: "#f50" } }), item.tooltip ? React.createElement(antd_1.Tooltip, { title: item.tooltip, placement: "top", arrowPointAtCenter: true }, React.createElement("span", null, label), @@ -59,7 +59,7 @@ class default_1 extends React.PureComponent { } }); return (React.createElement(antd_1.Dropdown, { overlay: React.createElement(antd_1.Menu, { onClick: this.onMenuClick }, menus), trigger: ['click'], placement: "bottomRight", visible: this.state.visible, onVisibleChange: this.onDropdownVisibleChange }, - React.createElement(antd_1.Icon, { type: "more", style: { padding: "0 12px", cursor: "pointer", color: "#108ee9" }, onClick: (e) => { + React.createElement(antd_1.Icon, { type: "more", style: { padding: "0 8px", cursor: "pointer", color: "#f50" }, onClick: (e) => { e.stopPropagation(); } }))); } diff --git a/src/page/list_col_action.tsx b/src/page/list_col_action.tsx index 69b132d..f275570 100644 --- a/src/page/list_col_action.tsx +++ b/src/page/list_col_action.tsx @@ -56,7 +56,7 @@ export default class extends React.PureComponent { item.onClick && item.onClick(this.props.record, this.props.mainKey); }} > - + {item.tooltip ? { > ) => { e.stopPropagation(); }} -- Gitee From 3221be1a8a8ac8abca42e558323c911b61121737 Mon Sep 17 00:00:00 2001 From: leexs Date: Sat, 25 Mar 2023 13:46:54 +0800 Subject: [PATCH 29/33] =?UTF-8?q?=E6=93=8D=E4=BD=9C=E9=A1=B9=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E9=BB=98=E8=AE=A4=E5=9B=BE=E6=A0=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/page/list.js | 2 +- lib/page/list_col_action.js | 2 +- src/page/list.tsx | 2 +- src/page/list_col_action.tsx | 1 + 4 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/page/list.js b/lib/page/list.js index f7bcaae..e1070da 100644 --- a/lib/page/list.js +++ b/lib/page/list.js @@ -109,7 +109,7 @@ class ListPage extends React.PureComponent { if (this.props.otherActions && this.props.otherActions.length > 0) { this.props.otherActions.forEach((act) => { const action = { - icon: act.icon, + icon: act.icon || "right", label: act.label, tooltip: act.tooltip, enable: act.enable, diff --git a/lib/page/list_col_action.js b/lib/page/list_col_action.js index 8a6d3f5..2f8b453 100644 --- a/lib/page/list_col_action.js +++ b/lib/page/list_col_action.js @@ -49,7 +49,7 @@ class default_1 extends React.PureComponent { // 显示非分隔符的操作项 menus.push(React.createElement(antd_1.Menu.Item, { key: index, onClick: (e) => { item.onClick && item.onClick(this.props.record, this.props.mainKey); - } }, + }, className: "xc-page-list-op-item" }, React.createElement(antd_1.Icon, { type: item.icon, style: { marginRight: "12px", color: "#f50" } }), item.tooltip ? React.createElement(antd_1.Tooltip, { title: item.tooltip, placement: "top", arrowPointAtCenter: true }, diff --git a/src/page/list.tsx b/src/page/list.tsx index b364bcd..7f26a4d 100644 --- a/src/page/list.tsx +++ b/src/page/list.tsx @@ -318,7 +318,7 @@ export default class ListPage extends React.PureComponent { if (this.props.otherActions && this.props.otherActions.length > 0) { this.props.otherActions.forEach((act) => { const action: Action = { - icon: act.icon, + icon: act.icon || "right", label: act.label, tooltip: act.tooltip, enable: act.enable, diff --git a/src/page/list_col_action.tsx b/src/page/list_col_action.tsx index f275570..a386f0a 100644 --- a/src/page/list_col_action.tsx +++ b/src/page/list_col_action.tsx @@ -55,6 +55,7 @@ export default class extends React.PureComponent { onClick={(e: any) => { item.onClick && item.onClick(this.props.record, this.props.mainKey); }} + className="xc-page-list-op-item" > {item.tooltip -- Gitee From 05a33fa55a8a15aeb5700039e22674357ec29336 Mon Sep 17 00:00:00 2001 From: leexs Date: Mon, 8 May 2023 09:07:25 +0800 Subject: [PATCH 30/33] =?UTF-8?q?create=E9=A1=B5=E9=9D=A2=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0submitShow=E5=B1=9E=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/page/create.d.ts | 7 ++++++- lib/page/create.js | 5 ++++- src/page/create.tsx | 25 +++++++++++++++++-------- 3 files changed, 27 insertions(+), 10 deletions(-) diff --git a/lib/page/create.d.ts b/lib/page/create.d.ts index 05b6b94..df93576 100644 --- a/lib/page/create.d.ts +++ b/lib/page/create.d.ts @@ -12,6 +12,10 @@ interface Props { * 字段列表。 */ fields: Field.Base.CreateConfig[]; + /** + * 提交按钮是否显示。 + */ + submitShow: boolean; /** * 提交按钮的自定义标签。 */ @@ -52,6 +56,7 @@ interface CreateFormProps extends FormComponentProps, Props { } declare class CreateComponent extends React.PureComponent { static defaultProps: { + submitShow: boolean; submitLabel: string; formProps: {}; submitFormItemProps: {}; @@ -66,5 +71,5 @@ declare class CreateComponent extends React.PureComponent { _onReset: (e: React.MouseEvent) => void; getFormValues: (getFormData: (values: any) => void) => void; } -declare const _default: import("antd/lib/form/interface").ConnectedComponentClass>; +declare const _default: import("antd/lib/form/interface").ConnectedComponentClass>; export default _default; diff --git a/lib/page/create.js b/lib/page/create.js index 7627024..55a1e40 100644 --- a/lib/page/create.js +++ b/lib/page/create.js @@ -63,7 +63,9 @@ class CreateComponent extends React.PureComponent { // 渲染按钮 this._renderSubmit = () => { return (React.createElement(antd_1.Form.Item, Object.assign({ className: "xc-form-button", label: " ", colon: false, style: { height: "auto" } }, this.defaultSubmitFormItemProps, this.props.submitFormItemProps), - React.createElement(antd_1.Button, { className: "xc-button-default", icon: "check", type: "primary", htmlType: "submit" }, this.props.submitLabel), + this.props.submitShow + ? React.createElement(antd_1.Button, { className: "xc-button-default", icon: "check", type: "primary", htmlType: "submit" }, this.props.submitLabel) + : null, this.props.action && this.props.action.map((node) => { return node; }), @@ -137,6 +139,7 @@ class CreateComponent extends React.PureComponent { } } CreateComponent.defaultProps = { + submitShow: true, submitLabel: "提交", formProps: {}, submitFormItemProps: {}, diff --git a/src/page/create.tsx b/src/page/create.tsx index b800a56..e3abad6 100644 --- a/src/page/create.tsx +++ b/src/page/create.tsx @@ -16,6 +16,10 @@ interface Props { * 字段列表。 */ fields: Field.Base.CreateConfig[]; + /** + * 提交按钮是否显示。 + */ + submitShow: boolean; /** * 提交按钮的自定义标签。 */ @@ -57,6 +61,7 @@ interface CreateFormProps extends FormComponentProps, Props { } class CreateComponent extends React.PureComponent { static defaultProps = { + submitShow: true, submitLabel: "提交", formProps: {}, submitFormItemProps: {}, @@ -84,6 +89,7 @@ class CreateComponent extends React.PureComponent { sm: { span: 20 }, }, }; + refForm: Form | null = null; render() { @@ -151,14 +157,17 @@ class CreateComponent extends React.PureComponent { {...this.defaultSubmitFormItemProps} {...this.props.submitFormItemProps} > - + {this.props.submitShow + ? + : null + } {this.props.action && this.props.action.map((node) => { return node; })} -- Gitee From ea8e029101488de655a9f61926f8c0659c7dcc50 Mon Sep 17 00:00:00 2001 From: leexs Date: Fri, 12 May 2023 15:33:44 +0800 Subject: [PATCH 31/33] =?UTF-8?q?=E6=93=8D=E4=BD=9C=E5=88=97=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/page/list_col_action.js | 6 ++++-- src/page/list_col_action.tsx | 10 ++++++---- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/lib/page/list_col_action.js b/lib/page/list_col_action.js index 2f8b453..9c9ada7 100644 --- a/lib/page/list_col_action.js +++ b/lib/page/list_col_action.js @@ -59,9 +59,11 @@ class default_1 extends React.PureComponent { } }); return (React.createElement(antd_1.Dropdown, { overlay: React.createElement(antd_1.Menu, { onClick: this.onMenuClick }, menus), trigger: ['click'], placement: "bottomRight", visible: this.state.visible, onVisibleChange: this.onDropdownVisibleChange }, - React.createElement(antd_1.Icon, { type: "more", style: { padding: "0 8px", cursor: "pointer", color: "#f50" }, onClick: (e) => { + React.createElement("a", { style: { padding: "0 8px", color: "#f50" }, onClick: (e) => { e.stopPropagation(); - } }))); + } }, + React.createElement("span", null, "操作 "), + React.createElement(antd_1.Icon, { style: { color: "#f50" }, type: "down" })))); } ; } diff --git a/src/page/list_col_action.tsx b/src/page/list_col_action.tsx index a386f0a..c6dca26 100644 --- a/src/page/list_col_action.tsx +++ b/src/page/list_col_action.tsx @@ -84,13 +84,15 @@ export default class extends React.PureComponent { visible={this.state.visible} onVisibleChange={this.onDropdownVisibleChange} > - ) => { e.stopPropagation(); }} - /> + > + {"操作 "} + + ); }; -- Gitee From 6a1c9a64097693174066dc159d2c6d8e5cd87f26 Mon Sep 17 00:00:00 2001 From: leexs Date: Fri, 12 May 2023 15:40:45 +0800 Subject: [PATCH 32/33] =?UTF-8?q?=E6=93=8D=E4=BD=9C=E5=88=97=E6=94=B9?= =?UTF-8?q?=E7=94=A8=E4=B8=A4=E4=B8=AAicon?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/page/list_col_action.js | 6 +++--- src/page/list_col_action.tsx | 10 +++++----- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/page/list_col_action.js b/lib/page/list_col_action.js index 9c9ada7..649781c 100644 --- a/lib/page/list_col_action.js +++ b/lib/page/list_col_action.js @@ -59,11 +59,11 @@ class default_1 extends React.PureComponent { } }); return (React.createElement(antd_1.Dropdown, { overlay: React.createElement(antd_1.Menu, { onClick: this.onMenuClick }, menus), trigger: ['click'], placement: "bottomRight", visible: this.state.visible, onVisibleChange: this.onDropdownVisibleChange }, - React.createElement("a", { style: { padding: "0 8px", color: "#f50" }, onClick: (e) => { + React.createElement("span", { style: { display: "inline-block", padding: "0 8px", cursor: "pointer" }, onClick: (e) => { e.stopPropagation(); } }, - React.createElement("span", null, "操作 "), - React.createElement(antd_1.Icon, { style: { color: "#f50" }, type: "down" })))); + React.createElement(antd_1.Icon, { type: "menu", style: { marginRight: "4px" } }), + React.createElement(antd_1.Icon, { type: "down", style: { color: "#f50" } })))); } ; } diff --git a/src/page/list_col_action.tsx b/src/page/list_col_action.tsx index c6dca26..f5fd16b 100644 --- a/src/page/list_col_action.tsx +++ b/src/page/list_col_action.tsx @@ -84,15 +84,15 @@ export default class extends React.PureComponent { visible={this.state.visible} onVisibleChange={this.onDropdownVisibleChange} > - ) => { e.stopPropagation(); }} > - {"操作 "} - - + + + ); }; -- Gitee From b076199ea0d29f21ba2b9e0d2543695322144d40 Mon Sep 17 00:00:00 2001 From: leexs Date: Fri, 12 May 2023 17:00:34 +0800 Subject: [PATCH 33/33] =?UTF-8?q?=E6=81=A2=E5=A4=8Dmore=E5=8A=A0=E8=BE=B9?= =?UTF-8?q?=E6=A1=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/page/list_col_action.js | 6 ++---- src/page/list_col_action.tsx | 12 +++++------- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/lib/page/list_col_action.js b/lib/page/list_col_action.js index 649781c..f0c63b3 100644 --- a/lib/page/list_col_action.js +++ b/lib/page/list_col_action.js @@ -59,11 +59,9 @@ class default_1 extends React.PureComponent { } }); return (React.createElement(antd_1.Dropdown, { overlay: React.createElement(antd_1.Menu, { onClick: this.onMenuClick }, menus), trigger: ['click'], placement: "bottomRight", visible: this.state.visible, onVisibleChange: this.onDropdownVisibleChange }, - React.createElement("span", { style: { display: "inline-block", padding: "0 8px", cursor: "pointer" }, onClick: (e) => { + React.createElement(antd_1.Icon, { type: "more", style: { border: "1px solid #d9d9d9", borderRadius: "50%", padding: "2px", cursor: "pointer", color: "#f50" }, onClick: (e) => { e.stopPropagation(); - } }, - React.createElement(antd_1.Icon, { type: "menu", style: { marginRight: "4px" } }), - React.createElement(antd_1.Icon, { type: "down", style: { color: "#f50" } })))); + } }))); } ; } diff --git a/src/page/list_col_action.tsx b/src/page/list_col_action.tsx index f5fd16b..7b6be3b 100644 --- a/src/page/list_col_action.tsx +++ b/src/page/list_col_action.tsx @@ -84,16 +84,14 @@ export default class extends React.PureComponent { visible={this.state.visible} onVisibleChange={this.onDropdownVisibleChange} > - ) => { e.stopPropagation(); }} - > - - - - + /> + ); }; -- Gitee