Explorar el Código

越封装越复杂

shaogen1995 hace 3 semanas
padre
commit
f3e8074b33

+ 6 - 0
src/components/Z3upFilesRef/index.module.scss

@@ -3,6 +3,12 @@
     a {
       color: black;
     }
+    .Z3Btn {
+      & > span {
+        font-size: 14px;
+        color: #999;
+      }
+    }
     .Z3files {
       .ZTbox1ImgRow {
         display: inline-block;

+ 15 - 8
src/components/Z3upFilesRef/index.tsx

@@ -369,8 +369,12 @@ function Z3upFilesRef(
       thumbPc: ''
     }
     if (oneIsCover && fileList.length) {
-      obj.thumb = fileList[0].thumb
-      obj.thumbPc = fileList[0].filePath
+      const findObj = fileList.find(v => v.type === 'img')
+
+      if (findObj) {
+        obj.thumb = findObj.thumb
+        obj.thumbPc = findObj.filePath
+      }
     }
     return obj
   }, [fileList, oneIsCover])
@@ -393,12 +397,15 @@ function Z3upFilesRef(
       />
       <div className='Z3Btn'>
         {!isLook && (
-          <Button
-            onClick={() => myInput.current?.click()}
-            icon={<UploadOutlined rev={undefined} />}
-          >
-            上传文件
-          </Button>
+          <>
+            <Button
+              onClick={() => myInput.current?.click()}
+              icon={<UploadOutlined rev={undefined} />}
+            >
+              上传文件
+            </Button>
+            &emsp;{oneIsCover ? <span>第一张图片将用作封面</span> : ''}
+          </>
         )}
 
         <div className='Z3files'>

+ 195 - 0
src/components/ZRichTextOne/index.module.scss

@@ -0,0 +1,195 @@
+.ZRichTextOne {
+  width: 1000px;
+
+  :global {
+    // 正文
+    .formRightZW {
+      width: 700px;
+      top: -3px;
+      position: relative;
+      display: flex;
+      align-items: center;
+      justify-content: space-between;
+      height: 32px;
+
+      .formRightZWRR {
+        display: flex;
+      }
+    }
+
+    // 从查看进来
+    .formRightZWLook {
+      .ant-checkbox-wrapper {
+        pointer-events: none;
+      }
+    }
+
+    .txtBox {
+      width: 100%;
+      position: relative;
+
+      a {
+        color: #fff !important;
+      }
+
+      // 隐藏媒体功能
+      .control-item.media {
+        display: none;
+      }
+
+      button {
+        &:nth-of-type(7) {
+          display: none !important;
+        }
+        &:nth-of-type(8) {
+          display: none !important;
+        }
+        &:nth-of-type(18) {
+          display: none !important;
+        }
+        &:nth-of-type(19) {
+          display: none !important;
+        }
+      }
+
+      .bf-container {
+        height: 100%;
+      }
+
+      .bf-content {
+        height: 400px;
+        padding-bottom: 0px;
+      }
+
+      .bf-controlbar {
+        position: relative;
+
+        .upImgBox {
+          position: absolute;
+          bottom: 13px;
+          right: 15px;
+          cursor: pointer;
+          color: var(--themeColor);
+          // display: none;
+        }
+
+        .upImgBoxNo {
+          display: none;
+        }
+      }
+
+      .zztxtRow {
+        margin-bottom: 20px;
+        border: 1px solid #ccc;
+
+        .zztxtRow1 {
+          padding: 0 20px;
+          height: 40px;
+          display: flex;
+          align-items: center;
+          justify-content: space-between;
+          background-color: #e8e8e8;
+
+          .zztxtRow1_1 {
+            display: flex;
+            align-items: center;
+
+            .zztxtRow1_1_1 {
+              font-weight: 700;
+              font-size: 16px;
+              margin-right: 20px;
+            }
+
+            .zztxtRow1_1_2 {
+              display: flex;
+              align-items: center;
+              width: 580px;
+              height: 32px;
+            }
+          }
+        }
+
+        .zztxtRow1_2 {
+          display: flex;
+          align-items: center;
+
+          .anticon {
+            cursor: pointer;
+            font-size: 18px;
+          }
+
+          .zztxtRow1_2Icon {
+            position: relative;
+            top: 2px;
+          }
+
+          .zztxtRow1_2IconNo {
+            pointer-events: none;
+            opacity: 0.2;
+          }
+        }
+      }
+
+      .zztxtRowErr {
+        border-color: #ff4d4f;
+      }
+    }
+
+    // 从查看进来
+    .txtBoxLook {
+      .button-remove {
+        display: none !important;
+      }
+      .bf-controlbar {
+        pointer-events: auto !important;
+        display: flex;
+        justify-content: flex-end;
+        button {
+          display: none;
+          &:last-child {
+            display: inline-block;
+          }
+        }
+        div {
+          display: none;
+        }
+        .separator-line {
+          display: none;
+        }
+      }
+    }
+
+    .noUpThumb {
+      position: relative;
+      overflow: hidden;
+      opacity: 0;
+      transition: top 0.2s;
+      color: #ff4d4f;
+      top: -20px;
+    }
+
+    .noUpThumbAc {
+      top: -10px;
+      opacity: 1;
+    }
+
+    .bf-media .bf-image {
+      float: initial !important;
+      display: block;
+      margin: 0px auto;
+      text-align: center;
+
+      // 不让拖动放大缩小图片(会报错)
+      .bf-csize-icon {
+        display: none !important;
+      }
+
+      img {
+        max-width: 500px;
+        max-height: 300px;
+      }
+    }
+
+    // .bf-video-wrap
+  }
+}

+ 161 - 0
src/components/ZRichTextOne/index.tsx

@@ -0,0 +1,161 @@
+import React, { useCallback, useMemo, useRef, useState } from 'react'
+import styles from './index.module.scss'
+
+// 引入编辑器组件
+
+// 安装---npm install braft-editor --save --force
+// npm install braft-utils --save --force
+import { ContentUtils } from 'braft-utils'
+import BraftEditor from 'braft-editor'
+// 引入编辑器样式
+import 'braft-editor/dist/index.css'
+
+import classNames from 'classnames'
+import { MessageFu } from '@/utils/message'
+import { fileDomInitialFu } from '@/utils/domShow'
+import { baseURL } from '@/utils/http'
+import { forwardRef, useImperativeHandle } from 'react'
+import { API_upFile } from '@/store/action/layout'
+import { Button } from 'antd'
+
+type Props = {
+  check: boolean //表单校验,为fasle表示不校验
+  isLook: boolean //是否是查看进来
+  ref: any //当前自己的ref,给父组件调用
+  myUrl: string //上传的api地址
+  titTxt?: string
+}
+
+function ZRichTextOne({ check, isLook, myUrl, titTxt = '请输入内容' }: Props, ref: any) {
+  const [section, setSection] = useState(BraftEditor.createEditorState(''))
+
+  // 判断 富文本是否为空
+  const isTxtFlag = useMemo(() => {
+    let flag = false
+
+    // 不是按章节发布,检查第一个富文本
+    const txt = section.toText()
+    const txtHtml = section.toHTML()
+    const txtRes = txt.replaceAll('\n', '').replaceAll(' ', '')
+    if (!txtRes && !txtHtml.includes('class="media-wrap')) flag = true
+
+    return flag
+  }, [section])
+
+  const myInput = useRef<HTMLInputElement>(null)
+
+  // 上传图片、视频
+  const handeUpPhoto = useCallback(
+    async (e: React.ChangeEvent<HTMLInputElement>) => {
+      if (e.target.files) {
+        // 拿到files信息
+        const filesInfo = e.target.files[0]
+
+        let type = ['image/jpeg', 'image/png', 'video/mp4']
+        let size = 5
+        let txt = '图片只支持png、jpg和jpeg格式!'
+        let txt2 = '图片最大支持5M!'
+
+        // 校验格式
+        if (!type.includes(filesInfo.type)) {
+          e.target.value = ''
+          return MessageFu.warning(txt)
+        }
+
+        // 校验大小
+        if (filesInfo.size > size * 1024 * 1024) {
+          e.target.value = ''
+          return MessageFu.warning(txt2)
+        }
+
+        // 创建FormData对象
+        const fd = new FormData()
+        // 把files添加进FormData对象(‘photo’为后端需要的字段)
+        fd.append('type', 'img')
+        fd.append('file', filesInfo)
+
+        e.target.value = ''
+
+        try {
+          const res = await API_upFile(fd, myUrl)
+          if (res.code === 0) {
+            MessageFu.success('上传成功')
+            // 在光标位置插入图片
+            const newTxt = ContentUtils.insertMedias(section, [
+              {
+                type: 'IMAGE',
+                url: baseURL + (res.data.compressedUrl || res.data.originalUrl)
+              }
+            ])
+
+            setSection(newTxt)
+          }
+          fileDomInitialFu()
+        } catch (error) {
+          fileDomInitialFu()
+        }
+      }
+    },
+    [myUrl, section]
+  )
+
+  // 让父组件调用的 回显 富文本
+  const ritxtShowFu = useCallback((val: any) => {
+    if (val) setSection(BraftEditor.createEditorState(val))
+  }, [])
+
+  // 让父组件调用的返回 富文本信息 和 表单校验 isTxtFlag为ture表示未通过校验
+  const fatherBtnOkFu = useCallback(() => {
+    return { val: section.toHTML(), flag: isTxtFlag }
+  }, [isTxtFlag, section])
+
+  // 可以让父组件调用子组件的方法
+  useImperativeHandle(ref, () => ({
+    ritxtShowFu,
+    fatherBtnOkFu
+  }))
+
+  return (
+    <div className={styles.ZRichTextOne} id='ZRichTextOne'>
+      <input
+        id='upInput'
+        type='file'
+        accept='.png,.jpg,.jpeg,.mp4'
+        ref={myInput}
+        onChange={e => handeUpPhoto(e)}
+      />
+
+      <div className={classNames('formRightZW', isLook ? 'formRightZWLook' : '')}>
+        <div className='formRightZWRR'>
+          <div hidden={isLook}>
+            <Button
+              onClick={() => {
+                myInput.current?.click()
+              }}
+            >
+              上传图片
+            </Button>
+          </div>
+        </div>
+      </div>
+
+      <div className={classNames('txtBox', isLook ? 'txtBoxLook' : '')}>
+        <div className={classNames('zztxtRow')}>
+          {/* 主体 */}
+          <BraftEditor
+            readOnly={isLook}
+            placeholder={isLook ? '(空)' : '请输入内容'}
+            value={section}
+            onChange={e => setSection(e)}
+            imageControls={['remove']}
+          />
+        </div>
+      </div>
+      <div className={classNames('noUpThumb', check && isTxtFlag ? 'noUpThumbAc' : '')}>
+        {titTxt}
+      </div>
+    </div>
+  )
+}
+
+export default forwardRef(ZRichTextOne)

+ 2 - 0
src/pages/Dmanage/D1register/D1edit/index.tsx

@@ -5,6 +5,7 @@ import EditBtn from '@/pages/Zother/EditBtn'
 import { D1API_obj } from '@/store/action/Dmanage/D1register'
 import { InfoProvider } from '@/pages/Zother/InfoContext'
 import { rowArrTemp } from '@/pages/Zother/data'
+import SonGoodsList from '@/pages/Zother/SonGoodsList'
 
 const rowArr = rowArrTemp('登记')
 
@@ -17,6 +18,7 @@ function D1edit() {
           <EditTop pageTxt='藏品登记' rowArr={rowArr} APIobj={D1API_obj} />
 
           {/* 藏品清单 */}
+          <SonGoodsList />
 
           {/* 底部按钮 */}
           <EditBtn path='/register' APIobj={D1API_obj} />

+ 13 - 0
src/pages/Zother/AddGoods/index.module.scss

@@ -88,6 +88,7 @@
         .AGfull {
           width: 100%;
           display: flex;
+          margin-bottom: 24px;
           .AGfullll {
             width: 110px;
             position: relative;
@@ -99,6 +100,18 @@
             width: calc(100% - 110px);
           }
         }
+        .AGbtnok {
+          width: auto;
+          position: absolute;
+          top: 50%;
+          transform: translateY(-50%);
+          right: 165px;
+          .ant-btn {
+            width: 74px;
+            margin: 24px 0;
+            display: block;
+          }
+        }
       }
     }
   }

