Commit 13bb554c authored by 田翔's avatar 田翔

fix: 增加其他操作的功能

parent 5c3f3727
......@@ -268,6 +268,22 @@ export function DeleteTableDataInfo(data) {
});
}
//导出数据
export function ExportAccountData({ accountName, ids, exportAll }) {
return request({
url: `${BASEURL}/ExportAccountData?accountName=${accountName}&ids=${ids}&exportAll=${exportAll}`,
method: 'get',
});
}
//导出模板
export function ExportAccountModel({ accountName, exportAll }) {
return request({
url: `${BASEURL}/ExportAccountData?accountName=${accountName}&exportAll=${exportAll}`,
method: 'get',
});
}
//获取数据字典
export function GetDataDictionaryList(params) {
return request({
......
import React, { useCallback, useEffect, useMemo, useRef, useState, forwardRef, useImperativeHandle } from 'react';
import {
Row,
DatePicker,
Select,
Button,
Input,
Tooltip,
Space,
Popconfirm,
message,
Upload,
ConfigProvider,
Modal,
Image,
Dropdown,
Menu,
Popover,
Form,
} from 'antd';
import 'dayjs/locale/zh-cn';
import locale from 'antd/es/date-picker/locale/zh_CN';
import {
SnippetsOutlined,
PlusOutlined,
FormOutlined,
DeleteOutlined,
ImportOutlined,
ExportOutlined,
FileZipOutlined,
FileImageOutlined,
CustomerServiceOutlined,
VideoCameraOutlined,
ExclamationCircleOutlined,
QuestionCircleOutlined,
EditOutlined,
DownOutlined,
} from '@ant-design/icons';
import styles from './search.less';
import moment from 'moment';
import React, { useMemo, useState, forwardRef, useImperativeHandle } from 'react'
import { Row, DatePicker, Select, Button, Input, message, Upload, Dropdown, Menu, Form } from 'antd'
import 'dayjs/locale/zh-cn'
import locale from 'antd/es/date-picker/locale/zh_CN'
import { PlusOutlined, DeleteOutlined, ImportOutlined, ExportOutlined, QuestionCircleOutlined, EditOutlined, DownOutlined } from '@ant-design/icons'
import styles from './search.less'
import moment from 'moment'
const { Search } = Input;
const { RangePicker } = DatePicker;
const { Option } = Select;
const dateFormat = 'YYYY-MM-DD';
const SearchGroup = forwardRef((props, ref) => {
......@@ -154,6 +120,112 @@ const SearchGroup = forwardRef((props, ref) => {
};
}, [])
const uploadProps = {
action: `${window.location.origin}${'/PandaWorkFlow/WorkFlow/AccountManage/ImportAccountData'}`,
multiple: false,
showUploadList: false,
headers: {
'Content-Type': 'multipart/form-data',
},
withCredentials: true,
customRequest({ action, file, headers, withCredentials }) {
const formData = new FormData();
formData.append('file', file);
const _data = { accountName };
if (checkName) {
_data.checkName = checkName;
}
// 默认开启检查全部字段
_data.isCheck = true;
importAccountData(
{
headers: {
'Content-Type': 'multipart/form-data',
},
},
{ ..._data },
formData,
).then(res => {
if (res.code === 0) {
message.success('导入成功!');
getAccountData();
} else {
message.warning(res.msg);
}
});
},
};
const otherMenu = [
{
label: (
<Upload {...uploadProps}>
<Button style={{ width: '170px', textAlign: 'left' }} size='middle' icon={<ImportOutlined />} type='text'>
导入
</Button>
</Upload>
),
key: 'uploadBtn',
},
{
label: (
<Button
style={{ width: '100%', textAlign: 'left' }}
size='middle'
type='text'
onClick={() => btnsClick('导出模板')}
icon={<ExportOutlined />}
>
导出模板
</Button>
),
key: '导出模板',
},
{
label: (
<Button
style={{ width: '100%', textAlign: 'left' }}
size='middle'
type='text'
onClick={() => btnsClick('导出全字段模板')}
icon={<ExportOutlined />}
>
导出全字段模板 <QuestionCircleOutlined style={{ fontSize: 10 }} title='导出整张台账表字段' />
</Button>
),
key: '导出全字段模板',
},
{
label: (
<Button
style={{ width: '100%', textAlign: 'left' }}
size='middle'
type='text'
onClick={() => btnsClick('导出数据')}
icon={<ExportOutlined />}
>
导出数据
</Button>
),
key: '导出数据',
},
{
label: (
<Button
style={{ width: '100%', textAlign: 'left' }}
size='middle'
type='text'
onClick={() => btnsClick('导出全字段数据')}
icon={<ExportOutlined />}
>
导出全字段数据
<QuestionCircleOutlined style={{ fontSize: 10, color: 'red' }} title='导出整张表全字段数据,数据量大时可能导致崩溃,请按需谨慎使用!' />
</Button>
),
key: '导出全字段数据',
}
]
const batchMenu = [
{
label: (
......@@ -183,7 +255,7 @@ const SearchGroup = forwardRef((props, ref) => {
),
key: '批量修改',
}
];
]
const onSearch = e => {
setQueryInfo({ ...queryInfo, info: e });
......@@ -229,7 +301,6 @@ const SearchGroup = forwardRef((props, ref) => {
ranges={{ ...rangerOptions }}
format={formatterStr}
style={{ width: 300 }}
// onChange={dateChange}
/>
</Form.Item>
) : null
......@@ -255,6 +326,17 @@ const SearchGroup = forwardRef((props, ref) => {
{/* 按钮区域 */}
<div className={styles.controlRowRight}>
<div className={styles.controlBtns}>
{
!readOnly ? (
<Dropdown.Button
style={{ marginLeft: '20px' }}
icon={<DownOutlined />}
overlay={<Menu items={otherMenu} />}
>
其他操作
</Dropdown.Button>
) : null
}
{
!readOnly ? (
<Dropdown.Button
......
......@@ -8,11 +8,12 @@ import BatchEdit from './components/BatchEdit'
import {
GetAccountConfigInfo,
GetAccountPageList,
getStationListByUserID,
GetTableDataInfo,
EditTableDataInfo,
SaveTableDataInfo,
DeleteTableDataInfo,
ExportAccountData,
ExportAccountModel,
} from '../../apis/process'
import { isJson, isObject } from '../../utils/index'
import FormRender from '../FormRender'
......@@ -105,6 +106,66 @@ const Account = (props) => {
}
batchEditRef.current.open({ accountTable: accountName, id: keys.join(','), })
}
if (['导出数据', '导出全字段数据'].includes(type)) {
exportData({ exportAll: type === '导出全字段数据' })
}
if (['导出模板', '导出全字段模板'].includes(type)) {
exportTemplate({ exportAll: type === '导出全字段模板' })
}
}
const exportData = ({ exportAll }) => {
Modal.confirm({
icon: <ExclamationCircleOutlined />,
content: keys.length > 0 ? `共选择${keys.length}条数据,确定要导出吗` : '确定要导出全部数据吗?',
onOk: async () => {
return await new Promise(async (resolve, reject) => {
let res = await ExportAccountData({ accountName: accountName, ids: keys.join(','), exportAll })
if (res && res.code === -1) {
message.error(res.msg)
reject()
} else {
const url = window.URL.createObjectURL(new Blob([res]))
const a = document.createElement('a')
a.href = url
a.target = '_blank'
a.download = '数据文件.xls'
a.click()
a.remove()
resolve()
}
})
},
okText: '确定',
cancelText: '取消',
})
}
const exportTemplate = ({ exportAll }) => {
Modal.confirm({
icon: <ExclamationCircleOutlined />,
content: keys.length > 0 ? `共选择${keys.length}条数据,确定要导出吗` : '确定要导出全部数据吗?',
onOk: async () => {
return await new Promise(async (resolve, reject) => {
let res = await ExportAccountModel({ accountName: accountName, exportAll })
if (res && res.code === -1) {
message.error(res.msg)
reject()
} else {
const url = window.URL.createObjectURL(new Blob([res]))
const a = document.createElement('a')
a.href = url
a.target = '_blank'
a.download = '数据文件.xls'
a.click()
a.remove()
resolve()
}
})
},
okText: '确定',
cancelText: '取消',
})
}
const saveClick = (addField, formJson, values, type) => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment