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
437dd7ca
Commit
437dd7ca
authored
Sep 05, 2022
by
陈龙
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 新增大量功能
parent
34c8f109
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
576 additions
and
70 deletions
+576
-70
CustomerColorPicker.js
...age/Components/customerColorPicker/CustomerColorPicker.js
+30
-0
CustomerColorPicker.less
...e/Components/customerColorPicker/CustomerColorPicker.less
+26
-0
fileUpload.js
...ort/src/ReportsManage/Components/fileUpload/fileUpload.js
+222
-0
fileUpload.less
...t/src/ReportsManage/Components/fileUpload/fileUpload.less
+25
-0
ReportEditForm.js
...omponents/BasicReport/src/ReportsManage/ReportEditForm.js
+121
-58
ReportsManage.js
...components/BasicReport/src/ReportsManage/ReportsManage.js
+0
-0
ReportsSetting.js
...omponents/BasicReport/src/ReportsManage/ReportsSetting.js
+0
-0
constant.js
...omponents/BasicReport/src/ReportsManage/utils/constant.js
+23
-0
handlers.js
...omponents/BasicReport/src/ReportsManage/utils/handlers.js
+22
-12
utils.js
...e-components/BasicReport/src/ReportsManage/utils/utils.js
+42
-0
report.js
...ges/base-components/BasicReport/src/api/service/report.js
+65
-0
No files found.
packages/base-components/BasicReport/src/ReportsManage/Components/customerColorPicker/CustomerColorPicker.js
0 → 100644
View file @
437dd7ca
/*
** 自定义取色板
** create by ChenLong on 2022/8/23
** 功能路径:src\pages\product\ReportsManage\Components\CustomerColorPicker.js
** 菜单参数列表:*变量名*(变量说明,数据类型,是否必填,取值范围)
**/
import
React
from
'react'
;
import
style
from
'./CustomerColorPicker.less'
;
import
{
tagColors
,
tagBackgroundColors
}
from
'../../utils/constant'
;
import
classnames
from
'classnames'
;
const
CustomerColorPicker
=
(
props
)
=>
{
return
(
<
div
className
=
{
style
.
colorPickerWrapper
}
>
{
tagColors
.
map
((
color
,
index
)
=>
(
<
div
className
=
{
classnames
(
style
.
colorCard
)}
onClick
=
{()
=>
props
.
clickColorPicker
(
tagBackgroundColors
[
index
])}
style
=
{{
color
:
color
,
backgroundColor
:
tagBackgroundColors
[
index
],
}}
>
A
<
/div
>
))}
<
/div
>
);
};
export
default
CustomerColorPicker
;
packages/base-components/BasicReport/src/ReportsManage/Components/customerColorPicker/CustomerColorPicker.less
0 → 100644
View file @
437dd7ca
@import '~antd/es/style/themes/default.less';
.colorPickerWrapper {
display: flex;
gap: 5px;
width: 330px;
//height: 40px;
padding: 10px;
background: #ffffff;
border: 1px solid rgba(200, 200, 200, 0.85);
border-radius: 4px;
.colorCard {
display: flex;
flex: 0 0 30px;
align-items: center;
justify-content: center;
height: 30px;
font-size: 14px;
&:hover {
font-weight: bold;
font-size: 16px;
box-shadow: #1685ff;
cursor: pointer;
}
}
}
packages/base-components/BasicReport/src/ReportsManage/Components/fileUpload/fileUpload.js
0 → 100644
View file @
437dd7ca
/** @tips: 约定:该控件,获取文件路径字符串或上传了文件(即对应编辑时从接口获取的文件链接和新增时获取的对象),都会将符合要求的对象(上传的文件数据或自行拼接的,必须包含status、type、uid等必要字段)转化为字符串 */
/**
* @description: 合并老版的文件、可预览文件、录音、视频
* @params: 接收参数 renderTo: Recording/Video/File
* @return: {Object} 文件类型返回需要另外处理
* @date: 2021/12/1
* @author: ChenLong
* @待解决问题: 为什么list不直接返回url,而要把file对象变成对象字符串?
*/
/** @tips: 上传业务为:1.通过上传接口,上传文件,获取上传的链接;2.将文件链接存储到服务器,获取存储的地址;3.提交地址 */
/**
* @description: 完成 1.文件名校验;2.编辑界面的文件加载及显示的能力;3.不同类型文件的判断
* @date: 2021/12/2
*/
/**
* @description: 合并图片/可预览图片到文件上传中
* @date: 2021/12/6
*/
/**
* @description: 文件类型单独处理。文件类型返回的是文件对象的字符串,使用JSON.parse解析之后,取url值即可,拼成用逗号分割的字符串即可。这部分修改在入口文件内
* @description: 需要判断值是文件对象的字符串,约定:文件类必须会有 status: 'done'
* @date: 2021/12/8
*/
/** @tips: 裁剪功能在前端框架内无法正常工作,暂不提供裁剪功能 */
// 自定义Form Render组件
import
React
,
{
useState
,
useEffect
}
from
'react'
;
import
{
Upload
,
Button
,
Modal
,
message
}
from
'antd'
;
import
{
UploadOutlined
,
DownloadOutlined
}
from
'@ant-design/icons'
;
import
'./fileUpload.less'
;
import
{
downloadFunc
,
filenameVerification
}
from
'../../utils/utils'
;
import
{
uploadFileUrl
,
downloadFileUrl
}
from
'../../../../../api/service/workflow'
;
const
videoTypeArray
=
[
'.mp4'
];
const
audioTypeArray
=
[
'.mp4'
];
const
fileTypeArray
=
[];
const
imageTypeArray
=
[
'.bmp'
,
'.gif'
,
'.jpeg'
,
'tiff'
,
'.png'
,
'.svg'
,
'.jpg'
];
const
FileUpload
=
({
value
,
onChange
,
schema
})
=>
{
const
_isRecordingOrVideo
=
[
'Recording'
,
'Video'
,
'Image'
].
includes
(
schema
.
renderTo
);
const
_isVideo
=
schema
.
renderTo
===
'Video'
;
const
_isAudio
=
schema
.
renderTo
===
'Recording'
;
const
_isImage
=
schema
.
renderTo
===
'Image'
;
const
[
previewTitle
,
setPreviewTitle
]
=
useState
(
''
);
const
[
previewVisible
,
setPreviewVisible
]
=
useState
(
false
);
const
[
previewUrl
,
setPreviewUrl
]
=
useState
(
''
);
const
[
showList
,
setShowList
]
=
useState
(
''
);
const
file
=
value
||
schema
.
default
;
const
option
=
{
name
:
'file'
,
action
:
`
${
window
.
location
.
origin
}${
uploadFileUrl
}
`
,
listType
:
_isRecordingOrVideo
?
'picture-card'
:
'picture'
,
withCredentials
:
true
,
beforeUpload
(
file
,
fileList
)
{
/** @tips: 解决提交文件中存在特殊字符的问题 */
let
_continueUpload
=
true
;
let
_msg
=
{
type
:
'success'
,
content
:
'上传成功!'
,
};
fileList
.
forEach
((
item
)
=>
{
let
_msgObject
=
filenameVerification
(
item
);
if
(
_msgObject
.
type
===
'error'
)
{
_continueUpload
=
false
;
_msg
=
{
type
:
'error'
,
content
:
'上传失败!文件名不符合规则!'
,
};
}
});
_msg
.
type
===
'error'
?
message
[
_msg
.
type
](
_msg
.
content
)
:
''
;
return
_continueUpload
;
},
onChange
:
({
file
,
fileList
,
event
})
=>
{
// 检验名字,名字不通过不允许显示
if
(
filenameVerification
(
file
).
type
===
'error'
)
return
false
;
// 返回的链接在file.response内;不设置url,预览图表不可点击
if
(
file
.
status
===
'done'
&&
file
.
response
.
code
===
0
)
{
file
.
url
=
`
${
downloadFileUrl
}
?filePath=
${
file
.
response
.
data
}
`
;
file
.
sourcePath
=
file
.
response
.
data
;
message
.
success
(
'上传成功!'
);
}
else
if
(
file
.
status
===
'done'
&&
file
.
response
.
code
!==
0
)
{
file
.
status
=
'error'
;
message
.
error
(
'上传失败!'
);
}
onChange
((
fileList
&&
fileList
.
length
&&
JSON
.
stringify
(
fileList
))
||
''
);
setShowList
(
JSON
.
stringify
(
fileList
));
},
onPreview
(
file
)
{
if
(
_isRecordingOrVideo
)
{
setPreviewVisible
(
true
);
setPreviewUrl
(
file
.
url
);
}
},
previewFile
(
file
)
{},
onDownload
(
file
)
{
downloadFunc
(
file
.
url
,
file
.
name
,
'_self'
);
},
};
const
handleCancel
=
()
=>
{
setPreviewVisible
(
false
);
setPreviewTitle
(
''
);
};
/**
* @description: 返回文件类型限定值
* @params: {Array} typeArray: Video | Recording | File
* @date: 2021/12/2
* @author: ChenLong
*/
const
returnFileTypeString
=
(
type
)
=>
{
let
_obj
=
{
Video
:
videoTypeArray
,
Recording
:
audioTypeArray
,
File
:
fileTypeArray
,
Image
:
imageTypeArray
,
};
return
_obj
[
type
].
join
(
','
);
};
useEffect
(()
=>
{
debugger
;
let
fileList
=
[];
(
file
||
''
).
split
(
','
).
forEach
((
item
,
index
)
=>
{
if
(
item
&&
filenameVerification
({
name
:
item
},
true
).
type
!==
'error'
)
{
// @Tips: 直接过滤掉名字中有异常字符的文件
let
_obj
=
{
uid
:
index
+
'_'
+
Math
.
random
(),
value
:
item
,
name
:
item
.
split
(
'
\
\'
).reverse()[0],
type: schema.renderTo === '
Image
' ? '
image
' : '
file
',
status: '
done
',
url: `${downloadFileUrl}?filePath=${item}`,
sourcePath: item,
};
if (schema.renderTo === '
Image
') _obj.thumbUrl = `${downloadFileUrl}?filePath=${item}`;
fileList.push(_obj);
}
});
// onChange(fileList.length && JSON.stringify(fileList) || '');
setShowList(JSON.stringify(fileList));
}, []);
useEffect(() => {
if (value) {
let fileList = [];
(file || '').split('
,
').forEach((item, index) => {
if (item && filenameVerification({ name: item }, true).type !== '
error
') {
// @Tips: 直接过滤掉名字中有异常字符的文件
let _obj = {
uid: index + '
_
' + Math.random(),
value: item,
name: item.split('
\\
').reverse()[0],
type: schema.renderTo === '
Image
' ? '
image
' : '
file
',
status: '
done
',
url: `${downloadFileUrl}?filePath=${item}`,
sourcePath: item,
};
if (schema.renderTo === '
Image
') _obj.thumbUrl = `${downloadFileUrl}?filePath=${item}`;
fileList.push(_obj);
}
});
// onChange(fileList.length && JSON.stringify(fileList) || '');
setShowList(JSON.stringify(fileList));
}
}, [value]);
return (
<>
{/** @tips: 裁剪功能无法正常工作,暂不提供 */}
{/* <ImgCrop beforeCrop={(file) => {
let _returnObj = filenameVerification(file);
if (_returnObj.type === '
error
') {
message.error(_returnObj.content);
return false;
}
return schema.renderTo === '
Image
';
}} rotate locale={'
zh
-
cn
'} modalTitle={'
编辑图片
'} modalOk={'
确定
'}
modalCancel={'
取消
'}>*/}
<Upload
disabled={schema.disabled}
{...option}
fileList={showList ? JSON.parse(showList) : []}
multiple
style={{ width: '
100
%
' }}
className={_isRecordingOrVideo ? '
formUploadVideoOrRecording
' : '
formUpload
'}
showUploadList={{
showPreviewIcon: _isRecordingOrVideo,
showDownloadIcon: true,
downloadIcon: <DownloadOutlined />,
}}
accept={returnFileTypeString(schema.renderTo)}
>
{!_isRecordingOrVideo ? (
<Button disabled={schema.disabled} icon={<UploadOutlined />}>
Upload
</Button>
) : (
'
+
Upload
'
)}
</Upload>
{/* </ImgCrop>*/}
<Modal
style={{ width: '
30
%
' }}
bodyStyle={{ textAlign: '
center
' }}
visible={previewVisible}
title={previewTitle}
footer={null}
onCancel={handleCancel}
>
{_isVideo ? (
<video width={'
100
%
'} height={'
100
%
'} controls autoPlay src={previewUrl} />
) : (
''
)}
{_isAudio ? <audio controls autoPlay src={previewUrl} /> : ''}
{_isImage ? <img width={'
100
%
'} height={'
100
%
'} src={previewUrl} alt="缩略图" /> : ''}
</Modal>
</>
);
};
export default FileUpload;
packages/base-components/BasicReport/src/ReportsManage/Components/fileUpload/fileUpload.less
0 → 100644
View file @
437dd7ca
@import '~antd/es/style/themes/default.less';
@parse-form-prefix-cls: ~'@{ant-prefix}-parse-form';
.@{parse-form-prefix-cls} {
.formUpload {
width: 100%;
.@{ant-prefix}-upload-list-item {
float: left;
width: 49%;
max-width: 300px; // 增加了最大宽度,防止样式失效导致布局错误的问题
margin-right: 1%;
}
}
.@{ant-prefix}-animate {
}
.formUploadVideoOrRecording {
width: 100%;
.@{ant-prefix}-upload-list-item {
float: left;
width: 99%;
margin-right: 1%;
}
}
}
packages/base-components/BasicReport/src/ReportsManage/ReportEditForm.js
View file @
437dd7ca
...
@@ -8,11 +8,15 @@ import React, { useEffect, useState } from 'react';
...
@@ -8,11 +8,15 @@ 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
}
from
'antd'
;
import
moment
from
'moment'
;
import
moment
from
'moment'
;
import
{
submitReportData
}
from
'../api/service/report'
;
import
{
submitReportData
}
from
'../api/service/report'
;
import
FileUpload
from
'./Components/fileUpload/fileUpload'
;
import
{
reportService
}
from
'../api'
;
// 类型
// 类型
const
USER_ID
=
window
.
globalConfig
.
userInfo
.
OID
;
const
DATE_PICKER_ARRAY
=
[
'日期'
];
const
DATE_PICKER_ARRAY
=
[
'日期'
];
const
DATE_TIME_PICKER_ARRAY
=
[
'日期时刻'
];
const
DATE_TIME_PICKER_ARRAY
=
[
'日期时刻'
];
const
DATE_TYPE
=
[
'日期'
,
'日期时刻'
];
// 用来匹配是否需要转为日期对象;
const
DATE_TYPE
=
[
'日期'
,
'日期时刻'
];
// 用来匹配是否需要转为日期对象;
const
NUMBER_ARRAY
=
[
'数值'
,
'金额'
];
const
NUMBER_ARRAY
=
[
'数值'
,
'金额'
];
const
FILE_ARRAY
=
[
'附件'
];
// 形态对应组件
// 形态对应组件
// 对应关系
// 对应关系
...
@@ -24,8 +28,9 @@ const NUMBER_ARRAY = ['数值', '金额'];
...
@@ -24,8 +28,9 @@ const NUMBER_ARRAY = ['数值', '金额'];
* @params: reportDetails 各个字段的配置列表
* @params: reportDetails 各个字段的配置列表
* data 与reportDetails对应的值
* data 与reportDetails对应的值
*/
*/
const
ReportEditForm
=
({
reportDetails
,
reportData
,
onCancel
,
reportName
})
=>
{
const
ReportEditForm
=
({
reportDetails
,
reportData
,
onCancel
,
reportName
,
modalType
})
=>
{
if
(
!
reportData
||
Object
.
keys
(
reportData
).
length
===
0
)
return
<>
未传递表单数据
<
/>
;
// if (!reportData || Object.keys(reportData).length === 0) return <>未传递表单数据</>;
const
[
fileAlias
,
setFileAlias
]
=
useState
([]);
// 附件需要单独处理提交的数据
const
[
form
]
=
Form
.
useForm
();
const
[
form
]
=
Form
.
useForm
();
const
formItemLayout
=
{
const
formItemLayout
=
{
labelCol
:
{
labelCol
:
{
...
@@ -52,77 +57,135 @@ const ReportEditForm = ({ reportDetails, reportData, onCancel, reportName }) =>
...
@@ -52,77 +57,135 @@ const ReportEditForm = ({ reportDetails, reportData, onCancel, reportName }) =>
return
<
DatePicker
/>
;
return
<
DatePicker
/>
;
}
else
if
(
NUMBER_ARRAY
.
includes
(
config
.
type
))
{
}
else
if
(
NUMBER_ARRAY
.
includes
(
config
.
type
))
{
return
<
InputNumber
/>
;
return
<
InputNumber
/>
;
}
else
if
(
FILE_ARRAY
.
includes
(
config
.
type
))
{
return
<
FileUpload
schema
=
{{
renderTo
:
'File'
}}
/>
;
}
else
{
}
else
{
return
<
Input
/>
;
return
<
Input
/>
;
}
}
};
};
const
submitReportForm
=
()
=>
{
const
submitReportForm
=
()
=>
{
let
_data
=
form
.
getFieldsValue
();
form
.
validateFields
().
then
((
values
)
=>
{
console
.
log
(
_data
);
let
_data
=
values
;
// {
let
final
=
[];
// "key": "string",
Object
.
keys
(
_data
).
forEach
((
key
)
=>
{
// "fieldName": "string",
let
value
=
reportData
[
key
];
// "fieldValue": "string"
let
_value
=
_data
[
key
];
// }
if
(
moment
.
isMoment
(
_data
[
key
]))
{
let
final
=
[];
_value
=
moment
(
_data
[
key
]).
format
(
'YYYY-MM-DD HH:mm:ss'
);
Object
.
keys
(
_data
).
forEach
((
key
)
=>
{
}
let
value
=
reportData
[
key
];
if
(
value
!==
_value
)
{
let
_value
=
_data
[
key
];
if
(
fileAlias
.
includes
(
key
))
{
if
(
moment
.
isMoment
(
_data
[
key
]))
{
_value
=
_value
_value
=
moment
(
_data
[
key
]).
format
(
'YYYY-MM-DD HH:mm:ss'
);
?
JSON
.
parse
(
_value
)
.
reduce
((
final
,
curr
)
=>
{
final
.
push
(
curr
.
sourcePath
);
return
final
;
},
[])
.
join
(
','
)
:
''
;
}
let
_finalData
=
{
fieldAlias
:
key
,
fieldValue
:
_value
,
};
if
(
modalType
===
'编辑'
)
{
_finalData
.
key
=
reportData
.
Key
;
}
final
.
push
(
_finalData
);
}
});
if
(
modalType
===
'新增'
)
{
reportService
.
addReportData
({
reportName
:
reportName
,
userId
:
USER_ID
,
reportDatas
:
final
,
})
.
then
((
res
)
=>
{
if
(
res
.
code
===
0
)
{
message
.
success
(
'保存成功!'
);
onCancel
();
}
else
if
(
res
.
code
===
-
1
)
{
message
.
error
(
res
.
msg
);
}
else
if
(
res
.
code
===
-
2
)
{
message
.
error
(
'系统故障,请找管理员查看故障!'
);
}
});
}
}
if
(
value
!==
_value
)
{
if
(
modalType
===
'编辑'
)
{
final
.
push
({
submitReportData
(
key
:
reportData
.
Key
,
{},
fieldName
:
key
,
{
fieldValue
:
_value
,
editDatas
:
final
,
reportName
:
reportName
,
userId
:
USER_ID
,
},
).
then
((
res
)
=>
{
if
(
res
.
code
===
0
)
{
message
.
success
(
'保存成功!'
);
onCancel
();
}
else
if
(
res
.
code
===
-
1
)
{
message
.
error
(
res
.
msg
);
}
else
if
(
res
.
code
===
-
2
)
{
message
.
error
(
'系统故障,请找管理员查看故障!'
);
}
});
});
}
}
});
});
console
.
log
(
final
);
// reportService.updateReportData()
submitReportData
(
{
reportName
:
reportName
,
userId
:
window
.
globalConfig
.
userInfo
.
OID
,
},
final
,
).
then
((
res
)
=>
{
if
(
res
.
code
===
0
)
{
message
.
success
(
'保存成功!'
);
onCancel
();
}
});
};
};
useEffect
(()
=>
{
if
(
reportDetails
&&
reportDetails
.
length
)
{
let
_fileAlias
=
[...
fileAlias
];
reportDetails
.
forEach
((
item
)
=>
{
if
(
item
.
type
===
'附件'
)
_fileAlias
.
push
(
item
.
fieldAlias
);
});
setFileAlias
(
_fileAlias
);
}
},
[
reportDetails
]);
useEffect
(()
=>
{
useEffect
(()
=>
{
if
(
reportData
&&
Object
.
keys
(
reportData
).
length
)
if
(
reportData
&&
Object
.
keys
(
reportData
).
length
)
form
.
setFieldsValue
(
handleDate
(
reportDetails
,
reportData
));
form
.
setFieldsValue
(
handleDate
(
reportDetails
,
reportData
));
},
[
reportData
]);
},
[
reportData
]);
return
(
return
(
<
div
>
<
div
style
=
{{
position
:
'relative'
}}
>
<
Form
{...
formItemLayout
}
form
=
{
form
}
>
<
div
>
<
Row
>
<
Form
{...
formItemLayout
}
form
=
{
form
}
>
{
reportDetails
&&
<
Row
style
=
{{
overflowY
:
'scroll'
,
maxHeight
:
'calc(100vh - 300px)'
}}
>
reportDetails
.
map
((
config
)
=>
{
{
reportDetails
&&
return
(
reportDetails
.
map
((
config
)
=>
{
<
Col
span
=
{
8
}
>
return
(
<
Form
.
Item
label
=
{
config
.
fieldAlias
}
name
=
{
config
.
fieldAlias
}
>
<
Col
span
=
{
8
}
key
=
{
config
.
fieldAlias
}
>
{
componentMap
(
config
)}
<
Form
.
Item
<
/Form.Item
>
label
=
{
config
.
fieldAlias
}
<
/Col
>
name
=
{
config
.
fieldAlias
}
);
rules
=
{[
})}
{
<
/Row
>
required
:
config
.
isRequired
,
<
Row
>
message
:
`
${
config
.
fieldAlias
}
必填`
,
<
Col
span
=
{
24
}
style
=
{{
textAlign
:
'right'
}}
>
},
{
/*<Form.Item style={{textAlign:'right'}}>*/
}
]}
<
Button
type
=
{
'primary'
}
onClick
=
{
submitReportForm
}
>
>
提交
{
componentMap
(
config
)}
<
/Button
>
<
/Form.Item
>
{
/*</Form.Item>*/
}
<
/Col
>
<
/Col
>
);
<
/Row
>
})}
<
/Form
>
<
/Row
>
<
Row
>
<
Col
span
=
{
24
}
style
=
{{
textAlign
:
'right'
}}
>
{
/*<Form.Item style={{textAlign:'right'}}>*/
}
<
Button
style
=
{{
position
:
'sticky'
,
bottom
:
0
}}
type
=
{
'primary'
}
onClick
=
{
submitReportForm
}
>
提交
<
/Button
>
{
/*</Form.Item>*/
}
<
/Col
>
<
/Row
>
<
/Form
>
<
/div
>
<
/div
>
<
/div
>
);
);
};
};
...
...
packages/base-components/BasicReport/src/ReportsManage/ReportsManage.js
View file @
437dd7ca
This diff is collapsed.
Click to expand it.
packages/base-components/BasicReport/src/ReportsManage/ReportsSetting.js
View file @
437dd7ca
This diff is collapsed.
Click to expand it.
packages/base-components/BasicReport/src/ReportsManage/utils/constant.js
0 → 100644
View file @
437dd7ca
const
tagColors
=
[
'rgb(129, 134, 143)'
,
'rgb(41, 114, 244)'
,
'rgb(0, 163, 245)'
,
'rgb(69, 176, 118)'
,
'rgb(222, 60, 54)'
,
'rgb(248, 136, 37)'
,
'rgb(189, 160, 20)'
,
'rgb(154, 56, 215)'
,
'rgb(221, 64, 151)'
,
];
const
tagBackgroundColors
=
[
'rgb(220, 223, 228)'
,
'rgb(214, 229, 255)'
,
'rgb(214, 241, 255)'
,
'rgb(211, 243, 226)'
,
'rgb(255, 220, 219)'
,
'rgb(255, 236, 219)'
,
'rgb(255, 245, 204)'
,
'rgb(251, 219, 255)'
,
'rgb(255, 219, 234)'
,
];
export
{
tagColors
,
tagBackgroundColors
};
packages/base-components/BasicReport/src/ReportsManage/utils/handlers.js
View file @
437dd7ca
...
@@ -8,7 +8,8 @@ import { hasMoney, isNumber } from './utils';
...
@@ -8,7 +8,8 @@ import { hasMoney, isNumber } from './utils';
* @params: config下的数值的configRule结构如下,[{最大值: 10,最小值: 0,颜色:'#AAAAAA'}];
* @params: config下的数值的configRule结构如下,[{最大值: 10,最小值: 0,颜色:'#AAAAAA'}];
* @business: configRule有值,则按照configRule设置;没有,按照color设置; 有最大值,无最小值;['', 1]
* @business: configRule有值,则按照configRule设置;没有,按照color设置; 有最大值,无最小值;['', 1]
* 有最大值,有最小值;[2,
* 有最大值,有最小值;[2,
* 10]
*
* 10]
* 有最小值,无最大值;[11,'']
* 有最小值,无最大值;[11,'']
*/
*/
// 链接 功能 弹窗功能待提出需求
// 链接 功能 弹窗功能待提出需求
...
@@ -76,7 +77,8 @@ const returnOpacity = (rgba) => {
...
@@ -76,7 +77,8 @@ const returnOpacity = (rgba) => {
};
};
export
const
handleNumber
=
(
config
,
number
)
=>
{
export
const
handleNumber
=
(
config
,
number
)
=>
{
let
_color
=
''
;
let
_color
=
''
;
if
(
number
)
number
=
Number
(
number
);
// 当设置精度后,会被转成字符串
let
_number
;
if
(
number
)
_number
=
Number
(
number
);
// 当设置精度后,会被转成字符串
if
(
config
.
numericalConfigs
&&
config
.
numericalConfigs
.
length
)
{
if
(
config
.
numericalConfigs
&&
config
.
numericalConfigs
.
length
)
{
config
.
numericalConfigs
.
forEach
((
item
)
=>
{
config
.
numericalConfigs
.
forEach
((
item
)
=>
{
// 接口对于数值类型的返回为null
// 接口对于数值类型的返回为null
...
@@ -84,11 +86,11 @@ export const handleNumber = (config, number) => {
...
@@ -84,11 +86,11 @@ export const handleNumber = (config, number) => {
let
_max
=
item
.
maxValue
||
''
;
let
_max
=
item
.
maxValue
||
''
;
let
_min
=
item
.
minValue
||
''
;
let
_min
=
item
.
minValue
||
''
;
if
(
_max
!==
''
&&
_min
===
''
)
{
if
(
_max
!==
''
&&
_min
===
''
)
{
_color
=
number
<=
Number
(
_max
)
?
''
:
item
.
color
;
_color
=
_
number
<=
Number
(
_max
)
?
''
:
item
.
color
;
}
else
if
(
_min
!==
''
&&
_max
===
''
)
{
}
else
if
(
_min
!==
''
&&
_max
===
''
)
{
_color
=
number
>
Number
(
_min
)
?
item
.
color
:
''
;
_color
=
_
number
>
Number
(
_min
)
?
item
.
color
:
''
;
}
else
{
}
else
{
_color
=
number
>
Number
(
_min
)
&&
number
<=
Number
(
_max
)
?
item
.
color
:
''
;
_color
=
_number
>
Number
(
_min
)
&&
_
number
<=
Number
(
_max
)
?
item
.
color
:
''
;
}
}
}
}
});
});
...
@@ -144,15 +146,23 @@ export const handleTag = (config, text) => {
...
@@ -144,15 +146,23 @@ export const handleTag = (config, text) => {
}
}
_color
=
config
.
color
||
'rgba(0,0,0,.85)'
;
_color
=
config
.
color
||
'rgba(0,0,0,.85)'
;
// String(text)为了解决可能存在数值类型的数据需要设置成标签的需求
// String(text)为了解决可能存在数值类型的数据需要设置成标签的需求
// return String(text).split(_configMap['分隔符']).map(item => <Tag color={_map[item]}>{item}</Tag>);
return
String
(
text
)
return
String
(
text
)
.
split
(
_configMap
[
'分隔符'
])
.
split
(
_configMap
[
'分隔符'
])
.
map
((
item
)
=>
<
Tag
color
=
{
_map
[
item
]}
>
{
item
}
<
/Tag>
)
;
.
map
((
item
)
=>
(
/* return String(text).split(_configMap['分隔符']).map(item => <Tag style={{
<
Tag
background: _map[item] || _color,
style
=
{{
border: `1px solid ${_map[item]}`,
background
:
_map
[
item
]
||
_color
,
borderRadius: 4,
border
:
`1px solid
${
_map
[
item
]
||
_color
}
`
,
color: `rgba(0, 0, 0, .65)`,
borderRadius
:
2
,
}}>{item}</Tag>);*/
color
:
_map
[
item
]
?
tagColors
[
tagBackgroundColors
.
findIndex
((
c
)
=>
c
===
_map
[
item
])]
:
`rgba(0, 0, 0, .65)`
,
}}
>
{
item
}
<
/Tag
>
));
};
};
export
const
handleText
=
(
config
,
text
)
=>
{
export
const
handleText
=
(
config
,
text
)
=>
{
return
<
span
style
=
{{
color
:
config
.
color
||
'rgba(0,0,0,.85)'
}}
>
{
text
}
<
/span>
;
return
<
span
style
=
{{
color
:
config
.
color
||
'rgba(0,0,0,.85)'
}}
>
{
text
}
<
/span>
;
...
...
packages/base-components/BasicReport/src/ReportsManage/utils/utils.js
View file @
437dd7ca
...
@@ -24,7 +24,9 @@ const hasMoney = (configItems) => {
...
@@ -24,7 +24,9 @@ const hasMoney = (configItems) => {
const
returnHandledNumber
=
(
configItems
,
num
)
=>
{
const
returnHandledNumber
=
(
configItems
,
num
)
=>
{
// 精度、前缀、后缀、倍率
// 精度、前缀、后缀、倍率
// $_d|_d%|_d*0.0001|金额|0.00
// $_d|_d%|_d*0.0001|金额|0.00
if
(
isNaN
(
num
))
return
'-'
;
if
(
!
configItems
)
return
num
;
if
(
!
configItems
)
return
num
;
num
=
Number
(
num
);
let
_items
=
configItems
.
split
(
'|'
);
let
_items
=
configItems
.
split
(
'|'
);
/* let prefix = '';
/* let prefix = '';
let suffix = '';*/
let suffix = '';*/
...
@@ -58,8 +60,10 @@ const returnHandledNumber = (configItems, num) => {
...
@@ -58,8 +60,10 @@ const returnHandledNumber = (configItems, num) => {
* @author: ChenLong
* @author: ChenLong
* @params:
* @params:
* configItems 报表字段的配置 例如 defaultValue=智慧水务
* configItems 报表字段的配置 例如 defaultValue=智慧水务
*
* defaultDateModel=customer|defaultDateValue=2022-01-01,2022-12-31;
* defaultDateModel=customer|defaultDateValue=2022-01-01,2022-12-31;
* keysArray
* keysArray
*
* 所需要返回的值的key的集合,比如你需要获取configItems中的’defaultValue‘,那么keysArray=['defaultValue'];
* 所需要返回的值的key的集合,比如你需要获取configItems中的’defaultValue‘,那么keysArray=['defaultValue'];
* @returns:
* @returns:
* defaultValue 通用参数 默认值
* defaultValue 通用参数 默认值
...
@@ -74,6 +78,42 @@ const returnDefaultValueOrConfigs = (configItems = '', keysArray = []) => {
...
@@ -74,6 +78,42 @@ const returnDefaultValueOrConfigs = (configItems = '', keysArray = []) => {
});
});
return
_map
;
return
_map
;
};
};
function
downloadFunc
(
url
,
name
,
target
=
'_self'
)
{
const
a
=
document
.
createElement
(
'a'
);
a
.
href
=
url
;
a
.
target
=
target
;
a
.
download
=
name
;
a
.
click
();
a
.
remove
();
}
/**
* @description: 校验文件的名称是否包含特殊字符
* @params: {Object: File} file file对象 { special:Boolean } 是否去除/的匹配
* @date: 2021/12/8
* @author: ChenLong
* @returns {Object} {type: error | success ,content: 提示...}
*/
function
filenameVerification
(
file
,
special
)
{
debugger
;
// 文件名含有特殊字符 提示不能上传 {+,:/?#[]@!$&\\*+;=}
// 规则对象(flag)
var
flag
=
!
special
?
new
RegExp
(
"[`~!@#$^&*=|{}':;',
\\
[
\\
]/?~!@#¥&*——|{}【】‘;:”“'。,、?]"
)
:
new
RegExp
(
"[`~!@#$^&*=|{}':;',[
\\
]?~!@#¥&*——|{}【】‘;:”“'。,、?]"
);
if
(
flag
.
test
(
file
.
name
))
{
return
{
type
:
'error'
,
content
:
`文件名格式错误,请检查文件名是否含有特殊字符
${
"~!@#$^&*=|{}':;',
\\
[
\\
]/?~!@#¥&*——|{}【】‘;:”“'。,、?"
}
`
,
};
}
return
{
type
:
'success'
,
content
:
`上传成功!`
,
};
}
export
{
export
{
isObject
,
isObject
,
isString
,
isString
,
...
@@ -82,4 +122,6 @@ export {
...
@@ -82,4 +122,6 @@ export {
isArray
,
isArray
,
returnHandledNumber
,
returnHandledNumber
,
returnDefaultValueOrConfigs
,
returnDefaultValueOrConfigs
,
downloadFunc
,
filenameVerification
,
};
};
packages/base-components/BasicReport/src/api/service/report.js
View file @
437dd7ca
...
@@ -24,6 +24,13 @@ export const API = {
...
@@ -24,6 +24,13 @@ export const API = {
SAVE_REPORT_LIST_SORT_FIELDS
:
`
${
BASEURL
}
/SaveReportListSortFields`
,
// 保存排序
SAVE_REPORT_LIST_SORT_FIELDS
:
`
${
BASEURL
}
/SaveReportListSortFields`
,
// 保存排序
ADD_REPORT_DETAIL_INFO_INDEX
:
`
${
BASEURL
}
/AddReportDetailInfoIndex`
,
// 变更接口顺序
ADD_REPORT_DETAIL_INFO_INDEX
:
`
${
BASEURL
}
/AddReportDetailInfoIndex`
,
// 变更接口顺序
UPDATE_REPORT_DATA
:
`
${
BASEURL
}
/UpdateReportData`
,
// 更新报表数据
UPDATE_REPORT_DATA
:
`
${
BASEURL
}
/UpdateReportData`
,
// 更新报表数据
GET_REPORT_DETAILS
:
`
${
BASEURL
}
/GetReportDetails`
,
// 获取报表配置
DEL_REPORT_DATA
:
`
${
BASEURL
}
/DelReportData`
,
// 删除报表数据
SET_REPORT_ALLOW
:
`
${
BASEURL
}
/SetReportAllow`
,
// 设置关注
ADD_REPORT_DATA
:
`
${
BASEURL
}
/AddReportData`
,
// 添加报表数据
EXPORT_JPG
:
`
${
BASEURL
}
/ExportJPGAccountData`
,
EXPORT_REPORT_CONFIG
:
`
${
BASEURL
}
/ExportReportConfig`
,
IMPORT_REPORT_CONFIG
:
`
${
BASEURL
}
/ImportReportConfig`
,
};
};
const
reportService
=
{
const
reportService
=
{
getReportInfo
:
{
getReportInfo
:
{
...
@@ -96,6 +103,41 @@ const reportService = {
...
@@ -96,6 +103,41 @@ const reportService = {
method
:
constants
.
REQUEST_METHOD_POST
,
method
:
constants
.
REQUEST_METHOD_POST
,
type
:
constants
.
REQUEST_METHOD_POST
,
type
:
constants
.
REQUEST_METHOD_POST
,
},
},
getReportDetails
:
{
url
:
API
.
GET_REPORT_DETAILS
,
method
:
constants
.
REQUEST_METHOD_GET
,
type
:
constants
.
REQUEST_METHOD_GET
,
},
delReportData
:
{
url
:
API
.
DEL_REPORT_DATA
,
method
:
constants
.
REQUEST_METHOD_POST
,
type
:
constants
.
REQUEST_METHOD_POST
,
},
setReportAllow
:
{
url
:
API
.
SET_REPORT_ALLOW
,
method
:
constants
.
REQUEST_METHOD_POST
,
type
:
constants
.
REQUEST_METHOD_POST
,
},
addReportData
:
{
url
:
API
.
ADD_REPORT_DATA
,
method
:
constants
.
REQUEST_METHOD_POST
,
type
:
constants
.
REQUEST_METHOD_POST
,
},
exportJPG
:
{
url
:
API
.
EXPORT_JPG
,
method
:
constants
.
REQUEST_METHOD_POST
,
type
:
constants
.
REQUEST_METHOD_POST
,
},
exportConfig
:
{
url
:
API
.
EXPORT_REPORT_CONFIG
,
method
:
constants
.
REQUEST_METHOD_GET
,
type
:
constants
.
REQUEST_METHOD_GET
,
},
importConfig
:
{
url
:
API
.
IMPORT_REPORT_CONFIG
,
method
:
constants
.
REQUEST_METHOD_POST
,
type
:
constants
.
REQUEST_METHOD_POST
,
},
};
};
export
const
submitReportData
=
(
params
,
data
)
=>
export
const
submitReportData
=
(
params
,
data
)
=>
request
({
request
({
...
@@ -112,10 +154,33 @@ export const exportAccountData = (options, params, data) =>
...
@@ -112,10 +154,33 @@ export const exportAccountData = (options, params, data) =>
params
,
params
,
data
,
data
,
});
});
export
const
exportJPG
=
(
options
,
data
)
=>
{
return
request
({
url
:
API
.
EXPORT_JPG
,
method
:
'post'
,
...
options
,
data
,
});
};
export
const
addReportDetailInfoIndex
=
(
data
)
=>
export
const
addReportDetailInfoIndex
=
(
data
)
=>
request
({
request
({
url
:
API
.
ADD_REPORT_DETAIL_INFO_INDEX
,
url
:
API
.
ADD_REPORT_DETAIL_INFO_INDEX
,
method
:
'post'
,
method
:
'post'
,
data
,
data
,
});
});
export
const
importReportConfig
=
(
options
,
params
,
data
)
=>
request
({
url
:
API
.
IMPORT_REPORT_CONFIG
,
method
:
'post'
,
...
options
,
params
,
data
,
});
export
const
exportReportConfig
=
(
options
,
params
)
=>
request
({
url
:
API
.
EXPORT_REPORT_CONFIG
,
method
:
'get'
,
...
options
,
params
,
});
export
default
reportService
;
export
default
reportService
;
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