|
@ -6,7 +6,7 @@ import moment from "moment"; |
|
|
import '../style.less'; |
|
|
import '../style.less'; |
|
|
import { push } from 'react-router-redux'; |
|
|
import { push } from 'react-router-redux'; |
|
|
import PointModel from '../components/pointModel' |
|
|
import PointModel from '../components/pointModel' |
|
|
import { Model } from 'echarts'; |
|
|
import { Model } from 'qrcode'; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const Information = (props) => { |
|
|
const Information = (props) => { |
|
@ -27,11 +27,12 @@ const Information = (props) => { |
|
|
const [form] = Form.useForm(); |
|
|
const [form] = Form.useForm(); |
|
|
|
|
|
|
|
|
var QRCode = require('qrcode') |
|
|
var QRCode = require('qrcode') |
|
|
|
|
|
const { createCanvas, loadImage, registerFont } = require('canvas') |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const qrCodeId = props?.match?.params?.id |
|
|
const qrCodeId = props?.match?.params?.id |
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
useEffect(() => { |
|
|
console.log(props?.match?.params?.id); |
|
|
|
|
|
projectList(query) |
|
|
projectList(query) |
|
|
}, []) |
|
|
}, []) |
|
|
|
|
|
|
|
@ -71,141 +72,191 @@ const Information = (props) => { |
|
|
return url |
|
|
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' //
|
|
|
|
|
|
// // }
|
|
|
|
|
|
// // });
|
|
|
|
|
|
|
|
|
const columns = [ |
|
|
// QRCode.toDataURL(name, {
|
|
|
{ |
|
|
// errorCorrectionLevel: 'low',
|
|
|
title: '序号', |
|
|
// type: 'image/png',
|
|
|
dataIndex: 'index', |
|
|
// quality: 0.3,
|
|
|
key: 'index', |
|
|
// margin: 2,
|
|
|
render: (text, record, index) => index + 1 |
|
|
// maskPattern: 9,
|
|
|
}, { |
|
|
// width: 400,
|
|
|
title: '点位名称', |
|
|
// color: {
|
|
|
dataIndex: 'name', |
|
|
// dark: "#000000ff",
|
|
|
key: 'name', |
|
|
// light: "#ffffffff"
|
|
|
}, { |
|
|
// }
|
|
|
title: '所在地区', |
|
|
// }, function (err, v) {
|
|
|
dataIndex: 'position', |
|
|
// url = v
|
|
|
key: 'position', |
|
|
// })
|
|
|
render: (text, record, index) => { |
|
|
// // return url
|
|
|
return record.longitude && record.latitude ? <div style={{ width: 100 }}>{record.longitude},{record.latitude}</div> : "--" |
|
|
|
|
|
} |
|
|
|
|
|
}, { |
|
|
|
|
|
title: '描述', |
|
|
|
|
|
dataIndex: 'describe', |
|
|
|
|
|
key: 'describe', |
|
|
|
|
|
render: (text, record, index) => record.describe || '--' |
|
|
|
|
|
}, { |
|
|
|
|
|
title: '操作', |
|
|
|
|
|
dataIndex: 'operation', |
|
|
|
|
|
key: 'operation', |
|
|
|
|
|
render: (text, record, index) => { |
|
|
|
|
|
return ( |
|
|
|
|
|
<div style={{ width: 224 }}> |
|
|
|
|
|
<Button type="link" onClick={() => { |
|
|
|
|
|
setAddModel(true) |
|
|
|
|
|
setModelData(record) |
|
|
|
|
|
console.log(record); |
|
|
|
|
|
}} |
|
|
|
|
|
|
|
|
|
|
|
>编辑</Button> |
|
|
// const canvas = createCanvas(CW, CH)
|
|
|
<Popconfirm |
|
|
// const ctx = canvas.getContext('2d')
|
|
|
title='确认删除工程信息?' |
|
|
// ctx.clearRect(0, 0, CW, CH)
|
|
|
position='topLeft' |
|
|
// ctx.fillStyle = 'rgba(255,255,255,1)'
|
|
|
onConfirm={() => { |
|
|
// ctx.fillRect(0, 0, CW, CH)
|
|
|
dispatch(projectRegime.delPosition(record.id)).then(res => { |
|
|
// ctx.fillStyle = 'rgba(0,0,0,1)'
|
|
|
if (res.success) { |
|
|
// ctx.font = `${FONTSIZE}px ZiTiQuanWeiJunHei`
|
|
|
if ((limits > 11 && tableList.length > 1) || limits < 11) { |
|
|
// // ctx.font = `700 ${FONTSIZE}px `
|
|
|
projectList({ ...query, ...search }) |
|
|
// let image = loadImage(url)
|
|
|
} else { |
|
|
// ctx.drawImage(image, 0, 0, CW, CW)
|
|
|
projectList({ limit: query?.limit, page: query?.page - 1, ...search }) |
|
|
// const text = ctx.measureText(name)
|
|
|
setQuery({ limit: query?.limit, page: query?.page - 1 }); |
|
|
// 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 = [ |
|
|
}} |
|
|
{ |
|
|
> |
|
|
title: '序号', |
|
|
<Button type="link" danger >删除</Button> |
|
|
dataIndex: 'index', |
|
|
</Popconfirm> |
|
|
key: 'index', |
|
|
{/* <Button type="link" danger >二维码生成</Button> */} |
|
|
render: (text, record, index) => index + 1 |
|
|
<Button type="link" onClick={() => { |
|
|
}, { |
|
|
let url = createQrCode('FS' + Date.now() + record.id) |
|
|
title: '点位名称', |
|
|
console.log(url); |
|
|
dataIndex: 'name', |
|
|
dispatch(projectRegime.addPosition({ |
|
|
key: 'name', |
|
|
qrCode: url, |
|
|
}, { |
|
|
id: record.id, |
|
|
title: '所在地区', |
|
|
}, true)) |
|
|
dataIndex: 'position', |
|
|
}} >二维码生成</Button> |
|
|
key: 'position', |
|
|
</div> |
|
|
render: (text, record, index) => { |
|
|
) |
|
|
return record.longitude && record.latitude ? <div style={{ width: 100 }}>{record.longitude},{record.latitude}</div> : "--" |
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
] |
|
|
}, { |
|
|
|
|
|
title: '描述', |
|
|
return ( |
|
|
dataIndex: 'describe', |
|
|
<> |
|
|
key: 'describe', |
|
|
<img src={selec} /> |
|
|
render: (text, record, index) => record.describe || '--' |
|
|
|
|
|
}, { |
|
|
<div style={{ display: 'flex', marginBottom: 10 }}> |
|
|
title: '操作', |
|
|
<Button type="primary" onClick={() => { |
|
|
dataIndex: 'operation', |
|
|
setAddModel(true) |
|
|
key: 'operation', |
|
|
}}>新建点位</Button> |
|
|
render: (text, record, index) => { |
|
|
<Button type="primary" style={{ marginLeft: 20 }} onClick={() => { |
|
|
return ( |
|
|
select?.map(v => { |
|
|
<div style={{ width: 224 }}> |
|
|
let url = createQrCode('FS' + Date.now() + v.id) |
|
|
<Button type="link" onClick={() => { |
|
|
|
|
|
setAddModel(true) |
|
|
|
|
|
setModelData(record) |
|
|
|
|
|
console.log(record); |
|
|
|
|
|
}} |
|
|
|
|
|
|
|
|
|
|
|
>编辑</Button> |
|
|
|
|
|
<Popconfirm |
|
|
|
|
|
title={<div style={{ width: 184 }}>删除该点位后,与巡检计划关联的点位删除,对应的巡检记录删除,是否确认删除?</div>} |
|
|
|
|
|
position='topLeft' |
|
|
|
|
|
onConfirm={() => { |
|
|
|
|
|
dispatch(projectRegime.delPosition(record.id)).then(res => { |
|
|
|
|
|
if (res.success) { |
|
|
|
|
|
if ((limits > 11 && tableList.length > 1) || limits < 11) { |
|
|
|
|
|
projectList({ ...query, ...search }) |
|
|
|
|
|
} else { |
|
|
|
|
|
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); |
|
|
console.log(url); |
|
|
dispatch(projectRegime.addPosition({ |
|
|
dispatch(projectRegime.addPosition({ |
|
|
qrCode: url, |
|
|
qrCode: url, |
|
|
id: v.id, |
|
|
id: record.id, |
|
|
}, true)) |
|
|
}, true)) |
|
|
}) |
|
|
}} >二维码生成</Button> |
|
|
}}>一键生成二维码</Button> |
|
|
</div> |
|
|
</div> |
|
|
) |
|
|
|
|
|
} |
|
|
<Table |
|
|
} |
|
|
columns={columns} |
|
|
] |
|
|
dataSource={tableList} |
|
|
|
|
|
pagination={{ |
|
|
return ( |
|
|
current: query.page + 1, |
|
|
<> |
|
|
total: limits, |
|
|
<img src={selec} /> |
|
|
showSizeChanger: true, |
|
|
|
|
|
showQuickJumper: true, |
|
|
<div style={{ display: 'flex', marginBottom: 10 }}> |
|
|
pageSizeOptions: [10, 20, 50], |
|
|
<Button type="primary" onClick={() => { |
|
|
showTotal: (total) => { |
|
|
setAddModel(true) |
|
|
return <span style={{ fontSize: 15 }}>{`共${Math.ceil(total / query?.limit)}页,${total}项`}</span> |
|
|
}}>新建点位</Button> |
|
|
}, |
|
|
<Button type="primary" style={{ marginLeft: 20 }} onClick={() => { |
|
|
onChange: (page, pageSize) => { |
|
|
select?.map(v => { |
|
|
setQuery({ limit: pageSize, page: page - 1 }); |
|
|
let url = createQrCode('FS' + Date.now() + v.id) |
|
|
projectList({ limit: pageSize, page: page - 1, ...search, companyId: companyID || search?.companyId }) |
|
|
console.log(url); |
|
|
} |
|
|
dispatch(projectRegime.addPosition({ |
|
|
}} |
|
|
qrCode: url, |
|
|
rowSelection={{ |
|
|
id: v.id, |
|
|
selectedRowKeys: select?.map(v => v.id) || [], |
|
|
}, true)) |
|
|
onChange: (selectedRowKeys, selectedRows) => { |
|
|
}) |
|
|
setSelect(selectedRows) |
|
|
}}>一键生成二维码</Button> |
|
|
console.log(selectedRows); |
|
|
</div> |
|
|
} |
|
|
|
|
|
}} |
|
|
<Table |
|
|
/> |
|
|
columns={columns} |
|
|
{ |
|
|
dataSource={tableList} |
|
|
addModel ? |
|
|
pagination={{ |
|
|
<PointModel |
|
|
current: query.page + 1, |
|
|
modelData={modelData} |
|
|
total: limits, |
|
|
qrCodeId={qrCodeId} |
|
|
showSizeChanger: true, |
|
|
close={() => { |
|
|
showQuickJumper: true, |
|
|
setAddModel(false) |
|
|
pageSizeOptions: [10, 20, 50], |
|
|
setModelData({}) |
|
|
showTotal: (total) => { |
|
|
}} |
|
|
return <span style={{ fontSize: 15 }}>{`共${Math.ceil(total / query?.limit)}页,${total}项`}</span> |
|
|
success={() => { |
|
|
}, |
|
|
setAddModel(false) |
|
|
onChange: (page, pageSize) => { |
|
|
setModelData({}) |
|
|
setQuery({ limit: pageSize, page: page - 1 }); |
|
|
setQuery({ limit: 10, page: 0 }); |
|
|
projectList({ limit: pageSize, page: page - 1, ...search, companyId: companyID || search?.companyId }) |
|
|
projectList({ limit: 10, page: 0 }) |
|
|
} |
|
|
}} |
|
|
}} |
|
|
/> : "" |
|
|
rowSelection={{ |
|
|
} |
|
|
selectedRowKeys: select?.map(v => v.id) || [], |
|
|
</> |
|
|
onChange: (selectedRowKeys, selectedRows) => { |
|
|
) |
|
|
setSelect(selectedRows) |
|
|
|
|
|
console.log(selectedRows); |
|
|
|
|
|
} |
|
|
|
|
|
}} |
|
|
|
|
|
/> |
|
|
|
|
|
{ |
|
|
|
|
|
addModel ? |
|
|
|
|
|
<PointModel |
|
|
|
|
|
modelData={modelData} |
|
|
|
|
|
qrCodeId={qrCodeId} |
|
|
|
|
|
close={() => { |
|
|
|
|
|
setAddModel(false) |
|
|
|
|
|
setModelData({}) |
|
|
|
|
|
}} |
|
|
|
|
|
success={() => { |
|
|
|
|
|
setAddModel(false) |
|
|
|
|
|
setModelData({}) |
|
|
|
|
|
setQuery({ limit: 10, page: 0 }); |
|
|
|
|
|
projectList({ limit: 10, page: 0 }) |
|
|
|
|
|
}} |
|
|
|
|
|
/> : "" |
|
|
|
|
|
} |
|
|
|
|
|
</> |
|
|
|
|
|
) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
function mapStateToProps (state) { |
|
|
function mapStateToProps (state) { |
|
|