Browse Source

问题

master
wenlele 2 years ago
parent
commit
10bf219820
  1. 4
      api/app/lib/controllers/projectRegime/projectSituation.js
  2. 53
      web/client/src/sections/projectRegime/containers/qrCode.js

4
api/app/lib/controllers/projectRegime/projectSituation.js

@ -8,9 +8,9 @@ async function projectList (ctx, next) {
const { limit, page, name, justStructure } = ctx.query; const { limit, page, name, justStructure } = ctx.query;
let options = { let options = {
// where: { where: {
// }, },
// include: [{ // include: [{
// as: 'company', // as: 'company',
// model: models.Company, // model: models.Company,

53
web/client/src/sections/projectRegime/containers/qrCode.js

@ -6,6 +6,8 @@ import '../style.less';
import ProjectAddModel from '../components/projectAddModel' import ProjectAddModel from '../components/projectAddModel'
import { Model } from 'echarts'; import { Model } from 'echarts';
import { login } from '../../auth/actions/auth'; import { login } from '../../auth/actions/auth';
import { createCanvas, loadImage, registerFont } from 'canvas'
const QrCode = (props) => { const QrCode = (props) => {
const { dispatch, actions, user, loading } = props const { dispatch, actions, user, loading } = props
@ -23,6 +25,7 @@ const QrCode = (props) => {
useEffect(() => { useEffect(() => {
dispatch(projectRegime.getProjectList({ justStructure: true })).then(res => { dispatch(projectRegime.getProjectList({ justStructure: true })).then(res => {
if (res.success) { if (res.success) {
@ -89,33 +92,33 @@ const QrCode = (props) => {
justifyContent: 'center', alignItems: 'center', borderTop: '1px solid #3c383824' justifyContent: 'center', alignItems: 'center', borderTop: '1px solid #3c383824'
}}> }}>
{/* <a href={`${v.qrCode + '?filename=' + encodeURIComponent(v.name)}.png`}> */} {/* <a href={`${v.qrCode + '?filename=' + encodeURIComponent(v.name)}.png`}> */}
<Button type="primary" onClick={() => { <Button type="primary" onClick={() => {
const aa = (v) => { const aa = (v) => {
const img = new Image(), const img = new Image(),
canvas = $('.canas'), canvas = createCanvas(460, 490),
ctx = canvas[0].getContext('2d') ctx = canvas.getContext('2d')
img.crossOrigin = 'anonymous' img.crossOrigin = 'anonymous'
img.onload = function () { img.onload = function () {
const w = 460, h = 490 const w = 460, h = 490
canvas.attr({ width: w, height: h })
ctx.drawImage(img, 0, 0) ctx.drawImage(img, 0, 0,460,490)
ctx.beginPath() ctx.beginPath()
ctx.font = 'dcscsdcsd' ctx.font = 'dcscsdcsd'
ctx.fillStyle = '#000' ctx.fillStyle = '#000'
ctx.fillText('5315', w, h) ctx.fillText('5315', w, h)
ctx.closePath() ctx.closePath()
const save_link = document.createElement('a') const save_link = document.createElement('a')
save_link.href = canvas[0].toDataURl('image/png') save_link.href = canvas.toDataURl('image/png')
save_link.download = 'dcscds.png' save_link.download = 'dcscds.png'
document.body.appendChild(save_link) document.body.appendChild(save_link)
save_link.click() save_link.click()
save_link.remove() save_link.remove()
}
img.src = v
} }
aa(v.qrCode) img.src = v
}
aa(v.qrCode)
}}>下载二维码</Button> }}>下载二维码</Button>
{/* </a> */} {/* </a> */}
</div> </div>

Loading…
Cancel
Save