Commit 3ef4d574 authored by 田翔's avatar 田翔

fix: 增加只读参数传递

parent 91621f11
......@@ -47,15 +47,13 @@ const { Option } = Select;
const dateFormat = 'YYYY-MM-DD';
const SearchGroup = forwardRef((props, ref) => {
useImperativeHandle(ref, () => ({
getQueryInfo,
}));
const { readOnly } = props
const [form] = Form.useForm();
// const {
// fieldSearch
// } = props.params;
const [showPicker, setShowPicker] = useState(true);
const [dateArray, setDateArray] = useState([
// moment(moment().format('YYYY-MM-DD 00:00:00')).subtract(1, 'years'),
......@@ -229,55 +227,15 @@ const SearchGroup = forwardRef((props, ref) => {
) : (
''
)}
{/* {filterColumnsList.map((item, index) => (
<Form.Item key={item.name + index} label={item.alias} className={styles.noMarginBottom}>
<Select
size='middle'
defaultValue='全部'
onChange={e => storeFilterListValue(e, item.name)}
style={{ width: 120 }}
>
{item.list.map(obj => (
<Option key={obj} value={obj}>
{obj}
</Option>
))}
</Select>
</Form.Item>
))} */}
<Form.Item label={'快捷搜索'} name="info" className={styles.noMarginBottom}>
{/* {searchKey && fieldSearch ? <Select
style={{ maxWidth: '112px' }}
placeholder='请选择字段'
showArrow
showSearch
allowClear
onSelect={e => setSearchKey(e)}
defaultValue={searchKey}
>
{accountConfig?.searchFieldGroup?.slice(
1,
-1,
).split(',').map(v => <Select.Option key={v} value={v}>{v}</Select.Option>)}
</Select> : null} */}
<Search
// title={`请输入${accountConfig?.searchFieldGroup?.slice(
// 1,
// -1,
// ) || ''}搜索`}
size="middle"
// placeholder={`请输入${accountConfig?.searchFieldGroup?.slice(
// 1,
// -1,
// ) || ''}搜索`}
style={{
width: 320,
verticalAlign: 'middle',
marginLeft: '10px',
}}
placeholder="请输入值"
// value={searchValues}
// onChange={e => setSearchValues(e.target.value)}
onSearch={onSearch}
/>
</Form.Item>
......@@ -285,54 +243,20 @@ const SearchGroup = forwardRef((props, ref) => {
</Form>
{/* 按钮区域 */}
<div className={styles.controlRowRight}>
{/* {
state !== 'special' ? <Dropdown.Button type={permission.includes('addBtn') ? '' : 'primary'} icon={<DownOutlined />}
overlay={menu}>其他操作</Dropdown.Button> : ''
}
{
bulkButton ? <Dropdown.Button style={{ "marginLeft": "20px" }} type={permission.includes('addBtn') ? '' : 'primary'} icon={<DownOutlined />}
overlay={batchMenu}>批量操作</Dropdown.Button> : ''
} */}
<div className={styles.controlBtns}>
{/* {permission.includes('editBtn') && !bulkButton ? (
<Button
type="primary" ghost
size='middle'
onClick={() => bulkEditing()}
icon={<EditOutlined />}
style={{ marginLeft: 20 }}
>
批量修改
</Button>
) : (
''
)} */}
{/* {permission.includes('deleteBtn') && !bulkButton ? (
<Button
type='primary' ghost
size='middle'
onClick={() => deleteInBatch()}
icon={<DeleteOutlined />}
style={{ marginLeft: 20 }}
>
批量删除
</Button>
) : (
''
)} */}
{/* {permission.includes('addBtn') ? ( */}
<Button
type="primary"
size="middle"
onClick={() => btnsClick('添加')}
icon={<PlusOutlined />}
style={{ marginLeft: 20 }}
>
添加
</Button>
{/* ) : (
''
)} */}
{
!readOnly ? (
<Button
type="primary"
size="middle"
onClick={() => btnsClick('添加')}
icon={<PlusOutlined />}
style={{ marginLeft: 20 }}
>
添加
</Button>
) : null
}
</div>
</div>
</Row>
......
......@@ -37,7 +37,7 @@ const getFileInfo = (formJson) => {
const Account = (props) => {
const userID = window?.globalConfig?.userInfo?.OID || 1
const { accountName } = props
const { accountName, readOnly } = props
const [detailShow, setDetailShow] = useState(false)
const [params, setParams] = useState({
userID: userID,
......@@ -65,9 +65,7 @@ const Account = (props) => {
const getColumnSearchProps = (dataIndex) => ({
filterDropdown: ({ setSelectedKeys, selectedKeys, confirm, clearFilters, close }) => (
<div
style={{
padding: 8,
}}
style={{ padding: 8 }}
onKeyDown={(e) => e.stopPropagation()}
>
<Input
......@@ -136,6 +134,31 @@ const Account = (props) => {
return array
}, [config])
const btns = useMemo(() => {
if (readOnly) {
return [
{
title: '详情',
icon: <IconPack.XiangQing />,
},
]
}
return [
{
title: '详情',
icon: <IconPack.XiangQing />,
},
{
title: '编辑',
icon: <IconPack.BianJi />,
},
{
title: '删除',
icon: <IconPack.ShanChu />,
}
]
}, [readOnly])
const columns = useMemo(() => {
return [
{
......@@ -149,24 +172,10 @@ const Account = (props) => {
...fileColumns,
{
title: '操作',
width: 120,
width: btns.length * 35 + 30,
align: 'center',
fixed: 'right',
render: (r) => {
let btns = [
{
title: '详情',
icon: <IconPack.XiangQing />,
},
{
title: '编辑',
icon: <IconPack.BianJi />,
},
{
title: '删除',
icon: <IconPack.ShanChu />,
}
]
return (
<div style={{ display: 'flex', justifyContent: 'center' }}>
{
......@@ -174,6 +183,7 @@ const Account = (props) => {
if (v.title === '删除') {
return (
<Popconfirm
key={v.title}
title='确定要删除数据吗?'
onConfirm={() => btnsClick(v.title, r.ID)}
okText='确定'
......@@ -190,6 +200,7 @@ const Account = (props) => {
}
return (
<Button
key={v.title}
type='link'
title={v.title}
icon={v.icon}
......@@ -205,7 +216,7 @@ const Account = (props) => {
}
}
]
}, [fileColumns])
}, [btns, fileColumns])
const btnsClick = async (type, id) => {
const { addFieldGroup, editFieldGroup, formJson } = config
......@@ -356,6 +367,7 @@ const Account = (props) => {
<SearchGroup
onChange={search}
btnsClick={btnsClick}
readOnly={readOnly}
/>
</div>
<div className={styles.bottom}>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment