|
@ -1,7 +1,9 @@ |
|
|
import { Button, Form, Input, Modal, Select } from 'antd'; |
|
|
import { Button, Form, Input, Modal, Select } from 'antd'; |
|
|
|
|
|
import { DeleteOutlined } from '@ant-design/icons'; |
|
|
import React, { useState, useEffect } from 'react'; |
|
|
import React, { useState, useEffect } from 'react'; |
|
|
import { connect } from 'react-redux'; |
|
|
import { connect } from 'react-redux'; |
|
|
import { getCheckItemsGroup } from '../actions/checkItems'; |
|
|
import { getCheckItemsGroup, delCheckItemsGroup } from '../actions/checkItems'; |
|
|
|
|
|
const { Option } = Select; |
|
|
|
|
|
|
|
|
const CheckItemsModal = ({ visible, onOk, onCancel, curRecord, dispatch }) => { |
|
|
const CheckItemsModal = ({ visible, onOk, onCancel, curRecord, dispatch }) => { |
|
|
const [group, setGroup] = useState([]); |
|
|
const [group, setGroup] = useState([]); |
|
@ -9,13 +11,26 @@ const CheckItemsModal = ({ visible, onOk, onCancel, curRecord, dispatch }) => { |
|
|
const [form] = Form.useForm(); |
|
|
const [form] = Form.useForm(); |
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
useEffect(() => { |
|
|
|
|
|
getGroup(); |
|
|
|
|
|
}, []) |
|
|
|
|
|
|
|
|
|
|
|
function getGroup() { |
|
|
dispatch(getCheckItemsGroup()).then(res => { |
|
|
dispatch(getCheckItemsGroup()).then(res => { |
|
|
if (res.success) { |
|
|
if (res.success) { |
|
|
const opt = res.payload.data?.map(g => ({ value: g.id, label: g.name })); |
|
|
const opt = res.payload.data?.map(g => ({ value: g.id, label: g.name })); |
|
|
setGroup(opt); |
|
|
setGroup(opt); |
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
|
}, []) |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function delGroup(id) { |
|
|
|
|
|
dispatch(delCheckItemsGroup(id)).then(res => { |
|
|
|
|
|
if (res.success) { |
|
|
|
|
|
form.setFieldValue('group', null) |
|
|
|
|
|
getGroup(); |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
return ( |
|
|
return ( |
|
|
<Modal |
|
|
<Modal |
|
@ -71,7 +86,18 @@ const CheckItemsModal = ({ visible, onOk, onCancel, curRecord, dispatch }) => { |
|
|
{ |
|
|
{ |
|
|
isNewGroup |
|
|
isNewGroup |
|
|
? <Input /> |
|
|
? <Input /> |
|
|
: <Select options={group} loading={!group?.length} /> |
|
|
: <Select loading={!group?.length} optionLabelProp="label"> |
|
|
|
|
|
{ |
|
|
|
|
|
group?.map((g) => { |
|
|
|
|
|
return <Option key={g.value} value={g.value} label={g.label}> |
|
|
|
|
|
<div style={{ display: 'flex', justifyContent: 'space-between' }}> |
|
|
|
|
|
{g.label} |
|
|
|
|
|
<DeleteOutlined onClick={() => { delGroup(g.value) }} /> |
|
|
|
|
|
</div> |
|
|
|
|
|
</Option> |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
|
|
|
</Select> |
|
|
} |
|
|
} |
|
|
</Form.Item> |
|
|
</Form.Item> |
|
|
</Form> |
|
|
</Form> |
|
|