Ver código fonte

feat: 凭证管理

chenlei 3 meses atrás
pai
commit
32f2c4908d

+ 43 - 33
src/pages/A_workbench/A3flow/data.ts

@@ -2,6 +2,16 @@ import { selectObj } from '@/utils/select'
 import { A3flowSearchType, IA3flowListParams } from './types'
 import { businessTypeObj, statusObj } from '@/utils/tableData'
 import { D4_APIdel } from '@/store/action/D4impStor'
+import { B1_APIdel } from '@/store/action/B1collect'
+import { B2_APIdel } from '@/store/action/B2identify'
+import { FourAPI_del } from '@/store/action/FourAll'
+import { C6_APIdel } from '@/store/action/C6edit'
+import { D2_APIdel } from '@/store/action/D2storSet'
+import { D8_APIdel } from '@/store/action/D8cancel'
+import { E1_APIdel } from '@/store/action/E1accident'
+import { E2_APIdel } from '@/store/action/E2damaged'
+import { E3_APIdel } from '@/store/action/E3actuality'
+import { E4_APIdel } from '@/store/action/E4repair'
 
 export const DEFAULT_A3FLOW_PARAMS: IA3flowListParams = {
   pageNum: 1,
@@ -41,84 +51,84 @@ export const A3FLOW_TABLE_COLUMNS = [
 // 业务类型详情映射
 export const BUSINESS_DETAIL_PATH_MAP: Record<string, string> = {
   // 藏品征集
-  ZJ: 'collection_add',
+  ZJ: 'collect_edit',
   // 藏品鉴定
   JD: 'identify_edit',
   // 藏品入馆
-  RG: 'enterMuseum_edit',
+  RG: 'entering_edit',
   // 藏品入藏
-  RC: 'collection_store',
+  RC: 'enterTibet_edit',
   // 藏品登记
-  DJ: 'collection_register',
+  DJ: 'register',
   // 藏品编辑
-  BJ: 'collection_edit',
+  BJ: 'goodEdit_edit',
   // 藏品删除
-  SC: 'collection_delete',
+  SC: '',
   // 藏品入库
   RK: 'impStor_edit',
   // 藏品移库
   YK: 'moveStor_edit',
   // 藏品出库
-  CK: 'outStor_edit',
+  CK: 'putsStor_edit',
   // 藏品注销
-  ZX: 'collection_writeoff',
+  ZX: 'cancel_edit',
   // 藏品盘点
-  PD: 'collection_inventory',
+  PD: 'check',
   // 人员出入库
-  CR: 'person_access',
+  CR: 'staff',
   // 事故登记
   SG: 'accident_edit',
   // 残损登记
-  CS: 'damage_edit',
+  CS: 'damaged_edit',
   // 现状登记
-  XZ: 'status_edit',
+  XZ: 'actuality_edit',
   // 文物修复
-  XF: 'recovery_edit',
+  XF: 'repair_edit',
   // 展览申请
-  ZL: 'exhibit_apply',
+  ZL: '',
   // 藏品总登记号
-  ZDJ: 'collection_mainRegister'
+  ZDJ: ''
 }
 
 // TOFIX: 待完善
 // 业务类型删除接口映射
 export const BUSINESS_DELETE_API_MAP: Record<string, Function> = {
   // 藏品征集
-  ZJ: D4_APIdel,
+  ZJ: B1_APIdel,
   // 藏品鉴定
-  JD: D4_APIdel,
+  JD: B2_APIdel,
   // 藏品入馆
-  RG: D4_APIdel,
+  RG: (id: number) => FourAPI_del('1', id),
   // 藏品入藏
-  RC: D4_APIdel,
+  RC: (id: number) => FourAPI_del('2', id),
   // 藏品登记
-  DJ: D4_APIdel,
+  DJ: (id: number) => FourAPI_del('3', id),
   // 藏品编辑
-  BJ: D4_APIdel,
+  BJ: C6_APIdel,
   // 藏品删除
-  SC: D4_APIdel,
+  SC: (id: number) => FourAPI_del('4', id),
   // 藏品入库
   RK: D4_APIdel,
   // 藏品移库
-  YK: D4_APIdel,
+  // YK: ,
   // 藏品出库
-  CK: D4_APIdel,
+  CK: D2_APIdel,
   // 藏品注销
-  ZX: D4_APIdel,
+  ZX: D8_APIdel,
   // 藏品盘点
-  PD: D4_APIdel,
+  // PD: ,
   // 人员出入库
-  CR: D4_APIdel,
+  // CR: ,
   // 事故登记
-  SG: D4_APIdel,
+  SG: E1_APIdel,
   // 残损登记
-  CS: D4_APIdel,
+  CS: E2_APIdel,
   // 现状登记
-  XZ: D4_APIdel,
+  XZ: E3_APIdel,
   // 文物修复
-  XF: D4_APIdel,
+  XF: E4_APIdel
   // 展览申请
-  ZL: D4_APIdel,
+  // ZL: ,
   // 藏品总登记号
-  ZDJ: D4_APIdel
+  // ZDJ:
 }

+ 2 - 1
src/pages/A_workbench/A3flow/index.tsx

@@ -19,6 +19,7 @@ import { MessageFu } from '@/utils/message'
 import { businessTypeObj, statusObj } from '@/utils/tableData'
 import history, { btnFlagFu } from '@/utils/history'
 import MyPopconfirm from '@/components/MyPopconfirm'
+import { filterEmptyStrings } from '@/utils/objects'
 
 const { RangePicker } = DatePicker
 
@@ -127,7 +128,7 @@ function A3flow() {
       // @ts-ignore
       rest.endTime = date[1]
     }
-    dispatch(A3_APIList(rest))
+    dispatch(A3_APIList(filterEmptyStrings(rest)))
   }, [dispatch])
 
   const handleExport = async () => {

+ 15 - 6
src/pages/A_workbench/A4voucher/constants.ts

@@ -1,17 +1,26 @@
 import { selectObj } from '@/utils/select'
 import { A4voucherSearchType, IA4voucherParams } from './types'
+import { businessTypeObj } from '@/utils/tableData'
 
 export const DEFAULT_A4VOUCHER_PARAMS: IA4voucherParams = {
   pageNum: 1,
   pageSize: 10,
-  num: ''
+  goodNum: '',
+  fileName: '',
+  moduleName: ''
 }
 
 export const A4VOUCHER_PARAM_ROWS: A4voucherSearchType[] = [
-  { name: '凭证名称', key: 'num', type: '输入框' },
-  { name: '归档日期范围', key: 'num', type: '日期选择' },
-  { name: '业务类型', key: 'num', type: '下拉框', data: selectObj['业务类型'] },
-  { name: '业务编号', key: 'num', type: '输入框' }
+  { name: '凭证名称', key: 'fileName', type: '输入框' },
+  { name: '归档日期范围', key: 'date', type: '日期选择' },
+  { name: '业务类型', key: 'moduleName', type: '下拉框', data: selectObj['业务类型'] },
+  { name: '业务编号', key: 'goodNum', type: '输入框' }
 ]
 
-export const A4VOUCHER_TABLE_COLUMNS = [['txt', '业务编号', 'num']]
+export const A4VOUCHER_TABLE_COLUMNS = [
+  ['txt', '凭证名称', 'fileName'],
+  ['txt', '归档日期', 'updateTime'],
+  ['txtChange', '业务类型', 'moduleName', businessTypeObj],
+  ['txt', '业务编号', 'goodNum'],
+  ['txt', '发起日期', 'createTime']
+]

+ 87 - 36
src/pages/A_workbench/A4voucher/index.tsx

@@ -1,27 +1,32 @@
-import React, { useCallback, useMemo, useRef, useState } from 'react'
+import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react'
 import styles from './index.module.scss'
-import { Button, Checkbox, DatePicker, Input, Select } from 'antd'
+import { Button, Checkbox, DatePicker, Input, Popconfirm, Select } from 'antd'
 import MyTable from '@/components/MyTable'
 import { useDispatch, useSelector } from 'react-redux'
 import { RootState } from '@/store'
-import { A4voucherSearchType, IA4voucherParams } from './types'
-import history, { btnFlagFu } from '@/utils/history'
+import { A4voucherItemType, A4voucherSearchType, IA4voucherParams } from './types'
+import history, { downFileFu } from '@/utils/history'
 import {
   A4VOUCHER_PARAM_ROWS,
   A4VOUCHER_TABLE_COLUMNS,
   DEFAULT_A4VOUCHER_PARAMS
 } from './constants'
-import MyPopconfirm from '@/components/MyPopconfirm'
-import { A3_APIList } from '@/store/action/A3flow'
+import { MessageFu } from '@/utils/message'
+import { A4_APIDownload, A4_APIList } from '@/store/action/A4voucher'
+import { filterEmptyStrings } from '@/utils/objects'
+import { fileImgArr } from '@/store/action/layout'
+import { BUSINESS_DETAIL_PATH_MAP } from '../A3flow/data'
 
 const { RangePicker } = DatePicker
 
 function A4voucher() {
   // 从仓库拿数据
-  const tableInfo = useSelector((state: RootState) => state.F1exhibition.tableInfo)
+  const tableInfo = useSelector((state: RootState) => state.A4voucher.tableInfo)
   const [formData, setFormData] = useState({ ...DEFAULT_A4VOUCHER_PARAMS })
   const formDataRef = useRef({ ...DEFAULT_A4VOUCHER_PARAMS })
   const dispatch = useDispatch()
+  // 获取下载权限
+  const downImg = useSelector((state: RootState) => state.A0Layout.downImg)
 
   // 输入框的改变
   const txtChangeFu = useCallback(
@@ -53,7 +58,7 @@ function A4voucher() {
                 options={item.data}
                 placeholder='全部'
                 allowClear={true}
-                value={formData[item.key as 'num'] ? formData[item.key as 'num'] : null}
+                value={formData[item.key as 'goodNum'] ? formData[item.key as 'goodNum'] : null}
                 onChange={e => setFormData({ ...formData, [item.key]: e })}
               />
             ) : item.type === '日期选择' ? (
@@ -108,49 +113,58 @@ function A4voucher() {
       // @ts-ignore
       rest.endTime = date[1]
     }
-    dispatch(A3_APIList(rest))
+    dispatch(A4_APIList(filterEmptyStrings(rest)))
   }, [dispatch])
 
   // 点击操作按钮
-  const tableBtnFu = useCallback((item: any, key: string) => {}, [])
-
-  // 点击删除
-  const delTableFu = useCallback(async (item: any) => {}, [])
+  const tableBtnFu = useCallback((item: A4voucherItemType, key: string) => {
+    switch (key) {
+      case '1':
+        history.push(`/${BUSINESS_DETAIL_PATH_MAP[item.moduleName]}/4/${item.moduleId}`)
+        break
+    }
+  }, [])
 
   const tableLastBtn = useMemo(() => {
     return [
       {
         title: '操作',
         render: (item: any) => {
-          let obj = btnFlagFu(item)
-          return !Object.values(obj).some(Boolean) ? (
-            '-'
-          ) : (
-            <>
-              {obj['编辑'] ? (
-                <Button size='small' type='text' onClick={() => tableBtnFu(item, '2')}>
-                  编辑
-                </Button>
-              ) : null}
+          const fileNameArr = item.fileName.split('.')
+          const fileNameLast = fileNameArr[fileNameArr.length - 1]
 
-              {obj['审批'] ? (
-                <Button size='small' type='text' onClick={() => tableBtnFu(item, '3')}>
-                  审批
-                </Button>
-              ) : null}
-              {obj['查看'] ? (
-                <Button size='small' type='text' onClick={() => tableBtnFu(item, '4')}>
-                  查看
+          return (
+            <>
+              <Button size='small' type='text' onClick={() => tableBtnFu(item, '1')}>
+                查看
+              </Button>
+              {downImg['图片'] === '原图和缩略图' && fileImgArr.includes(fileNameLast) ? (
+                <Popconfirm
+                  title='请选择图片规格'
+                  onConfirm={() => downFileFu(item.filePath)}
+                  onCancel={() => downFileFu(item.thumb)}
+                  okText='原图'
+                  cancelText='缩略图'
+                >
+                  <Button size='small' type='text'>
+                    下载
+                  </Button>
+                </Popconfirm>
+              ) : (
+                <Button
+                  size='small'
+                  type='text'
+                  onClick={() => downFileFu(item.thumb || item.filePath)}
+                >
+                  下载
                 </Button>
-              ) : null}
-
-              {obj['删除'] ? <MyPopconfirm txtK='删除' onConfirm={() => delTableFu(item)} /> : null}
+              )}
             </>
           )
         }
       }
     ]
-  }, [delTableFu, tableBtnFu])
+  }, [tableBtnFu])
 
   // 多选
   const [checkArr, setCheckArr] = useState<number[]>([])
@@ -175,6 +189,27 @@ function A4voucher() {
     ]
   }, [checkArr, checkFu])
 
