Commit 529982bb by zhaochengxiang

要素可选

parent 28c20a6b
......@@ -620,7 +620,7 @@ const AssetAction = (props) => {
export default AssetAction;
const MultipleItem = ({ value, onChange, element }) => {
export const MultipleItem = ({ value, onChange, element }) => {
return (
<Select
value={value?value.split(','):undefined}
......@@ -628,7 +628,17 @@ const MultipleItem = ({ value, onChange, element }) => {
disabled={element?.manualMaintain==='否'}
onChange={(val) => {
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>)
}
......
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 { useClickAway } from 'ahooks'
import LocalStorage from 'local-storage'
......@@ -8,9 +8,9 @@ import { dispatch } from '../../../model'
import { usePage } from '../../../util/hooks/page'
import Table from '../../../util/Component/Table'
import { getQueryParam, isSzseEnv } from '../../../util'
import { EditableCell } from '../Model/Component/ImportActionTable'
import '../Model/Component/EditModel.less'
import { MultipleItem } from '../AssetManage/Component/AssetAction'
const FC = (props) => {
const ids = getQueryParam('ids', props.location?.search)
......@@ -137,69 +137,90 @@ export const EditAssets = React.forwardRef(function ({ action, ids, elementIds }
},
}), [form, editingKey, modifyData, elements])
const getColumnBatchEditProps = (title, dataIndex) => ({
filterDropdown: ({ confirm }) => (
<div
style={{
width: 320,
padding: 8,
}}
onKeyDown={(e) => e.stopPropagation()}
>
<h4 className='mb-3'>批量编辑</h4>
<Form
form={colBatchEditForm}
labelCol={{ span: 6 }}
wrapperCol={{ span: 18 }}
autoComplete="off"
const getColumnBatchEditProps = (element, dataIndex) => ({
filterDropdown: ({ confirm }) => {
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} />
}
return (
<div
style={{
width: 320,
padding: 8,
}}
onKeyDown={(e) => e.stopPropagation()}
>
<Form.Item
name={dataIndex}
label={title}
rules={[{ required: true, message: `请输入${title}!` }]}
style={{ marginBottom: 15 }}
<h4 className='mb-3'>批量编辑</h4>
<Form
form={colBatchEditForm}
labelCol={{ span: 6 }}
wrapperCol={{ span: 18 }}
autoComplete="off"
>
<Input
placeholder={`请输入${title}`}
/>
</Form.Item>
</Form>
<div className='flex' style={{ justifyContent: 'end' }}>
<Space>
<Button
size='small'
onClick={() => {
confirm?.()
}}
<Form.Item
name={dataIndex}
label={element?.name}
rules={[{ required: true, message: `请输入${element?.name}!` }]}
style={{ marginBottom: 15 }}
>
取消
</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)
{ inputNode }
</Form.Item>
</Form>
<div className='flex' style={{ justifyContent: 'end' }}>
<Space>
<Button
size='small'
onClick={() => {
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>
</Space>
}
}}
>
确定
</Button>
</Space>
</div>
</div>
</div>
),
)
},
filterIcon: (filtered) => (
<SettingOutlined/>
),
......@@ -231,8 +252,7 @@ export const EditAssets = React.forwardRef(function ({ action, ids, elementIds }
}
col.onCell = (record) => ({
record,
inputType: 'text',
element,
dataIndex: col.dataIndex,
colTitle: col.title,
editing: isEditing(record),
......@@ -240,7 +260,7 @@ export const EditAssets = React.forwardRef(function ({ action, ids, elementIds }
if (action === 'edit') {
col = {
...col,
...getColumnBatchEditProps(element.name, `element${index}`)
...getColumnBatchEditProps(element, `element${index}`)
}
}
......@@ -355,4 +375,64 @@ export const EditAssets = React.forwardRef(function ({ action, ids, elementIds }
</Form>
</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;
const supportMaxAttributeCountPerPage = 100;
const MENU_ID = 'model-attribute-menu';
const InputDebounce = DebounceInput(300)(Input);
export const InputDebounce = DebounceInput(300)(Input);
const ResizeableHeaderCell = 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