diff --git a/src/App.css b/src/App.css index c2e5fff9..9a82ff69 100644 --- a/src/App.css +++ b/src/App.css @@ -229,6 +229,11 @@ border: none; } +.table-box-app .zent-datepicker-trigger{ + background: #f5f6f7 !important; + border: none; +} + /* 日期整体样式 */ .zent-datepicker .zent-datepicker-trigger { border-radius: 0 !important; diff --git a/src/components/UseCouponAddEdit/index copy 2.jsx b/src/components/UseCouponAddEdit/index copy 2.jsx new file mode 100644 index 00000000..be3afd47 --- /dev/null +++ b/src/components/UseCouponAddEdit/index copy 2.jsx @@ -0,0 +1,435 @@ +import React, { forwardRef, useImperativeHandle, useRef } from "react"; +import { useSetState } from "ahooks"; +import { FixedSizeList } from "react-window"; +import { + Card, + DateRangePicker, + Button, + LayoutRow as Row, + LayoutCol as Col, + LayoutGrid as Grids, + Select, +} from "zent"; +import moment from "moment"; + +import Ipt from "@/components/input/main"; +import Form from "@/components/form/main"; +import FormItem from "@/components/form-item/main"; +import Grid from "@/components/gird/main.js"; + +import "./style.less"; + +const tableColumn = [ + { + title: "商品编号", + name: "key_code", + prop: "key_code", + type: "normal", + width: "auto", + }, + { + title: "商品名称", + name: "key_code", + prop: "key_code", + type: "normal", + width: "auto", + }, + { + title: "官方价", + name: "key_code", + prop: "key_code", + type: "normal", + width: "auto", + }, + { + title: "合同单价", + name: "key_code", + prop: "key_code", + type: "normal", + width: "auto", + }, + { + title: "库存数量", + name: "key_code", + prop: "key_code", + type: "normal", + width: "auto", + }, + { + title: "批次号", + name: "key_code", + prop: "key_code", + type: "normal", + width: "auto", + }, + { + title: "总预算", + name: "key_code", + prop: "key_code", + type: "normal", + width: "auto", + }, + { + title: "有效时间段", + name: "key_code", + prop: "key_code", + type: "normal", + width: "auto", + }, + { + title: "创建时间", + name: "key_code", + prop: "key_code", + type: "normal", + width: "auto", + }, + { + title: "类型", + name: "key_code", + prop: "key_code", + type: "normal", + width: "auto", + }, + { + title: "上游平台", + name: "key_code", + prop: "key_code", + type: "normal", + width: "auto", + }, + { + title: "操作", + name: "key_code", + prop: "key_code", + type: "normal", + width: "auto", + }, +]; + +const rules = { + name: [{ type: "required", message: "请输入批次名称" }], +}; + +const UseCouponAddEdit = forwardRef((props, ref) => { + /** + * type 入口类型 0优惠券新增 1计划、key批次 (是否显示两个字段) + */ + const { type = 0 } = props; + const [state, setState] = useSetState({ + setup1_title: "基本信息", + setup2_title: "发放规则", + setup3_title: "商品范围", + disabled: false, + model: { + name: "", + date_time: "", + }, + tableData: [], + tableHeight: 500, + page: 1, + dataCount: 0, + rankoptions: [], + rank: [], + newGoodsBtnLoading: false, + newGoldLoading: false, + lodgingTable: true, + plan_OPTIONS: [ + { + key: "1", + text: `plan 1`, + }, + ], + key_OPTIONS: [ + { + key: "1", + text: `key 1`, + }, + ], + }); + + useImperativeHandle(ref, () => ({ + submit: submit, + })); + + const form_el = useRef(null); + const table_el = useRef(null); + + const submit = () => { + let el = form_el.current.validator(); + console.log("el =>", el); + }; + + const onReturn = () => {}; + const onChangeCombinedDate = () => {}; + const onDisabledRange = (date, type) => { + let disabled = false; + if (type == "end") { + disabled = moment(date.getTime()).add(1, "days") <= new Date().getTime(); + } + if (type == "start") { + disabled = date.getTime() <= new Date().getTime(); + } + return disabled; + }; + const onPageChange = () => {}; + const onCountChange = () => {}; + const selectionFun = () => {}; + const onRankChange = () => {}; + const addProduct = () => {}; + const renderOptionList = (options, renderOption) => { + return ( + + {({ index, style }) => ( +
{renderOption(options[index], index)}
+ )} +
+ ); + }; + const plan_key_formEl = () => { + return ( + <> + + + + + ); + }; + return ( +
+
+ + {/* 是否显示两个字段 */} + {type === 1 ? plan_key_formEl() : null} + + + { + setState({ model: { name: e } }); + }} + onClearItem={() => { + setState({ model: { name: "" } }); + }} + value={state.model.name} + placeholder={"请输入"} + labelWidth={"0px"} + maxLength={20} + height={"36px"} + countShow={true} + width={"520px"} + alignment={"left"} + /> + + + + { + onChangeCombinedDate(e); + }} + disabledDate={onDisabledRange} + /> + + + + + + +

+ 面额 * +

