|  |  | @ -1,7 +1,9 @@ | 
			
		
	
		
			
				
					|  |  |  | import { Button, Form, Input, Modal, Select } from 'antd'; | 
			
		
	
		
			
				
					|  |  |  | import { DeleteOutlined } from '@ant-design/icons'; | 
			
		
	
		
			
				
					|  |  |  | import React, { useState, useEffect } from 'react'; | 
			
		
	
		
			
				
					|  |  |  | 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 [group, setGroup] = useState([]); | 
			
		
	
	
		
			
				
					|  |  | @ -9,13 +11,26 @@ const CheckItemsModal = ({ visible, onOk, onCancel, curRecord, dispatch }) => { | 
			
		
	
		
			
				
					|  |  |  |   const [form] = Form.useForm(); | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |   useEffect(() => { | 
			
		
	
		
			
				
					|  |  |  |     getGroup(); | 
			
		
	
		
			
				
					|  |  |  |   }, []) | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |   function getGroup() { | 
			
		
	
		
			
				
					|  |  |  |     dispatch(getCheckItemsGroup()).then(res => { | 
			
		
	
		
			
				
					|  |  |  |       if (res.success) { | 
			
		
	
		
			
				
					|  |  |  |         const opt = res.payload.data?.map(g => ({ value: g.id, label: g.name })); | 
			
		
	
		
			
				
					|  |  |  |         setGroup(opt); | 
			
		
	
		
			
				
					|  |  |  |       } | 
			
		
	
		
			
				
					|  |  |  |     }); | 
			
		
	
		
			
				
					|  |  |  |   }, []) | 
			
		
	
		
			
				
					|  |  |  |   } | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |   function delGroup(id) { | 
			
		
	
		
			
				
					|  |  |  |     dispatch(delCheckItemsGroup(id)).then(res => { | 
			
		
	
		
			
				
					|  |  |  |       if (res.success) { | 
			
		
	
		
			
				
					|  |  |  |         form.setFieldValue('group', null) | 
			
		
	
		
			
				
					|  |  |  |         getGroup(); | 
			
		
	
		
			
				
					|  |  |  |       } | 
			
		
	
		
			
				
					|  |  |  |     }); | 
			
		
	
		
			
				
					|  |  |  |   } | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |   return ( | 
			
		
	
		
			
				
					|  |  |  |     <Modal | 
			
		
	
	
		
			
				
					|  |  | @ -71,7 +86,18 @@ const CheckItemsModal = ({ visible, onOk, onCancel, curRecord, dispatch }) => { | 
			
		
	
		
			
				
					|  |  |  |           { | 
			
		
	
		
			
				
					|  |  |  |             isNewGroup | 
			
		
	
		
			
				
					|  |  |  |               ? <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> | 
			
		
	
	
		
			
				
					|  |  | 
 |