|
@@ -0,0 +1,326 @@
|
|
|
|
|
+import React, { useCallback, useMemo, useState } from 'react'
|
|
|
|
|
+import styles from './index.module.scss'
|
|
|
|
|
+import {
|
|
|
|
|
+ Button,
|
|
|
|
|
+ Cascader,
|
|
|
|
|
+ DatePicker,
|
|
|
|
|
+ Form,
|
|
|
|
|
+ Input,
|
|
|
|
|
+ InputNumber,
|
|
|
|
|
+ Modal,
|
|
|
|
|
+ Select,
|
|
|
|
|
+ TimePicker
|
|
|
|
|
+} from 'antd'
|
|
|
|
|
+import dayjs from 'dayjs'
|
|
|
|
|
+import { B2baseRenData, B2renListType, B2statusSelArr, B2typeSelArr } from './data'
|
|
|
|
|
+import { cityArr, papersSelArr } from '@/pages/A6record/A6add/data'
|
|
|
|
|
+import MyPopconfirm from '@/components/MyPopconfirm'
|
|
|
|
|
+import TextArea from 'antd/es/input/TextArea'
|
|
|
|
|
+import MyTable from '@/components/MyTable'
|
|
|
|
|
+import { MessageFu } from '@/utils/message'
|
|
|
|
|
+import { B2_APIadd } from '@/store/action/B2exhiLog'
|
|
|
|
|
+
|
|
|
|
|
+type Props = {
|
|
|
|
|
+ closeFu: () => void
|
|
|
|
|
+ upTableFu: () => void
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+function B2add({ closeFu, upTableFu }: Props) {
|
|
|
|
|
+ // 没有通过校验
|
|
|
|
|
+ const onFinishFailed = useCallback(() => {}, [])
|
|
|
|
|
+
|
|
|
|
|
+ // 个人和团队预约
|
|
|
|
|
+ const [type, setType] = useState('person')
|
|
|
|
|
+
|
|
|
|
|
+ // 参观人/负责人信息
|
|
|
|
|
+ const [renList, setRenList] = useState<B2renListType[]>([{ ...B2baseRenData }])
|
|
|
|
|
+
|
|
|
|
|
+ // 通过校验点击确定
|
|
|
|
|
+ const onFinish = useCallback(
|
|
|
|
|
+ async (values: any) => {
|
|
|
|
|
+ let renArr = [] as B2renListType[]
|
|
|
|
|
+ if (type === 'person') renArr = [...renList]
|
|
|
|
|
+ else renArr = [renList[0]]
|
|
|
|
|
+
|
|
|
|
|
+ const obj: any = {
|
|
|
|
|
+ teamDesc: values.teamDesc,
|
|
|
|
|
+ teamPcs: values.teamPcs,
|
|
|
|
|
+ type
|
|
|
|
|
+ }
|
|
|
|
|
+ obj.info = []
|
|
|
|
|
+ let infoTemp: any = {
|
|
|
|
|
+ createTime: dayjs(values.createTime).format('YYYY-MM-DD HH:mm:ss'),
|
|
|
|
|
+ updateTime: dayjs(values.updateTime).format('YYYY-MM-DD HH:mm:ss'),
|
|
|
|
|
+ bookDate: dayjs(values.bookDate).format('YYYY-MM-DD'),
|
|
|
|
|
+ time: `${dayjs(values.time[0]).format('HH:mm')}-${dayjs(values.time[1]).format(
|
|
|
|
|
+ 'HH:mm'
|
|
|
|
|
+ )}`,
|
|
|
|
|
+ status: values.status
|
|
|
|
|
+ }
|
|
|
|
|
+ if (values.myCity && values.myCity.length > 1) {
|
|
|
|
|
+ infoTemp.province = values.myCity[0]
|
|
|
|
|
+ infoTemp.city = values.myCity[1]
|
|
|
|
|
+ }
|
|
|
|
|
+ renArr.forEach(v => {
|
|
|
|
|
+ infoTemp = {
|
|
|
|
|
+ ...infoTemp,
|
|
|
|
|
+ name: v.name,
|
|
|
|
|
+ phone: v.phone,
|
|
|
|
|
+ papers: v.papers,
|
|
|
|
|
+ identity: v.identity
|
|
|
|
|
+ }
|
|
|
|
|
+ obj.info.push(infoTemp)
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
|
|
+ const res = await B2_APIadd(obj)
|
|
|
|
|
+ if (res.code === 0) {
|
|
|
|
|
+ MessageFu.success('新增成功')
|
|
|
|
|
+ upTableFu()
|
|
|
|
|
+ closeFu()
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ [closeFu, renList, type, upTableFu]
|
|
|
|
|
+ )
|
|
|
|
|
+
|
|
|
|
|
+ const txtChange = useCallback(
|
|
|
|
|
+ (id: number, value: string, key: 'name' | 'phone' | 'papers' | 'identity') => {
|
|
|
|
|
+ setRenList(
|
|
|
|
|
+ renList.map(v => ({
|
|
|
|
|
+ ...v,
|
|
|
|
|
+ [key]: id === v.id ? value : v[key]
|
|
|
|
|
+ }))
|
|
|
|
|
+ )
|
|
|
|
|
+ },
|
|
|
|
|
+ [renList]
|
|
|
|
|
+ )
|
|
|
|
|
+
|
|
|
|
|
+ const txtCss = useCallback(
|
|
|
|
|
+ (flag: boolean) => {
|
|
|
|
|
+ const flagRes = flag || type === 'person'
|
|
|
|
|
+ const css: any = {
|
|
|
|
|
+ opacity: flagRes ? '1' : '0.5',
|
|
|
|
|
+ pointerEvents: flagRes ? 'auto' : 'none'
|
|
|
|
|
+ }
|
|
|
|
|
+ return css
|
|
|
|
|
+ },
|
|
|
|
|
+ [type]
|
|
|
|
|
+ )
|
|
|
|
|
+
|
|
|
|
|
+ const tableLastBtn = useMemo(() => {
|
|
|
|
|
+ return [
|
|
|
|
|
+ {
|
|
|
|
|
+ title: `${type === 'team' ? '负责人' : '参观人'}姓名`,
|
|
|
|
|
+ render: (item: B2renListType, _: any, index: number) => (
|
|
|
|
|
+ <Input
|
|
|
|
|
+ style={txtCss(index === 0)}
|
|
|
|
|
+ placeholder='请输入'
|
|
|
|
|
+ maxLength={20}
|
|
|
|
|
+ showCount
|
|
|
|
|
+ value={item.name}
|
|
|
|
|
+ onChange={e => txtChange(item.id, e.target.value.trim(), 'name')}
|
|
|
|
|
+ />
|
|
|
|
|
+ )
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ title: `${type === 'team' ? '负责人' : '参观人'}电话`,
|
|
|
|
|
+ render: (item: B2renListType, _: any, index: number) => (
|
|
|
|
|
+ <Input
|
|
|
|
|
+ style={txtCss(index === 0)}
|
|
|
|
|
+ placeholder='请输入'
|
|
|
|
|
+ maxLength={20}
|
|
|
|
|
+ showCount
|
|
|
|
|
+ value={item.phone}
|
|
|
|
|
+ onChange={e => txtChange(item.id, e.target.value.trim(), 'phone')}
|
|
|
|
|
+ />
|
|
|
|
|
+ )
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ title: '证件类型',
|
|
|
|
|
+ render: (item: B2renListType, _: any, index: number) => (
|
|
|
|
|
+ <Select
|
|
|
|
|
+ style={{ ...txtCss(index === 0), width: '100%' }}
|
|
|
|
|
+ placeholder='请选择'
|
|
|
|
|
+ options={papersSelArr}
|
|
|
|
|
+ value={item.papers || null}
|
|
|
|
|
+ onChange={e => txtChange(item.id, e, 'papers')}
|
|
|
|
|
+ />
|
|
|
|
|
+ )
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ title: '证件号码',
|
|
|
|
|
+ render: (item: B2renListType, _: any, index: number) => (
|
|
|
|
|
+ <Input
|
|
|
|
|
+ style={txtCss(index === 0)}
|
|
|
|
|
+ placeholder='请输入'
|
|
|
|
|
+ maxLength={20}
|
|
|
|
|
+ showCount
|
|
|
|
|
+ value={item.identity}
|
|
|
|
|
+ onChange={e => txtChange(item.id, e.target.value.trim(), 'identity')}
|
|
|
|
|
+ />
|
|
|
|
|
+ )
|
|
|
|
|
+ },
|
|
|
|
|
+
|
|
|
|
|
+ {
|
|
|
|
|
+ title: '操作',
|
|
|
|
|
+ render: (item: B2renListType, _: any, index: number) =>
|
|
|
|
|
+ index === 0 || type === 'team' ? (
|
|
|
|
|
+ ' - '
|
|
|
|
|
+ ) : (
|
|
|
|
|
+ <MyPopconfirm
|
|
|
|
|
+ txtK='删除'
|
|
|
|
|
+ onConfirm={() => setRenList(renList.filter(v => v.id !== item.id))}
|
|
|
|
|
+ />
|
|
|
|
|
+ )
|
|
|
|
|
+ }
|
|
|
|
|
+ ]
|
|
|
|
|
+ }, [renList, txtChange, txtCss, type])
|
|
|
|
|
+
|
|
|
|
|
+ return (
|
|
|
|
|
+ <Modal
|
|
|
|
|
+ wrapClassName={styles.B2add}
|
|
|
|
|
+ open={true}
|
|
|
|
|
+ title='新增展馆预约记录'
|
|
|
|
|
+ footer={
|
|
|
|
|
+ [] // 设置footer为空,去掉 取消 确定默认按钮
|
|
|
|
|
+ }
|
|
|
|
|
+ >
|
|
|
|
|
+ <Form
|
|
|
|
|
+ name='basic'
|
|
|
|
|
+ onFinish={onFinish}
|
|
|
|
|
+ onFinishFailed={onFinishFailed}
|
|
|
|
|
+ autoComplete='off'
|
|
|
|
|
+ scrollToFirstError
|
|
|
|
|
+ initialValues={{
|
|
|
|
|
+ myCity: ['广东省', '横琴粤澳深度合作区'],
|
|
|
|
|
+ type: 'person',
|
|
|
|
|
+ status: 1
|
|
|
|
|
+ }}
|
|
|
|
|
+ >
|
|
|
|
|
+ <div className='FormBox'>
|
|
|
|
|
+ <Form.Item
|
|
|
|
|
+ label='申请时间'
|
|
|
|
|
+ name='createTime'
|
|
|
|
|
+ rules={[{ required: true, message: '请选择' }]}
|
|
|
|
|
+ >
|
|
|
|
|
+ <DatePicker showTime format='YYYY-MM-DD HH:mm:ss' />
|
|
|
|
|
+ </Form.Item>
|
|
|
|
|
+
|
|
|
|
|
+ <Form.Item
|
|
|
|
|
+ label='预约类型'
|
|
|
|
|
+ name='type'
|
|
|
|
|
+ rules={[{ required: true, message: '请选择' }]}
|
|
|
|
|
+ >
|
|
|
|
|
+ <Select
|
|
|
|
|
+ placeholder='请选择'
|
|
|
|
|
+ value={type}
|
|
|
|
|
+ onChange={e => setType(e)}
|
|
|
|
|
+ options={B2typeSelArr}
|
|
|
|
|
+ />
|
|
|
|
|
+ </Form.Item>
|
|
|
|
|
+
|
|
|
|
|
+ <Form.Item label='来自地区' name='myCity'>
|
|
|
|
|
+ <Cascader options={cityArr} placeholder='请选择' />
|
|
|
|
|
+ </Form.Item>
|
|
|
|
|
+
|
|
|
|
|
+ <Form.Item
|
|
|
|
|
+ label='预约日期'
|
|
|
|
|
+ name='bookDate'
|
|
|
|
|
+ rules={[{ required: true, message: '请选择' }]}
|
|
|
|
|
+ >
|
|
|
|
|
+ <DatePicker placeholder='请选择' />
|
|
|
|
|
+ </Form.Item>
|
|
|
|
|
+
|
|
|
|
|
+ <Form.Item
|
|
|
|
|
+ label='预约时段'
|
|
|
|
|
+ name='time'
|
|
|
|
|
+ rules={[{ required: true, message: '请选择' }]}
|
|
|
|
|
+ >
|
|
|
|
|
+ <TimePicker.RangePicker format='HH:mm' />
|
|
|
|
|
+ </Form.Item>
|
|
|
|
|
+
|
|
|
|
|
+ <Form.Item
|
|
|
|
|
+ label='核销状态'
|
|
|
|
|
+ name='status'
|
|
|
|
|
+ rules={[{ required: true, message: '请选择' }]}
|
|
|
|
|
+ >
|
|
|
|
|
+ <Select placeholder='请选择' options={B2statusSelArr} />
|
|
|
|
|
+ </Form.Item>
|
|
|
|
|
+
|
|
|
|
|
+ <Form.Item
|
|
|
|
|
+ label='核销时间'
|
|
|
|
|
+ name='updateTime'
|
|
|
|
|
+ rules={[{ required: true, message: '请选择' }]}
|
|
|
|
|
+ >
|
|
|
|
|
+ <DatePicker showTime format='YYYY-MM-DD HH:mm:ss' />
|
|
|
|
|
+ </Form.Item>
|
|
|
|
|
+ {type === 'team' ? (
|
|
|
|
|
+ <>
|
|
|
|
|
+ <Form.Item
|
|
|
|
|
+ label='参团人数'
|
|
|
|
|
+ name='teamPcs'
|
|
|
|
|
+ rules={[{ required: true, message: '请输入参团人数!' }]}
|
|
|
|
|
+ >
|
|
|
|
|
+ <InputNumber min={1} max={999} precision={0} placeholder='请输入数字' />
|
|
|
|
|
+ </Form.Item>
|
|
|
|
|
+
|
|
|
|
|
+ <Form.Item label='团队描述' name='teamDesc' className='antdRowAll'>
|
|
|
|
|
+ <TextArea
|
|
|
|
|
+ autoSize
|
|
|
|
|
+ maxLength={200}
|
|
|
|
|
+ placeholder='请输入内容,不超过200个字'
|
|
|
|
|
+ />
|
|
|
|
|
+ </Form.Item>
|
|
|
|
|
+ </>
|
|
|
|
|
+ ) : null}
|
|
|
|
|
+
|
|
|
|
|
+ <div className='B2Form'>
|
|
|
|
|
+ <div className='B2Formll'>
|
|
|
|
|
+ <span>* </span>
|
|
|
|
|
+ {type === 'team' ? '负责人' : '参观人'}信息:
|
|
|
|
|
+ </div>
|
|
|
|
|
+ <div className='B2Formrr'>
|
|
|
|
|
+ <Button
|
|
|
|
|
+ disabled={type === 'team'}
|
|
|
|
|
+ type='primary'
|
|
|
|
|
+ onClick={() => {
|
|
|
|
|
+ if (renList.length >= 10) return MessageFu.warning('最多添加10条信息')
|
|
|
|
|
+ setRenList([...renList, { ...B2baseRenData, id: Date.now() }])
|
|
|
|
|
+ }}
|
|
|
|
|
+ >
|
|
|
|
|
+ 新增
|
|
|
|
|
+ </Button>
|
|
|
|
|
+  
|
|
|
|
|
+ <span className='B2FormErr'>
|
|
|
|
|
+ 预约类型为团队预约的时候,只取第一条数据为负责人信息
|
|
|
|
|
+ </span>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </div>
|
|
|
|
|
+
|
|
|
|
|
+ <div className='B2Form'>
|
|
|
|
|
+ <div className='B2Formll'></div>
|
|
|
|
|
+ <div className='B2Formrr'>
|
|
|
|
|
+ <MyTable
|
|
|
|
|
+ list={renList}
|
|
|
|
|
+ pagingInfo={false}
|
|
|
|
|
+ columnsTemp={[]}
|
|
|
|
|
+ lastBtn={tableLastBtn}
|
|
|
|
|
+ />
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ {/* 确定和取消按钮 */}
|
|
|
|
|
+ <Form.Item className='FormBtn'>
|
|
|
|
|
+ <Button type='primary' htmlType='submit'>
|
|
|
|
|
+ 提交
|
|
|
|
|
+ </Button>
|
|
|
|
|
+  
|
|
|
|
|
+ <MyPopconfirm txtK='取消' onConfirm={closeFu} />
|
|
|
|
|
+ </Form.Item>
|
|
|
|
|
+ </Form>
|
|
|
|
|
+ </Modal>
|
|
|
|
|
+ )
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+const MemoB2add = React.memo(B2add)
|
|
|
|
|
+
|
|
|
|
|
+export default MemoB2add
|