|
@@ -1,8 +1,20 @@
|
|
|
-import { Button, Form, Input, message, Modal } from "antd";
|
|
|
-import React, { useState } from "react";
|
|
|
+import {
|
|
|
+ Button,
|
|
|
+ Cascader,
|
|
|
+ Form,
|
|
|
+ Input,
|
|
|
+ InputNumber,
|
|
|
+ message,
|
|
|
+ Modal,
|
|
|
+ Select,
|
|
|
+} from "antd";
|
|
|
+import React, { useRef, useState } from "react";
|
|
|
import styles from "./index.module.scss";
|
|
|
import classNames from "classnames";
|
|
|
import "./index.css";
|
|
|
+import { useSelector } from "react-redux";
|
|
|
+import { RootState } from "@/store";
|
|
|
+const { Option } = Select;
|
|
|
|
|
|
type Props = {
|
|
|
id: any;
|
|
@@ -16,12 +28,65 @@ function ObjectAdd({ id, colsePage }: Props) {
|
|
|
};
|
|
|
// 通过校验之后发送请求
|
|
|
const onFinish = async (values: any) => {
|
|
|
+ console.log("具体质量的单位", danweiValue);
|
|
|
+
|
|
|
console.log("--点击确定存到仓库", values);
|
|
|
};
|
|
|
|
|
|
// 选择商品信息还是附近(默认商品信息)
|
|
|
const [titSelect, setTitSelect] = useState("tit1");
|
|
|
|
|
|
+ // 从仓库中获取各下拉数据
|
|
|
+ const options1 = useSelector(
|
|
|
+ (state: RootState) => state.loginStore.selectAll["藏品编号名称"]
|
|
|
+ );
|
|
|
+
|
|
|
+ const options2 = useSelector(
|
|
|
+ (state: RootState) => state.loginStore.selectAll["年代"]
|
|
|
+ );
|
|
|
+ const options3 = useSelector(
|
|
|
+ (state: RootState) => state.loginStore.selectAll["质地"]
|
|
|
+ );
|
|
|
+ const options4 = useSelector(
|
|
|
+ (state: RootState) => state.loginStore.selectAll["文物类别"]
|
|
|
+ );
|
|
|
+ const options5 = useSelector(
|
|
|
+ (state: RootState) => state.loginStore.selectAll["文物级别"]
|
|
|
+ );
|
|
|
+ const options6 = useSelector(
|
|
|
+ (state: RootState) => state.loginStore.selectAll["质量范围"]
|
|
|
+ );
|
|
|
+ const options7 = useSelector(
|
|
|
+ (state: RootState) => state.loginStore.selectAll["完残程度"]
|
|
|
+ );
|
|
|
+ const options8 = useSelector(
|
|
|
+ (state: RootState) => state.loginStore.selectAll["保存状态"]
|
|
|
+ );
|
|
|
+
|
|
|
+ // 单位选择
|
|
|
+ const [danweiValue, setDanweiValue] = useState("kg");
|
|
|
+
|
|
|
+ // 设置表单初始数据(区分编辑和新增)
|
|
|
+
|
|
|
+ const defaultData = useRef<any>(null);
|
|
|
+ if (id) {
|
|
|
+ defaultData.current = {
|
|
|
+ name1: "编辑",
|
|
|
+ name3: "索书号",
|
|
|
+ name5: ["其他"],
|
|
|
+ };
|
|
|
+ } else {
|
|
|
+ defaultData.current = {
|
|
|
+ name3: options1[0].name ? options1[0].name : null,
|
|
|
+ name5: ["地质年代", "显生宙", "新生代", "第四纪"],
|
|
|
+ name6: ["单一质地", "有机质", "竹"],
|
|
|
+ name8: options4[0].name ? options4[0].name : null,
|
|
|
+ name10: options5[0].name ? options5[0].name : null,
|
|
|
+ name15: options6[0].name ? options6[0].name : null,
|
|
|
+ name17: options7[0].name ? options7[0].name : null,
|
|
|
+ };
|
|
|
+ }
|
|
|
+
|
|
|
return (
|
|
|
<div className={styles.ObjectAdd}>
|
|
|
<Modal
|
|
@@ -54,21 +119,195 @@ function ObjectAdd({ id, colsePage }: Props) {
|
|
|
|
|
|
<Form
|
|
|
name="basic"
|
|
|
- labelCol={{ span: 5 }}
|
|
|
- wrapperCol={{ span: 16 }}
|
|
|
onFinish={onFinish}
|
|
|
onFinishFailed={onFinishFailed}
|
|
|
autoComplete="off"
|
|
|
+ initialValues={defaultData.current}
|
|
|
>
|
|
|
- <Form.Item
|
|
|
- label="旧密码"
|
|
|
- name="oldPassword"
|
|
|
- rules={[{ required: true, message: "不能为空!" }]}
|
|
|
- >
|
|
|
- <Input maxLength={15} />
|
|
|
- </Form.Item>
|
|
|
+ <div className="formRow">
|
|
|
+ <Form.Item
|
|
|
+ label="藏品名称"
|
|
|
+ name="name1"
|
|
|
+ rules={[{ required: true, message: "不能为空!" }]}
|
|
|
+ >
|
|
|
+ <Input maxLength={50} showCount placeholder="请输入" />
|
|
|
+ </Form.Item>
|
|
|
+ <Form.Item label="原名" name="name2">
|
|
|
+ <Input maxLength={50} showCount placeholder="请输入" />
|
|
|
+ </Form.Item>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div className="formRow">
|
|
|
+ <div className="bs">*</div>
|
|
|
+ <Form.Item label="藏品编号名称" name="name3">
|
|
|
+ <Select
|
|
|
+ placeholder="请选择"
|
|
|
+ options={options1.map((v: any) => ({
|
|
|
+ label: v.name,
|
|
|
+ value: v.name,
|
|
|
+ }))}
|
|
|
+ />
|
|
|
+ </Form.Item>
|
|
|
+ <Form.Item label="藏品编号" name="name4">
|
|
|
+ <Input maxLength={50} showCount placeholder="请输入" />
|
|
|
+ </Form.Item>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div className="formRow">
|
|
|
+ <div className="bs bs2">*</div>
|
|
|
+ <div className="bs bs3">*</div>
|
|
|
+ <Form.Item label="年代" name="name5">
|
|
|
+ <Cascader
|
|
|
+ allowClear={false}
|
|
|
+ fieldNames={{
|
|
|
+ label: "name",
|
|
|
+ value: "name",
|
|
|
+ children: "children",
|
|
|
+ }}
|
|
|
+ options={options2}
|
|
|
+ placeholder="请选择"
|
|
|
+ />
|
|
|
+ </Form.Item>
|
|
|
+ <Form.Item label="文物质地" name="name6">
|
|
|
+ <Cascader
|
|
|
+ allowClear={false}
|
|
|
+ fieldNames={{
|
|
|
+ label: "name",
|
|
|
+ value: "name",
|
|
|
+ children: "children",
|
|
|
+ }}
|
|
|
+ options={options3}
|
|
|
+ placeholder="请选择"
|
|
|
+ />
|
|
|
+ </Form.Item>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div className="formRow">
|
|
|
+ <div className="bs bs3">*</div>
|
|
|
+ <Form.Item label="具体年代" name="name7">
|
|
|
+ <Input maxLength={50} showCount placeholder="请输入" />
|
|
|
+ </Form.Item>
|
|
|
+ <Form.Item label="文物类别" name="name8">
|
|
|
+ <Select
|
|
|
+ placeholder="请选择"
|
|
|
+ options={options4.map((v: any) => ({
|
|
|
+ label: v.name,
|
|
|
+ value: v.name,
|
|
|
+ }))}
|
|
|
+ />
|
|
|
+ </Form.Item>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div className="formRow">
|
|
|
+ <div className="bs bs3">*</div>
|
|
|
+ <Form.Item
|
|
|
+ rules={[{ required: true, message: "不能为空!" }]}
|
|
|
+ label="实际数量"
|
|
|
+ name="name9"
|
|
|
+ >
|
|
|
+ <InputNumber maxLength={8} placeholder="请输入数字" />
|
|
|
+ </Form.Item>
|
|
|
+ <Form.Item label="文物级别" name="name10">
|
|
|
+ <Select
|
|
|
+ placeholder="请选择"
|
|
|
+ options={options5.map((v: any) => ({
|
|
|
+ label: v.name,
|
|
|
+ value: v.name,
|
|
|
+ }))}
|
|
|
+ />
|
|
|
+ </Form.Item>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div className="formRow formRowThree">
|
|
|
+ <Form.Item
|
|
|
+ rules={[{ required: true, message: "不能为空!" }]}
|
|
|
+ label="外形尺寸"
|
|
|
+ name="name11"
|
|
|
+ >
|
|
|
+ <InputNumber maxLength={8} placeholder="通长" addonAfter="cm" />
|
|
|
+ </Form.Item>
|
|
|
+ <Form.Item
|
|
|
+ rules={[{ required: true, message: "不能为空!" }]}
|
|
|
+ label=""
|
|
|
+ name="name12"
|
|
|
+ >
|
|
|
+ <InputNumber maxLength={8} placeholder="通宽" addonAfter="cm" />
|
|
|
+ </Form.Item>
|
|
|
+ <Form.Item
|
|
|
+ className="formRowThreeRow"
|
|
|
+ rules={[{ required: true, message: "不能为空!" }]}
|
|
|
+ label=""
|
|
|
+ name="name13"
|
|
|
+ >
|
|
|
+ <InputNumber maxLength={8} placeholder="通高" addonAfter="cm" />
|
|
|
+ </Form.Item>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div className="formRow formRowFull">
|
|
|
+ <Form.Item
|
|
|
+ label="具体尺寸"
|
|
|
+ name="name14"
|
|
|
+ rules={[{ required: true, message: "不能为空!" }]}
|
|
|
+ >
|
|
|
+ <Input maxLength={50} showCount placeholder="请输入" />
|
|
|
+ </Form.Item>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div className="formRow">
|
|
|
+ <div className="bs bs4">*</div>
|
|
|
+ <Form.Item label="质量范围" name="name15">
|
|
|
+ <Select
|
|
|
+ placeholder="请选择"
|
|
|
+ options={options6.map((v: any) => ({
|
|
|
+ label: v.name,
|
|
|
+ value: v.name,
|
|
|
+ }))}
|
|
|
+ />
|
|
|
+ </Form.Item>
|
|
|
+ <Form.Item className="formRowSelec" label="具体质量" name="name16">
|
|
|
+ <InputNumber
|
|
|
+ maxLength={8}
|
|
|
+ placeholder="请输入"
|
|
|
+ addonAfter={
|
|
|
+ <Select
|
|
|
+ value={danweiValue}
|
|
|
+ onChange={(val) => setDanweiValue(val)}
|
|
|
+ >
|
|
|
+ <Option value="kg">kg</Option>
|
|
|
+ <Option value="g">g</Option>
|
|
|
+ </Select>
|
|
|
+ }
|
|
|
+ />
|
|
|
+ {/* <div className="formRowSelecSon">
|
|
|
+
|
|
|
+ </div> */}
|
|
|
+ </Form.Item>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div className="formRow">
|
|
|
+ <div className="bs bs4">*</div>
|
|
|
+ <Form.Item label="完残程度" name="name17">
|
|
|
+ <Select
|
|
|
+ placeholder="请选择"
|
|
|
+ options={options7.map((v: any) => ({
|
|
|
+ label: v.name,
|
|
|
+ value: v.name,
|
|
|
+ }))}
|
|
|
+ />
|
|
|
+ </Form.Item>
|
|
|
+ <Form.Item label="保存状态" name="name18">
|
|
|
+ <Select
|
|
|
+ placeholder="请选择"
|
|
|
+ options={options8.map((v: any) => ({
|
|
|
+ label: v.name,
|
|
|
+ value: v.name,
|
|
|
+ }))}
|
|
|
+ />
|
|
|
+ </Form.Item>
|
|
|
+ </div>
|
|
|
|
|
|
- <Form.Item wrapperCol={{ offset: 14, span: 16 }}>
|
|
|
+ <br />
|
|
|
+ <Form.Item wrapperCol={{ offset: 20 }}>
|
|
|
<Button onClick={colsePage}>取消</Button>
|
|
|
 
|
|
|
<Button type="primary" htmlType="submit">
|