|
|
@@ -0,0 +1,98 @@
|
|
|
+import React, { useCallback, useEffect, useRef } from 'react'
|
|
|
+import styles from './index.module.scss'
|
|
|
+import { Button, Form, FormInstance, Input, Modal, Select } from 'antd'
|
|
|
+import MyPopconfirm from '@/components/MyPopconfirm'
|
|
|
+import { I3editSelectDate, I3editSelectlength, TypeI3list } from './data'
|
|
|
+import { MessageFu } from '@/utils/message'
|
|
|
+import { I3_APIsave } from '@/store/action/Isystem/I3numSet'
|
|
|
+
|
|
|
+type Props = {
|
|
|
+ editObj: TypeI3list
|
|
|
+ editFu: () => void
|
|
|
+ closeFu: () => void
|
|
|
+}
|
|
|
+
|
|
|
+function I3edit({ editObj, editFu, closeFu }: Props) {
|
|
|
+ useEffect(() => {
|
|
|
+ FormBoxRef.current?.setFieldsValue(editObj)
|
|
|
+ }, [editObj])
|
|
|
+
|
|
|
+ // 设置表单ref
|
|
|
+ const FormBoxRef = useRef<FormInstance>(null)
|
|
|
+
|
|
|
+ // 没有通过校验
|
|
|
+ const onFinishFailed = useCallback(() => {
|
|
|
+ // return MessageFu.warning("有表单不符号规则!");
|
|
|
+ }, [])
|
|
|
+
|
|
|
+ // 通过校验点击确定
|
|
|
+ const onFinish = useCallback(
|
|
|
+ async (values: any) => {
|
|
|
+ const obj = { ...values, id: editObj.id }
|
|
|
+ const res = await I3_APIsave(obj)
|
|
|
+ if (res.code === 0) {
|
|
|
+ MessageFu.success('编辑成功')
|
|
|
+ editFu()
|
|
|
+ closeFu()
|
|
|
+ }
|
|
|
+ },
|
|
|
+ [closeFu, editFu, editObj.id]
|
|
|
+ )
|
|
|
+
|
|
|
+ return (
|
|
|
+ <Modal
|
|
|
+ wrapClassName={styles.I3edit}
|
|
|
+ open={true}
|
|
|
+ title='编辑'
|
|
|
+ footer={
|
|
|
+ [] // 设置footer为空,去掉 取消 确定默认按钮
|
|
|
+ }
|
|
|
+ >
|
|
|
+ <div className='I3aMain'>
|
|
|
+ <Form
|
|
|
+ scrollToFirstError={true}
|
|
|
+ ref={FormBoxRef}
|
|
|
+ name='basic'
|
|
|
+ labelCol={{ span: 3 }}
|
|
|
+ onFinish={onFinish}
|
|
|
+ onFinishFailed={onFinishFailed}
|
|
|
+ autoComplete='off'
|
|
|
+ >
|
|
|
+ <Form.Item label='编号类型' name='name'>
|
|
|
+ <Input maxLength={30} disabled />
|
|
|
+ </Form.Item>
|
|
|
+
|
|
|
+ <Form.Item
|
|
|
+ label='前缀'
|
|
|
+ name='prefix'
|
|
|
+ rules={[{ pattern: /^[A-Z0-9]*$/, message: '请输入大写英文字母或数字' }]}
|
|
|
+ >
|
|
|
+ <Input maxLength={6} showCount placeholder='请输入大写英文字母或数字' />
|
|
|
+ </Form.Item>
|
|
|
+
|
|
|
+ <Form.Item label='日期方式' name='dateType'>
|
|
|
+ <Select options={I3editSelectDate} />
|
|
|
+ </Form.Item>
|
|
|
+
|
|
|
+ <Form.Item label='流水号位数' name='length' rules={[{ required: true, message: '' }]}>
|
|
|
+ <Select options={I3editSelectlength} />
|
|
|
+ </Form.Item>
|
|
|
+
|
|
|
+ {/* 确定和取消按钮 */}
|
|
|
+ <br />
|
|
|
+ <Form.Item wrapperCol={{ offset: 9, span: 16 }}>
|
|
|
+ <Button type='primary' htmlType='submit'>
|
|
|
+ 提交
|
|
|
+ </Button>
|
|
|
+  
|
|
|
+ <MyPopconfirm txtK='取消' onConfirm={closeFu} />
|
|
|
+ </Form.Item>
|
|
|
+ </Form>
|
|
|
+ </div>
|
|
|
+ </Modal>
|
|
|
+ )
|
|
|
+}
|
|
|
+
|
|
|
+const MemoI3edit = React.memo(I3edit)
|
|
|
+
|
|
|
+export default MemoI3edit
|