Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录
切换导航
S
shop-new
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
王天霸
shop-new
Commits
9a862698
提交
9a862698
authored
3月 18, 2022
作者:
王天霸
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
级联选择器处理
上级
7134b940
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
297 行增加
和
217 行删除
+297
-217
.env.development
.env.development
+1
-1
goodsinfomation.vue
src/views/system/goods/add/components/goodsinfomation.vue
+296
-216
没有找到文件。
.env.development
浏览文件 @
9a862698
...
...
@@ -7,9 +7,9 @@ ENV = 'development'
# 测试环境
VUE_APP_BASE_API = 'http://192.168.26.179:6605/api/v1'
#VUE_APP_BASE_API = 'http://192.168.111.240:6605/api/v1'
# 文档模块 直接调用 sys开放接口
VUE_APP_BASE_SYS_API = 'http://sysapi.jxhh.com'
# 路由懒加载
VUE_CLI_BABEL_TRANSPILE_MODULES = true
src/views/system/goods/add/components/goodsinfomation.vue
浏览文件 @
9a862698
<
template
>
<div
class=
"goods-info"
>
<el-form
:model=
"goodsInfoForm"
:rules=
"goodsInfoRules"
ref=
"goodsInfoForm"
label-width=
"150px"
class=
"demo-goodsInfoForm"
size=
"small"
>
<el-form
:model=
"goodsInfoForm"
:rules=
"goodsInfoRules"
ref=
"goodsInfoForm"
label-width=
"150px"
class=
"demo-goodsInfoForm"
size=
"small"
>
<el-form-item
label=
"商品分类:"
prop=
"categoryStr"
>
<el-input
style=
"width:420px;"
v-model
.
trim=
"goodsInfoForm.categoryStr"
:disabled=
"true"
></el-input>
<el-link
class=
"edit-type-span el-icon-edit"
type=
"primary"
:underline=
"false"
@
click=
"editType"
>
修改所在类目
</el-link>
<el-link
class=
"edit-type-span el-icon-edit"
type=
"primary"
:underline=
"false"
@
click=
"editType"
>
修改所在类目
</el-link>
<span
class=
"tip-span"
>
该商品所在类目须支持七天无理由退货
</span>
</el-form-item>
...
...
@@ -41,12 +43,7 @@
</el-form-item>
-->
<el-form-item
label=
"所属品牌:"
prop=
"brand_id"
>
<el-select
v-model
.
trim=
"goodsInfoForm.brand_id"
placeholder=
"请选择商品品牌"
style=
"width: 420px;"
>
<el-option
v-for=
"item in brandOptions"
:key=
"item.id"
:label=
"item.brand_cn"
:value=
"item.id"
></el-option>
<el-option
v-for=
"item in brandOptions"
:key=
"item.id"
:label=
"item.brand_cn"
:value=
"item.id"
></el-option>
</el-select>
<el-link
class=
"edit-type-span el-icon-plus"
type=
"primary"
:underline=
"false"
@
click=
"toBrand"
>
新增品牌
</el-link>
</el-form-item>
...
...
@@ -63,36 +60,30 @@
商品图片最多上传7张,默认第一张为主图
<span
style=
"margin-left: 20px;"
>
单张图片需限制在2M以内,可上传png、jpg格式,尺寸要求为800 * 800
</span>
</span>
<draggable
:list=
"goodsImgFileList"
group=
"article"
class=
"dragArea"
@
end=
"handchange($event)"
>
<div
v-for=
"(element,index) in goodsImgFileList"
:key=
"index"
class=
"list-complete-item"
style=
"float:left;margin:0 10px;"
>
<div
style=
"width:98px;height:98px;position: relative;"
class=
""
@
mouseover=
"showDelBtn(index)"
@
mouseleave=
"hiddenDelBtn"
>
<draggable
:list=
"goodsImgFileList"
group=
"article"
class=
"dragArea"
@
end=
"handchange($event)"
>
<div
v-for=
"(element,index) in goodsImgFileList"
:key=
"index"
class=
"list-complete-item"
style=
"float:left;margin:0 10px;"
>
<div
style=
"width:98px;height:98px;position: relative;"
class=
""
@
mouseover=
"showDelBtn(index)"
@
mouseleave=
"hiddenDelBtn"
>
<img
v-if=
"element"
:src=
"element.url"
width=
"98"
height=
"98"
/>
<span
class=
"iconcur"
v-show=
"index==currentDelBtn"
style=
"width:100%;height:100%;line-height: 98px;text-align: center; position:absolute;top:0;left:0;background-color: rgba(0,0,0,0.5);
<span
class=
"iconcur"
v-show=
"index==currentDelBtn"
style=
"width:100%;height:100%;line-height: 98px;text-align: center; position:absolute;top:0;left:0;background-color: rgba(0,0,0,0.5);
transition: opacity .3s;"
>
<i
class=
"el-icon-zoom-in iconcur"
style=
"font-size:20px;color:#fff;"
@
click=
"lookimg(element)"
></i>
<i
class=
"el-icon-delete iconcur"
style=
"font-size:20px;color:#fff;"
@
click=
"deleImg(element,index)"
></i>
<i
class=
"el-icon-zoom-in iconcur"
style=
"font-size:20px;color:#fff;"
@
click=
"lookimg(element)"
></i>
<i
class=
"el-icon-delete iconcur"
style=
"font-size:20px;color:#fff;"
@
click=
"deleImg(element,index)"
></i>
</span>
</div>
</div>
<p
v-if=
"index==0"
style=
"margin:0;padding:0;text-align:center;background:#ccc;color:#fff;"
>
主图
</p>
</div>
</draggable>
<el-dialog
:visible
.
sync=
"dialogVisible"
>
<img
width=
"100%"
:src=
"dialogImageUrl"
alt=
""
>
</el-dialog>
<!--
{{
goodsImgFileList
}}
-->
<el-upload
class=
"upload-img"
list-type=
"picture-card"
action=
"#"
:limit=
"7"
:on-exceed=
"limitImg5"
:before-upload=
"beforeUpGoodsImg"
:http-request=
"uploadGoodsImg"
:show-file-list=
"false"
:on-preview=
"handlePictureCardPreview"
:on-remove=
"handleRemove"
:file-list=
"goodsImgFileList"
><i
class=
"el-icon-plus"
/>
<!--
{{
goodsImgFileList
}}
-->
<el-upload
class=
"upload-img"
list-type=
"picture-card"
action=
"#"
:limit=
"7"
:on-exceed=
"limitImg5"
:before-upload=
"beforeUpGoodsImg"
:http-request=
"uploadGoodsImg"
:show-file-list=
"false"
:on-preview=
"handlePictureCardPreview"
:on-remove=
"handleRemove"
:file-list=
"goodsImgFileList"
><i
class=
"el-icon-plus"
/>
</el-upload>
<el-dialog
:visible
.
sync=
"goodsImgVisible"
>
<img
width=
"100%"
:src=
"goodsImgUrlDialog"
alt=
""
>
...
...
@@ -100,54 +91,33 @@
</el-form-item>
<el-form-item
label=
'商品视频:'
>
<el-form-item
label=
'商品视频:'
>
<span
class=
"tip-span"
style=
"display: block;line-height: 34px;"
>
最多上传一个视频(mp4格式),视频时长不超过30秒,
<span
style=
"margin-left: 20px;"
>
视频大小不超过10M,默认视频在图片前面
</span>
</span>
<video
v-if=
"vediosrc"
style=
"width:300px;height:150px;float:left;margin:0 10px 0 0;"
v-bind:src=
"vediosrc"
class=
"avatar video-avatar"
controls=
"controls"
>
您的浏览器不支持视频播放
</video>
<i
@
click=
"delvideo"
v-if=
"vediosrc"
class=
"el-icon-circle-close iconcur"
style=
"color:red;font-size: 18px;"
></i>
<el-upload
v-if=
"!vediosrc"
class=
"upload-img"
ref=
"videoref"
action=
"#"
:limit=
"1"
list-type=
"picture-card"
:before-upload=
"beforeUpGoodsvedio"
:http-request=
"uploadGoodsvedio"
:show-file-list=
"false"
:on-preview=
"handlePictureCardPreview"
:on-remove=
"handleRemove"
:on-error=
"vedioerror"
:file-list=
"goodsvedioFileList"
><i
class=
"el-icon-plus"
/>
<!-- v-if="videoform.showvideopath !='' && !videoflag" -->
<video
v-if=
"vediosrc"
style=
"width:300px;height:150px;float:left;margin:0 10px 0 0;"
v-bind:src=
"vediosrc"
class=
"avatar video-avatar"
controls=
"controls"
>
您的浏览器不支持视频播放
</video>
<i
@
click=
"delvideo"
v-if=
"vediosrc"
class=
"el-icon-circle-close iconcur"
style=
"color:red;font-size: 18px;"
></i>
<el-upload
v-if=
"!vediosrc"
class=
"upload-img"
ref=
"videoref"
action=
"#"
:limit=
"1"
list-type=
"picture-card"
:before-upload=
"beforeUpGoodsvedio"
:http-request=
"uploadGoodsvedio"
:show-file-list=
"false"
:on-preview=
"handlePictureCardPreview"
:on-remove=
"handleRemove"
:on-error=
"vedioerror"
:file-list=
"goodsvedioFileList"
><i
class=
"el-icon-plus"
/>
<!-- v-if="videoform.showvideopath !='' && !videoflag" -->
</el-upload>
</el-form-item>
</el-form>
<!-- 修改 商品分类目录 -->
<!--
<el-cascader-panel
v-model=
"SSQList"
:props=
'props'
@
change=
"SSQChange"
ref=
"ssqCascader"
></el-cascader-panel>
-->
<el-dialog
v-loading=
"loadingSSQ"
class=
"add-workorder-dialog"
title=
"修改商品分类"
:visible
.
sync=
"editGoodsTypeDialog"
:before-close=
"cancelType"
destroy-on-close
width=
"60%"
center
>
<el-cascader-panel
v-show=
"editGoodsTypeDialog"
v-model
.
trim=
"SSQGoodsList"
:props=
'goodsprops'
:options=
"fuckoptions"
@
active-item-change=
"SSQGoodsChange"
ref=
"ssqGoodsCascader"
></el-cascader-panel>
<!--
<el-cascader-panel
v-model=
"SSQList"
:props=
'props'
@
change=
"SSQChange"
ref=
"ssqCascader"
></el-cascader-panel>
-->
<el-dialog
v-loading=
"loadingSSQ"
class=
"add-workorder-dialog opendow"
title=
"修改商品分类"
:visible
.
sync=
"editGoodsTypeDialog"
:close-on-click-modal=
"false"
:before-close=
"cancelType"
center
>
<el-cascader-panel
style=
"width:80%;"
v-show=
"editGoodsTypeDialog"
v-model
.
trim=
"SSQGoodsList"
:props=
'goodsprops'
:options=
"fuckoptions"
@
change=
"handGoodsChang"
@
active-item-change=
"SSQGoodsChange"
ref=
"ssqGoodsCascader"
></el-cascader-panel>
<span
slot=
"footer"
class=
"dialog-footer"
>
<el-button
@
click=
"cancelType"
size=
"mini"
>
取 消
</el-button>
<el-button
type=
"primary"
@
click=
"saveType"
size=
"mini"
>
确 定
</el-button>
...
...
@@ -157,7 +127,7 @@
</
template
>
<
script
>
import
{
NewGetCategory
,
GetFreight
,
UploadImg
,
getByCategoryData
,
uploadVideo
}
from
'@/api/module/goods'
import
{
NewGetCategory
,
NewGetCategoryData
,
GetFreight
,
UploadImg
,
getByCategoryData
,
uploadVideo
}
from
'@/api/module/goods'
import
{
getBrandsInf
}
from
'@/api/module/brand/brand'
import
{
getAreaList
}
from
'@/api/module/retreat/address'
import
draggable
from
'vuedraggable'
...
...
@@ -173,15 +143,16 @@
draggable
},
computed
:
{
//这一部分直接拿过来用的
dragOptions
()
{
return
{
animation
:
200
,
group
:
"description"
,
disabled
:
false
,
ghostClass
:
"ghost"
};
}
},
dragOptions
()
{
return
{
valdata
:[],
animation
:
200
,
group
:
"description"
,
disabled
:
false
,
ghostClass
:
"ghost"
};
}
},
data
()
{
let
categoryIdCheck
=
(
rule
,
value
,
callback
)
=>
{
if
(
this
.
goodsImgFileList
.
length
<
1
)
{
...
...
@@ -191,29 +162,29 @@
}
};
let
goodsDecCheck
=
(
rule
,
value
,
callback
)
=>
{
if
(
!
value
)
{
if
(
!
value
)
{
callback
(
new
Error
(
"商品关键词,不能为空"
));
}
else
{
if
(
value
.
indexOf
(
','
)
>
-
1
)
{
if
(
value
.
indexOf
(
','
)
>
-
1
)
{
callback
(
new
Error
(
"商品关键词,不能有中文状态下的逗号,请再次检查"
));
}
// 如果包含了,英文逗号,说明有多个,就校验个数
if
(
value
.
indexOf
(
','
)
>
-
1
)
{
if
(
value
.
indexOf
(
','
)
>
-
1
)
{
let
arrLength
=
value
.
split
(
','
).
length
;
console
.
log
(
value
.
split
(
','
));
if
(
arrLength
>
5
)
{
if
(
arrLength
>
5
)
{
callback
(
new
Error
(
"商品关键词,不能超过5个"
));
}
else
{
}
else
{
callback
();
}
}
else
{
}
else
{
callback
();
}
}
}
return
{
dialogVisible
:
false
,
dialogImageUrl
:
''
,
dialogVisible
:
false
,
dialogImageUrl
:
''
,
videoflag
:
false
,
//是否显示进度条
videouploadpercent
:
""
,
...
...
@@ -221,10 +192,10 @@
isshowuploadvideo
:
false
,
//显示上传按钮
videoform
:
{
showvideopath
:
''
showvideopath
:
''
},
goodsvedioFileList
:[],
vediosrc
:
''
,
goodsvedioFileList
:
[],
vediosrc
:
''
,
loadingapp
:
false
,
drag
:
false
,
currentDelBtn
:
-
1
,
...
...
@@ -245,20 +216,20 @@
web_url
:
''
,
// 外部链接
out_goods_id
:
''
,
// 商品编码
imgs
:
[],
// 商品图片
video
:
''
video
:
''
},
goodsInfoRules
:
{
categoryStr
:
[{
required
:
true
,
message
:
'商品分类不能为空'
,
trigger
:
'blur'
}],
categoryStr
:
[{
required
:
true
,
message
:
'商品分类不能为空'
,
trigger
:
'blur'
}],
goods_name
:
[
{
required
:
true
,
message
:
'请输入商品名称'
,
trigger
:
'blur'
},
{
min
:
3
,
max
:
50
,
message
:
'商品标题限制在3字符以上,50个字符以下'
,
trigger
:
'blur'
}
{
required
:
true
,
message
:
'请输入商品名称'
,
trigger
:
'blur'
},
{
min
:
3
,
max
:
50
,
message
:
'商品标题限制在3字符以上,50个字符以下'
,
trigger
:
'blur'
}
],
// goods_des: [{required: true, validator: goodsDecCheck, trigger: 'blur'}],
// producing_area:[{required: true, message: '请选择商品产地', trigger: 'change'}],
deliver_area
:
[{
required
:
true
,
message
:
'请选择商品发货地'
,
trigger
:
'change'
}],
unit
:
[{
required
:
true
,
message
:
'商品单位不能为空'
,
trigger
:
'blur'
}],
goods_brand
:
[{
required
:
true
,
message
:
'请选择商品品牌'
,
trigger
:
'change'
}],
imgs
:
[{
required
:
true
,
message
:
'请上传商品图片'
,
validator
:
categoryIdCheck
}]
deliver_area
:
[{
required
:
true
,
message
:
'请选择商品发货地'
,
trigger
:
'change'
}],
unit
:
[{
required
:
true
,
message
:
'商品单位不能为空'
,
trigger
:
'blur'
}],
goods_brand
:
[{
required
:
true
,
message
:
'请选择商品品牌'
,
trigger
:
'change'
}],
imgs
:
[{
required
:
true
,
message
:
'请上传商品图片'
,
validator
:
categoryIdCheck
}]
},
goodsImgFileList
:
[],
// 商品图片地址 集合list
goodsImgVisible
:
false
,
// 图片能否预览
...
...
@@ -272,7 +243,7 @@
// lazy: true,
// lazyLoad: this.lazyLoad,
value
:
"id"
,
label
:
'
label
'
,
label
:
'
title
'
,
// leaf: 'leaf',
children
:
'children'
,
// checkStrictly: true
...
...
@@ -293,45 +264,46 @@
// 获取 商品品牌
this
.
getBrands
();
// 获取类目
this
.
getSSQArea
();
//
this.getSSQArea();
},
mounted
()
{
if
(
this
.
goodsinfodata
.
goods_id
)
{
if
(
this
.
goodsinfodata
.
goods_id
)
{
this
.
goodsInfoForm
=
this
.
goodsinfodata
;
this
.
vediosrc
=
this
.
goodsinfodata
.
video
if
(
this
.
goodsInfoForm
.
imgs
.
length
>
0
)
{
this
.
goodsInfoForm
.
imgs
.
forEach
(
(
item
)
=>
{
if
(
this
.
goodsInfoForm
.
imgs
.
length
>
0
)
{
this
.
goodsInfoForm
.
imgs
.
forEach
(
(
item
)
=>
{
let
objImg
=
{
'url'
:
''
}
objImg
.
url
=
item
;
this
.
goodsImgFileList
.
push
(
objImg
);
})
}
}
else
{
}
else
{
this
.
goodsInfoForm
.
categoryStr
=
this
.
goodsinfodata
.
categoryStr
;
this
.
goodsInfoForm
.
categoryList
=
this
.
goodsinfodata
.
categoryList
;
}
// 初始化 服务费率
this
.
getByCategoryFee
(
this
.
goodsInfoForm
.
categoryList
)
this
.
SSQGoodsList
=
this
.
goodsInfoForm
.
categoryList
this
.
getalllist
(
this
.
SSQGoodsList
)
},
methods
:
{
handchange
(){
//图片拖动结束
handchange
()
{
//图片拖动结束
console
.
log
(
this
.
goodsImgFileList
)
this
.
goodsInfoForm
.
imgs
=
[]
this
.
goodsImgFileList
.
forEach
(
item
=>
{
this
.
goodsInfoForm
.
imgs
.
push
(
item
.
url
)
this
.
goodsImgFileList
.
forEach
(
item
=>
{
this
.
goodsInfoForm
.
imgs
.
push
(
item
.
url
)
})
},
delvideo
(){
delvideo
()
{
this
.
vediosrc
=
''
this
.
goodsvedioFileList
=
[]
},
// 上传 视频 之前
beforeUpGoodsvedio
(
file
)
{
debugger
let
isImgSize
=
(
file
.
size
/
1024
/
1024
)
>
10
;
//
debugger
let
isImgSize
=
(
file
.
size
/
1024
/
1024
)
>
10
;
if
(
file
.
type
!==
"video/mp4"
)
{
if
(
file
.
type
!==
"video/mp4"
)
{
this
.
$message
({
message
:
'上传视频格式只支持 mp4 格式'
,
type
:
"warning"
...
...
@@ -339,7 +311,7 @@
return
false
;
}
if
(
isImgSize
)
{
if
(
isImgSize
)
{
this
.
$message
({
message
:
'上传视频大小不能超过10MB'
,
type
:
"warning"
...
...
@@ -350,105 +322,190 @@
// 上传 商品视频
uploadGoodsvedio
(
param
)
{
const
formData
=
new
FormData
()
formData
.
append
(
'file'
,
param
.
file
)
uploadVideo
(
formData
).
then
(
res
=>
{
if
(
res
.
data
&&
res
.
code
==
1
)
{
let
urlObj
=
{
'url'
:
''
};
urlObj
.
url
=
res
.
data
.
url
;
this
.
goodsvedioFileList
.
push
(
urlObj
);
this
.
vediosrc
=
res
.
data
.
url
this
.
goodsInfoForm
.
video
=
res
.
data
.
url
this
.
$message
({
type
:
'success'
,
message
:
'视频上传成功'
});
}
else
{
this
.
goodsvedioFileList
=
[]
this
.
vediosrc
=
''
this
.
$notify
.
error
({
title
:
'错误'
,
message
:
res
.
message
});
}
}).
catch
((
err
)
=>
{
console
.
log
(
err
)
});
formData
.
append
(
'file'
,
param
.
file
)
uploadVideo
(
formData
).
then
(
res
=>
{
if
(
res
.
data
&&
res
.
code
==
1
)
{
let
urlObj
=
{
'url'
:
''
};
urlObj
.
url
=
res
.
data
.
url
;
this
.
goodsvedioFileList
.
push
(
urlObj
);
this
.
vediosrc
=
res
.
data
.
url
this
.
goodsInfoForm
.
video
=
res
.
data
.
url
this
.
$message
({
type
:
'success'
,
message
:
'视频上传成功'
});
}
else
{
this
.
goodsvedioFileList
=
[]
this
.
vediosrc
=
''
this
.
$notify
.
error
({
title
:
'错误'
,
message
:
res
.
message
});
}
}).
catch
((
err
)
=>
{
console
.
log
(
err
)
});
},
vedioerror
(
err
,
file
,
fileList
){
vedioerror
(
err
,
file
,
fileList
)
{
console
.
log
(
err
,
file
,
fileList
)
},
onEnd
(){
debugger
console
.
log
(
this
.
goodsImgFileList
)
onEnd
()
{
//
debugger
console
.
log
(
this
.
goodsImgFileList
)
this
.
drag
=
false
},
//显示删除图片的图标
showDelBtn
(
index
)
{
this
.
currentDelBtn
=
index
},
//隐藏删除图片的图标
hiddenDelBtn
()
{
this
.
currentDelBtn
=
-
1
},
// 删除图片
deleImg
(
data
,
index
)
{
this
.
goodsImgFileList
.
splice
(
index
,
1
)
this
.
goodsInfoForm
.
imgs
.
splice
(
index
,
1
);
},
lookimg
(
data
)
{
this
.
dialogVisible
=
true
this
.
dialogImageUrl
=
data
.
url
},
showDelBtn
(
index
)
{
this
.
currentDelBtn
=
index
},
//隐藏删除图片的图标
hiddenDelBtn
()
{
this
.
currentDelBtn
=
-
1
},
// 删除图片
deleImg
(
data
,
index
)
{
this
.
goodsImgFileList
.
splice
(
index
,
1
)
this
.
goodsInfoForm
.
imgs
.
splice
(
index
,
1
);
},
lookimg
(
data
)
{
this
.
dialogVisible
=
true
this
.
dialogImageUrl
=
data
.
url
},
// 数据初始化
initInfo
()
{
this
.
$refs
.
goodsInfoForm
.
resetFields
();
this
.
goodsImgFileList
=
[];
},
// 获取 商品品牌
getBrands
()
{
// 增加入参
let
data
=
{
status
:
1
}
getBrandsInf
(
data
).
then
(
res
=>
{
if
(
res
.
code
==
1
)
{
getBrandsInf
(
data
).
then
(
res
=>
{
if
(
res
.
code
==
1
)
{
this
.
brandOptions
=
res
.
data
.
data
?
res
.
data
.
data
:
[];
}
else
{
}
else
{
this
.
brandOptions
=
[];
}
});
},
/* 修改 商品分类 类目 */
editType
()
{
this
.
SSQGoodsList
=
[];
// this.SSQGoodsList = [];
this
.
fuckoptions
=
this
.
setTreeData
(
this
.
fuckoptions
)
this
.
editGoodsTypeDialog
=
true
;
this
.
SSQGoodsList
=
this
.
goodsInfoForm
.
categoryList
},
getSSQArea
(
node
,
resolve
)
{
let
limboNode
=
{
id
:
0
};
NewGetCategory
(
limboNode
).
then
(
res
=>
{
getalllist
(
itemarr
){
// debugger
let
limboNode
itemarr
.
forEach
((
item
,
index
)
=>
{
if
(
index
==
0
){
limboNode
=
{
parent_id
:
0
}
}
if
(
index
>
0
){
limboNode
=
{
parent_id
:
itemarr
[
index
-
1
]
}
}
NewGetCategoryData
(
limboNode
).
then
(
res
=>
{
let
date
=
res
.
data
.
forEach
(
item
=>
{
if
(
item
.
level
!==
2
){
item
[
'children'
]
=
[]
}
})
this
.
fuckoptions
.
push
.
apply
(
this
.
fuckoptions
,
res
.
data
)
});
})
},
getSSQArea
()
{
let
limboNode
=
{
id
:
0
};
NewGetCategoryData
(
limboNode
).
then
(
res
=>
{
this
.
fuckoptions
=
res
.
data
;
});
},
setTreeData
(
arr
)
{
// 删除所有 children,以防止多次调用
arr
.
forEach
(
function
(
item
)
{
// delete item.children;
});
let
map
=
{};
// 构建map
arr
.
forEach
(
i
=>
{
map
[
i
.
id
]
=
i
;
// 构建以third_id为键 当前数据为值
});
let
treeData
=
[];
arr
.
forEach
(
child
=>
{
const
mapItem
=
map
[
child
.
parent_id
];
// 判断当前数据的parent_id是否存在map中
if
(
mapItem
)
{
// 存在则表示当前数据不是最顶层数据
// 注意: 这里的map中的数据是引用了arr的它的指向还是arr,当mapItem改变时arr也会改变,踩坑点
(
mapItem
.
children
||
(
mapItem
.
children
=
[])).
push
(
child
);
// 这里判断mapItem中是否存在children, 存在则插入当前数据, 不存在则赋值children为[]然后再插入当前数据
}
else
{
// 不存在则是组顶层数据
treeData
.
push
(
child
);
}
});
return
treeData
;
},
// 类目修改
handGoodsChang
(
val
){
console
.
log
(
val
,
'newval'
)
this
.
SSQGoodsList
=
val
},
SSQGoodsChange
(
value
)
{
this
.
SSQGoodsList
=
value
;
this
.
valdata
=
[]
console
.
log
(
value
,
'ccc'
)
let
limboNode
=
{
parent_id
:
value
[
value
.
length
-
1
]
}
NewGetCategoryData
(
limboNode
).
then
(
res
=>
{
// debugger
res
.
data
.
forEach
(
val
=>
{
if
(
val
.
level
!==
2
){
val
[
'children'
]
=
[]
}
this
.
valdata
.
push
(
val
)
})
console
.
log
(
this
.
valdata
)
if
(
value
.
length
==
1
){
this
.
fuckoptions
.
forEach
((
item
,
index
)
=>
{
if
(
item
.
id
==
value
[
value
.
length
-
1
]){
// debugger
this
.
fuckoptions
[
index
].
children
=
this
.
valdata
// debugger
}
})
}
if
(
value
.
length
==
2
){
this
.
fuckoptions
.
forEach
((
item
,
index
)
=>
{
if
(
item
.
id
==
value
[
0
]){
this
.
fuckoptions
[
index
].
children
.
forEach
((
iten
,
indexs
)
=>
{
if
(
iten
.
id
===
value
[
1
]){
this
.
fuckoptions
[
index
].
children
[
indexs
].
children
=
this
.
valdata
}
})
}
})
}
});
console
.
log
(
this
.
SSQGoodsList
,
'aaaaa'
)
},
// 确认 修改 商品分类
saveType
()
{
if
(
this
.
SSQGoodsList
&&
this
.
SSQGoodsList
.
length
===
3
)
{
if
(
this
.
SSQGoodsList
&&
this
.
SSQGoodsList
.
length
===
3
)
{
let
ssqLabelList
=
this
.
$refs
[
'ssqGoodsCascader'
].
getCheckedNodes
()[
0
].
pathLabels
;
this
.
goodsInfoForm
.
categoryList
=
this
.
SSQGoodsList
;
this
.
goodsInfoForm
.
categoryStr
=
ssqLabelList
[
0
]
+
'/'
+
ssqLabelList
[
1
]
+
'/'
+
ssqLabelList
[
2
];
this
.
editGoodsTypeDialog
=
false
;
this
.
$message
({
type
:
'success'
,
message
:
'修改成功'
});
this
.
$message
({
type
:
'success'
,
message
:
'修改成功'
});
// 修改类目后更新 服务费率
this
.
getByCategoryFee
(
this
.
goodsInfoForm
.
categoryList
)
}
else
{
this
.
$message
({
type
:
'warning'
,
message
:
'请选择完整三级类目'
});
}
else
{
this
.
$message
({
type
:
'warning'
,
message
:
'请选择完整三级类目'
});
}
},
// 取消 修改 商品分类
...
...
@@ -463,10 +520,10 @@ showDelBtn(index) {
this
.
$message
({
message
:
'最多上传7张图片'
,
type
:
'warning'
})
},
// 上传 商品图片 之前
beforeUpGoodsImg
(
file
)
{
let
isImgSize
=
(
file
.
size
/
1024
/
1024
)
>
2
;
beforeUpGoodsImg
(
file
)
{
let
isImgSize
=
(
file
.
size
/
1024
/
1024
)
>
2
;
if
(
file
.
type
!==
"image/png"
&&
file
.
type
!==
"image/jpg"
&&
file
.
type
!=
"image/jpeg"
)
{
if
(
file
.
type
!==
"image/png"
&&
file
.
type
!==
"image/jpg"
&&
file
.
type
!=
"image/jpeg"
)
{
this
.
$message
({
message
:
'上传图片格式只支持 jpg / png 格式'
,
type
:
"warning"
...
...
@@ -474,7 +531,7 @@ showDelBtn(index) {
return
false
;
}
if
(
isImgSize
)
{
if
(
isImgSize
)
{
this
.
$message
({
message
:
'上传图片大小不能超过2MB'
,
type
:
"warning"
...
...
@@ -483,10 +540,10 @@ showDelBtn(index) {
}
// // 图片宽高尺寸限制 800*800
return
new
Promise
(
function
(
resolve
,
reject
)
{
return
new
Promise
(
function
(
resolve
,
reject
)
{
let
_URL
=
window
.
URL
||
window
.
webkitURL
;
let
img
=
new
Image
();
img
.
onload
=
function
()
{
img
.
onload
=
function
()
{
// 图片是否是正方形 宽高比为 1
file
.
width
=
img
.
width
;
file
.
height
=
img
.
height
;
...
...
@@ -494,11 +551,11 @@ showDelBtn(index) {
valid
?
resolve
()
:
reject
();
}
img
.
src
=
_URL
.
createObjectURL
(
file
);
}).
then
(()
=>
{
}).
then
(()
=>
{
return
file
;
},
()
=>
{
},
()
=>
{
this
.
$message
({
message
:
'商品图片尺寸必须为800 * 800像素,请重新选择!'
,
message
:
'商品图片尺寸必须为800 * 800像素,请重新选择!'
,
type
:
'warning'
});
return
Promise
.
reject
();
...
...
@@ -508,22 +565,22 @@ showDelBtn(index) {
// 上传 商品图片
uploadGoodsImg
(
param
)
{
//console.log(327,param);
this
.
getBase64
(
param
.
file
).
then
(
res
=>
{
this
.
getBase64
(
param
.
file
).
then
(
res
=>
{
let
result
=
res
.
split
(
","
);
this
.
Base64img
=
result
[
1
];
let
data
=
{
"img_data"
:
this
.
Base64img
};
UploadImg
(
data
).
then
(
res
=>
{
let
urlObj
=
{
'url'
:
''
};
if
(
res
.
data
)
{
let
data
=
{
"img_data"
:
this
.
Base64img
};
UploadImg
(
data
).
then
(
res
=>
{
let
urlObj
=
{
'url'
:
''
};
if
(
res
.
data
)
{
urlObj
.
url
=
res
.
data
.
image_url
;
this
.
goodsImgFileList
.
push
(
urlObj
);
this
.
goodsInfoForm
.
imgs
=
[];
// 1009 hxz 初始化img
this
.
goodsImgFileList
.
forEach
(
item
=>
{
this
.
goodsImgFileList
.
forEach
(
item
=>
{
this
.
goodsInfoForm
.
imgs
.
push
(
item
.
url
)
})
this
.
$message
({
type
:
'success'
,
message
:
'图片上传成功'
});
this
.
$message
({
type
:
'success'
,
message
:
'图片上传成功'
});
// 只清除一次,不浪费哦
if
(
this
.
goodsImgFileList
.
length
===
1
)
{
if
(
this
.
goodsImgFileList
.
length
===
1
)
{
this
.
$refs
.
goodsInfoForm
.
clearValidate
(
'imgs'
);
}
}
...
...
@@ -531,7 +588,7 @@ showDelBtn(index) {
});
},
// 商品信息 子组件 form表单校验, 在父组件中被调用
validateGoodsInfoForm
()
{
validateGoodsInfoForm
()
{
let
flag
=
null
this
.
$refs
[
'goodsInfoForm'
].
validate
(
valid
=>
{
if
(
valid
)
{
...
...
@@ -555,16 +612,16 @@ showDelBtn(index) {
this
.
goodsInfoForm
.
imgs
.
splice
(
i
,
1
);
}
}
if
(
this
.
goodsImgFileList
.
length
===
0
)
{
if
(
this
.
goodsImgFileList
.
length
===
0
)
{
this
.
$refs
.
goodsInfoForm
.
validateField
(
'imgs'
)
}
else
{
}
else
{
this
.
$refs
.
goodsInfoForm
.
clearValidate
(
'imgs'
);
}
},
// 维护品牌
toBrand
()
{
this
.
$router
.
push
({
path
:
'/system/shop/brand'
});
this
.
$router
.
push
({
path
:
'/system/shop/brand'
});
},
/** 根据类目 获取服务费率
...
...
@@ -580,10 +637,10 @@ showDelBtn(index) {
data
.
category_id
=
cateList
[
0
];
}
// console.log(8888,data);
getByCategoryData
(
data
).
then
(
res
=>
{
if
(
res
.
code
==
1
)
{
this
.
cateFee
=
res
.
data
.
service_fee_ratio
?
res
.
data
.
service_fee_ratio
:
''
this
.
$store
.
commit
(
'SET_CATEFEE'
,
this
.
cateFee
);
getByCategoryData
(
data
).
then
(
res
=>
{
if
(
res
.
code
==
1
)
{
this
.
cateFee
=
res
.
data
.
service_fee_ratio
?
res
.
data
.
service_fee_ratio
:
''
this
.
$store
.
commit
(
'SET_CATEFEE'
,
this
.
cateFee
);
}
});
},
...
...
@@ -612,38 +669,61 @@ showDelBtn(index) {
ul
{
padding
:
0
;
}
.goods-info
{
padding
:
20px
;
/*margin-top: 18px;*/
}
.type-text-span
{
display
:
inline-block
;
width
:
420px
;
/*margin: 0 20px 0;*/
}
.edit-type-span
{
display
:
inline-block
;
cursor
:
pointer
;
margin
:
0
20px
;
}
/* 一般提示性文字 */
.tip-span
{
color
:
#909399
;
font-size
:
12px
;
}
.edit-type-span
{
display
:
inline-block
;
cursor
:
pointer
;
margin
:
0
20px
;
}
/* 一般提示性文字 */
.tip-span
{
color
:
#909399
;
font-size
:
12px
;
}
/
deep
/
.el-form-item
{
margin-bottom
:
20px
;
}
.list-complete-item
{
display
:
inline-block
;
}
.imgSty
{
margin
:
0
10px
;
}
.iconcur
{
cursor
:
pointer
;
}
.list-complete-item
{
display
:
inline-block
;
}
.imgSty
{
margin
:
0
10px
;
}
.iconcur
{
cursor
:
pointer
;
}
/*/deep/.el-cascader-menu {*/
/* height:600px;*/
/*}*/
</
style
>
/
deep
/
.el-cascader-menu
{
max-width
:
250px
!important
;
min-width
:
250px
!important
;
}
/
deep
/
.el-cascader-menu__wrap
{
width
:
auto
!important
;
max-width
:
250px
!important
;
min-width
:
250px
!important
;
}
.opendow
/
deep
/
.el-dialog
{
width
:
800px
;
}
</
style
>
\ No newline at end of file
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论