Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
Y
yudao-cloud
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
hblj
yudao-cloud
Commits
6c135166
提交
6c135166
authored
5月 01, 2019
作者:
YunaiV
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
前端:文件上传。后续继续完善。
上级
120fba6c
隐藏空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
149 行增加
和
5 行删除
+149
-5
package.json
admin-web/package.json
+1
-0
ProductSpuAddOrUpdate.js
admin-web/src/pages/Product/ProductSpuAddOrUpdate.js
+122
-4
ProductSpuAddOrUpdate.less
admin-web/src/pages/Product/ProductSpuAddOrUpdate.less
+10
-0
admin.js
admin-web/src/services/admin.js
+14
-0
MVCConfiguration.java
...coder/mall/admin/application/config/MVCConfiguration.java
+2
-1
没有找到文件。
admin-web/package.json
浏览文件 @
6c135166
...
@@ -52,6 +52,7 @@
...
@@ -52,6 +52,7 @@
"omit.js"
:
"^1.0.0"
,
"omit.js"
:
"^1.0.0"
,
"path-to-regexp"
:
"^3.0.0"
,
"path-to-regexp"
:
"^3.0.0"
,
"prop-types"
:
"^15.6.2"
,
"prop-types"
:
"^15.6.2"
,
"qiniu-js"
:
"^2.5.4"
,
"qs"
:
"^6.6.0"
,
"qs"
:
"^6.6.0"
,
"rc-animate"
:
"^2.6.0"
,
"rc-animate"
:
"^2.6.0"
,
"react"
:
"^16.7.0"
,
"react"
:
"^16.7.0"
,
...
...
admin-web/src/pages/Product/ProductSpuAddOrUpdate.js
浏览文件 @
6c135166
...
@@ -3,17 +3,134 @@
...
@@ -3,17 +3,134 @@
import
React
,
{
PureComponent
,
Fragment
,
Component
}
from
'react'
;
import
React
,
{
PureComponent
,
Fragment
,
Component
}
from
'react'
;
import
{
connect
}
from
'dva'
;
import
{
connect
}
from
'dva'
;
import
moment
from
'moment'
;
import
moment
from
'moment'
;
import
{
Card
,
Form
,
Input
,
Radio
,
Button
,
Table
,
Select
}
from
'antd'
;
import
{
Card
,
Form
,
Input
,
Radio
,
Button
,
Modal
,
Select
,
Upload
,
Icon
}
from
'antd'
;
import
PageHeaderWrapper
from
'@/components/PageHeaderWrapper'
;
import
PageHeaderWrapper
from
'@/components/PageHeaderWrapper'
;
import
*
as
qiniu
from
'qiniu-js'
import
styles
from
'./ProductSpuAddOrUpdate.less'
;
import
styles
from
'./ProductSpuAddOrUpdate.less'
;
import
ProductAttrSelectFormItem
from
"../../components/Product/ProductAttrSelectFormItem"
;
import
ProductAttrSelectFormItem
from
"../../components/Product/ProductAttrSelectFormItem"
;
import
ProductSkuAddOrUpdateTable
from
"../../components/Product/ProductSkuAddOrUpdateTable"
;
import
ProductSkuAddOrUpdateTable
from
"../../components/Product/ProductSkuAddOrUpdateTable"
;
import
{
fileGetQiniuToken
,
fileUploadQiniu
}
from
"../../services/admin"
;
const
FormItem
=
Form
.
Item
;
const
FormItem
=
Form
.
Item
;
const
RadioGroup
=
Radio
.
Group
;
const
RadioGroup
=
Radio
.
Group
;
const
Option
=
Select
.
Option
;
const
Option
=
Select
.
Option
;
class
PicturesWall
extends
React
.
Component
{
state
=
{
token
:
undefined
,
// 七牛 token
previewVisible
:
false
,
previewImage
:
''
,
fileList
:
[{
// 目前图片
uid
:
-
1
,
name
:
'xxx.png'
,
status
:
'done'
,
url
:
'https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png'
,
}],
};
handleCancel
=
()
=>
this
.
setState
({
previewVisible
:
false
})
handlePreview
=
(
file
)
=>
{
this
.
setState
({
previewImage
:
file
.
url
||
file
.
thumbUrl
,
previewVisible
:
true
,
});
}
beforeUpload
=
async
()
=>
{
const
tokenResult
=
await
fileGetQiniuToken
();
if
(
tokenResult
.
code
!==
0
)
{
alert
(
'获得七牛上传 Token 失败'
);
return
false
;
}
this
.
setState
({
token
:
tokenResult
.
data
,
});
return
true
;
};
customRequest
=
({
action
,
file
,
headers
,
onError
,
onProgress
,
onSuccess
,
withCredentials
,})
=>
{
// 使用 FileReader 将上传的文件转换成二进制流,满足 'application/octet-stream' 格式的要求
const
reader
=
new
FileReader
();
reader
.
readAsArrayBuffer
(
file
);
let
fileData
=
null
;
reader
.
onload
=
(
e
)
=>
{
// 在文件读取结束后执行的操作
fileData
=
e
.
target
.
result
;
// 上传文件
// fileUploadQiniu(fileData);
// debugger;
// 使用 axios 进行文件上传的请求
// axios.put(action, fileData, {
// withCredentials,
// headers,
// onUploadProgress: ({ total, loaded }) => {
// // 进行上传进度输出,更加直观
// onProgress({ percent: Math.round(loaded / total * 100).toFixed(2) }, file);
// },
// }).then(response => {
// onSuccess(response, file);
// })
// .catch(onError);
let
observable
=
qiniu
.
upload
(
file
,
'123'
,
this
.
state
.
token
);
observable
.
subscribe
(
function
()
{
// next
},
function
()
{
// error
},
function
()
{
// complete
});
};
return
{
abort
()
{
console
.
log
(
'upload progress is aborted.'
);
},
};
};
handleChange
=
({
fileList
})
=>
this
.
setState
({
fileList
})
render
()
{
const
{
previewVisible
,
previewImage
,
fileList
}
=
this
.
state
;
const
uploadButton
=
(
<
div
>
<
Icon
type
=
"plus"
/>
<
div
className
=
"ant-upload-text"
>
Upload
<
/div
>
<
/div
>
);
return
(
<
div
className
=
"clearfix"
>
<
Upload
// action="https://www.mocky.io/v2/5cc8019d300000980a055e76"
action
=
"https://up-z2.qiniu.com"
listType
=
"picture-card"
fileList
=
{
fileList
}
onPreview
=
{
this
.
handlePreview
}
onChange
=
{
this
.
handleChange
}
beforeUpload
=
{
this
.
beforeUpload
}
customRequest
=
{
this
.
customRequest
}
>
{
fileList
.
length
>=
3
?
null
:
uploadButton
}
<
/Upload
>
<
Modal
visible
=
{
previewVisible
}
footer
=
{
null
}
onCancel
=
{
this
.
handleCancel
}
>
<
img
alt
=
"example"
style
=
{{
width
:
'100%'
}}
src
=
{
previewImage
}
/
>
<
/Modal
>
<
/div
>
);
}
};
// roleList
// roleList
@
connect
(({
productSpuList
,
productAttrList
,
productSpuAddOrUpdate
,
loading
})
=>
({
@
connect
(({
productSpuList
,
productAttrList
,
productSpuAddOrUpdate
,
loading
})
=>
({
// list: productSpuList.list.spus,
// list: productSpuList.list.spus,
...
@@ -246,9 +363,10 @@ class ProductSpuAddOrUpdate extends Component {
...
@@ -246,9 +363,10 @@ class ProductSpuAddOrUpdate extends Component {
})(
<
Input
placeholder
=
"请输入"
/>
)}
})(
<
Input
placeholder
=
"请输入"
/>
)}
<
/FormItem
>
<
/FormItem
>
<
FormItem
labelCol
=
{{
span
:
5
}}
wrapperCol
=
{{
span
:
15
}}
label
=
"商品主图"
>
<
FormItem
labelCol
=
{{
span
:
5
}}
wrapperCol
=
{{
span
:
15
}}
label
=
"商品主图"
>
{
form
.
getFieldDecorator
(
'picUrls'
,
{
{
/*{form.getFieldDecorator('picUrls', {*/
}
initialValue
:
''
,
// TODO 修改 // TODO 芋艿,做成上传组件
{
/* initialValue: '', // TODO 修改 // TODO 芋艿,做成上传组件*/
}
})(
<
Input
placeholder
=
"请输入"
/>
)}
{
/*})(<Input placeholder="请输入" />)}*/
}
<
PicturesWall
/>
<
/FormItem
>
<
/FormItem
>
<
FormItem
labelCol
=
{{
span
:
5
}}
wrapperCol
=
{{
span
:
15
}}
label
=
"是否上架"
>
<
FormItem
labelCol
=
{{
span
:
5
}}
wrapperCol
=
{{
span
:
15
}}
label
=
"是否上架"
>
{
form
.
getFieldDecorator
(
'visible'
,
{
{
form
.
getFieldDecorator
(
'visible'
,
{
...
...
admin-web/src/pages/Product/ProductSpuAddOrUpdate.less
浏览文件 @
6c135166
...
@@ -13,3 +13,13 @@
...
@@ -13,3 +13,13 @@
.tableDelete {
.tableDelete {
color: red;
color: red;
}
}
.ant-upload-select-picture-card i {
font-size: 32px;
color: #999;
}
.ant-upload-select-picture-card .ant-upload-text {
margin-top: 8px;
color: #666;
}
admin-web/src/services/admin.js
浏览文件 @
6c135166
...
@@ -156,3 +156,17 @@ export async function dictionaryDelete(params) {
...
@@ -156,3 +156,17 @@ export async function dictionaryDelete(params) {
method
:
'POST'
,
method
:
'POST'
,
});
});
}
}
// file
export
async
function
fileGetQiniuToken
()
{
return
request
(
`/admin-api/admins/file/get_qiniu_token`
,
{
method
:
'GET'
,
});
}
// export async function fileUploadQiniu(fileData) {
// return request(`/qiniu/upload`, {
// method: 'POST',
// });
// }
admin/admin-application/src/main/java/cn/iocoder/mall/admin/application/config/MVCConfiguration.java
浏览文件 @
6c135166
...
@@ -38,7 +38,8 @@ public class MVCConfiguration implements WebMvcConfigurer {
...
@@ -38,7 +38,8 @@ public class MVCConfiguration implements WebMvcConfigurer {
public
void
addInterceptors
(
InterceptorRegistry
registry
)
{
public
void
addInterceptors
(
InterceptorRegistry
registry
)
{
// registry.addInterceptor(securityInterceptor).addPathPatterns("/user/**", "/admin/**"); // 只拦截我们定义的接口
// registry.addInterceptor(securityInterceptor).addPathPatterns("/user/**", "/admin/**"); // 只拦截我们定义的接口
registry
.
addInterceptor
(
adminAccessLogInterceptor
).
addPathPatterns
(
"/admins/**"
);
registry
.
addInterceptor
(
adminAccessLogInterceptor
).
addPathPatterns
(
"/admins/**"
);
registry
.
addInterceptor
(
adminSecurityInterceptor
.
setIgnoreUrls
(
ignoreUrls
)).
addPathPatterns
(
"/admins/**"
);
registry
.
addInterceptor
(
adminSecurityInterceptor
.
setIgnoreUrls
(
ignoreUrls
)).
addPathPatterns
(
"/admins/**"
)
.
excludePathPatterns
(
"/admins/passport/login"
);
// 排除登陆接口
}
}
@Override
@Override
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论