Commit 529982bb by zhaochengxiang

要素可选

parent 28c20a6b
...@@ -620,7 +620,7 @@ const AssetAction = (props) => { ...@@ -620,7 +620,7 @@ const AssetAction = (props) => {
export default AssetAction; export default AssetAction;
const MultipleItem = ({ value, onChange, element }) => { export const MultipleItem = ({ value, onChange, element }) => {
return ( return (
<Select <Select
value={value?value.split(','):undefined} value={value?value.split(','):undefined}
...@@ -628,7 +628,17 @@ const MultipleItem = ({ value, onChange, element }) => { ...@@ -628,7 +628,17 @@ const MultipleItem = ({ value, onChange, element }) => {
disabled={element?.manualMaintain==='否'} disabled={element?.manualMaintain==='否'}
onChange={(val) => { onChange={(val) => {
onChange?.((val??[]).length === 0 ? undefined : val.toString()) onChange?.((val??[]).length === 0 ? undefined : val.toString())
}}> }}
dropdownRender={(originNode) => (
<div
onClick={e => {
e.stopPropagation()
}}
>
{originNode}
</div>
)}
>
{ {
(typeof(element?.optional) === 'string') && (element.optional??'').split(',').map((item, index) => <Select.Option key={index} value={item}>{item}</Select.Option>) (typeof(element?.optional) === 'string') && (element.optional??'').split(',').map((item, index) => <Select.Option key={index} value={item}>{item}</Select.Option>)
} }
......
import React from 'react' import React from 'react'
import { Tooltip, Typography, Input, Space, Button, Form, Spin } from 'antd' import { Tooltip, Typography, Input, Space, Button, Form, Spin, Select } from 'antd'
import { SettingOutlined } from '@ant-design/icons' import { SettingOutlined } from '@ant-design/icons'
import { useClickAway } from 'ahooks' import { useClickAway } from 'ahooks'
import LocalStorage from 'local-storage' import LocalStorage from 'local-storage'
...@@ -8,9 +8,9 @@ import { dispatch } from '../../../model' ...@@ -8,9 +8,9 @@ import { dispatch } from '../../../model'
import { usePage } from '../../../util/hooks/page' import { usePage } from '../../../util/hooks/page'
import Table from '../../../util/Component/Table' import Table from '../../../util/Component/Table'
import { getQueryParam, isSzseEnv } from '../../../util' import { getQueryParam, isSzseEnv } from '../../../util'
import { EditableCell } from '../Model/Component/ImportActionTable'
import '../Model/Component/EditModel.less' import '../Model/Component/EditModel.less'
import { MultipleItem } from '../AssetManage/Component/AssetAction'
const FC = (props) => { const FC = (props) => {
const ids = getQueryParam('ids', props.location?.search) const ids = getQueryParam('ids', props.location?.search)
...@@ -137,69 +137,90 @@ export const EditAssets = React.forwardRef(function ({ action, ids, elementIds } ...@@ -137,69 +137,90 @@ export const EditAssets = React.forwardRef(function ({ action, ids, elementIds }
}, },
}), [form, editingKey, modifyData, elements]) }), [form, editingKey, modifyData, elements])
const getColumnBatchEditProps = (title, dataIndex) => ({ const getColumnBatchEditProps = (element, dataIndex) => ({
filterDropdown: ({ confirm }) => ( filterDropdown: ({ confirm }) => {
<div let inputNode = <Input />
style={{
width: 320, if (element?.selectMode === '单选') {
padding: 8, inputNode = <Select
}} dropdownRender={(originNode) => (
onKeyDown={(e) => e.stopPropagation()} <div
> onClick={e => {
<h4 className='mb-3'>批量编辑</h4> e.stopPropagation()
<Form }}
form={colBatchEditForm} >
labelCol={{ span: 6 }} {originNode}
wrapperCol={{ span: 18 }} </div>
autoComplete="off" )}
>
{
(typeof(element?.optional) === 'string') && (element?.optional??'').split(',').map((item, index) => <Select.Option key={index} value={item}>{item}</Select.Option>)
}
</Select>
} else if (element?.selectMode === '多选') {
inputNode = <MultipleItem element={element} />
}
return (
<div
style={{
width: 320,
padding: 8,
}}
onKeyDown={(e) => e.stopPropagation()}
> >
<Form.Item <h4 className='mb-3'>批量编辑</h4>
name={dataIndex} <Form
label={title} form={colBatchEditForm}
rules={[{ required: true, message: `请输入${title}!` }]} labelCol={{ span: 6 }}
style={{ marginBottom: 15 }} wrapperCol={{ span: 18 }}
autoComplete="off"
> >
<Input <Form.Item
placeholder={`请输入${title}`} name={dataIndex}
/> label={element?.name}
</Form.Item> rules={[{ required: true, message: `请输入${element?.name}!` }]}
</Form> style={{ marginBottom: 15 }}
<div className='flex' style={{ justifyContent: 'end' }}>
<Space>
<Button
size='small'
onClick={() => {
confirm?.()
}}
> >
取消 { inputNode }
</Button> </Form.Item>
<Button </Form>
size='small' <div className='flex' style={{ justifyContent: 'end' }}>
type="primary" <Space>
onClick={ async () => { <Button
try { size='small'
await save() onClick={() => {
const rows = await colBatchEditForm.validateFields()
const newModifyData = [...modifyData]
const index = parseInt(dataIndex.slice('element'.length))
for (const item of newModifyData) {
item.values[index] = rows[`${dataIndex}`]
}
setModifyData(newModifyData)
confirm?.() confirm?.()
} catch (e) { }}
>
取消
</Button>
<Button
size='small'
type="primary"
onClick={ async () => {
try {
await save()
const rows = await colBatchEditForm.validateFields()
const newModifyData = [...modifyData]
const index = parseInt(dataIndex.slice('element'.length))
for (const item of newModifyData) {
item.values[index] = rows[`${dataIndex}`]
}
setModifyData(newModifyData)
confirm?.()
} catch (e) {
} }
}} }}
> >
确定 确定
</Button> </Button>
</Space> </Space>
</div>
</div> </div>
</div> )
), },
filterIcon: (filtered) => ( filterIcon: (filtered) => (
<SettingOutlined/> <SettingOutlined/>
), ),
...@@ -231,8 +252,7 @@ export const EditAssets = React.forwardRef(function ({ action, ids, elementIds } ...@@ -231,8 +252,7 @@ export const EditAssets = React.forwardRef(function ({ action, ids, elementIds }
} }
col.onCell = (record) => ({ col.onCell = (record) => ({
record, element,
inputType: 'text',
dataIndex: col.dataIndex, dataIndex: col.dataIndex,
colTitle: col.title, colTitle: col.title,
editing: isEditing(record), editing: isEditing(record),
...@@ -240,7 +260,7 @@ export const EditAssets = React.forwardRef(function ({ action, ids, elementIds } ...@@ -240,7 +260,7 @@ export const EditAssets = React.forwardRef(function ({ action, ids, elementIds }
if (action === 'edit') { if (action === 'edit') {
col = { col = {
...col, ...col,
...getColumnBatchEditProps(element.name, `element${index}`) ...getColumnBatchEditProps(element, `element${index}`)
} }
} }
...@@ -355,4 +375,64 @@ export const EditAssets = React.forwardRef(function ({ action, ids, elementIds } ...@@ -355,4 +375,64 @@ export const EditAssets = React.forwardRef(function ({ action, ids, elementIds }
</Form> </Form>
</div> </div>
) )
}) })
\ No newline at end of file
export const EditableCell = ({
editing,
dataIndex,
colTitle,
element,
require,
children,
...restProps
}) => {
let editingComponent = null
if (editing) {
let inputNode = <Input />
if (element?.selectMode === '单选') {
inputNode = <Select
dropdownRender={(originNode) => (
<div
onClick={e => {
e.stopPropagation()
}}
>
{originNode}
</div>
)}
>
{
(typeof(element?.optional) === 'string') && (element?.optional??'').split(',').map((item, index) => <Select.Option key={index} value={item}>{item}</Select.Option>)
}
</Select>
} else if (element?.selectMode === '多选') {
inputNode = <MultipleItem element={element} />
}
editingComponent = (
<Form.Item
name={dataIndex}
style={{ margin: 0 }}
rules={[
{
required: (require===null)?false:require,
message: `请输入${colTitle}!`,
},
]}
>
{ inputNode }
</Form.Item>
)
}
return (
<td {...restProps}>
{editing ? (
editingComponent
) : (
children
)}
</td>
)
}
\ No newline at end of file
...@@ -28,7 +28,7 @@ const perSuggestCount = 5; ...@@ -28,7 +28,7 @@ const perSuggestCount = 5;
const supportMaxAttributeCountPerPage = 100; const supportMaxAttributeCountPerPage = 100;
const MENU_ID = 'model-attribute-menu'; const MENU_ID = 'model-attribute-menu';
const InputDebounce = DebounceInput(300)(Input); export const InputDebounce = DebounceInput(300)(Input);
const ResizeableHeaderCell = props => { const ResizeableHeaderCell = props => {
const { onResize, width, onClick, ...restProps } = props; const { onResize, width, onClick, ...restProps } = props;
......
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