From 99c0ccd473e30f029b81feb65975d654528bc3e5 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期四, 20 四月 2023 17:58:02 +0800 Subject: [PATCH] 2023-04-20 --- src/tabviews/custom/components/group/normal-group/index.jsx | 158 ++++++++++++++++++++++++++-------------------------- 1 files changed, 79 insertions(+), 79 deletions(-) diff --git a/src/tabviews/custom/components/group/normal-group/index.jsx b/src/tabviews/custom/components/group/normal-group/index.jsx index 631caf0..ff504f4 100644 --- a/src/tabviews/custom/components/group/normal-group/index.jsx +++ b/src/tabviews/custom/components/group/normal-group/index.jsx @@ -1,7 +1,7 @@ import React, {Component} from 'react' import PropTypes from 'prop-types' import { is, fromJS } from 'immutable' -import { Col, notification, Button, Row } from 'antd' +import { Col, notification, Row } from 'antd' import Api from '@/api' import asyncComponent from '@/utils/asyncComponent' @@ -44,7 +44,7 @@ state = { mainSearch: [], - printing: false, + // printing: false, data: null } @@ -296,101 +296,101 @@ }) } - canvasToImage(canvas) { - let image = new Image() - image.src = canvas.toDataURL('image/jpg') - image.style = 'width:100%;height:100%;position:absolute;z-index:1;left:0px;top:0px;' - return image - } + // canvasToImage(canvas) { + // let image = new Image() + // image.src = canvas.toDataURL('image/jpg') + // image.style = 'width:100%;height:100%;position:absolute;z-index:1;left:0px;top:0px;' + // return image + // } - print = () => { - const { config } = this.props - const { printing } = this.state + // print = () => { + // const { config } = this.props + // const { printing } = this.state - if (printing) return - this.setState({printing: true}) + // if (printing) return + // this.setState({printing: true}) - let qrcodes = document.getElementsByClassName('qrcode-box') + // let qrcodes = document.getElementsByClassName('qrcode-box') - for (let i = 0; i < qrcodes.length; i++) { - let canvas = qrcodes[i].getElementsByTagName('canvas')[0] + // for (let i = 0; i < qrcodes.length; i++) { + // let canvas = qrcodes[i].getElementsByTagName('canvas')[0] - if (canvas) { - let img = this.canvasToImage(canvas) + // if (canvas) { + // let img = this.canvasToImage(canvas) - canvas.remove() - qrcodes[i].append(img) - } - } + // canvas.remove() + // qrcodes[i].append(img) + // } + // } - let pageSize = ['A4', 'A3', 'A5'].includes(config.setting.pageSize) ? config.setting.pageSize : 'A4' - let pageLayout = config.setting.pageLayout !== 'horizontal' ? 'vertical' : 'horizontal' - let hides = config.setting.hide || [] + // let pageSize = ['A4', 'A3', 'A5'].includes(config.setting.pageSize) ? config.setting.pageSize : 'A4' + // let pageLayout = config.setting.pageLayout !== 'horizontal' ? 'vertical' : 'horizontal' + // let hides = config.setting.hide || [] - let pageParam = { - A4: { - vertical: 980, - horizontal: 1200, - }, - A3: { - vertical: 1200, - horizontal: 1600, - }, - A5: { - vertical: 700, - horizontal: 1000, - } - } + // let pageParam = { + // A4: { + // vertical: 980, + // horizontal: 1200, + // }, + // A3: { + // vertical: 1200, + // horizontal: 1600, + // }, + // A5: { + // vertical: 700, + // horizontal: 1000, + // } + // } - let width = pageParam[pageSize][pageLayout] + // let width = pageParam[pageSize][pageLayout] - try { - let jubuData = document.getElementById(config.uuid).innerHTML + // try { + // let jubuData = document.getElementById(config.uuid).innerHTML - let iframe = document.createElement('IFRAME') - let linkList = document.getElementsByTagName('link') // 鑾峰彇鐖剁獥鍙ink鏍囩瀵硅薄鍒楄〃 - let styleList = document.getElementsByTagName('style') // 鑾峰彇鐖剁獥鍙tyle鏍囩瀵硅薄鍒楄〃 + // let iframe = document.createElement('IFRAME') + // let linkList = document.getElementsByTagName('link') // 鑾峰彇鐖剁獥鍙ink鏍囩瀵硅薄鍒楄〃 + // let styleList = document.getElementsByTagName('style') // 鑾峰彇鐖剁獥鍙tyle鏍囩瀵硅薄鍒楄〃 - document.body.appendChild(iframe) - let doc = iframe.contentWindow.document + // document.body.appendChild(iframe) + // let doc = iframe.contentWindow.document - doc.open() - doc.write(`<!DOCTYPE html><html lang="en"><head>`) - for (let i = 0;i < linkList.length;i++) { - if (linkList[i].type === 'text/css') { - doc.write(`<LINK rel="stylesheet" type="text/css" href="${linkList[i].href}">`) - } - } - doc.write(`<style>body{width: ${width}px!important;} *{border-style: solid;border-width: 0;} .print-button{display: none!important;} ${hides.includes('search') ? '.top-search{display: none!important;}' : ''} ${hides.includes('button') ? '.ant-btn{opacity: 0!important;}' : ''}</style>`) - for (let i = 0;i < styleList.length;i++) { - doc.write('<style>' + styleList[i].innerHTML + '</style>') - } - doc.write(`</head><body>`) - doc.write(jubuData) - doc.write(`</body></html>`) - doc.close() + // doc.open() + // doc.write(`<!DOCTYPE html><html lang="en"><head>`) + // for (let i = 0;i < linkList.length;i++) { + // if (linkList[i].type === 'text/css') { + // doc.write(`<LINK rel="stylesheet" type="text/css" href="${linkList[i].href}">`) + // } + // } + // doc.write(`<style>body{width: ${width}px!important;} *{border-style: solid;border-width: 0;} .print-button{display: none!important;} ${hides.includes('search') ? '.top-search{display: none!important;}' : ''} ${hides.includes('button') ? '.ant-btn{opacity: 0!important;}' : ''}</style>`) + // for (let i = 0;i < styleList.length;i++) { + // doc.write('<style>' + styleList[i].innerHTML + '</style>') + // } + // doc.write(`</head><body>`) + // doc.write(jubuData) + // doc.write(`</body></html>`) + // doc.close() - setTimeout(() => { - iframe.contentWindow.focus() - iframe.contentWindow.print() + // setTimeout(() => { + // iframe.contentWindow.focus() + // iframe.contentWindow.print() - document.body.removeChild(iframe) + // document.body.removeChild(iframe) - this.setState({printing: false}) - }, 500) - } catch (e) { - this.setState({printing: false}) - notification.warning({ - top: 92, - message: '鎵撳嵃寮傚父锛�', - duration: 5 - }) - } - } + // this.setState({printing: false}) + // }, 500) + // } catch (e) { + // this.setState({printing: false}) + // notification.warning({ + // top: 92, + // message: '鎵撳嵃寮傚父锛�', + // duration: 5 + // }) + // } + // } render() { const { config } = this.props - const { printing } = this.state + // const { printing } = this.state if (!config.components || config.components.length === 0) return (<div style={config.style}></div>) @@ -399,7 +399,7 @@ {config.setting && config.setting.title ? <div className="group-header" style={config.headerStyle}> <span className="title">{config.setting.title}</span> </div> : null} - {config.setting && config.setting.print === 'true' ? <Button className="print-button" icon="printer" loading={printing} onClick={this.print}></Button> : null} + {/* {config.setting && config.setting.print === 'true' ? <Button className="print-button" icon="printer" loading={printing} onClick={this.print}></Button> : null} */} <Row className="component-wrap">{this.getComponents()}</Row> </div> ) -- Gitblit v1.8.0