|
@@ -45,6 +45,9 @@ function AddBuilding(props) {
|
45
|
45
|
|
46
|
46
|
const [poi, setPoi] = useState([])
|
47
|
47
|
|
|
48
|
+ // 视频上传按钮是否 禁用
|
|
49
|
+ const [fileUploadDisabled, setFileUploadDisabled] = useState(false)
|
|
50
|
+
|
48
|
51
|
// console.log('props.building: ', props.building)
|
49
|
52
|
if (props.building.buildingId !== undefined) {
|
50
|
53
|
const { buildingId } = props.building
|
|
@@ -75,6 +78,8 @@ function AddBuilding(props) {
|
75
|
78
|
res.mapCoordinate = res.coordinate
|
76
|
79
|
if (res.videoUrl) {
|
77
|
80
|
res.videoUrl = [].concat(res.videoUrl)
|
|
81
|
+ // 视频上传按钮禁用
|
|
82
|
+ setFileUploadDisabled(true)
|
78
|
83
|
}
|
79
|
84
|
setPoi(res.mapJson || [])
|
80
|
85
|
props.form.setFieldsValue(res)
|
|
@@ -101,6 +106,7 @@ function AddBuilding(props) {
|
101
|
106
|
// 列表图
|
102
|
107
|
data.listImg = data.listImage && data.listImage.map((item, index) => ({ imgType: 'list', url: item, orderNo: index + 1 }))
|
103
|
108
|
if (data.videoUrl) {
|
|
109
|
+ console.log(data.videoUrl[0])
|
104
|
110
|
data.videoUrl = data.videoUrl[0]
|
105
|
111
|
}
|
106
|
112
|
|
|
@@ -120,9 +126,13 @@ function AddBuilding(props) {
|
120
|
126
|
|
121
|
127
|
// 视频文件上传前 回调
|
122
|
128
|
function fileUploadBeforeUpload(file, fileList) {
|
123
|
|
- console.log(file, fileList)
|
|
129
|
+ // console.log('视频文件上传前 回调: ', file, fileList)
|
124
|
130
|
return new Promise((resolve, reject) => {
|
125
|
|
- if (file.type === 'video/mp4' || file.type === '.mp4') {
|
|
131
|
+ if (fileUploadDisabled) {
|
|
132
|
+ openNotificationWithIcon('error', '项目视频,只允许上传一个')
|
|
133
|
+ reject()
|
|
134
|
+ } else if (file.type === 'video/mp4' || file.type === '.mp4') {
|
|
135
|
+ setFileUploadDisabled(true)
|
126
|
136
|
resolve(file)
|
127
|
137
|
} else {
|
128
|
138
|
openNotificationWithIcon('error', '项目视频,仅支持MP4格式')
|
|
@@ -271,7 +281,8 @@ function AddBuilding(props) {
|
271
|
281
|
</Form.Item>
|
272
|
282
|
<Form.Item label="项目视频" help="视频仅支持mp4格式,建议尺寸:1920*1080,比例16:9">
|
273
|
283
|
{getFieldDecorator('videoUrl')(
|
274
|
|
- <FileUpload accept=".mp4" beforeUpload={fileUploadBeforeUpload} label="上传视频"/>,
|
|
284
|
+ // disabled={fileUploadDisabled}
|
|
285
|
+ <FileUpload accept=".mp4" beforeUpload={fileUploadBeforeUpload} label="上传视频" />,
|
275
|
286
|
)}
|
276
|
287
|
</Form.Item>
|
277
|
288
|
<Form.Item label="楼盘主图" help="建议图片尺寸:750*600px,比例5:4,格式:jpg,用于楼盘详情">
|