+ 126 - 5
src/pages/Zother/AddGoods/index.tsx

@@ -1,7 +1,7 @@
 import React, { useCallback, useEffect, useRef } from 'react'
 import styles from './index.module.scss'
 import { GoodsType } from '../SonGoodsList/data'
-import { Cascader, DatePicker, Form, FormInstance, Input, InputNumber, Select } from 'antd'
+import { Button, Cascader, DatePicker, Form, FormInstance, Input, InputNumber, Select } from 'antd'
 import { useDispatch, useSelector } from 'react-redux'
 import { RootState } from '@/store'
 import { E1_APIgetTree } from '@/store/action/Eculture/E1tag'
@@ -10,12 +10,36 @@ import { getTokenInfo } from '@/utils/storage'
 import { getDictFu, selectObj } from '@/utils/dataChange'
 import TextArea from 'antd/es/input/TextArea'
 import Z3upFilesRef from '@/components/Z3upFilesRef'
+import GuShi from '../GuShi'
+import MyPopconfirm from '@/components/MyPopconfirm'
+import { API_getGoodsInfo } from '@/store/action/Cledger/C1ledger'
+
+// 级联的数据转换成字符串
+export const cascaderChArr = [
+  'tagDictId',
+  'typeDictId',
+  'ageDictId',
+  'pcsUnitDictId',
+  'textureDictId',
+  'qualityLevelDictId'
+]
+
+// 下拉框为空的时候转变成null
+export const addZiSelectChArr = [
+  'level',
+  'tornLevel',
+  'keep',
+  'qualityScope',
+  'qualityUnitDictId',
+  'inGoodYearScope',
+  'source'
+]
 
 type Props = {
   info: GoodsType
   closeFu: () => void
-  isEdit: boolean //藏品编辑模块
-  editSnap?: GoodsType //藏品模块属于新增还是编辑
+  isEdit: boolean //藏品编辑-模块
+  editSnap?: GoodsType //藏品编辑-属于新增还是编辑
   succFu: (val: GoodsType, newFlag?: boolean) => void
   moduleId: number
 }
