Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
T
TOSTUMI
Project
Project
Details
Activity
Releases
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
Maple
TOSTUMI
Commits
93a133a8
Commit
93a133a8
authored
Feb 18, 2021
by
cellee
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
小区新增重构
Signed-off-by:
cellee
<
893264950@qq.com
>
parent
ff46bff4
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
541 additions
and
515 deletions
+541
-515
PdfUpload.tsx
src/components/Form/PdfUpload.tsx
+141
-22
zip.less
src/components/Form/zip.less
+9
-0
Adds.tsx
src/pages/CommunityManagement/CellList/Adds.tsx
+199
-390
Adds3.tsx
src/pages/CommunityManagement/CellList/Adds3.tsx
+190
-102
params.ts
src/utils/params.ts
+2
-1
No files found.
src/components/Form/PdfUpload.tsx
View file @
93a133a8
/*
/*
* @Author: your name
* @Author: your name
* @Date: 2021-02-01 14:54:48
* @Date: 2021-02-01 14:54:48
* @LastEditTime: 2021-02-18 1
3:54:59
* @LastEditTime: 2021-02-18 1
6:48:37
* @LastEditors: Please set LastEditors
* @LastEditors: Please set LastEditors
* @Description: In User Settings Edit
* @Description: In User Settings Edit
* @FilePath: \tostumi\src\components\Form\PdfUpload.tsx
* @FilePath: \tostumi\src\components\Form\PdfUpload.tsx
*/
*/
import
React
,
{
useState
}
from
'react'
;
import
React
,
{
useState
}
from
'react'
;
import
{
Input
,
Upload
,
message
,
Button
,
Spi
n
}
from
'antd'
;
import
{
Input
,
Upload
,
message
,
Button
,
Modal
,
Paginatio
n
}
from
'antd'
;
import
{
import
{
LoadingOutlined
,
LoadingOutlined
,
PlusOutlined
,
PlusOutlined
,
...
@@ -15,6 +15,8 @@ import {
...
@@ -15,6 +15,8 @@ import {
FilePdfOutlined
,
FilePdfOutlined
,
}
from
'@ant-design/icons'
;
}
from
'@ant-design/icons'
;
import
PDF
from
'react-pdf-js'
;
interface
PriceInputProps
{
interface
PriceInputProps
{
value
?:
any
;
value
?:
any
;
onChange
?:
any
;
onChange
?:
any
;
...
@@ -28,9 +30,12 @@ const PdfUpload: React.FC<PriceInputProps> = ({ value = {}, onChange, disabled,
...
@@ -28,9 +30,12 @@ const PdfUpload: React.FC<PriceInputProps> = ({ value = {}, onChange, disabled,
const
[
idx
,
setIdx
]
=
useState
(
0
);
// 点击的第几个
const
[
idx
,
setIdx
]
=
useState
(
0
);
// 点击的第几个
const
[
imgList
,
setImgList
]
=
useState
([]
as
any
);
// 列表
const
[
imgList
,
setImgList
]
=
useState
([]
as
any
);
// 列表
const
[
PdfUrl
,
setPdfUrl
]
=
useState
(
null
);
//地址
const
[
PdfUrl
,
setPdfUrl
]
=
useState
(
null
as
any
);
//地址
const
[
ModalVisible
,
setModalVisible
]
=
useState
(
false
);
//显示隐藏
const
[
ModalVisible
,
setModalVisible
]
=
useState
(
false
);
//显示隐藏
const
[
numPages
,
setNumPages
]
=
useState
(
1
as
any
);
// 总页码数
const
[
pageNumber
,
setPageNumber
]
=
useState
(
1
);
// 当前页码数
// 上传前检测
// 上传前检测
function
beforeUpload
(
file
:
any
)
{
function
beforeUpload
(
file
:
any
)
{
const
isJpgOrPng
=
file
.
type
===
'application/pdf'
||
file
.
type
===
'pdf'
;
const
isJpgOrPng
=
file
.
type
===
'application/pdf'
||
file
.
type
===
'pdf'
;
...
@@ -46,10 +51,11 @@ const PdfUpload: React.FC<PriceInputProps> = ({ value = {}, onChange, disabled,
...
@@ -46,10 +51,11 @@ const PdfUpload: React.FC<PriceInputProps> = ({ value = {}, onChange, disabled,
// 上传成功怎么做
// 上传成功怎么做
const
handleChange
=
(
info
:
any
)
=>
{
const
handleChange
=
(
info
:
any
)
=>
{
console
.
log
(
info
);
//
console.log(info);
let
{
status
,
response
}
=
info
.
file
;
let
{
status
,
response
}
=
info
.
file
;
// 加载中状态
if
(
status
===
'uploading'
)
{
if
(
status
===
'uploading'
)
{
// setLoading();
let
v
=
loading
;
let
v
=
loading
;
v
[
idx
]
=
true
;
v
[
idx
]
=
true
;
setLoading
([...
v
]);
setLoading
([...
v
]);
...
@@ -58,8 +64,9 @@ const PdfUpload: React.FC<PriceInputProps> = ({ value = {}, onChange, disabled,
...
@@ -58,8 +64,9 @@ const PdfUpload: React.FC<PriceInputProps> = ({ value = {}, onChange, disabled,
v
[
idx
]
=
false
;
v
[
idx
]
=
false
;
setLoading
([...
v
]);
setLoading
([...
v
]);
}
}
// 上传成功后处理
if
(
status
===
'done'
)
{
if
(
status
===
'done'
)
{
console
.
log
(
'上传成功'
);
let
{
fileName
,
key
,
fileUrl
}
=
response
.
data
;
let
{
fileName
,
key
,
fileUrl
}
=
response
.
data
;
let
list
=
JSON
.
parse
(
JSON
.
stringify
(
imgList
));
let
list
=
JSON
.
parse
(
JSON
.
stringify
(
imgList
));
let
obj
=
{
let
obj
=
{
...
@@ -73,9 +80,15 @@ const PdfUpload: React.FC<PriceInputProps> = ({ value = {}, onChange, disabled,
...
@@ -73,9 +80,15 @@ const PdfUpload: React.FC<PriceInputProps> = ({ value = {}, onChange, disabled,
message
.
warning
(
'The current category has been deleted'
);
message
.
warning
(
'The current category has been deleted'
);
return
false
;
return
false
;
}
else
{
}
else
{
// 在判断输入框填了没 ,填了的话去掉提示
if
(
list
[
parseInt
(
key
)].
name
!==
''
)
{
list
[
parseInt
(
key
)].
tip
=
false
;
}
// 否则添加进去
// 否则添加进去
list
[
parseInt
(
key
)].
fileList
.
push
(
obj
);
list
[
parseInt
(
key
)].
fileList
.
push
(
obj
);
setImgList
([...
list
]);
setImgList
([...
list
]);
onChange
&&
onChange
(
list
);
}
}
}
}
};
};
...
@@ -83,15 +96,29 @@ const PdfUpload: React.FC<PriceInputProps> = ({ value = {}, onChange, disabled,
...
@@ -83,15 +96,29 @@ const PdfUpload: React.FC<PriceInputProps> = ({ value = {}, onChange, disabled,
// 新增的按钮
// 新增的按钮
const
add
=
()
=>
{
const
add
=
()
=>
{
let
list
=
JSON
.
parse
(
JSON
.
stringify
(
imgList
));
let
list
=
JSON
.
parse
(
JSON
.
stringify
(
imgList
));
let
item
=
{
let
valve
=
false
;
// 控制阀
id
:
Math
.
floor
(
Math
.
random
()
*
100
),
for
(
let
i
in
list
)
{
name
:
''
,
if
(
list
[
i
].
name
==
''
||
list
[
i
].
fileList
.
length
==
0
)
{
fileList
:
[],
list
[
i
].
tip
=
true
;
tip
:
false
,
valve
=
true
;
loading
:
false
,
}
else
{
message
:
'123'
,
list
[
i
].
tip
=
false
;
};
}
list
.
push
(
item
);
}
if
(
!
valve
)
{
let
item
=
{
id
:
Math
.
floor
(
Math
.
random
()
*
100
),
name
:
''
,
fileList
:
[],
tip
:
false
,
message
:
'Required'
,
};
list
.
push
(
item
);
onChange
&&
onChange
(
list
);
}
setImgList
([...
list
]);
setImgList
([...
list
]);
};
};
...
@@ -99,7 +126,10 @@ const PdfUpload: React.FC<PriceInputProps> = ({ value = {}, onChange, disabled,
...
@@ -99,7 +126,10 @@ const PdfUpload: React.FC<PriceInputProps> = ({ value = {}, onChange, disabled,
const
del
=
(
index
:
any
)
=>
{
const
del
=
(
index
:
any
)
=>
{
let
list
=
JSON
.
parse
(
JSON
.
stringify
(
imgList
));
let
list
=
JSON
.
parse
(
JSON
.
stringify
(
imgList
));
list
.
splice
(
index
,
1
);
list
.
splice
(
index
,
1
);
setImgList
([...
list
]);
setImgList
([...
list
]);
onChange
&&
onChange
(
list
);
};
};
//携带数据 、 传递给后台加 key
//携带数据 、 传递给后台加 key
...
@@ -110,45 +140,110 @@ const PdfUpload: React.FC<PriceInputProps> = ({ value = {}, onChange, disabled,
...
@@ -110,45 +140,110 @@ const PdfUpload: React.FC<PriceInputProps> = ({ value = {}, onChange, disabled,
// 点击预览
// 点击预览
const
handlePreview
=
async
(
file
:
any
)
=>
{
const
handlePreview
=
async
(
file
:
any
)
=>
{
// console.log(file);
setPdfUrl
(
file
);
setPdfUrl
(
file
);
setModalVisible
(
true
);
setModalVisible
(
true
);
};
};
// 点击删除
const
onRemove
=
(
e
:
any
)
=>
{
let
list
=
JSON
.
parse
(
JSON
.
stringify
(
imgList
));
for
(
let
i
in
list
)
{
let
ary
=
list
[
i
].
fileList
;
for
(
let
v
in
ary
)
{
if
(
ary
[
v
].
name
==
e
.
name
)
{
ary
.
splice
(
v
,
1
);
}
}
}
setImgList
([...
list
]);
onChange
&&
onChange
(
list
);
};
// 点击上传记录index
// 点击上传记录index
const
opens
=
(
i
:
any
)
=>
{
const
opens
=
(
i
:
any
)
=>
{
setIdx
(
i
);
setIdx
(
i
);
};
};
// 上传pdf的图标
const
icons
=
()
=>
{
const
icons
=
()
=>
{
return
<
FilePdfOutlined
/>;
return
<
FilePdfOutlined
/>;
};
};
//隐藏框
const
handleCancel
=
()
=>
{
setModalVisible
(
false
);
// 还原页码数
setNumPages
(
1
);
setPageNumber
(
1
);
};
// pdf 总页数
const
onDocumentLoadSuccess
=
(
pages
:
any
)
=>
{
setNumPages
(
pages
);
};
// 切换pdf 总数
const
onChangePage
=
(
page
:
any
)
=>
{
setPageNumber
(
page
);
};
// 输入框
const
inpChange
=
(
e
:
any
)
=>
{
let
{
id
,
value
}
=
e
.
target
;
let
list
=
JSON
.
parse
(
JSON
.
stringify
(
imgList
));
list
[
id
].
name
=
value
;
// 在判断上传文件了没 ,上传了的话去掉提示
if
(
list
[
id
].
fileList
.
length
>
0
)
{
list
[
id
].
tip
=
false
;
}
// console.log(list);
setImgList
([...
list
]);
onChange
&&
onChange
(
list
);
};
return
(
return
(
<>
<>
{
imgList
.
map
((
item
:
any
,
index
:
any
)
=>
{
{
imgList
.
map
((
item
:
any
,
index
:
any
)
=>
{
return
(
return
(
<
div
className=
"pdf"
key=
{
index
}
>
<
div
className=
"pdf"
key=
{
index
}
>
<
div
className=
{
item
.
tip
?
'inpt ant-form-item-has-error'
:
'inpt'
}
>
<
div
className=
{
item
.
tip
?
'inpt ant-form-item-has-error'
:
'inpt'
}
>
<
Input
placeholder=
"Basic usage"
className=
"pdf-input"
/>
<
Input
placeholder=
"Basic usage"
className=
"pdf-input"
onChange=
{
inpChange
}
id=
{
index
}
value=
{
item
.
name
}
/>
{
item
.
tip
?
<
span
className=
"tips"
>
{
item
.
message
}
</
span
>
:
null
}
{
item
.
tip
?
<
span
className=
"tips"
>
{
item
.
message
}
</
span
>
:
null
}
</
div
>
</
div
>
<
div
className=
{
item
.
tip
?
'pdf-div ant-upload-list-item-error'
:
'pdf-div'
}
>
<
div
className=
{
item
.
tip
?
'pdf-div ant-upload-list-item-error'
:
'pdf-div'
}
onClick=
{
()
=>
opens
(
index
)
}
// key=
{
Math
.
random
()}
>
<
Upload
<
Upload
className=
"avatar-uploader"
className=
"avatar-uploader"
accept=
".pdf"
accept=
".pdf"
action=
{
action
!=
null
?
action
:
'/tos/community/pdf/upload'
}
action=
{
action
!=
null
?
action
:
'/tos/community/pdf/upload'
}
data=
{
()
=>
updeta
(
index
)
}
// 携带数据
data=
{
()
=>
updeta
(
index
)
}
// 携带数据
name=
"file"
name=
"file"
listType=
"picture-card"
listType=
"picture-card"
// 展现方式
fileList=
{
item
.
fileList
}
fileList=
{
item
.
fileList
}
onChange=
{
handleChange
}
//上传文件改变时的状态
onPreview=
{
handlePreview
}
// 预览
onPreview=
{
handlePreview
}
// 预览
beforeUpload=
{
beforeUpload
}
//上传前检测
beforeUpload=
{
beforeUpload
}
//上传前检测
onChange=
{
handleChange
}
onRemove=
{
onRemove
}
id=
{
index
}
// id=
{
index
}
iconRender=
{
icons
}
iconRender=
{
icons
}
// 上传成功后的图标
>
>
{
item
.
fileList
&&
item
.
fileList
.
length
>=
5
?
null
:
(
{
item
.
fileList
&&
item
.
fileList
.
length
>=
5
?
null
:
(
<
div
onClick=
{
()
=>
opens
(
index
)
}
>
<
div
>
{
loading
[
index
]
?
<
LoadingOutlined
/>
:
<
PlusOutlined
/>
}
{
loading
[
index
]
?
<
LoadingOutlined
/>
:
<
PlusOutlined
/>
}
{
/* <PlusOutlined></PlusOutlined> */
}
{
/* <PlusOutlined></PlusOutlined> */
}
<
div
style=
{
{
marginTop
:
8
}
}
>
Upload
</
div
>
<
div
style=
{
{
marginTop
:
8
}
}
>
Upload
</
div
>
...
@@ -181,6 +276,30 @@ const PdfUpload: React.FC<PriceInputProps> = ({ value = {}, onChange, disabled,
...
@@ -181,6 +276,30 @@ const PdfUpload: React.FC<PriceInputProps> = ({ value = {}, onChange, disabled,
)
}
)
}
{
/* 弹出层 */
}
{
/* 弹出层 */
}
<
Modal
title=
{
PdfUrl
!=
null
?
PdfUrl
.
name
:
'File Preview'
}
visible=
{
ModalVisible
}
width=
{
650
}
onCancel=
{
handleCancel
}
style=
{
{
textAlign
:
'center'
}
}
footer=
{
null
}
>
<>
<
PDF
file=
{
PdfUrl
?
PdfUrl
.
url
:
null
}
page=
{
pageNumber
}
scale=
{
1
}
onDocumentComplete=
{
onDocumentLoadSuccess
}
/>
<
Pagination
style=
{
{
textAlign
:
'center'
,
marginTop
:
10
,
display
:
'block'
}
}
simple
current=
{
pageNumber
}
total=
{
numPages
*
10
}
onChange=
{
onChangePage
}
/>
</>
</
Modal
>
</>
</>
);
);
};
};
...
...
src/components/Form/zip.less
View file @
93a133a8
...
@@ -6,6 +6,7 @@
...
@@ -6,6 +6,7 @@
}
}
// pdf上传
// pdf上传
.pdf {
.pdf {
margin-bottom: 15px;
margin-bottom: 15px;
display: flex;
display: flex;
...
@@ -58,3 +59,11 @@
...
@@ -58,3 +59,11 @@
height: 80px;
height: 80px;
border-radius: 2px;
border-radius: 2px;
}
}
.ant-form-item-has-error {
.pdf-div {
.ant-upload {
border-color: #f00;
}
}
}
src/pages/CommunityManagement/CellList/Adds.tsx
View file @
93a133a8
This diff is collapsed.
Click to expand it.
src/pages/CommunityManagement/CellList/Adds
2
.tsx
→
src/pages/CommunityManagement/CellList/Adds
3
.tsx
View file @
93a133a8
This diff is collapsed.
Click to expand it.
src/utils/params.ts
View file @
93a133a8
/*
/*
* @Author: your name
* @Author: your name
* @Date: 2020-11-19 20:34:18
* @Date: 2020-11-19 20:34:18
* @LastEditTime: 2021-0
1-28 15:34:25
* @LastEditTime: 2021-0
2-18 16:50:47
* @LastEditors: Please set LastEditors
* @LastEditors: Please set LastEditors
* @Description: In User Settings Edit
* @Description: In User Settings Edit
* @FilePath: \tostumi\src\utils\params.ts
* @FilePath: \tostumi\src\utils\params.ts
...
@@ -95,4 +95,5 @@ export const requestList = [
...
@@ -95,4 +95,5 @@ export const requestList = [
[
'/tos/community/facilities/get/detail'
,
'60 获取小区设施详情'
,
{}],
[
'/tos/community/facilities/get/detail'
,
'60 获取小区设施详情'
,
{}],
[
'/tos/bookingService/delete'
,
'61 设施删除'
,
{}],
[
'/tos/bookingService/delete'
,
'61 设施删除'
,
{}],
[
'/tos/community/download/excel'
,
'62 关闭小区后获取当前小区预约需要退费的表格'
,
{}],
[
'/tos/community/download/excel'
,
'62 关闭小区后获取当前小区预约需要退费的表格'
,
{}],
[
'/tos/tosCommunity/saveCommunity'
,
'63 新建小区PDF版本'
,
{}],
];
];
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