فهرست منبع

添加设置节假日开放

lanxin 3 روز پیش
والد
کامیت
4593ed4eb3

+ 5 - 1
src/pages/A3map/index.tsx

@@ -109,7 +109,11 @@ const A3map = () => {
               >
                 预览
               </Button>
-              <Button type='primary' onClick={() => publishFu(data.contextId)}>
+              <Button
+                type='primary'
+                disabled={data.status === 1}
+                onClick={() => publishFu(data.contextId)}
+              >
                 发布
               </Button>
             </div>

+ 83 - 0
src/pages/C1reserveOpt/C1OpenDay.tsx

@@ -0,0 +1,83 @@
+import React, { useCallback, useState } from 'react'
+import styles from './index.module.scss'
+import { Button, DatePicker, Modal, InputNumber } from 'antd'
+import MyPopconfirm from '@/components/MyPopconfirm'
+import dayjs from 'dayjs'
+import { MessageFu } from '@/utils/message'
+
+type Props = {
+  closeFu: () => void
+  editFu: (val: string[], num: number) => void
+  baseTime: string
+  num: number
+}
+
+function C1NoTime({ baseTime, closeFu, editFu, num }: Props) {
+  const baseTimeArr = baseTime
+    ? JSON.parse(baseTime).openDate.map((v: any) =>
+        v.replaceAll('年', '-').replaceAll('月', '-').replaceAll('日', '')
+      )
+    : []
+
+  const [value, setValue] = useState<string[]>(baseTimeArr)
+  const [personCount, setPersonCount] = useState(JSON.parse(baseTime).count)
+
+  const onChange = useCallback(
+    (date: any, dateString: string[] | string) => {
+      if (dateString.length) {
+        let arr = dateString as string[]
+        if (arr.length > num) {
+          arr = arr.filter((c, i) => i < num)
+          MessageFu.warning(`最多${num}个日期,已过滤超出日期`)
+        }
+        setValue(arr.map(v => v.replaceAll('年', '-').replaceAll('月', '-').replaceAll('日', '')))
+      } else setValue([])
+    },
+    [num]
+  )
+
+  return (
+    <Modal
+      wrapClassName={styles.C1Notime}
+      open={true}
+      title='节假日开放日期'
+      footer={
+        [] // 设置footer为空,去掉 取消 确定默认按钮
+      }
+    >
+      <DatePicker
+        multiple
+        onChange={onChange}
+        maxTagCount='responsive'
+        value={value ? value.map(v => dayjs(v)) : []}
+        size='large'
+        allowClear={false}
+        format='YYYY年MM月DD日'
+      />
+
+      <div className='allowCount'>
+        <div className='title'>节假日可预约人数</div>
+        <InputNumber
+          style={{ width: 120 }}
+          defaultValue={500}
+          value={personCount}
+          onChange={val => setPersonCount(val!)}
+          min={1}
+          max={11600}
+        />
+      </div>
+
+      <div className='C1Nbtn'>
+        <MyPopconfirm txtK='取消' onConfirm={closeFu} />
+        &emsp;
+        <Button type='primary' onClick={() => editFu(value, personCount)}>
+          提交
+        </Button>
+      </div>
+    </Modal>
+  )
+}
+
+const MemoC1NoTime = React.memo(C1NoTime)
+
+export default MemoC1NoTime

+ 16 - 0
src/pages/C1reserveOpt/index.module.scss

@@ -48,6 +48,22 @@
         display: none !important;
       }
     }
+    .allowCount {
+      width: 100%;
+      height: 100px;
+      display: flex;
+      flex-direction: column;
+      justify-content: center;
+      gap: 12px;
+      .title {
+        height: 35px;
+        color: rgba(0, 0, 0, 0.88);
+        font-weight: 600;
+        font-size: 16px;
+        line-height: 1.5;
+        border-bottom: 1px solid #ccc;
+      }
+    }
     .C1Nbtn {
       margin-top: 24px;
     }

+ 59 - 6
src/pages/C1reserveOpt/index.tsx

@@ -9,6 +9,7 @@ import { C1tableC } from '@/utils/tableData'
 import B1edit from './C1edit'
 import { MessageFu } from '@/utils/message'
 import C1NoTime from './C1NoTime'
