Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
J
jinfa-platform
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
黄庭坚
jinfa-platform
Commits
64c7300a
Commit
64c7300a
authored
Sep 29, 2020
by
前端-钟卫鹏
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix:取消图片尺寸
parent
158b6bbd
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
68 additions
and
27 deletions
+68
-27
addProducts.tsx
src/pages/commodity/products/addProducts.tsx
+43
-3
basicInfoForm.tsx
...ages/commodity/products/addProductsItem/basicInfoForm.tsx
+1
-1
productImageForm.tsx
...s/commodity/products/addProductsItem/productImageForm.tsx
+24
-23
No files found.
src/pages/commodity/products/addProducts.tsx
View file @
64c7300a
import
React
,
{
useState
,
useRef
,
useEffect
,
createContext
}
from
'react'
import
{
history
}
from
'umi'
;
import
{
Button
,
Card
,
Tabs
,
message
}
from
'antd'
import
{
Button
,
Card
,
Tabs
,
message
,
Badge
}
from
'antd'
import
{
PageHeaderWrapper
}
from
'@ant-design/pro-layout'
import
{
SaveOutlined
,
...
...
@@ -106,8 +106,6 @@ const AddProducts: React.FC<{}> = (props) => {
}
},
[
selectCategoryId
])
// useEffect(() => {
// renderTemplate(currentTemplateName)
// }, [currentTemplateName])
...
...
@@ -371,7 +369,49 @@ const AddProducts: React.FC<{}> = (props) => {
onRef=
{
(
refs
)
=>
setFormRefs
([...
formRefs
,
refs
])
}
/>
</
TabPane
>
{
/* 带校验 Badge */
}
{
/* <TabPane tab={<Badge count={1} offset={[12, 0]}>基本信息</Badge>} key="1">
<BasicInfoForm
onRef={(refs) => setFormRefs([...formRefs, refs])}
onChangeAttributeList={(_lists: any) => setAttributeList(_lists)} />
</TabPane>
<TabPane tab={<Badge count={1} offset={[12, 0]}>选择货品</Badge>} key="2">
<SelectGoodsForm />
</TabPane>
<TabPane tab={<Badge count={1} offset={[12, 0]}>商品属性</Badge>} key="3">
<ProductAttributeForm
onRef={(refs) => setFormRefs([...formRefs, refs])}
attributesData={attributeList}
/>
</TabPane>
<TabPane tab={<Badge count={1} offset={[12, 0]}>价格设置</Badge>} key="4">
<PriceAttributeForm
onRef={(refs) => setFormRefs([...formRefs, refs])}
/>
</TabPane>
<TabPane tab={<Badge count={1} offset={[12, 0]}>商品图片</Badge>} key="5">
<ProductImageForm />
</TabPane>
<TabPane tab={<Badge count={1} offset={[12, 0]}>商品描述</Badge>} key="6">
{
renderTemplate()
}
</TabPane>
<TabPane tab={<Badge count={1} offset={[12, 0]}>物流信息</Badge>} key="7">
<LogisticsForm
onRef={(refs) => setFormRefs([...formRefs, refs])}
/>
</TabPane>
<TabPane tab={<Badge count={1} offset={[12, 0]}>其他</Badge>} key="8">
<OtherForm
onRef={(refs) => setFormRefs([...formRefs, refs])}
/>
</TabPane> */
}
</
Tabs
>
</
Card
>
</
PageHeaderWrapper
>)
}
...
...
src/pages/commodity/products/addProductsItem/basicInfoForm.tsx
View file @
64c7300a
...
...
@@ -6,7 +6,6 @@ import {
PlusOutlined
,
MinusOutlined
,
}
from
'@ant-design/icons'
import
styles
from
'./index.less'
import
{
PublicApi
}
from
'@/services/api'
;
import
{
GetProductCustomerGetCustomerCategoryTreeResponse
,
...
...
@@ -208,6 +207,7 @@ const BasicInfoForm: React.FC<Iprops> = (props) => {
]
}
>
<
Cascader
allowClear=
{
false
}
disabled=
{
!
isUpdateAttribute
}
options=
{
customerCategoryTree
}
fieldNames=
{
{
label
:
'title'
,
value
:
'id'
,
children
:
'children'
}
}
...
...
src/pages/commodity/products/addProductsItem/productImageForm.tsx
View file @
64c7300a
...
...
@@ -129,30 +129,31 @@ const ProductImageForm: React.FC<{}> = (props) => {
if
(
!
isLimit
)
{
message
.
error
(
'上传图片不超过600K!'
);
}
return
isJpgOrPng
&&
isLimit
&&
isSize
(
file
,
800
,
800
);
return
isJpgOrPng
&&
isLimit
}
//检测尺寸
const
isSize
=
(
file
,
w
,
h
)
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
let
width
=
w
;
let
height
=
h
;
let
_URL
=
window
.
URL
||
window
.
webkitURL
;
let
img
=
new
Image
();
img
.
onload
=
function
()
{
let
valid
=
img
.
width
<=
width
&&
img
.
height
<=
height
;
valid
?
resolve
()
:
reject
();
};
img
.
src
=
_URL
.
createObjectURL
(
file
);
}).
then
(
()
=>
{
return
file
;
},
()
=>
{
message
.
error
(
file
.
name
+
"图片尺寸不符合要求,请修改后重新上传!"
);
return
Promise
.
reject
();
}
);
};
// 检测尺寸
// const isSize = (file, w, h) => {
// return new Promise((resolve, reject) => {
// let width = w;
// let height = h;
// let _URL = window.URL || window.webkitURL;
// let img = new Image();
// img.onload = function() {
// let valid = img.width <= width && img.height <= height;
// valid ? resolve() : reject();
// };
// img.src = _URL.createObjectURL(file);
// }).then(
// () => {
// return file;
// },
// () => {
// message.error(file.name + "图片尺寸不符合要求,请修改后重新上传!");
// return Promise.reject();
// }
// );
// };
const
handlePreview
=
async
file
=>
{
if
(
!
file
.
url
&&
!
file
.
preview
)
{
...
...
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