|
@@ -56,47 +56,6 @@ export default {
|
|
|
const file = new File([blob], fileName, { type: blob.type })
|
|
const file = new File([blob], fileName, { type: blob.type })
|
|
|
return file
|
|
return file
|
|
|
},
|
|
},
|
|
|
- copyPDFURL(url) {
|
|
|
|
|
- // 数字没有 .length 不能执行selectText 需要转化成字符串
|
|
|
|
|
- const textString = url.toString();
|
|
|
|
|
- const input = document.createElement('input');
|
|
|
|
|
- input.id = 'copy-input';
|
|
|
|
|
- input.readOnly = true; // 防止ios聚焦触发键盘事件
|
|
|
|
|
- input.style.position = 'absolute';
|
|
|
|
|
- input.style.left = '-1000px';
|
|
|
|
|
- input.style.zIndex = '-1000';
|
|
|
|
|
- document.body.appendChild(input);
|
|
|
|
|
- input.value = textString;
|
|
|
|
|
-
|
|
|
|
|
- // ios必须先选中文字且不支持 input.select();
|
|
|
|
|
- selectText(input, 0, textString.length);
|
|
|
|
|
-
|
|
|
|
|
- input.blur();
|
|
|
|
|
- document.body.removeChild(input); // 使用完成后,移除 input 元素,避免占用页面高度
|
|
|
|
|
-
|
|
|
|
|
- // input自带的select()方法在苹果端无法进行选择,所以需要自己去写一个类似的方法
|
|
|
|
|
- // 选择文本。createTextRange(setSelectionRange)是input方法
|
|
|
|
|
- function selectText(textBox, startIndex, stopIndex) {
|
|
|
|
|
- if (textBox.createTextRange) {
|
|
|
|
|
- //ie
|
|
|
|
|
- const range = textBox.createTextRange();
|
|
|
|
|
- range.collapse(true);
|
|
|
|
|
- range.moveStart('character', startIndex); //起始光标
|
|
|
|
|
- range.moveEnd('character', stopIndex - startIndex); //结束光标
|
|
|
|
|
- range.select(); //不兼容苹果
|
|
|
|
|
- } else {
|
|
|
|
|
- //firefox/chrome
|
|
|
|
|
- textBox.setSelectionRange(startIndex, stopIndex);
|
|
|
|
|
- textBox.focus();
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- console.log(document.execCommand('copy'), 'execCommand');
|
|
|
|
|
- if (document.execCommand('copy')) {
|
|
|
|
|
- document.execCommand('copy');
|
|
|
|
|
-
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
},
|
|
},
|
|
|
created() {
|
|
created() {
|
|
|
},
|
|
},
|
|
@@ -191,9 +150,16 @@ export default {
|
|
|
title: '打印票据遇到问题?',
|
|
title: '打印票据遇到问题?',
|
|
|
content: '<p>系统检测到您未成功打印票据,是否尝试手动复制链接到剪贴板下载?</p>',
|
|
content: '<p>系统检测到您未成功打印票据,是否尝试手动复制链接到剪贴板下载?</p>',
|
|
|
onOk: () => {
|
|
onOk: () => {
|
|
|
- this.copyPDFURL('/wx-print?svc_code=' +this.$route.query.svc_code + '&is_download=true'
|
|
|
|
|
|
|
+
|
|
|
|
|
+ let url='/wx-print?svc_code=' +this.$route.query.svc_code + '&is_download=true'
|
|
|
+ '&cp_id=' + this.$route.query.cp_id + '&doc=' + this.$route.query.doc + '&layout_id='
|
|
+ '&cp_id=' + this.$route.query.cp_id + '&doc=' + this.$route.query.doc + '&layout_id='
|
|
|
- + this.$route.query.layout_id + '&data_id=' + this.$route.query.data_id)
|
|
|
|
|
|
|
+ + this.$route.query.layout_id + '&data_id=' + this.$route.query.data_id
|
|
|
|
|
+
|
|
|
|
|
+ this.$copyText(url).then(function (e) {
|
|
|
|
|
+ console.log('复制成功',e);
|
|
|
|
|
+ }, function (e) {
|
|
|
|
|
+ console.log('复制失败',e);
|
|
|
|
|
+ })
|
|
|
},
|
|
},
|
|
|
onCancel: () => {
|
|
onCancel: () => {
|
|
|
console.log(0)
|
|
console.log(0)
|