Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wisdom-components
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ReactWeb5
wisdom-components
Commits
9df6ec87
Commit
9df6ec87
authored
Sep 09, 2022
by
陈龙
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 实现选择器
parent
5d128a0a
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
64 additions
and
43 deletions
+64
-43
ReportEditForm.js
...omponents/BasicReport/src/ReportsManage/ReportEditForm.js
+15
-1
ReportsManage.js
...components/BasicReport/src/ReportsManage/ReportsManage.js
+3
-2
utils.js
...e-components/BasicReport/src/ReportsManage/utils/utils.js
+46
-40
No files found.
packages/base-components/BasicReport/src/ReportsManage/ReportEditForm.js
View file @
9df6ec87
...
...
@@ -5,13 +5,17 @@
** 菜单参数列表:*变量名*(变量说明,数据类型,是否必填,取值范围)
**/
import
React
,
{
useEffect
,
useState
}
from
'react'
;
import
{
Form
,
Input
,
DatePicker
,
InputNumber
,
Space
,
Row
,
Col
,
Button
,
message
}
from
'antd'
;
import
{
Form
,
Input
,
DatePicker
,
InputNumber
,
Space
,
Row
,
Col
,
Button
,
message
,
Select
}
from
'antd'
;
import
moment
from
'moment'
;
import
{
submitReportData
}
from
'../api/service/report'
;
import
FileUpload
from
'./Components/fileUpload/fileUpload'
;
import
{
reportService
}
from
'../api'
;
import
{
isSelect
,
returnOptions
}
from
'./utils/utils'
;
const
{
Option
}
=
Select
;
// 类型
const
USER_ID
=
window
.
globalConfig
.
userInfo
.
OID
;
const
TEXT_ARRAY
=
[
'文本'
,
'标签'
];
const
DATE_PICKER_ARRAY
=
[
'日期'
];
const
DATE_TIME_PICKER_ARRAY
=
[
'日期时刻'
];
const
DATE_TYPE
=
[
'日期'
,
'日期时刻'
];
// 用来匹配是否需要转为日期对象;
...
...
@@ -60,6 +64,16 @@ const ReportEditForm = ({ reportDetails, reportData, onCancel, reportName, modal
}
else
if
(
FILE_ARRAY
.
includes
(
config
.
type
))
{
return
<
FileUpload
schema
=
{{
renderTo
:
'File'
}}
/>
;
}
else
{
if
(
isSelect
(
config
.
configItems
))
{
let
options
=
returnOptions
(
config
.
configItems
);
if
(
options
)
{
return
<
Select
>
{
options
.
map
(
item
=>
<
Option
value
=
{
item
}
>
{
item
}
<
/Option>
)
}
<
/Select>
;
}
}
return
<
Input
/>
;
}
};
...
...
packages/base-components/BasicReport/src/ReportsManage/ReportsManage.js
View file @
9df6ec87
...
...
@@ -249,6 +249,7 @@ const ReportsManage = (props) => {
const
[
sorterObject
,
setSorterObject
]
=
useState
({});
const
[
detailConfig
,
setDetailConfig
]
=
useState
({
url
:
''
,
type
:
''
,
params
:
{}
});
const
[
controlsHeight
,
setControlsHeight
]
=
useState
(
44
);
const
[
getNewData
,
setGetNewData
]
=
useState
(
false
);
const
menu
=
()
=>
{
const
_item
=
[
{
...
...
@@ -812,7 +813,7 @@ const ReportsManage = (props) => {
.
then
((
res
)
=>
{
if
(
res
.
code
===
0
)
{
message
.
success
(
'删除成功!'
);
getData
(
pagination
);
setGetNewData
(
!
getNewData
);
}
});
},
...
...
@@ -965,7 +966,7 @@ const ReportsManage = (props) => {
},
[
tableHeaderLevel
]);
useEffect
(()
=>
{
if
(
!
isInit
)
getData
(
pagination
);
},
[
timeFrom
,
timeTo
,
sorterObject
,
filterObject
]);
},
[
timeFrom
,
timeTo
,
sorterObject
,
filterObject
,
getNewData
]);
useEffect
(()
=>
{
function
getRefHeight
()
{
if
(
timer
)
clearTimeout
(
timer
);
...
...
packages/base-components/BasicReport/src/ReportsManage/utils/utils.js
View file @
9df6ec87
...
...
@@ -13,18 +13,31 @@ const isArray = (arr) => {
const
hasMoney
=
(
configItems
)
=>
{
if
(
!
configItems
)
return
false
;
let
_items
=
configItems
.
split
(
'|'
);
return
!!
_items
.
find
((
item
)
=>
item
===
'金额'
);
return
!!
_items
.
find
(
item
=>
item
===
'金额'
);
};
const
isSelect
=
(
configItems
)
=>
{
if
(
!
configItems
)
return
false
;
let
_items
=
configItems
.
split
(
'|'
);
return
!!
_items
.
find
(
item
=>
item
===
'renderAsSelect'
);
};
// options=name1[.value1],name2[.value2],name3[.value3];
const
returnOptions
=
(
configItems
)
=>
{
if
(
!
configItems
)
return
false
;
let
_items
=
configItems
.
split
(
'|'
);
let
_options
=
_items
.
find
(
item
=>
item
.
includes
(
'options='
));
if
(
!
_options
)
return
false
;
return
_options
.
replace
(
'options='
,
''
).
split
(
','
);
};
/**
*
@d
escription: 用来在summary中处理数值的配置
*
@p
arams: 参数描述
*
@d
ate: 2022/8/10
*
@a
uthor: ChenLong
*/
*
@D
escription: 用来在summary中处理数值的配置
*
@P
arams: 参数描述
*
@D
ate: 2022/8/10
*
@A
uthor: ChenLong
*
*
/
const
returnHandledNumber
=
(
configItems
,
num
)
=>
{
// 精度、前缀、后缀、倍率
// $_d|_d%|_d*0.0001|金额|0.00
if
(
isNaN
(
Number
(
num
)
))
return
'-'
;
if
(
isNaN
(
num
))
return
'-'
;
if
(
!
configItems
)
return
num
;
num
=
Number
(
num
);
let
_items
=
configItems
.
split
(
'|'
);
...
...
@@ -33,7 +46,7 @@ const returnHandledNumber = (configItems, num) => {
let
template
=
'_d'
;
let
precision
=
0
;
let
rate
=
1
;
_items
.
forEach
(
(
item
)
=>
{
_items
.
forEach
(
item
=>
{
let
_arr
=
[];
if
(
item
.
match
(
/_d
[^\*]
/
))
{
// 后缀
...
...
@@ -48,35 +61,27 @@ const returnHandledNumber = (configItems, num) => {
}
});
// 可能存在NaN的问题
let
final
=
_items
.
includes
(
'金额'
)
?
Number
((
num
*
rate
).
toFixed
(
precision
)).
toLocaleString
()
:
Number
((
num
*
rate
).
toFixed
(
precision
));
let
final
=
_items
.
includes
(
'金额'
)
?
Number
((
num
*
rate
).
toFixed
(
precision
)).
toLocaleString
()
:
Number
((
num
*
rate
).
toFixed
(
precision
));
return
template
.
replace
(
/_d/
,
isString
(
final
)
?
final
:
'-'
);
};
/**
* @description: 返回configItems内配置的默认值、默认模式等等
* @params: 参数描述
* @date: 2022/8/12
* @author: ChenLong
* @params:
* configItems 报表字段的配置 例如 defaultValue=智慧水务
*
*
* defaultDateModel=customer|defaultDateValue=2022-01-01,2022-12-31;
* keysArray
*
*
* 所需要返回的值的key的集合,比如你需要获取configItems中的’defaultValue‘,那么keysArray=['defaultValue'];
* @returns:
* defaultValue 通用参数 默认值
* @Description: 返回configItems内配置的默认值、默认模式等等
* @Params: 参数描述
* @Date: 2022/8/12
* @Author: ChenLong
* @params:
* configItems 报表字段的配置 例如 defaultValue=智慧水务 defaultDateModel=customer|defaultDateValue=2022-01-01,2022-12-31;
* keysArray 所需要返回的值的key的集合,比如你需要获取configItems中的’defaultValue‘,那么keysArray=['defaultValue'];
* @Returns:
* defaultValue 通用参数 默认值
* defaultDateModel 时间参数 默认模式
* defaultDateValue 时间参数 默认时间
*/
*
*
/
const
returnDefaultValueOrConfigs
=
(
configItems
=
''
,
keysArray
=
[])
=>
{
let
_map
=
{};
let
_configItemsArray
=
configItems
.
split
(
'|'
);
keysArray
.
forEach
(
(
key
)
=>
{
_map
[
key
]
=
_configItemsArray
.
find
(
(
item
)
=>
item
.
includes
(
`
${
key
}
=`
))?.
replace
(
`
${
key
}
=`
,
''
);
keysArray
.
forEach
(
key
=>
{
_map
[
key
]
=
_configItemsArray
.
find
(
item
=>
item
.
includes
(
`
${
key
}
=`
))?.
replace
(
`
${
key
}
=`
,
''
);
});
return
_map
;
};
...
...
@@ -91,22 +96,20 @@ function downloadFunc(url, name, target = '_self') {
}
/**
*
@d
escription: 校验文件的名称是否包含特殊字符
*
@p
arams: {Object: File} file file对象 { special:Boolean } 是否去除/的匹配
*
@d
ate: 2021/12/8
*
@a
uthor: ChenLong
*
@returns
{Object} {type: error | success ,content: 提示...}
*/
*
@D
escription: 校验文件的名称是否包含特殊字符
*
@P
arams: {Object: File} file file对象 { special:Boolean } 是否去除/的匹配
*
@D
ate: 2021/12/8
*
@A
uthor: ChenLong
*
@Return
{Object} {type: error | success ,content: 提示...}
*
*
/
function
filenameVerification
(
file
,
special
)
{
// 文件名含有特殊字符 提示不能上传 {+,:/?#[]@!$&\\*+;=}
// 规则对象(flag)
var
flag
=
!
special
?
new
RegExp
(
"[`~!@#$^&*=|{}':;',
\\
[
\\
]/?~!@#¥&*——|{}【】‘;:”“'。,、?]"
)
:
new
RegExp
(
"[`~!@#$^&*=|{}':;',[
\\
]?~!@#¥&*——|{}【】‘;:”“'。,、?]"
);
var
flag
=
!
special
?
new
RegExp
(
'[`~!@#$^&*=|{}
\'
:;
\'
,
\\
[
\\
]/?~!@#¥&*——|{}【】‘;:”“
\'
。,、?]'
)
:
new
RegExp
(
'[`~!@#$^&*=|{}
\'
:;
\'
,[
\\
]?~!@#¥&*——|{}【】‘;:”“
\'
。,、?]'
);
if
(
flag
.
test
(
file
.
name
))
{
return
{
type
:
'error'
,
content
:
`文件名格式错误,请检查文件名是否含有特殊字符
${
"~!@#$^&*=|{}':;',
\\
[
\\
]/?~!@#¥&*——|{}【】‘;:”“'。,、?"
}
`
,
content
:
`文件名格式错误,请检查文件名是否含有特殊字符
${
'~!@#$^&*=|{}
\'
:;
\'
,
\\
[
\\
]/?~!@#¥&*——|{}【】‘;:”“
\'
。,、?'
}
`
,
};
}
return
{
...
...
@@ -125,4 +128,6 @@ export {
returnDefaultValueOrConfigs
,
downloadFunc
,
filenameVerification
,
};
isSelect
,
returnOptions
,
};
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment