工单布局修改
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
import React, { useState, useRef } from 'react';
|
||||
import {
|
||||
Form, Select, Input, Button, Space, message, Card, Typography,
|
||||
Row, Col, Modal
|
||||
Form, Select, Button, Space, message, Card, Typography,
|
||||
Row, Col, Modal, Input
|
||||
} from 'antd';
|
||||
import QRCode from 'qrcode';
|
||||
import axios from 'axios';
|
||||
import DictManager from "../DictManager"
|
||||
import DictManager from "../DictManager";
|
||||
|
||||
const { Text } = Typography;
|
||||
|
||||
@@ -51,9 +51,12 @@ const SerialNumGenerate = () => {
|
||||
const [loading, setLoading] = useState(false);
|
||||
const qrRef = useRef(null);
|
||||
|
||||
// 查询相关状态
|
||||
const [queryCode, setQueryCode] = useState('');
|
||||
const [queryLoading, setQueryLoading] = useState(false);
|
||||
|
||||
const [manageVisible, setManageVisible] = useState(false);
|
||||
|
||||
// 全部解构出来
|
||||
const {
|
||||
types,
|
||||
models,
|
||||
@@ -69,9 +72,7 @@ const SerialNumGenerate = () => {
|
||||
return `${num}-${check}`;
|
||||
};
|
||||
|
||||
// ==============================================
|
||||
// 【最终版】生成序列号 + JSON二维码
|
||||
// ==============================================
|
||||
// 生成序列号 + JSON二维码
|
||||
const generateQRCode = async () => {
|
||||
try {
|
||||
const values = await form.validateFields();
|
||||
@@ -139,6 +140,27 @@ const SerialNumGenerate = () => {
|
||||
}
|
||||
};
|
||||
|
||||
// 查询二维码
|
||||
const handleQueryQRCode = async () => {
|
||||
if (!queryCode) return message.warning('请输入序列号');
|
||||
setQueryLoading(true);
|
||||
try {
|
||||
const res = await axios.get('/api/query-qrcode', { params: { sn: queryCode } });
|
||||
if (res.data?.qrUrl) {
|
||||
setQrUrl(res.data.qrUrl);
|
||||
setQrJson(res.data.qrJson || '');
|
||||
setSerialNumber(res.data.serialNumber || '');
|
||||
message.success('查询成功');
|
||||
} else {
|
||||
message.warning('未找到该序列号');
|
||||
}
|
||||
} catch {
|
||||
message.error('查询失败');
|
||||
} finally {
|
||||
setQueryLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<div style={{ padding: '0 20px', minHeight: '100vh' }}>
|
||||
<Card
|
||||
@@ -186,6 +208,25 @@ const SerialNumGenerate = () => {
|
||||
</Button>
|
||||
</Form.Item>
|
||||
</Form>
|
||||
|
||||
{/* 查询模块(已加回) */}
|
||||
<Card size="small" title="查询历史二维码" style={{ marginTop: 20 }}>
|
||||
<Space style={{ width: '100%' }}>
|
||||
<Input
|
||||
value={queryCode}
|
||||
onChange={(e) => setQueryCode(e.target.value)}
|
||||
placeholder="输入序列号查询"
|
||||
style={
|
||||
{
|
||||
width: '300px'
|
||||
}
|
||||
}
|
||||
/>
|
||||
<Button type="primary" loading={queryLoading} onClick={handleQueryQRCode}>
|
||||
查询
|
||||
</Button>
|
||||
</Space>
|
||||
</Card>
|
||||
</Col>
|
||||
|
||||
{/* 右侧二维码 */}
|
||||
@@ -213,7 +254,7 @@ const SerialNumGenerate = () => {
|
||||
|
||||
<Space style={{ marginTop: 24 }}>
|
||||
<Button onClick={downloadQRCode}>下载二维码</Button>
|
||||
<Button type="primary" loading={loading} onClick={saveToDatabase}>保存到数据库</Button>
|
||||
<Button type="primary" loading={loading} onClick={saveToDatabase}>保存</Button>
|
||||
</Space>
|
||||
</div>
|
||||
</Col>
|
||||
@@ -232,6 +273,7 @@ const SerialNumGenerate = () => {
|
||||
<DictManager title="机器人型号" data={models} onAdd={() => { }} onUpdate={() => { }} onDelete={() => { }} />
|
||||
<DictManager title="配置" data={configs} onAdd={() => { }} onUpdate={() => { }} onDelete={() => { }} />
|
||||
<DictManager title="国家" data={countries} onAdd={() => { }} onUpdate={() => { }} onDelete={() => { }} />
|
||||
<DictManager title="省份" data={provinces} onAdd={() => { }} onUpdate={() => { }} onDelete={() => { }} />
|
||||
</Modal>
|
||||
</div>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user