|  | @@ -444,7 +444,28 @@ |  | @@ -444,7 +444,28 @@ | 
| 444 | <video width="100%" height="200" autoplay loop controls id="videos"> | 444 | <video width="100%" height="200" autoplay loop controls id="videos"> | 
| 445 | <source src="/static/login/New-jumbo.mp4" type="video/mp4"> | 445 | <source src="/static/login/New-jumbo.mp4" type="video/mp4"> | 
| 446 | </video> | 446 | </video> | 
| 447 | -            <el-button class="btns" @click="screenshot">一键截屏</el-button> | 447 | +            <el-row> | 
|  |  | 448 | +                <el-image | 
|  |  | 449 | +                        :src="imgBase64" width="200" height="200" | 
|  |  | 450 | +                        fit="fill"></el-image> | 
|  |  | 451 | +            </el-row> | 
|  |  | 452 | +            <el-button type="success" class="btns" @click="screenshot">一键截屏上传</el-button> | 
|  |  | 453 | +<!--            <el-upload--> | 
|  |  | 454 | +<!--                    class="upload-demo"--> | 
|  |  | 455 | +<!--                    drag--> | 
|  |  | 456 | +<!--                    action=""--> | 
|  |  | 457 | +<!--                    :headers="uploadHeaderObj"--> | 
|  |  | 458 | +<!--                    :on-success="handleUploadSuccess"--> | 
|  |  | 459 | +<!--                    :auto-upload="false"--> | 
|  |  | 460 | +<!--                    :on-change="submitUpload"--> | 
|  |  | 461 | +<!--                    ref="upload"--> | 
|  |  | 462 | +<!--            >--> | 
|  |  | 463 | +<!--                <i class="el-icon-upload avatar-uploader-icon"></i>--> | 
|  |  | 464 | +<!--                <div class="el-upload__text">将文件拖到此处,或<em>点击上传文件</em></div>--> | 
|  |  | 465 | +<!--                <div class="el-upload__tip" slot="tip">只能上传xml文件,且不超过2MB</div>--> | 
|  |  | 466 | +<!--            </el-upload>--> | 
|  |  | 467 | +<!--            <el-button style="margin-left: 10px;" size="small" type="success" @click="submitUpload">上传到服务器</el-button>--> | 
|  |  | 468 | + | 
| 448 | </el-drawer> | 469 | </el-drawer> | 
| 449 | </el-row> | 470 | </el-row> | 
| 450 | </template> | 471 | </template> | 
|  | @@ -461,6 +482,8 @@ |  | @@ -461,6 +482,8 @@ | 
| 461 | import jsutil from "@/common/js/util"; | 482 | import jsutil from "@/common/js/util"; | 
| 462 | import { getList as getCRMList } from '@/api/crm_api'; | 483 | import { getList as getCRMList } from '@/api/crm_api'; | 
| 463 | import { loginedUserInfo } from '@/api/user'; | 484 | import { loginedUserInfo } from '@/api/user'; | 
|  |  | 485 | +    import html2canvas from 'html2canvas' | 
|  |  | 486 | +    import {uploadPath,upfileWithPost} from "../../api/technological"; | 
| 464 |  | 487 |  | 
| 465 |  | 488 |  | 
| 466 | export default { | 489 | export default { | 
|  | @@ -480,6 +503,12 @@ |  | @@ -480,6 +503,12 @@ | 
| 480 | areaData:[], | 503 | areaData:[], | 
| 481 | locationData:[], | 504 | locationData:[], | 
| 482 | roles:[], | 505 | roles:[], | 
|  |  | 506 | +                imgBase64:'', | 
|  |  | 507 | +                imgUploadPath:uploadPath, | 
|  |  | 508 | +                uploadFileList:[], | 
|  |  | 509 | +                uploadHeaderObj: { | 
|  |  | 510 | +                    Authorization: window.sessionStorage.getItem("token"), | 
|  |  | 511 | +                }, | 
| 483 | dialogMap: { | 512 | dialogMap: { | 
| 484 | update: '编辑', | 513 | update: '编辑', | 
| 485 | create: '新增' | 514 | create: '新增' | 
|  | @@ -830,6 +859,84 @@ |  | @@ -830,6 +859,84 @@ | 
| 830 | }; | 859 | }; | 
| 831 | }, | 860 | }, | 
| 832 | screenshot(){ | 861 | screenshot(){ | 
|  |  | 862 | +                let video = document.getElementById('videos') | 
|  |  | 863 | +                html2canvas(video, { | 
|  |  | 864 | +                    allowTaint: true, | 
|  |  | 865 | +                    useCORS: true | 
|  |  | 866 | +                }).then((canvas) => { | 
|  |  | 867 | +                    // base64 | 
|  |  | 868 | +                    this.imgBase64 = canvas.toDataURL('image/png') | 
|  |  | 869 | +                    // 下载方法1,浏览器弹出下载文件提示 | 
|  |  | 870 | +                    const saveInfo = { | 
|  |  | 871 | +                        // 导出文件格式自己定义 | 
|  |  | 872 | +                        'download': '文件名' + '.png', | 
|  |  | 873 | +                        'href': this.imgBase64 | 
|  |  | 874 | +                    } | 
|  |  | 875 | +                    const element = document.createElement('a') | 
|  |  | 876 | +                    element.style.display = 'none' | 
|  |  | 877 | +                    for (const key in saveInfo) { | 
|  |  | 878 | +                        element.setAttribute(key, saveInfo[key]) | 
|  |  | 879 | +                    } | 
|  |  | 880 | +                    document.body.appendChild(element) | 
|  |  | 881 | +                    // element.click() | 
|  |  | 882 | +                    setTimeout(() => { | 
|  |  | 883 | +                        document.body.removeChild(element) | 
|  |  | 884 | +                    }, 300) | 
|  |  | 885 | +                    this.uploadFile(this.imgBase64) | 
|  |  | 886 | +                }) | 
|  |  | 887 | +            }, | 
|  |  | 888 | +            // 接口上传 | 
|  |  | 889 | +            uploadFile(imgBase64){ | 
|  |  | 890 | +                const base64List = imgBase64.split(',')[1] | 
|  |  | 891 | +                const raw = window.atob(base64List) | 
|  |  | 892 | +                const rawLength = raw.length | 
|  |  | 893 | +                const uInt8Array = new Uint8Array(rawLength) | 
|  |  | 894 | +                for (let i = 0; i < rawLength; ++i) { | 
|  |  | 895 | +                    uInt8Array[i] = raw.charCodeAt(i) | 
|  |  | 896 | +                } | 
|  |  | 897 | +                // 若需上传,将base64转为file文件 | 
|  |  | 898 | +                const blob = new Blob([uInt8Array], { type: 'image/png' }) | 
|  |  | 899 | +                let fileOfBlob = new File([blob], 'imgCaptureTest' + '.png') | 
|  |  | 900 | +                // this.submitUpload(fileOfBlob); | 
|  |  | 901 | +                var formData = new FormData() | 
|  |  | 902 | +                formData.append('file', fileOfBlob) | 
|  |  | 903 | +                this.submitUpload(formData); | 
|  |  | 904 | +            }, | 
|  |  | 905 | +            //上传文件 | 
|  |  | 906 | +            handleUploadSuccess: function(response, file, fileList){ | 
|  |  | 907 | +                let res = response.data; | 
|  |  | 908 | +                if (response.code !== '200') { | 
|  |  | 909 | +                    // 关闭加载 | 
|  |  | 910 | +                    return this.$message.error(response.msg); | 
|  |  | 911 | +                } | 
|  |  | 912 | +                this.$message.success(res.msg); | 
|  |  | 913 | +                this.addForm.picUrl = res.data.relativePath | 
|  |  | 914 | + | 
|  |  | 915 | +            }, | 
|  |  | 916 | +            submitUpload(formData){ | 
|  |  | 917 | +                let ld = this.$loading({ | 
|  |  | 918 | +                    text:"图片数据上传中..." | 
|  |  | 919 | +                }) | 
|  |  | 920 | +                const para = { | 
|  |  | 921 | +                    file:formData | 
|  |  | 922 | +                } | 
|  |  | 923 | +                upfileWithPost(formData).then((response)=>{ | 
|  |  | 924 | +                    let res = response.data; | 
|  |  | 925 | +                    if (res.code !== '200') { | 
|  |  | 926 | +                        // 关闭加载 | 
|  |  | 927 | +                        return this.$message.error(res.msg); | 
|  |  | 928 | +                    } | 
|  |  | 929 | +                    this.$message.success(res.msg); | 
|  |  | 930 | +                    this.addForm.picUrl = res.data.relativePath | 
|  |  | 931 | +                }).finally(()=>{ | 
|  |  | 932 | +                    ld.close() | 
|  |  | 933 | +                }) | 
|  |  | 934 | +                // this.$refs.upload.submit(); | 
|  |  | 935 | +            }, | 
|  |  | 936 | +            trnSelectionChange(){ | 
|  |  | 937 | + | 
|  |  | 938 | +            }, | 
|  |  | 939 | +            checkSelectable(){ | 
| 833 |  | 940 |  | 
| 834 | } | 941 | } | 
| 835 | }, | 942 | }, |