Commit 6391bed5 authored by 彭俊龙's avatar 彭俊龙

设备巡检二维码设计支持批量操作

parent 6b7fd8e8
Pipeline #94816 failed with stages
import React, { useState, useImperativeHandle, forwardRef, useMemo, useEffect } from 'react' import React, { useState, useImperativeHandle, forwardRef, useMemo, useEffect, useRef } from 'react'
import { Modal, Form, Input, Table, Button, Switch, Upload, Radio, Checkbox, message, Tag, Spin, Select } from 'antd' import { Modal, Form, Input, Table, Button, Switch, Upload, Radio, Checkbox, message, Tag, Spin, Select } from 'antd'
import { UploadOutlined, FileOutline, ArrowDownOutlined } from '@ant-design/icons' import { UploadOutlined, FileOutline, ArrowDownOutlined } from '@ant-design/icons'
import styles from './index.less' import styles from './index.less'
import QRCode from 'qrcode.react' import QRCode from 'qrcode.react'
import { GetDeviceQRCodeConfig, EditOrAddDeviceQRCodeConfig } from '@/services/flow/flow' import { GetDeviceQRCodeConfig, EditOrAddDeviceQRCodeConfig, BatchEditDeviceQRCodeConfig } from '@/services/flow/flow'
import html2canvas from 'html2canvas' import html2canvas from 'html2canvas'
import JSZip from 'jszip' import JSZip from 'jszip'
import { saveAs } from 'file-saver' import { saveAs } from 'file-saver'
...@@ -137,10 +137,12 @@ const QRCodeViewSuzhou = props => { ...@@ -137,10 +137,12 @@ const QRCodeViewSuzhou = props => {
const QRCodeDesign = (props, ref) => { const QRCodeDesign = (props, ref) => {
useImperativeHandle(ref, () => ({ useImperativeHandle(ref, () => ({
open open,
batchEditOpen
})) }))
const [record, setRecord] = useState({}) const [record, setRecord] = useState({})
const [isBatchEdit, setBatchEdit] = useState(false);
const [visible, setVisible] = useState(false) const [visible, setVisible] = useState(false)
const [show, setShow] = useState(false) const [show, setShow] = useState(false)
const [loading, setLoading] = useState(false) const [loading, setLoading] = useState(false)
...@@ -153,7 +155,7 @@ const QRCodeDesign = (props, ref) => { ...@@ -153,7 +155,7 @@ const QRCodeDesign = (props, ref) => {
const [minVisible, setMinVisible] = useState(false) const [minVisible, setMinVisible] = useState(false)
const [active, setActive] = useState('') const [active, setActive] = useState('')
const [form] = Form.useForm() const [form] = Form.useForm()
let accountNames = useRef([]);
const columns = useMemo(() => { const columns = useMemo(() => {
return [ return [
{ {
...@@ -393,9 +395,29 @@ const QRCodeDesign = (props, ref) => { ...@@ -393,9 +395,29 @@ const QRCodeDesign = (props, ref) => {
setRecord(record) setRecord(record)
setShow(false) setShow(false)
setVisible(true) setVisible(true)
setBatchEdit(false);
getDataSource(record) getDataSource(record)
} }
const batchEditOpen = (keys)=>{
console.log(keys, '批量选中台账名')
if(!keys || keys.length == 0){
message.warn('请选择需要批量设计的数据');
return;
}
if(values){
let vals = values;
Object.keys(vals).forEach(k=> vals[k] = '')
form?.setFieldsValue(vals)
setValues(vals)
}
setShowList([]);
accountNames.current = keys;
setShow(true);
setVisible(true);
setBatchEdit(true);
}
const onValuesChange = (values) => { const onValuesChange = (values) => {
form.setFieldsValue(values) form.setFieldsValue(values)
setValues(form.getFieldsValue(true)) setValues(form.getFieldsValue(true))
...@@ -438,6 +460,28 @@ const QRCodeDesign = (props, ref) => { ...@@ -438,6 +460,28 @@ const QRCodeDesign = (props, ref) => {
}) })
} }
const batchSave = async ()=>{
let params = {
AccountNamelist: accountNames.current,
DeviceQRCodeConfig: {
corporateName: values.CorporateName,
title: values.Title,
labelLogoUrl: values.LabelLogoUrl,
isSystemLogo: values.IsSystemLogo === '系统LOGO' ? 1 : 0,
isPandaLogo: values.IsPandaLogo ? 1 : 0,
Template: values.Template || 'default'
}
}
const { code, data } = await BatchEditDeviceQRCodeConfig(params)
if (code === 0) {
message.success('保存成功!')
setShow(false)
setVisible(false)
} else {
message.error('保存失败!')
}
}
const save = async () => { const save = async () => {
let params = { let params = {
ID: parentQRCode.ID, ID: parentQRCode.ID,
...@@ -472,8 +516,8 @@ const QRCodeDesign = (props, ref) => { ...@@ -472,8 +516,8 @@ const QRCodeDesign = (props, ref) => {
</> </>
) : ( ) : (
<> <>
<Button onClick={() => setShow(false)}>返回</Button> {!isBatchEdit && <Button onClick={() => setShow(false)}>返回</Button>}
<Button type='primary' onClick={() => save()}>保存</Button> <Button type='primary' onClick={() => !isBatchEdit ? save() : batchSave()}>保存</Button>
</> </>
) )
} }
...@@ -481,7 +525,8 @@ const QRCodeDesign = (props, ref) => { ...@@ -481,7 +525,8 @@ const QRCodeDesign = (props, ref) => {
) )
return ( return (
<Modal <>{visible &&
<Modal
wrapClassName={styles.QRCodeModal} wrapClassName={styles.QRCodeModal}
visible={visible} visible={visible}
onCancel={() => setVisible(false)} onCancel={() => setVisible(false)}
...@@ -668,6 +713,8 @@ const QRCodeDesign = (props, ref) => { ...@@ -668,6 +713,8 @@ const QRCodeDesign = (props, ref) => {
} }
</div> </div>
</Modal> </Modal>
}</>
) )
} }
......
...@@ -20,6 +20,7 @@ import { ...@@ -20,6 +20,7 @@ import {
PlusOutlined, PlusOutlined,
OrderedListOutlined, OrderedListOutlined,
ApartmentOutlined, ApartmentOutlined,
SettingOutlined
} from '@ant-design/icons'; } from '@ant-design/icons';
import styles from './maintenance.less'; import styles from './maintenance.less';
import AddModal from './AddModal'; import AddModal from './AddModal';
...@@ -36,6 +37,7 @@ const maintenance = () => { ...@@ -36,6 +37,7 @@ const maintenance = () => {
const [addVisible, setAddVisible] = useState(false); const [addVisible, setAddVisible] = useState(false);
const [addVisibleNew, setAddVisibleNew] = useState(false); const [addVisibleNew, setAddVisibleNew] = useState(false);
const [optionVisible, setOptionVisible] = useState(false); const [optionVisible, setOptionVisible] = useState(false);
const [selectedRowKeys, setSelectedRowKeys] = useState([]);
const [type, setType] = useState(''); const [type, setType] = useState('');
const [formObj, setFormObj] = useState(''); const [formObj, setFormObj] = useState('');
const [treeLoading, setTreeLoading] = useState(false); const [treeLoading, setTreeLoading] = useState(false);
...@@ -736,7 +738,7 @@ const maintenance = () => { ...@@ -736,7 +738,7 @@ const maintenance = () => {
{/* <EditTwoTone onClick={() => editOption(record)} style={{ fontSize: '16px' }} /> */} {/* <EditTwoTone onClick={() => editOption(record)} style={{ fontSize: '16px' }} /> */}
</Tooltip> </Tooltip>
<Tooltip title="二维码设计"> <Tooltip title="二维码设计">
<Button type='link' onClick={() => editQrCode(record)}>二维码设计</Button> <Button type='link' onClick={() => editQrCode(record)}>二维码设计111</Button>
{/* <EditTwoTone onClick={() => editQrCode(record)} style={{ fontSize: '16px' }} /> */} {/* <EditTwoTone onClick={() => editQrCode(record)} style={{ fontSize: '16px' }} /> */}
</Tooltip> </Tooltip>
</Space> </Space>
...@@ -755,6 +757,11 @@ const maintenance = () => { ...@@ -755,6 +757,11 @@ const maintenance = () => {
setType('add'); setType('add');
}; };
const batchEditQRCode= ()=>{
QRCodeDesignRef.current.batchEditOpen(selectedRowKeys)
}
const editEventType = record => { const editEventType = record => {
if (activeName === 'project') { if (activeName === 'project') {
setAddVisibleNew(true); setAddVisibleNew(true);
...@@ -922,6 +929,27 @@ const maintenance = () => { ...@@ -922,6 +929,27 @@ const maintenance = () => {
维保模板 维保模板
</div> */} </div> */}
</div> </div>
<span
style={{
float: 'right',
marginRight: '10px',
display: activeName === 'configuration' ? 'block' : 'none',
}}
>
<Button
icon={<SettingOutlined className={styles.icon}/>}
onClick={batchEditQRCode}
type="primary"
style={{
verticalAlign: 'middle',
marginTop: '10px',
marginRight: '20px',
}}
>
<span style={{ marginTop: '-2px' }}>批量二维码设计</span>
</Button>
</span>
<span <span
style={{ style={{
float: 'right', float: 'right',
...@@ -980,7 +1008,7 @@ const maintenance = () => { ...@@ -980,7 +1008,7 @@ const maintenance = () => {
) : ( ) : (
<Table <Table
size="small" size="small"
rowKey="ID" rowKey={record=> record.AccountName}
bordered bordered
loading={treeLoading} loading={treeLoading}
onRow={record => ({ onRow={record => ({
...@@ -993,6 +1021,13 @@ const maintenance = () => { ...@@ -993,6 +1021,13 @@ const maintenance = () => {
} }
}, // 双击 }, // 双击
})} })}
rowSelection={{
selectedRowKeys,
onChange: (RowKeys, selectedRows) => {
setSelectedRowKeys(RowKeys);
console.log(`selectedRowKeys: ${RowKeys}`, 'selectedRows: ', selectedRows);
},
}}
columns={columns} columns={columns}
dataSource={filterTableData} dataSource={filterTableData}
scroll={{ y: 'calc(100vh - 215px)', x: 'max-content' }} scroll={{ y: 'calc(100vh - 215px)', x: 'max-content' }}
......
...@@ -114,6 +114,9 @@ export const GetDeviceQRCodeConfig = (param) => get(`${PUBLISH_SERVICE}/WorkOrde ...@@ -114,6 +114,9 @@ export const GetDeviceQRCodeConfig = (param) => get(`${PUBLISH_SERVICE}/WorkOrde
//新增或修改维保二维码配置 //新增或修改维保二维码配置
export const EditOrAddDeviceQRCodeConfig = query => post(`${PUBLISH_SERVICE}/WorkOrderCenter/EditOrAddDeviceQRCodeConfig`, query); export const EditOrAddDeviceQRCodeConfig = query => post(`${PUBLISH_SERVICE}/WorkOrderCenter/EditOrAddDeviceQRCodeConfig`, query);
//新增或修改维保二维码配置
export const BatchEditDeviceQRCodeConfig = query => post(`${PUBLISH_SERVICE}/WorkOrderCenter/BatchEditDeviceQRCodeConfig`, query);
//修改流程节点顺序 //修改流程节点顺序
export const UpdateFlowNodeOrder = query => get(`${PUBLISH_SERVICE}/WorkOrderCenter/UpdateFlowNodeOrder`, query); export const UpdateFlowNodeOrder = query => get(`${PUBLISH_SERVICE}/WorkOrderCenter/UpdateFlowNodeOrder`, query);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment