shaogen1995 1 anno fa
parent
commit
70446df4dd

+ 1 - 1
src/components/ZRichTexts/index.module.scss

@@ -4,7 +4,7 @@
   :global {
     // 正文
     .formRightZW {
-      width: 700px;
+      width: 1000px;
       top: -3px;
       position: relative;
       display: flex;

+ 8 - 17
src/components/ZRichTexts/index.tsx

@@ -55,7 +55,7 @@ function ZRichTexts(
   // 是否按章节发布
   const [isSection, setIsSection] = useState(false)
 
-  // 当前上传 图片 视频的索引
+  // 当前上传 图片
   const nowIndexRef = useRef(0)
 
   // 判断 富文本是否为空
@@ -84,27 +84,18 @@ function ZRichTexts(
 
   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 type = ['image/jpeg', 'image/png']
         let size = 5
         let txt = '图片只支持png、jpg和jpeg格式!'
         let txt2 = '图片最大支持5M!'
 
-        const isVideoFlag = filesInfo.name.endsWith('.mp4') || filesInfo.name.endsWith('.MP4')
-
-        if (isVideoFlag) {
-          // 上传视频
-          size = 500
-          txt = '视频只支持mp4格式!'
-          txt2 = '视频最大支持500M!'
-        }
-
         // 校验格式
         if (!type.includes(filesInfo.type)) {
           e.target.value = ''
@@ -120,7 +111,7 @@ function ZRichTexts(
         // 创建FormData对象
         const fd = new FormData()
         // 把files添加进FormData对象(‘photo’为后端需要的字段)
-        fd.append('type', isVideoFlag ? 'video' : 'img')
+        fd.append('type', 'img')
         fd.append('dirCode', dirCode)
         fd.append('file', filesInfo)
 
@@ -133,7 +124,7 @@ function ZRichTexts(
             // 在光标位置插入图片
             const newTxt = ContentUtils.insertMedias(sectionArr[nowIndexRef.current].txt, [
               {
-                type: isVideoFlag ? 'VIDEO' : 'IMAGE',
+                type: 'IMAGE',
                 url: baseURL + res.data.filePath
               }
             ])
@@ -264,7 +255,7 @@ function ZRichTexts(
       <input
         id='upInput'
         type='file'
-        accept='.png,.jpg,.jpeg,.mp4'
+        accept='.png,.jpg,.jpeg'
         ref={myInput}
         onChange={e => handeUpPhoto(e)}
       />
@@ -302,7 +293,7 @@ function ZRichTexts(
                   myInput.current?.click()
                 }}
               >
-                上传图片/视频
+                上传图片
               </Button>
             </div>
           </div>
@@ -346,7 +337,7 @@ function ZRichTexts(
                       myInput.current?.click()
                     }}
                   >
-                    上传图片/视频
+                    上传图片
                   </Button>
                 </div>
               </div>

+ 98 - 0
src/pages/A7notice/A7add/index.module.scss

@@ -0,0 +1,98 @@
+.A7add {
+  position: absolute;
+  top: 0;
+  left: 0;
+  width: 100%;
+  height: 100%;
+  z-index: 12;
+  background-color: #fff;
+  border-radius: 10px;
+  padding: 24px;
+
+  :global {
+    .A7aMain {
+      width: 100%;
+      height: 100%;
+      overflow-y: auto;
+
+      textarea {
+        min-height: 75px !important;
+      }
+
+      .A1fromRow {
+        position: relative;
+        width: 800px;
+
+        .A1_6Frow {
+          position: absolute;
+          left: 200px;
+          top: 5px;
+          color: #999;
+          font-size: 12px;
+        }
+      }
+
+      .ant-form {
+        width: 800px;
+
+        // .ant-input-affix-wrapper{
+        //   width: 800px;
+        // }
+        .formRow {
+          display: flex;
+
+          .formLeft {
+            position: relative;
+            top: 3px;
+            width: 100px;
+            text-align: right;
+
+            & > span {
+              color: #ff4d4f;
+            }
+          }
+
+          .formRight {
+            width: calc(100% - 100px);
+          }
+        }
+
+        .A7abtn {
+          position: absolute;
+          z-index: 10;
+          left: 1200px;
+          top: 50%;
+          transform: translateY(-50%);
+        }
+      }
+    }
+
+    // 从查看进入
+    .A7aMainLook {
+      // 左边的 label 也不让选中
+      label {
+        pointer-events: none;
+      }
+
+      .ant-picker {
+        pointer-events: none;
+      }
+
+      .ant-checkbox-wrapper {
+        pointer-events: none;
+      }
+
+      .ant-input-number {
+        pointer-events: none;
+      }
+
+      .ant-select {
+        pointer-events: none;
+      }
+
+      .ant-radio-wrapper {
+        pointer-events: none;
+      }
+    }
+  }
+}

+ 184 - 0
src/pages/A7notice/A7add/index.tsx

@@ -0,0 +1,184 @@
+import React, { useCallback, useEffect, useRef, useState } from 'react'
+import styles from './index.module.scss'
+import { A1EditInfoType } from '@/pages/A1manage/data'
+import { Button, Form, FormInstance, Input, InputNumber, Select } from 'antd'
+import classNames from 'classnames'
+import { A7_APIgetInfo, A7_APIsave } from '@/store/action/A7notice'
+import { MessageFu } from '@/utils/message'
+import { useSelector } from 'react-redux'
+import { RootState } from '@/store'
+import MyPopconfirm from '@/components/MyPopconfirm'
+import ZRichTexts from '@/components/ZRichTexts'
+
+type Props = {
+  editInfo: A1EditInfoType
+  closeFu: () => void
+  addTableFu: () => void
+  editTableFu: () => void
+}
+
+function A7add({ editInfo, closeFu, addTableFu, editTableFu }: Props) {
+  const { typeList } = useSelector((state: RootState) => state.A7notice)
+
+  // 表单的ref
+  const FormBoxRef = useRef<FormInstance>(null)
+
+  // 富文本的ref
+  const ZRichTextRef = useRef<any>(null)
+
+  // 编辑/查看 进入页面 获取信息
+  const getInfoFu = useCallback(async (id: number) => {
+    const res = await A7_APIgetInfo(id)
+    if (res.code === 0) {
+      const data = res.data
+
+      console.log('--------', data.description)
+
+      // 设置富文本
+      ZRichTextRef.current?.ritxtShowFu(JSON.parse(data.description || '{}'))
+
+      FormBoxRef.current?.setFieldsValue(data)
+    }
+  }, [])
+
+  useEffect(() => {
+    if (editInfo.id > 0) {
+      getInfoFu(editInfo.id)
+    } else {
+      FormBoxRef.current?.setFieldsValue({
+        sort: 999
+      })
+    }
+  }, [editInfo.id, getInfoFu])
+
+  // 附件 是否 已经点击过确定
+  const [fileCheck, setFileCheck] = useState(false)
+
+  // 没有通过校验
+  const onFinishFailed = useCallback(() => {
+    setFileCheck(true)
+  }, [])
+
+  //  通过校验点击确定
+  const onFinish = useCallback(
+    async (values: any) => {
+      setFileCheck(true)
+
+      // 富文本校验不通过
+      const rtf = ZRichTextRef.current?.fatherBtnOkFu() || { flag: true }
+
+      if (rtf.flag) return MessageFu.warning('请输入完整正文!')
+
+      const obj = {
+        ...values,
+        id: editInfo.id > 0 ? editInfo.id : null,
+        description: JSON.stringify(rtf.val || '')
+      }
+
+      // if (obj) {
+      //   console.log(123, obj);
+      //   return;
+      // }
+
+      const res = await A7_APIsave(obj)
+
+      if (res.code === 0) {
+        MessageFu.success(`${editInfo.txt}成功!`)
+        editInfo.id > 0 ? editTableFu() : addTableFu()
+        closeFu()
+      }
+    },
+    [addTableFu, closeFu, editInfo.id, editInfo.txt, editTableFu]
+  )
+
+  return (
+    <div className={styles.A7add}>
+      <div className={classNames('A7aMain', editInfo.txt === '查看' ? 'A7aMainLook' : '')}>
+        <Form
+          ref={FormBoxRef}
+          name='basic'
+          labelCol={{ span: 3 }}
+          onFinish={onFinish}
+          onFinishFailed={onFinishFailed}
+          autoComplete='off'
+          scrollToFirstError
+        >
+          <Form.Item label='标题' name='name' rules={[{ required: true, message: '请输入标题!' }]}>
+            <Input
+              readOnly={editInfo.txt === '查看'}
+              placeholder='请输入内容'
+              maxLength={20}
+              showCount
+            />
+          </Form.Item>
+
+          <Form.Item
+            label='公告类型'
+            name='dictId'
+            rules={[{ required: true, message: '请选择公告类型!' }]}
+          >
+            <Select
+              placeholder='请选择'
+              fieldNames={{ label: 'name', value: 'id' }}
+              style={{ width: 200 }}
+              options={typeList}
+            />
+          </Form.Item>
+
+          {/* 封面 */}
+          <div className='formRow'>
+            <div className='formLeft'>
+              <span>* </span>
+              正文:
+            </div>
+            <div className='formRight'>
+              <ZRichTexts
+                check={fileCheck}
+                dirCode={'A7notice'}
+                isLook={editInfo.txt === '查看'}
+                ref={ZRichTextRef}
+                myUrl='cms/notice/upload'
+                isOne={true}
+                upAudioBtnNone={true}
+              />
+            </div>
+          </div>
+          {/* {editInfo.txt === '查看' ? <br /> : null} */}
+
+          <div className='A1fromRow'>
+            <Form.Item
+              label='排序值'
+              name='sort'
+              rules={[{ required: true, message: '请输入排序值!' }]}
+            >
+              <InputNumber min={1} max={999} precision={0} placeholder='请输入' />
+            </Form.Item>
+            <div className='A1_6Frow' hidden={editInfo.txt === '查看'}>
+              请输入1~999的数字。数字越小,排序越靠前。数字相同时,更新发布的内容排在前面
+            </div>
+          </div>
+
+          {/* 确定和取消按钮 */}
+          <Form.Item className='A7abtn'>
+            {editInfo.txt === '查看' ? (
+              <Button onClick={closeFu}>返回</Button>
+            ) : (
+              <>
+                <Button type='primary' htmlType='submit'>
+                  提交
+                </Button>
+                <br />
+                <br />
+                <MyPopconfirm txtK='取消' onConfirm={closeFu} />
+              </>
+            )}
+          </Form.Item>
+        </Form>
+      </div>
+    </div>
+  )
+}
+
+const MemoA7add = React.memo(A7add)
+
+export default MemoA7add

+ 63 - 0
src/pages/A7notice/A7type/index.module.scss

@@ -0,0 +1,63 @@
+.A7type {
+  width: 100%;
+  height: 100%;
+  padding: 24px;
+  background-color: #fff;
+  border-radius: 10px;
+
+  :global {
+    .A7tTitle {
+      display: flex;
+      justify-content: space-between;
+    }
+    .A7tTable {
+      border-radius: 10px;
+      overflow: hidden;
+      margin-top: 15px;
+      height: calc(100% - 77px);
+    }
+  }
+}
+
+// 新增 、编辑弹窗
+.A7tAdd {
+  :global {
+    .ant-modal-close {
+      display: none;
+    }
+    .ant-modal {
+      width: 800px !important;
+      top: 30%;
+    }
+    .ant-modal-body {
+      border-top: 1px solid #ccc;
+      padding-top: 15px !important;
+    }
+
+    .A7tMain {
+      width: 100%;
+      height: 100%;
+      overflow-y: auto;
+      position: relative;
+
+      .A7tFromRow {
+        position: relative;
+
+        .A7tFrowTit {
+          position: absolute;
+          left: 180px;
+          top: 5px;
+          color: #999;
+          font-size: 12px;
+        }
+      }
+
+      .ant-form {
+        .A7tBtn {
+          text-align: center;
+          margin-top: 30px;
+        }
+      }
+    }
+  }
+}

+ 171 - 0
src/pages/A7notice/A7type/index.tsx

@@ -0,0 +1,171 @@
+import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react'
+import styles from './index.module.scss'
+import { Button, Form, FormInstance, Input, InputNumber, Modal } from 'antd'
+import { useDispatch, useSelector } from 'react-redux'
+import { RootState } from '@/store'
+import { A7_APIdel2, A7_APIgetList2, A7_APIsave2 } from '@/store/action/A7notice'
+import MyTable from '@/components/MyTable'
+import { MessageFu } from '@/utils/message'
+import { A7tableType, A7typeType } from '@/types'
+import MyPopconfirm from '@/components/MyPopconfirm'
+import { A7tableCtype } from '@/utils/tableData'
+
+type Props = {
+  closeFu: () => void
+}
+
+function A7type({ closeFu }: Props) {
+  const dispatch = useDispatch()
+
+  useEffect(() => {
+    dispatch(A7_APIgetList2())
+  }, [dispatch])
+
+  const { typeList } = useSelector((state: RootState) => state.A7notice)
+
+  const delTableFu = useCallback(
+    async (id: number) => {
+      const res = await A7_APIdel2(id)
+      if (res.code === 0) {
+        MessageFu.success('删除成功!')
+        dispatch(A7_APIgetList2())
+      }
+    },
+    [dispatch]
+  )
+
+  const tableLastBtn = useMemo(() => {
+    return [
+      {
+        title: '操作',
+        render: (item: A7typeType) =>
+          item.id === 5 ? (
+            ' - '
+          ) : (
+            <>
+              <Button size='small' type='text' onClick={() => setEditInfo(item)}>
+                编辑
+              </Button>
+              <MyPopconfirm txtK='删除' onConfirm={() => delTableFu(item.id)} />
+            </>
+          )
+      }
+    ]
+  }, [delTableFu])
+
+  // 新增和编辑
+  const [editInfo, setEditInfo] = useState({} as A7typeType)
+
+  useEffect(() => {
+    FormBoxRef.current?.setFieldsValue(editInfo)
+  }, [editInfo])
+
+  // 表单的ref
+  const FormBoxRef = useRef<FormInstance>(null)
+
+  // 没有通过校验
+  const onFinishFailed = useCallback(() => {}, [])
+
+  //  通过校验点击确定
+  const onFinish = useCallback(
+    async (values: any) => {
+      const res = await A7_APIsave2({
+        id: editInfo.id > 0 ? editInfo.id : null,
+        name: values.name,
+        sort: values.sort,
+        type: 'notice',
+        display: 1
+      })
+      if (res.code === 0) {
+        MessageFu.success(editInfo.id > 0 ? '编辑成功!' : '新增成功!')
+        setEditInfo({} as A7typeType)
+        dispatch(A7_APIgetList2())
+      }
+    },
+    [dispatch, editInfo.id]
+  )
+
+  return (
+    <div className={styles.A7type}>
+      <div className='A7tTitle'>
+        <h1>公告类型</h1>
+        <div>
+          <Button type='primary' onClick={() => setEditInfo({ id: -1, name: '', sort: 999 })}>
+            新增
+          </Button>
+          &emsp;
+          <Button onClick={closeFu}>关闭</Button>
+        </div>
+      </div>
+
+      <div className='A7tTable'>
+        <MyTable
+          classKey='A7tTable'
+          yHeight={580}
+          list={typeList}
+          columnsTemp={A7tableCtype}
+          lastBtn={tableLastBtn}
+          pagingInfo={false}
+        />
+      </div>
+
+      {/* 新增/编辑 */}
+      {editInfo.id ? (
+        <Modal
+          wrapClassName={styles.A7tAdd}
+          open={true}
+          title={editInfo.id > 0 ? '编辑' : '新增'}
+          footer={
+            [] // 设置footer为空,去掉 取消 确定默认按钮
+          }
+        >
+          <div className='A7tMain'>
+            <Form
+              ref={FormBoxRef}
+              name='basic'
+              labelCol={{ span: 2 }}
+              onFinish={onFinish}
+              onFinishFailed={onFinishFailed}
+              autoComplete='off'
+              scrollToFirstError
+            >
+              <Form.Item
+                label='标题'
+                name='name'
+                rules={[{ required: true, message: '请输入标题!' }]}
+              >
+                <Input placeholder='请输入内容' maxLength={20} showCount />
+              </Form.Item>
+
+              <div className='A7tFromRow'>
+                <Form.Item
+                  label='排序值'
+                  name='sort'
+                  rules={[{ required: true, message: '请输入排序值!' }]}
+                >
+                  <InputNumber min={1} max={999} precision={0} placeholder='请输入' />
+                </Form.Item>
+                <div className='A7tFrowTit'>
+                  请输入1~999的数字。数字越小,排序越靠前。数字相同时,更新发布的内容排在前面
+                </div>
+              </div>
+
+              {/* 确定和取消按钮 */}
+              <Form.Item className='A7tBtn'>
+                <Button type='primary' htmlType='submit'>
+                  提交
+                </Button>
+                &emsp;
+                <MyPopconfirm txtK='取消' onConfirm={() => setEditInfo({} as A7tableType)} />
+              </Form.Item>
+            </Form>
+          </div>
+        </Modal>
+      ) : null}
+    </div>
+  )
+}
+
+const MemoA7type = React.memo(A7type)
+
+export default MemoA7type

+ 6 - 0
src/pages/A7notice/data.ts

@@ -0,0 +1,6 @@
+export type A7FromDataType = {
+  searchKey: string
+  dictId: number | null
+  pageNum: number
+  pageSize: number
+}

+ 41 - 0
src/pages/A7notice/index.module.scss

@@ -1,4 +1,45 @@
 .A7notice {
+  position: relative;
   :global {
+    .A7top {
+      border-radius: 10px;
+      background-color: #fff;
+      padding: 15px 24px;
+      display: flex;
+      justify-content: space-between;
+      & > div {
+        display: flex;
+        .A7TopRow {
+          display: flex;
+          align-items: center;
+          margin-right: 20px;
+          .ant-select-selection-placeholder {
+            color: black;
+          }
+        }
+      }
+    }
+    .A7tableBox {
+      border-radius: 10px;
+      overflow: hidden;
+      margin-top: 15px;
+      height: calc(100% - 77px);
+      background-color: #fff;
+    }
+
+    .A7type {
+      position: absolute;
+      top: 0;
+      left: 0;
+      width: 100%;
+      height: 100%;
+      border-radius: 10px;
+      padding: 50px 100px;
+      background-color: rgba(0, 0, 0, 0.6);
+      & > div {
+        width: 100%;
+        height: 100%;
+      }
+    }
   }
 }

+ 181 - 2
src/pages/A7notice/index.tsx

@@ -1,9 +1,188 @@
-import React from 'react'
+import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react'
 import styles from './index.module.scss'
+import { A7FromDataType } from './data'
+import { useDispatch, useSelector } from 'react-redux'
+import { A7_APIdel, A7_APIgetList, A7_APIgetList2 } from '@/store/action/A7notice'
+import { RootState } from '@/store'
+import { MessageFu } from '@/utils/message'
+import { A7tableType } from '@/types'
+import { Button, Input, Select } from 'antd'
+import MyPopconfirm from '@/components/MyPopconfirm'
+import { A1EditInfoType } from '../A1manage/data'
+import MyTable from '@/components/MyTable'
+import { A7tableC } from '@/utils/tableData'
+import A7type from './A7type'
+import A7add from './A7add'
+
+const fromDataBase: A7FromDataType = {
+  dictId: null,
+  searchKey: '',
+  pageNum: 1,
+  pageSize: 10
+}
+
 function A7notice() {
+  const dispatch = useDispatch()
+
+  useEffect(() => {
+    dispatch(A7_APIgetList2())
+  }, [dispatch])
+
+  const [fromData, setFromData] = useState(fromDataBase)
+
+  const getListFu = useCallback(() => {
+    dispatch(A7_APIgetList(fromData))
+  }, [dispatch, fromData])
+
+  useEffect(() => {
+    getListFu()
+  }, [getListFu])
+
+  const [inputKey, setInputKey] = useState(1)
+
+  // 输入框的输入
+  const timeRef = useRef(-1)
+  const txtChangeFu = useCallback(
+    (e: React.ChangeEvent<HTMLInputElement>, key: 'searchKey') => {
+      clearTimeout(timeRef.current)
+      timeRef.current = window.setTimeout(() => {
+        setFromData({ ...fromData, [key]: e.target.value.replaceAll("'", ''), pageNum: 1 })
+      }, 500)
+    },
+    [fromData]
+  )
+
+  // 点击重置
+  const resetSelectFu = useCallback(() => {
+    setInputKey(Date.now())
+    setFromData({ ...fromDataBase })
+  }, [])
+
+  const { tableInfo, typeList } = useSelector((state: RootState) => state.A7notice)
+
+  const delTableFu = useCallback(
+    async (id: number) => {
+      const res = await A7_APIdel(id)
+      if (res.code === 0) {
+        MessageFu.success('删除成功!')
+        getListFu()
+      }
+    },
+    [getListFu]
+  )
+
+  const tableLastBtn = useMemo(() => {
+    return [
+      {
+        title: '操作',
+        render: (item: A7tableType) => (
+          <>
+            <Button
+              size='small'
+              type='text'
+              onClick={() => setEditInfo({ id: item.id, txt: '查看' })}
+            >
+              查看
+            </Button>
+            <Button
+              size='small'
+              type='text'
+              onClick={() => setEditInfo({ id: item.id, txt: '编辑' })}
+            >
+              编辑
+            </Button>
+            <MyPopconfirm txtK='删除' onConfirm={() => delTableFu(item.id)} />
+          </>
+        )
+      }
+    ]
+  }, [delTableFu])
+
+  //查看、新增、编辑
+  const [editInfo, setEditInfo] = useState<A1EditInfoType>({
+    id: 0,
+    txt: ''
+  })
+
+  // 公告类型显示隐藏
+  const [typeShow, setTypeShow] = useState(false)
+
   return (
     <div className={styles.A7notice}>
-      <h1>A7notice</h1>
+      <div className='pageTitle'>公告管理 {editInfo.id ? ` - ${editInfo.txt}` : ''}</div>
+
+      {/* 顶部筛选 */}
+      <div className='A7top'>
+        <div>
+          <div className='A7TopRow'>
+            <span>搜索:</span>
+            <Input
+              key={inputKey}
+              maxLength={20}
+              style={{ width: 200 }}
+              placeholder='请输入公告标题'
+              allowClear
+              onChange={e => txtChangeFu(e, 'searchKey')}
+            />
+          </div>
+
+          <div className='A7TopRow'>
+            <span>展示分类:</span>
+            <Select
+              allowClear
+              placeholder='全部'
+              style={{ width: 200 }}
+              value={fromData.dictId}
+              fieldNames={{ label: 'name', value: 'id' }}
+              onChange={e => setFromData({ ...fromData, pageNum: 1, dictId: e })}
+              options={typeList}
+            />
+          </div>
+        </div>
+        <div>
+          <Button onClick={resetSelectFu}>重置</Button>&emsp;
+          <Button type='primary' onClick={() => setTypeShow(true)}>
+            公告类型
+          </Button>
+          &emsp;
+          <Button type='primary' onClick={() => setEditInfo({ id: -1, txt: '新增' })}>
+            新增
+          </Button>
+        </div>
+      </div>
+
+      {/* 表格主体 */}
+      <div className='A7tableBox'>
+        <MyTable
+          yHeight={625}
+          list={tableInfo.list}
+          columnsTemp={A7tableC}
+          lastBtn={tableLastBtn}
+          pageNum={fromData.pageNum}
+          pageSize={fromData.pageSize}
+          total={tableInfo.total}
+          onChange={(pageNum, pageSize) => setFromData({ ...fromData, pageNum, pageSize })}
+        />
+      </div>
+
+      {/* 公告类型 */}
+      {typeShow ? (
+        <div className='A7type'>
+          <div>
+            <A7type closeFu={() => setTypeShow(false)} />
+          </div>
+        </div>
+      ) : null}
+
+      {/* 新增/编辑 */}
+      {editInfo.id ? (
+        <A7add
+          editInfo={editInfo}
+          closeFu={() => setEditInfo({ id: 0, txt: '新增' })}
+          addTableFu={resetSelectFu}
+          editTableFu={getListFu}
+        />
+      ) : null}
     </div>
   )
 }

+ 66 - 0
src/store/action/A7notice.ts

@@ -0,0 +1,66 @@
+import http from '@/utils/http'
+import { AppDispatch } from '..'
+
+/**
+ *公告管理-列表
+ */
+
+export const A7_APIgetList = (data: any): any => {
+  return async (dispatch: AppDispatch) => {
+    const res = await http.post('cms/notice/pageList', data)
+    if (res.code === 0) {
+      const obj = {
+        list: res.data.records,
+        total: res.data.total
+      }
+      dispatch({ type: 'A7/getList', payload: obj })
+    }
+  }
+}
+/**
+ * 公告管理-删除
+ */
+export const A7_APIdel = (id: number) => {
+  return http.get(`cms/notice/remove/${id}`)
+}
+
+/**
+ * 公告管理-获取详情
+ */
+export const A7_APIgetInfo = (id: number) => {
+  return http.get(`cms/notice/detail/${id}`)
+}
+
+/**
+ * 公告管理-新增/编辑
+ */
+export const A7_APIsave = (data: any) => {
+  return http.post('cms/notice/save', data)
+}
+
+// --------------------公告类型--------------------
+/**
+ *公告类型-列表
+ */
+
+export const A7_APIgetList2 = (): any => {
+  return async (dispatch: AppDispatch) => {
+    const res = await http.get('cms/dict/getList')
+    if (res.code === 0) {
+      dispatch({ type: 'A7/getTypeList', payload: res.data })
+    }
+  }
+}
+/**
+ * 公告类型-删除
+ */
+export const A7_APIdel2 = (id: number) => {
+  return http.get(`cms/dict/removes/${id}`)
+}
+
+/**
+ * 公告类型-新增/编辑
+ */
+export const A7_APIsave2 = (data: any) => {
+  return http.post('cms/dict/save', data)
+}

+ 38 - 0
src/store/reducer/A7notice.ts

@@ -0,0 +1,38 @@
+import { A7tableType, A7typeType } from '@/types'
+
+// 初始化状态
+const initState = {
+  // 列表数据
+  tableInfo: {
+    list: [] as A7tableType[],
+    total: 0
+  },
+  // 公告类型
+  typeList: [] as A7typeType[]
+}
+
+// 定义 action 类型
+type Props =
+  | {
+      type: 'A7/getList'
+      payload: { list: A7tableType[]; total: number }
+    }
+  | {
+      type: 'A7/getTypeList'
+      payload: A7typeType[]
+    }
+
+// reducer
+export default function Reducer(state = initState, action: Props) {
+  switch (action.type) {
+    // 获取列表数据
+    case 'A7/getList':
+      return { ...state, tableInfo: action.payload }
+    // 获取列表数据
+    case 'A7/getTypeList':
+      return { ...state, typeList: action.payload }
+
+    default:
+      return state
+  }
+}

+ 2 - 0
src/store/reducer/index.ts

@@ -9,6 +9,7 @@ import A3recommend from './A3recommend'
 import A4iosUser from './A4iosUser'
 import A5bookAudit from './A5bookAudit'
 import A6remarkAudit from './A6remarkAudit'
+import A7notice from './A7notice'
 import Z1user from './Z1user'
 import Z2log from './Z2log'
 
@@ -21,6 +22,7 @@ const rootReducer = combineReducers({
   A4iosUser,
   A5bookAudit,
   A6remarkAudit,
+  A7notice,
   Z1user,
   Z2log
 })

+ 14 - 0
src/types/api/A7notice.ts

@@ -0,0 +1,14 @@
+export type A7tableType = {
+  creatorName: string
+  id: number
+  name: string
+  rtf: string
+  sort: number
+  type: string
+}
+
+export type A7typeType = {
+  id: number
+  name: string
+  sort: number
+}

+ 1 - 0
src/types/index.d.ts

@@ -5,5 +5,6 @@ export * from './api/A3recommend'
 export * from './api/A4iosUser'
 export * from './api/A5bookAudit'
 export * from './api/A6remarkAudit'
+export * from './api/A7notice'
 export * from './api/Z1user'
 export * from './api/Z2log'

+ 12 - 0
src/utils/tableData.ts

@@ -92,6 +92,18 @@ export const A6tableC = [
   ['txt', '提交时间', 'createTime']
 ]
 
+export const A7tableC = [
+  ['txt', '标题', 'name'],
+  ['txt', '公告类型', 'dictName'],
+  ['txt', '排序值', 'sort'],
+  ['txt', '编辑人', 'creatorName']
+]
+
+export const A7tableCtype = [
+  ['txt', '类型名称', 'name'],
+  ['txt', '排序值', 'sort']
+]
+
 export const Z1tableC = [
   ['txt', '用户名', 'userName'],
   ['txtChange', '角色', 'isAdmin', { 1: '管理员', 0: '普通成员' }],