123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148 |
- <template>
- <div class="image-cut">
- <ImgCutter @cutDown="handleCutDown" ref="imageCut" :crossOrigin="true" :originalGraph="false" :cutWidth="400" :cutHeight="260" v-show="cutImageShow" @on-clear-all="handleCutClearAll" :showChooseBtn="false" :lockScroll="false" :box-width="boxWidth" :box-height="boxHeight" :tool="true" @error="handleCutError">
- <span slot="open"></span>
- </ImgCutter>
- </div>
- </template>
- <script>
- import service from '@/service';
- import ImgCutter from 'vue-img-cutter';
- export default {
- name: 'image-cut',
- components: {ImgCutter},
- props:{
- /**
- * [boxWidth 弹出层宽度]
- * @type {Object}
- */
- boxWidth:{
- type:Number,
- default:service.dialogMax(0.9,0.7).width
- },
- /**
- * [boxHeight 弹出层高度]
- * @type {Object}
- */
- boxHeight:{
- type:Number,
- default:service.dialogMax(0.7,0.7).height
- },
- },
- data() {
- return {
- /**
- * [cutImageShow 是否显示图片裁剪功能]
- * @type {Boolean}
- */
- cutImageShow:false,
- /**
- * [openParams 设置参数]
- * @type {Object}
- */
- openParams:{}
- };
- },
- methods:{
- /**
- * [initialize 初始化]
- * @author szjcomo
- * @date 2021-02-22
- * @return {[type]} [description]
- */
- initialize:function() {
- let that = this;
- },
- /**
- * [cutOpen 开始图片裁剪]
- * @author szjcomo
- * @date 2021-02-22
- * @param {Object} data [description]
- * @return {[type]} [description]
- */
- cutOpen:function(data = {},params = {}) {
- let that = this;
- that.cutImageShow = true;
- that.openParams = params;
- that.$refs.imageCut.handleOpen(data);
- },
- /**
- * [handleCutDown 图片裁剪完成后回调函数]
- * @author szjcomo
- * @date 2021-02-22
- * @param {[type]} data [description]
- * @return {[type]} [description]
- */
- handleCutDown:function(data) {
- let that = this;
- that.cutImageShow = false;
- that.$emit('success',data,that.openParams);
- },
- /**
- * [handleCutClearAll 清空画布回调函数]
- * @author szjcomo
- * @date 2021-02-22
- * @return {[type]} [description]
- */
- handleCutClearAll:function() {
- let that = this;
- that.cutImageShow = false;
- },
- /**
- * [handleCutError 图片裁剪错误信息]
- * @author szjcomo
- * @date 2021-02-22
- * @param {[type]} err [description]
- * @return {[type]} [description]
- */
- handleCutError:function(err) {
- let that = this;
- that.$emit('error',err);
- }
- },
- //计算属性
- computed:{
- },
- //侦听属性
- watch:{
- },
- //实例刚在内存中被创建出来,此时,还没有初始化好 data 和 methods 属性
- beforeCreate:function(){
- },
- //实例已经在内存中创建OK,此时 data 和 methods 已经创建OK,此时还没有开始 编译模板
- created:function(){
- },
- //此时已经完成了模板的编译,但是还没有挂载到页面中
- beforeMount:function(){
- },
- //此时,已经将编译好的模板,挂载到了页面指定的容器中显示
- mounted:function(){
- let that = this;
- that.initialize();
- },
- //状态更新之前执行此函数, 此时 data 中的状态值是最新的,但是界面上显示的 数据还是旧的,因为此时还没有开始重新渲染DOM节点
- beforeUpdate:function(){
- },
- //实例更新完毕之后调用此函数,此时 data 中的状态值 和 界面上显示的数据,都已经完成了更新,界面已经被重新渲染好了!
- updated:function(){
- },
- //实例销毁之前调用。在这一步,实例仍然完全可用。
- beforeDestroy:function(){
- },
- //Vue 实例销毁后调用。调用后,Vue 实例指示的所有东西都会解绑定,所有的事件监听器会被移除,所有的子实例也会被销毁。
- destroyed:function(){
- }
- }
- </script>
- <style>
- .image-cut .mask{z-index: 9999;}
- </style>
|