@yorha2b-lab/autodev 2.1.6 → 2.1.8
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/package.json
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { useState } from 'react'
|
|
1
2
|
import { MyTable } from './MyTable'
|
|
2
3
|
import { Modal, Space, Button } from 'antd'
|
|
3
4
|
import { MySearchForm } from './MySearchForm'
|
|
@@ -6,6 +7,8 @@ import { useTableQuery } from '../hooks/useTableQuery'
|
|
|
6
7
|
|
|
7
8
|
export const MyModalTable = ({ api, onOk, title, width, footer, visible, columns, setModal, formItems, rowSelection, formatResponse, functionButtons, extraParams = {} }) => {
|
|
8
9
|
|
|
10
|
+
const [pending, setPending] = useState(false)
|
|
11
|
+
|
|
9
12
|
const { total, loading, dataSource, search, setSearch } = useTableQuery(api, formatResponse, extraParams)
|
|
10
13
|
|
|
11
14
|
const handleSearch = values => setSearch({ ...search, ...values, pageNo: 1 })
|
|
@@ -14,13 +17,19 @@ export const MyModalTable = ({ api, onOk, title, width, footer, visible, columns
|
|
|
14
17
|
|
|
15
18
|
const handleOk = () => {
|
|
16
19
|
if (onOk) {
|
|
17
|
-
|
|
20
|
+
try {
|
|
21
|
+
setPending(true)
|
|
22
|
+
onOk()
|
|
23
|
+
setPending(false)
|
|
24
|
+
} catch (error) {
|
|
25
|
+
console.log('操作失败:', error)
|
|
26
|
+
}
|
|
18
27
|
}
|
|
19
28
|
setModal({ visible: false })
|
|
20
29
|
}
|
|
21
30
|
|
|
22
31
|
return (
|
|
23
|
-
<Modal centered destroyOnClose title={title} width={width} open={visible} onOk={handleOk} footer={footer} onCancel={() => setModal({ visible: false })}>
|
|
32
|
+
<Modal centered destroyOnClose title={title} width={width} open={visible} onOk={handleOk} footer={footer} onCancel={() => setModal({ visible: false })} confirmLoading={pending}>
|
|
24
33
|
{formItems?.length > 0 && <MySearchForm search={search} formItems={formItems} setSearch={handleSearch} syncUrlParams={false} />}
|
|
25
34
|
{functionButtons?.length > 0 && <Space>{functionButtons.map(item => <Button key={item.name} type={item.type} onClick={item.onClick}>{item.name}</Button>)}</Space>}
|
|
26
35
|
<MyTable
|
|
@@ -3,13 +3,15 @@ import { useState, useEffect } from 'react'
|
|
|
3
3
|
import { UploadOutlined } from '@ant-design/icons'
|
|
4
4
|
import { Button, Tree, Radio, Input, Upload, Select, Cascader, Checkbox, DatePicker, InputNumber, TreeSelect, AutoComplete } from 'antd'
|
|
5
5
|
|
|
6
|
-
const AliyunOSSUpload = ({
|
|
6
|
+
const AliyunOSSUpload = ({ value, onChange, ...restProps }) => {
|
|
7
7
|
|
|
8
|
-
const
|
|
8
|
+
const { oss, url, path, options, ...originUploadProps } = restProps
|
|
9
|
+
|
|
10
|
+
const [OSSData, setOSSData] = useState(oss)
|
|
9
11
|
|
|
10
12
|
const init = async () => {
|
|
11
13
|
try {
|
|
12
|
-
const result = await initOSS()
|
|
14
|
+
const result = await initOSS(url, options)
|
|
13
15
|
setOSSData(result)
|
|
14
16
|
} catch (err) {
|
|
15
17
|
console.log(err)
|
|
@@ -17,7 +19,9 @@ const AliyunOSSUpload = ({ path, style, value, disabled, onChange }) => {
|
|
|
17
19
|
}
|
|
18
20
|
|
|
19
21
|
useEffect(() => {
|
|
20
|
-
|
|
22
|
+
if (!OSSData) {
|
|
23
|
+
init()
|
|
24
|
+
}
|
|
21
25
|
}, [])
|
|
22
26
|
|
|
23
27
|
const handleChange = ({ fileList }) => onChange?.([...fileList])
|
|
@@ -36,14 +40,11 @@ const AliyunOSSUpload = ({ path, style, value, disabled, onChange }) => {
|
|
|
36
40
|
})
|
|
37
41
|
|
|
38
42
|
const beforeUpload = async file => {
|
|
39
|
-
if (!OSSData) {
|
|
40
|
-
return false
|
|
41
|
-
}
|
|
42
43
|
const expire = Number(OSSData.expire) * 1000
|
|
43
44
|
if (expire < Date.now()) {
|
|
44
45
|
await init()
|
|
45
46
|
}
|
|
46
|
-
file.url = `${OSSData
|
|
47
|
+
file.url = `${OSSData?.dir ?? path}/${file.uid}_${file.name}`.replace(/\/\//g, '/')
|
|
47
48
|
return file
|
|
48
49
|
}
|
|
49
50
|
|
|
@@ -55,10 +56,11 @@ const AliyunOSSUpload = ({ path, style, value, disabled, onChange }) => {
|
|
|
55
56
|
data: getExtraData,
|
|
56
57
|
action: OSSData?.host,
|
|
57
58
|
onChange: handleChange,
|
|
59
|
+
...originUploadProps
|
|
58
60
|
}
|
|
59
61
|
|
|
60
62
|
return (
|
|
61
|
-
<Upload {...uploadProps}
|
|
63
|
+
<Upload {...uploadProps}>
|
|
62
64
|
<Button icon={<UploadOutlined />}>选择文件</Button>
|
|
63
65
|
</Upload>
|
|
64
66
|
)
|
|
@@ -3,6 +3,16 @@ import { request } from './request'
|
|
|
3
3
|
|
|
4
4
|
//常用工具函数,使用前确保已安装对应模块
|
|
5
5
|
|
|
6
|
+
export const parseExcel = async file => {
|
|
7
|
+
/* const arrayBuffer = await file.arrayBuffer()
|
|
8
|
+
const XLSX = require('xlsx')
|
|
9
|
+
const workbook = XLSX.read(arrayBuffer, { type: 'array' })
|
|
10
|
+
const firstSheetName = workbook.SheetNames?.[0]
|
|
11
|
+
const worksheet = workbook.Sheets[firstSheetName]
|
|
12
|
+
const excelData = XLSX.utils.sheet_to_json(worksheet, { header: 1 })
|
|
13
|
+
return excelData.filter(item => item.length > 0) */
|
|
14
|
+
}
|
|
15
|
+
|
|
6
16
|
export const initOSS = async (url, options) => {
|
|
7
17
|
/* const OSS = require('ali-oss')
|
|
8
18
|
const crypto = require('crypto-js')
|
|
@@ -16,7 +26,7 @@ export const initOSS = async (url, options) => {
|
|
|
16
26
|
],
|
|
17
27
|
}))
|
|
18
28
|
const signature = crypto.enc.Base64.stringify(crypto.HmacSHA1(policy, accessKeySecret))
|
|
19
|
-
return { client, policy, signature, ...response?.data } */
|
|
29
|
+
return { client, policy, signature,host: `https://${bucket}.${endpoint.split('//')[1]}`, ...response?.data } */
|
|
20
30
|
}
|
|
21
31
|
|
|
22
32
|
export const formatQuery = (params, formItems) => {
|