Browse Source

导出模块的更新

shaogen1995 3 tháng trước cách đây
mục cha
commit
dc06870d03

+ 5 - 1
src/App.tsx

@@ -12,12 +12,13 @@ import store, { RootState } from './store'
 import UpAsyncLoding from './components/UpAsyncLoding'
 import MessageCom from './components/Message'
 import LookDom from './components/LookDom'
+import Zexport from './components/Zexport'
 const Layout = React.lazy(() => import('./pages/Layout'))
 const Login = React.lazy(() => import('./pages/Login'))
 
 export default function App() {
   // 从仓库中获取查看图片的信息
-  const lookBigImg = useSelector((state: RootState) => state.A0Layout.lookBigImg)
+  const { lookBigImg, exInfo } = useSelector((state: RootState) => state.A0Layout)
 
   return (
     <>
@@ -64,6 +65,9 @@ export default function App() {
 
       {/* antd 轻提示 ---兼容360浏览器 */}
       <MessageCom />
+
+      {/* 所有批量导出 */}
+      {exInfo.show ? <Zexport /> : null}
     </>
   )
 }

+ 35 - 0
src/components/Zexport/index.module.scss

@@ -1,4 +1,39 @@
 .Zexport {
   :global {
+    .ant-modal-close {
+      display: none;
+    }
+    .ant-modal {
+      width: 800px !important;
+    }
+
+    .ZexMain {
+      border-top: 1px solid #999999;
+      padding-top: 15px;
+      width: 100%;
+      .ant-checkbox-wrapper {
+        margin-bottom: 10px;
+        margin-right: 10px;
+      }
+
+      .ZexBtn {
+        margin-top: 20px;
+        text-align: center;
+      }
+      .ZexTit {
+        position: relative;
+        opacity: 0;
+        pointer-events: none;
+        color: #ff4d4f;
+        margin-top: 10px;
+        text-align: center;
+        top: -10px;
+        transition: top 0.3s;
+      }
+      .ZexTitAc {
+        top: 0px;
+        opacity: 1;
+      }
+    }
   }
 }

+ 94 - 4
src/components/Zexport/index.tsx

@@ -1,10 +1,100 @@
-import React from 'react'
+import React, { useCallback, useEffect, useMemo, useState } from 'react'
 import styles from './index.module.scss'
+import { Button, Checkbox, Modal } from 'antd'
+import { useSelector } from 'react-redux'
+import store, { RootState } from '@/store'
+import { ExInfoType } from '@/store/reducer/layout'
+import { MessageFu } from '@/utils/message'
+import classNames from 'classnames'
+import dayjs from 'dayjs'
+import ExportJsonExcel from 'js-export-excel'
+
 function Zexport() {
+  const { exInfo } = useSelector((state: RootState) => state.A0Layout)
+
+  const [arr, setArr] = useState<{ label: string; value: boolean }[]>([])
+
+  useEffect(() => {
+    setArr(exInfo.arr.map(v => ({ label: v.txt, value: true })))
+  }, [exInfo.arr])
+
+  // 选中的txt集合
+  const txtAcArr = useMemo(() => {
+    return arr.filter(v => v.value).map(c => c.label)
+  }, [arr])
+
+  const btnOk = useCallback(() => {
+    if (txtAcArr.length === 0) return MessageFu.warning('最少选择一个字段')
+
+    const keyArr = exInfo.arr.filter(v => txtAcArr.includes(v.txt)).map(c => c.key)
+
+    const name = exInfo.name + dayjs(new Date()).format('YYYY-MM-DD HH:mm')
+
+    const numArr = keyArr.map(v => 10)
+
+    const option = {
+      fileName: name,
+      datas: [
+        {
+          sheetData: exInfo.data,
+          sheetName: name,
+          sheetFilter: keyArr,
+          sheetHeader: txtAcArr,
+          columnWidths: numArr
+        }
+      ]
+    }
+
+    const toExcel = new ExportJsonExcel(option) //new
+    toExcel.saveExcel() //保存
+    MessageFu.success('导出成功')
+    store.dispatch({ type: 'layout/exInfo', payload: {} as ExInfoType })
+  }, [exInfo, txtAcArr])
+
   return (
-    <div className={styles.Zexport}>
-      <h1>Zexport</h1>
-    </div>
+    <Modal
+      wrapClassName={styles.Zexport}
+      destroyOnClose
+      open={true}
+      title='导出设置'
+      footer={
+        [] // 设置footer为空,去掉 取消 确定默认按钮
+      }
+    >
+      <div className='ZexMain'>
+        {arr.map(v => (
+          <Checkbox
+            key={v.label}
+            checked={v.value}
+            onChange={e =>
+              setArr(
+                arr.map(c => ({
+                  label: c.label,
+                  value: c.label === v.label ? !c.value : c.value
+                }))
+              )
+            }
+          >
+            {v.label}
+          </Checkbox>
+        ))}
+
+        <div className='ZexBtn'>
+          <Button type='primary' onClick={btnOk} disabled={txtAcArr.length === 0}>
+            导出
+          </Button>
+          &emsp;
+          <Button
+            onClick={() => store.dispatch({ type: 'layout/exInfo', payload: {} as ExInfoType })}
+          >
+            取消
+          </Button>
+        </div>
+        <div className={classNames('ZexTit', txtAcArr.length === 0 ? 'ZexTitAc' : '')}>
+          最少选择一个字段
+        </div>
+      </div>
+    </Modal>
   )
 }
 

+ 37 - 63
src/pages/A3_ledger/A32Routing/index.tsx

@@ -1,11 +1,9 @@
 import React, { useCallback, useEffect, useRef, useState } from 'react'
 import styles from './index.module.scss'
 import { Button, Cascader, Input, Select } from 'antd'
-import dayjs from 'dayjs'
 import { MessageFu } from '@/utils/message'
 import { resJiLianFu } from '@/utils/history'
 import { statusCollectObj, statusStorageObj } from '@/utils/tableData'
-import ExportJsonExcel from 'js-export-excel'
 import { useDispatch } from 'react-redux'
 import { C1baseFormData, C1baseFormData2, C1InputKeyArr1, C1InputKeyArr2 } from '../C1ledger/data'
 import { A32_APIgetList } from '@/store/action/A32Routing'
@@ -71,7 +69,7 @@ function A32Routing() {
     arr = arr.map(v => ({
       ...v,
       show: true,
-      son: v.son.filter(c => c.name.includes(value2) && filterId.includes(c.id))
+      son: (v.son || []).filter(c => c.name.includes(value2) && filterId.includes(c.id))
     }))
 
     const arrPu: { id: string; name: string; key: string }[] = []
@@ -236,8 +234,6 @@ function A32Routing() {
 
   // 点击导出
   const deriveFu = useCallback(async () => {
-    const name = '藏品分账' + dayjs(new Date()).format('YYYY-MM-DD HH:mm')
-
     const obj = {
       ...formDataOldRef.current,
       pageNum: 1,
@@ -250,64 +246,42 @@ function A32Routing() {
     if (res.code === 0) {
       if (res.data.records.length <= 0) return MessageFu.warning('当前搜索条件没有数据!')
 
-      const option = {
-        fileName: name,
-        datas: [
-          {
-            sheetData: res.data.records.map((v: FourTableType) => ({
-              ...v,
-              thumbPc: v.thumbPc ? window.location.origin + v.thumbPc : '(空)',
-              dictType: resJiLianFu(v.dictType),
-              dictAge: v.dictAge === '其他' ? '其他' : resJiLianFu(v.dictAge),
-              dictTexture3: resJiLianFu(v.dictTexture3),
-              dictTorn: resJiLianFu(v.dictTorn),
-              source: resJiLianFu(v.source),
-              statusCollect: Reflect.get(statusCollectObj, v.statusCollect) || '(空)',
-              statusStorage: Reflect.get(statusStorageObj, v.statusStorage) || '(空)',
-              accountIndoor:
-                (selectObj['展览状态'].find(c => c.value === v.accountIndoor) || {}).label ||
-                '(空)'
-            })),
-            sheetName: name,
-            sheetFilter: [
-              'num',
-              'thumbPc',
-              'numName',
-              'name',
-              'dictLevel',
-              'dictType',
-              'dictAge',
-              'dictTexture3',
-              'dictTorn',
-              'source',
-              'statusCollect',
-              'statusStorage',
-              'accountIndoor',
-              'createTime'
-            ],
-            sheetHeader: [
-              '藏品编号',
-              '封面图地址',
-              '编号类型',
-              '藏品名称',
-              '文物级别',
-              '文物类别',
-              '年代',
-              '质地',
-              '完残程度',
-              '来源',
-              '入藏状态',
-              '库存状态',
-              '展览状态',
-              '创建日期'
-            ],
-            columnWidths: [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]
-          }
-        ]
-      }
-
-      const toExcel = new ExportJsonExcel(option) //new
-      toExcel.saveExcel() //保存
+      store.dispatch({
+        type: 'layout/exInfo',
+        payload: {
+          name: '藏品分账',
+          show: true,
+          arr: [
+            { key: 'num', txt: '藏品编号' },
+            { key: 'thumbPc', txt: '封面图地址' },
+            { key: 'numName', txt: '编号类型' },
+            { key: 'name', txt: '藏品名称' },
+            { key: 'dictLevel', txt: '文物级别' },
+            { key: 'dictType', txt: '文物类别' },
+            { key: 'dictAge', txt: '年代' },
+            { key: 'dictTexture3', txt: '质地' },
+            { key: 'dictTorn', txt: '完残程度' },
+            { key: 'source', txt: '来源' },
+            { key: 'statusCollect', txt: '入藏状态' },
+            { key: 'statusStorage', txt: '库存状态' },
+            { key: 'accountIndoor', txt: '展览状态' },
+            { key: 'createTime', txt: '创建日期' }
+          ],
+          data: res.data.records.map((v: FourTableType) => ({
+            ...v,
+            thumbPc: v.thumbPc ? window.location.origin + v.thumbPc : '(空)',
+            dictType: resJiLianFu(v.dictType),
+            dictAge: v.dictAge === '其他' ? '其他' : resJiLianFu(v.dictAge),
+            dictTexture3: resJiLianFu(v.dictTexture3),
+            dictTorn: resJiLianFu(v.dictTorn),
+            source: resJiLianFu(v.source),
+            statusCollect: Reflect.get(statusCollectObj, v.statusCollect) || '(空)',
+            statusStorage: Reflect.get(statusStorageObj, v.statusStorage) || '(空)',
+            accountIndoor:
+              (selectObj['展览状态'].find(c => c.value === v.accountIndoor) || {}).label || '(空)'
+          }))
+        }
+      })
     }
   }, [treeAc])
 

+ 37 - 65
src/pages/A3_ledger/C1ledger/index.tsx

@@ -10,10 +10,8 @@ import classNames from 'classnames'
 import Y1cathet from '@/pages/Y_goodsDetails/Y1cathet'
 import { useDispatch, useSelector } from 'react-redux'
 import { C1_APIgetList } from '@/store/action/C1ledger'
-import { RootState } from '@/store'
-import dayjs from 'dayjs'
+import store, { RootState } from '@/store'
 import { MessageFu } from '@/utils/message'
-import ExportJsonExcel from 'js-export-excel'
 import C8recycleBin from '../ComPage/C8recycleBin'
 import C4import from '../ComPage/C4import'
 import { selectObj } from '@/utils/select'
@@ -196,10 +194,6 @@ function C1ledger() {
 
   // 点击导出
   const deriveFu = useCallback(async () => {
-    const name = antiqueSearch
-      ? '藏品信息'
-      : '藏品总账' + dayjs(new Date()).format('YYYY-MM-DD HH:mm')
-
     const res = await C1_APIgetList(
       {
         ...formDataOldRef.current,
@@ -212,64 +206,42 @@ function C1ledger() {
     if (res.code === 0) {
       if (res.data.records.length <= 0) return MessageFu.warning('当前搜索条件没有数据!')
 
-      const option = {
-        fileName: name,
-        datas: [
-          {
-            sheetData: res.data.records.map((v: FourTableType) => ({
-              ...v,
-              thumbPc: v.thumbPc ? window.location.origin + v.thumbPc : '(空)',
-              dictType: resJiLianFu(v.dictType),
-              dictAge: v.dictAge === '其他' ? '其他' : resJiLianFu(v.dictAge),
-              dictTexture3: resJiLianFu(v.dictTexture3),
-              dictTorn: resJiLianFu(v.dictTorn),
-              source: resJiLianFu(v.source),
-              statusCollect: Reflect.get(statusCollectObj, v.statusCollect) || '(空)',
-              statusStorage: Reflect.get(statusStorageObj, v.statusStorage) || '(空)',
-              accountIndoor:
-                (selectObj['展览状态'].find(c => c.value === v.accountIndoor) || {}).label ||
-                '(空)'
-            })),
-            sheetName: name,
-            sheetFilter: [
-              'num',
-              'thumbPc',
-              'numName',
-              'name',
-              'dictLevel',
-              'dictType',
-              'dictAge',
-              'dictTexture3',
-              'dictTorn',
-              'source',
-              'statusCollect',
-              'statusStorage',
-              'accountIndoor',
-              'createTime'
-            ],
-            sheetHeader: [
-              '藏品编号',
-              '封面图地址',
-              '编号类型',
-              '藏品名称',
-              '文物级别',
-              '文物类别',
-              '年代',
-              '质地',
-              '完残程度',
-              '来源',
-              '入藏状态',
-              '库存状态',
-              '展览状态',
-              '创建日期'
-            ],
-            columnWidths: [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]
-          }
-        ]
-      }
-
-      const toExcel = new ExportJsonExcel(option) //new
-      toExcel.saveExcel() //保存
+      store.dispatch({
+        type: 'layout/exInfo',
+        payload: {
+          name: antiqueSearch ? '藏品信息' : '藏品总账',
+          show: true,
+          arr: [
+            { key: 'num', txt: '藏品编号' },
+            { key: 'thumbPc', txt: '封面图地址' },
+            { key: 'numName', txt: '编号类型' },
+            { key: 'name', txt: '藏品名称' },
+            { key: 'dictLevel', txt: '文物级别' },
+            { key: 'dictType', txt: '文物类别' },
+            { key: 'dictAge', txt: '年代' },
+            { key: 'dictTexture3', txt: '质地' },
+            { key: 'dictTorn', txt: '完残程度' },
+            { key: 'source', txt: '来源' },
+            { key: 'statusCollect', txt: '入藏状态' },
+            { key: 'statusStorage', txt: '库存状态' },
+            { key: 'accountIndoor', txt: '展览状态' },
+            { key: 'createTime', txt: '创建日期' }
+          ],
+          data: res.data.records.map((v: FourTableType) => ({
+            ...v,
+            thumbPc: v.thumbPc ? window.location.origin + v.thumbPc : '(空)',
+            dictType: resJiLianFu(v.dictType),
+            dictAge: v.dictAge === '其他' ? '其他' : resJiLianFu(v.dictAge),
+            dictTexture3: resJiLianFu(v.dictTexture3),
+            dictTorn: resJiLianFu(v.dictTorn),
+            source: resJiLianFu(v.source),
+            statusCollect: Reflect.get(statusCollectObj, v.statusCollect) || '(空)',
+            statusStorage: Reflect.get(statusStorageObj, v.statusStorage) || '(空)',
+            accountIndoor:
+              (selectObj['展览状态'].find(c => c.value === v.accountIndoor) || {}).label || '(空)'
+          }))
+        }
+      })
     }
   }, [antiqueSearch])
 

+ 22 - 32
src/pages/A_workbench/A3flow/index.tsx

@@ -10,11 +10,9 @@ import {
 } from './data'
 import styles from './index.module.scss'
 import MyTable from '@/components/MyTable'
-import { RootState } from '@/store'
+import store, { RootState } from '@/store'
 import { useDispatch, useSelector } from 'react-redux'
 import { A3_APIList } from '@/store/action/A3flow'
-import ExportJsonExcel from 'js-export-excel'
-import dayjs from 'dayjs'
 import { MessageFu } from '@/utils/message'
 import { businessTypeObj, statusObj } from '@/utils/tableData'
 import history, { btnFlagFu } from '@/utils/history'
@@ -132,8 +130,6 @@ function A3flow() {
   }, [dispatch])
 
   const handleExport = async () => {
-    const name = '流程管理' + dayjs(new Date()).format('YYYY-MM-DD HH:mm')
-
     const res = await A3_APIList(
       {
         ...formDataRef.current,
@@ -146,33 +142,27 @@ function A3flow() {
     if (res.code === 0) {
       if (res.data.records.length <= 0) return MessageFu.warning('当前搜索条件没有数据!')
 
-      const option = {
-        fileName: name,
-        datas: [
-          {
-            sheetData: res.data.records.map((v: A3flowItemType) => ({
-              ...v,
-              type: Reflect.get(businessTypeObj, v.type) || '(空)',
-              status: Reflect.get(statusObj, v.status) || '(空)'
-            })),
-            sheetName: name,
-            sheetFilter: ['type', 'num', 'name', 'deptName', 'userName', 'createTime', 'status'],
-            sheetHeader: [
-              '业务类型',
-              '业务编号',
-              '申请名称',
-              '发起部门',
-              '发起人',
-              '发起日期',
-              '申请状态'
-            ],
-            columnWidths: [10, 10, 10, 10, 10, 10, 10]
-          }
-        ]
-      }
-
-      const toExcel = new ExportJsonExcel(option) //new
-      toExcel.saveExcel() //保存
+      store.dispatch({
+        type: 'layout/exInfo',
+        payload: {
+          name: '流程管理',
+          show: true,
+          arr: [
+            { key: 'type', txt: '业务类型' },
+            { key: 'num', txt: '业务编号' },
+            { key: 'name', txt: '申请名称' },
+            { key: 'deptName', txt: '发起部门' },
+            { key: 'userName', txt: '发起人' },
+            { key: 'createTime', txt: '发起日期' },
+            { key: 'status', txt: '申请状态' }
+          ],
+          data: res.data.records.map((v: A3flowItemType) => ({
+            ...v,
+            type: Reflect.get(businessTypeObj, v.type) || '(空)',
+            status: Reflect.get(statusObj, v.status) || '(空)'
+          }))
+        }
+      })
     }
   }
 

+ 21 - 23
src/pages/B_enterTibet/B1collect/index.tsx

@@ -10,10 +10,9 @@ import { useDispatch, useSelector } from 'react-redux'
 import { B1baseFormData, B1InputKeyType } from './data'
 import { B1_APIdel, B1_APIgetList } from '@/store/action/B1collect'
 import MyPopconfirm from '@/components/MyPopconfirm'
-import { RootState } from '@/store'
-import dayjs from 'dayjs'
-import ExportJsonExcel from 'js-export-excel'
+import store, { RootState } from '@/store'
 import { FourTableType } from './type'
+import dayjs from 'dayjs'
 const { RangePicker } = DatePicker
 
 function B1collect() {
@@ -164,8 +163,6 @@ function B1collect() {
 
   // 点击导出
   const deriveFu = useCallback(async () => {
-    const name = '藏品征集' + dayjs(new Date()).format('YYYY-MM-DD HH:mm')
-
     const res = await B1_APIgetList(
       {
         ...formDataOldRef.current,
@@ -178,24 +175,25 @@ function B1collect() {
     if (res.code === 0) {
       if (res.data.records.length <= 0) return MessageFu.warning('当前搜索条件没有数据!')
 
-      const option = {
-        fileName: name,
-        datas: [
-          {
-            sheetData: res.data.records.map((v: FourTableType) => ({
-              ...v,
-              status: statusObj[v.status as 1]
-            })),
-            sheetName: name,
-            sheetFilter: ['num', 'date', 'deptName', 'creatorName', 'createTime', 'status'],
-            sheetHeader: ['业务单号', '征集日期', '发起部门', '发送人', '发起日期', '申请状态'],
-            columnWidths: [10, 10, 10, 10, 10, 10]
-          }
-        ]
-      }
-
-      const toExcel = new ExportJsonExcel(option) //new
-      toExcel.saveExcel() //保存
+      store.dispatch({
+        type: 'layout/exInfo',
+        payload: {
+          name: '藏品征集',
+          show: true,
+          arr: [
+            { key: 'num', txt: '业务单号' },
+            { key: 'date', txt: '征集日期' },
+            { key: 'deptName', txt: '发起部门' },
+            { key: 'creatorName', txt: '发送人' },
+            { key: 'createTime', txt: '发起日期' },
+            { key: 'status', txt: '申请状态' }
+          ],
+          data: res.data.records.map((v: FourTableType) => ({
+            ...v,
+            status: statusObj[v.status as 1]
+          }))
+        }
+      })
     }
   }, [])
 

+ 19 - 22
src/pages/B_enterTibet/B2identify/index.tsx

@@ -2,13 +2,12 @@ import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react'
 import styles from './index.module.scss'
 import { useDispatch, useSelector } from 'react-redux'
 import { B1baseFormData, B1InputKeyType } from '../B1collect/data'
-import ExportJsonExcel from 'js-export-excel'
 import { Button, DatePicker, Input, Select } from 'antd'
 import { B2_APIdel, B2_APIgetList } from '@/store/action/B2identify'
 import { MessageFu } from '@/utils/message'
 import history, { btnFlagFu } from '@/utils/history'
 import MyPopconfirm from '@/components/MyPopconfirm'
-import { RootState } from '@/store'
+import store, { RootState } from '@/store'
 import dayjs from 'dayjs'
 import { B1TableC, statusObj } from '@/utils/tableData'
 import { selectObj } from '@/utils/select'
@@ -149,8 +148,6 @@ function B2identify() {
 
   // 点击导出
   const deriveFu = useCallback(async () => {
-    const name = '藏品鉴定' + dayjs(new Date()).format('YYYY-MM-DD HH:mm')
-
     const res = await B2_APIgetList(
       {
         ...formDataOldRef.current,
@@ -163,24 +160,24 @@ function B2identify() {
     if (res.code === 0) {
       if (res.data.records.length <= 0) return MessageFu.warning('当前搜索条件没有数据!')
 
-      const option = {
-        fileName: name,
-        datas: [
-          {
-            sheetData: res.data.records.map((v: FourTableType) => ({
-              ...v,
-              status: statusObj[v.status as 1]
-            })),
-            sheetName: name,
-            sheetFilter: ['num', 'deptName', 'creatorName', 'createTime', 'status'],
-            sheetHeader: ['业务单号', '发起部门', '发送人', '发起日期', '申请状态'],
-            columnWidths: [10, 10, 10, 10, 10]
-          }
-        ]
-      }
-
-      const toExcel = new ExportJsonExcel(option) //new
-      toExcel.saveExcel() //保存
+      store.dispatch({
+        type: 'layout/exInfo',
+        payload: {
+          name: '藏品鉴定',
+          show: true,
+          arr: [
+            { key: 'num', txt: '业务单号' },
+            { key: 'deptName', txt: '发起部门' },
+            { key: 'creatorName', txt: '发送人' },
+            { key: 'createTime', txt: '发起日期' },
+            { key: 'status', txt: '申请状态' }
+          ],
+          data: res.data.records.map((v: FourTableType) => ({
+            ...v,
+            status: statusObj[v.status as 1]
+          }))
+        }
+      })
     }
   }, [])
 

+ 20 - 29
src/pages/B_enterTibet/B34typeIn/index.tsx

@@ -8,9 +8,8 @@ import history, { btnFlagFu } from '@/utils/history'
 import { FourTableType } from '../B1collect/type'
 import { Button, DatePicker, Input, Select } from 'antd'
 import MyPopconfirm from '@/components/MyPopconfirm'
-import { RootState } from '@/store'
+import store, { RootState } from '@/store'
 import dayjs from 'dayjs'
-import ExportJsonExcel from 'js-export-excel'
 import { B34TableC, statusObj } from '@/utils/tableData'
 import { selectObj } from '@/utils/select'
 import MyTable from '@/components/MyTable'
@@ -164,8 +163,6 @@ function B34typeIn({ type }: Props) {
 
   // 点击导出
   const deriveFu = useCallback(async () => {
-    const name = `藏品${type}` + dayjs(new Date()).format('YYYY-MM-DD HH:mm')
-
     const res = await FourAPI_getList(
       {
         ...formDataOldRef.current,
@@ -179,31 +176,25 @@ function B34typeIn({ type }: Props) {
     if (res.code === 0) {
       if (res.data.records.length <= 0) return MessageFu.warning('当前搜索条件没有数据!')
 
-      const option = {
-        fileName: name,
-        datas: [
-          {
-            sheetData: res.data.records.map((v: FourTableType) => ({
-              ...v,
-              status: statusObj[v.status as 1]
-            })),
-            sheetName: name,
-            sheetFilter: ['date', 'num', 'deptName', 'creatorName', 'createTime', 'status'],
-            sheetHeader: [
-              `${type}日期`,
-              `${type}凭证号`,
-              '发起部门',
-              '发送人',
-              '发起日期',
-              '申请状态'
-            ],
-            columnWidths: [10, 10, 10, 10, 10, 10]
-          }
-        ]
-      }
-
-      const toExcel = new ExportJsonExcel(option) //new
-      toExcel.saveExcel() //保存
+      store.dispatch({
+        type: 'layout/exInfo',
+        payload: {
+          name: `藏品${type}`,
+          show: true,
+          arr: [
+            { key: 'date', txt: `${type}日期` },
+            { key: 'num', txt: `${type}凭证号` },
+            { key: 'deptName', txt: '发起部门' },
+            { key: 'creatorName', txt: '发送人' },
+            { key: 'createTime', txt: '发起日期' },
+            { key: 'status', txt: '申请状态' }
+          ],
+          data: res.data.records.map((v: FourTableType) => ({
+            ...v,
+            status: statusObj[v.status as 1]
+          }))
+        }
+      })
     }
   }, [type])
 

+ 20 - 23
src/pages/C_goodsManage/C21wealth/index.tsx

@@ -1,7 +1,7 @@
 import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react'
 import styles from './index.module.scss'
 import { useDispatch, useSelector } from 'react-redux'
-import { RootState } from '@/store'
+import store, { RootState } from '@/store'
 import { Button, Cascader, DatePicker, Input, Select } from 'antd'
 import history, { btnFlagFu } from '@/utils/history'
 import MyPopconfirm from '@/components/MyPopconfirm'
@@ -14,9 +14,7 @@ import {
 import { C21WealthSearchType, IC21WealthItem, IC21WealthParams } from './types'
 import { C21_APIdel, C21_APIList } from '@/store/action/C21wealth'
 import { MessageFu } from '@/utils/message'
-import dayjs from 'dayjs'
 import { statusObj } from '@/utils/tableData'
-import ExportJsonExcel from 'js-export-excel'
 
 const { RangePicker } = DatePicker
 
@@ -186,8 +184,6 @@ function C21wealth() {
 
   // 点击导出
   const deriveFu = useCallback(async () => {
-    const name = '资源使用' + dayjs(new Date()).format('YYYY-MM-DD HH:mm')
-
     const res = await C21_APIList(
       {
         ...formDataOldRef.current,
@@ -200,24 +196,25 @@ function C21wealth() {
     if (res.code === 0) {
       if (res.data.records.length <= 0) return MessageFu.warning('当前搜索条件没有数据!')
 
-      const option = {
-        fileName: name,
-        datas: [
-          {
-            sheetData: res.data.records.map((v: IC21WealthItem) => ({
-              ...v,
-              status: statusObj[v.status as 1]
-            })),
-            sheetName: name,
-            sheetFilter: ['num', 'dateStart', 'authUnit', 'creatorName', 'createTime', 'status'],
-            sheetHeader: ['申请编号', '交修日期', '交修部门', '发起人', '发送日期', '申请状态'],
-            columnWidths: [10, 10, 10, 10, 10, 10]
-          }
-        ]
-      }
-
-      const toExcel = new ExportJsonExcel(option) //new
-      toExcel.saveExcel() //保存
+      store.dispatch({
+        type: 'layout/exInfo',
+        payload: {
+          name: '资源使用',
+          show: true,
+          arr: [
+            { key: 'num', txt: '申请编号' },
+            { key: 'dateStart', txt: '交修日期' },
+            { key: 'authUnit', txt: '交修部门' },
+            { key: 'creatorName', txt: '发起人' },
+            { key: 'createTime', txt: '发送日期' },
+            { key: 'status', txt: '申请状态' }
+          ],
+          data: res.data.records.map((v: IC21WealthItem) => ({
+            ...v,
+            status: statusObj[v.status as 1]
+          }))
+        }
+      })
     }
   }, [])
 

+ 22 - 41
src/pages/C_goodsManage/C22goodEdit/index.tsx

@@ -1,12 +1,11 @@
 import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react'
 import styles from './index.module.scss'
-import ExportJsonExcel from 'js-export-excel'
 import { selectObj } from '@/utils/select'
 import { Button, DatePicker, Input, Select } from 'antd'
 import { useDispatch, useSelector } from 'react-redux'
 import { C22baseFormData, C22InputKeyType, C22tableBtnFu } from './data'
 import { C6_APIgetList, C6_APIrevocation } from '@/store/action/C6edit'
-import { RootState } from '@/store'
+import store, { RootState } from '@/store'
 import { MessageFu } from '@/utils/message'
 import dayjs from 'dayjs'
 import { C6tableC, statusObj } from '@/utils/tableData'
@@ -204,8 +203,6 @@ function C22goodEdit() {
 
   // 点击导出
   const deriveFu = useCallback(async () => {
-    const name = '藏品编辑' + dayjs(new Date()).format('YYYY-MM-DD HH:mm')
-
     const res = await C6_APIgetList(
       {
         ...formDataOldRef.current,
@@ -218,43 +215,27 @@ function C22goodEdit() {
     if (res.code === 0) {
       if (res.data.records.length <= 0) return MessageFu.warning('当前搜索条件没有数据!')
 
-      const option = {
-        fileName: name,
-        datas: [
-          {
-            sheetData: res.data.records.map((v: FourTableType) => ({
-              ...v,
-              status: statusObj[v.status as 1]
-            })),
-            sheetName: name,
-            sheetFilter: [
-              'goodsNum',
-              'goodsName',
-              'num',
-              'typeName',
-              'deptName',
-              'creatorName',
-              'createTime',
-              'status'
-            ],
-
-            sheetHeader: [
-              '藏品编号',
-              '藏品名称',
-              '业务单号',
-              '编辑类型',
-              '发起部门',
-              '发送人',
-              '发起日期',
-              '申请状态'
-            ],
-            columnWidths: [10, 10, 10, 10, 10, 10, 10, 10]
-          }
-        ]
-      }
-
-      const toExcel = new ExportJsonExcel(option) //new
-      toExcel.saveExcel() //保存
+      store.dispatch({
+        type: 'layout/exInfo',
+        payload: {
+          name: '藏品编辑',
+          show: true,
+          arr: [
+            { key: 'goodsNum', txt: '藏品编号' },
+            { key: 'goodsName', txt: '藏品名称' },
+            { key: 'num', txt: '业务单号' },
+            { key: 'typeName', txt: '编辑类型' },
+            { key: 'deptName', txt: '发起部门' },
+            { key: 'creatorName', txt: '发送人' },
+            { key: 'createTime', txt: '发起日期' },
+            { key: 'status', txt: '申请状态' }
+          ],
+          data: res.data.records.map((v: FourTableType) => ({
+            ...v,
+            status: statusObj[v.status as 1]
+          }))
+        }
+      })
     }
   }, [])
 

+ 33 - 57
src/pages/C_goodsManage/C3focus/index.tsx

@@ -2,15 +2,13 @@ import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react'
 import styles from './index.module.scss'
 import { useDispatch, useSelector } from 'react-redux'
 import { C1baseFormData, C1InputKeyArr1 } from '../../A3_ledger/C1ledger/data'
-import ExportJsonExcel from 'js-export-excel'
 import { C3_APIfocusNo, C3_APIgetList } from '@/store/action/C3focus'
 import { C1InputKeyType } from '../../A3_ledger/C1ledger/type'
 import { Button, Cascader, Input, Select } from 'antd'
 import { openGoodsInfoFu, resJiLianFu } from '@/utils/history'
 import { MessageFu } from '@/utils/message'
-import { RootState } from '@/store'
+import store, { RootState } from '@/store'
 import classNames from 'classnames'
-import dayjs from 'dayjs'
 import { C1tableC, statusCollectObj, statusStorageObj } from '@/utils/tableData'
 import MyTable from '@/components/MyTable'
 import Y1cathet from '@/pages/Y_goodsDetails/Y1cathet'
@@ -184,8 +182,6 @@ function C3focus() {
 
   // 点击导出
   const deriveFu = useCallback(async () => {
-    const name = '藏品关注' + dayjs(new Date()).format('YYYY-MM-DD HH:mm')
-
     const res = await C3_APIgetList(
       {
         ...formDataOldRef.current,
@@ -198,58 +194,38 @@ function C3focus() {
     if (res.code === 0) {
       if (res.data.records.length <= 0) return MessageFu.warning('当前搜索条件没有数据!')
 
-      const option = {
-        fileName: name,
-        datas: [
-          {
-            sheetData: res.data.records.map((v: FourTableType) => ({
-              ...v,
-              thumbPc: v.thumbPc ? window.location.origin + v.thumbPc : '(空)',
-              dictType: resJiLianFu(v.dictType),
-              dictAge: v.dictAge === '其他' ? '其他' : resJiLianFu(v.dictAge),
-              dictTexture3: resJiLianFu(v.dictTexture3),
-              dictTorn: resJiLianFu(v.dictTorn),
-              source: resJiLianFu(v.source),
-              statusCollect: Reflect.get(statusCollectObj, v.statusCollect) || '(空)',
-              statusStorage: Reflect.get(statusStorageObj, v.statusStorage) || '(空)'
-            })),
-            sheetName: name,
-            sheetFilter: [
-              'num',
-              'thumbPc',
-              'numName',
-              'name',
-              'dictLevel',
-              'dictType',
-              'dictAge',
-              'dictTexture3',
-              'dictTorn',
-              'source',
-
-              'statusCollect',
-              'statusStorage'
-            ],
-            sheetHeader: [
-              '藏品编号',
-              '封面图地址',
-              '编号类型',
-              '藏品名称',
-              '文物级别',
-              '文物类别',
-              '年代',
-              '质地',
-              '完残程度',
-              '来源',
-              '入藏状态',
-              '库存状态'
-            ],
-            columnWidths: [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]
-          }
-        ]
-      }
-
-      const toExcel = new ExportJsonExcel(option) //new
-      toExcel.saveExcel() //保存
+      store.dispatch({
+        type: 'layout/exInfo',
+        payload: {
+          name: '藏品关注',
+          show: true,
+          arr: [
+            { key: 'num', txt: '藏品编号' },
+            { key: 'thumbPc', txt: '封面图地址' },
+            { key: 'numName', txt: '编号类型' },
+            { key: 'name', txt: '藏品名称' },
+            { key: 'dictLevel', txt: '文物级别' },
+            { key: 'dictType', txt: '文物类别' },
+            { key: 'dictAge', txt: '年代' },
+            { key: 'dictTexture3', txt: '质地' },
+            { key: 'dictTorn', txt: '完残程度' },
+            { key: 'source', txt: '来源' },
+            { key: 'statusCollect', txt: '入藏状态' },
+            { key: 'statusStorage', txt: '库存状态' }
+          ],
+          data: res.data.records.map((v: FourTableType) => ({
+            ...v,
+            thumbPc: v.thumbPc ? window.location.origin + v.thumbPc : '(空)',
+            dictType: resJiLianFu(v.dictType),
+            dictAge: v.dictAge === '其他' ? '其他' : resJiLianFu(v.dictAge),
+            dictTexture3: resJiLianFu(v.dictTexture3),
+            dictTorn: resJiLianFu(v.dictTorn),
+            source: resJiLianFu(v.source),
+            statusCollect: Reflect.get(statusCollectObj, v.statusCollect) || '(空)',
+            statusStorage: Reflect.get(statusStorageObj, v.statusStorage) || '(空)'
+          }))
+        }
+      })
     }
   }, [])
 

+ 21 - 38
src/pages/D_storeManage/D4impStor/index.tsx

@@ -1,7 +1,6 @@
 import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react'
 import styles from './index.module.scss'
 import dayjs from 'dayjs'
-import ExportJsonExcel from 'js-export-excel'
 import { Button, DatePicker, Input, Select } from 'antd'
 import { useDispatch, useSelector } from 'react-redux'
 import { D4baseFormData, D4InputKeyType } from './data'
@@ -9,7 +8,7 @@ import { D4_APIdel, D4_APIgetList } from '@/store/action/D4impStor'
 import { MessageFu } from '@/utils/message'
 import history, { btnFlagFu } from '@/utils/history'
 import MyPopconfirm from '@/components/MyPopconfirm'
-import { RootState } from '@/store'
+import store, { RootState } from '@/store'
 import { D4tableC, statusObj } from '@/utils/tableData'
 import { FourTableType } from '@/pages/B_enterTibet/B1collect/type'
 import { selectObj } from '@/utils/select'
@@ -163,8 +162,6 @@ function D4impStor() {
 
   // 点击导出
   const deriveFu = useCallback(async () => {
-    const name = '藏品入库' + dayjs(new Date()).format('YYYY-MM-DD HH:mm')
-
     const res = await D4_APIgetList(
       {
         ...formDataOldRef.current,
@@ -177,40 +174,26 @@ function D4impStor() {
     if (res.code === 0) {
       if (res.data.records.length <= 0) return MessageFu.warning('当前搜索条件没有数据!')
 
-      const option = {
-        fileName: name,
-        datas: [
-          {
-            sheetData: res.data.records.map((v: FourTableType) => ({
-              ...v,
-              status: statusObj[v.status as 1]
-            })),
-            sheetName: name,
-            sheetFilter: [
-              'date',
-              'num',
-              'sonNum',
-              'deptName',
-              'creatorName',
-              'createTime',
-              'status'
-            ],
-            sheetHeader: [
-              '入库日期',
-              '入库单编号',
-              '分库缩写',
-              '发起部门',
-              '发送人',
-              '发起日期',
-              '申请状态'
-            ],
-            columnWidths: [10, 10, 10, 10, 10, 10, 10]
-          }
-        ]
-      }
-
-      const toExcel = new ExportJsonExcel(option) //new
-      toExcel.saveExcel() //保存
+      store.dispatch({
+        type: 'layout/exInfo',
+        payload: {
+          name: '藏品入库',
+          show: true,
+          arr: [
+            { key: 'date', txt: '入库日期' },
+            { key: 'num', txt: '入库单编号' },
+            { key: 'sonNum', txt: '分库缩写' },
+            { key: 'deptName', txt: '发起部门' },
+            { key: 'creatorName', txt: '发送人' },
+            { key: 'createTime', txt: '发起日期' },
+            { key: 'status', txt: '申请状态' }
+          ],
+          data: res.data.records.map((v: FourTableType) => ({
+            ...v,
+            status: statusObj[v.status as 1]
+          }))
+        }
+      })
     }
   }, [])
 

+ 19 - 23
src/pages/D_storeManage/D8cancel/index.tsx

@@ -4,14 +4,13 @@ import { Button, DatePicker, Input, Select } from 'antd'
 import { useDispatch, useSelector } from 'react-redux'
 import { C22baseFormData, C22InputKeyType } from '@/pages/C_goodsManage/C22goodEdit/data'
 import { D8_APIdel, D8_APIgetList } from '@/store/action/D8cancel'
-import { RootState } from '@/store'
+import store, { RootState } from '@/store'
 import { MessageFu } from '@/utils/message'
 import history, { btnFlagFu } from '@/utils/history'
 import { FourTableType } from '@/pages/B_enterTibet/B1collect/type'
 import MyPopconfirm from '@/components/MyPopconfirm'
 import dayjs from 'dayjs'
 import { D8tableC, statusObj } from '@/utils/tableData'
-import ExportJsonExcel from 'js-export-excel'
 import { selectObj } from '@/utils/select'
 import MyTable from '@/components/MyTable'
 const { RangePicker } = DatePicker
@@ -151,8 +150,6 @@ function D8cancel() {
 
   // 点击导出
   const deriveFu = useCallback(async () => {
-    const name = '藏品注销' + dayjs(new Date()).format('YYYY-MM-DD HH:mm')
-
     const res = await D8_APIgetList(
       {
         ...formDataOldRef.current,
@@ -165,25 +162,24 @@ function D8cancel() {
     if (res.code === 0) {
       if (res.data.records.length <= 0) return MessageFu.warning('当前搜索条件没有数据!')
 
-      const option = {
-        fileName: name,
-        datas: [
-          {
-            sheetData: res.data.records.map((v: FourTableType) => ({
-              ...v,
-              status: statusObj[v.status as 1]
-            })),
-            sheetName: name,
-            sheetFilter: ['num', 'deptName', 'creatorName', 'createTime', 'status'],
-
-            sheetHeader: ['业务单号', '发起部门', '发送人', '发起日期', '申请状态'],
-            columnWidths: [10, 10, 10, 10, 10, 10, 10, 10]
-          }
-        ]
-      }
-
-      const toExcel = new ExportJsonExcel(option) //new
-      toExcel.saveExcel() //保存
+      store.dispatch({
+        type: 'layout/exInfo',
+        payload: {
+          name: '藏品注销',
+          show: true,
+          arr: [
+            { key: 'num', txt: '业务单号' },
+            { key: 'deptName', txt: '发起部门' },
+            { key: 'creatorName', txt: '发送人' },
+            { key: 'createTime', txt: '发起日期' },
+            { key: 'status', txt: '申请状态' }
+          ],
+          data: res.data.records.map((v: FourTableType) => ({
+            ...v,
+            status: statusObj[v.status as 1]
+          }))
+        }
+      })
     }
   }, [])
 

+ 24 - 44
src/pages/E_goodsStorage/E1accident/index.tsx

@@ -8,9 +8,8 @@ import { MessageFu } from '@/utils/message'
 import history, { btnFlagFu } from '@/utils/history'
 import { FourTableType } from '@/pages/B_enterTibet/B1collect/type'
 import MyPopconfirm from '@/components/MyPopconfirm'
-import { RootState } from '@/store'
+import store, { RootState } from '@/store'
 import dayjs from 'dayjs'
-import ExportJsonExcel from 'js-export-excel'
 import { E1inputKeyArr } from './data'
 import { selectObj } from '@/utils/select'
 import MyTable from '@/components/MyTable'
@@ -188,8 +187,6 @@ function E1accident() {
 
   // 点击导出
   const deriveFu = useCallback(async () => {
-    const name = '事故登记' + dayjs(new Date()).format('YYYY-MM-DD HH:mm')
-
     const res = await E1_APIgetList(
       {
         ...formDataOldRef.current,
@@ -202,46 +199,29 @@ function E1accident() {
     if (res.code === 0) {
       if (res.data.records.length <= 0) return MessageFu.warning('当前搜索条件没有数据!')
 
-      const option = {
-        fileName: name,
-        datas: [
-          {
-            sheetData: res.data.records.map((v: FourTableType) => ({
-              ...v,
-              status: statusObj[v.status as 1]
-            })),
-            sheetName: name,
-            sheetFilter: [
-              'goodsNum',
-              'numName',
-              'num',
-              'date',
-              'sonTypeName',
-              'goodsName',
-              'authUser',
-              'creatorName',
-              'createTime',
-              'status'
-            ],
-            sheetHeader: [
-              '藏品编号',
-              '编号类型',
-              '申请编号',
-              '事故时间',
-              '事故责任',
-              '藏品名称',
-              '鉴定人',
-              '发起人',
-              '发送日期',
-              '申请状态'
-            ],
-            columnWidths: [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]
-          }
-        ]
-      }
-
-      const toExcel = new ExportJsonExcel(option) //new
-      toExcel.saveExcel() //保存
+      store.dispatch({
+        type: 'layout/exInfo',
+        payload: {
+          name: '事故登记',
+          show: true,
+          arr: [
+            { key: 'goodsNum', txt: '藏品编号' },
+            { key: 'numName', txt: '编号类型' },
+            { key: 'num', txt: '申请编号' },
+            { key: 'date', txt: '事故时间' },
+            { key: 'sonTypeName', txt: '事故责任' },
+            { key: 'goodsName', txt: '藏品名称' },
+            { key: 'authUser', txt: '鉴定人' },
+            { key: 'creatorName', txt: '发起人' },
+            { key: 'createTime', txt: '发送日期' },
+            { key: 'status', txt: '申请状态' }
+          ],
+          data: res.data.records.map((v: FourTableType) => ({
+            ...v,
+            status: statusObj[v.status as 1]
+          }))
+        }
+      })
     }
   }, [])
 

+ 20 - 22
src/pages/E_goodsStorage/E4repair/index.tsx

@@ -9,10 +9,9 @@ import { MessageFu } from '@/utils/message'
 import history, { btnFlagFu } from '@/utils/history'
 import { FourTableType } from '@/pages/B_enterTibet/B1collect/type'
 import MyPopconfirm from '@/components/MyPopconfirm'
-import { RootState } from '@/store'
+import store, { RootState } from '@/store'
 import dayjs from 'dayjs'
 import { E4tableC, statusObj } from '@/utils/tableData'
-import ExportJsonExcel from 'js-export-excel'
 import { selectObj } from '@/utils/select'
 import MyTable from '@/components/MyTable'
 const { RangePicker } = DatePicker
@@ -162,8 +161,6 @@ function E4repair() {
 
   // 点击导出
   const deriveFu = useCallback(async () => {
-    const name = '文物修复' + dayjs(new Date()).format('YYYY-MM-DD HH:mm')
-
     const res = await E4_APIgetList(
       {
         ...formDataOldRef.current,
@@ -176,24 +173,25 @@ function E4repair() {
     if (res.code === 0) {
       if (res.data.records.length <= 0) return MessageFu.warning('当前搜索条件没有数据!')
 
-      const option = {
-        fileName: name,
-        datas: [
-          {
-            sheetData: res.data.records.map((v: FourTableType) => ({
-              ...v,
-              status: statusObj[v.status as 1]
-            })),
-            sheetName: name,
-            sheetFilter: ['num', 'dateStart', 'authUnit', 'creatorName', 'createTime', 'status'],
-            sheetHeader: ['申请编号', '交修日期', '交修部门', '发起人', '发送日期', '申请状态'],
-            columnWidths: [10, 10, 10, 10, 10, 10]
-          }
-        ]
-      }
-
-      const toExcel = new ExportJsonExcel(option) //new
-      toExcel.saveExcel() //保存
+      store.dispatch({
+        type: 'layout/exInfo',
+        payload: {
+          name: '文物修复',
+          show: true,
+          arr: [
+            { key: 'num', txt: '申请编号' },
+            { key: 'dateStart', txt: '交修日期' },
+            { key: 'authUnit', txt: '交修部门' },
+            { key: 'creatorName', txt: '发起人' },
+            { key: 'createTime', txt: '发送日期' },
+            { key: 'status', txt: '申请状态' }
+          ],
+          data: res.data.records.map((v: FourTableType) => ({
+            ...v,
+            status: statusObj[v.status as 1]
+          }))
+        }
+      })
     }
   }, [])
 

+ 16 - 1
src/store/reducer/layout.ts

@@ -6,6 +6,13 @@ type DownImgType = {
   图片: '原图和缩略图' | '缩略图'
 }
 
+export type ExInfoType = {
+  name: string
+  show: boolean
+  arr: { key: string; txt: string }[]
+  data: any[]
+}
+
 // 初始化状态
 const initState = {
   // 所有图片点击预览查看大图
@@ -38,7 +45,10 @@ const initState = {
   downImg: {
     可见: '不可见',
     图片: '缩略图'
-  } as DownImgType
+  } as DownImgType,
+
+  // 批量导出
+  exInfo: {} as ExInfoType
 }
 
 // 定义 action 类型
@@ -56,6 +66,7 @@ type LayoutActionType =
   | { type: 'layout/userInfo'; payload: UserTableListType }
   | { type: 'layout/passEditShow'; payload: boolean }
   | { type: 'layout/downImg'; payload: DownImgType }
+  | { type: 'layout/exInfo'; payload: ExInfoType }
 
 // 频道 reducer
 export default function layoutReducer(state = initState, action: LayoutActionType) {
@@ -82,6 +93,10 @@ export default function layoutReducer(state = initState, action: LayoutActionTyp
     // 下载图片的权限
     case 'layout/downImg':
       return { ...state, downImg: action.payload }
+
+    // 批量导出
+    case 'layout/exInfo':
+      return { ...state, exInfo: action.payload }
     default:
       return state
   }