@bit-sun/business-component 2.0.17-alpha.1 → 2.0.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.fatherrc.ts +0 -1
- package/dist/components/Functional/ExportFunctions/ExportHistoryDrawer/index.d.ts +2 -0
- package/dist/components/Functional/ExportFunctions/ExportIcon/index.d.ts +7 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.esm.js +239 -2
- package/dist/index.js +240 -0
- package/dist/utils/utils.d.ts +2 -0
- package/package.json +3 -3
- package/src/assets/exportFail.svg +38 -0
- package/src/assets/exportProcessing.svg +29 -0
- package/src/assets/exportSuccess.svg +35 -0
- package/src/assets/exportlogo.png +0 -0
- package/src/assets/upExport.svg +23 -0
- package/src/components/Functional/ExportFunctions/ExportHistoryDrawer/index.less +24 -0
- package/src/components/Functional/ExportFunctions/ExportHistoryDrawer/index.tsx +150 -0
- package/src/components/Functional/ExportFunctions/ExportIcon/index.tsx +44 -0
- package/src/index.ts +2 -0
- package/src/utils/utils.ts +22 -0
- package/dist/index.umd.js +0 -113563
- package/dist/index.umd.min.js +0 -27
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import React, { useEffect, useState } from 'react';
|
|
2
|
+
import {Drawer, Tooltip, Table, Space, Button, message, Popconfirm} from 'antd';
|
|
3
|
+
import upExport from '../../../../assets/upExport.svg';
|
|
4
|
+
import exportProcessing from '../../../../assets/exportProcessing.svg';
|
|
5
|
+
import exportSuccess from '../../../../assets/exportSuccess.svg';
|
|
6
|
+
import exportFail from '../../../../assets/exportFail.svg';
|
|
7
|
+
import styles from './index.less';
|
|
8
|
+
import { downloadExcel, handleCommonTimeRender } from '@/utils/utils';
|
|
9
|
+
import axios from 'axios';
|
|
10
|
+
|
|
11
|
+
const ExportHistoryIcon = () => {
|
|
12
|
+
const [exportHistoryParams, setExportHistoryParams] = useState({
|
|
13
|
+
visible: false,
|
|
14
|
+
title: '导出列表',
|
|
15
|
+
width: '420',
|
|
16
|
+
placement: 'right',
|
|
17
|
+
onClose: () =>
|
|
18
|
+
setExportHistoryParams({
|
|
19
|
+
...exportHistoryParams,
|
|
20
|
+
visible: false,
|
|
21
|
+
}),
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
return (
|
|
25
|
+
<div style={{ cursor: 'pointer' }}>
|
|
26
|
+
<Tooltip title="导出记录">
|
|
27
|
+
<img
|
|
28
|
+
width={24}
|
|
29
|
+
src={upExport}
|
|
30
|
+
onClick={() =>
|
|
31
|
+
setExportHistoryParams({
|
|
32
|
+
...exportHistoryParams,
|
|
33
|
+
visible: true,
|
|
34
|
+
})
|
|
35
|
+
}
|
|
36
|
+
/>
|
|
37
|
+
</Tooltip>
|
|
38
|
+
{exportHistoryParams.visible && (
|
|
39
|
+
<ExportHistoryDrawer {...exportHistoryParams} />
|
|
40
|
+
)}
|
|
41
|
+
</div>
|
|
42
|
+
);
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
const ExportHistoryDrawer = (props: any) => {
|
|
46
|
+
const [dataSource, setDataSource] = useState([]);
|
|
47
|
+
const [pagination, setPagination] = useState({
|
|
48
|
+
current: 1,
|
|
49
|
+
pageSize: 20,
|
|
50
|
+
total: undefined
|
|
51
|
+
})
|
|
52
|
+
const remoteData = (pag?: any) => {
|
|
53
|
+
axios({
|
|
54
|
+
url: '/oms-ops/businessImport',
|
|
55
|
+
method: 'get',
|
|
56
|
+
params: {
|
|
57
|
+
'qp-type-eq': 100,
|
|
58
|
+
currentPage: pag?.current || pagination.current,
|
|
59
|
+
pageSize: pag?.pageSize || pagination.pageSize,
|
|
60
|
+
},
|
|
61
|
+
}).then((result) => {
|
|
62
|
+
setDataSource(result?.data?.data?.items);
|
|
63
|
+
setPagination({
|
|
64
|
+
current: result?.data?.data?.page,
|
|
65
|
+
pageSize:result?.data?.data?.size,
|
|
66
|
+
total: result?.data?.data?.total
|
|
67
|
+
})
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
useEffect(() => {
|
|
72
|
+
remoteData()
|
|
73
|
+
}, []);
|
|
74
|
+
const columns = [
|
|
75
|
+
{
|
|
76
|
+
title: false,
|
|
77
|
+
key: 'name',
|
|
78
|
+
dataIndex: 'name',
|
|
79
|
+
render: (text: any, record: any) => {
|
|
80
|
+
const { importStatus, createTime } = record;
|
|
81
|
+
let resultIcon;
|
|
82
|
+
switch (importStatus) {
|
|
83
|
+
case '10':
|
|
84
|
+
resultIcon = <img src={exportProcessing} />;
|
|
85
|
+
break;
|
|
86
|
+
case '20':
|
|
87
|
+
resultIcon = <img src={exportSuccess} />;
|
|
88
|
+
break;
|
|
89
|
+
case '30':
|
|
90
|
+
resultIcon = <img src={exportFail} />;
|
|
91
|
+
}
|
|
92
|
+
return (
|
|
93
|
+
<div style={{ display: 'flex' }}>
|
|
94
|
+
<div className={styles.pictureWrap}>{resultIcon}</div>
|
|
95
|
+
<div style={{ marginLeft: '4px' }}>
|
|
96
|
+
<div style={{ fontSize: '14px', marginBottom: '-3px' }}>
|
|
97
|
+
{text}
|
|
98
|
+
</div>
|
|
99
|
+
<div
|
|
100
|
+
style={{
|
|
101
|
+
color: '#BFBFBF',
|
|
102
|
+
fontSize: '12px',
|
|
103
|
+
lineHeight: '16px',
|
|
104
|
+
}}
|
|
105
|
+
>
|
|
106
|
+
{record?.importStatus === '10'
|
|
107
|
+
? '导出进行中...'
|
|
108
|
+
: handleCommonTimeRender(createTime)}
|
|
109
|
+
</div>
|
|
110
|
+
</div>
|
|
111
|
+
</div>
|
|
112
|
+
);
|
|
113
|
+
},
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
title: false,
|
|
117
|
+
dataIndex: '2',
|
|
118
|
+
render: (text: any, record: any) => {
|
|
119
|
+
return (
|
|
120
|
+
<Space>
|
|
121
|
+
{record.importStatus == 20 && <Button style={{padding: 0}} type={'link'} onClick={() => {
|
|
122
|
+
downloadExcel(record.importUrl, record.name, true);
|
|
123
|
+
}}>下载</Button>}
|
|
124
|
+
{record.importStatus !== 10 && <Popconfirm title={'确定要删除吗?'} onConfirm={() => {
|
|
125
|
+
axios({
|
|
126
|
+
url:`/oms-ops/businessImport/${record.id}`,
|
|
127
|
+
method:'DELETE',
|
|
128
|
+
})
|
|
129
|
+
.then((result) => {
|
|
130
|
+
message.success('删除成功')
|
|
131
|
+
remoteData()
|
|
132
|
+
})
|
|
133
|
+
}}>
|
|
134
|
+
<Button style={{padding: 0}} type={'link'} danger={true} >删除</Button>
|
|
135
|
+
</Popconfirm>}
|
|
136
|
+
</Space>
|
|
137
|
+
);
|
|
138
|
+
},
|
|
139
|
+
},
|
|
140
|
+
];
|
|
141
|
+
|
|
142
|
+
return (
|
|
143
|
+
<Drawer {...props} bodyStyle={{ padding: 0 }}>
|
|
144
|
+
<div className={styles.tableWrapper}>
|
|
145
|
+
<Table columns={columns} dataSource={dataSource} pagination={pagination} onChange={remoteData} />
|
|
146
|
+
</div>
|
|
147
|
+
</Drawer>
|
|
148
|
+
);
|
|
149
|
+
};
|
|
150
|
+
export default ExportHistoryIcon;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import React, {Ref} from 'react'
|
|
2
|
+
import {message, Popconfirm, Tooltip} from "antd";
|
|
3
|
+
import axios from 'axios'
|
|
4
|
+
import exportlogo from '../../../../assets/exportlogo.png'
|
|
5
|
+
|
|
6
|
+
interface exportIconType{
|
|
7
|
+
url: string,
|
|
8
|
+
params: any,
|
|
9
|
+
otherParams?: any
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const ExportIcon = ({params, url, otherParams}: exportIconType) => {
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
return (
|
|
16
|
+
<div style={{ cursor: 'pointer' }}>
|
|
17
|
+
<Popconfirm
|
|
18
|
+
title={'确定要导出当前数据吗?'}
|
|
19
|
+
onConfirm={() => {
|
|
20
|
+
axios({
|
|
21
|
+
url,
|
|
22
|
+
method:'POST',
|
|
23
|
+
data:params?.current || params(),
|
|
24
|
+
...otherParams,
|
|
25
|
+
})
|
|
26
|
+
.then((result: any) => {
|
|
27
|
+
result = result.data;
|
|
28
|
+
if (result.code !== '000000') {
|
|
29
|
+
message.error(result?.msg);
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
message.success('任务已排入导出队列')
|
|
33
|
+
})
|
|
34
|
+
}}
|
|
35
|
+
>
|
|
36
|
+
<Tooltip title="导出数据">
|
|
37
|
+
<img width={32} src={exportlogo} />
|
|
38
|
+
</Tooltip>
|
|
39
|
+
</Popconfirm>
|
|
40
|
+
</div>
|
|
41
|
+
)
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export default ExportIcon
|
package/src/index.ts
CHANGED
|
@@ -22,3 +22,5 @@ export { default as TreeSearchSelect } from './components/Functional/TreeSearchS
|
|
|
22
22
|
export { default as BusinessTreeSearchSelect } from './components/Business/TreeSearchSelect';
|
|
23
23
|
export { default as StateFlow } from './components/Business/StateFlow';
|
|
24
24
|
export { default as GuideWrapper } from './components/Business/CommonGuideWrapper';
|
|
25
|
+
export { default as ExportIcon } from './components/Functional/ExportFunctions/ExportIcon'
|
|
26
|
+
export { default as ExportHistoryIcon } from './components/Functional/ExportFunctions/ExportHistoryDrawer'
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import dayjs from 'dayjs'
|
|
2
|
+
|
|
3
|
+
export function downloadExcel(data: any, fileName?: any, isResUrl?: boolean) {
|
|
4
|
+
const resUrl = isResUrl
|
|
5
|
+
? data
|
|
6
|
+
: window.URL.createObjectURL(
|
|
7
|
+
new Blob([data], {
|
|
8
|
+
type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
|
9
|
+
}),
|
|
10
|
+
);
|
|
11
|
+
const save_link = document.createElement('a');
|
|
12
|
+
save_link.href = resUrl;
|
|
13
|
+
if (fileName) {
|
|
14
|
+
save_link.download = fileName; /// 设置下载文件名
|
|
15
|
+
}
|
|
16
|
+
save_link.click();
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function handleCommonTimeRender(text: any, format?: any) {
|
|
20
|
+
const formatType = format || 'YYYY-MM-DD HH:mm:ss';
|
|
21
|
+
return text && dayjs(text).format(formatType);
|
|
22
|
+
}
|