shaogen1995 8 mesiacov pred
rodič
commit
129e995614

BIN
展示端/src/assets/img/exhibit/del.png


+ 13 - 0
展示端/src/components/ZexhiBtn/index.module.scss

@@ -24,5 +24,18 @@
       background-color: var(--themeColor2);
       color: #fff;
     }
+
+    .FormBtn {
+      width: 65%;
+      height: 54px;
+      background-color: var(--themeColor2) !important;
+
+      font-size: 18px;
+      display: flex;
+      justify-content: center;
+      align-items: center;
+      color: #fff;
+      font-weight: 700;
+    }
   }
 }

+ 6 - 3
展示端/src/components/ZexhiBtn/index.tsx

@@ -9,12 +9,13 @@ type Props = {
   nextOk?: boolean
   onlyBack?: boolean
   backFu?: () => void
+  FormBtn?: React.ReactNode
 }
 
-function ZexhiBtn({ nextFu, nextOk = true, onlyBack = false, backFu }: Props) {
+function ZexhiBtn({ nextFu, nextOk = true, onlyBack = false, backFu, FormBtn }: Props) {
   const routerLength = useSelector((state: RootState) => state.A0Layout.routerLength)
   return (
-    <div className={styles.ZexhiBtn}>
+    <div id='ZexhiBtn' className={styles.ZexhiBtn}>
       <div
         onClick={() => {
           if (backFu) backFu()
@@ -25,7 +26,9 @@ function ZexhiBtn({ nextFu, nextOk = true, onlyBack = false, backFu }: Props) {
       >
         返回
       </div>
-      {onlyBack ? null : (
+      {onlyBack ? null : FormBtn ? (
+        FormBtn
+      ) : (
         <div className={`ZexhiBtn1 ZexhiBtn2 ${nextOk ? '' : 'myBtnNo'}`} onClick={nextFu}>
           下一步
         </div>

+ 84 - 1
展示端/src/pages/B4form/index.module.scss

@@ -5,6 +5,8 @@
   :global {
     .B4main {
       height: calc(100% - 100px);
+      overflow-y: auto;
+      overflow-x: hidden;
       padding: 26px 24px;
       .B4top {
         height: 130px;
@@ -19,6 +21,7 @@
         padding: 0 0 4px 13%;
         font-size: 16px;
         color: #828282;
+        margin-bottom: 5px;
         & > p {
           padding-right: 20px;
           margin-bottom: 6px;
@@ -41,7 +44,87 @@
         display: flex;
         justify-content: center;
         align-items: center;
-        margin-bottom: 15px;
+        margin-bottom: 20px;
+      }
+
+      .B4KaBox {
+        #ZexhiBtn {
+          position: absolute;
+          bottom: 0;
+          left: 0;
+          width: 100%;
+        }
+
+        .B4Ka {
+          margin-bottom: 20px;
+          background-color: #fff;
+          border-radius: 5px;
+          box-shadow: 0px 4px 10px 0px rgba(0, 0, 0, 0.25);
+          padding: 18px 0 20px;
+          .B4tit {
+            display: flex;
+            justify-content: space-between;
+            font-size: 18px;
+            .B4titTxt {
+              padding-left: 25px;
+              font-weight: 700;
+              color: var(--themeColor);
+              position: relative;
+              margin-bottom: 20px;
+              &::before {
+                content: '';
+                position: absolute;
+                width: 6px;
+                height: 100%;
+                top: 0;
+                left: 0;
+                background-color: var(--themeColor);
+              }
+            }
+            .B4titDel {
+              padding-right: 24px;
+              color: #f45151;
+              img {
+                position: relative;
+                top: -3px;
+              }
+            }
+          }
+
+          .ant-form-item {
+            padding: 0 13px;
+            margin-bottom: 12px;
+            height: 40px;
+            .ant-row {
+              display: flex;
+              .ant-form-item-label {
+                width: 110px;
+                flex: none;
+                display: block;
+              }
+              .ant-form-item-control {
+                flex: none;
+                display: block;
+                width: calc(100% - 110px);
+              }
+
+              .ant-input {
+                border: none !important;
+                box-shadow: none !important;
+                border-bottom: 1px solid #bebebe !important;
+                border-radius: 0;
+              }
+            }
+
+            .ant-input-number {
+              width: 100%;
+              border: none !important;
+              box-shadow: none !important;
+              border-bottom: 1px solid #bebebe !important;
+              border-radius: 0;
+            }
+          }
+        }
       }
     }
   }

+ 157 - 9
展示端/src/pages/B4form/index.tsx

@@ -1,22 +1,33 @@
-import React, { useEffect, useState } from 'react'
+import React, { useCallback, useEffect, useRef, useState } from 'react'
 import styles from './index.module.scss'
 import { useParams } from 'react-router-dom'
 // 待完善 上个页面的数组接口
 import { listTemp } from '../B3start'
 import ZexhiBtn from '@/components/ZexhiBtn'
+import { Button, Form, FormInstance, Input } from 'antd'
+import ZinfoPop from '@/components/ZinfoPop'
+import history from '@/utils/history'
+import classNames from 'classnames'
+import { MessageFu } from '@/utils/message'
+import delImg from '@/assets/img/exhibit/del.png'
+import MyPopconfirm from '@/components/MyPopconfirm'
 
 function B4form() {
-  // 获取路由参数 bookId待完善(存疑)
+  useEffect(() => {
+    FormBoxRef.current?.setFieldsValue({
+      name1: '王大锤',
+      phone1: '18702025091',
+      identity1: '421083199504071212'
+    })
+  }, [])
+
+  // 获取路由参数
   const [urlObj, setUrlObj] = useState({
     bookDate: '',
     bookId: 0,
     time: ''
   })
 
-  useEffect(() => {
-    console.log('获取参数', urlObj)
-  }, [urlObj])
-
   const urlObjTemp: any = useParams()
 
   useEffect(() => {
@@ -29,6 +40,54 @@ function B4form() {
     })
   }, [urlObjTemp])
 
+  // 表单的ref
+  const FormBoxRef = useRef<FormInstance>(null)
+
+  const [formArr, setFormArr] = useState([{ id: 1 }])
+  const formArrNumRef = useRef(1)
+
+  // 点击新增 参观人
+  const addFormFu = useCallback(() => {
+    if (formArr.length >= 3) return MessageFu.warning('最多3位!')
+    setFormArr([...formArr, { id: formArrNumRef.current + 1 }])
+    formArrNumRef.current += 1
+  }, [formArr])
+
+  // 点击删除 参观人
+  const delFormFu = useCallback(
+    (id: number) => {
+      setFormArr(formArr.filter(v => v.id !== id))
+    },
+    [formArr]
+  )
+
+  // 没有通过校验
+  const onFinishFailed = useCallback(() => {}, [])
+
+  // 打开提示弹窗
+  const [titPop, setTitPop] = useState('')
+
+  //  通过校验点击确定
+  const onFinish = useCallback(
+    async (values: any) => {
+      const arr: any = []
+
+      formArr.forEach(v => {
+        arr.push({
+          bookDate: urlObj.bookDate,
+          bookId: urlObj.bookId,
+          time: urlObj.time,
+          name: values[`name${v.id}`],
+          phone: values[`phone${v.id}`],
+          identity: values[`identity${v.id}`]
+        })
+      })
+
+      setTitPop('succ')
+    },
+    [formArr, urlObj]
+  )
+
   return (
     <div className={styles.B4form}>
       <div className='B4main'>
@@ -44,12 +103,101 @@ function B4form() {
         </div>
 
         {/* 按钮 */}
-        <div className='B4addBtn'>新增参观人(最多3位)</div>
+        <div
+          className={classNames('B4addBtn', formArr.length >= 3 ? 'myBtnNo' : '')}
+          onClick={addFormFu}
+        >
+          新增参观人(最多3位)
+        </div>
+
+        <div className='B4KaBox'>
+          <Form
+            ref={FormBoxRef}
+            name='basic'
+            // labelCol={{ span: 3 }}
+            onFinish={onFinish}
+            onFinishFailed={onFinishFailed}
+            autoComplete='off'
+            scrollToFirstError
+          >
+            {/* 卡片 */}
+            {formArr.map((item, index) => (
+              <div className='B4Ka' key={item.id}>
+                <div className='B4tit'>
+                  <div className='B4titTxt'>参观人信息{index + 1}</div>
 
-        <div>1234564</div>
+                  {formArr.length <= 1 ? (
+                    <div></div>
+                  ) : (
+                    <MyPopconfirm
+                      txtK='删除'
+                      onConfirm={() => delFormFu(item.id)}
+                      Dom={
+                        <div className='B4titDel'>
+                          <img src={delImg} alt='' /> 删除
+                        </div>
+                      }
+                    />
+                  )}
+                </div>
+
+                <Form.Item
+                  label='姓名'
+                  name={`name${item.id}`}
+                  rules={[{ required: true, message: '请输入负责人姓名!' }]}
+                  getValueFromEvent={e => e.target.value.replace(/\s+/g, '')}
+                >
+                  <Input placeholder='请输入内容,不超过6个字' maxLength={6} />
+                </Form.Item>
+
+                <Form.Item
+                  label='联系方式'
+                  name={`phone${item.id}`}
+                  rules={[
+                    { required: true, message: '请输入联系方式!' },
+                    {
+                      pattern: /^1[3-9][0-9]{9}$/,
+                      message: '请输入正确格式的手机号!'
+                    }
+                  ]}
+                >
+                  <Input placeholder='请输入11位数字' maxLength={11} />
+                </Form.Item>
+
+                <Form.Item
+                  label='身份证号'
+                  name={`identity${item.id}`}
+                  rules={[
+                    { required: true, message: '请输入身份证号!' },
+                    {
+                      pattern:
+                        /^[1-9]\d{5}(19|20)\d{2}((0[1-9])|(1[0-2]))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/,
+                      message: '请输入正确格式的身份证号!'
+                    }
+                  ]}
+                >
+                  <Input placeholder='请输入18位证件编码' maxLength={18} />
+                </Form.Item>
+              </div>
+            ))}
+
+            {/* 底部按钮 */}
+            <ZexhiBtn
+              nextFu={() => {}}
+              FormBtn={
+                <Button className='FormBtn' type='primary' htmlType='submit'>
+                  提交
+                </Button>
+              }
+            />
+          </Form>
+        </div>
       </div>
 
-      <ZexhiBtn nextFu={() => {}} />
+      {/* 预约成功的弹窗 */}
+      {titPop ? (
+        <ZinfoPop txt2='' type={titPop as 'succ'} callFu={() => history.push('/exhiMy')} />
+      ) : null}
     </div>
   )
 }

+ 4 - 1
展示端/src/pages/Z1login/index.tsx

@@ -48,7 +48,10 @@ function Z1login() {
     if (code) {
       // 发请求,拿token
       // 用户信息存到本地
-      setTokenInfo({ token: 'xxxxxxxxxxxx' })
+      setTokenInfo({
+        token:
+          'eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJvakpPdDZBc1MyTUhKSUFLMWtqSV9FTllyRnIwIiwibG9naW5UeXBlIjoid3giLCJpZCI6MSwidXNlck5hbWUiOiJvakpPdDZBc1MyTUhKSUFLMWtqSV9FTllyRnIwIiwiZXhwIjoxNzM0MzI2NTAwLCJyb2xlS2V5cyI6WyJ3ZWJfdXNlciJdLCJpYXQiOjE3MzQyNDAxMDAsImp0aSI6IjYwMTQ3MWI2LThiZDMtNGIyOC05OGQ0LTVkOGE3MjM3MjA2NiJ9.q94qvpZ0IjtW2CVyKgvgzE6jjRTizIClP1_FpxaUtfU'
+      })
       // 跳到首页
       MessageFu.success('登录成功!')
       toHomeFu()