|
@@ -1,16 +1,16 @@
|
|
|
-import React, { useMemo } from 'react'
|
|
|
|
|
|
|
+import React, { useMemo, useState } from 'react'
|
|
|
import styles from './index.module.scss'
|
|
import styles from './index.module.scss'
|
|
|
import { authorityFu } from '@/utils/authority'
|
|
import { authorityFu } from '@/utils/authority'
|
|
|
-import { selectObj, getDictFu } from '@/utils/dataChange'
|
|
|
|
|
|
|
+import { selectObj, getDictFu, resJiLianFu } from '@/utils/dataChange'
|
|
|
import history, { openLink } from '@/utils/history'
|
|
import history, { openLink } from '@/utils/history'
|
|
|
import TableList from '@/pages/Zother/TableList'
|
|
import TableList from '@/pages/Zother/TableList'
|
|
|
import { useSelector } from 'react-redux'
|
|
import { useSelector } from 'react-redux'
|
|
|
import { RootState } from '@/store'
|
|
import { RootState } from '@/store'
|
|
|
-import { API_getGoodsList } from '@/store/action/Cledger/C1ledger'
|
|
|
|
|
|
|
+import { API_getGoodsList, API_getGoodsListAll } from '@/store/action/Cledger/C1ledger'
|
|
|
import { baseFormData } from '@/pages/Zother/data'
|
|
import { baseFormData } from '@/pages/Zother/data'
|
|
|
import { goodsSonTableC } from '@/utils/tableData'
|
|
import { goodsSonTableC } from '@/utils/tableData'
|
|
|
-import { Button, Dropdown } from 'antd'
|
|
|
|
|
-
|
|
|
|
|
|
|
+import { Button, Dropdown, Modal, Radio, Checkbox } from 'antd'
|
|
|
|
|
+import { exportExcelFile } from '@/utils/xlsxExport'
|
|
|
const C1topSearch = [
|
|
const C1topSearch = [
|
|
|
{
|
|
{
|
|
|
type: 'input',
|
|
type: 'input',
|
|
@@ -61,13 +61,13 @@ const C1topSearch = [
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
|
type: 'select',
|
|
type: 'select',
|
|
|
- key: 'xxx',
|
|
|
|
|
|
|
+ key: 'siteStatus',
|
|
|
placeholder: '库存状态',
|
|
placeholder: '库存状态',
|
|
|
options: selectObj['藏品库存状态']
|
|
options: selectObj['藏品库存状态']
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
|
type: 'select',
|
|
type: 'select',
|
|
|
- key: 'xxxx',
|
|
|
|
|
|
|
+ key: 'siteLoc',
|
|
|
placeholder: `搜索库房位置`
|
|
placeholder: `搜索库房位置`
|
|
|
}
|
|
}
|
|
|
]
|
|
]
|
|
@@ -82,10 +82,66 @@ const C1baseFormData = {
|
|
|
const columnsTempAdd = [
|
|
const columnsTempAdd = [
|
|
|
...goodsSonTableC(false),
|
|
...goodsSonTableC(false),
|
|
|
['select', '入藏状态', 'status', selectObj['藏品入藏状态']],
|
|
['select', '入藏状态', 'status', selectObj['藏品入藏状态']],
|
|
|
- ['txt', '库存状态', 'xxx'],
|
|
|
|
|
- ['txt', '库房位置', 'xxx']
|
|
|
|
|
|
|
+ ['txt', '库存状态', 'siteStatus'],
|
|
|
|
|
+ ['txt', '库房位置', 'siteLoc']
|
|
|
]
|
|
]
|
|
|
|
|
|
|
|
|
|
+const ExportModal = ({
|
|
|
|
|
+ open,
|
|
|
|
|
+ availableYears,
|
|
|
|
|
+ onConfirm,
|
|
|
|
|
+ onCancel
|
|
|
|
|
+}: {
|
|
|
|
|
+ open: boolean
|
|
|
|
|
+ availableYears: number[] | string[]
|
|
|
|
|
+ onConfirm: (exportType: number, years: number[]) => void
|
|
|
|
|
+ onCancel: () => void
|
|
|
|
|
+}) => {
|
|
|
|
|
+ const [exportValue, setExportValue] = useState<number>(1)
|
|
|
|
|
+ const [selectedYears, setSelectedYears] = useState<number[]>([])
|
|
|
|
|
+
|
|
|
|
|
+ const onExportTypeChange = (e: any) => {
|
|
|
|
|
+ setExportValue(e.target.value)
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return (
|
|
|
|
|
+ <Modal
|
|
|
|
|
+ title='数据导出'
|
|
|
|
|
+ open={open}
|
|
|
|
|
+ onOk={() => onConfirm(exportValue, selectedYears)}
|
|
|
|
|
+ onCancel={onCancel}
|
|
|
|
|
+ okText='导出'
|
|
|
|
|
+ cancelText='取消'
|
|
|
|
|
+ >
|
|
|
|
|
+ <span style={{ marginBottom: 16 }}>导出范围:</span>
|
|
|
|
|
+
|
|
|
|
|
+ <Radio.Group
|
|
|
|
|
+ onChange={onExportTypeChange}
|
|
|
|
|
+ value={exportValue}
|
|
|
|
|
+ options={[
|
|
|
|
|
+ { value: 1, label: '所有年份' },
|
|
|
|
|
+ { value: 2, label: '按年份' }
|
|
|
|
|
+ ]}
|
|
|
|
|
+ />
|
|
|
|
|
+
|
|
|
|
|
+ {exportValue === 2 && (
|
|
|
|
|
+ <div style={{ marginTop: 24 }}>
|
|
|
|
|
+ <Checkbox.Group
|
|
|
|
|
+ style={{ flexDirection: 'column', gap: '5px' }}
|
|
|
|
|
+ options={availableYears.map(year => ({
|
|
|
|
|
+ label: `${year}年`,
|
|
|
|
|
+ value: year
|
|
|
|
|
+ }))}
|
|
|
|
|
+ value={selectedYears}
|
|
|
|
|
+ onChange={checkedValues => setSelectedYears(checkedValues as number[])}
|
|
|
|
|
+ />
|
|
|
|
|
+ <div style={{ opacity: '0.5', marginTop: '10px' }}>上述年份为藏品制档日期所在年份</div>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ )}
|
|
|
|
|
+ </Modal>
|
|
|
|
|
+ )
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
function C1ledger() {
|
|
function C1ledger() {
|
|
|
const tableInfo = useSelector((state: RootState) => state.C1ledger.tableInfo)
|
|
const tableInfo = useSelector((state: RootState) => state.C1ledger.tableInfo)
|
|
|
|
|
|
|
@@ -160,8 +216,62 @@ function C1ledger() {
|
|
|
}
|
|
}
|
|
|
}, [])
|
|
}, [])
|
|
|
|
|
|
|
|
- const dataExport = () => {
|
|
|
|
|
- console.log('数据导出了')
|
|
|
|
|
|
|
+ const [allData, setAllData] = useState([])
|
|
|
|
|
+ const [isModalOpen, setIsModalOpen] = useState(false)
|
|
|
|
|
+ const [availableYears, setAvailableYears] = useState<any>([])
|
|
|
|
|
+ const showModal = async () => {
|
|
|
|
|
+ setIsModalOpen(true)
|
|
|
|
|
+ const res = await API_getGoodsListAll()
|
|
|
|
|
+ setAllData(res.data.records)
|
|
|
|
|
+ //获取年份信息
|
|
|
|
|
+ const years = Array.from(
|
|
|
|
|
+ new Set(
|
|
|
|
|
+ res.data.records
|
|
|
|
|
+ .map((item: any) => item.createTime?.slice(0, 4))
|
|
|
|
|
+ .filter(Boolean) as string[]
|
|
|
|
|
+ )
|
|
|
|
|
+ ).sort((a, b) => Number(b) - Number(a))
|
|
|
|
|
+ setAvailableYears(years)
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ const dataExport = async (exportType: number = 1, years: number[] = []) => {
|
|
|
|
|
+ // 根据导出范围筛选数据:
|
|
|
|
|
+ // exportType === 1:所有年份,不做筛选
|
|
|
|
|
+ // exportType === 2:按年份,只保留所选年份的数据
|
|
|
|
|
+ const filteredData =
|
|
|
|
|
+ exportType === 2 && years.length
|
|
|
|
|
+ ? allData.filter((item: any) => {
|
|
|
|
|
+ if (!item.createTime) return false
|
|
|
|
|
+ const yearStr = item.createTime.slice(0, 4)
|
|
|
|
|
+ const yearNum = yearStr
|
|
|
|
|
+ return years.includes(yearNum)
|
|
|
|
|
+ })
|
|
|
|
|
+ : allData
|
|
|
|
|
+
|
|
|
|
|
+ const listData = filteredData.map((item: any) => {
|
|
|
|
|
+ return {
|
|
|
|
|
+ 藏品登记号: item.num,
|
|
|
|
|
+ 封面: item.thumb,
|
|
|
|
|
+ 藏品标签: item.tagDictId,
|
|
|
|
|
+ 藏品名称: item.name,
|
|
|
|
|
+ 级别: item.level,
|
|
|
|
|
+ 类别: resJiLianFu(item.typeDictId),
|
|
|
|
|
+ 年代: resJiLianFu(item.ageDictId),
|
|
|
|
|
+ 质地: resJiLianFu(item.textureDictId),
|
|
|
|
|
+ 完残程度: item.tornLevel,
|
|
|
|
|
+ 数量: item.pcs,
|
|
|
|
|
+ 入藏状态: item.status,
|
|
|
|
|
+ 库存状态: item.siteStatus,
|
|
|
|
|
+ 库房位置: item.siteLoc
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+ console.log(years)
|
|
|
|
|
+ exportExcelFile(
|
|
|
|
|
+ listData,
|
|
|
|
|
+ [100, 100, 100, 100, 100, 200, 200, 200, 100, 100, 100, 100, 100],
|
|
|
|
|
+ '藏品总账数据'
|
|
|
|
|
+ )
|
|
|
|
|
+ setIsModalOpen(false)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 故事管理/藏品总账定制右侧内容
|
|
// 故事管理/藏品总账定制右侧内容
|
|
@@ -183,12 +293,18 @@ function C1ledger() {
|
|
|
<Dropdown menu={{ items: rightBtnOptions['weihu'] }} trigger={['click']}>
|
|
<Dropdown menu={{ items: rightBtnOptions['weihu'] }} trigger={['click']}>
|
|
|
<Button type='primary'>藏品维护</Button>
|
|
<Button type='primary'>藏品维护</Button>
|
|
|
</Dropdown>
|
|
</Dropdown>
|
|
|
- <Button type='primary' onClick={dataExport}>
|
|
|
|
|
|
|
+ <Button type='primary' onClick={() => console.log(123)}>
|
|
|
数据导入
|
|
数据导入
|
|
|
</Button>
|
|
</Button>
|
|
|
- <Button type='primary' onClick={dataExport}>
|
|
|
|
|
|
|
+ <Button type='primary' onClick={showModal}>
|
|
|
数据导出
|
|
数据导出
|
|
|
</Button>
|
|
</Button>
|
|
|
|
|
+ <ExportModal
|
|
|
|
|
+ open={isModalOpen}
|
|
|
|
|
+ availableYears={availableYears}
|
|
|
|
|
+ onConfirm={dataExport}
|
|
|
|
|
+ onCancel={() => setIsModalOpen(false)}
|
|
|
|
|
+ />
|
|
|
<Button type='primary' onClick={clickSearch}>
|
|
<Button type='primary' onClick={clickSearch}>
|
|
|
查询
|
|
查询
|
|
|
</Button>
|
|
</Button>
|