|
@@ -0,0 +1,87 @@
|
|
|
+import React, { useCallback, useState } from "react";
|
|
|
+import styles from "./index.module.scss";
|
|
|
+import { Button, Input, Modal, Popconfirm } from "antd";
|
|
|
+import { B2_APIcheckNum, B2_APIeditNum } from "@/store/action/B2Scene";
|
|
|
+import { MessageFu } from "@/utils/message";
|
|
|
+
|
|
|
+type Props = {
|
|
|
+ info: { id: number; num: string; name: string };
|
|
|
+ closeFu: () => void;
|
|
|
+ upTableFu: () => void;
|
|
|
+};
|
|
|
+
|
|
|
+function EditNum({ info, closeFu, upTableFu }: Props) {
|
|
|
+ const [value, setValue] = useState("");
|
|
|
+
|
|
|
+ const btnOkFu = useCallback(async () => {
|
|
|
+ if (value === info.num) return MessageFu.warning("新旧编码不能相同!");
|
|
|
+
|
|
|
+ const res1 = await B2_APIcheckNum(value);
|
|
|
+ if (res1.code === 0) {
|
|
|
+ if (res1.data) {
|
|
|
+ // 编码存在
|
|
|
+ const res2 = await B2_APIeditNum(info.id, value);
|
|
|
+ if (res2.code === 0) {
|
|
|
+ MessageFu.success("更新成功!");
|
|
|
+ upTableFu();
|
|
|
+ closeFu();
|
|
|
+ }
|
|
|
+ } else MessageFu.warning("该机房编码不存在,请先在机房管理中创建!");
|
|
|
+ }
|
|
|
+ }, [closeFu, info.id, info.num, upTableFu, value]);
|
|
|
+
|
|
|
+ return (
|
|
|
+ <Modal
|
|
|
+ wrapClassName={styles.EditNum}
|
|
|
+ open={true}
|
|
|
+ title="修改机房编码"
|
|
|
+ footer={
|
|
|
+ [] // 设置footer为空,去掉 取消 确定默认按钮
|
|
|
+ }
|
|
|
+ >
|
|
|
+ <div className="B2Emain">
|
|
|
+ <div className="B2Ebox1">
|
|
|
+ <div>机房编码:</div>
|
|
|
+ <div>{info.num}</div>
|
|
|
+ </div>
|
|
|
+ <div className="B2Ebox1">
|
|
|
+ <div>场景名称:</div>
|
|
|
+ <div>{info.name}</div>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div className="B2Ebox1">
|
|
|
+ <div>新机房编码:</div>
|
|
|
+ <div>
|
|
|
+ <Input
|
|
|
+ placeholder="请输入24位纯数字"
|
|
|
+ maxLength={24}
|
|
|
+ style={{ width: 300 }}
|
|
|
+ value={value}
|
|
|
+ onChange={(e) => setValue(e.target.value.replace(/[^\d]/g, ""))}
|
|
|
+ />
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div className="B2Ebtn">
|
|
|
+ <Button type="primary" onClick={btnOkFu} disabled={value.length < 24}>
|
|
|
+ 提交
|
|
|
+ </Button>
|
|
|
+  
|
|
|
+ <Popconfirm
|
|
|
+ title="放弃编辑后,信息将不会保存!"
|
|
|
+ okText="放弃"
|
|
|
+ cancelText="取消"
|
|
|
+ onConfirm={closeFu}
|
|
|
+ okButtonProps={{ loading: false }}
|
|
|
+ >
|
|
|
+ <Button>取消</Button>
|
|
|
+ </Popconfirm>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </Modal>
|
|
|
+ );
|
|
|
+}
|
|
|
+
|
|
|
+const MemoEditNum = React.memo(EditNum);
|
|
|
+
|
|
|
+export default MemoEditNum;
|