pengjun 1 year ago
parent
commit
d5ed1acba0
  1. 4
      src/components/doctorCheck/CheckPicture.vue
  2. 98
      src/components/doctorCheck/PacsCutPic.vue

4
src/components/doctorCheck/CheckPicture.vue

@ -498,7 +498,7 @@ export default {
},
// //
btnCutPicBak() {
btnCutPic() {
this.dialogWinCutPic = true
@ -509,7 +509,7 @@ export default {
},
btnCutPic() {
btnCutPicBak() {
if (this.checkPictures.length == 0) {
this.$message.warning({ showClose: true, message: "暂无可裁图片!" });
return;

98
src/components/doctorCheck/PacsCutPic.vue

@ -44,7 +44,7 @@
<div class="col-md-3">
<div class="imgCutDownBox" :style="'height:458px;'">
<div class="imgCutDownBoxContainer" style="z-index: 2;">
<img :src="imgSrc" v-if="!!imgSrc" alt="" style="z-index: 3000;"/>
<img :src="imgSrc" v-if="!!imgSrc" alt="" style="z-index: 3000;" />
<span v-else class="imgCutDownTips">{{ 'block3.title8' }}</span>
</div>
@ -93,6 +93,7 @@
</div>
</div>
</div>
<canvas id="myCanvas"></canvas>
</div>
</template>
@ -153,6 +154,27 @@ export default {
};
},
created() {
// canvas
// this.$nextTick(() => {
// let canvas = document.getElementById('myCanvas');
// let ctx = canvas.getContext('2d');
// //
// let img = new Image();
// //
// img.src = this.cutImgSrc
// //
// img.onload = function () {
// canvas.width = img.width;
// canvas.height = img.height;
// //
// console.log('img.width,img.height', img.width, img.height)
// ctx.drawImage(img, 0, 0); // xy
// };
// })
},
mounted() {
@ -181,7 +203,7 @@ export default {
});
})
.catch(err => {
this.$message.error({showClose:true,message:err})
this.$message.error({ showClose: true, message: err })
})
},
@ -196,7 +218,7 @@ export default {
//
// this.loadImg = false;
// this.imgSrc = '';
console.log('this.imgSrc',this.imgSrc)
console.log('this.imgSrc', this.imgSrc)
},
onPrintImg: function (res) {
@ -312,6 +334,73 @@ export default {
},
convertImageToBase64: function (url) {
return new Promise((resolve, reject) => {
fetch(url, {
method: 'GET',
// mode: 'no-cors',
// headers: {
// 'Content-Type': 'application/json', //
// 'Authorization': 'Bearer ' + token,
// 'Access-Control-Allow-Origin': '*'
// }
})
.then(response => {
if (!response.ok) {
console.log('response',response)
throw new Error('Network response was not ok ' + response.statusText);
}
return response.blob()
})
.then(blob => createImageBitmap(blob))
.then(imageBitmap => {
const canvas = document.createElement('canvas');
const ctx = canvas.getContext('2d');
canvas.width = imageBitmap.width;
canvas.height = imageBitmap.height;
ctx.drawImage(imageBitmap, 0, 0);
const dataUrl = canvas.toDataURL('image/png');
console.log('dataUrl', dataUrl)
resolve(dataUrl)
})
.catch(err => {
reject(err)
})
})
},
convertImageToBase641: function (url) {
this.$nextTick(() => {
return new Promise((resolve, reject) => {
let canvas = document.getElementById('myCanvas');
let ctx = canvas.getContext('2d');
//
let img = new Image();
// 访
// img.crossOrigin = 'Anonymous';
//
img.src = url
//
img.onload = function () {
canvas.width = img.width;
canvas.height = img.height;
//
console.log('img.width,img.height', img.width, img.height)
ctx.drawImage(img, 0, 0); // xy
let dataURL = canvas.toDataURL('image/png');
console.log('dataURL', dataURL)
resolve(dataURL);
};
})
})
},
convertImageToBase642: function (url) {
return new Promise((resolve, reject) => {
// Image
const img = new Image();
@ -320,7 +409,8 @@ export default {
//
img.onload = () => {
// canvas
const canvas = document.createElement('canvas');
// const canvas = document.createElement('canvas');
const canvas = document.getElementById('myCanvas')
const ctx = canvas.getContext('2d');
// canvas
canvas.width = img.width;

Loading…
Cancel
Save