Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
saas
/
scrm-micro-services
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit deabf2f5
authored
Oct 21, 2021
by
cwq0219
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
新增商品;表单
1 parent
80df3888
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
194 additions
and
47 deletions
src/components/glsx-combi-form/index.vue
src/views/cmmodityLibrary/editProduct.vue
src/components/glsx-combi-form/index.vue
View file @
deabf2f
...
@@ -46,7 +46,7 @@
...
@@ -46,7 +46,7 @@
</el-radio-group>
</el-radio-group>
<el-date-picker
v-else-if=
"item.type === 'datePicker'"
v-model=
"formObj[item.name]"
:type=
"item.dateType || 'daterange'"
:clearable=
"item.isClear || false"
range-separator=
"至"
start-placeholder=
"开始日期"
end-placeholder=
"结束日期"
:picker-options=
"pickerOption[item.pickerOptions]"
></el-date-picker>
<el-date-picker
v-else-if=
"item.type === 'datePicker'"
v-model=
"formObj[item.name]"
:type=
"item.dateType || 'daterange'"
:clearable=
"item.isClear || false"
range-separator=
"至"
start-placeholder=
"开始日期"
end-placeholder=
"结束日期"
:picker-options=
"pickerOption[item.pickerOptions]"
></el-date-picker>
<!-- 图片上传 -->
<!-- 图片上传 -->
<el-upload
v-else-if=
"item.type === 'upload'"
:auto-upload=
"false"
action=
"#"
list-type=
"picture-card"
:limit=
"item.limitNum || 1"
:fileList=
"formObj[item.name]"
accept=
"image/jpeg,image/png,image/jpg"
:on-change=
"(file, fileList) => handleChangeUpload(file, fileList, item)"
>
<
!-- <
el-upload v-else-if="item.type === 'upload'" :auto-upload="false" action="#" list-type="picture-card" :limit="item.limitNum || 1" :fileList="formObj[item.name]" accept="image/jpeg,image/png,image/jpg" :on-change="(file, fileList) => handleChangeUpload(file, fileList, item)">
<i slot="default" class="el-icon-plus"></i>
<i slot="default" class="el-icon-plus"></i>
<div slot="file" slot-scope="{ file }">
<div slot="file" slot-scope="{ file }">
<img class="el-upload-list__item-thumbnail" :src="file.url" alt="" />
<img class="el-upload-list__item-thumbnail" :src="file.url" alt="" />
...
@@ -59,13 +59,45 @@
...
@@ -59,13 +59,45 @@
</span>
</span>
</span>
</span>
</div>
</div>
</el-upload>
</el-upload> -->
<
template
v-else-if=
"item.type === 'upload'"
>
<p
class=
"photo-top-tips"
>
{{
item
.
topTips
}}
</p>
<div
v-if=
"Array.isArray(formObj[item.name]) ? (formObj[item.name].length
< item
.
maxPhotoNum
)
:
!
formObj
[
item
.
name
]"
class=
"activity-img"
>
<div
class=
"add"
>
+
</div>
<span
class=
"number"
>
{{
formObj
[
item
.
name
].
length
}}
/
{{
item
.
maxPhotoNum
}}
</span>
<input
type=
"file"
style=
"opacity: 0;"
:id=
"item.name + 'file'"
ref=
"file"
class=
"activity-img img-w-h"
accept=
"image/png, image/jpeg, image/gif, image/jpg"
@
change=
"e => handleImgChange(e, item)"
>
</div>
<template>
<div
v-if=
"Array.isArray(formObj[item.name]) ? formObj[item.name].length : formObj[item.name]"
>
<span
v-if=
"Array.isArray(formObj[item.name])"
>
<span
v-for=
"(subItem, subIndex) in formObj[item.name]"
:key=
"subIndex"
class=
"muti-imgs img-w-h"
>
<img
class=
"img-w-h"
:src=
"subItem.content"
/>
<span
class=
"img-btns"
>
<span
class=
"btn-item"
>
<i
class=
"el-icon-delete"
@
click=
"handleImgDelete(item, subIndex)"
></i>
<i
class=
"el-icon-zoom-in"
@
click=
"handleImgLook(subItem.content)"
></i>
</span>
</span>
</span>
</span>
<span
v-else
class=
"muti-imgs"
>
<img
class=
"img-w-h"
:src=
"formObj[item.name]"
/>
<span
class=
"img-btns"
>
<span
class=
"btn-item"
>
<i
class=
"el-icon-delete"
@
click=
"handleImgDelete(item)"
></i>
<i
class=
"el-icon-zoom-in"
@
click=
"handleImgLook(formObj[item.name])"
></i>
</span>
</span>
</span>
</div>
</
template
>
</template>
</el-form-item>
</el-form-item>
</template>
</template>
<slot
name=
"footer"
></slot>
<slot
name=
"footer"
></slot>
</el-form>
</el-form>
<el-dialog
:visible
.
sync=
"isImgVisible"
>
<el-dialog
:visible
.
sync=
"isImgVisible"
>
<img
width=
"100%"
:src=
"dialogImageUrl"
alt=
""
/>
<img
class=
"dialog-img"
width=
"100%"
:src=
"dialogImageUrl"
alt=
""
/>
</el-dialog>
</el-dialog>
</div>
</div>
</template>
</template>
...
@@ -133,37 +165,71 @@ export default {
...
@@ -133,37 +165,71 @@ export default {
item
.
keyFn
()
item
.
keyFn
()
}
}
},
},
// 图片上传
// 图片
handleChangeUpload
(
file
,
fileList
,
targetItem
)
{
handleImgChange
(
e
,
targetItem
)
{
var
reader
=
new
FileReader
()
var
file
=
e
.
srcElement
.
files
[
0
]
const
limitSize
=
targetItem
.
limitSize
||
10
const
limitSize
=
targetItem
.
limitSize
||
10
const
isType
=
[
'image/jpeg'
,
'image/png'
,
'image/jpg'
].
includes
(
file
.
raw
.
type
)
const
isType
=
[
'image/jpeg'
,
'image/png'
,
'image/jpg'
].
includes
(
file
.
type
)
const
isLt10M
=
file
.
size
/
1024
/
1024
<
limitSize
const
isLt
=
file
.
size
/
1024
/
1024
<
limitSize
const
limitNum
=
targetItem
.
limitNum
||
1
const
maxPhotoNum
=
targetItem
.
maxPhotoNum
||
1
if
(
maxPhotoNum
==
this
.
formObj
[
targetItem
.
name
].
length
)
{
if
(
limitNum
==
this
.
formObj
[
targetItem
.
name
].
length
)
{
this
.
$message
.
error
(
'只能上传'
+
maxPhotoNum
+
'张图片'
)
this
.
$message
.
error
(
'只能上传'
+
limitNum
+
'张图片'
)
return
true
return
true
}
}
if
(
!
isType
)
{
if
(
!
isType
)
{
this
.
$message
.
error
(
'上传图片不是jpg、jpeg或png的格式!'
)
this
.
$message
.
error
(
'上传图片不是jpg、jpeg或png的格式!'
)
this
.
formObj
[
targetItem
.
name
]
=
this
.
formObj
[
targetItem
.
name
].
filter
(
item
=>
item
.
uid
!=
file
.
uid
)
return
true
return
true
}
}
if
(
!
isLt
10M
)
{
if
(
!
isLt
)
{
this
.
$message
.
error
(
'上传图片大小不能超过'
+
limitSize
+
'MB!'
)
this
.
$message
.
error
(
'上传图片大小不能超过'
+
limitSize
+
'MB!'
)
this
.
formObj
[
targetItem
.
name
]
=
this
.
formObj
[
targetItem
.
name
].
filter
(
item
=>
item
.
uid
!=
file
.
uid
)
return
true
return
true
}
}
reader
.
readAsDataURL
(
file
)
targetItem
.
handleUpload
(
file
,
fileList
,
targetItem
)
reader
.
onload
=
e
=>
{
targetItem
.
handleUpload
(
e
,
file
,
targetItem
)
}
},
},
handleImgPreview
(
file
)
{
// 图片删除
this
.
dialogImageUrl
=
file
.
url
handleImgDelete
(
targetItem
,
subIndex
=
-
1
)
{
this
.
isImgVisible
=
true
Array
.
isArray
(
this
.
formObj
[
targetItem
.
name
])
?
this
.
formObj
[
targetItem
.
name
].
splice
(
subIndex
,
1
)
:
(
this
.
formObj
[
targetItem
.
name
]
=
''
)
},
},
handleImgRemove
(
file
,
targetItem
)
{
// 图片查看
this
.
formObj
[
targetItem
.
name
]
=
this
.
formObj
[
targetItem
.
name
].
filter
(
item
=>
item
.
uid
!=
file
.
uid
)
handleImgLook
(
src
)
{
this
.
isImgVisible
=
true
this
.
dialogImageUrl
=
src
}
}
// 图片上传
// handleChangeUpload(file, fileList, targetItem) {
// const limitSize = targetItem.limitSize || 10
// const isType = ['image/jpeg', 'image/png', 'image/jpg'].includes(file.raw.type)
// const isLt10M = file.size / 1024 / 1024 < limitSize
// const limitNum = targetItem.limitNum || 1
// if (limitNum == this.formObj[targetItem.name].length) {
// this.$message.error('只能上传' + limitNum + '张图片')
// return true
// }
// if (!isType) {
// this.$message.error('上传图片不是jpg、jpeg或png的格式!')
// this.formObj[targetItem.name] = this.formObj[targetItem.name].filter(item => item.uid != file.uid)
// return true
// }
// if (!isLt10M) {
// this.$message.error('上传图片大小不能超过' + limitSize + 'MB!')
// this.formObj[targetItem.name] = this.formObj[targetItem.name].filter(item => item.uid != file.uid)
// return true
// }
// targetItem.handleUpload(file, fileList, targetItem)
// },
// handleImgPreview(file) {
// this.dialogImageUrl = file.url
// this.isImgVisible = true
// },
// handleImgRemove(file, targetItem) {
// this.formObj[targetItem.name] = this.formObj[targetItem.name].filter(item => item.uid != file.uid)
// }
}
}
}
}
</
script
>
</
script
>
...
@@ -239,4 +305,85 @@ export default {
...
@@ -239,4 +305,85 @@ export default {
/* .glsx-combi-form .tips {
/* .glsx-combi-form .tips {
margin: 0;
margin: 0;
} */
} */
/* 图片上传 */
.glsx-combi-form
.photo-top-tips
{
/* height: 36px; */
margin
:
0
0
;
color
:
#999999
;
}
.glsx-combi-form
.img-w-h
{
width
:
88px
;
height
:
74px
;
}
.glsx-combi-form
.activity-img
{
position
:
relative
;
color
:
#999999
;
border
:
1px
dashed
#d9d9d9
;
cursor
:
pointer
;
}
.glsx-combi-form
.activity-Input
{
position
:
absolute
;
top
:
0
;
left
:
0
;
}
.glsx-combi-form
.muti-imgs
{
display
:
inline-block
;
position
:
relative
;
}
.activity-img
.add
{
position
:
absolute
;
top
:
40%
;
font-size
:
40px
;
left
:
50%
;
transform
:
translate3d
(
-50%
,
-50%
,
0
);
}
.activity-img
.number
{
position
:
absolute
;
bottom
:
0
;
left
:
50%
;
transform
:
translateX
(
-50%
);
}
.muti-imgs
.img-btns
{
display
:
none
;
height
:
100%
;
position
:
absolute
;
width
:
88px
;
height
:
74px
;
left
:
0
;
top
:
0
;
z-index
:
2
;
color
:
#fff
;
background
:
rgba
(
0
,
0
,
0
,
0.5
);
}
.glsx-combi-form
.el-icon-delete
,
.glsx-combi-form
.el-icon-zoom-in
{
cursor
:
pointer
;
}
.muti-imgs
.img-btns
.btn-item
{
position
:
absolute
;
top
:
50%
;
left
:
50%
;
transform
:
translate
(
-50%
,
-50%
);
}
.muti-imgs
.img-btns
.btn-item
{
display
:
flex
;
width
:
70%
;
justify-content
:
space-around
;
}
.muti-imgs
:hover
.img-btns
{
display
:
block
;
}
.glsx-combi-form
.dialog-img
{
width
:
100%
;
height
:
100%
;
}
/* 图片上传 */
</
style
>
</
style
>
src/views/cmmodityLibrary/editProduct.vue
View file @
deabf2f
...
@@ -9,8 +9,8 @@
...
@@ -9,8 +9,8 @@
</div>
</div>
<div
slot=
"proTable"
class=
"select-pro"
>
<div
slot=
"proTable"
class=
"select-pro"
>
<GLTable
v-show=
"selectedProInfoList.length"
ref=
"warehousListRef"
:hasPage=
"hasPage"
:searchForm=
"searchForm"
:tableParams=
"tableParams"
:tableData=
"selectedProInfoList"
>
<GLTable
v-show=
"selectedProInfoList.length"
ref=
"warehousListRef"
:hasPage=
"hasPage"
:searchForm=
"searchForm"
:tableParams=
"tableParams"
:tableData=
"selectedProInfoList"
>
<span
slot=
"
coverImgUrl
"
slot-scope=
"scope"
>
<span
slot=
"
goodsImage
"
slot-scope=
"scope"
>
<img
:src=
"scope.scope.goodsImage"
/>
<img
class=
"m-t-10"
:src=
"scope.scope.goodsImage"
/>
</span>
</span>
<span
slot=
"price"
>
<span
slot=
"price"
>
<el-input
placeholder=
"请输入"
v-model=
"editForm.price"
><template
slot=
"append"
>
元
</
template
></el-input>
<el-input
placeholder=
"请输入"
v-model=
"editForm.price"
><template
slot=
"append"
>
元
</
template
></el-input>
...
@@ -67,7 +67,7 @@ export default {
...
@@ -67,7 +67,7 @@ export default {
editForm
:
{
editForm
:
{
name
:
''
,
name
:
''
,
price
:
''
,
price
:
''
,
coverImgUrl
:
[]
coverImgUrl
:
''
},
},
selectedProInfoList
:
[],
selectedProInfoList
:
[],
editRule
:
{
editRule
:
{
...
@@ -83,22 +83,16 @@ export default {
...
@@ -83,22 +83,16 @@ export default {
label
:
'商品缩略图'
,
label
:
'商品缩略图'
,
name
:
'coverImgUrl'
,
name
:
'coverImgUrl'
,
type
:
'upload'
,
type
:
'upload'
,
limitSize
:
1
,
// limitSize: 1,
maxPhotoNum
:
1
,
tips
:
'建议尺寸:300像素 * 300像素,图片大小不得超过1M'
,
tips
:
'建议尺寸:300像素 * 300像素,图片大小不得超过1M'
,
handleUpload
:
(
file
,
fileList
,
targetItem
)
=>
{
handleUpload
:
(
e
,
file
,
targetItem
)
=>
{
// this.editForm[targetItem.name] = fileList
const
imgFile
=
e
.
target
.
result
// this.editForm[targetItem.name].pop()
const
base64
=
file
.
name
.
split
(
'.'
)[
1
]
+
'@'
+
imgFile
.
split
(
','
)[
1
]
var
reader
=
new
FileReader
()
uploadImg
({
file
:
base64
,
fileType
:
'image'
}).
then
(
res
=>
{
var
fileInfo
=
file
.
raw
this
.
editForm
[
targetItem
.
name
]
=
res
reader
.
readAsDataURL
(
fileInfo
)
this
.
$refs
.
editFormRef
.
$refs
[
this
.
editChildRef
].
validateField
(
targetItem
.
name
)
reader
.
onload
=
e
=>
{
})
const
imgFile
=
e
.
target
.
result
const
base64
=
fileInfo
.
name
.
split
(
'.'
)[
1
]
+
'@'
+
imgFile
.
split
(
','
)[
1
]
uploadImg
({
file
:
base64
,
fileType
:
'image'
}).
then
(
res
=>
{
this
.
editForm
[
targetItem
.
name
]
=
[{
url
:
res
,
uid
:
file
.
uid
}]
this
.
$refs
.
editFormRef
.
$refs
[
this
.
editChildRef
].
validateField
(
targetItem
.
name
)
})
}
}
}
},
},
{
{
...
@@ -134,7 +128,7 @@ export default {
...
@@ -134,7 +128,7 @@ export default {
{
{
label
:
'商品图片'
,
label
:
'商品图片'
,
prop
:
'goodsImage'
,
prop
:
'goodsImage'
,
addHtml
:
'
coverImgUrl
'
addHtml
:
'
goodsImage
'
},
},
{
{
label
:
'商品名称'
,
label
:
'商品名称'
,
...
@@ -175,9 +169,18 @@ export default {
...
@@ -175,9 +169,18 @@ export default {
getInfo
()
{
getInfo
()
{
getGoodInfoApi
({
id
:
this
.
routeInfo
.
id
}).
then
(
res
=>
{
getGoodInfoApi
({
id
:
this
.
routeInfo
.
id
}).
then
(
res
=>
{
console
.
log
(
res
)
console
.
log
(
res
)
this
.
editForm
.
id
=
res
.
id
this
.
editForm
=
res
this
.
editForm
.
name
=
res
.
name
this
.
editForm
.
price
=
res
.
price
?
(
res
.
price
/
100
).
toFixed
(
2
)
:
''
this
.
editForm
.
price
=
res
.
price
if
(
res
.
goodsInfo
)
{
this
.
selectedProInfo
=
{
id
:
res
.
goodsInfo
.
goodsId
,
goodsName
:
res
.
goodsInfo
.
name
,
merchantId
:
res
.
goodsInfo
.
merchantId
,
merchantName
:
res
.
goodsInfo
.
merchantName
,
goodsImage
:
res
.
goodsInfo
.
selfGoodsImageUrl
}
this
.
selectedProInfoList
=
[
this
.
selectedProInfo
]
}
})
})
},
},
handleProDelete
()
{
handleProDelete
()
{
...
@@ -205,7 +208,6 @@ export default {
...
@@ -205,7 +208,6 @@ export default {
this
.
$refs
.
editFormRef
.
$refs
[
this
.
editChildRef
].
validate
(
valid
=>
{
this
.
$refs
.
editFormRef
.
$refs
[
this
.
editChildRef
].
validate
(
valid
=>
{
if
(
valid
)
{
if
(
valid
)
{
var
params
=
JSON
.
parse
(
JSON
.
stringify
(
this
.
editForm
))
var
params
=
JSON
.
parse
(
JSON
.
stringify
(
this
.
editForm
))
params
.
coverImgUrl
=
this
.
editForm
.
coverImgUrl
[
0
].
url
params
.
price
=
this
.
editForm
.
price
*
100
params
.
price
=
this
.
editForm
.
price
*
100
params
.
shopMallGoodsInfo
=
{
params
.
shopMallGoodsInfo
=
{
goodsId
:
this
.
selectedProInfo
.
id
,
goodsId
:
this
.
selectedProInfo
.
id
,
...
@@ -214,9 +216,7 @@ export default {
...
@@ -214,9 +216,7 @@ export default {
merchantName
:
this
.
selectedProInfo
.
merchantName
,
merchantName
:
this
.
selectedProInfo
.
merchantName
,
selfGoodsImageUrl
:
this
.
selectedProInfo
.
goodsImage
selfGoodsImageUrl
:
this
.
selectedProInfo
.
goodsImage
}
}
console
.
log
(
params
)
insertGoodApi
(
params
).
then
(
res
=>
{
insertGoodApi
(
params
).
then
(
res
=>
{
console
.
log
(
res
)
this
.
$message
({
this
.
$message
({
message
:
res
.
code
==
'0'
?
'操作成功'
:
'操作失败'
,
message
:
res
.
code
==
'0'
?
'操作成功'
:
'操作失败'
,
type
:
res
.
code
==
'0'
?
'success'
:
'error'
type
:
res
.
code
==
'0'
?
'success'
:
'error'
...
@@ -243,7 +243,7 @@ export default {
...
@@ -243,7 +243,7 @@ export default {
/* width: calc(98% - 140px); */
/* width: calc(98% - 140px); */
width
:
98%
;
width
:
98%
;
}
}
.edit-pro
img
{
.edit-pro
.m-t-10
{
margin-top
:
10px
;
margin-top
:
10px
;
}
}
</
style
>
</
style
>
Write
Preview
Markdown
is supported
Attach a file
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 post a comment