|
@@ -7,7 +7,7 @@ import { getKuListByOpenFu } from '@/pages/Zother/data'
|
|
|
import { ziyuanAcGet, ziyuanAcSet } from '@/utils/storage'
|
|
import { ziyuanAcGet, ziyuanAcSet } from '@/utils/storage'
|
|
|
import { APIdelTable, APIdownXlsx, B1_APIgetList } from '@/store/action/Bresource/B1overview'
|
|
import { APIdelTable, APIdownXlsx, B1_APIgetList } from '@/store/action/Bresource/B1overview'
|
|
|
import { RootState } from '@/store'
|
|
import { RootState } from '@/store'
|
|
|
-import { Button, Cascader, Input, Select } from 'antd'
|
|
|
|
|
|
|
+import { Button, Cascader, Input, Select, message } from 'antd'
|
|
|
import { Z1_APIgetFormZiDuan } from '@/store/action/Zsystem/Z1sysSet'
|
|
import { Z1_APIgetFormZiDuan } from '@/store/action/Zsystem/Z1sysSet'
|
|
|
import { baseFormType } from '@/pages/Zsystem/Z1sysSet/data'
|
|
import { baseFormType } from '@/pages/Zsystem/Z1sysSet/data'
|
|
|
import { treeOneIdByResFu } from '@/pages/Zother/Z1formSet/data'
|
|
import { treeOneIdByResFu } from '@/pages/Zother/Z1formSet/data'
|
|
@@ -16,7 +16,7 @@ import { MessageFu } from '@/utils/message'
|
|
|
import Z0sonTable from '@/components/Z0sonTable'
|
|
import Z0sonTable from '@/components/Z0sonTable'
|
|
|
import { openLink } from '@/utils/history'
|
|
import { openLink } from '@/utils/history'
|
|
|
import MyPopconfirm from '@/components/MyPopconfirm'
|
|
import MyPopconfirm from '@/components/MyPopconfirm'
|
|
|
-import { downloadFileByUrl } from '@/utils'
|
|
|
|
|
|
|
+import { downloadFileByUrl, transformTableDataForExport, downloadExcel } from '@/utils'
|
|
|
function B1overview() {
|
|
function B1overview() {
|
|
|
const [kuList, setKuList] = useState<antdSelectType[]>([])
|
|
const [kuList, setKuList] = useState<antdSelectType[]>([])
|
|
|
|
|
|
|
@@ -160,7 +160,7 @@ function B1overview() {
|
|
|
{
|
|
{
|
|
|
title: '入库状态',
|
|
title: '入库状态',
|
|
|
width: 100,
|
|
width: 100,
|
|
|
- render: (item: any) => tableSelectToTxt(item.status_storage, selectObj['入库状态'])
|
|
|
|
|
|
|
+ render: (item: any) => tableSelectToTxt(item.status_storage, selectObj['入库状态'], '入库')
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
|
title: '发布状态',
|
|
title: '发布状态',
|
|
@@ -215,6 +215,11 @@ function B1overview() {
|
|
|
|
|
|
|
|
// 点击数据导出
|
|
// 点击数据导出
|
|
|
const deriveFu = useCallback(async () => {
|
|
const deriveFu = useCallback(async () => {
|
|
|
|
|
+ if (!formZi.length) {
|
|
|
|
|
+ MessageFu.warning('请先获取表单字段')
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
const obj = {
|
|
const obj = {
|
|
|
...formDataOldRef.current,
|
|
...formDataOldRef.current,
|
|
|
pageNum: 1,
|
|
pageNum: 1,
|
|
@@ -230,12 +235,29 @@ function B1overview() {
|
|
|
|
|
|
|
|
obj.dictQuery = sonObj
|
|
obj.dictQuery = sonObj
|
|
|
|
|
|
|
|
|
|
+ const hideLoading = message.loading('正在导出...', 0)
|
|
|
const res = await B1_APIgetList(obj, true)
|
|
const res = await B1_APIgetList(obj, true)
|
|
|
|
|
+ hideLoading()
|
|
|
|
|
+
|
|
|
if (res.code === 0) {
|
|
if (res.code === 0) {
|
|
|
const list = res.data.records || []
|
|
const list = res.data.records || []
|
|
|
- console.log('-----------', list)
|
|
|
|
|
|
|
+ if (!list.length) {
|
|
|
|
|
+ MessageFu.warning('没有可导出的数据')
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 转换数据为导出格式
|
|
|
|
|
+ const { headers, data } = transformTableDataForExport(list, formZi, selectObj)
|
|
|
|
|
+
|
|
|
|
|
+ // 获取文件名(使用资源库名称)
|
|
|
|
|
+ const kuObj = kuList.find(v => v.value === formData.formDefId)
|
|
|
|
|
+ const fileName = kuObj ? `${kuObj.label}-数据导出` : '数据导出'
|
|
|
|
|
+
|
|
|
|
|
+ // 下载 Excel 文件
|
|
|
|
|
+ downloadExcel(headers, data, fileName)
|
|
|
|
|
+ MessageFu.success('导出成功')
|
|
|
}
|
|
}
|
|
|
- }, [])
|
|
|
|
|
|
|
+ }, [formZi, formData.formDefId, kuList])
|
|
|
|
|
|
|
|
return (
|
|
return (
|
|
|
<div className={styles.B1overview}>
|
|
<div className={styles.B1overview}>
|