diff --git a/src/components/UseCouponAddEdit/index copy 2.jsx b/src/components/UseCouponAddEdit/index copy 2.jsx
new file mode 100644
index 00000000..dbb5b582
--- /dev/null
+++ b/src/components/UseCouponAddEdit/index copy 2.jsx
@@ -0,0 +1,820 @@
+import React, {
+ forwardRef,
+ useImperativeHandle,
+ useRef,
+ useEffect,
+} from "react";
+import { useSetState } from "ahooks";
+import { FixedSizeList } from "react-window";
+import {
+ Card,
+ DateRangePicker,
+ Button,
+ Select,
+ Notify,
+ BlockLoading,
+} from "zent";
+import moment from "moment";
+import _ from "lodash";
+
+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 UseGoodsScopePop from "../UseGoodsScopePop/index";
+import { isAmount } from "@/tools/validate";
+
+import { getProductInfoSelect, handelResponse } from "@/assets/api.js";
+import { mulNum } from "@/tools/number";
+import "./style.less";
+
+const tableColumn = [
+ {
+ title: "商品编号",
+ name: "product_id",
+ prop: "product_id",
+ type: "normal",
+ width: "auto",
+ },
+ {
+ title: "商品名称",
+ name: "product_name",
+ prop: "product_name",
+ type: "normal",
+ width: "auto",
+ },
+ {
+ title: "官方价",
+ name: "official_price",
+ prop: "official_price",
+ type: "normal",
+ width: "auto",
+ },
+ {
+ title: "合同单价",
+ name: "contract_price",
+ prop: "contract_price",
+ type: "normal",
+ width: "auto",
+ },
+ {
+ title: "库存数量",
+ name: "quantity",
+ prop: "quantity",
+ type: "normal",
+ width: "auto",
+ },
+ {
+ title: "批次号",
+ name: "channel_activity_id",
+ prop: "channel_activity_id",
+ type: "normal",
+ width: "auto",
+ },
+ {
+ title: "总预算",
+ name: "all_budget",
+ prop: "all_budget",
+ type: "normal",
+ width: "auto",
+ },
+ {
+ title: "有效时间段",
+ name: "effectDate",
+ prop: "effectDate",
+ type: "normal",
+ width: "auto",
+ },
+ {
+ title: "创建时间",
+ name: "createDate",
+ prop: "createDate",
+ type: "normal",
+ width: "auto",
+ },
+ {
+ title: "类型",
+ name: "goods_type",
+ prop: "goods_type",
+ type: "slot",
+ width: "auto",
+ },
+ {
+ title: "上游平台",
+ name: "upstream",
+ prop: "upstream",
+ type: "normal",
+ width: "auto",
+ },
+ {
+ title: "操作",
+ name: "opearo",
+ prop: "opearo",
+ type: "slot",
+ width: "200px",
+ },
+];
+
+const info_rules = {
+ plan_id: [{ type: "required", message: "请选择归属计划" }],
+ key_batch_id: [{ type: "required", message: "请选择归属key" }],
+ name: [{ type: "required", message: "请输入批次名称" }],
+ date_time: [{ type: "required", message: "请选择时间" }],
+};
+
+const rule_rules = {
+ full: [
+ { type: "required", message: "请输入面额" },
+ {
+ type: "regExp",
+ message: "请输入两位小数",
+ reg: "^[0-9][0-9]*([.][0-9]{1,2})?$",
+ },
+ ],
+ restrict: [
+ { type: "required", message: "请输入发放总量" },
+ {
+ type: "regExp",
+ message: "请输入正整数",
+ reg: "^[1-9]*$",
+ },
+ ],
+};
+
+const UseCouponAddEdit = forwardRef((props, ref) => {
+ const { type = 0, isAuditButton = true, isCopy = false } = props; // type 入口类型 0优惠券新增 1计划、key批次 (是否显示两个字段)
+
+ useEffect(() => {
+ if (type === 0) {
+ delete info_rules.plan_id;
+ delete info_rules.key_batch_id;
+ } else {
+ info_rules.plan_id = [{ type: "required", message: "请选择归属计划" }];
+ info_rules.key_batch_id = [
+ { type: "required", message: "请选择归属key" },
+ ];
+ }
+ }, []);
+
+ const [state, setState] = useSetState({
+ setup1_title: "基本信息",
+ setup2_title: "发放规则",
+ setup3_title: "商品范围",
+ time_disabled: false,
+ tableData: [],
+ tableHeight: 500,
+ page: 1,
+ dataCount: 0,
+ rankoptions: [],
+ rank: [],
+ newGoodsBtnLoading: false,
+ newGoldLoading: false,
+ lodgingTable: true,
+ isRestrict: true,
+ plan_OPTIONS: [
+ {
+ key: "1",
+ text: `plan 1`,
+ },
+ {
+ key: "2",
+ text: `plan 2`,
+ },
+ ],
+ key_OPTIONS: [
+ {
+ key: 2,
+ text: `key 1`,
+ },
+ ],
+ addProductBtnLoading: false,
+ addGoldBtnLoading: false,
+ product_title: "",
+ showScopePop: false,
+ scopePopType: "",
+ productData: {},
+ direct_reseller_id: 23329,
+ tableLoading: false,
+ });
+
+ // 基础信息
+ const [form_info_data, setForm_info_data] = useSetState({
+ plan_id: "",
+ key_batch_id: "",
+ name: "",
+ date_time: "",
+ });
+ const form_info_el = useRef(null);
+
+ // 发放规则
+ const [form_rule_data, setForm_rule_data] = useSetState({
+ full: "",
+ reduce: "",
+ restrict: "",
+ budget: "",
+ });
+ const form_rule_el = useRef(null);
+
+ // 设置发放总量是否可用
+ useEffect(() => {
+ setIsRestrict();
+ }, [form_rule_data.reduce, form_rule_data.full]);
+
+ // 计算发放总数
+ useEffect(() => {
+ setBudget();
+ }, [form_rule_data.reduce, form_rule_data.restrict]);
+
+ const table_el = useRef(null);
+
+ useImperativeHandle(ref, () => ({
+ submit: submit,
+ }));
+
+ const submit = () => {
+ // 基础信息
+ let el_setup1 = form_info_el.current.validator();
+ // console.log("el_setup1 =>", el_setup1);
+ // console.log("form_info_data =>", form_info_data);
+
+ // 发放规则
+ let el_setup2 = form_rule_el.current.validator();
+ // console.log("el_setup2 =>", el_setup2);
+
+ console.log("rank =>", state.rank);
+ };
+
+ const onReturn = () => {};
+ const onChangeCombinedDate = (e) => {
+ setForm_info_data({ date_time: e });
+ // 传入时间
+ sessionStorage.setItem(
+ "knockGold_effectDate",
+ JSON.stringify({
+ begin_time: e[0],
+ end_time: e[1],
+ })
+ );
+ };
+ 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 clearStorageData = () => {
+ if (state.tableData.length <= 0) {
+ sessionStorage.setItem("productData", "");
+ sessionStorage.setItem("knockGoldData", "");
+ }
+
+ // 新建商品
+ let product_data = state.tableData.filter((item) => item.goods_type === 1);
+ if (product_data.length <= 0) {
+ sessionStorage.setItem("productData", "");
+ } else {
+ sessionStorage.setItem("productData", JSON.stringify(product_data));
+ }
+
+ // 立减金
+ let knockGold_data = state.tableData.filter(
+ (item) => item.goods_type === 2
+ );
+ if (knockGold_data.length <= 0) {
+ sessionStorage.setItem("knockGoldData", "");
+ } else {
+ sessionStorage.setItem("knockGoldData", JSON.stringify(knockGold_data));
+ }
+ };
+
+ const addProduct = (type) => {
+ try {
+ // 第一步:获取直连天下的商品数据需要分销商 id
+ const direct_reseller_ids = state.direct_reseller_id;
+ if (direct_reseller_ids <= 0) {
+ Notify.error(`请添加映射分销商`);
+ return;
+ }
+ // 第二步:清除本地存储数据
+ clearStorageData();
+
+ // 第三步: 区分是新建商品还是立减金
+ if (type === "addProduct") {
+ setState({
+ product_title: "新建商品",
+ addProductBtnLoading: true,
+ scopePopType: "addProduct",
+ });
+ } else {
+ setState({
+ product_title: "新增立减金",
+ addGoldBtnLoading: true,
+ scopePopType: "addKnockGold",
+ });
+ }
+
+ // 第四步:获取商品数据
+ let param = {
+ reseller_id: direct_reseller_ids,
+ };
+ getProductInfoSelect(param).then((res) => {
+ setState({ addProductBtnLoading: false, addGoldBtnLoading: false });
+ handelResponse(
+ res,
+ (req, msg) => {
+ // !!!!!!!!!!!!!! 为了兼容老版本 新增商品设为空!!!老版本使用 productsList 获取商品数据!!!!!!!!!!
+ sessionStorage.setItem("productsList", JSON.stringify(req.data));
+ // !!!!!!!!!!!!!! 为了兼容老版本 新增商品设为空!!!老版本使用 productsList 获取商品数据!!!!!!!!!!
+ setState({ productData: null });
+ setState({
+ showScopePop: true,
+ });
+ },
+ (err) => {
+ console.log("err =>", err);
+ }
+ );
+ });
+ } catch (err) {
+ setState({ addProductBtnLoading: false, addGoldBtnLoading: false });
+ }
+ };
+
+ // 编辑
+ const productEditShow = (rowData) => {
+ try {
+ // 第一步:获取直连天下的商品数据需要分销商 id
+ const direct_reseller_ids = state.direct_reseller_id;
+ if (direct_reseller_ids <= 0) {
+ Notify.error(`请添加映射分销商`);
+ return;
+ }
+ setState({
+ tableLoading: true,
+ });
+ // 第二步:获取商品数据
+ let param = {
+ reseller_id: direct_reseller_ids,
+ };
+ getProductInfoSelect(param).then((res) => {
+ setState({ tableLoading: false });
+ handelResponse(
+ res,
+ (req, msg) => {
+ // 设置所有的商品数据
+ sessionStorage.setItem("productsList", JSON.stringify(req.data));
+ /* 区分立减金 */
+ if (rowData.goods_type === 2) {
+ let obj = rowData.only;
+ setState({
+ product_title: "编辑立减金",
+ productData: obj,
+ addIsType: "addKnockGold",
+ showScopePop: true,
+ });
+ } else {
+ setState({
+ product_title: "编辑商品",
+ productData: rowData,
+ addIsType: "addProduct",
+ showScopePop: true,
+ });
+ }
+ },
+ (err) => {
+ console.log("err =>", err);
+ }
+ );
+ });
+ } catch (err) {
+ setState({ tableLoading: false });
+ console.log("err =>", err);
+ }
+ };
+
+ const renderOptionList = (options, renderOption) => {
+ return (
+
+ {({ index, style }) => (
+ {renderOption(options[index], index)}
+ )}
+
+ );
+ };
+
+ // 判断是否可用
+ const setIsRestrict = () => {
+ if (isAmount(form_rule_data.reduce) && isAmount(form_rule_data.full)) {
+ setState({ isRestrict: false });
+ } else {
+ setState({ isRestrict: true });
+ }
+ };
+
+ // 计算总预算
+ const setBudget = () => {
+ if (isAmount(form_rule_data.reduce) && isAmount(form_rule_data.restrict)) {
+ let num = mulNum(
+ Number(form_rule_data.reduce),
+ Number(form_rule_data.restrict)
+ );
+ setForm_rule_data({
+ budget: num,
+ });
+ } else {
+ setForm_rule_data({
+ budget: "",
+ });
+ }
+ };
+
+ // 优惠券弹窗 取消
+ const scopePopClose = () => {
+ setState({
+ showScopePop: false,
+ });
+ };
+
+ const selectionFun = (e) => {
+ let arr = [];
+ _.map(e, (res) => {
+ let obj = {};
+ obj.key = res;
+ obj.text = res.product_name;
+ arr.push(obj);
+ return obj;
+ });
+ setState({ rank: arr });
+ };
+
+ const onRankChange = (e) => {
+ let new_table_data = state.tableData.map((item) => {
+ item.checked =
+ e.findIndex((checks) => {
+ return checks.key === item;
+ }) > -1;
+ return item;
+ });
+ setState({ tableData: new_table_data, rank: e });
+ };
+
+ // 优惠券弹窗 提交
+ const scopePopSubmit = (data) => {
+ try {
+ // 格式化表格数据
+ let data_new = data;
+ let new_table = state.tableData;
+
+ // 判断是否是编辑 商品
+ if (data_new.goods_type === 1) {
+ let el_index = new_table.findIndex(
+ (item) => item.product_id === data_new.product_id
+ );
+ if (el_index !== -1) {
+ new_table[el_index] = data_new;
+ } else {
+ new_table.push(data_new);
+ }
+ }
+
+ // 立减金
+ if (data_new.goods_type === 2) {
+ let el_index = new_table.findIndex(
+ (item) =>
+ item.channel_activity_id === data_new.only.channel_activity_id
+ );
+ if (el_index !== -1) {
+ new_table[el_index] = data_new;
+ } else {
+ new_table.push(data_new);
+ }
+ }
+
+ console.log("所有数据 =>", new_table);
+
+ // 设置商品范围选择
+ let select_opt = [];
+ new_table.map((item) => {
+ let obj = {};
+ obj.key = item; // 确保差异
+ obj.text = item.product_name;
+ select_opt.push(obj);
+ });
+
+ // 格式化商品范围
+ setState({
+ tableData: new_table,
+ rankoptions: select_opt,
+ });
+ } catch (err) {
+ console.log("err =>", err);
+ }
+ };
+
+ // 商品范围删除
+ const deleteGoodsScope = (index) => {
+ let new_table = state.tableData;
+ if (index === 0) {
+ new_table = [];
+ } else {
+ new_table = new_table.splice(index, 1);
+ }
+ let select_opt = [];
+ new_table.map((item) => {
+ let obj = {};
+ obj.key = item; // 确保差异
+ obj.text = item.product_name;
+ select_opt.push(obj);
+ });
+ selectionFun(new_table);
+ setState({
+ tableData: new_table,
+ rankoptions: select_opt,
+ });
+ };
+
+ return (
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ onPageChange(e)}
+ emptyText={
+ state.lodgingTable
+ ? "抱歉,暂无相关数据记录"
+ : "查询 请输入【分销商】或【计划名称】或【key】进行查询"
+ }
+ countChange={(e) => onCountChange(e)}
+ checkChange={(data) => selectionFun(data)}
+ ComponentHandler={(com, rowData, rowIndex) => {
+ if (com === "opearo") {
+ return (
+
+ productEditShow(rowData)}
+ >
+ 编辑
+
+ deleteGoodsScope(rowIndex)}
+ >
+ 删除
+
+
+ );
+ }
+
+ if (com === "goods_type") {
+ return (
+ {rowData.goods_type === 1 ? "商品" : "立减金"}
+ );
+ }
+ }}
+ />
+
+
+
+ {isAuditButton ? (
+
+
+
+
+ ) : null}
+
+
scopePopClose()}
+ submit={(data) => scopePopSubmit(data)}
+ >
+
+ );
+});
+
+export default UseCouponAddEdit;
diff --git a/src/components/UseCouponAddEdit/index copy 3.jsx b/src/components/UseCouponAddEdit/index copy 3.jsx
new file mode 100644
index 00000000..1560fe63
--- /dev/null
+++ b/src/components/UseCouponAddEdit/index copy 3.jsx
@@ -0,0 +1,795 @@
+import React, {
+ forwardRef,
+ useImperativeHandle,
+ useRef,
+ useEffect,
+} from "react";
+import { useSetState } from "ahooks";
+import { FixedSizeList } from "react-window";
+import {
+ Card,
+ DateRangePicker,
+ Button,
+ Select,
+ Notify,
+ BlockLoading,
+} from "zent";
+import moment from "moment";
+import _ from "lodash";
+
+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 UseGoodsScopePop from "../UseGoodsScopePop/index";
+import { isAmount } from "@/tools/validate";
+
+import { getProductInfoSelect, handelResponse } from "@/assets/api.js";
+import { mulNum } from "@/tools/number";
+import "./style.less";
+
+const tableColumn = [
+ {
+ title: "商品编号",
+ name: "product_id",
+ prop: "product_id",
+ type: "normal",
+ width: "auto",
+ },
+ {
+ title: "商品名称",
+ name: "product_name",
+ prop: "product_name",
+ type: "normal",
+ width: "auto",
+ },
+ {
+ title: "官方价",
+ name: "official_price",
+ prop: "official_price",
+ type: "normal",
+ width: "auto",
+ },
+ {
+ title: "合同单价",
+ name: "contract_price",
+ prop: "contract_price",
+ type: "normal",
+ width: "auto",
+ },
+ {
+ title: "库存数量",
+ name: "quantity",
+ prop: "quantity",
+ type: "normal",
+ width: "auto",
+ },
+ {
+ title: "批次号",
+ name: "channel_activity_id",
+ prop: "channel_activity_id",
+ type: "normal",
+ width: "auto",
+ },
+ {
+ title: "总预算",
+ name: "all_budget",
+ prop: "all_budget",
+ type: "normal",
+ width: "auto",
+ },
+ {
+ title: "有效时间段",
+ name: "effectDate",
+ prop: "effectDate",
+ type: "normal",
+ width: "auto",
+ },
+ {
+ title: "创建时间",
+ name: "createDate",
+ prop: "createDate",
+ type: "normal",
+ width: "auto",
+ },
+ {
+ title: "类型",
+ name: "goods_type",
+ prop: "goods_type",
+ type: "slot",
+ width: "auto",
+ },
+ {
+ title: "上游平台",
+ name: "upstream",
+ prop: "upstream",
+ type: "normal",
+ width: "auto",
+ },
+ {
+ title: "操作",
+ name: "opearo",
+ prop: "opearo",
+ type: "slot",
+ width: "200px",
+ },
+];
+
+const info_rules = {
+ plan_id: [{ type: "required", message: "请选择归属计划" }],
+ key_batch_id: [{ type: "required", message: "请选择归属key" }],
+ name: [{ type: "required", message: "请输入批次名称" }],
+ date_time: [{ type: "required", message: "请选择时间" }],
+};
+
+const rule_rules = {
+ full: [
+ { type: "required", message: "请输入面额" },
+ {
+ type: "regExp",
+ message: "请输入两位小数",
+ reg: "^[0-9][0-9]*([.][0-9]{1,2})?$",
+ },
+ ],
+ restrict: [
+ { type: "required", message: "请输入发放总量" },
+ {
+ type: "regExp",
+ message: "请输入正整数",
+ reg: "^[1-9]*$",
+ },
+ ],
+};
+
+const UseCouponAddEdit = forwardRef((props, ref) => {
+ const { type = 0, isAuditButton = true, isCopy = false } = props; // type 入口类型 0优惠券新增 1计划、key批次 (是否显示两个字段)
+
+ useEffect(() => {
+ if (type === 0) {
+ delete info_rules.plan_id;
+ delete info_rules.key_batch_id;
+ } else {
+ info_rules.plan_id = [{ type: "required", message: "请选择归属计划" }];
+ info_rules.key_batch_id = [
+ { type: "required", message: "请选择归属key" },
+ ];
+ }
+ }, []);
+
+ const [state, setState] = useSetState({
+ setup1_title: "基本信息",
+ setup2_title: "发放规则",
+ setup3_title: "商品范围",
+ time_disabled: false,
+ tableData: [],
+ tableHeight: 500,
+ page: 1,
+ dataCount: 0,
+ rankoptions: [],
+ rank: [],
+ newGoodsBtnLoading: false,
+ newGoldLoading: false,
+ lodgingTable: true,
+ isRestrict: true,
+ plan_OPTIONS: [
+ {
+ key: "1",
+ text: `plan 1`,
+ },
+ {
+ key: "2",
+ text: `plan 2`,
+ },
+ ],
+ key_OPTIONS: [
+ {
+ key: 2,
+ text: `key 1`,
+ },
+ ],
+ addProductBtnLoading: false,
+ addGoldBtnLoading: false,
+ product_title: "",
+ showScopePop: false,
+ scopePopType: "",
+ productData: {},
+ direct_reseller_id: 23329,
+ tableLoading: false,
+ });
+
+ // 基础信息
+ const [form_info_data, setForm_info_data] = useSetState({
+ plan_id: "",
+ key_batch_id: "",
+ name: "",
+ date_time: "",
+ });
+ const form_info_el = useRef(null);
+
+ // 发放规则
+ const [form_rule_data, setForm_rule_data] = useSetState({
+ full: "",
+ reduce: "",
+ restrict: "",
+ budget: "",
+ });
+ const form_rule_el = useRef(null);
+
+ // 设置发放总量是否可用
+ useEffect(() => {
+ setIsRestrict();
+ }, [form_rule_data.reduce, form_rule_data.full]);
+
+ // 计算发放总数
+ useEffect(() => {
+ setBudget();
+ }, [form_rule_data.reduce, form_rule_data.restrict]);
+
+ const table_el = useRef(null);
+
+ useImperativeHandle(ref, () => ({
+ submit: submit,
+ }));
+
+ const submit = () => {
+ // 基础信息
+ let el_setup1 = form_info_el.current.validator();
+ // console.log("el_setup1 =>", el_setup1);
+ // console.log("form_info_data =>", form_info_data);
+
+ // 发放规则
+ let el_setup2 = form_rule_el.current.validator();
+ // console.log("el_setup2 =>", el_setup2);
+
+ console.log("rank =>", state.rank);
+ };
+
+ const onReturn = () => {};
+ const onChangeCombinedDate = (e) => {
+ setForm_info_data({ date_time: e });
+ // 传入时间
+ sessionStorage.setItem(
+ "knockGold_effectDate",
+ JSON.stringify({
+ begin_time: e[0],
+ end_time: e[1],
+ })
+ );
+ };
+ 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 clearStorageData = () => {
+ if (state.tableData.length <= 0) {
+ sessionStorage.setItem("productData", "");
+ sessionStorage.setItem("knockGoldData", "");
+ }
+
+ // 新建商品
+ let product_data = state.tableData.filter((item) => item.goods_type === 1);
+ if (product_data.length <= 0) {
+ sessionStorage.setItem("productData", "");
+ } else {
+ sessionStorage.setItem("productData", JSON.stringify(product_data));
+ }
+
+ // 立减金
+ let knockGold_data = state.tableData.filter(
+ (item) => item.goods_type === 2
+ );
+ if (knockGold_data.length <= 0) {
+ sessionStorage.setItem("knockGoldData", "");
+ } else {
+ sessionStorage.setItem("knockGoldData", JSON.stringify(knockGold_data));
+ }
+ };
+
+ const addProduct = (type) => {
+ try {
+ // 第一步:获取直连天下的商品数据需要分销商 id
+ const direct_reseller_ids = state.direct_reseller_id;
+ if (direct_reseller_ids <= 0) {
+ Notify.error(`请添加映射分销商`);
+ return;
+ }
+ // 第二步:清除本地存储数据
+ clearStorageData();
+
+ // 第三步: 区分是新建商品还是立减金
+ if (type === "addProduct") {
+ setState({
+ product_title: "新建商品",
+ addProductBtnLoading: true,
+ scopePopType: "addProduct",
+ });
+ } else {
+ setState({
+ product_title: "新增立减金",
+ addGoldBtnLoading: true,
+ scopePopType: "addKnockGold",
+ });
+ }
+
+ // 第四步:获取商品数据
+ let param = {
+ reseller_id: direct_reseller_ids,
+ };
+ getProductInfoSelect(param).then((res) => {
+ setState({ addProductBtnLoading: false, addGoldBtnLoading: false });
+ handelResponse(
+ res,
+ (req, msg) => {
+ // !!!!!!!!!!!!!! 为了兼容老版本 新增商品设为空!!!老版本使用 productsList 获取商品数据!!!!!!!!!!
+ sessionStorage.setItem("productsList", JSON.stringify(req.data));
+ // !!!!!!!!!!!!!! 为了兼容老版本 新增商品设为空!!!老版本使用 productsList 获取商品数据!!!!!!!!!!
+ setState({ productData: null });
+ setState({
+ showScopePop: true,
+ });
+ },
+ (err) => {
+ console.log("err =>", err);
+ }
+ );
+ });
+ } catch (err) {
+ setState({ addProductBtnLoading: false, addGoldBtnLoading: false });
+ }
+ };
+
+ // 编辑
+ const productEditShow = (rowData) => {
+ try {
+ // 第一步:获取直连天下的商品数据需要分销商 id
+ const direct_reseller_ids = state.direct_reseller_id;
+ if (direct_reseller_ids <= 0) {
+ Notify.error(`请添加映射分销商`);
+ return;
+ }
+ setState({
+ tableLoading: true,
+ });
+ // 第二步:获取商品数据
+ let param = {
+ reseller_id: direct_reseller_ids,
+ };
+ getProductInfoSelect(param).then((res) => {
+ setState({ tableLoading: false });
+ handelResponse(
+ res,
+ (req, msg) => {
+ // 设置所有的商品数据
+ sessionStorage.setItem("productsList", JSON.stringify(req.data));
+ /* 区分立减金 */
+ if (rowData.goods_type === 2) {
+ let obj = rowData.only;
+ setState({
+ product_title: "编辑立减金",
+ productData: obj,
+ addIsType: "addKnockGold",
+ showScopePop: true,
+ });
+ } else {
+ setState({
+ product_title: "编辑商品",
+ productData: rowData,
+ addIsType: "addProduct",
+ showScopePop: true,
+ });
+ }
+ },
+ (err) => {
+ console.log("err =>", err);
+ }
+ );
+ });
+ } catch (err) {
+ setState({ tableLoading: false });
+ console.log("err =>", err);
+ }
+ };
+
+ const renderOptionList = (options, renderOption) => {
+ return (
+
+ {({ index, style }) => (
+ {renderOption(options[index], index)}
+ )}
+
+ );
+ };
+
+ // 判断是否可用
+ const setIsRestrict = () => {
+ if (isAmount(form_rule_data.reduce) && isAmount(form_rule_data.full)) {
+ setState({ isRestrict: false });
+ } else {
+ setState({ isRestrict: true });
+ }
+ };
+
+ // 计算总预算
+ const setBudget = () => {
+ if (isAmount(form_rule_data.reduce) && isAmount(form_rule_data.restrict)) {
+ let num = mulNum(
+ Number(form_rule_data.reduce),
+ Number(form_rule_data.restrict)
+ );
+ setForm_rule_data({
+ budget: num,
+ });
+ } else {
+ setForm_rule_data({
+ budget: "",
+ });
+ }
+ };
+
+ // 优惠券弹窗 取消
+ const scopePopClose = () => {
+ setState({
+ showScopePop: false,
+ });
+ };
+
+ const selectionFun = (e) => {
+ let arr = [];
+ _.map(e, (res) => {
+ let obj = {};
+ obj.key = res.product_id;
+ obj.text = res.product_name;
+ arr.push(obj);
+ return obj;
+ });
+ setState({ rank: arr });
+ };
+
+ const onRankChange = (e) => {
+ let new_table_data = state.tableData.map((item) => {
+ console.log("item =>", item);
+ item.checked =
+ e.findIndex((checks) => {
+ return checks.key == item.product_id;
+ }) > -1;
+ return item;
+ });
+ setState({ tableData: new_table_data, rank: e });
+ };
+
+ // 优惠券弹窗 提交
+ const scopePopSubmit = (table_all) => {
+ try {
+ // 格式化表格数据
+ let new_table = table_all;
+ console.log("所有数据 =>", new_table);
+ // 设置商品范围选择
+ let select_opt = [];
+ new_table.map((item) => {
+ let obj = {};
+ obj.key = item.product_id; // 确保差异
+ obj.text = item.product_name;
+ select_opt.push(obj);
+ });
+ console.log("select_opt =>", select_opt);
+
+ // 格式化商品范围
+ setState({
+ tableData: new_table,
+ rankoptions: select_opt,
+ });
+ } catch (err) {
+ console.log("err =>", err);
+ }
+ };
+
+ // 商品范围删除
+ const deleteGoodsScope = (index) => {
+ let new_table = state.tableData;
+ if (index === 0) {
+ new_table = [];
+ } else {
+ new_table = new_table.splice(index, 1);
+ }
+ let select_opt = [];
+ new_table.map((item) => {
+ let obj = {};
+ obj.key = item.product_id;
+ obj.text = item.product_name;
+ select_opt.push(obj);
+ });
+ selectionFun(new_table);
+ setState({
+ tableData: new_table,
+ rankoptions: select_opt,
+ });
+ };
+
+ return (
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ onPageChange(e)}
+ emptyText={
+ state.lodgingTable
+ ? "抱歉,暂无相关数据记录"
+ : "查询 请输入【分销商】或【计划名称】或【key】进行查询"
+ }
+ countChange={(e) => onCountChange(e)}
+ checkChange={(data) => selectionFun(data)}
+ ComponentHandler={(com, rowData, rowIndex) => {
+ if (com === "opearo") {
+ return (
+
+ productEditShow(rowData)}
+ >
+ 编辑
+
+ deleteGoodsScope(rowIndex)}
+ >
+ 删除
+
+
+ );
+ }
+
+ if (com === "goods_type") {
+ return (
+ {rowData.goods_type === 1 ? "商品" : "立减金"}
+ );
+ }
+ }}
+ />
+
+
+
+ {isAuditButton ? (
+
+
+
+
+ ) : null}
+
+
scopePopClose()}
+ tableData={state.tableData}
+ submit={(data) => scopePopSubmit(data)}
+ >
+
+ );
+});
+
+export default UseCouponAddEdit;
diff --git a/src/components/UseCouponAddEdit/index copy.jsx b/src/components/UseCouponAddEdit/index copy.jsx
index e6b64ca2..dbb5b582 100644
--- a/src/components/UseCouponAddEdit/index copy.jsx
+++ b/src/components/UseCouponAddEdit/index copy.jsx
@@ -6,21 +6,27 @@ import React, {
} from "react";
import { useSetState } from "ahooks";
import { FixedSizeList } from "react-window";
-import { Card, DateRangePicker, Button, Select, Notify } from "zent";
+import {
+ Card,
+ DateRangePicker,
+ Button,
+ Select,
+ Notify,
+ BlockLoading,
+} from "zent";
import moment from "moment";
+import _ from "lodash";
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 UseGoodsScopePop from "../UseGoodsScopePop/index";
-
import { isAmount } from "@/tools/validate";
import { getProductInfoSelect, handelResponse } from "@/assets/api.js";
import { mulNum } from "@/tools/number";
import "./style.less";
-import _ from "lodash";
const tableColumn = [
{
@@ -60,8 +66,8 @@ const tableColumn = [
},
{
title: "批次号",
- name: "key_batch_id",
- prop: "key_batch_id",
+ name: "channel_activity_id",
+ prop: "channel_activity_id",
type: "normal",
width: "auto",
},
@@ -136,7 +142,7 @@ const rule_rules = {
};
const UseCouponAddEdit = forwardRef((props, ref) => {
- const { type = 0, isAuditButton = true } = props; // type 入口类型 0优惠券新增 1计划、key批次 (是否显示两个字段)
+ const { type = 0, isAuditButton = true, isCopy = false } = props; // type 入口类型 0优惠券新增 1计划、key批次 (是否显示两个字段)
useEffect(() => {
if (type === 0) {
@@ -186,7 +192,9 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
product_title: "",
showScopePop: false,
scopePopType: "",
- productData: [],
+ productData: {},
+ direct_reseller_id: 23329,
+ tableLoading: false,
});
// 基础信息
@@ -232,7 +240,8 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
// 发放规则
let el_setup2 = form_rule_el.current.validator();
// console.log("el_setup2 =>", el_setup2);
- // console.log("发放规则 =>", form_rule_data);
+
+ console.log("rank =>", state.rank);
};
const onReturn = () => {};
@@ -289,7 +298,7 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
const addProduct = (type) => {
try {
// 第一步:获取直连天下的商品数据需要分销商 id
- const direct_reseller_ids = 23329;
+ const direct_reseller_ids = state.direct_reseller_id;
if (direct_reseller_ids <= 0) {
Notify.error(`请添加映射分销商`);
return;
@@ -323,6 +332,8 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
(req, msg) => {
// !!!!!!!!!!!!!! 为了兼容老版本 新增商品设为空!!!老版本使用 productsList 获取商品数据!!!!!!!!!!
sessionStorage.setItem("productsList", JSON.stringify(req.data));
+ // !!!!!!!!!!!!!! 为了兼容老版本 新增商品设为空!!!老版本使用 productsList 获取商品数据!!!!!!!!!!
+ setState({ productData: null });
setState({
showScopePop: true,
});
@@ -332,12 +343,63 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
}
);
});
- // !!!!!!!!!!!!!! 为了兼容老版本 新增商品设为空!!!老版本使用 productsList 获取商品数据!!!!!!!!!!
- setState({ productData: null });
} catch (err) {
setState({ addProductBtnLoading: false, addGoldBtnLoading: false });
}
};
+
+ // 编辑
+ const productEditShow = (rowData) => {
+ try {
+ // 第一步:获取直连天下的商品数据需要分销商 id
+ const direct_reseller_ids = state.direct_reseller_id;
+ if (direct_reseller_ids <= 0) {
+ Notify.error(`请添加映射分销商`);
+ return;
+ }
+ setState({
+ tableLoading: true,
+ });
+ // 第二步:获取商品数据
+ let param = {
+ reseller_id: direct_reseller_ids,
+ };
+ getProductInfoSelect(param).then((res) => {
+ setState({ tableLoading: false });
+ handelResponse(
+ res,
+ (req, msg) => {
+ // 设置所有的商品数据
+ sessionStorage.setItem("productsList", JSON.stringify(req.data));
+ /* 区分立减金 */
+ if (rowData.goods_type === 2) {
+ let obj = rowData.only;
+ setState({
+ product_title: "编辑立减金",
+ productData: obj,
+ addIsType: "addKnockGold",
+ showScopePop: true,
+ });
+ } else {
+ setState({
+ product_title: "编辑商品",
+ productData: rowData,
+ addIsType: "addProduct",
+ showScopePop: true,
+ });
+ }
+ },
+ (err) => {
+ console.log("err =>", err);
+ }
+ );
+ });
+ } catch (err) {
+ setState({ tableLoading: false });
+ console.log("err =>", err);
+ }
+ };
+
const renderOptionList = (options, renderOption) => {
return (
{
// 格式化表格数据
let data_new = data;
let new_table = state.tableData;
- new_table.push(data_new);
+
+ // 判断是否是编辑 商品
+ if (data_new.goods_type === 1) {
+ let el_index = new_table.findIndex(
+ (item) => item.product_id === data_new.product_id
+ );
+ if (el_index !== -1) {
+ new_table[el_index] = data_new;
+ } else {
+ new_table.push(data_new);
+ }
+ }
+
+ // 立减金
+ if (data_new.goods_type === 2) {
+ let el_index = new_table.findIndex(
+ (item) =>
+ item.channel_activity_id === data_new.only.channel_activity_id
+ );
+ if (el_index !== -1) {
+ new_table[el_index] = data_new;
+ } else {
+ new_table.push(data_new);
+ }
+ }
+
+ console.log("所有数据 =>", new_table);
+
// 设置商品范围选择
let select_opt = [];
new_table.map((item) => {
@@ -649,47 +738,60 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
- onPageChange(e)}
- emptyText={
- state.lodgingTable
- ? "抱歉,暂无相关数据记录"
- : "查询 请输入【分销商】或【计划名称】或【key】进行查询"
- }
- countChange={(e) => onCountChange(e)}
- checkChange={(data) => selectionFun(data)}
- ComponentHandler={(com, rowData, rowIndex) => {
- if (com === "opearo") {
- return (
-
- 编辑
- deleteGoodsScope(rowIndex)}
- >
- 删除
-
-
- );
+
+ onPageChange(e)}
+ emptyText={
+ state.lodgingTable
+ ? "抱歉,暂无相关数据记录"
+ : "查询 请输入【分销商】或【计划名称】或【key】进行查询"
}
+ countChange={(e) => onCountChange(e)}
+ checkChange={(data) => selectionFun(data)}
+ ComponentHandler={(com, rowData, rowIndex) => {
+ if (com === "opearo") {
+ return (
+
+ productEditShow(rowData)}
+ >
+ 编辑
+
+ deleteGoodsScope(rowIndex)}
+ >
+ 删除
+
+
+ );
+ }
- if (com === "goods_type") {
- return (
- {rowData.goods_type === 1 ? "商品" : "立减金"}
- );
- }
- }}
- />
+ if (com === "goods_type") {
+ return (
+ {rowData.goods_type === 1 ? "商品" : "立减金"}
+ );
+ }
+ }}
+ />
+
{isAuditButton ? (
diff --git a/src/components/UseCouponAddEdit/index.jsx b/src/components/UseCouponAddEdit/index.jsx
index e6b64ca2..1560fe63 100644
--- a/src/components/UseCouponAddEdit/index.jsx
+++ b/src/components/UseCouponAddEdit/index.jsx
@@ -6,21 +6,27 @@ import React, {
} from "react";
import { useSetState } from "ahooks";
import { FixedSizeList } from "react-window";
-import { Card, DateRangePicker, Button, Select, Notify } from "zent";
+import {
+ Card,
+ DateRangePicker,
+ Button,
+ Select,
+ Notify,
+ BlockLoading,
+} from "zent";
import moment from "moment";
+import _ from "lodash";
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 UseGoodsScopePop from "../UseGoodsScopePop/index";
-
import { isAmount } from "@/tools/validate";
import { getProductInfoSelect, handelResponse } from "@/assets/api.js";
import { mulNum } from "@/tools/number";
import "./style.less";
-import _ from "lodash";
const tableColumn = [
{
@@ -60,8 +66,8 @@ const tableColumn = [
},
{
title: "批次号",
- name: "key_batch_id",
- prop: "key_batch_id",
+ name: "channel_activity_id",
+ prop: "channel_activity_id",
type: "normal",
width: "auto",
},
@@ -136,7 +142,7 @@ const rule_rules = {
};
const UseCouponAddEdit = forwardRef((props, ref) => {
- const { type = 0, isAuditButton = true } = props; // type 入口类型 0优惠券新增 1计划、key批次 (是否显示两个字段)
+ const { type = 0, isAuditButton = true, isCopy = false } = props; // type 入口类型 0优惠券新增 1计划、key批次 (是否显示两个字段)
useEffect(() => {
if (type === 0) {
@@ -186,7 +192,9 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
product_title: "",
showScopePop: false,
scopePopType: "",
- productData: [],
+ productData: {},
+ direct_reseller_id: 23329,
+ tableLoading: false,
});
// 基础信息
@@ -232,7 +240,8 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
// 发放规则
let el_setup2 = form_rule_el.current.validator();
// console.log("el_setup2 =>", el_setup2);
- // console.log("发放规则 =>", form_rule_data);
+
+ console.log("rank =>", state.rank);
};
const onReturn = () => {};
@@ -289,7 +298,7 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
const addProduct = (type) => {
try {
// 第一步:获取直连天下的商品数据需要分销商 id
- const direct_reseller_ids = 23329;
+ const direct_reseller_ids = state.direct_reseller_id;
if (direct_reseller_ids <= 0) {
Notify.error(`请添加映射分销商`);
return;
@@ -323,6 +332,8 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
(req, msg) => {
// !!!!!!!!!!!!!! 为了兼容老版本 新增商品设为空!!!老版本使用 productsList 获取商品数据!!!!!!!!!!
sessionStorage.setItem("productsList", JSON.stringify(req.data));
+ // !!!!!!!!!!!!!! 为了兼容老版本 新增商品设为空!!!老版本使用 productsList 获取商品数据!!!!!!!!!!
+ setState({ productData: null });
setState({
showScopePop: true,
});
@@ -332,12 +343,63 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
}
);
});
- // !!!!!!!!!!!!!! 为了兼容老版本 新增商品设为空!!!老版本使用 productsList 获取商品数据!!!!!!!!!!
- setState({ productData: null });
} catch (err) {
setState({ addProductBtnLoading: false, addGoldBtnLoading: false });
}
};
+
+ // 编辑
+ const productEditShow = (rowData) => {
+ try {
+ // 第一步:获取直连天下的商品数据需要分销商 id
+ const direct_reseller_ids = state.direct_reseller_id;
+ if (direct_reseller_ids <= 0) {
+ Notify.error(`请添加映射分销商`);
+ return;
+ }
+ setState({
+ tableLoading: true,
+ });
+ // 第二步:获取商品数据
+ let param = {
+ reseller_id: direct_reseller_ids,
+ };
+ getProductInfoSelect(param).then((res) => {
+ setState({ tableLoading: false });
+ handelResponse(
+ res,
+ (req, msg) => {
+ // 设置所有的商品数据
+ sessionStorage.setItem("productsList", JSON.stringify(req.data));
+ /* 区分立减金 */
+ if (rowData.goods_type === 2) {
+ let obj = rowData.only;
+ setState({
+ product_title: "编辑立减金",
+ productData: obj,
+ addIsType: "addKnockGold",
+ showScopePop: true,
+ });
+ } else {
+ setState({
+ product_title: "编辑商品",
+ productData: rowData,
+ addIsType: "addProduct",
+ showScopePop: true,
+ });
+ }
+ },
+ (err) => {
+ console.log("err =>", err);
+ }
+ );
+ });
+ } catch (err) {
+ setState({ tableLoading: false });
+ console.log("err =>", err);
+ }
+ };
+
const renderOptionList = (options, renderOption) => {
return (
{
let arr = [];
_.map(e, (res) => {
let obj = {};
- obj.key = res;
+ obj.key = res.product_id;
obj.text = res.product_name;
arr.push(obj);
return obj;
@@ -400,9 +462,10 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
const onRankChange = (e) => {
let new_table_data = state.tableData.map((item) => {
+ console.log("item =>", item);
item.checked =
e.findIndex((checks) => {
- return checks.key === item;
+ return checks.key == item.product_id;
}) > -1;
return item;
});
@@ -410,20 +473,20 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
};
// 优惠券弹窗 提交
- const scopePopSubmit = (data) => {
+ const scopePopSubmit = (table_all) => {
try {
// 格式化表格数据
- let data_new = data;
- let new_table = state.tableData;
- new_table.push(data_new);
+ let new_table = table_all;
+ console.log("所有数据 =>", new_table);
// 设置商品范围选择
let select_opt = [];
new_table.map((item) => {
let obj = {};
- obj.key = item; // 确保差异
+ obj.key = item.product_id; // 确保差异
obj.text = item.product_name;
select_opt.push(obj);
});
+ console.log("select_opt =>", select_opt);
// 格式化商品范围
setState({
@@ -446,7 +509,7 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
let select_opt = [];
new_table.map((item) => {
let obj = {};
- obj.key = item; // 确保差异
+ obj.key = item.product_id;
obj.text = item.product_name;
select_opt.push(obj);
});
@@ -649,47 +712,60 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
- onPageChange(e)}
- emptyText={
- state.lodgingTable
- ? "抱歉,暂无相关数据记录"
- : "查询 请输入【分销商】或【计划名称】或【key】进行查询"
- }
- countChange={(e) => onCountChange(e)}
- checkChange={(data) => selectionFun(data)}
- ComponentHandler={(com, rowData, rowIndex) => {
- if (com === "opearo") {
- return (
-
- 编辑
- deleteGoodsScope(rowIndex)}
- >
- 删除
-
-
- );
+
+ onPageChange(e)}
+ emptyText={
+ state.lodgingTable
+ ? "抱歉,暂无相关数据记录"
+ : "查询 请输入【分销商】或【计划名称】或【key】进行查询"
}
+ countChange={(e) => onCountChange(e)}
+ checkChange={(data) => selectionFun(data)}
+ ComponentHandler={(com, rowData, rowIndex) => {
+ if (com === "opearo") {
+ return (
+
+ productEditShow(rowData)}
+ >
+ 编辑
+
+ deleteGoodsScope(rowIndex)}
+ >
+ 删除
+
+
+ );
+ }
- if (com === "goods_type") {
- return (
- {rowData.goods_type === 1 ? "商品" : "立减金"}
- );
- }
- }}
- />
+ if (com === "goods_type") {
+ return (
+ {rowData.goods_type === 1 ? "商品" : "立减金"}
+ );
+ }
+ }}
+ />
+
{isAuditButton ? (
@@ -709,6 +785,7 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
type={state.scopePopType}
productData={state.productData}
onClose={() => scopePopClose()}
+ tableData={state.tableData}
submit={(data) => scopePopSubmit(data)}
>
diff --git a/src/components/UseGoodsScopePop/index copy 2.jsx b/src/components/UseGoodsScopePop/index copy 2.jsx
new file mode 100644
index 00000000..6f3fe8a0
--- /dev/null
+++ b/src/components/UseGoodsScopePop/index copy 2.jsx
@@ -0,0 +1,143 @@
+import React, { forwardRef, useImperativeHandle, useRef } from "react";
+import { Card, Drawer, Button } from "zent";
+
+import Productform from "@/pages/plan/product/add"; /* 商品 */
+import KnockGold from "@/components/knockGold"; /* 立减金 */
+
+const UseGoodsScopePop = forwardRef((props, ref) => {
+ const {
+ product_title,
+ drawerVisible,
+ onClose,
+ type,
+ productData,
+ submit,
+ tableData,
+ } = props;
+
+ // 如果需要 通过ref 控制此组件 放开注释
+ // useImperativeHandle(ref, () => ({
+ // submit: submitPop,
+ // }));
+
+ const product_el = useRef(null);
+ const knockGold_el = useRef(null);
+
+ // 新建商品数据处理
+ const format_product_model = () => {
+ // 是编辑还是新增
+
+ // 新增
+ let form_model = product_el.current.state.model;
+ form_model.goods_type = 1;
+ form_model.upstream = "直连天下";
+ form_model.all_budget =
+ Number(form_model.contract_price) * Number(form_model.quantity);
+ form_model.effectDate = "-";
+
+ let new_tableData = tableData;
+ new_tableData.push(form_model);
+
+ return new_tableData;
+ };
+
+ // 立减金数据处理
+ const format_knockGold_model = () => {
+ let channel_activity_id =
+ knockGold_el.current.state.model.channel_activity_id;
+ let form_data_arr = JSON.parse(sessionStorage.getItem("knockGoldData"));
+ let table_obj = {};
+ let form_model = form_data_arr.find(
+ (item) => item.channel_activity_id === channel_activity_id
+ );
+ if (form_model) {
+ table_obj.only = form_model; // 存储就数据 编辑好用
+ table_obj.product_id = channel_activity_id; // 商品编号
+ table_obj.product_name = form_model.batch_goods_name; // 商品名
+ table_obj.official_price = form_model.reduce_amount; // 官方价
+ table_obj.contract_price = form_model.price; // 合同价格
+ table_obj.quantity = Math.trunc(
+ form_model.all_budget / form_model.reduce_amount
+ ); // 库存数量
+ table_obj.channel_activity_id = form_model.channel_activity_id; // 批次号
+ table_obj.all_budget = Number(form_model.all_budget); // 总预算
+ table_obj.effectDate = `${form_model.time_limit.effect_time.end_time} 至 ${form_model.time_limit.effect_time.start_time}`; // 有效时间段
+ table_obj.createDate = ""; // 创建时间
+ table_obj.goods_type = 2; // 类型
+ table_obj.upstream =
+ String(form_model.channel) === "1" ? "支付宝" : "微信"; // 上游平台
+ // 格式化字段 适配table显示
+ return table_obj;
+ }
+ };
+
+ // 提交数据
+ const submitPop = async () => {
+ try {
+ // 第一步:判断是立减金还是新建商品
+ let visible = false;
+ if (type === "addProduct") {
+ visible = await product_el.current.submit();
+ } else {
+ visible = await knockGold_el.current.submit();
+ }
+ if (visible) {
+ // 第二步:获取商品或者立减金的数据 并格式化为table一样的字段 以商品数据为准 合并
+ let form_data = {};
+ if (type === "addProduct") {
+ form_data = format_product_model();
+ } else {
+ form_data = format_knockGold_model();
+ }
+ console.log("form_data 1=>", form_data);
+ submit(form_data);
+ onClose();
+ }
+ } catch (err) {
+ console.log("err =>", err);
+ }
+ };
+
+ return (
+
+
+
+
+ }
+ visible={drawerVisible}
+ onClose={(e) => onClose()}
+ maskClosable={false}
+ >
+
+
+ {type === "addKnockGold" ? (
+
+ ) : (
+
+ )}
+
+
+
+ );
+});
+
+export default UseGoodsScopePop;
diff --git a/src/components/UseGoodsScopePop/index copy.jsx b/src/components/UseGoodsScopePop/index copy.jsx
index 107552b1..1e623767 100644
--- a/src/components/UseGoodsScopePop/index copy.jsx
+++ b/src/components/UseGoodsScopePop/index copy.jsx
@@ -1,17 +1,15 @@
import React, { forwardRef, useImperativeHandle, useRef } from "react";
import { Card, Drawer, Button } from "zent";
-import { deWeightThree } from "@/utils";
-
import Productform from "@/pages/plan/product/add"; /* 商品 */
import KnockGold from "@/components/knockGold"; /* 立减金 */
-import _ from "lodash";
-
const UseGoodsScopePop = forwardRef((props, ref) => {
const { product_title, drawerVisible, onClose, type, productData, submit } =
props;
+ console.log("productData =>", productData);
+
// 如果需要 通过ref 控制此组件 放开注释
// useImperativeHandle(ref, () => ({
// submit: submitPop,
@@ -20,27 +18,67 @@ const UseGoodsScopePop = forwardRef((props, ref) => {
const product_el = useRef(null);
const knockGold_el = useRef(null);
+ // 新建商品数据处理
+ const format_product_model = () => {
+ let form_model = product_el.current.state.model;
+ form_model.goods_type = 1;
+ form_model.upstream = "直连天下";
+ form_model.all_budget =
+ Number(form_model.contract_price) * Number(form_model.quantity);
+ form_model.effectDate = "-";
+ return form_model;
+ };
+
+ // 立减金数据处理
+ const format_knockGold_model = () => {
+ let channel_activity_id =
+ knockGold_el.current.state.model.channel_activity_id;
+ let form_data_arr = JSON.parse(sessionStorage.getItem("knockGoldData"));
+ let table_obj = {};
+ let form_model = form_data_arr.find(
+ (item) => item.channel_activity_id === channel_activity_id
+ );
+ if (form_model) {
+ table_obj.only = form_model; // 存储就数据 编辑好用
+ table_obj.product_id = "-"; // 商品编号
+ table_obj.product_name = form_model.batch_goods_name; // 商品名
+ table_obj.official_price = form_model.reduce_amount; // 官方价
+ table_obj.contract_price = form_model.price; // 合同价格
+ table_obj.quantity = Math.trunc(
+ form_model.all_budget / form_model.reduce_amount
+ ); // 库存数量
+ table_obj.channel_activity_id = form_model.channel_activity_id; // 批次号
+ table_obj.all_budget = Number(form_model.all_budget); // 总预算
+ table_obj.effectDate = `${form_model.time_limit.effect_time.end_time} 至 ${form_model.time_limit.effect_time.start_time}`; // 有效时间段
+ table_obj.createDate = ""; // 创建时间
+ table_obj.goods_type = 2; // 类型
+ table_obj.upstream =
+ String(form_model.channel) === "1" ? "支付宝" : "微信"; // 上游平台
+ // 格式化字段 适配table显示
+ return table_obj;
+ }
+ };
+
// 提交数据
const submitPop = async () => {
- let scope_table_data = [];
- // 第一步:判断是立减金还是新建商品
- let visible = false;
- if (type === "addProduct") {
- visible = await product_el.current.submit();
- } else {
- visible = await knockGold_el.current.submit();
- }
try {
+ // 第一步:判断是立减金还是新建商品
+ let visible = false;
+ if (type === "addProduct") {
+ visible = await product_el.current.submit();
+ } else {
+ visible = await knockGold_el.current.submit();
+ }
if (visible) {
- let a1 = product_el.current.state.model;
- console.log("a1 =>", a1);
- // 第二步:数据格式化
- scope_table_data = sessionStorage.getItem("productData");
- if (scope_table_data) {
- scope_table_data = JSON.parse(scope_table_data);
+ // 第二步:获取商品或者立减金的数据 并格式化为table一样的字段 以商品数据为准
+ let form_data = {};
+ if (type === "addProduct") {
+ form_data = format_product_model();
+ } else {
+ form_data = format_knockGold_model();
}
- console.log("所有数据:", scope_table_data);
- submit(scope_table_data);
+ console.log("form_data 1=>", form_data);
+ submit(form_data);
onClose();
}
} catch (err) {
diff --git a/src/components/UseGoodsScopePop/index.jsx b/src/components/UseGoodsScopePop/index.jsx
index bd9240a8..6f3fe8a0 100644
--- a/src/components/UseGoodsScopePop/index.jsx
+++ b/src/components/UseGoodsScopePop/index.jsx
@@ -5,8 +5,15 @@ import Productform from "@/pages/plan/product/add"; /* 商品 */
import KnockGold from "@/components/knockGold"; /* 立减金 */
const UseGoodsScopePop = forwardRef((props, ref) => {
- const { product_title, drawerVisible, onClose, type, productData, submit } =
- props;
+ const {
+ product_title,
+ drawerVisible,
+ onClose,
+ type,
+ productData,
+ submit,
+ tableData,
+ } = props;
// 如果需要 通过ref 控制此组件 放开注释
// useImperativeHandle(ref, () => ({
@@ -18,36 +25,50 @@ const UseGoodsScopePop = forwardRef((props, ref) => {
// 新建商品数据处理
const format_product_model = () => {
+ // 是编辑还是新增
+
+ // 新增
let form_model = product_el.current.state.model;
form_model.goods_type = 1;
form_model.upstream = "直连天下";
form_model.all_budget =
Number(form_model.contract_price) * Number(form_model.quantity);
form_model.effectDate = "-";
- return form_model;
+
+ let new_tableData = tableData;
+ new_tableData.push(form_model);
+
+ return new_tableData;
};
// 立减金数据处理
const format_knockGold_model = () => {
- let form_model = knockGold_el.current.state.model;
+ let channel_activity_id =
+ knockGold_el.current.state.model.channel_activity_id;
+ let form_data_arr = JSON.parse(sessionStorage.getItem("knockGoldData"));
let table_obj = {};
- table_obj.only = form_model; // 存储就数据 编辑好用
-
- table_obj.product_id = "-"; // 商品编号
- table_obj.product_name = form_model.batch_goods_name; // 商品名
- table_obj.official_price = form_model.reduce_amount; // 官方价
- table_obj.contract_price = form_model.price; // 合同价格
- table_obj.quantity = Math.trunc(
- form_model.all_budget / form_model.reduce_amount
- ); // 库存数量
- table_obj.key_batch_id = form_model.channel_activity_id; // 批次号
- table_obj.all_budget = Number(form_model.all_budget); // 总预算
- table_obj.effectDate = form_model.entry_time; // 有效时间段
- table_obj.createDate = ""; // 创建时间
- table_obj.goods_type = 2; // 类型
- table_obj.upstream = String(form_model.channel) === "1" ? "支付宝" : "微信"; // 上游平台
- // 格式化字段 适配table显示
- return table_obj;
+ let form_model = form_data_arr.find(
+ (item) => item.channel_activity_id === channel_activity_id
+ );
+ if (form_model) {
+ table_obj.only = form_model; // 存储就数据 编辑好用
+ table_obj.product_id = channel_activity_id; // 商品编号
+ table_obj.product_name = form_model.batch_goods_name; // 商品名
+ table_obj.official_price = form_model.reduce_amount; // 官方价
+ table_obj.contract_price = form_model.price; // 合同价格
+ table_obj.quantity = Math.trunc(
+ form_model.all_budget / form_model.reduce_amount
+ ); // 库存数量
+ table_obj.channel_activity_id = form_model.channel_activity_id; // 批次号
+ table_obj.all_budget = Number(form_model.all_budget); // 总预算
+ table_obj.effectDate = `${form_model.time_limit.effect_time.end_time} 至 ${form_model.time_limit.effect_time.start_time}`; // 有效时间段
+ table_obj.createDate = ""; // 创建时间
+ table_obj.goods_type = 2; // 类型
+ table_obj.upstream =
+ String(form_model.channel) === "1" ? "支付宝" : "微信"; // 上游平台
+ // 格式化字段 适配table显示
+ return table_obj;
+ }
};
// 提交数据
@@ -61,7 +82,7 @@ const UseGoodsScopePop = forwardRef((props, ref) => {
visible = await knockGold_el.current.submit();
}
if (visible) {
- // 第二步:获取商品或者立减金的数据 并格式化为table一样的字段 以商品数据为准
+ // 第二步:获取商品或者立减金的数据 并格式化为table一样的字段 以商品数据为准 合并
let form_data = {};
if (type === "addProduct") {
form_data = format_product_model();
diff --git a/src/components/knockGold/index.jsx b/src/components/knockGold/index.jsx
index 175a2f9f..932e9867 100644
--- a/src/components/knockGold/index.jsx
+++ b/src/components/knockGold/index.jsx
@@ -1,13 +1,13 @@
/* 新增商品 */
-import { Component } from "react"
-import "./index.less"
-import Ipt from "@/components/input/main"
-import Form from "@/components/form/main"
-import FormItem from "@/components/form-item/main"
-import rules from "./rules"
-import moment from "moment"
-import { deWeightThree, timeDiff } from "@/utils"
-import { isSameDay } from "date-fns"
+import { Component } from "react";
+import "./index.less";
+import Ipt from "@/components/input/main";
+import Form from "@/components/form/main";
+import FormItem from "@/components/form-item/main";
+import rules from "./rules";
+import moment from "moment";
+import { deWeightThree, timeDiff } from "@/utils";
+import { isSameDay } from "date-fns";
import {
Select,
Button,
@@ -21,34 +21,34 @@ import {
Dialog,
Notify,
Tag,
- TimeRangePicker
-} from "zent"
-import _, { isArray } from "lodash"
-import { getVoucherWarningAccount, handelResponse } from "@/assets/api"
-import AddNewDialog from "./Dialog"
-import MobileComponent from "./mobileComponent"
-import WangEditor from "./wangEditor"
+ TimeRangePicker,
+} from "zent";
+import _, { isArray } from "lodash";
+import { getVoucherWarningAccount, handelResponse } from "@/assets/api";
+import AddNewDialog from "./Dialog";
+import MobileComponent from "./mobileComponent";
+import WangEditor from "./wangEditor";
const cardTypeList = [
{ key: "1", text: "借记卡" },
- { key: "2", text: "信用卡" }
-]
+ { key: "2", text: "信用卡" },
+];
const defaultInstructionWx = `1、立减金自领取之日起30天有效,请在有效期内使用
2、微信立减金自领取后每个立减金一次性使用,不兑换,不找零,到期后自动失效,逾期未使用不再补发。使用微信支付进行付款(大于立减金面额0.01元以上)即可自动抵扣
3、多张立减金可在单笔微信支付订单中一起使用,但当用户的立减金超过8张时,系统会选取其中一部分使用,不保证在一张订单中全部使用
4、在中国境内商户使用微信支付即可使用,少数特定商户(包括但不限于:CoCo奶茶、优衣库、星巴克、肯德基、必胜客、同程艺龙、热风、太平鸟、孩子王、航联保险、华为商城、Miss Sixty、Ochirly、Apple商城、FivePlus、信用卡还款、零钱通、理财通等)、以及社交支付(如转账、红包、个人收款码支付等)及合单支付(微信支付订单号为44开头的交易)无法使用立减金'
-
5、使用立减金的微信支付订单,如发生全额退款,且立减金仍在有效期内,立减金将自动退还给用户,如立减金已过期,则不退还给用户;如发生部分退款,用户支付金额将按比例原路退还,立减金将不退还给用户`
+
5、使用立减金的微信支付订单,如发生全额退款,且立减金仍在有效期内,立减金将自动退还给用户,如立减金已过期,则不退还给用户;如发生部分退款,用户支付金额将按比例原路退还,立减金将不退还给用户`;
const defaultInstructionZfb = `1、立减金自领取之日起7天有效,请在有效期内使用
2、支付宝立减金自领取后每个立减金一次性使用,不兑换、不找零,到期后自动失效,逾期未使用不再补发。使用支付宝支付进行付款(大于立减金面额0.01元以上)即可自动抵扣
3、多张立减金可在单笔支付宝支付订单中一起使用,但当用户的立减金超过8张时,系统会选取其中一部分使用,不保证在一张订单中全部使用
-
4、使用立减金的支付宝支付订单,如发生全额退款,且立减金仍在有效期内,立减金将自动退还给用户,如立减金已过期,则不退还给用户;如发生部分退款,用户支付金额将按比例原路退还,立减金将不退还给用户`
+
4、使用立减金的支付宝支付订单,如发生全额退款,且立减金仍在有效期内,立减金将自动退还给用户,如立减金已过期,则不退还给用户;如发生部分退款,用户支付金额将按比例原路退还,立减金将不退还给用户`;
const receiveTypeList = [
{ key: "all", text: "总共" },
{ key: "month", text: "每月" },
{ key: "week", text: "每周" },
- { key: "day", text: "每天" }
-]
+ { key: "day", text: "每天" },
+];
const week = [
{ key: "Mon", text: "周一" },
@@ -57,17 +57,17 @@ const week = [
{ key: "Thu", text: "周四" },
{ key: "Fri", text: "周五" },
{ key: "Sat", text: "周六" },
- { key: "Sun", text: "周日" }
-]
+ { key: "Sun", text: "周日" },
+];
//预警百分比
-const earlyPerList = ["70", "50", "30", "20"]
+const earlyPerList = ["70", "50", "30", "20"];
const initArray = (targetNum) => {
- return Array.from({ length: targetNum }, (_, index) => index)
-}
+ return Array.from({ length: targetNum }, (_, index) => index);
+};
export default class addKnockGold extends Component {
constructor(props) {
- super(props)
+ super(props);
this.state = {
model: {
channel: "1", // 渠道
@@ -99,7 +99,7 @@ export default class addKnockGold extends Component {
irregularDate: [[]], //不规则日期
irregularTime: [[]], //不规则时间
ruleDate: [[]], //规则日期
- ruleWeek: [] //规则周
+ ruleWeek: [], //规则周
},
TimeDiffer: "",
visible: false, //加框弹窗
@@ -109,126 +109,129 @@ export default class addKnockGold extends Component {
{
key: "0",
text: "立即生效",
- disabled: false
+ disabled: false,
},
{
key: "1",
text: "次日生效",
- disabled: false
- }
+ disabled: false,
+ },
],
//预警人数据
- userSelectList: []
- }
+ userSelectList: [],
+ };
}
componentWillMount() {
/* 此处解决 日期组件不回显问题 提前触发 */
if (this.props.data) {
- let model = this.state.model
- model.entry_time[0] = this.props.data.time_limit.effect_time.start_time
- model.entry_time[1] = this.props.data.time_limit.effect_time.end_time
- model.instruction = this.props.data.instruction
+ let model = this.state.model;
+ console.log("立减金 =>", model);
+ model.entry_time[0] = this.props.data.time_limit.effect_time.start_time;
+ model.entry_time[1] = this.props.data.time_limit.effect_time.end_time;
+ model.instruction = this.props.data.instruction;
model.fixed_time[0] =
- this.props.data.time_limit.use_time.fiexd_time?.start_time
+ this.props.data.time_limit.use_time.fiexd_time?.start_time;
model.fixed_time[1] =
- this.props.data.time_limit.use_time.fiexd_time?.end_time
+ this.props.data.time_limit.use_time.fiexd_time?.end_time;
if (this.props.data.time_limit.use_time.type === "week") {
- model.ruleWeek = this.props.data.time_limit.use_time?.week
- model.ruleDate = this.props.data.time_limit.use_time?.time
+ model.ruleWeek = this.props.data.time_limit.use_time?.week;
+ model.ruleDate = this.props.data.time_limit.use_time?.time;
}
if (this.props.data.time_limit.use_time.type === "irregular") {
- model.irregularDate = this.props.data.time_limit.use_time?.day
- model.irregularTime = this.props.data.time_limit.use_time?.time
+ model.irregularDate = this.props.data.time_limit.use_time?.day;
+ model.irregularTime = this.props.data.time_limit.use_time?.time;
}
- this.setState({ model: model })
+ this.setState({ model: model });
}
- this.getUserSelectList()
- this.getTimeDiff()
+ this.getUserSelectList();
+ this.getTimeDiff();
}
/* 可用时间段 添加和删除组件控制*/
addOrMoveFunction(index, key, valueKey, isLimit, err) {
- if (this.props?.data?.id ? true : false) return
+ if (this.props?.data?.id ? true : false) return;
return (
<>
{index !== 0 ? (
{
- const model = valueKey
- model.splice(index, 1)
- this.setState({ [key]: model })
- }}>
+ const model = valueKey;
+ model.splice(index, 1);
+ this.setState({ [key]: model });
+ }}
+ >
删除
) : null}
{index === valueKey.length - 1 ? (
{
if (isLimit || valueKey.length < 3) {
- const model = valueKey
- model.push([])
- this.setState({ [key]: model })
+ const model = valueKey;
+ model.push([]);
+ this.setState({ [key]: model });
} else {
- if (err) Notify.warn(err)
+ if (err) Notify.warn(err);
}
- }}>
+ }}
+ >
添加
) : null}
>
- )
+ );
}
/* 编辑回显 */
echoFun(UserSelectList) {
if (this.props.data) {
- let model = this.state.model
+ let model = this.state.model;
for (let key in this.props.data) {
- model[key] = this.props.data[key]
+ model[key] = this.props.data[key];
}
- model.weight = String(this.props.data.weight)
- model.early_per = this.props.data.early_per.map((item) => String(item))
- model.channel = String(this.props.data.channel)
- model.natural_limit = String(this.props.data.natural_limit)
- model.brush_limit = String(this.props.data.brush_limit)
- model.card_type = this.props.data.card_type.map((item) => String(item))
- model.receive_number = this.props.data.receive_conf.num
- model.receive_type = this.props.data.receive_conf.type
- model.timer[0] = this.props.data.time_limit.receive_time.start_time
- model.timer[1] = this.props.data.time_limit.receive_time.end_time
+ model.weight = String(this.props.data.weight);
+ model.early_per = this.props.data.early_per.map((item) => String(item));
+ model.channel = String(this.props.data.channel);
+ model.natural_limit = String(this.props.data.natural_limit);
+ model.brush_limit = String(this.props.data.brush_limit);
+ model.card_type = this.props.data.card_type.map((item) => String(item));
+ model.receive_number = this.props.data.receive_conf.num;
+ model.receive_type = this.props.data.receive_conf.type;
+ model.timer[0] = this.props.data.time_limit.receive_time.start_time;
+ model.timer[1] = this.props.data.time_limit.receive_time.end_time;
model.timer_type = !this.props.data.time_limit.receive_time?.start_time
? "1"
- : "2"
+ : "2";
model.effect_date_type =
this.state.getTimeList[
Number(this.props.data.time_limit.use_time.effect_date_type)
- ]
- model.effect_date = this.props.data.time_limit.use_time.effect_day
- model.usable_time = this.props.data.time_limit.use_time.type
+ ];
+ model.effect_date = this.props.data.time_limit.use_time.effect_day;
+ model.usable_time = this.props.data.time_limit.use_time.type;
model.early_notifier = this.props.data.early_notifier?.map((item) => {
return UserSelectList?.map((items) => {
if (item?.mobile === items.key || item?.real_name === items.text) {
- return items
+ return items;
}
- }).filter((item1) => item1)[0]
- })
+ }).filter((item1) => item1)[0];
+ });
- model.origin = this.props.data
+ model.origin = this.props.data;
/* 以下操作 筛选出输入框的预警值并经行填充 */
- const copy_early_per = this.props.data?.early_per || []
+ const copy_early_per = this.props.data?.early_per || [];
copy_early_per.map((item) => {
if (earlyPerList.indexOf(item) === -1) {
- return this.setState({ input_early_per: item, model: model })
+ return this.setState({ input_early_per: item, model: model });
} else {
- return this.setState({ model: model })
+ return this.setState({ model: model });
}
- })
+ });
}
}
@@ -238,8 +241,8 @@ export default class addKnockGold extends Component {
handelResponse(
res,
(req, msg) => {
- const defaultDataName = req.default.map((item) => item.real_name)
- const defaultDataMobile = req.default.map((item) => item.mobile)
+ const defaultDataName = req.default.map((item) => item.real_name);
+ const defaultDataMobile = req.default.map((item) => item.mobile);
const newData = req.data.map((item) => {
if (
defaultDataName.indexOf(item.real_name) !== -1 ||
@@ -249,98 +252,98 @@ export default class addKnockGold extends Component {
key: item.mobile,
text: item.real_name,
disabled: true,
- closable: false
- }
+ closable: false,
+ };
} else {
return {
key: item.mobile,
text: item.real_name,
- closable: true
- }
+ closable: true,
+ };
}
- })
- this.setState({ userSelectList: newData })
- this.echoFun(newData)
+ });
+ this.setState({ userSelectList: newData });
+ this.echoFun(newData);
},
(err) => {
- Notify.error(err)
+ Notify.error(err);
}
)
- )
+ );
}
/* x时间控件禁用 */
onDisabledRange = (date, type) => {
- let disabled = false
+ let disabled = false;
if (type == "end") {
- disabled = moment(date.getTime()).add(1, "days") <= new Date().getTime()
+ disabled = moment(date.getTime()).add(1, "days") <= new Date().getTime();
}
if (type == "start") {
- disabled = date.getTime() <= new Date().getTime()
+ disabled = date.getTime() <= new Date().getTime();
}
- return disabled
- }
+ return disabled;
+ };
/* x时间控件禁用 */
onDisabledRange1 = (date, type) => {
- let step1 = JSON.parse(sessionStorage.getItem("knockGold_effectDate"))
- let isdisabled = false
- let str = moment(date).format("YYYY-MM-DD HH:mm:ss")
- const isDay = moment(step1.end_time).format("HH:mm:ss")
+ let step1 = JSON.parse(sessionStorage.getItem("knockGold_effectDate"));
+ let isdisabled = false;
+ let str = moment(date).format("YYYY-MM-DD HH:mm:ss");
+ const isDay = moment(step1.end_time).format("HH:mm:ss");
if (type == "start") {
if (isDay < "23:59:59") {
isdisabled =
moment(str).isBefore(step1.begin_time) ||
- moment(str).subtract(1, "days").isAfter(step1.end_time)
+ moment(str).subtract(1, "days").isAfter(step1.end_time);
} else {
isdisabled =
moment(str).isBefore(step1.begin_time) ||
- moment(str).isAfter(step1.end_time)
+ moment(str).isAfter(step1.end_time);
}
}
if (type == "end") {
isdisabled =
moment(str).add(1, "days").isBefore(step1.begin_time) ||
- moment(str).isAfter(step1.end_time)
+ moment(str).isAfter(step1.end_time);
}
- return isdisabled
- }
+ return isdisabled;
+ };
/* x时间控件禁用 */
onDisabledRange2 = (date, type) => {
- let isdisabled = false
- let str = moment(date).format("YYYY-MM-DD HH:mm:ss")
- const isDay = moment(this.state.model.entry_time[1]).format("HH:mm:ss")
+ let isdisabled = false;
+ let str = moment(date).format("YYYY-MM-DD HH:mm:ss");
+ const isDay = moment(this.state.model.entry_time[1]).format("HH:mm:ss");
if (type == "start") {
if (isDay < "23:59:59") {
isdisabled =
moment(str).isBefore(this.state.model.entry_time[0]) ||
moment(str)
.subtract(1, "days")
- .isAfter(this.state.model.entry_time[1])
+ .isAfter(this.state.model.entry_time[1]);
} else {
isdisabled =
moment(str).isBefore(this.state.model.entry_time[0]) ||
- moment(str).isAfter(this.state.model.entry_time[1])
+ moment(str).isAfter(this.state.model.entry_time[1]);
}
}
if (type == "end") {
isdisabled =
moment(str).add(1, "days").isBefore(this.state.model.entry_time[0]) ||
- moment(str).isAfter(this.state.model.entry_time[1])
+ moment(str).isAfter(this.state.model.entry_time[1]);
}
- return isdisabled
- }
+ return isdisabled;
+ };
onDisabledTime = (date, type) => {
- let step1 = JSON.parse(sessionStorage.getItem("knockGold_effectDate"))
- const min = new Date(step1.begin_time)
- const hour = min.getHours()
- const minute = min.getMinutes()
- const second = min.getSeconds()
- const isSame = isSameDay(date, min)
+ let step1 = JSON.parse(sessionStorage.getItem("knockGold_effectDate"));
+ const min = new Date(step1.begin_time);
+ const hour = min.getHours();
+ const minute = min.getMinutes();
+ const second = min.getSeconds();
+ const isSame = isSameDay(date, min);
return isSame
? {
@@ -350,17 +353,17 @@ export default class addKnockGold extends Component {
disabledSeconds: (hourValue, minuteValue) =>
hourValue === hour && minuteValue === minute
? initArray(second)
- : []
+ : [],
}
- : {}
- }
+ : {};
+ };
onDisabledTime1 = (date, type) => {
- const min = new Date(this.state.model.entry_time[0])
- const hour = min.getHours()
- const minute = min.getMinutes()
- const second = min.getSeconds()
- const isSame = isSameDay(date, min)
+ const min = new Date(this.state.model.entry_time[0]);
+ const hour = min.getHours();
+ const minute = min.getMinutes();
+ const second = min.getSeconds();
+ const isSame = isSameDay(date, min);
return isSame
? {
@@ -370,17 +373,17 @@ export default class addKnockGold extends Component {
disabledSeconds: (hourValue, minuteValue) =>
hourValue === hour && minuteValue === minute
? initArray(second)
- : []
+ : [],
}
- : {}
- }
+ : {};
+ };
/* 当预警百分比自定义输入框经行操作时从 early_per 数组中找出并过滤 */
filterEarlyPer() {
const new_early_per = this.state.model.early_per.filter(
(item) => item !== this.state.input_early_per
- )
- this.onHandleChange(new_early_per, "early_per")
+ );
+ this.onHandleChange(new_early_per, "early_per");
}
/* 提交 */
@@ -392,60 +395,60 @@ export default class addKnockGold extends Component {
this.refs.form4.validator()
) {
if (this.props.data) {
- let temp = []
+ let temp = [];
if (sessionStorage.getItem("knockGoldData")) {
- temp = JSON.parse(sessionStorage.getItem("knockGoldData"))
+ temp = JSON.parse(sessionStorage.getItem("knockGoldData"));
}
let index = temp.findIndex((item) => {
return (
item.channel_activity_id === this.props.data.channel_activity_id
- )
- })
+ );
+ });
/* 校验表单 */
if (this.limitFunction() === false) {
- return false
+ return false;
}
/* 兼容老数据 */
if (this.props.data?.goods_id) {
temp[index] = Object.assign({
...this.state.model.origin,
- ...this.transformDataCode()
- })
+ ...this.transformDataCode(),
+ });
} else {
/* 新增编辑 */
- temp[index] = this.transformDataCode()
+ temp[index] = this.transformDataCode();
}
- sessionStorage.setItem("knockGoldData", JSON.stringify(temp))
+ sessionStorage.setItem("knockGoldData", JSON.stringify(temp));
- return true
+ return true;
} else {
/* 校验表单 */
if (this.limitFunction() === false) {
- return false
+ return false;
}
//缓存
- let temp = []
+ let temp = [];
if (sessionStorage.getItem("knockGoldData")) {
- temp = JSON.parse(sessionStorage.getItem("knockGoldData"))
+ temp = JSON.parse(sessionStorage.getItem("knockGoldData"));
}
- let data = temp ? temp : []
+ let data = temp ? temp : [];
//字段转换
- const models = this.transformDataCode()
+ const models = this.transformDataCode();
const isRepeat = data.find(
(item) => item.channel_activity_id === models.channel_activity_id
- )
+ );
if (isRepeat) {
- Notify.error("不允许输入重复的平台批次号")
- return false
+ Notify.error("不允许输入重复的平台批次号");
+ return false;
}
- data.push(models)
- sessionStorage.setItem("knockGoldData", JSON.stringify(data))
- return true
+ data.push(models);
+ sessionStorage.setItem("knockGoldData", JSON.stringify(data));
+ return true;
}
}
}
@@ -453,16 +456,16 @@ export default class addKnockGold extends Component {
/* 处理时间交集 */
detectTimeConflict(arr) {
for (var i = 0; i < arr.length; i++) {
- var d1 = arr[i][0]
- var d2 = arr[i][1]
+ var d1 = arr[i][0];
+ var d2 = arr[i][1];
for (var j = i + 1; j < arr.length; j++) {
// j=i+1:使其不要与自身比较
- var t1 = arr[j][0]
- var t2 = arr[j][1]
+ var t1 = arr[j][0];
+ var t2 = arr[j][1];
if ((d1 >= t1 && d1 < t2) || (d1 < t1 && d2 > t1)) {
- return true
+ return true;
} else {
- return false
+ return false;
}
}
}
@@ -470,101 +473,101 @@ export default class addKnockGold extends Component {
/* 数据转换统一处理函数 */
transformDataCode() {
- const transformData = {}
- transformData.channel = this.state.model.channel
+ const transformData = {};
+ transformData.channel = this.state.model.channel;
/* 是支付宝立减金 才进行模板赋值操作 */
if (transformData.channel == 1) {
- transformData.temp_no = this.state.model.temp_no
+ transformData.temp_no = this.state.model.temp_no;
} else {
- transformData.temp_no = ""
+ transformData.temp_no = "";
}
- transformData.batch_goods_name = this.state.model.batch_goods_name
- transformData.channel_activity_id = this.state.model.channel_activity_id //确认字段
- transformData.price = this.state.model.price //确认字段
- transformData.recharge_amount = this.state.model.recharge_amount //确认字段
- transformData.denomination = this.state.model.denomination
- transformData.reduce_amount = this.state.model.reduce_amount
- transformData.all_budget = this.state.model.all_budget
- transformData.day_budget = this.state.model.day_budget
- transformData.card_type = this.state.model.card_type
- transformData.natural_limit = this.state.model.natural_limit
- transformData.brush_limit = this.state.model.brush_limit
- transformData.instruction = this.state.model.instruction
- transformData.early_per = this.state.model.early_per.filter((item) => item)
+ transformData.batch_goods_name = this.state.model.batch_goods_name;
+ transformData.channel_activity_id = this.state.model.channel_activity_id; //确认字段
+ transformData.price = this.state.model.price; //确认字段
+ transformData.recharge_amount = this.state.model.recharge_amount; //确认字段
+ transformData.denomination = this.state.model.denomination;
+ transformData.reduce_amount = this.state.model.reduce_amount;
+ transformData.all_budget = this.state.model.all_budget;
+ transformData.day_budget = this.state.model.day_budget;
+ transformData.card_type = this.state.model.card_type;
+ transformData.natural_limit = this.state.model.natural_limit;
+ transformData.brush_limit = this.state.model.brush_limit;
+ transformData.instruction = this.state.model.instruction;
+ transformData.early_per = this.state.model.early_per.filter((item) => item);
transformData.early_notifier = this.state.model.early_notifier.map(
({ text, key }) => ({
real_name: text,
- mobile: key
+ mobile: key,
})
- )
- transformData.weight = this.state.model.weight
+ );
+ transformData.weight = this.state.model.weight;
transformData.receive_conf = {
type: this.state.model.receive_type,
- num: this.state.model.receive_number
- }
+ num: this.state.model.receive_number,
+ };
transformData.time_limit = {
effect_time: {
start_time: this.state.model.entry_time[0],
- end_time: this.state.model.entry_time[1]
+ end_time: this.state.model.entry_time[1],
},
receive_time: {
start_time: this.state.model.timer[0],
- end_time: this.state.model.timer[1]
+ end_time: this.state.model.timer[1],
},
use_time: {
type: this.state.model.usable_time,
...this.withTimeFunction(this.state.model.usable_time),
effect_day: this.state.model.effect_date,
- effect_date_type: this.state.model.effect_date_type?.key
- }
- }
+ effect_date_type: this.state.model.effect_date_type?.key,
+ },
+ };
- return transformData
+ return transformData;
}
/* 处理可用时间段 */
withTimeFunction(type) {
- let obj = {}
+ let obj = {};
switch (type) {
case "week":
- obj.time = this.state.model.ruleDate
- obj.week = this.state.model.ruleWeek
- break
+ obj.time = this.state.model.ruleDate;
+ obj.week = this.state.model.ruleWeek;
+ break;
case "irregular":
- obj.time = this.state.model.irregularTime
- obj.day = this.state.model.irregularDate
- break
+ obj.time = this.state.model.irregularTime;
+ obj.day = this.state.model.irregularDate;
+ break;
default:
obj.fiexd_time = {
start_time: this.state.model.fixed_time[0],
- end_time: this.state.model.fixed_time[1]
- }
- break
+ end_time: this.state.model.fixed_time[1],
+ };
+ break;
}
- return obj
+ return obj;
}
testDateFunction(arr) {
- return arr.map((item) => this.setTime(item)).filter((item) => item)
+ return arr.map((item) => this.setTime(item)).filter((item) => item);
}
/* 校验表单function */
limitFunction() {
if (!this.state.model.card_type) {
- Notify.error("请选择卡种")
- return false
+ Notify.error("请选择卡种");
+ return false;
}
if (this.state.model.early_per.filter((item) => item).length < 1) {
- Notify.error("请选预警百分比")
- return false
+ Notify.error("请选预警百分比");
+ return false;
}
if (!this.state.model.usable_time) {
- Notify.error("请选择可用时间段类型")
- return false
+ Notify.error("请选择可用时间段类型");
+ return false;
}
/* 可用时间段 */
@@ -573,8 +576,8 @@ export default class addKnockGold extends Component {
!this.state.model.effect_date_type?.key ||
!this.state.model.effect_date
) {
- Notify.error("请完整的填写或选择可用时间段")
- return false
+ Notify.error("请完整的填写或选择可用时间段");
+ return false;
}
}
@@ -585,16 +588,16 @@ export default class addKnockGold extends Component {
) {
Notify.error(
`有限期不允许大于生效时间段 注:当前有效期最小时间为 1 天,最大时间为 ${this.state.TimeDiffer} 天`
- )
- return false
+ );
+ return false;
}
if (
this.state.model.usable_time === "fiexd" &&
this.setTime(this.state.model.fixed_time)
) {
- Notify.error("请完整的选择固定时间段")
- return false
+ Notify.error("请完整的选择固定时间段");
+ return false;
}
if (
(this.state.model.usable_time === "fiexd" &&
@@ -602,8 +605,8 @@ export default class addKnockGold extends Component {
(this.state.model.usable_time === "fiexd" &&
this.state.model.fixed_time[1] > this.state.model.entry_time[1])
) {
- Notify.error("固定开始时间或结束时间不允许大于生效结束时间")
- return false
+ Notify.error("固定开始时间或结束时间不允许大于生效结束时间");
+ return false;
}
/* 验证有效期内,规则日期可用 */
@@ -613,8 +616,8 @@ export default class addKnockGold extends Component {
this.testDateFunction(this.state.model.ruleDate).length > 0 ||
this.state.model.ruleWeek.length < 1
) {
- Notify.error("请完整的选择规则日期和时间")
- return false
+ Notify.error("请完整的选择规则日期和时间");
+ return false;
}
}
@@ -624,79 +627,79 @@ export default class addKnockGold extends Component {
this.testDateFunction(this.state.model.irregularDate).length > 0 ||
this.testDateFunction(this.state.model.irregularTime).length > 0
) {
- Notify.error("请完整的选择不规则日期和时间")
- return false
+ Notify.error("请完整的选择不规则日期和时间");
+ return false;
}
}
if (this.detectTimeConflict(this.state.model.ruleDate)) {
- Notify.error("有效期内,规则时间存在交集")
- return false
+ Notify.error("有效期内,规则时间存在交集");
+ return false;
}
if (this.detectTimeConflict(this.state.model.irregularDate)) {
- Notify.error("有效期内,不规则日期存在交集")
- return false
+ Notify.error("有效期内,不规则日期存在交集");
+ return false;
}
if (this.detectTimeConflict(this.state.model.irregularTime)) {
- Notify.error("有效期内,不规则时间存在交集")
- return false
+ Notify.error("有效期内,不规则时间存在交集");
+ return false;
}
- const limitBit = /^-?\d+\.?\d{0,2}$/
+ const limitBit = /^-?\d+\.?\d{0,2}$/;
if (
!limitBit.test(this.state.model.denomination) ||
!limitBit.test(this.state.model.reduce_amount)
) {
- Notify.error("请输入正确的面额金额或立减金额(保留两位小数)")
- return false
+ Notify.error("请输入正确的面额金额或立减金额(保留两位小数)");
+ return false;
}
if (
this.state.model.denomination - 0 <
this.state.model.reduce_amount - 0
) {
- Notify.error("面额不允许大于满减金额")
- return false
+ Notify.error("面额不允许大于满减金额");
+ return false;
}
if (
this.state.model.recharge_amount - 0 >
this.state.model.all_budget - 0
) {
- Notify.error("充值批次金额不允许大于总预算")
- return false
+ Notify.error("充值批次金额不允许大于总预算");
+ return false;
}
if (this.state.model.all_budget - 0 < this.state.model.day_budget - 0) {
- Notify.error("单天预算发放上限不允许大于总预算")
- return false
+ Notify.error("单天预算发放上限不允许大于总预算");
+ return false;
}
if (this.state.model.day_budget - 0 < this.state.model.reduce_amount - 0) {
- Notify.error("单天预算发放上限不允许小于面额")
- return false
+ Notify.error("单天预算发放上限不允许小于面额");
+ return false;
}
if (
this.state.model.recharge_amount - 0 <
this.state.model.reduce_amount - 0
) {
- Notify.error("面额不允许大于批次充值金额")
- return false
+ Notify.error("面额不允许大于批次充值金额");
+ return false;
}
if (
Math.trunc(this.state.model.all_budget / this.state.model.reduce_amount) <
this.state.model.receive_number - 0
) {
- Notify.error("用户可领个数不允许大于库存(总预算/面额)")
- return false
+ Notify.error("用户可领个数不允许大于库存(总预算/面额)");
+ return false;
}
/* 生效时间段 */
if (this.setTime(this.state.model.entry_time)) {
- Notify.error("请选择结束时间或开始时间")
- return false
+ Notify.error("请选择结束时间或开始时间");
+ return false;
}
/* 领取时间段 */
@@ -704,37 +707,37 @@ export default class addKnockGold extends Component {
this.setTime(this.state.model.timer) &&
this.state.model.timer_type === "2"
) {
- Notify.error("请选择结束时间或开始时间")
- return false
+ Notify.error("请选择结束时间或开始时间");
+ return false;
}
/* 预警人数 */
if (this.state.model.early_notifier.length > 14) {
- Notify.error("目前仅支持新增10个预警通知人")
- return false
+ Notify.error("目前仅支持新增10个预警通知人");
+ return false;
}
}
//限制时间
setTime(data) {
- if (!isArray(data) || data?.length === 0) return true
- const newData = data.map((item) => Boolean(item))
- let blr = null
+ if (!isArray(data) || data?.length === 0) return true;
+ const newData = data.map((item) => Boolean(item));
+ let blr = null;
newData.map((item) => {
- if (!item) blr = true
- })
- return blr
+ if (!item) blr = true;
+ });
+ return blr;
}
/* 输入事件和选择事件统一处理 */
onHandleChange(value, key, childrenKey) {
- let model2 = this.state.model
+ let model2 = this.state.model;
if (childrenKey) {
- model2[key][childrenKey] = value
+ model2[key][childrenKey] = value;
} else {
}
- model2[key] = value
- this.setState({ model: model2 })
+ model2[key] = value;
+ this.setState({ model: model2 });
}
getTimeDiff() {
@@ -742,18 +745,18 @@ export default class addKnockGold extends Component {
const TimeDiffer = timeDiff(
this.state.model.entry_time[0],
this.state.model.entry_time[1]
- )
+ );
const data = this.state.getTimeList.map((item) => {
if (item?.key === "1") {
if (TimeDiffer < 2) {
- item.disabled = true
+ item.disabled = true;
} else {
- item.disabled = false
+ item.disabled = false;
}
}
- return item
- })
- this.setState({ TimeDiffer, getTimeList: data })
+ return item;
+ });
+ this.setState({ TimeDiffer, getTimeList: data });
}
}
@@ -761,44 +764,46 @@ export default class addKnockGold extends Component {
closeCallback(item) {
const newData = this.state.model.early_notifier.filter(
(items) => items.key !== item.key
- )
- this.onHandleChange(newData, "early_notifier") /* 调用公用setState */
+ );
+ this.onHandleChange(newData, "early_notifier"); /* 调用公用setState */
/* 当预警人为0 清除输入框 */
- if (newData.length < 1) this.setState({ warningInput: "" })
+ if (newData.length < 1) this.setState({ warningInput: "" });
}
render() {
return (
-
+
{/*
基本信息
*/}
-
-
{/*
时间限制
*/}
-
-
+
+
{
- this.onHandleChange(value, "entry_time")
- this.getTimeDiff()
+ this.onHandleChange(value, "entry_time");
+ this.getTimeDiff();
}}
disabledTime={this.onDisabledTime}
disabledDate={this.onDisabledRange1}
/>
{this.state.model.timer_type === "2" ? (
-
+
{
- this.onHandleChange(value, "timer")
+ this.onHandleChange(value, "timer");
}}
- width='240px'
+ width="240px"
disabledTime={this.onDisabledRange}
/>
{
- this.onHandleChange(target.value, "timer_type")
+ this.onHandleChange(target.value, "timer_type");
if (target.value === "1") {
- this.onHandleChange("", "timer")
+ this.onHandleChange("", "timer");
}
}}
disabled={this.props?.data?.id ? true : false}
- value={this.state.model.timer_type}>
+ value={this.state.model.timer_type}
+ >
不设置
每天
) : (
-
+
{
- this.onHandleChange(target.value, "timer_type")
+ this.onHandleChange(target.value, "timer_type");
}}
disabled={this.props?.data?.id ? true : false}
- value={this.state.model.timer_type}>
+ value={this.state.model.timer_type}
+ >
不设置
每天
@@ -1159,49 +1177,51 @@ export default class addKnockGold extends Component {
)}
-
+ id="usable_time"
+ labelname="可用时间段"
+ prop="official_price"
+ >
+
{
- this.onHandleChange(target.value, "usable_time")
- this.onHandleChange([], "fixed_time")
- this.onHandleChange([[]], "irregularDate")
- this.onHandleChange([[]], "irregularTime")
- this.onHandleChange([], "ruleWeek")
- this.onHandleChange([[]], "ruleDate")
- }}>
- 领取后
+ this.onHandleChange(target.value, "usable_time");
+ this.onHandleChange([], "fixed_time");
+ this.onHandleChange([[]], "irregularDate");
+ this.onHandleChange([[]], "irregularTime");
+ this.onHandleChange([], "ruleWeek");
+ this.onHandleChange([[]], "ruleDate");
+ }}
+ >
+ 领取后
{this.state.model.usable_time === "received" ? (
<>
{" "}
-
+
-
有效期
+
有效期
{
- this.onHandleChange(value, "effect_date")
+ this.onHandleChange(value, "effect_date");
}}
onClearItem={() => {
- this.onHandleChange("", "effect_date")
+ this.onHandleChange("", "effect_date");
}}
disabled={this.props?.data?.id ? true : false}
value={this.state.model.effect_date}
@@ -1209,7 +1229,7 @@ export default class addKnockGold extends Component {
labelWidth={"0px"}
maxLength={3}
height={"36px"}
- unit='天'
+ unit="天"
countShow={false}
width={"172px"}
alignment={"left"}
@@ -1217,91 +1237,95 @@ export default class addKnockGold extends Component {
>
) : null}
-
+
{
- this.onHandleChange(target.value, "usable_time")
- this.onHandleChange("", "effect_date_type")
- this.onHandleChange("", "effect_date")
- this.onHandleChange([[]], "irregularDate")
- this.onHandleChange([[]], "irregularTime")
- this.onHandleChange([], "ruleWeek")
- this.onHandleChange([[]], "ruleDate")
- }}>
- 固定时间
+ this.onHandleChange(target.value, "usable_time");
+ this.onHandleChange("", "effect_date_type");
+ this.onHandleChange("", "effect_date");
+ this.onHandleChange([[]], "irregularDate");
+ this.onHandleChange([[]], "irregularTime");
+ this.onHandleChange([], "ruleWeek");
+ this.onHandleChange([[]], "ruleDate");
+ }}
+ >
+ 固定时间
{this.state.model.usable_time === "fiexd" ? (
{
- this.onHandleChange(value, "fixed_time")
+ this.onHandleChange(value, "fixed_time");
}}
disabledDate={this.onDisabledRange2}
disabledTime={this.onDisabledTime1}
/>
) : null}
-
+
{
- this.onHandleChange(target.value, "usable_time")
- this.onHandleChange("", "effect_date_type")
- this.onHandleChange("", "effect_date")
- this.onHandleChange([[]], "fixed_time")
- this.onHandleChange([[]], "irregularDate")
- this.onHandleChange([[]], "irregularTime")
- }}>
- 有效期内,规则日期可用
+ this.onHandleChange(target.value, "usable_time");
+ this.onHandleChange("", "effect_date_type");
+ this.onHandleChange("", "effect_date");
+ this.onHandleChange([[]], "fixed_time");
+ this.onHandleChange([[]], "irregularDate");
+ this.onHandleChange([[]], "irregularTime");
+ }}
+ >
+ 有效期内,规则日期可用
{this.state.model.usable_time === "week" ? (
<>
this.onHandleChange(va, "ruleWeek")}
- style={{ marginLeft: "25px", marginTop: "20px" }}>
+ style={{ marginLeft: "25px", marginTop: "20px" }}
+ >
{week.map((week) => (
+ key={week.key}
+ >
{week.text}
))}
{this.state.model.ruleDate.map((item, index) => (
-
+
{
- const model = this.state.model.ruleDate
- model[index] = value
- this.onHandleChange(model, "ruleDate")
+ const model = this.state.model.ruleDate;
+ model[index] = value;
+ this.onHandleChange(model, "ruleDate");
}}
width={205}
disabledTime={this.onDisabledRange}
@@ -1315,48 +1339,49 @@ export default class addKnockGold extends Component {
)}
))}
-
+
请按照24小时制输入可用时段,最多设置3个时段
>
) : null}
-
+
{
- this.onHandleChange(target.value, "usable_time")
- this.onHandleChange("", "effect_date_type")
- this.onHandleChange("", "effect_date")
- this.onHandleChange([[]], "fixed_time")
- this.onHandleChange([], "ruleWeek")
- this.onHandleChange([[]], "ruleDate")
- }}>
- 有效期内,不规则日期可用
+ this.onHandleChange(target.value, "usable_time");
+ this.onHandleChange("", "effect_date_type");
+ this.onHandleChange("", "effect_date");
+ this.onHandleChange([[]], "fixed_time");
+ this.onHandleChange([], "ruleWeek");
+ this.onHandleChange([[]], "ruleDate");
+ }}
+ >
+ 有效期内,不规则日期可用
{this.state.model.usable_time === "irregular" ? (
<>
-
+
可在有效期内任意选择时间天数,以及可用时段。
因当前微信支持问题,如选择不规则时间,微信卡包内当前仅会展示有效期,建议
将具体可用日期以及时间段填写在使用说明内。
{this.state.model.irregularDate.map((time, index) => (
-
+
{
- const model = this.state.model.irregularDate
- model[index] = value
- this.onHandleChange(model, "irregularDate")
+ const model = this.state.model.irregularDate;
+ model[index] = value;
+ this.onHandleChange(model, "irregularDate");
}}
disabledDate={this.onDisabledRange2}
disabledTime={this.onDisabledTime1}
@@ -1370,22 +1395,22 @@ export default class addKnockGold extends Component {
))}
{this.state.model.irregularTime.map((time, index) => (
-
+
{
- const model = this.state.model.irregularTime
- model[index] = value
- this.onHandleChange(model, "irregularTime")
+ const model = this.state.model.irregularTime;
+ model[index] = value;
+ this.onHandleChange(model, "irregularTime");
}}
width={205}
disabledTime={this.onDisabledRange}
@@ -1407,14 +1432,14 @@ export default class addKnockGold extends Component {
{/* 样式设置
*/}
-
-
+
+
{
- this.onHandleChange(text, "instruction")
+ this.onHandleChange(text, "instruction");
}}
- width='520px'
+ width="520px"
text={this.state.model.instruction}
limitLength={500}
key={this.state.model.channel}
@@ -1424,13 +1449,14 @@ export default class addKnockGold extends Component {
{/* 预警规则
*/}
-
-
+
+
{
- this.onHandleChange(value, "early_per")
- }}>
+ this.onHandleChange(value, "early_per");
+ }}
+ >
{earlyPerList.map((item) => (
{item}%
@@ -1439,57 +1465,58 @@ export default class addKnockGold extends Component {
{
- this.filterEarlyPer()
- this.setState({ input_early_per: value })
+ this.filterEarlyPer();
+ this.setState({ input_early_per: value });
}}
onClearItem={() => {
- this.filterEarlyPer()
- this.setState({ input_early_per: "" })
+ this.filterEarlyPer();
+ this.setState({ input_early_per: "" });
}}
value={this.state.input_early_per}
placeholder={""}
labelWidth={"0px"}
maxLength={3}
height={"36px"}
- unit='%'
+ unit="%"
countShow={false}
width={"190px"}
alignment={"left"}
/>
-
-
+
+
-
+
{isArray(this.state.model.early_notifier) &&
this.state.model.early_notifier?.map((item) => (
this.closeCallback(item)}
- key={item?.key}>
+ key={item?.key}
+ >
{item?.text}
))}
@@ -1499,23 +1526,24 @@ export default class addKnockGold extends Component {
- )
+ );
}
}