|
@@ -1,12 +1,13 @@
|
|
|
import { weaponApi } from "@/api";
|
|
|
+import { FormPageFooter, MemoSpinLoding } from "@/components";
|
|
|
import {
|
|
|
DageFileCheckbox,
|
|
|
DageFileCheckboxMethods,
|
|
|
DageFileResponseType,
|
|
|
DageUpload,
|
|
|
- FormPageFooter,
|
|
|
- MemoSpinLoding,
|
|
|
-} from "@/components";
|
|
|
+ DageUploadConsumer,
|
|
|
+ DageUploadProvider,
|
|
|
+} from "@dage/web-components";
|
|
|
import { HistoryDictItem } from "@/types";
|
|
|
import { Form, FormInstance, Input, Select } from "antd";
|
|
|
import { useCallback, useEffect, useRef, useState } from "react";
|
|
@@ -20,7 +21,6 @@ export default function HistoryCreateOrEdit() {
|
|
|
const formRef = useRef<FormInstance>(null);
|
|
|
const dageFileCheckboxRef = useRef<DageFileCheckboxMethods>(null);
|
|
|
const [loading, setLoading] = useState(false);
|
|
|
- const [btnDisabled, setBtnDisabled] = useState(false);
|
|
|
const [dictList, setDictList] = useState<HistoryDictItem[]>([]);
|
|
|
const [fileList, setFileList] = useState<DageFileResponseType[]>([]);
|
|
|
|
|
@@ -85,7 +85,7 @@ export default function HistoryCreateOrEdit() {
|
|
|
.map((i: any) => (!!i.response ? i.response.data.filePath : i.uid))
|
|
|
.join(),
|
|
|
fileIds: fileList
|
|
|
- .map((i) => (!!i.response ? i.response.data.id : i.uid))
|
|
|
+ .map((i) => (!!i.response ? i.response.id : i.uid))
|
|
|
.join(),
|
|
|
});
|
|
|
|
|
@@ -107,148 +107,154 @@ export default function HistoryCreateOrEdit() {
|
|
|
return (
|
|
|
<div style={{ position: "relative" }}>
|
|
|
{loading && <MemoSpinLoding />}
|
|
|
- <Form ref={formRef} labelCol={{ span: 3 }}>
|
|
|
- <Form.Item
|
|
|
- label="名称"
|
|
|
- name="name"
|
|
|
- rules={[{ required: true, message: "请输入" }]}
|
|
|
- >
|
|
|
- <Input
|
|
|
- className="w450"
|
|
|
- placeholder="请输入内容"
|
|
|
- maxLength={20}
|
|
|
- showCount
|
|
|
- readOnly={readonly.current}
|
|
|
- />
|
|
|
- </Form.Item>
|
|
|
- <Form.Item
|
|
|
- label="所属阶段"
|
|
|
- name="stage"
|
|
|
- rules={[{ required: true, message: "请选择" }]}
|
|
|
- >
|
|
|
- <Select
|
|
|
- style={{ width: 200 }}
|
|
|
- placeholder="请选择"
|
|
|
- options={dictList.map((i) => ({
|
|
|
- value: i.name,
|
|
|
- label: i.name,
|
|
|
- }))}
|
|
|
- disabled={readonly.current}
|
|
|
- />
|
|
|
- </Form.Item>
|
|
|
- <Form.Item label="行业" name="vocation">
|
|
|
- <Input
|
|
|
- className="w450"
|
|
|
- placeholder="请输入内容"
|
|
|
- maxLength={30}
|
|
|
- showCount
|
|
|
- readOnly={readonly.current}
|
|
|
- />
|
|
|
- </Form.Item>
|
|
|
- <Form.Item label="类型" name="type">
|
|
|
- <Input
|
|
|
- className="w450"
|
|
|
- placeholder="请输入内容"
|
|
|
- maxLength={30}
|
|
|
- showCount
|
|
|
- readOnly={readonly.current}
|
|
|
- />
|
|
|
- </Form.Item>
|
|
|
- <Form.Item label="生产厂家" name="company">
|
|
|
- <Input
|
|
|
- className="w450"
|
|
|
- placeholder="请输入内容"
|
|
|
- maxLength={30}
|
|
|
- showCount
|
|
|
- readOnly={readonly.current}
|
|
|
- />
|
|
|
- </Form.Item>
|
|
|
- <Form.Item label="年份" name="year">
|
|
|
- <Input
|
|
|
- className="w450"
|
|
|
- placeholder="请输入内容"
|
|
|
- maxLength={30}
|
|
|
- showCount
|
|
|
- readOnly={readonly.current}
|
|
|
- />
|
|
|
- </Form.Item>
|
|
|
- <Form.Item label="尺寸" name="size">
|
|
|
- <Input
|
|
|
- className="w450"
|
|
|
- placeholder="请输入内容"
|
|
|
- maxLength={30}
|
|
|
- showCount
|
|
|
- readOnly={readonly.current}
|
|
|
- />
|
|
|
- </Form.Item>
|
|
|
- <Form.Item label="重量" name="weight">
|
|
|
- <Input
|
|
|
- className="w450"
|
|
|
- placeholder="请输入内容"
|
|
|
- maxLength={30}
|
|
|
- showCount
|
|
|
- readOnly={readonly.current}
|
|
|
- />
|
|
|
- </Form.Item>
|
|
|
- <Form.Item label="简介" name="description">
|
|
|
- <Input.TextArea
|
|
|
- className="w450"
|
|
|
- placeholder="请输入内容"
|
|
|
- maxLength={200}
|
|
|
- rows={8}
|
|
|
- showCount
|
|
|
- readOnly={readonly.current}
|
|
|
- />
|
|
|
- </Form.Item>
|
|
|
- <Form.Item label="选送理由" name="reason">
|
|
|
- <Input.TextArea
|
|
|
- className="w450"
|
|
|
- placeholder="请输入内容"
|
|
|
- maxLength={200}
|
|
|
- rows={4}
|
|
|
- showCount
|
|
|
- readOnly={readonly.current}
|
|
|
- />
|
|
|
- </Form.Item>
|
|
|
- <Form.Item
|
|
|
- label="封面图"
|
|
|
- name="thumb"
|
|
|
- rules={[{ required: true, message: "请输入" }]}
|
|
|
- >
|
|
|
- <DageUpload
|
|
|
- maxCount={1}
|
|
|
- disabled={readonly.current}
|
|
|
- tips="支持png、jpg和jpeg格式;最大20M,最多1张"
|
|
|
- action="/api/cms/goods/upload"
|
|
|
- onUploading={() => setBtnDisabled(true)}
|
|
|
- onUploaded={() => setBtnDisabled(false)}
|
|
|
- />
|
|
|
- </Form.Item>
|
|
|
- <Form.Item
|
|
|
- label="文件类型"
|
|
|
- name="fileTypes"
|
|
|
- rules={[
|
|
|
- { required: true, message: "请选择" },
|
|
|
- { validator: dageFileCheckboxRef.current?.validate! },
|
|
|
- ]}
|
|
|
- >
|
|
|
- <DageFileCheckbox
|
|
|
- ref={dageFileCheckboxRef}
|
|
|
- disabled={readonly.current}
|
|
|
- action="/api/cms/goods/upload"
|
|
|
- onFileChange={handleFileChange}
|
|
|
- />
|
|
|
- </Form.Item>
|
|
|
- </Form>
|
|
|
+ <DageUploadProvider>
|
|
|
+ <DageUploadConsumer>
|
|
|
+ {(data) => (
|
|
|
+ <>
|
|
|
+ <Form ref={formRef} labelCol={{ span: 3 }}>
|
|
|
+ <Form.Item
|
|
|
+ label="名称"
|
|
|
+ name="name"
|
|
|
+ rules={[{ required: true, message: "请输入" }]}
|
|
|
+ >
|
|
|
+ <Input
|
|
|
+ className="w450"
|
|
|
+ placeholder="请输入内容"
|
|
|
+ maxLength={20}
|
|
|
+ showCount
|
|
|
+ readOnly={readonly.current}
|
|
|
+ />
|
|
|
+ </Form.Item>
|
|
|
+ <Form.Item
|
|
|
+ label="所属阶段"
|
|
|
+ name="stage"
|
|
|
+ rules={[{ required: true, message: "请选择" }]}
|
|
|
+ >
|
|
|
+ <Select
|
|
|
+ style={{ width: 200 }}
|
|
|
+ placeholder="请选择"
|
|
|
+ options={dictList.map((i) => ({
|
|
|
+ value: i.name,
|
|
|
+ label: i.name,
|
|
|
+ }))}
|
|
|
+ disabled={readonly.current}
|
|
|
+ />
|
|
|
+ </Form.Item>
|
|
|
+ <Form.Item label="行业" name="vocation">
|
|
|
+ <Input
|
|
|
+ className="w450"
|
|
|
+ placeholder="请输入内容"
|
|
|
+ maxLength={30}
|
|
|
+ showCount
|
|
|
+ readOnly={readonly.current}
|
|
|
+ />
|
|
|
+ </Form.Item>
|
|
|
+ <Form.Item label="类型" name="type">
|
|
|
+ <Input
|
|
|
+ className="w450"
|
|
|
+ placeholder="请输入内容"
|
|
|
+ maxLength={30}
|
|
|
+ showCount
|
|
|
+ readOnly={readonly.current}
|
|
|
+ />
|
|
|
+ </Form.Item>
|
|
|
+ <Form.Item label="生产厂家" name="company">
|
|
|
+ <Input
|
|
|
+ className="w450"
|
|
|
+ placeholder="请输入内容"
|
|
|
+ maxLength={30}
|
|
|
+ showCount
|
|
|
+ readOnly={readonly.current}
|
|
|
+ />
|
|
|
+ </Form.Item>
|
|
|
+ <Form.Item label="年份" name="year">
|
|
|
+ <Input
|
|
|
+ className="w450"
|
|
|
+ placeholder="请输入内容"
|
|
|
+ maxLength={30}
|
|
|
+ showCount
|
|
|
+ readOnly={readonly.current}
|
|
|
+ />
|
|
|
+ </Form.Item>
|
|
|
+ <Form.Item label="尺寸" name="size">
|
|
|
+ <Input
|
|
|
+ className="w450"
|
|
|
+ placeholder="请输入内容"
|
|
|
+ maxLength={30}
|
|
|
+ showCount
|
|
|
+ readOnly={readonly.current}
|
|
|
+ />
|
|
|
+ </Form.Item>
|
|
|
+ <Form.Item label="重量" name="weight">
|
|
|
+ <Input
|
|
|
+ className="w450"
|
|
|
+ placeholder="请输入内容"
|
|
|
+ maxLength={30}
|
|
|
+ showCount
|
|
|
+ readOnly={readonly.current}
|
|
|
+ />
|
|
|
+ </Form.Item>
|
|
|
+ <Form.Item label="简介" name="description">
|
|
|
+ <Input.TextArea
|
|
|
+ className="w450"
|
|
|
+ placeholder="请输入内容"
|
|
|
+ maxLength={200}
|
|
|
+ rows={8}
|
|
|
+ showCount
|
|
|
+ readOnly={readonly.current}
|
|
|
+ />
|
|
|
+ </Form.Item>
|
|
|
+ <Form.Item label="选送理由" name="reason">
|
|
|
+ <Input.TextArea
|
|
|
+ className="w450"
|
|
|
+ placeholder="请输入内容"
|
|
|
+ maxLength={200}
|
|
|
+ rows={4}
|
|
|
+ showCount
|
|
|
+ readOnly={readonly.current}
|
|
|
+ />
|
|
|
+ </Form.Item>
|
|
|
+ <Form.Item
|
|
|
+ label="封面图"
|
|
|
+ name="thumb"
|
|
|
+ rules={[{ required: true, message: "请输入" }]}
|
|
|
+ >
|
|
|
+ <DageUpload
|
|
|
+ maxCount={1}
|
|
|
+ disabled={readonly.current}
|
|
|
+ tips="支持png、jpg和jpeg格式;最大20M,最多1张"
|
|
|
+ action="/api/cms/goods/upload"
|
|
|
+ />
|
|
|
+ </Form.Item>
|
|
|
+ <Form.Item
|
|
|
+ label="文件类型"
|
|
|
+ name="fileTypes"
|
|
|
+ rules={[
|
|
|
+ { required: true, message: "请选择" },
|
|
|
+ { validator: dageFileCheckboxRef.current?.validate! },
|
|
|
+ ]}
|
|
|
+ >
|
|
|
+ <DageFileCheckbox
|
|
|
+ ref={dageFileCheckboxRef}
|
|
|
+ disabled={readonly.current}
|
|
|
+ action="/api/cms/goods/upload"
|
|
|
+ onFileChange={handleFileChange}
|
|
|
+ />
|
|
|
+ </Form.Item>
|
|
|
+ </Form>
|
|
|
|
|
|
- {!loading && (
|
|
|
- <FormPageFooter
|
|
|
- showSubmit={!readonly.current}
|
|
|
- disabled={btnDisabled}
|
|
|
- onSubmit={handleSubmit}
|
|
|
- onCancel={handleCancel}
|
|
|
- />
|
|
|
- )}
|
|
|
+ {!loading && (
|
|
|
+ <FormPageFooter
|
|
|
+ showSubmit={!readonly.current}
|
|
|
+ disabled={data?.uploading}
|
|
|
+ onSubmit={handleSubmit}
|
|
|
+ onCancel={handleCancel}
|
|
|
+ />
|
|
|
+ )}
|
|
|
+ </>
|
|
|
+ )}
|
|
|
+ </DageUploadConsumer>
|
|
|
+ </DageUploadProvider>
|
|
|
</div>
|
|
|
);
|
|
|
}
|