+  const downsFu = useCallback(
+    async (type: 1 | 2) => {
+      const res = await A4_APIDownload(checkArr, type)
+      if (res.code === 0) {
+        MessageFu.success('下载成功')
+        downFileFu(res.data, () => {
+          setCheckArr([])
+        })
+      }
+    },
+    [checkArr]
+  )
+
+  useEffect(() => {
+    getListFu()
+  }, [getListFu, timeKey])
+
+  useEffect(() => {
+    formDataRef.current = formData
+  }, [formData])
+
   return (
     <div className={styles.A4voucher}>
       <div className='pageTitle'>凭证管理</div>
@@ -186,7 +221,23 @@ function A4voucher() {
 
       {/* 第二行 */}
       <div className='C1top C1top2'>
-        <Button type='primary'>批量导出</Button>
+        {downImg['图片'] === '原图和缩略图' ? (
+          <Popconfirm
+            title='请选择图片规格'
+            onConfirm={() => downsFu(1)}
+            onCancel={() => downsFu(2)}
+            okText='原图'
+            cancelText='缩略图'
+          >
+            <Button type='primary' disabled={checkArr.length === 0}>
+              批量下载
+            </Button>
+          </Popconfirm>
+        ) : (
+          <Button type='primary' disabled={checkArr.length === 0} onClick={() => downsFu(2)}>
+            批量下载
+          </Button>
+        )}
         &emsp;
         <Button type='primary' onClick={clickSearch}>
           查询

+ 10 - 3
src/pages/A_workbench/A4voucher/types.ts

@@ -1,7 +1,12 @@
 export type A4voucherItemType = {
   id: number
-  num: string
-  name: string
+  moduleId: number
+  fileName: string
+  type: string
+  goodNum: string
+  createTime: string
+  updateTime: string
+  moduleName: string
 }
 
 export type A4voucherSearchType = {
@@ -14,6 +19,8 @@ export type A4voucherSearchType = {
 export interface IA4voucherParams {
   pageSize: number
   pageNum: number
-  num: string
+  fileName: string
   date?: string[]
+  moduleName: string
+  goodNum: string
 }

+ 24 - 0
src/store/action/A4voucher.ts

@@ -0,0 +1,24 @@
+import http from '@/utils/http'
+import { AppDispatch } from '..'
+
+/**
+ * 借展管理-列表
+ */
+export const A4_APIList = (data: any, exportFlag = false): any => {
+  if (exportFlag) return http.post('/cms/orderFile/page', data)
+  return async (dispatch: AppDispatch) => {
+    const res = await http.post('/cms/orderFile/page', data)
+    if (res.code === 0) {
+      const obj = {
+        list: res.data.records,
+        total: res.data.total
+      }
+
+      dispatch({ type: 'A4/getList', payload: obj })
+    }
+  }
+}
+
+export const A4_APIDownload = (data: number[], type: 1 | 2) => {
+  return http.post(`cms/orderFile/downloadBatch?downloadType=${type}`, data)
+}

+ 1 - 1
src/store/action/C1ledger.ts

@@ -21,7 +21,7 @@ export const API_goodsInfo = (id: number) => {
  * 藏品-弹窗-选择藏品
  */
 export const API_goodsNowAdd = (url: string, data: any) => {
-  return http.get(url, data)
+  return http.post(url, data)
 }
 
 /**

+ 28 - 0
src/store/reducer/A4voucher.ts

@@ -0,0 +1,28 @@
+import { A4voucherItemType } from '@/pages/A_workbench/A4voucher/types'
+
+// 初始化状态
+const initState = {
+  // 列表数据
+  tableInfo: {
+    list: [] as A4voucherItemType[],
+    total: 0
+  }
+}
+
+// 定义 action 类型
+type Props = {
+  type: 'A4/getList'
+  payload: { list: A4voucherItemType[]; total: number }
+}
+
+// reducer
+export default function userReducer(state = initState, action: Props) {
+  switch (action.type) {
+    // 获取列表数据
+    case 'A4/getList':
+      return { ...state, tableInfo: action.payload }
+
+    default:
+      return state
+  }
+}

+ 3 - 1
src/store/reducer/index.ts

@@ -30,6 +30,7 @@ import Z7log from './Z7log'
 import A3flow from './A3flow'
 import F1exhibition from './F1exhibition'
 import C21wealth from './C21wealth'
+import A4voucher from './A4voucher'
 
 // 合并 reducer
 const rootReducer = combineReducers({
@@ -60,7 +61,8 @@ const rootReducer = combineReducers({
   Z7log,
   A3flow,
   F1exhibition,
-  C21wealth
+  C21wealth,
+  A4voucher
 })
 
 // 默认导出

+ 5 - 0
src/utils/objects.ts

@@ -0,0 +1,5 @@
+import { pickBy } from 'lodash'
+
+export const filterEmptyStrings = <T extends object>(obj: T): Partial<T> => {
+  return pickBy(obj, value => value !== '') as Partial<T>
+}