diff --git a/src/widgets/antd/list.jsx b/src/widgets/antd/list.jsx index 9a0b2d9..855b262 100644 --- a/src/widgets/antd/list.jsx +++ b/src/widgets/antd/list.jsx @@ -51,7 +51,7 @@ class ListItem extends React.Component { render() { const { item, p = {}, name, fold } = this.props; const descProps = { ...p, index: name }; - const { options = {} } = p; + const { options = {}, readonly } = p; const { foldable: canFold, hideDelete } = options; // 只有当items为object时才做收起(fold)处理 const isObj = p.schema.items && p.schema.items.type == 'object'; @@ -72,8 +72,8 @@ class ListItem extends React.Component { style={{ position: 'absolute', top: 12, right: 36 }} /> )} - - {!((canFold && fold) || hideDelete) && ( + {!readonly && } + {!((canFold && fold) || hideDelete || readonly) && ( @@ -127,37 +128,39 @@ class FieldList extends React.Component { })} /> ))} - - - 新增 - - {p.extraButtons && - p.extraButtons.length > 0 && - p.extraButtons.map(item => ( - { - if (item.callback === 'clearAll') { - p.onChange(p.name, []); - return; - } - if (item.callback === 'copyLast') { - const value = [...p.value]; - const lastIndex = value.length - 1; - value.push(lastIndex > -1 ? value[lastIndex] : p.newItem); - p.onChange(p.name, value); - return; - } - if (typeof window[item.callback] === 'function') { - window[item.callback].call(); // eslint-disable-line - } - }} - > - {item.text} - - ))} - + {!readonly && ( + + + 新增 + + {p.extraButtons && + p.extraButtons.length > 0 && + p.extraButtons.map(item => ( + { + if (item.callback === 'clearAll') { + p.onChange(p.name, []); + return; + } + if (item.callback === 'copyLast') { + const value = [...p.value]; + const lastIndex = value.length - 1; + value.push(lastIndex > -1 ? value[lastIndex] : p.newItem); + p.onChange(p.name, value); + return; + } + if (typeof window[item.callback] === 'function') { + window[item.callback].call(); // eslint-disable-line + } + }} + > + {item.text} + + ))} + + )} ); } diff --git a/src/widgets/fusion/list.jsx b/src/widgets/fusion/list.jsx index 10352ed..9310a43 100644 --- a/src/widgets/fusion/list.jsx +++ b/src/widgets/fusion/list.jsx @@ -48,7 +48,7 @@ class ListItem extends React.Component { render() { const { item, p = {}, name, fold } = this.props; const descProps = { ...p, index: name }; - const { options = {} } = p; + const { options = {}, readonly } = p; const { foldable: canFold, hideDelete } = options; // 只有当items为object时才做收起(fold)处理 const isObj = p.schema.items && p.schema.items.type == 'object'; @@ -69,8 +69,8 @@ class ListItem extends React.Component { style={{ position: 'absolute', top: 12, right: 36 }} /> )} - - {!((canFold && fold) || hideDelete) && ( + {!readonly && } + {!((canFold && fold) || hideDelete || readonly) && ( { @@ -100,6 +100,7 @@ class FieldList extends React.Component { render() { const { p, foldList = [], toggleFoldItem } = this.props; + const { readonly } = p; const list = p.value || []; return ( @@ -122,38 +123,40 @@ class FieldList extends React.Component { })} /> ))} - - - - 新增 - - {p.extraButtons && - p.extraButtons.length > 0 && - p.extraButtons.map(item => ( - { - if (item.callback === 'clearAll') { - p.onChange(p.name, []); - return; - } - if (item.callback === 'copyLast') { - const value = [...p.value]; - const lastIndex = value.length - 1; - value.push(lastIndex > -1 ? value[lastIndex] : p.newItem); - p.onChange(p.name, value); - return; - } - if (typeof window[item.callback] === 'function') { - window[item.callback].call(); // eslint-disable-line - } - }} - > - - {item.text} - - ))} - + {!readonly && ( + + + + 新增 + + {p.extraButtons && + p.extraButtons.length > 0 && + p.extraButtons.map(item => ( + { + if (item.callback === 'clearAll') { + p.onChange(p.name, []); + return; + } + if (item.callback === 'copyLast') { + const value = [...p.value]; + const lastIndex = value.length - 1; + value.push(lastIndex > -1 ? value[lastIndex] : p.newItem); + p.onChange(p.name, value); + return; + } + if (typeof window[item.callback] === 'function') { + window[item.callback].call(); // eslint-disable-line + } + }} + > + + {item.text} + + ))} + + )} ); }