|
|
@@ -30,7 +30,6 @@ import {
|
|
|
} from "@/store/action/A4Prise";
|
|
|
import { MessageFu } from "@/utils/message";
|
|
|
import { RangePickerProps } from "antd/es/date-picker";
|
|
|
-import { RcFile } from "antd/es/upload";
|
|
|
import RichText from "@/components/Z_RichText";
|
|
|
import moment from "moment";
|
|
|
import UpFileOne from "@/components/Z_upFileOne";
|
|
|
@@ -82,7 +81,9 @@ function A4Prize() {
|
|
|
setCover(res.data.thumb);
|
|
|
setDirCode(res.data.id);
|
|
|
// 调用富文本子组件的函数,回显数据
|
|
|
- richTxtRef.current.ritxtShowFu(res.data.rtf);
|
|
|
+ if (res.data.name !== "公益合伙人证书") {
|
|
|
+ richTxtRef.current.ritxtShowFu(res.data.rtf);
|
|
|
+ }
|
|
|
}
|
|
|
} else {
|
|
|
setModalType("add");
|
|
|
@@ -149,6 +150,31 @@ function A4Prize() {
|
|
|
[cover, curEditItem, form, getList, modalType]
|
|
|
);
|
|
|
|
|
|
+ const onFinishForZhengShu = useCallback(
|
|
|
+ async (values: any) => {
|
|
|
+ if (values) {
|
|
|
+ setCheck(true);
|
|
|
+
|
|
|
+ const obj = {
|
|
|
+ ...values,
|
|
|
+ id: curEditItem && modalType !== "add" ? curEditItem.id : null,
|
|
|
+ thumb: curEditItem?.thumb,
|
|
|
+ rtf: curEditItem?.rtf,
|
|
|
+ };
|
|
|
+
|
|
|
+ const res: any = await editPrizeByIdAPI(obj);
|
|
|
+ if (res.code === 0) {
|
|
|
+ MessageFu.success("提交成功!");
|
|
|
+ getList();
|
|
|
+ setEditPageVisible(false);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ form.resetFields();
|
|
|
+ setCover("");
|
|
|
+ },
|
|
|
+ [curEditItem, form, getList, modalType]
|
|
|
+ );
|
|
|
+
|
|
|
const handleChange = (value: string) => {
|
|
|
// console.log(`selected ${value}`);
|
|
|
};
|
|
|
@@ -176,11 +202,17 @@ function A4Prize() {
|
|
|
},
|
|
|
{
|
|
|
title: "库存",
|
|
|
- dataIndex: "stock",
|
|
|
+ // dataIndex: "stock",
|
|
|
+ render: (item: PrizeTableType) => (
|
|
|
+ <div>{item.name === "公益合伙人证书" ? "-" : item.stock}</div>
|
|
|
+ ),
|
|
|
},
|
|
|
{
|
|
|
title: "登记日期",
|
|
|
- dataIndex: "updateTime",
|
|
|
+ // dataIndex: "updateTime",
|
|
|
+ render: (item: PrizeTableType) => (
|
|
|
+ <div>{item.name === "公益合伙人证书" ? "-" : item.updateTime}</div>
|
|
|
+ ),
|
|
|
},
|
|
|
{
|
|
|
title: "状态",
|
|
|
@@ -191,7 +223,7 @@ function A4Prize() {
|
|
|
{
|
|
|
title: "操作",
|
|
|
render: (item: PrizeTableType) => {
|
|
|
- return (
|
|
|
+ return item.name !== "公益合伙人证书" ? (
|
|
|
<>
|
|
|
<Button
|
|
|
size="small"
|
|
|
@@ -215,6 +247,14 @@ function A4Prize() {
|
|
|
</Button>
|
|
|
</Popconfirm>
|
|
|
</>
|
|
|
+ ) : (
|
|
|
+ <Button
|
|
|
+ size="small"
|
|
|
+ type="text"
|
|
|
+ onClick={() => openEditPageFu(item.id)}
|
|
|
+ >
|
|
|
+ 编辑
|
|
|
+ </Button>
|
|
|
);
|
|
|
},
|
|
|
},
|
|
|
@@ -280,141 +320,220 @@ function A4Prize() {
|
|
|
/>
|
|
|
</div>
|
|
|
</div>
|
|
|
- {/* 编辑/新增弹窗 */}
|
|
|
- <Modal
|
|
|
- destroyOnClose
|
|
|
- closable={false}
|
|
|
- maskClosable={false}
|
|
|
- open={editPageVisible}
|
|
|
- title={modalType === "add" ? "新增奖品" : "编辑奖品"}
|
|
|
- width={1000}
|
|
|
- onCancel={() => setEditPageVisible(false)}
|
|
|
- footer={
|
|
|
- [] // 设置footer为空,去掉 取消 确定默认按钮
|
|
|
- }
|
|
|
- >
|
|
|
- <Form
|
|
|
- form={form}
|
|
|
- ref={FormBoxRef}
|
|
|
- name="basic"
|
|
|
- labelCol={{ span: 3 }}
|
|
|
- onFinish={onFinish}
|
|
|
- onFinishFailed={onFinishFailed}
|
|
|
- autoComplete="off"
|
|
|
+ {curEditItem?.name === "公益合伙人证书" && modalType === "edit" ? (
|
|
|
+ <Modal
|
|
|
+ destroyOnClose
|
|
|
+ closable={false}
|
|
|
+ maskClosable={false}
|
|
|
+ open={editPageVisible}
|
|
|
+ title={"编辑奖品"}
|
|
|
+ width={1000}
|
|
|
+ onCancel={() => setEditPageVisible(false)}
|
|
|
+ footer={
|
|
|
+ [] // 设置footer为空,去掉 取消 确定默认按钮
|
|
|
+ }
|
|
|
>
|
|
|
- <Form.Item
|
|
|
- label="奖品名称"
|
|
|
- name="name"
|
|
|
- rules={[{ required: true, message: "不能为空!" }]}
|
|
|
- >
|
|
|
- <Input maxLength={20} placeholder="请输入内容,不超过20个字" />
|
|
|
- </Form.Item>
|
|
|
- <Form.Item
|
|
|
- label="所需的积分"
|
|
|
- name="score"
|
|
|
- rules={[{ required: true, message: "不能为空!" }]}
|
|
|
- getValueFromEvent={(e) =>
|
|
|
- e.target.value.replace(/^(0+)|[^\d]+/g, "")
|
|
|
- }
|
|
|
- >
|
|
|
- <Input maxLength={5} placeholder="请输入正整数,1-99999" />
|
|
|
- </Form.Item>
|
|
|
- <Form.Item
|
|
|
- label="库存"
|
|
|
- name="stock"
|
|
|
- rules={[{ required: true, message: "不能为空!" }]}
|
|
|
- getValueFromEvent={(e) =>
|
|
|
- e.target.value.replace(/^(0+)|[^\d]+/g, "")
|
|
|
- }
|
|
|
- >
|
|
|
- <Input maxLength={5} placeholder="请输入正整数,1-99999" />
|
|
|
- </Form.Item>
|
|
|
- <Form.Item
|
|
|
- label="登记日期"
|
|
|
- name="date"
|
|
|
- initialValue={moment() as any}
|
|
|
- rules={[{ required: true, message: "不能为空!" }]}
|
|
|
+ <Form
|
|
|
+ form={form}
|
|
|
+ ref={FormBoxRef}
|
|
|
+ name="basic"
|
|
|
+ labelCol={{ span: 3 }}
|
|
|
+ onFinish={onFinishForZhengShu}
|
|
|
+ onFinishFailed={onFinishFailed}
|
|
|
+ autoComplete="off"
|
|
|
>
|
|
|
- <DatePicker showTime onChange={onChange} onOk={onOk} />
|
|
|
- </Form.Item>
|
|
|
- <Form.Item
|
|
|
- label="状态"
|
|
|
- name="isEnabled"
|
|
|
- initialValue={curEditItem ? (curEditItem.stock > 0 ? 1 : 0) : 1}
|
|
|
- rules={[{ required: true, message: "不能为空!" }]}
|
|
|
- >
|
|
|
- <Select
|
|
|
- defaultValue={"上架"}
|
|
|
- style={{ width: 120 }}
|
|
|
- onChange={handleChange}
|
|
|
- options={[
|
|
|
- { value: 1, label: "上架" },
|
|
|
- { value: 0, label: "下架" },
|
|
|
- ]}
|
|
|
- />
|
|
|
- </Form.Item>
|
|
|
- <Form.Item name="themb" initialValue={cover ? cover : ""}>
|
|
|
- <div style={{ marginLeft: "7%", display: "flex" }}>
|
|
|
- <span style={{ marginRight: "2px", color: "red" }}>*</span>
|
|
|
- <div>封面:</div>
|
|
|
- </div>
|
|
|
- <div style={{ marginLeft: "14%" }}>
|
|
|
- <UpFileOne
|
|
|
- myUrl="cms/prize/upload"
|
|
|
- cover={cover}
|
|
|
- setCover={(val) => {
|
|
|
- setCover(val);
|
|
|
+ <Form.Item
|
|
|
+ label="奖品名称"
|
|
|
+ name="name"
|
|
|
+ rules={[{ required: true, message: "不能为空!" }]}
|
|
|
+ >
|
|
|
+ {curEditItem.name}
|
|
|
+ </Form.Item>
|
|
|
+ <Form.Item
|
|
|
+ label="所需的积分"
|
|
|
+ name="score"
|
|
|
+ rules={[{ required: true, message: "不能为空!" }]}
|
|
|
+ getValueFromEvent={(e) =>
|
|
|
+ e.target.value.replace(/^(0+)|[^\d]+/g, "")
|
|
|
+ }
|
|
|
+ >
|
|
|
+ <Input maxLength={5} placeholder="请输入正整数,1-99999" />
|
|
|
+ </Form.Item>
|
|
|
+ <Form.Item
|
|
|
+ label="状态"
|
|
|
+ name="isEnabled"
|
|
|
+ initialValue={curEditItem ? (curEditItem.stock > 0 ? 1 : 0) : 1}
|
|
|
+ rules={[{ required: true, message: "不能为空!" }]}
|
|
|
+ >
|
|
|
+ <Select
|
|
|
+ defaultValue={"上架"}
|
|
|
+ style={{ width: 120 }}
|
|
|
+ onChange={handleChange}
|
|
|
+ options={[
|
|
|
+ { value: 1, label: "上架" },
|
|
|
+ { value: 0, label: "下架" },
|
|
|
+ ]}
|
|
|
+ />
|
|
|
+ </Form.Item>
|
|
|
+ {/* 确定和取消按钮 */}
|
|
|
+ <br />
|
|
|
+ <Form.Item wrapperCol={{ offset: 9, span: 16 }}>
|
|
|
+ <Button type="primary" htmlType="submit">
|
|
|
+ 提交
|
|
|
+ </Button>
|
|
|
+  
|
|
|
+ <Popconfirm
|
|
|
+ title="放弃编辑后,信息将不会保存!"
|
|
|
+ okText="放弃"
|
|
|
+ cancelText="取消"
|
|
|
+ onConfirm={() => {
|
|
|
+ setEditPageVisible(false);
|
|
|
+ form.resetFields();
|
|
|
+ setCover("");
|
|
|
}}
|
|
|
- isLook={false}
|
|
|
- coverCheck={check}
|
|
|
- size={2}
|
|
|
- dirCode={dirCode}
|
|
|
- checkTxt="请上传图片!"
|
|
|
+ okButtonProps={{ loading: false }}
|
|
|
+ >
|
|
|
+ <Button>取消</Button>
|
|
|
+ </Popconfirm>
|
|
|
+ </Form.Item>
|
|
|
+ </Form>
|
|
|
+ </Modal>
|
|
|
+ ) : (
|
|
|
+ <Modal
|
|
|
+ destroyOnClose
|
|
|
+ closable={false}
|
|
|
+ maskClosable={false}
|
|
|
+ open={editPageVisible}
|
|
|
+ title={modalType === "add" ? "新增奖品" : "编辑奖品"}
|
|
|
+ width={1000}
|
|
|
+ onCancel={() => setEditPageVisible(false)}
|
|
|
+ footer={
|
|
|
+ [] // 设置footer为空,去掉 取消 确定默认按钮
|
|
|
+ }
|
|
|
+ >
|
|
|
+ <Form
|
|
|
+ form={form}
|
|
|
+ ref={FormBoxRef}
|
|
|
+ name="basic"
|
|
|
+ labelCol={{ span: 3 }}
|
|
|
+ onFinish={onFinish}
|
|
|
+ onFinishFailed={onFinishFailed}
|
|
|
+ autoComplete="off"
|
|
|
+ >
|
|
|
+ <Form.Item
|
|
|
+ label="奖品名称"
|
|
|
+ name="name"
|
|
|
+ rules={[{ required: true, message: "不能为空!" }]}
|
|
|
+ >
|
|
|
+ <Input maxLength={20} placeholder="请输入内容,不超过20个字" />
|
|
|
+ </Form.Item>
|
|
|
+ <Form.Item
|
|
|
+ label="所需的积分"
|
|
|
+ name="score"
|
|
|
+ rules={[{ required: true, message: "不能为空!" }]}
|
|
|
+ getValueFromEvent={(e) =>
|
|
|
+ e.target.value.replace(/^(0+)|[^\d]+/g, "")
|
|
|
+ }
|
|
|
+ >
|
|
|
+ <Input maxLength={5} placeholder="请输入正整数,1-99999" />
|
|
|
+ </Form.Item>
|
|
|
+ <Form.Item
|
|
|
+ label="库存"
|
|
|
+ name="stock"
|
|
|
+ rules={[{ required: true, message: "不能为空!" }]}
|
|
|
+ getValueFromEvent={(e) =>
|
|
|
+ e.target.value.replace(/^(0+)|[^\d]+/g, "")
|
|
|
+ }
|
|
|
+ >
|
|
|
+ <Input maxLength={5} placeholder="请输入正整数,1-99999" />
|
|
|
+ </Form.Item>
|
|
|
+ <Form.Item
|
|
|
+ label="登记日期"
|
|
|
+ name="date"
|
|
|
+ initialValue={moment() as any}
|
|
|
+ rules={[{ required: true, message: "不能为空!" }]}
|
|
|
+ >
|
|
|
+ <DatePicker showTime onChange={onChange} onOk={onOk} />
|
|
|
+ </Form.Item>
|
|
|
+ <Form.Item
|
|
|
+ label="状态"
|
|
|
+ name="isEnabled"
|
|
|
+ initialValue={curEditItem ? (curEditItem.stock > 0 ? 1 : 0) : 1}
|
|
|
+ rules={[{ required: true, message: "不能为空!" }]}
|
|
|
+ >
|
|
|
+ <Select
|
|
|
+ defaultValue={"上架"}
|
|
|
+ style={{ width: 120 }}
|
|
|
+ onChange={handleChange}
|
|
|
+ options={[
|
|
|
+ { value: 1, label: "上架" },
|
|
|
+ { value: 0, label: "下架" },
|
|
|
+ ]}
|
|
|
/>
|
|
|
- </div>
|
|
|
+ </Form.Item>
|
|
|
+ <Form.Item name="themb" initialValue={cover ? cover : ""}>
|
|
|
+ <div style={{ marginLeft: "7%", display: "flex" }}>
|
|
|
+ <span style={{ marginRight: "2px", color: "red" }}>*</span>
|
|
|
+ <div>封面:</div>
|
|
|
+ </div>
|
|
|
+ <div style={{ marginLeft: "14%" }}>
|
|
|
+ <UpFileOne
|
|
|
+ myUrl="cms/prize/upload"
|
|
|
+ cover={cover}
|
|
|
+ setCover={(val) => {
|
|
|
+ setCover(val);
|
|
|
+ }}
|
|
|
+ isLook={false}
|
|
|
+ coverCheck={check}
|
|
|
+ size={2}
|
|
|
+ dirCode={dirCode}
|
|
|
+ checkTxt="请上传图片!"
|
|
|
+ />
|
|
|
+ </div>
|
|
|
|
|
|
- {/* <span style={{ marginLeft: "14%" }}>
|
|
|
+ {/* <span style={{ marginLeft: "14%" }}>
|
|
|
格式要求:支持png、jpg和jpeg的图片格式;最大支持2M;最多1张
|
|
|
</span> */}
|
|
|
- </Form.Item>
|
|
|
- <Form.Item name="introduction">
|
|
|
- <div style={{ marginLeft: "4%", display: "flex" }}>
|
|
|
- <span style={{ marginRight: "2px", color: "red" }}>*</span>
|
|
|
- <div>产品简介:</div>
|
|
|
- </div>
|
|
|
- <div style={{ marginLeft: "12%" }}>
|
|
|
- <RichText
|
|
|
- myUrl="cms/prize/upload"
|
|
|
- ref={richTxtRef}
|
|
|
- check={check}
|
|
|
- dirCode={dirCode}
|
|
|
- isLook={false}
|
|
|
- />
|
|
|
- </div>
|
|
|
- </Form.Item>
|
|
|
- {/* 确定和取消按钮 */}
|
|
|
- <br />
|
|
|
- <Form.Item wrapperCol={{ offset: 9, span: 16 }}>
|
|
|
- <Button type="primary" htmlType="submit">
|
|
|
- 提交
|
|
|
- </Button>
|
|
|
-  
|
|
|
- <Popconfirm
|
|
|
- title="放弃编辑后,信息将不会保存!"
|
|
|
- okText="放弃"
|
|
|
- cancelText="取消"
|
|
|
- onConfirm={() => {
|
|
|
- setEditPageVisible(false);
|
|
|
- form.resetFields();
|
|
|
- setCover("");
|
|
|
- }}
|
|
|
- okButtonProps={{ loading: false }}
|
|
|
- >
|
|
|
- <Button>取消</Button>
|
|
|
- </Popconfirm>
|
|
|
- </Form.Item>
|
|
|
- </Form>
|
|
|
- </Modal>
|
|
|
+ </Form.Item>
|
|
|
+ <Form.Item name="introduction">
|
|
|
+ <div style={{ marginLeft: "4%", display: "flex" }}>
|
|
|
+ <span style={{ marginRight: "2px", color: "red" }}>*</span>
|
|
|
+ <div>产品简介:</div>
|
|
|
+ </div>
|
|
|
+ <div style={{ marginLeft: "12%" }}>
|
|
|
+ <RichText
|
|
|
+ myUrl="cms/prize/upload"
|
|
|
+ ref={richTxtRef}
|
|
|
+ check={check}
|
|
|
+ dirCode={dirCode}
|
|
|
+ isLook={false}
|
|
|
+ />
|
|
|
+ </div>
|
|
|
+ </Form.Item>
|
|
|
+ {/* 确定和取消按钮 */}
|
|
|
+ <br />
|
|
|
+ <Form.Item wrapperCol={{ offset: 9, span: 16 }}>
|
|
|
+ <Button type="primary" htmlType="submit">
|
|
|
+ 提交
|
|
|
+ </Button>
|
|
|
+  
|
|
|
+ <Popconfirm
|
|
|
+ title="放弃编辑后,信息将不会保存!"
|
|
|
+ okText="放弃"
|
|
|
+ cancelText="取消"
|
|
|
+ onConfirm={() => {
|
|
|
+ setEditPageVisible(false);
|
|
|
+ form.resetFields();
|
|
|
+ setCover("");
|
|
|
+ }}
|
|
|
+ okButtonProps={{ loading: false }}
|
|
|
+ >
|
|
|
+ <Button>取消</Button>
|
|
|
+ </Popconfirm>
|
|
|
+ </Form.Item>
|
|
|
+ </Form>
|
|
|
+ </Modal>
|
|
|
+ )}
|
|
|
</div>
|
|
|
);
|
|
|
}
|