lanxin hace 2 semanas
padre
commit
dfd7af2d00

+ 33 - 22
src/components/ZRichTextOne/index.tsx

@@ -22,11 +22,18 @@ type Props = {
   check: boolean //表单校验,为fasle表示不校验
   isLook: boolean //是否是查看进来
   ref: any //当前自己的ref,给父组件调用
-  myUrl: string //上传的api地址
+  myUrl?: string //上传的api地址
   titTxt?: string
+  showUpload?: boolean //是否显示上传图片
 }
 
-function ZRichTextOne({ check, isLook, myUrl, titTxt = '请输入内容' }: Props, ref: any) {
+function ZRichTextOne({
+  check,
+  isLook,
+  myUrl = '',
+  titTxt = '请输入内容',
+  showUpload = true
+}: Props, ref: any) {
   const [section, setSection] = useState(BraftEditor.createEditorState(''))
 
   // 判断 富文本是否为空
@@ -117,27 +124,31 @@ function ZRichTextOne({ check, isLook, myUrl, titTxt = '请输入内容' }: Prop
 
   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>
+      {showUpload ? (
+        <>
+          <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>
-      </div>
+        </>
+      ) : null}
 
       <div className={classNames('txtBox', isLook ? 'txtBoxLook' : '')}>
         <div className={classNames('zztxtRow')}>

+ 9 - 5
src/pages/A6person/A6add/index.module.scss

@@ -15,7 +15,7 @@
       .ant-form {
         width: 1000px;
         .ant-form-item-label {
-          width: 120px;
+          width: 150px;
         }
 
         .nameRow {
@@ -32,7 +32,8 @@
           display: flex;
           margin-bottom: 24px;
           .formBoxll {
-            width: 120px;
+            width: 150px;
+            flex-shrink: 0;
             text-align: right;
             line-height: 26px;
             & > span {
@@ -40,21 +41,24 @@
             }
           }
           .formBoxrr {
-            width: calc(100% - 120px);
+            width: calc(100% - 150px);
+            #ZRichTextOne {
+              width: 100%;
+            }
           }
         }
         .sortForm {
           position: relative;
           .fromRowTit {
             position: absolute;
-            left: 225px;
+            left: 255px;
             top: 6px;
             color: #999;
             font-size: 12px;
           }
         }
         .BtnForm {
-          padding-left: 120px;
+          padding-left: 150px;
           margin-top: 40px;
           .ant-btn {
             margin-right: 30px;

+ 78 - 19
src/pages/A6person/A6add/index.tsx

@@ -7,7 +7,7 @@ import { MessageFu } from '@/utils/message'
 import ZupOne from '@/components/ZupOne'
 import ZupImgs from '@/components/ZupImgs'
 import MyPopconfirm from '@/components/MyPopconfirm'
-import TextArea from 'antd/es/input/TextArea'
+import ZRichTextOne from '@/components/ZRichTextOne'
 
 type Props = {
   txt: AddTxtType
@@ -20,7 +20,11 @@ type Props = {
 function A6add({ txt, _id, closeFu, addTableFu, editTableFu }: Props) {
   const FormBoxRef = useRef<FormInstance>(null)
   const ZupThumbRef = useRef<any>(null)
+  const ZupPersonRef = useRef<any>(null)
   const ZupImgsRef = useRef<any>(null)
+  const listSummaryRef = useRef<any>(null)
+  const introductionRef = useRef<any>(null)
+  const deedsRef = useRef<any>(null)
 
   const getInfoFu = useCallback(async (id: string) => {
     const res = await A6_APIgetInfo(id)
@@ -32,7 +36,15 @@ function A6add({ txt, _id, closeFu, addTableFu, editTableFu }: Props) {
         originalUrl: info.cover,
         compressedUrl: info.coverSmall
       })
+      ZupPersonRef.current?.setFileComFileFu({
+        originalName: '',
+        originalUrl: info.personImages,
+        compressedUrl: info.personImagesSmall
+      })
       ZupImgsRef.current?.setFileComFileFu(info.images || [])
+      listSummaryRef.current?.ritxtShowFu(info.listSummary)
+      introductionRef.current?.ritxtShowFu(info.introduction)
+      deedsRef.current?.ritxtShowFu(info.deeds)
     }
   }, [])
 
@@ -52,13 +64,24 @@ function A6add({ txt, _id, closeFu, addTableFu, editTableFu }: Props) {
       const coverUrl = ZupThumbRef.current?.fileComFileResFu()
       if (!coverUrl.originalUrl) return MessageFu.warning('请上传封面图')
 
+      const personUrl = ZupPersonRef.current?.fileComFileResFu()
+      if (!personUrl.originalUrl) return MessageFu.warning('请上传详情页人物封面')
+
       const images = ZupImgsRef.current?.fileComFileResFu() || []
+      const listSummaryRtf = listSummaryRef.current?.fatherBtnOkFu() || { val: '' }
+      const introductionRtf = introductionRef.current?.fatherBtnOkFu() || { val: '' }
+      const deedsRtf = deedsRef.current?.fatherBtnOkFu() || { val: '' }
 
       const obj = {
         ...values,
         _id: txt === '新增' ? null : _id,
+        listSummary: listSummaryRtf.val || '',
+        introduction: introductionRtf.val || '',
+        deeds: deedsRtf.val || '',
         cover: coverUrl.originalUrl || '',
         coverSmall: coverUrl.compressedUrl || '',
+        personImages: personUrl.originalUrl || '',
+        personImagesSmall: personUrl.compressedUrl || '',
         images
       }
 
@@ -116,6 +139,18 @@ function A6add({ txt, _id, closeFu, addTableFu, editTableFu }: Props) {
             </div>
           </Form.Item>
 
+          <div className='formBox'>
+            <div className='formBoxll'>列表简介:</div>
+            <div className='formBoxrr'>
+              <ZRichTextOne
+                check={false}
+                showUpload={false}
+                isLook={txt === '查看'}
+                ref={listSummaryRef}
+              />
+            </div>
+          </div>
+
           <Form.Item label='摘要' name='summary' getValueFromEvent={e => e.target.value}>
             <Input
               readOnly={txt === '查看'}
@@ -125,25 +160,29 @@ function A6add({ txt, _id, closeFu, addTableFu, editTableFu }: Props) {
             />
           </Form.Item>
 
-          <Form.Item label='个人简介' name='introduction' getValueFromEvent={e => e.target.value}>
-            <TextArea
-              readOnly={txt === '查看'}
-              maxLength={2000}
-              showCount
-              rows={5}
-              placeholder='请输入内容,不超过2000个字'
-            />
-          </Form.Item>
+          <div className='formBox'>
+            <div className='formBoxll'>个人简介:</div>
+            <div className='formBoxrr'>
+              <ZRichTextOne
+                check={false}
+                showUpload={false}
+                isLook={txt === '查看'}
+                ref={introductionRef}
+              />
+            </div>
+          </div>
 
-          <Form.Item label='追光事迹' name='deeds' getValueFromEvent={e => e.target.value}>
-            <TextArea
-              readOnly={txt === '查看'}
-              maxLength={20000}
-              showCount
-              rows={5}
-              placeholder='请输入内容,不超过20000个字'
-            />
-          </Form.Item>
+          <div className='formBox'>
+            <div className='formBoxll'>追光事迹:</div>
+            <div className='formBoxrr'>
+              <ZRichTextOne
+                check={false}
+                showUpload={false}
+                isLook={txt === '查看'}
+                ref={deedsRef}
+              />
+            </div>
+          </div>
 
           <div className='formBox'>
             <div className='formBoxll'>
@@ -166,6 +205,26 @@ function A6add({ txt, _id, closeFu, addTableFu, editTableFu }: Props) {
           </div>
 
           <div className='formBox'>
+            <div className='formBoxll'>
+              <span>* </span>详情页人物封面:
+            </div>
+            <div className='formBoxrr'>
+              <ZupOne
+                ref={ZupPersonRef}
+                isLook={txt === '查看'}
+                fileCheck={fileCheck}
+                myUrl='file/upload?upPath=A6person'
+                format={['image/jpeg', 'image/png']}
+                formatTxt='png、jpg和jpeg'
+                checkTxt='请上传详情页人物封面'
+                upTxt='最多1张'
+                myType='thumb'
+                size={5}
+              />
+            </div>
+          </div>
+
+          <div className='formBox'>
             <div className='formBoxll'>图片:</div>
             <div className='formBoxrr'>
               <ZupImgs

+ 3 - 0
src/pages/A6person/data.ts

@@ -2,11 +2,14 @@ export type A6listType = {
   _id: string
   name: string
   pinyin: string
+  listSummary: string
   summary: string
   introduction: string
   deeds: string
   cover: string
   coverSmall: string
+  personImages: string
+  personImagesSmall: string
   images: { url: string; urlSmall: string; intro: string }[]
   sort: number
   createTime: string