|
|
@ -1,34 +1,22 @@ |
|
|
|
import React, { useEffect, useState } from 'react'; |
|
|
|
import { connect } from 'react-redux'; |
|
|
|
import { Spin, Card, Form, Input, Select, Button, Table, Modal, Popconfirm, Tooltip } from 'antd'; |
|
|
|
const { TextArea } = Input; |
|
|
|
import moment from "moment"; |
|
|
|
import { Button, Table, Popconfirm } from 'antd'; |
|
|
|
import '../style.less'; |
|
|
|
import { push } from 'react-router-redux'; |
|
|
|
import PointModel from '../components/pointModel' |
|
|
|
import { Model } from 'qrcode'; |
|
|
|
|
|
|
|
|
|
|
|
const Information = (props) => { |
|
|
|
const { dispatch, actions, user, loading } = props |
|
|
|
const { dispatch, actions } = props |
|
|
|
const { projectRegime } = actions |
|
|
|
const [firmList, setFirmList] = useState([]) |
|
|
|
const [tableList, settableList] = useState([]) |
|
|
|
const [addModel, setAddModel] = useState(false) |
|
|
|
const [modelData, setModelData] = useState({}) |
|
|
|
const [query, setQuery] = useState({ limit: 10, page: 0 }) |
|
|
|
const [limits, setLimits] = useState() |
|
|
|
const [search, setSearch] = useState({}) |
|
|
|
const [isPicture, setIsPicture] = useState(false) |
|
|
|
const [pictureUrl, setPictureUrl] = useState() |
|
|
|
const [companyID, setCompanyId] = useState('') |
|
|
|
const [select, setSelect] = useState([]) |
|
|
|
const [selec, setSelec] = useState() |
|
|
|
const [form] = Form.useForm(); |
|
|
|
|
|
|
|
var QRCode = require('qrcode') |
|
|
|
const { createCanvas, loadImage, registerFont } = require('canvas') |
|
|
|
|
|
|
|
const [qrCodeingIds, setQrCodeingIds] = useState(null) |
|
|
|
|
|
|
|
const qrCodeId = props?.match?.params?.id |
|
|
|
|
|
|
@ -53,77 +41,7 @@ const Information = (props) => { |
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
|
const createQrCode = (name) => { |
|
|
|
let url = '' |
|
|
|
QRCode.toDataURL(name, { |
|
|
|
errorCorrectionLevel: 'low', |
|
|
|
type: 'image/png', |
|
|
|
quality: 0.3, |
|
|
|
margin: 2, |
|
|
|
maskPattern: 9, |
|
|
|
width: 400, |
|
|
|
color: { |
|
|
|
dark: "#000000ff", |
|
|
|
light: "#ffffffff" |
|
|
|
} |
|
|
|
}, function (err, v) { |
|
|
|
url = v |
|
|
|
}) |
|
|
|
return url |
|
|
|
} |
|
|
|
|
|
|
|
// const createQrCode = (name) => {
|
|
|
|
// const CW = 400, FONTSIZE = 30, FR = 2, CH = CW + FONTSIZE * FR;
|
|
|
|
// let url = ''
|
|
|
|
// // QRCode.toFile('F',name,
|
|
|
|
// // {
|
|
|
|
// // margin: 1,//二维码内边距,默认为4。单位px
|
|
|
|
// // height: CW,//二维码高度
|
|
|
|
// // width: CW,//二维码宽度
|
|
|
|
// // color: {
|
|
|
|
// // dark: '#000', //
|
|
|
|
// // light: '#fff' //
|
|
|
|
// // }
|
|
|
|
// // });
|
|
|
|
|
|
|
|
// QRCode.toDataURL(name, {
|
|
|
|
// errorCorrectionLevel: 'low',
|
|
|
|
// type: 'image/png',
|
|
|
|
// quality: 0.3,
|
|
|
|
// margin: 2,
|
|
|
|
// maskPattern: 9,
|
|
|
|
// width: 400,
|
|
|
|
// color: {
|
|
|
|
// dark: "#000000ff",
|
|
|
|
// light: "#ffffffff"
|
|
|
|
// }
|
|
|
|
// }, function (err, v) {
|
|
|
|
// url = v
|
|
|
|
// })
|
|
|
|
// // return url
|
|
|
|
|
|
|
|
// const canvas = createCanvas(CW, CH)
|
|
|
|
// const ctx = canvas.getContext('2d')
|
|
|
|
// ctx.clearRect(0, 0, CW, CH)
|
|
|
|
// ctx.fillStyle = 'rgba(255,255,255,1)'
|
|
|
|
// ctx.fillRect(0, 0, CW, CH)
|
|
|
|
// ctx.fillStyle = 'rgba(0,0,0,1)'
|
|
|
|
// ctx.font = `${FONTSIZE}px ZiTiQuanWeiJunHei`
|
|
|
|
// // ctx.font = `700 ${FONTSIZE}px `
|
|
|
|
// let image = loadImage(url)
|
|
|
|
// ctx.drawImage(image, 0, 0, CW, CW)
|
|
|
|
// const text = ctx.measureText(name)
|
|
|
|
// ctx.fillText(name, (CW - text.width) * 0.5, CH - FONTSIZE)
|
|
|
|
// canvas.toDataURL('image/png', (err, png) => {
|
|
|
|
// if (!err) {
|
|
|
|
// console.log(png);
|
|
|
|
// }
|
|
|
|
// })
|
|
|
|
// return url
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
const columns = [ |
|
|
|
const columns = [ |
|
|
|
{ |
|
|
|
title: '序号', |
|
|
|
dataIndex: 'index', |
|
|
@ -151,14 +69,11 @@ const columns = [ |
|
|
|
key: 'operation', |
|
|
|
render: (text, record, index) => { |
|
|
|
return ( |
|
|
|
<div style={{ width: 224 }}> |
|
|
|
<> |
|
|
|
<Button type="link" onClick={() => { |
|
|
|
setAddModel(true) |
|
|
|
setModelData(record) |
|
|
|
console.log(record); |
|
|
|
}} |
|
|
|
|
|
|
|
>编辑</Button> |
|
|
|
}}>编辑</Button> |
|
|
|
<Popconfirm |
|
|
|
title={<div style={{ width: 184 }}>删除该点位后,与巡检计划关联的点位删除,对应的巡检记录删除,是否确认删除?</div>} |
|
|
|
position='topLeft' |
|
|
@ -171,46 +86,49 @@ const columns = [ |
|
|
|
projectList({ limit: query?.limit, page: query?.page - 1, ...search }) |
|
|
|
setQuery({ limit: query?.limit, page: query?.page - 1 }); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
}) |
|
|
|
}} |
|
|
|
> |
|
|
|
<Button type="link" danger >删除</Button> |
|
|
|
</Popconfirm> |
|
|
|
{/* <Button type="link" danger >二维码生成</Button> */} |
|
|
|
<Button type="link" onClick={() => { |
|
|
|
let url = createQrCode('FS' + Date.now() + record.id) |
|
|
|
console.log(url); |
|
|
|
setQrCodeingIds([record.id]) |
|
|
|
dispatch(projectRegime.addPosition({ |
|
|
|
qrCode: url, |
|
|
|
qrCode: true, |
|
|
|
id: record.id, |
|
|
|
}, true)) |
|
|
|
}} >二维码生成</Button> |
|
|
|
</div> |
|
|
|
}, true)).then(() => { |
|
|
|
setQrCodeingIds(null) |
|
|
|
}) |
|
|
|
}} loading={qrCodeingIds?.includes(record.id)}>二维码生成</Button> |
|
|
|
</> |
|
|
|
) |
|
|
|
} |
|
|
|
} |
|
|
|
] |
|
|
|
] |
|
|
|
|
|
|
|
return ( |
|
|
|
return ( |
|
|
|
<> |
|
|
|
<img src={selec} /> |
|
|
|
|
|
|
|
<div style={{ display: 'flex', marginBottom: 10 }}> |
|
|
|
<Button type="primary" onClick={() => { |
|
|
|
setAddModel(true) |
|
|
|
}}>新建点位</Button> |
|
|
|
<Button type="primary" style={{ marginLeft: 20 }} onClick={() => { |
|
|
|
select?.map(v => { |
|
|
|
let url = createQrCode('FS' + Date.now() + v.id) |
|
|
|
console.log(url); |
|
|
|
if (select.length) { |
|
|
|
setQrCodeingIds(select.map(s => s.id)); |
|
|
|
select?.map((v, i) => { |
|
|
|
dispatch(projectRegime.addPosition({ |
|
|
|
qrCode: url, |
|
|
|
qrCode: true, |
|
|
|
id: v.id, |
|
|
|
}, true)) |
|
|
|
}, true)).then(() => { |
|
|
|
if (i === select.length - 1) { |
|
|
|
setQrCodeingIds(null); |
|
|
|
} |
|
|
|
}) |
|
|
|
}}>一键生成二维码</Button> |
|
|
|
}) |
|
|
|
} |
|
|
|
}} disabled={qrCodeingIds?.length}>一键生成二维码</Button> |
|
|
|
</div> |
|
|
|
|
|
|
|
<Table |
|
|
@ -256,10 +174,10 @@ return ( |
|
|
|
/> : "" |
|
|
|
} |
|
|
|
</> |
|
|
|
) |
|
|
|
) |
|
|
|
} |
|
|
|
|
|
|
|
function mapStateToProps (state) { |
|
|
|
function mapStateToProps(state) { |
|
|
|
const { auth, global } = state; |
|
|
|
return { |
|
|
|
user: auth.user, |
|
|
|