Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
apaas-ui
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gzga-jzapi
apaas-ui
Commits
c20f9be2
Commit
c20f9be2
authored
Sep 16, 2020
by
刘殿昕
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修复裁剪二次调用图片及图片定位异常问题
parent
c9d529bd
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
16 deletions
+28
-16
src/components/general/cropper.vue
src/components/general/cropper.vue
+28
-16
No files found.
src/components/general/cropper.vue
View file @
c20f9be2
...
@@ -5,6 +5,7 @@
...
@@ -5,6 +5,7 @@
<i
class=
"el-icon-refresh-right img_replace"
></i>
<i
class=
"el-icon-refresh-right img_replace"
></i>
<input
<input
type=
"file"
type=
"file"
id=
"upItem1"
class=
"up_input"
class=
"up_input"
accept=
"image/png, image/jpeg, image/gif, image/jpg"
accept=
"image/png, image/jpeg, image/gif, image/jpg"
@
change=
"uploadImg($event,1)"
@
change=
"uploadImg($event,1)"
...
@@ -21,6 +22,7 @@
...
@@ -21,6 +22,7 @@
<i
class=
"el-icon-plus add_icon"
></i>
<i
class=
"el-icon-plus add_icon"
></i>
<input
<input
type=
"file"
type=
"file"
id=
"upItem2"
class=
"up_input"
class=
"up_input"
accept=
"image/png, image/jpeg, image/gif, image/jpg"
accept=
"image/png, image/jpeg, image/gif, image/jpg"
@
change=
"uploadImg($event,1)"
@
change=
"uploadImg($event,1)"
...
@@ -49,6 +51,7 @@
...
@@ -49,6 +51,7 @@
:autoCropWidth=
"options.autoCropWidth"
:autoCropWidth=
"options.autoCropWidth"
:autoCropHeight=
"options.autoCropHeight"
:autoCropHeight=
"options.autoCropHeight"
:centerBox=
"options.centerBox"
:centerBox=
"options.centerBox"
:mode=
"options.mode"
@
realTime=
"realTime"
@
realTime=
"realTime"
></vueCropper>
></vueCropper>
</div>
</div>
...
@@ -70,30 +73,30 @@
...
@@ -70,30 +73,30 @@
import
{
VueCropper
}
from
"
vue-cropper
"
;
import
{
VueCropper
}
from
"
vue-cropper
"
;
export
default
{
export
default
{
components
:
{
components
:
{
VueCropper
VueCropper
,
},
},
props
:
{
props
:
{
fileArray
:
{
fileArray
:
{
type
:
Array
,
type
:
Array
,
default
:
()
=>
{
default
:
()
=>
{
[];
[];
}
}
,
},
},
fit
:
{
fit
:
{
type
:
String
,
type
:
String
,
default
:
""
default
:
""
,
},
},
max
:
{
max
:
{
type
:
Number
,
type
:
Number
,
default
:
1
default
:
1
,
}
}
,
},
},
watch
:
{
watch
:
{
fileArray
:
{
fileArray
:
{
handler
(
val
)
{
handler
(
val
)
{
this
.
fileArr
=
val
;
this
.
fileArr
=
val
;
}
}
,
}
}
,
},
},
data
()
{
data
()
{
return
{
return
{
...
@@ -104,7 +107,8 @@ export default {
...
@@ -104,7 +107,8 @@ export default {
canMoveBox
:
true
,
//截图框不能拖动
canMoveBox
:
true
,
//截图框不能拖动
autoCropWidth
:
200
,
//截图框宽度
autoCropWidth
:
200
,
//截图框宽度
autoCropHeight
:
200
,
//截图框高度
autoCropHeight
:
200
,
//截图框高度
centerBox
:
false
//截图框被限制在图片里面
centerBox
:
true
,
//截图框被限制在图片里面
mode
:
"
cover
"
,
},
},
previews
:
{},
//实时预览图数据
previews
:
{},
//实时预览图数据
attach
:
{
attach
:
{
...
@@ -112,16 +116,24 @@ export default {
...
@@ -112,16 +116,24 @@ export default {
userId
:
""
,
userId
:
""
,
customaryUrl
:
""
,
//原图片路径
customaryUrl
:
""
,
//原图片路径
laterUrl
:
""
,
//裁剪后图片路径
laterUrl
:
""
,
//裁剪后图片路径
attachType
:
"
photo
"
//附件类型
attachType
:
"
photo
"
,
//附件类型
},
},
fileName
:
""
,
//本机文件地址
fileName
:
""
,
//本机文件地址
uploadImgRelaPath
:
""
,
//上传后图片地址
uploadImgRelaPath
:
""
,
//上传后图片地址
fileArr
:
[]
fileArr
:
[]
,
};
};
},
},
methods
:
{
methods
:
{
//控制弹出层关闭
//控制弹出层关闭
handleClose
()
{
handleClose
()
{
let
abc1
=
document
.
getElementById
(
"
upItem1
"
);
let
abc2
=
document
.
getElementById
(
"
upItem2
"
);
if
(
abc1
)
{
abc1
.
value
=
""
;
}
if
(
abc2
)
{
abc2
.
value
=
""
;
}
this
.
dialogVisible
=
false
;
this
.
dialogVisible
=
false
;
},
},
//实时预览
//实时预览
...
@@ -143,7 +155,7 @@ export default {
...
@@ -143,7 +155,7 @@ export default {
//fileReader 接口,用于异步读取文件数据
//fileReader 接口,用于异步读取文件数据
var
reader
=
new
FileReader
();
var
reader
=
new
FileReader
();
reader
.
readAsDataURL
(
file
);
//重要 以dataURL形式读取文件
reader
.
readAsDataURL
(
file
);
//重要 以dataURL形式读取文件
reader
.
onload
=
e
=>
{
reader
.
onload
=
(
e
)
=>
{
// data = window.URL.createObjectURL(new Blob([e.target.result])) 转化为blob格式
// data = window.URL.createObjectURL(new Blob([e.target.result])) 转化为blob格式
let
data
=
e
.
target
.
result
;
let
data
=
e
.
target
.
result
;
...
@@ -158,24 +170,24 @@ export default {
...
@@ -158,24 +170,24 @@ export default {
//确认截图,上传
//确认截图,上传
cut
(
type
)
{
cut
(
type
)
{
var
formData
=
new
FormData
();
var
formData
=
new
FormData
();
this
.
$refs
.
cropper
.
getCropBlob
(
res
=>
{
this
.
$refs
.
cropper
.
getCropBlob
(
(
res
)
=>
{
//res是裁剪后图片的bolb对象
//res是裁剪后图片的bolb对象
formData
.
append
(
"
file
"
,
res
,
this
.
userId
);
formData
.
append
(
"
file
"
,
res
,
this
.
userId
);
formData
.
append
(
"
directory
"
,
"
image
"
);
formData
.
append
(
"
directory
"
,
"
image
"
);
let
url
=
"
/apaas/static/image/upload
"
;
let
url
=
"
/apaas/static/image/upload
"
;
this
.
$http
this
.
$http
.
post
(
url
,
formData
,
{
.
post
(
url
,
formData
,
{
headers
:
{
"
Content-Type
"
:
"
multipart/form-data
"
}
headers
:
{
"
Content-Type
"
:
"
multipart/form-data
"
}
,
})
})
.
then
(
res
=>
{
.
then
(
(
res
)
=>
{
this
.
fileArr
=
[{
name
:
res
.
data
.
data
,
url
:
res
.
data
.
data
}];
this
.
fileArr
=
[{
name
:
res
.
data
.
data
,
url
:
res
.
data
.
data
}];
// 上传图片后服务器返回访问路径
// 上传图片后服务器返回访问路径
this
.
$emit
(
"
getNewUrl
"
,
res
.
data
.
data
);
this
.
$emit
(
"
getNewUrl
"
,
res
.
data
.
data
);
this
.
handleClose
();
this
.
handleClose
();
});
});
});
});
}
}
,
}
}
,
};
};
</
script
>
</
script
>
...
...
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