@@ -33,11 +57,93 @@ function AddGoods({ closeFu, succFu, isEdit, editSnap, moduleId, info }: Props)
   // 设置表单ref
   const FormBoxRef = useRef<FormInstance>(null)
 
+  // 故事模块的ref
+  const guShiRef = useRef<any>(null)
+
+  // 附件模块的ref
+  const fileRef = useRef<any>(null)
+
+  // 藏品编辑模块用来对比
+  const objOld = useRef({} as GoodsType)
+
+  // 编辑进来获取详情
+  const getInfo = useCallback(
+    async (id: number) => {
+      const res = await API_getGoodsInfo(id)
+      if (res.code === 0) {
+        // 藏品编辑信息保存
+        objOld.current = { ...res.data }
+
+        const obj = editSnap && editSnap.id ? { ...editSnap } : { ...res.data }
+        // makeDate inGoodYear 2个日期需要格式处理一下
+        if (obj.makeDate) obj.makeDate = dayjs(obj.makeDate)
+        if (obj.inGoodYear) obj.inGoodYear = dayjs(obj.inGoodYear)
+
+        cascaderChArr.forEach(v => {
+          if (obj[v] === '0') obj[v] = null
+          else if (obj[v]) obj[v] = obj[v].split(',')
+        })
+
+        addZiSelectChArr.forEach(v => {
+          if (!obj[v]) obj[v] = null
+        })
+
+        FormBoxRef.current?.setFieldsValue(obj)
+
+        // 设置附件
+        // fileRef.current?.sonSetListFu(fileList)
+
+        // 待完善sg-设置故事
+        // guShiRef.current?.setGuShiListBySon(list)
+      }
+    },
+    [editSnap]
+  )
+
+  useEffect(() => {
+    if (info.id > 0) getInfo(info.id)
+  }, [getInfo, info.id])
+
   // 没有通过校验
   const onFinishFailed = useCallback(() => {}, [])
 
   // 通过校验点击确定
