diff --git a/lib/config/bit_select.d.ts b/lib/config/bit_select.d.ts index 75f9723f1a2e0c3d6252da2d771320e92a1ba5f4..e60107c4ee3a5fc9759111079613a2b173275e99 100644 --- a/lib/config/bit_select.d.ts +++ b/lib/config/bit_select.d.ts @@ -28,6 +28,10 @@ export interface OptionItem { * 描述。 */ description?: string; + /** + * 是否显示tag样式。 + */ + showTag?: boolean; } export interface Options { /** diff --git a/lib/config/date_time.d.ts b/lib/config/date_time.d.ts index b95f9dcad8e6106fe7ceea1e27b4954f24bf3b81..13d4cd402ce5cbb459d2314d432be2b723b9f88f 100644 --- a/lib/config/date_time.d.ts +++ b/lib/config/date_time.d.ts @@ -41,6 +41,10 @@ export interface Options { * 描述。 */ description?: string; + /** + * 是否显示tag样式。 + */ + showTag?: boolean; /** * 值宽度。 */ diff --git a/lib/config/digit.d.ts b/lib/config/digit.d.ts index 0b3edf59b15234ea529f5a46b9d082ec388d550b..1a8161e9850119f41e0eed8041d6278c1e46e58d 100644 --- a/lib/config/digit.d.ts +++ b/lib/config/digit.d.ts @@ -24,6 +24,10 @@ export interface Options { * 描述。 */ description?: string; + /** + * 是否显示tag样式。 + */ + showTag?: boolean; /** * 值宽度。 */ diff --git a/lib/config/select.d.ts b/lib/config/select.d.ts index 10d1d075714d6885c068e967d1ef3672456e8774..41eadbba41ad432bf5435d783aeaad730012805a 100644 --- a/lib/config/select.d.ts +++ b/lib/config/select.d.ts @@ -58,6 +58,10 @@ export interface Options { * 描述。 */ description?: string; + /** + * 是否显示tag样式。 + */ + showTag?: boolean; /** * 值宽度。 */ diff --git a/lib/config/switch.d.ts b/lib/config/switch.d.ts index 812e32665d5b4f4302e69fdc89c89f90040c7005..094e0912b150cabf4aec4982815c0f4ec4bd4628 100644 --- a/lib/config/switch.d.ts +++ b/lib/config/switch.d.ts @@ -28,6 +28,10 @@ export interface Options { * 描述。 */ description?: string; + /** + * 是否显示tag样式。 + */ + showTag?: boolean; /** * 值宽度。 */ diff --git a/lib/config/text.d.ts b/lib/config/text.d.ts index eba71bef13d4b140e4da0e4b28153b33ffd157ec..9cf93655616c40e89e7e130787aa5fe409c2c265 100644 --- a/lib/config/text.d.ts +++ b/lib/config/text.d.ts @@ -1,6 +1,7 @@ /** * 文本类型。 */ +/// import * as Base from './base'; export declare const Type = "text"; export interface Options { @@ -28,6 +29,10 @@ export interface Options { * 描述。 */ description?: string; + /** + * 是否显示tag样式。 + */ + showTag?: boolean; /** * 值宽度。 */ @@ -36,6 +41,10 @@ export interface Options { * 单位宽度。 */ unitWidth?: number; + /** + * 自定义渲染方法 + */ + render?: (text: string) => React.ReactNode; } export declare const DefaultOptions: Options; export declare const NewBase: (name: string, label: string, options?: Partial) => Base.Config; diff --git a/lib/config/tree_select.d.ts b/lib/config/tree_select.d.ts index cbc888a669e73ed32da4f6bf4aad8fc1f62204d9..e6344807c4939b147eaa3a3afdac1453a5f159c9 100644 --- a/lib/config/tree_select.d.ts +++ b/lib/config/tree_select.d.ts @@ -33,6 +33,10 @@ export interface Options { * 描述。 */ description?: string; + /** + * 是否显示tag样式。 + */ + showTag?: boolean; /** * 值宽度。 */ diff --git a/lib/field/detail/bit_select.js b/lib/field/detail/bit_select.js index 496b479d539984044af54753b5aa9d652f7d5b38..6d72c6de7b576ff0110233bd3dcabe36fe06ca9a 100644 --- a/lib/field/detail/bit_select.js +++ b/lib/field/detail/bit_select.js @@ -33,7 +33,7 @@ class BitSelect extends React.PureComponent { const valueLabel = this._getValueLabel(item); return valueLabel === null ? null : (React.createElement("div", { key: key, className: "xc-bit-select-view" }, item.fieldLabel + ": " + valueLabel, - Render.description(this.props.list, item.description))); + Render.description(item.description, item.showTag))); }; } render() { @@ -49,7 +49,7 @@ class BitSelect extends React.PureComponent { 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(this.props.list, item.description))); + Render.description(item.description, item.showTag))); } 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 52479c826fca965373a8f556b7b57773a3999e07..ec59bf0ae11140a0cb62f289df02ad52d5a092ef 100644 --- a/lib/field/detail/date_time.js +++ b/lib/field/detail/date_time.js @@ -58,7 +58,7 @@ class DateTime 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.description(this.props.list, field.options.description)); + 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/detail/digit.js b/lib/field/detail/digit.js index 06076a866c4be172610f4ba5062b04d1a6f509c3..bc202b700cd45a7c7519a6c912559fd650970aef 100644 --- a/lib/field/detail/digit.js +++ b/lib/field/detail/digit.js @@ -29,8 +29,8 @@ 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(this.props.list, field.options.unitLabel, field.options.unitWidth), - Render.description(this.props.list, field.options.description)); + 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(DigitView, Object.assign({}, option))); diff --git a/lib/field/detail/select.js b/lib/field/detail/select.js index 547adbd21a4eca03f08863f303da97ad372c99ba..6f793594db5ab561544d3ff9217979109f0d462d 100644 --- a/lib/field/detail/select.js +++ b/lib/field/detail/select.js @@ -56,8 +56,8 @@ 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(this.props.list, field.options.unitLabel, field.options.unitWidth), - Render.description(this.props.list, field.options.description)); + 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(Select, Object.assign({}, option))); diff --git a/lib/field/detail/storage.d.ts b/lib/field/detail/storage.d.ts index 9452c36d5c1e804ecdc75436c5757abc65a10874..b1316eb1d7f2f03dabbe34b8bbf8838196d2c1e0 100644 --- a/lib/field/detail/storage.d.ts +++ b/lib/field/detail/storage.d.ts @@ -11,10 +11,6 @@ export interface Option { data: { [key: string]: any; }; - /** - * 是否是列表。 - */ - list?: boolean; } export declare function get(option: Option): React.ReactNode | null; export declare function set(fieldType: string, func?: (option: Option) => React.ReactNode | null): void; diff --git a/lib/field/detail/switch.js b/lib/field/detail/switch.js index d58a5564ba4ade86a79e0fe8c2eebd11c4d1c5fc..b0c7e7f8716a909ac46cf55b71e34a1704058796 100644 --- a/lib/field/detail/switch.js +++ b/lib/field/detail/switch.js @@ -32,8 +32,8 @@ 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(this.props.list, field.options.unitLabel, field.options.unitWidth), - Render.description(this.props.list, field.options.description)); + : Render.unit(field.options.unitLabel, field.options.showTag, 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 73ce65b99b75755e3ead51894dd098af0681067c..0f05143b411e8e0f8a488d9cc785b4d910787564 100644 --- a/lib/field/detail/text.js +++ b/lib/field/detail/text.js @@ -22,9 +22,11 @@ class TextView 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.unit(this.props.list, field.options.unitLabel, field.options.unitWidth), - Render.description(this.props.list, field.options.description)); + 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.description(field.options.description, field.options.showTag)); } } 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 aa5eb1e05d7d53bdd14eaf3187471cb880d92b93..77d69f23159705886df1ab39b28937defca3d8ed 100644 --- a/lib/field/detail/tree_select.js +++ b/lib/field/detail/tree_select.js @@ -60,7 +60,7 @@ class TreeSelectView 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.description(this.props.list, field.options.description)); + 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/modify/bit_select.js b/lib/field/modify/bit_select.js index f7577169ff2470c0503962305004fb7f4678c530..c6fa445d69f9e11cbd0161063083256687d7c315 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(false, option.description))))); + Render.description(option.description, option.showTag === undefined ? true : 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 19ccf4e85f44092a8819a763e0e6470b1fd3a74b..19aca07793eb5a332ad2692daf38138d34a20c1f 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(false, field.options.description))); + Render.description(field.options.description, field.options.showTag === undefined ? true : 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 3ab973235931cebc07eecb23dc47918a923e61e2..d7d282f0a57034fd9d3e0fcb6f3f57888f812f61 100644 --- a/lib/field/modify/digit.js +++ b/lib/field/modify/digit.js @@ -60,8 +60,8 @@ 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(false, field.options.unitLabel, field.options.unitWidth), - Render.description(false, field.options.description))); + 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))); } } 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 c09d7758e5bd11ba69154c926a2329345c5aa41d..ca32d35f481deb69c5c8c6bd6f81e28d710b2bc4 100644 --- a/lib/field/modify/select.js +++ b/lib/field/modify/select.js @@ -60,8 +60,8 @@ class SelectView extends React.PureComponent { return option.props.children.indexOf(value) >= 0; } : undefined, onChange: this._onChange }, this.state.dataSource !== undefined ? this.state.dataSource.map(this._renderSelectOption) : undefined)), - Render.unit(false, field.options.unitLabel, field.options.unitWidth), - Render.description(false, field.options.description))); + 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))); } } 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 e769d93bc07e06aaab05a1e7b245cf325cf0d100..420c65e720d1f99d2d8dace50f0f6aa98ff91a0b 100644 --- a/lib/field/modify/switch.js +++ b/lib/field/modify/switch.js @@ -32,8 +32,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" } })), - useRadio ? null : Render.unit(false, field.options.unitLabel, field.options.unitWidth), - Render.description(false, field.options.description))); + 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))); } } 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 8f00055006b2f07556837cf86c1fba6b359dfdfc..bda6e731b4b31488ef74d1cd89b1ee0f17f1cfbe 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(false, field.options.unitLabel, field.options.unitWidth), - Render.description(false, field.options.description))); + 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))); } } 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 1532140a1da4a4178c9c59dc26f6ee301c44d849..a11fe579a0607dadde8f6e019d4463425ebf66fc 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(false, field.options.description))); + Render.description(field.options.description, field.options.showTag === undefined ? true : field.options.showTag))); } } Storage.set(Field.TreeSelect.Type, (option) => React.createElement(TreeSelectView, Object.assign({}, option))); diff --git a/lib/field/util/render.d.ts b/lib/field/util/render.d.ts index 722eb2f8b91f1f7aa6b07244d2385b44418502e6..b14e18c7e302be5fafa3ae8ef4bd63cc8d891b75 100644 --- a/lib/field/util/render.d.ts +++ b/lib/field/util/render.d.ts @@ -1,3 +1,3 @@ /// -export declare function unit(list?: boolean, unit?: string, witdh?: number): JSX.Element | null; -export declare function description(list?: boolean, desc?: string): JSX.Element | null; +export declare function unit(unit?: string, tag?: boolean, witdh?: number): JSX.Element | null; +export declare function description(desc?: string, tag?: boolean): JSX.Element | null; diff --git a/lib/field/util/render.js b/lib/field/util/render.js index 2ec42de6ae30a945456307c36ada6d0cfcae5c56..b10462607860197e6548b996a9c0f32478c91d28 100644 --- a/lib/field/util/render.js +++ b/lib/field/util/render.js @@ -9,17 +9,17 @@ var __importStar = (this && this.__importStar) || function (mod) { Object.defineProperty(exports, "__esModule", { value: true }); const React = __importStar(require("react")); const antd_1 = require("antd"); -function unit(list, unit, witdh) { +function unit(unit, tag, witdh) { return unit - ? (list === true - ? React.createElement("span", null, unit) - : React.createElement(antd_1.Tag, { color: "#2db7f5", style: { width: witdh || "auto", textAlign: "center" } }, unit)) : null; + ? (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(list, desc) { +function description(desc, tag) { return desc - ? (list === true - ? React.createElement("span", null, unit) - : React.createElement(antd_1.Tag, { color: "blue" }, desc)) : null; + ? (tag === true + ? React.createElement(antd_1.Tag, { color: "blue" }, desc) + : React.createElement("span", null, unit)) : null; } exports.description = description; diff --git a/lib/page/list.js b/lib/page/list.js index 26a32a5bf1e6eeb60af617a4b0c69eb81b740430..ea8d9e36a0cc376fb69d6f35d26973e9616d06ea 100644 --- a/lib/page/list.js +++ b/lib/page/list.js @@ -78,7 +78,6 @@ class ListPage extends React.PureComponent { const option = { field: Object.assign(Object.assign({}, fieldItem), { options: Object.assign(Object.assign({}, fieldItem.options), { showInDetail: true }) }), data: { [fieldItem.name]: value }, - list: true, }; return DetailFields.get(option); } }, fieldItem.options.tableProps))); diff --git a/src/config/bit_select.ts b/src/config/bit_select.ts index 1fa36c46732bf5da5086288c49dfad4e15a65e38..3364b2d64d7ff606ebaeb1d110cc908ef7d6498f 100644 --- a/src/config/bit_select.ts +++ b/src/config/bit_select.ts @@ -31,6 +31,10 @@ export interface OptionItem { * 描述。 */ description?: string; + /** + * 是否显示tag样式。 + */ + showTag?: boolean, } export interface Options { diff --git a/src/config/date_time.ts b/src/config/date_time.ts index 034c281321dc11f2e94620f560d746b430f18cdd..7edd76295e21c49c73a21c1efaac7c240de3f15d 100644 --- a/src/config/date_time.ts +++ b/src/config/date_time.ts @@ -44,6 +44,10 @@ export interface Options { * 描述。 */ description?: string; + /** + * 是否显示tag样式。 + */ + showTag?: boolean, /** * 值宽度。 */ diff --git a/src/config/digit.ts b/src/config/digit.ts index ff33a441b7f2c325f40b2bcce7f31170d63bd842..7dffa9c87a90ed462550291e5b629afef4fe1ebf 100644 --- a/src/config/digit.ts +++ b/src/config/digit.ts @@ -27,6 +27,10 @@ export interface Options { * 描述。 */ description?: string; + /** + * 是否显示tag样式。 + */ + showTag?: boolean, /** * 值宽度。 */ diff --git a/src/config/select.ts b/src/config/select.ts index 5ef789ff4ceec6365d3c60a1676d3d04cbf3ec27..0574b237914edae12350b391131b899c85523b7a 100644 --- a/src/config/select.ts +++ b/src/config/select.ts @@ -62,6 +62,10 @@ export interface Options { * 描述。 */ description?: string; + /** + * 是否显示tag样式。 + */ + showTag?: boolean, /** * 值宽度。 */ diff --git a/src/config/switch.ts b/src/config/switch.ts index ecdbdb48556446420ee25939c429aedf1297c1d1..a3e43ae048883778f4cb28e983a12c84b1548ec0 100644 --- a/src/config/switch.ts +++ b/src/config/switch.ts @@ -31,6 +31,10 @@ export interface Options { * 描述。 */ description?: string; + /** + * 是否显示tag样式。 + */ + showTag?: boolean, /** * 值宽度。 */ diff --git a/src/config/text.ts b/src/config/text.ts index 6f752043978361cdfced0c56b60ba2448a0235e6..8cd8d81522df92d7188e8951e7ecb8e7d98dfb9c 100644 --- a/src/config/text.ts +++ b/src/config/text.ts @@ -31,6 +31,10 @@ export interface Options { * 描述。 */ description?: string; + /** + * 是否显示tag样式。 + */ + showTag?: boolean, /** * 值宽度。 */ @@ -39,6 +43,10 @@ export interface Options { * 单位宽度。 */ unitWidth?: number; + /** + * 自定义渲染方法 + */ + render?: (text: string) => React.ReactNode; } export const DefaultOptions: Options = { diff --git a/src/config/tree_select.ts b/src/config/tree_select.ts index f68a409b3b28e9af4740d19bcc7e0ee729dacb76..4cefe81871830c049b56b9ce28a10b7b4a65d2e6 100644 --- a/src/config/tree_select.ts +++ b/src/config/tree_select.ts @@ -36,6 +36,10 @@ export interface Options { * 描述。 */ description?: string; + /** + * 是否显示tag样式。 + */ + showTag?: boolean, /** * 值宽度。 */ diff --git a/src/field/detail/bit_select.tsx b/src/field/detail/bit_select.tsx index ef35c7499dff79b91cd95ef7ef5aca0da234006b..c7282988c388eb132960ac0262bb6be4cef48f3d 100644 --- a/src/field/detail/bit_select.tsx +++ b/src/field/detail/bit_select.tsx @@ -22,7 +22,7 @@ class BitSelect extends React.PureComponent { {valueLabel} - {Render.description(this.props.list, item.description)} + {Render.description(item.description, item.showTag)} ); } @@ -54,7 +54,7 @@ class BitSelect extends React.PureComponent { return valueLabel === null ? null : (
{item.fieldLabel + ": " + valueLabel} - {Render.description(this.props.list, item.description)} + {Render.description(item.description, item.showTag)}
); }; diff --git a/src/field/detail/date_time.tsx b/src/field/detail/date_time.tsx index e51efc29dfb001bb0079107b3e9e0d8963533ed7..61c73fb770fa3612f8414e6486494988f6e649e1 100644 --- a/src/field/detail/date_time.tsx +++ b/src/field/detail/date_time.tsx @@ -16,7 +16,7 @@ class DateTime extends React.PureComponent { {value} - {Render.description(this.props.list, field.options.description)} + {Render.description(field.options.description, field.options.showTag)} ; } diff --git a/src/field/detail/digit.tsx b/src/field/detail/digit.tsx index c1806cc1b1777b272b9dca9161edb62542ccd1c8..18e5f9cec84ada0c66bf8856d83724b33dbc8523 100644 --- a/src/field/detail/digit.tsx +++ b/src/field/detail/digit.tsx @@ -24,8 +24,8 @@ class DigitView extends React.PureComponent { {value} - {Render.unit(this.props.list, field.options.unitLabel, field.options.unitWidth)} - {Render.description(this.props.list, field.options.description)} + {Render.unit(field.options.unitLabel, field.options.showTag, 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 f3c1d14924dafd8b965bab03a5aa67cce2d2cc34..cf36b4ba9e3298da74893e94e074d4cc8d1f26ce 100644 --- a/src/field/detail/select.tsx +++ b/src/field/detail/select.tsx @@ -57,8 +57,8 @@ class Select extends React.PureComponent { {value} - {Render.unit(this.props.list, field.options.unitLabel, field.options.unitWidth)} - {Render.description(this.props.list, field.options.description)} + {Render.unit(field.options.unitLabel, field.options.showTag, field.options.unitWidth)} + {Render.description(field.options.description, field.options.showTag)} ; } } diff --git a/src/field/detail/storage.ts b/src/field/detail/storage.ts index 68a44f24b68f32053d8b0b31dc168b1cbc45c823..323923ca8ed3e32f5e24659a74e5b97776be4cf3 100644 --- a/src/field/detail/storage.ts +++ b/src/field/detail/storage.ts @@ -9,10 +9,6 @@ export interface Option { * 实际数据。 */ data: { [key: string]: any }; - /** - * 是否是列表。 - */ - list?: boolean, } const gMap: { [fieldType: string]: (option: Option) => React.ReactNode | null } = {}; diff --git a/src/field/detail/switch.tsx b/src/field/detail/switch.tsx index 759174808abc9ed75bb5ad0b381ddd48dcb70583..98d81697cc27fc186e185f36233025811b538393 100644 --- a/src/field/detail/switch.tsx +++ b/src/field/detail/switch.tsx @@ -29,9 +29,9 @@ class Switch extends React.PureComponent { ? : ) - : Render.unit(this.props.list, field.options.unitLabel, field.options.unitWidth) + : Render.unit(field.options.unitLabel, field.options.showTag, field.options.unitWidth) } - {Render.description(this.props.list, field.options.description)} + {Render.description(field.options.description, field.options.showTag)} ; }; } diff --git a/src/field/detail/text.tsx b/src/field/detail/text.tsx index 80188002832bbfdcfa7c9c6737cb9b6724b50900..674ff28035cc6d1dc213d08e191369f1975bd8ed 100644 --- a/src/field/detail/text.tsx +++ b/src/field/detail/text.tsx @@ -16,11 +16,14 @@ class TextView extends React.PureComponent { return value === "" ?
:
- - {value} - - {Render.unit(this.props.list, field.options.unitLabel, field.options.unitWidth)} - {Render.description(this.props.list, field.options.description)} + {field.options.render === undefined + ? + {value} + + : field.options.render(value) + } + {Render.unit(field.options.unitLabel, field.options.showTag, 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 214efc8035ce5fa801150c16001536cb6be90490..8b5abdd68427c20b82ab4e3a0268b0fb668765f0 100644 --- a/src/field/detail/tree_select.tsx +++ b/src/field/detail/tree_select.tsx @@ -49,7 +49,7 @@ class TreeSelectView extends React.PureComponent { {value} - {Render.description(this.props.list, field.options.description)} + {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 1a351f59639317c99649343eb5cd2f326a551608..855f998ab95a3d5dd6053b0665c5580b9ec92c44 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(false, option.description)} + {Render.description(option.description, option.showTag === undefined ? true : option.showTag)} diff --git a/src/field/modify/date_time.tsx b/src/field/modify/date_time.tsx index 1a234513ef08a768e157515cfa948263d2ae5f85..13eb42e5750517d5244be7191c37b8a4adb9e694 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(false, field.options.description)} + {Render.description(field.options.description, field.options.showTag === undefined ? true : field.options.showTag)} ); } diff --git a/src/field/modify/digit.tsx b/src/field/modify/digit.tsx index 425eb06dbb38082b89bd9035a702cf980e59b098..1a439788f22042e4f14fd7b6ff96c01d59884bef 100644 --- a/src/field/modify/digit.tsx +++ b/src/field/modify/digit.tsx @@ -41,8 +41,8 @@ class Digit extends React.PureComponent { onChange={this._onChange} /> )} - {Render.unit(false, field.options.unitLabel, field.options.unitWidth)} - {Render.description(false, field.options.description)} + {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)} ); } diff --git a/src/field/modify/select.tsx b/src/field/modify/select.tsx index ce6f97d340aa425f986cbb530da0bb0056ca29aa..503b5216702020529146afe8659cc8e6aa5865e1 100644 --- a/src/field/modify/select.tsx +++ b/src/field/modify/select.tsx @@ -67,8 +67,8 @@ class SelectView extends React.PureComponent { {this.state.dataSource !== undefined ? this.state.dataSource.map(this._renderSelectOption) : undefined} )} - {Render.unit(false, field.options.unitLabel, field.options.unitWidth)} - {Render.description(false, field.options.description)} + {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)} ); } diff --git a/src/field/modify/switch.tsx b/src/field/modify/switch.tsx index f30af4ebdacded5fa8de1aaba6ba1845836d8125..060a9ed93ea0ca88cbab6622d3414af54e93a110 100644 --- a/src/field/modify/switch.tsx +++ b/src/field/modify/switch.tsx @@ -41,8 +41,8 @@ class SwitchView extends React.PureComponent { style={{ width: field.options.valueWidth || "auto" }} /> )} - {useRadio ? null : Render.unit(false, field.options.unitLabel, field.options.unitWidth)} - {Render.description(false, field.options.description)} + {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)} ); } diff --git a/src/field/modify/text.tsx b/src/field/modify/text.tsx index bfb87aca7a1ac76613c27ad3153ea8d9e192f800..866c040e02e193b07553f8f530e1f5eb6fc2944c 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(false, field.options.unitLabel, field.options.unitWidth)} - {Render.description(false, field.options.description)} + {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)} ); } diff --git a/src/field/modify/tree_select.tsx b/src/field/modify/tree_select.tsx index bab8f23902683684af6c5741ca2f0ad9eb967a25..e50f4c28774b78b21dddfc41501f35b36556a6c9 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(false, field.options.description)} + {Render.description(field.options.description, field.options.showTag === undefined ? true : field.options.showTag)} ); } diff --git a/src/field/util/render.tsx b/src/field/util/render.tsx index bf39120bad182aed2b7c2982eff786e2d49f39fc..8fc359b6cd3dfd9167c408877fd68db4ba919ff0 100644 --- a/src/field/util/render.tsx +++ b/src/field/util/render.tsx @@ -1,23 +1,23 @@ import * as React from 'react'; import { Tag } from 'antd'; -export function unit(list?: boolean, unit?: string, witdh?: number) { +export function unit(unit?: string, tag?: boolean, witdh?: number) { return unit - ? (list === true - ? {unit} - : {unit} + : {unit} ) : null; } -export function description(list?: boolean, desc?: string) { +export function description(desc?: string, tag?: boolean) { return desc - ? (list === true - ? {unit} - : {desc} + ? (tag === true + ? {desc} + : {unit} ) : null; } diff --git a/src/page/list.tsx b/src/page/list.tsx index e2940a88795d77205355d51641c74791d2cc4d77..ebf9ce0d8753912aa83b17dac834c77b0b4cd2f5 100644 --- a/src/page/list.tsx +++ b/src/page/list.tsx @@ -259,7 +259,6 @@ export default class ListPage extends React.PureComponent { }, }, data: { [fieldItem.name]: value }, - list: true, }; return DetailFields.get(option); }}