+import C1OpenDay from './C1OpenDay'
 import C1xuZhi from './C1xuZhi'
 function C1reserveOpt() {
   const dispatch = useDispatch()
@@ -25,9 +26,12 @@ function C1reserveOpt() {
 
   // 编辑
   const [edit, setEdit] = useState(false)
+  const [isShowOpenDay, setIsShowOpenDay] = useState(false)
   const [isShowNo, setIsShowNo] = useState(false)
   // 1111111111111不可预约日期--------------开始
   const [noList, setNoList] = useState<string>('')
+  // 2222222222222开放日期--------------开始
+  const [openList, setOpenList] = useState<string>('')
 
   const getNoListFu = useCallback(async () => {
     const res = await C1_APIgetbk({ type: 'stopDate' })
@@ -36,11 +40,20 @@ function C1reserveOpt() {
     }
   }, [])
 
+  // 开放日期
+  const getOpenListFu = useCallback(async () => {
+    const res = await C1_APIgetbk({ type: 'openDate' })
+    if (res.code === 0) {
+      setOpenList(res.data?.rtf || '')
+    }
+  }, [])
+
   useEffect(() => {
     getNoListFu()
-  }, [getNoListFu])
+    getOpenListFu()
+  }, [getNoListFu, getOpenListFu])
 
-  // 点击提交或者取消
+  // NoTime点击提交或者取消
   const A2NoBtn = useCallback(
     async (val: string[]) => {
       let str = ''
@@ -68,17 +81,47 @@ function C1reserveOpt() {
     },
     [getNoListFu]
   )
-  // 1111111111111不可预约日期--------------结束
 
-  // 2222222222------------- 预约须知---------开始
-  // 17:场馆介绍 16:预约须知
+  // OpenDay点击提交或者取消
+  const A2OpenDayBtn = useCallback(
+    async (val: string[], num: number) => {
+      const str = JSON.stringify({
+        openDate: val,
+        count: num
+      })
+
+      console.log(str, 'openData')
+
+      let res
+      if (str === '') {
+        res = await C1_APIdelbk({
+          type: 'openDate'
+        })
+      } else {
+        res = await C1_APIsavebk({
+          rtf: str,
+          type: 'openDate'
+        })
+      }
+      if (res.code === 0) {
+        MessageFu.success('设置开放日期成功!')
+        getOpenListFu()
+        setIsShowOpenDay(false)
+      }
+    },
+    [getOpenListFu]
+  )
+
   const [configId, setConfigId] = useState(0)
-  // 2222222222------------- 预约须知---------结束
 
   return (
     <div className={styles.C1reserveOpt}>
       <div className='pageTitle'>展馆预约设置{edit ? ' - 编辑' : null}</div>
       <div className='C1top'>
+        <Button type='primary' onClick={() => setIsShowOpenDay(true)}>
+          设置节假日开放日期
+        </Button>
+        &emsp;
         <Button type='primary' onClick={() => setIsShowNo(true)}>
           设置不可预约日期
         </Button>
@@ -106,6 +149,16 @@ function C1reserveOpt() {
         />
       ) : null}
 
+      {/* 节假日开放日期设置 */}
+      {isShowOpenDay ? (
+        <C1OpenDay
+          num={999}
+          baseTime={openList}
+          editFu={(val, num) => A2OpenDayBtn(val, num)}
+          closeFu={() => setIsShowOpenDay(false)}
+        />
+      ) : null}
+
       {/*预约须知 */}
       {configId ? <C1xuZhi closeFu={() => setConfigId(0)} /> : null}
     </div>

+ 1 - 1
src/types/api/C1reserveOpt.d.ts

@@ -24,7 +24,7 @@ export type C1addType = {
 
 export type C1bkType = {
   rtf?: string | null
-  type: 'stopDate' | 'notice'
+  type: 'stopDate' | 'notice' | 'openDate'
 }
 
 export type C1eTableDataKeyType =

+ 1 - 1
src/utils/http.ts

@@ -16,7 +16,7 @@ console.log(baseUrlTemp)
 // const baseFlag = baseUrlTemp.includes('https://')
 
 // 请求基地址
-// export const baseURL = envFlag ? baseUrlTemp : baseUrlTemp2
+// export const baseURL = envFlag ? baseUrlTemp : baseUrlTemp
 export const baseURL = baseUrlTemp2
 
 // 处理  类型"AxiosResponse<any, any>"上不存在属性"code"