-  const onFinish = useCallback(async (values: any) => {}, [])
+  const onFinish = useCallback(
+    async (values: any) => {
+      // 获取附件
+      const { list: flieList, thumb, thumbPc } = fileRef.current?.sonResListFu()
+      // 待完善sg-设置故事
+      // const guShiList= guShiRef.current?.getGuShiListBySon()
+      // 2个日期的格式处理
+      let makeDate = ''
+      if (values.makeDate) makeDate = dayjs(values.makeDate).format('YYYY-MM-DD')
+      let inGoodYear = ''
+      if (values.inGoodYear) inGoodYear = dayjs(values.inGoodYear).format('YYYY-MM-DD')
+
+      const obj = {
+        ...values,
+        id: info.id > 0 ? info.id : null,
+        makeDate,
+        inGoodYear,
+        fileIds: flieList.join(','),
+        thumb,
+        thumbPc
+      }
+      for (const k in obj) {
+        if (obj[k] === null || obj[k] === undefined) obj[k] = ''
+      }
+
+      // 级联的数据转换成字符串
+      cascaderChArr.forEach(v => {
+        if (values[v]) obj[v] = values[v].join(',')
+      })
+      if (1 + 1 === 2) {
+        console.log(123, obj)
+        return
+      }
+    },
+    [info.id]
+  )
 
   return (
     <div className={styles.AddGoods}>
@@ -284,6 +390,7 @@ function AddGoods({ closeFu, succFu, isEdit, editSnap, moduleId, info }: Props)
               <div className='AGfullll'>附件:</div>
               <div className='AGfullrr'>
                 <Z3upFilesRef
+                  ref={fileRef}
                   oneIsCover={true}
                   moduleId={moduleId}
                   dirCode='registerGoods'
@@ -291,8 +398,22 @@ function AddGoods({ closeFu, succFu, isEdit, editSnap, moduleId, info }: Props)
                 />
               </div>
             </div>
+            {/* 横线 */}
+            <div className='AGxian'></div>
+            <div className='AGfull'>
+              <div className='AGfullll'>故事:</div>
+              <div className='AGfullrr'>
+                <GuShi moduleId={moduleId} ref={guShiRef} />
+              </div>
+            </div>
 
-            {/* 故事模块待完善sg */}
+            {/* 确定和取消按钮 */}
+            <Form.Item className='AGbtnok'>
+              <Button type='primary' htmlType='submit'>
+                提交
+              </Button>
+              <MyPopconfirm txtK='取消' onConfirm={closeFu} />
+            </Form.Item>
           </div>
         </Form>
       </div>

+ 50 - 21
src/pages/Zother/EditBtn/index.tsx

@@ -2,20 +2,22 @@ import React, { useCallback, useEffect, useState } from 'react'
 import styles from './index.module.scss'
 import { Button } from 'antd'
 import MyPopconfirm from '@/components/MyPopconfirm'
-import { backPageFu } from '@/utils/history'
+import history, { backPageFu } from '@/utils/history'
 import { useParams } from 'react-router-dom'
-import { editBtnShowFu, pageSkitFu } from '@/utils/authority'
+import { editBtnShowFu, editPageToTopFu, pageSkitFu } from '@/utils/authority'
 import { useInfo } from '../InfoContext'
 import { MessageFu } from '@/utils/message'
 import { fileIdsResFu } from '@/utils'
+import { API_objType } from '@/store/action/Dmanage/D1register'
 
 type Props = {
   path: string
-  APIobj: any
+  APIobj: API_objType
+  checkListTxt?: string
 }
 
-function EditBtn({ path, APIobj }: Props) {
-  const { info, snaps, delSnapIdsRef } = useInfo()
+function EditBtn({ path, APIobj, checkListTxt = '藏品' }: Props) {
+  const { info, snaps, delSnapIdsRef, setTimeKeyFu } = useInfo()
 
   const [btnCan, setBtnCan] = useState({ status: 0, creatorId: 0 })
 
@@ -35,26 +37,13 @@ function EditBtn({ path, APIobj }: Props) {
     }
   }, [btnCan])
 
-  // 触发检查
-  const checkFu = useCallback(() => {
-    let flag = false
-    if (snaps.length === 0) {
-      flag = true
-      return MessageFu.warning('请添加藏品')
-    }
-    return flag
-  }, [snaps.length])
-
   // 点击按钮触发事件
   const sonClick = useCallback(
-    (val: string, flag?: string) => {
+    async (val: string, flag?: string) => {
       // console.log('点击按钮', val, flag)
-      // 新增、编辑、审批、查看跳转
+      // 新增、编辑、审批、查看互相跳转
       if (flag) pageSkitFu(path, val, id, flag)
       else {
-        // 草稿、发起、审批、撤回、删除
-        // 各种操作按钮逻辑待完善sg
-
         const obj = {
           ...info,
           fileIds: fileIdsResFu(info.files),
@@ -68,9 +57,49 @@ function EditBtn({ path, APIobj }: Props) {
           }))
         }
         console.log('xxxxxxxxx', obj)
+
+        // 草稿、发起、审批、撤回、删除
+
+        if (val === '草稿') {
+          const res = await APIobj['草稿'](obj)
+          if (res.code === 0) {
+            pageSkitFu(path, '4', id, '详情', '保存草稿成功')
+          }
+        } else if (val === '撤回') {
+          const res = await APIobj['撤回'](obj.id)
+          if (res.code === 0) {
+            MessageFu.success('撤回成功')
+            // 重新调用获取详情接口-当前页刷新状态
+            setTimeKeyFu()
+          }
+        } else if (val === '删除') {
+          const res = await APIobj['删除'](obj.id)
+          if (res.code === 0) {
+            MessageFu.success('删除成功')
+            // 回到列表页面
+            history.replace(path)
+          }
+        } else if (val === '发起') {
+          if (!info.num) {
+            editPageToTopFu()
+            return MessageFu.warning('请输入申请编号')
+          }
+          if (snaps.length === 0) {
+            editPageToTopFu()
+            return MessageFu.warning(`请至少添加一个${checkListTxt}`)
+          }
+          const res = await APIobj['发起'](obj)
+          if (res.code === 0) {
+            MessageFu.success('操作成功')
+            // 重新调用获取详情接口-当前页刷新状态
+            setTimeKeyFu()
+          }
+        } else if (val === '审批') {
+          // 待完善sg
+        }
       }
     },
-    [delSnapIdsRef, id, info, path, snaps]
+    [APIobj, checkListTxt, delSnapIdsRef, id, info, path, setTimeKeyFu, snaps]
   )
 
   return (

+ 8 - 7
src/pages/Zother/EditTop/index.tsx

@@ -8,7 +8,8 @@ import classNames from 'classnames'
 import TextArea from 'antd/es/input/TextArea'
 import { useInfo } from '../InfoContext'
 import Z3upFiles from '@/components/Z3upFiles'
-import SonGoodsList from '../SonGoodsList'
+import { API_objType } from '@/store/action/Dmanage/D1register'
+import { editPageToTopFu } from '@/utils/authority'
 
 const pageKeyTxtObj = {
   1: '新增',
@@ -23,11 +24,11 @@ type Props = {
   // 页面字段
   pageTxt: string
   // api
-  APIobj: any
+  APIobj: API_objType
 }
 
 function EditTop({ rowArr, pageTxt, APIobj }: Props) {
-  const { info, setInfoFu, setSnapsFu, snapsID2ref } = useInfo()
+  const { info, setInfoFu, setSnapsFu, snapsID2ref, timeKey } = useInfo()
 
   const { key, id } = useParams<any>()
   // key:1 新增 2编辑 3审批 4查看
@@ -45,6 +46,9 @@ function EditTop({ rowArr, pageTxt, APIobj }: Props) {
     async (id: number) => {
       const res = await APIobj['获取详情'](id)
       if (res.code === 0) {
+        // 回到顶部
+        editPageToTopFu()
+
         const data = res.data
         setInfoFu(data)
 
@@ -73,7 +77,7 @@ function EditTop({ rowArr, pageTxt, APIobj }: Props) {
   useEffect(() => {
     if (key === '1') createFu()
     else getInfoFu(id)
-  }, [createFu, getInfoFu, id, key])
+  }, [createFu, getInfoFu, id, key, timeKey])
 
   // 页面最上部文字
   const pageKeyTxt = useMemo(() => {
@@ -200,9 +204,6 @@ function EditTop({ rowArr, pageTxt, APIobj }: Props) {
               </div>
             </div>
           </div>
-
-          {/* 藏品清单 */}
-          <SonGoodsList />
         </>
       ) : null}
     </div>

+ 4 - 0
src/pages/Zother/GuShi/GuShiMo/index.module.scss

@@ -0,0 +1,4 @@
+.GuShiMo {
+  :global {
+  }
+}

+ 45 - 0
src/pages/Zother/GuShi/GuShiMo/index.tsx

@@ -0,0 +1,45 @@
+import React, { useRef } from 'react'
+import styles from './index.module.scss'
+import { Modal } from 'antd'
+import { GuShiType } from '../data'
+
+type Props = {
+  guShiInfo: GuShiType
+  closeFu: () => void
+  succFu: (val: '新增' | '编辑') => void
+}
+// 待完善sg
+function GuShiMo({ guShiInfo, closeFu, succFu }: Props) {
+  // 富文本的ref
+  const ZRichTextRef = useRef<any>(null)
+
+  // 设置富文本
+  // ZRichTextRef.current?.ritxtShowFu(description)
+
+  // 获取富文本
+  //  const rtf = ZRichTextRef.current?.fatherBtnOkFu() || { flag: true }
+  // rtf.val
+
+  return (
+    <Modal
+      wrapClassName={styles.GuShiMo}
+      destroyOnClose
+      open={true}
+      title={guShiInfo.id > 0 ? '编辑' : '新增'}
+      footer={
+        [] // 设置footer为空,去掉 取消 确定默认按钮
+      }
+    >
+      {/* <ZRichTextOne
+          check={false}
+          myUrl='file/upload?upPath=A1intro'
+          isLook={false}
+          ref={ZRichTextRef}
+        /> */}
+    </Modal>
+  )
+}
+
+const MemoGuShiMo = React.memo(GuShiMo)
+
+export default MemoGuShiMo

+ 7 - 0
src/pages/Zother/GuShi/data.ts

@@ -0,0 +1,7 @@
+export type GuShiType = {
+  id: number
+  fileIds?: string
+  name: string
+  remark: string
+  rtf: string
+}

+ 10 - 0
src/pages/Zother/GuShi/index.module.scss

@@ -0,0 +1,10 @@
+.GuShi {
+  :global {
+    .ant-table-wrapper {
+      margin-top: 15px;
+      .ant-table-cell {
+        padding: 8px !important;
+      }
+    }
+  }
+}

+ 70 - 0
src/pages/Zother/GuShi/index.tsx

@@ -0,0 +1,70 @@
+import styles from './index.module.scss'
+import { Button } from 'antd'
+import { forwardRef, useCallback, useImperativeHandle, useMemo, useState } from 'react'
+import { GuShiType } from './data'
+import MyTable from '@/components/MyTable'
+import MyPopconfirm from '@/components/MyPopconfirm'
+
+type Props = {
+  moduleId: number
+  ref: any
+}
+
+function GuShi({ moduleId }: Props, ref: any) {
+  // 故事数据
+  const [guShiList, setGuShiList] = useState<GuShiType[]>([])
+
+  // 点击删除-待完善sg
+  const delTableFu = useCallback(
+    (id: number) => {
+      setGuShiList(guShiList.filter(v => v.id !== id))
+    },
+    [guShiList]
+  )
+
+  const tableLastBtn = useMemo(() => {
+    return [
+      {
+        title: '操作',
+        render: (item: GuShiType) => {
+          return (
+            <>
+              <Button size='small' type='text'>
+                编辑
+              </Button>
+              <MyPopconfirm txtK='删除' onConfirm={() => delTableFu(item.id)} />
+            </>
+          )
+        }
+      }
+    ]
+  }, [delTableFu])
+
+  // 给父组件调用
+  const setGuShiListBySon = useCallback((list: GuShiType[]) => {
+    setGuShiList(list || [])
+  }, [])
+
+  const getGuShiListBySon = useCallback(() => {
+    return guShiList
+  }, [guShiList])
+  useImperativeHandle(ref, () => ({
+    setGuShiListBySon,
+    getGuShiListBySon
+  }))
+
+  return (
+    <div className={styles.GuShi}>
+      <Button>新增</Button>
+      <MyTable
+        classKey='GuShiTable'
+        list={guShiList}
+        columnsTemp={[['txt', '故事标题', 'name']]}
+        lastBtn={tableLastBtn}
+        pagingInfo={false}
+      />
+    </div>
+  )
+}
+
+export default forwardRef(GuShi)

+ 20 - 2
src/pages/Zother/InfoContext.tsx

@@ -11,6 +11,8 @@ type InfoContextValue = {
   setSnapsFu: (snaps: GoodsType[]) => void
   delSnapIdsRef: React.MutableRefObject<number[]>
   snapsID2ref: React.MutableRefObject<SnapsID2refType[]>
+  timeKey: number
+  setTimeKeyFu: () => void
 }
 
 type Props = {
@@ -20,6 +22,13 @@ type Props = {
 const InfoContext = createContext<InfoContextValue | undefined>(undefined)
 
 export function InfoProvider({ children }: Props) {
+  // 用来刷新页面
+  const [timeKey, setTimeKey] = useState(0)
+
+  const setTimeKeyFu = useCallback(() => {
+    setTimeKey(Date.now())
+  }, [])
+
   // 顶部信息
   const [info, setInfo] = useState({} as Typetable)
 
@@ -45,8 +54,17 @@ export function InfoProvider({ children }: Props) {
   const snapsID2ref = useRef<SnapsID2refType[]>([])
 
   const value = useMemo(
-    () => ({ info, setInfoFu, snaps, setSnapsFu, delSnapIdsRef, snapsID2ref }),
-    [info, setInfoFu, setSnapsFu, snaps]
+    () => ({
+      info,
+      setInfoFu,
+      snaps,
+      setSnapsFu,
+      delSnapIdsRef,
+      snapsID2ref,
+      timeKey,
+      setTimeKeyFu
+    }),
+    [info, setInfoFu, setSnapsFu, setTimeKeyFu, snaps, timeKey]
   )
 
   return <InfoContext.Provider value={value}>{children}</InfoContext.Provider>

+ 14 - 1
src/pages/Zother/SonGoodsList/index.module.scss

@@ -2,8 +2,21 @@
   width: 100%;
   border-top: 1px solid #ccc;
   :global {
-    .SonGoodsListTable {
+    .EdTit {
       padding: 15px;
+      font-weight: 700;
+      font-size: 18px;
+      display: flex;
+      justify-content: space-between;
+      .ant-btn {
+        margin-left: 15px;
+      }
+      .EdTitBtn {
+        pointer-events: none;
+      }
+    }
+    .SonGoodsListTable {
+      padding: 0 15px 15px;
       .ant-table-cell {
         padding: 8px !important;
       }

+ 1 - 1
src/pages/Zother/SonGoodsList/index.tsx

@@ -1,4 +1,4 @@
-import React, { useEffect, useMemo, useRef, useState } from 'react'
+import React, { useMemo, useState } from 'react'
 import styles from './index.module.scss'
 import { Button } from 'antd'
 import MyTable from '@/components/MyTable'

+ 8 - 0
src/store/action/Cledger/C1ledger.ts

@@ -0,0 +1,8 @@
+import http from '@/utils/http'
+
+/**
+ * 藏品总账-获取藏品详情
+ */
+export const API_getGoodsInfo = (id: number) => {
+  return http.get(`cms/good/ledger/detail/${id}`)
+}

+ 8 - 0
src/store/action/Dmanage/D1register.ts

@@ -19,8 +19,16 @@ export const D1_APIgetList = (data: any): any => {
   }
 }
 
+export type APItxtType = '创建订单' | '获取详情' | '草稿' | '发起' | '审批' | '撤回' | '删除'
+
+export type API_objType = { [x in APItxtType]: any }
+
 export const D1API_obj = {
   创建订单: () => APIbase('get', 'cms/order/register/create'),
   获取详情: (id: number) => APIbase('get', `cms/order/register/detail/${id}`),
+  草稿: (data: any) => APIbase('post', `cms/order/register/saveDraft`, data),
+  发起: (data: any) => APIbase('post', `cms/order/register/saveApply`, data),
+  审批: (data: any) => APIbase('post', `cms/order/register/audit`, data),
+  撤回: (id: number) => APIbase('get', `cms/order/register/revocation/${id}`),
   删除: (id: number) => APIbase('get', `cms/order/register/remove/${id}`)
 }

+ 2 - 2
src/utils/authority.ts

@@ -60,8 +60,8 @@ export const editPageToTopFu = () => {
 }
 
 // 详情页跳转
-export const pageSkitFu = (path: string, key: string, id: number, txt?: string) => {
+export const pageSkitFu = (path: string, key: string, id: number, txt?: string, txt2?: string) => {
   history.replace(`${path}_edit/${key}/${id}`)
   editPageToTopFu()
-  if (txt) MessageFu.success(`已调转至${txt}页面`)
+  if (txt) MessageFu.success(`${txt2 || ''}已调转至${txt}页面`)
 }