|
@ -5,6 +5,9 @@ import moment from "moment"; |
|
|
import '../style.less'; |
|
|
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 { createCanvas, loadImage, registerFont } from 'canvas' |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const QrCode = (props) => { |
|
|
const QrCode = (props) => { |
|
|
const { dispatch, actions, user, loading } = props |
|
|
const { dispatch, actions, user, loading } = props |
|
@ -22,50 +25,48 @@ 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) { |
|
|
setFirmList(res.payload.data?.rows?.map(v => ({ value: v.id, label: v.name }))) |
|
|
setFirmList(res.payload.data?.rows?.map(v => ({ value: v.id, label: v.name }))) |
|
|
} |
|
|
} |
|
|
}) |
|
|
}) |
|
|
|
|
|
projectList({}) |
|
|
}, []) |
|
|
}, []) |
|
|
|
|
|
|
|
|
const projectList = (obj) => { |
|
|
const projectList = (obj) => { |
|
|
const { limit, page, companyId, name, type } = obj |
|
|
const { projectId, name } = obj |
|
|
dispatch(projectRegime.getProjectList({ limit, page, companyId, name, type })).then(res => { |
|
|
dispatch(projectRegime.qrCodeShow({ projectId, name })).then(res => { |
|
|
// console.log(res)
|
|
|
|
|
|
if (res.success) { |
|
|
if (res.success) { |
|
|
settableList(res.payload.data?.rows?.map(v => ({ ...v, key: v.id }))) |
|
|
settableList(res.payload.data?.rows) |
|
|
setLimits(res.payload.data?.count) |
|
|
|
|
|
} |
|
|
} |
|
|
}) |
|
|
}) |
|
|
} |
|
|
} |
|
|
|
|
|
console.log(firmList); |
|
|
|
|
|
|
|
|
return ( |
|
|
return ( |
|
|
<> |
|
|
<> |
|
|
<div style={{ display: 'flex', justifyContent: 'space-between', padding: '0 10px' }}> |
|
|
|
|
|
<Form |
|
|
<Form |
|
|
style={{ display: 'flex', }} |
|
|
style={{ display: 'flex', }} |
|
|
onFinish={r => { |
|
|
onFinish={r => { |
|
|
projectList(r) |
|
|
projectList(r) |
|
|
setSearch(r) |
|
|
|
|
|
}} |
|
|
}} |
|
|
> |
|
|
> |
|
|
<Form.Item |
|
|
<Form.Item |
|
|
label='所属公司' |
|
|
label='结构物名称' |
|
|
name="companyId" |
|
|
name="projectId" |
|
|
style={{ marginRight: 16, minWidth: 180 }} |
|
|
style={{ marginRight: 16, width: 240 }} |
|
|
initialValue={firmList[0]?.name} |
|
|
// initialValue={firmList[0]?.name}
|
|
|
> |
|
|
> |
|
|
<Select allowClear placeholder="全部" options={firmList} /> |
|
|
<Select allowClear placeholder="请选择结构物名称" options={firmList} /> |
|
|
</Form.Item> |
|
|
</Form.Item> |
|
|
<Form.Item |
|
|
<Form.Item |
|
|
label='项目名称' |
|
|
label='点位名称' |
|
|
name="name" |
|
|
name="name" |
|
|
style={{ marginRight: 16, minWidth: 180 }} |
|
|
style={{ marginRight: 16, width: 260 }} |
|
|
> |
|
|
> |
|
|
<Input placeholder="请输入项目名称" allowClear /> |
|
|
<Input placeholder="请输入点位名称" allowClear /> |
|
|
</Form.Item> |
|
|
</Form.Item> |
|
|
<Form.Item wrapperCol={{}}> |
|
|
<Form.Item wrapperCol={{}}> |
|
|
<Button type="primary" htmlType="submit"> |
|
|
<Button type="primary" htmlType="submit"> |
|
@ -73,10 +74,58 @@ const QrCode = (props) => { |
|
|
</Button> |
|
|
</Button> |
|
|
</Form.Item> |
|
|
</Form.Item> |
|
|
</Form> |
|
|
</Form> |
|
|
<Button onClick={() => { |
|
|
<div > |
|
|
console.log(45513); |
|
|
{ |
|
|
setAddModel(true) |
|
|
tableList?.map(v => { |
|
|
}}>新建项目</Button> |
|
|
return <div key={v.name + v.id} |
|
|
|
|
|
style={{ display: 'inline-block', margin: '0 10px 10px 0', border: '1px solid #3c383824' }} > |
|
|
|
|
|
<div style={{ |
|
|
|
|
|
display: 'flex', flexDirection: 'column', padding: '6px 0', |
|
|
|
|
|
marginLeft: 20, width: 220, borderBottom: '1px solid #3c383824' |
|
|
|
|
|
}}> |
|
|
|
|
|
<span>结构物名称:{firmList?.filter(u => u.value == v.projectId)[0]?.label}</span> |
|
|
|
|
|
<span>结构物名称:{v.name}</span> |
|
|
|
|
|
</div> |
|
|
|
|
|
<img src={v.qrCode} style={{ display: 'inline-block', width: 260 }} /> |
|
|
|
|
|
<div style={{ |
|
|
|
|
|
width: 260, height: 60, background: '#e1d4d42e', display: 'flex', |
|
|
|
|
|
justifyContent: 'center', alignItems: 'center', borderTop: '1px solid #3c383824' |
|
|
|
|
|
}}> |
|
|
|
|
|
{/* <a href={`${v.qrCode + '?filename=' + encodeURIComponent(v.name)}.png`}> */} |
|
|
|
|
|
<Button type="primary" onClick={() => { |
|
|
|
|
|
const aa = (v) => { |
|
|
|
|
|
const img = new Image(), |
|
|
|
|
|
canvas = createCanvas(460, 490), |
|
|
|
|
|
ctx = canvas.getContext('2d') |
|
|
|
|
|
img.crossOrigin = 'anonymous' |
|
|
|
|
|
img.onload = function () { |
|
|
|
|
|
const w = 460, h = 490 |
|
|
|
|
|
|
|
|
|
|
|
ctx.drawImage(img, 0, 0,460,490) |
|
|
|
|
|
ctx.beginPath() |
|
|
|
|
|
ctx.font = 'dcscsdcsd' |
|
|
|
|
|
ctx.fillStyle = '#000' |
|
|
|
|
|
ctx.fillText('5315', w, h) |
|
|
|
|
|
ctx.closePath() |
|
|
|
|
|
const save_link = document.createElement('a') |
|
|
|
|
|
save_link.href = canvas.toDataURl('image/png') |
|
|
|
|
|
save_link.download = 'dcscds.png' |
|
|
|
|
|
document.body.appendChild(save_link) |
|
|
|
|
|
save_link.click() |
|
|
|
|
|
save_link.remove() |
|
|
|
|
|
} |
|
|
|
|
|
img.src = v |
|
|
|
|
|
} |
|
|
|
|
|
aa(v.qrCode) |
|
|
|
|
|
|
|
|
|
|
|
}}>下载二维码</Button> |
|
|
|
|
|
{/* </a> */} |
|
|
|
|
|
|
|
|
|
|
|
</div> |
|
|
|
|
|
</div> |
|
|
|
|
|
} |
|
|
|
|
|
) |
|
|
|
|
|
} |
|
|
</div> |
|
|
</div> |
|
|
|
|
|
|
|
|
</> |
|
|
</> |
|
|