+ + +
+ + { + setState({ model: { name: e } }); + }} + onClearItem={() => { + setState({ model: { name: "" } }); + }} + value={state.model.name} + placeholder={"请输入"} + labelWidth={"0px"} + maxLength={20} + height={"36px"} + countShow={false} + width={"130px"} + alignment={"left"} + /> +
+ + + +
+ + { + setState({ model: { name: e } }); + }} + onClearItem={() => { + setState({ model: { name: "" } }); + }} + value={state.model.name} + placeholder={"请输入"} + labelWidth={"0px"} + maxLength={20} + height={"36px"} + countShow={false} + width={"130px"} + alignment={"left"} + unit="元" + /> +
+ +
+
+ + + { + setState({ model: { name: e } }); + }} + onClearItem={() => { + setState({ model: { name: "" } }); + }} + value={state.model.name} + placeholder={"请输入"} + labelWidth={"0px"} + maxLength={20} + height={"36px"} + countShow={false} + width={"520px"} + alignment={"left"} + unit="个" + /> + + + + { + setState({ model: { name: e } }); + }} + onClearItem={() => { + setState({ model: { name: "" } }); + }} + value={state.model.name} + placeholder={"请输入"} + labelWidth={"0px"} + maxLength={20} + height={"36px"} + countShow={false} + width={"520px"} + alignment={"left"} + unit="元" + /> + +
+ + +
+ + + + + + + { + onRankChange(e); + }} + /> + + +
+
{ + /** + * type 入口类型 0优惠券新增 1计划、key批次 (是否显示两个字段) + */ + const { type = 0 } = props; const [state, setState] = useSetState({ setup1_title: "基本信息", setup2_title: "发放规则", @@ -117,7 +124,7 @@ const UseCouponAddEdit = forwardRef((props, ref) => { disabled: false, model: { name: "", - time: "", + name1: "", }, tableData: [], tableHeight: 500, @@ -128,7 +135,20 @@ const UseCouponAddEdit = forwardRef((props, ref) => { newGoodsBtnLoading: false, newGoldLoading: false, lodgingTable: true, + plan_OPTIONS: [ + { + key: "1", + text: `plan 1`, + }, + ], + key_OPTIONS: [ + { + key: "1", + text: `key 1`, + }, + ], }); + const [stateData, setStateData] = useState({ addNew: "", addNew1: "" }); useImperativeHandle(ref, () => ({ submit: submit, @@ -137,7 +157,11 @@ const UseCouponAddEdit = forwardRef((props, ref) => { const form_el = useRef(null); const table_el = useRef(null); - const submit = () => {}; + const submit = () => { + let el = form_el.current.validator(); + console.log("el =>", el); + }; + const onReturn = () => {}; const onChangeCombinedDate = () => {}; const onDisabledRange = (date, type) => { @@ -153,232 +177,86 @@ const UseCouponAddEdit = forwardRef((props, ref) => { const onPageChange = () => {}; const onCountChange = () => {}; const selectionFun = () => {}; - const addCouponBtn = () => {}; - const searchCallback = () => {}; const onRankChange = () => {}; const addProduct = () => {}; + const renderOptionList = (options, renderOption) => { + return ( + + {({ index, style }) => ( +
{renderOption(options[index], index)}
+ )} +
+ ); + }; + const plan_key_formEl = () => { + return ( + <> + + + + + ); + }; return (
- + - - - { - setState({ model: { name: e } }); - }} - onClearItem={() => { - setState({ model: { name: "" } }); - }} - value={state.model.name} - placeholder={"请输入"} - labelWidth={"0px"} - maxLength={20} - height={"36px"} - countShow={true} - width={"520px"} - alignment={"left"} - /> - - - - { - onChangeCombinedDate(e); - }} - disabledDate={onDisabledRange} - /> - - - - - - - -

- 面额 * -

- - -
- - { - setState({ model: { name: e } }); - }} - onClearItem={() => { - setState({ model: { name: "" } }); - }} - value={state.model.name} - placeholder={"请输入"} - labelWidth={"0px"} - maxLength={20} - height={"36px"} - countShow={false} - width={"130px"} - alignment={"left"} - /> -
- - - -
- - { - setState({ model: { name: e } }); - }} - onClearItem={() => { - setState({ model: { name: "" } }); - }} - value={state.model.name} - placeholder={"请输入"} - labelWidth={"0px"} - maxLength={20} - height={"36px"} - countShow={false} - width={"130px"} - alignment={"left"} - unit="元" - /> -
- -
-
- - + { - setState({ model: { name: e } }); + onChange={(value) => { + setStateData({ ...stateData, addNew: value }); }} onClearItem={() => { - setState({ model: { name: "" } }); + setStateData({ ...stateData, addNew: "" }); }} - value={state.model.name} + value={stateData.addNew} placeholder={"请输入"} labelWidth={"0px"} maxLength={20} height={"36px"} - countShow={false} + countShow={true} width={"520px"} alignment={"left"} - unit="个" /> - + { - setState({ model: { name: e } }); + onChange={(value) => { + setStateData({ ...stateData, addNew1: value }); }} onClearItem={() => { - setState({ model: { name: "" } }); + setStateData({ ...stateData, addNew1: "" }); }} - value={state.model.name} + value={stateData.addNew1} placeholder={"请输入"} labelWidth={"0px"} maxLength={20} height={"36px"} - countShow={false} + countShow={true} width={"520px"} alignment={"left"} - unit="元" />
- - -
-