|
@@ -1,5 +1,12 @@
|
|
|
-import { Form, Modal, Select } from "antd"
|
|
|
+import UploadImg from "@/components/UploadImg"
|
|
|
+import { QuestionCircleOutlined } from "@ant-design/icons"
|
|
|
+import { Col, DatePicker, Form, Input, InputNumber, Modal, Radio, Row, Select, Space, Tooltip } from "antd"
|
|
|
+import { RangePickerProps } from "antd/es/date-picker"
|
|
|
import React from "react"
|
|
|
+import moment from "moment"
|
|
|
+import { MaterialSourceEnum, MaterialTypeEnum, RatioEnum, StatusEnum, TaskTypeEnum } from "@/const"
|
|
|
+import Interval from "@/components/Interval"
|
|
|
+import UploadImgs from "@/components/UploadImgs"
|
|
|
|
|
|
interface Props {
|
|
|
initialValues?: any
|
|
@@ -14,38 +21,146 @@ interface Props {
|
|
|
const TaskModal: React.FC<Props> = ({ initialValues, visible, onChange, onClose }) => {
|
|
|
|
|
|
/*************************************/
|
|
|
- const [form] = Form.useForm()
|
|
|
+ const [form] = Form.useForm<TASKAPI.AddTask>()
|
|
|
+ const endTime = Form.useWatch('endTime', form)
|
|
|
+ const startTime = Form.useWatch('startTime', form)
|
|
|
/*************************************/
|
|
|
|
|
|
const handleOk = async () => {
|
|
|
|
|
|
}
|
|
|
|
|
|
+ const disabledStartDate: RangePickerProps['disabledDate'] = (current) => {
|
|
|
+ // Can not select days before today and today
|
|
|
+ if (endTime) {
|
|
|
+ return current && (current < moment().startOf('day') || current > moment(endTime).endOf('day'));
|
|
|
+ }
|
|
|
+ return current && (current < moment().startOf('day') || current > moment().add(30, 'day').endOf('day'));
|
|
|
+ };
|
|
|
+
|
|
|
+ const disabledEndDate: RangePickerProps['disabledDate'] = (current) => {
|
|
|
+ // Can not select days before today and today
|
|
|
+ if (startTime) {
|
|
|
+ return current && (current < moment(startTime).startOf('day') || current > moment().add(30, 'day').endOf('day'));
|
|
|
+ }
|
|
|
+ return current && (current < moment().startOf('day') || current > moment().add(30, 'day').endOf('day'));
|
|
|
+ };
|
|
|
+
|
|
|
return <Modal
|
|
|
title={`发布任务`}
|
|
|
open={visible}
|
|
|
onCancel={onClose}
|
|
|
onOk={handleOk}
|
|
|
+ width={1000}
|
|
|
>
|
|
|
<Form
|
|
|
- initialValues={initialValues}
|
|
|
+ initialValues={
|
|
|
+ Object.keys(initialValues).length > 0 ?
|
|
|
+ initialValues :
|
|
|
+ {
|
|
|
+ taskType: 'TASK_TYPE_GAME',
|
|
|
+ materialType: 'MATERIAL_TYPE_VIDEO',
|
|
|
+ status: 'STATUS_NORMAL',
|
|
|
+ materialSource: 'MATERIAL_SOURCE_ORIGINAL',
|
|
|
+ checkout: 2,
|
|
|
+ materialExamples: ['https://zx-material-center-test.oss-cn-hangzhou.aliyuncs.com/image/AAFE07F5819A488EB0A7B14E03FBBE7E.jpg', 'https://zx-material-center-test.oss-cn-hangzhou.aliyuncs.com/image/2E6677DBEC314344B0416557531899D2.jpg', 'https://zx-material-center-test.oss-cn-hangzhou.aliyuncs.com/image/AAFE07F5819A488EB0A7B14E03FBBE7E.jpg', 'https://zx-material-center-test.oss-cn-hangzhou.aliyuncs.com/image/2E6677DBEC314344B0416557531899D2.jpg']
|
|
|
+ }
|
|
|
+ }
|
|
|
name="taskModal"
|
|
|
form={form}
|
|
|
- layout="vertical"
|
|
|
- labelCol={{ span: 4 }}
|
|
|
- wrapperCol={{ span: 20 }}
|
|
|
+ labelCol={{ span: 6 }}
|
|
|
+ wrapperCol={{ span: 18 }}
|
|
|
+ colon={false}
|
|
|
+ labelAlign="left"
|
|
|
>
|
|
|
- <Form.Item label="任务紧急度" name='taskName'>
|
|
|
- <Select
|
|
|
- placeholder="请选择任务紧急度"
|
|
|
- options={[
|
|
|
- { value: 'jack', label: 'Jack' },
|
|
|
- { value: 'lucy', label: 'Lucy' },
|
|
|
- { value: 'Yiminghe', label: 'yiminghe' },
|
|
|
- { value: 'disabled', label: 'Disabled', disabled: true },
|
|
|
- ]}
|
|
|
- />
|
|
|
- </Form.Item>
|
|
|
+ <Row gutter={20}>
|
|
|
+ <Col span={12}>
|
|
|
+ <Form.Item label={<strong>任务头像</strong>} name='avatar'>
|
|
|
+ <UploadImg isUpload={true}/>
|
|
|
+ </Form.Item>
|
|
|
+ <Form.Item label={<strong>任务名称</strong>} name='name' rules={[{ required: true, message: '请输入任务名称!' }]}>
|
|
|
+ <Input placeholder="请输入任务名称" />
|
|
|
+ </Form.Item>
|
|
|
+ <Form.Item label={<strong>描述</strong>} name='remark'>
|
|
|
+ <Input placeholder="请输入任务描述" />
|
|
|
+ </Form.Item>
|
|
|
+ <Form.Item label={<strong>补充说明</strong>} name='remarkMore'>
|
|
|
+ <Input placeholder="请输入补充说明" />
|
|
|
+ </Form.Item>
|
|
|
+ <Form.Item label={<strong>
|
|
|
+ <span style={{ color: '#ff4d4f' }}>*</span>有效时间
|
|
|
+ <Tooltip title="开始日期必填">
|
|
|
+ <QuestionCircleOutlined style={{ marginLeft: 2 }} />
|
|
|
+ </Tooltip>
|
|
|
+ </strong>}>
|
|
|
+ <Space>
|
|
|
+ <Form.Item name="startTime" noStyle rules={[{ required: true, message: '请设置开始日期!' }]}>
|
|
|
+ <DatePicker placeholder="开始日期" disabledDate={disabledStartDate} />
|
|
|
+ </Form.Item>
|
|
|
+ <span>-</span>
|
|
|
+ <Form.Item name="endTime" noStyle>
|
|
|
+ <DatePicker placeholder="结束日期" disabledDate={disabledEndDate} />
|
|
|
+ </Form.Item>
|
|
|
+ </Space>
|
|
|
+ </Form.Item>
|
|
|
+ <Form.Item label={<strong>紧急度</strong>} tooltip="任务紧急度决定任务的展示情况,默认将“置顶”任务展示页面最前,其次按照发布时间倒序排列展示(即最新发布的任务展示在页面最前端)" name='urgency' rules={[{ required: true, message: '请选择任务紧急度!' }]}>
|
|
|
+ <Select
|
|
|
+ placeholder="请选择任务紧急度"
|
|
|
+ options={[
|
|
|
+ { value: false, label: '普通' },
|
|
|
+ { value: true, label: '置顶' }
|
|
|
+ ]}
|
|
|
+ />
|
|
|
+ </Form.Item>
|
|
|
+ <Form.Item label={<strong>任务状态</strong>} name='status' rules={[{ required: true, message: '请选择任务状态!' }]}>
|
|
|
+ <Radio.Group>
|
|
|
+ {Object.keys(StatusEnum).filter(key => initialValues?.id ? true : key === 'STATUS_EXPIRE' ? false : true).map(key => <Radio value={key} key={key}>{(StatusEnum as any)[key]}</Radio>)}
|
|
|
+ </Radio.Group>
|
|
|
+ </Form.Item>
|
|
|
+ <Form.Item label={<strong>任务分类</strong>} name='taskType' rules={[{ required: true, message: '请选择任务分类!' }]}>
|
|
|
+ <Radio.Group>
|
|
|
+ {Object.keys(TaskTypeEnum).map(key => <Radio value={key} key={key}>{(TaskTypeEnum as any)[key]}</Radio>)}
|
|
|
+ </Radio.Group>
|
|
|
+ </Form.Item>
|
|
|
+ <Form.Item label={<strong>素材类型</strong>} name='materialType' rules={[{ required: true, message: '请选择素材类型!' }]}>
|
|
|
+ <Radio.Group>
|
|
|
+ {Object.keys(MaterialTypeEnum).map(key => <Radio value={key} key={key}>{(MaterialTypeEnum as any)[key]}</Radio>)}
|
|
|
+ </Radio.Group>
|
|
|
+ </Form.Item>
|
|
|
+ <Form.Item label={<strong>素材来源</strong>} name='materialSource' rules={[{ required: true, message: '请选择素材类型!' }]}>
|
|
|
+ <Radio.Group>
|
|
|
+ {Object.keys(MaterialSourceEnum).map(key => <Radio value={key} key={key}>{(MaterialSourceEnum as any)[key]}</Radio>)}
|
|
|
+ </Radio.Group>
|
|
|
+ </Form.Item>
|
|
|
+ <Form.Item label={<strong>奖励结算</strong>} name='checkout' rules={[{ required: true, message: '请输入奖励结算!' }]}>
|
|
|
+ <InputNumber
|
|
|
+ addonBefore="消耗比例"
|
|
|
+ min={0}
|
|
|
+ max={100}
|
|
|
+ formatter={(value) => `${value}%`}
|
|
|
+ parser={(value) => value!.replace('%', '') as any}
|
|
|
+ />
|
|
|
+ </Form.Item>
|
|
|
+ </Col>
|
|
|
+ <Col span={12}>
|
|
|
+ <Form.Item label={<strong>素材比例</strong>} name='ratio' rules={[{ required: true, message: '请选择素材比例!' }]}>
|
|
|
+ <Select
|
|
|
+ placeholder="请选择素材比例"
|
|
|
+ options={Object.keys(RatioEnum).map(key => ({ label: (RatioEnum as any)[key], value: key }))}
|
|
|
+ />
|
|
|
+ </Form.Item>
|
|
|
+ <Form.Item label={<strong>素材尺寸</strong>} name='size' rules={[{ required: true, message: '请选择素材比例!' }]}>
|
|
|
+ <Interval unit="*" placeholder={['720', '1280']}/>
|
|
|
+ </Form.Item>
|
|
|
+ <Form.Item label={<strong>素材大小</strong>} name='extent' tooltip="单位(MB)" rules={[{ required: true, message: '请选择素材比例!' }]}>
|
|
|
+ <Interval placeholder={['20M', '40M']}/>
|
|
|
+ </Form.Item>
|
|
|
+ <Form.Item label={<strong>素材示例上传</strong>} name='materialExamples'>
|
|
|
+ <UploadImgs isUpload={true} maxCount={10} />
|
|
|
+ </Form.Item>
|
|
|
+ </Col>
|
|
|
+ </Row>
|
|
|
+
|
|
|
</Form>
|
|
|
</Modal>
|
|
|
}
|