From 40cc0153b7f8ac978b3dbdc21fb2790d72be4ccc Mon Sep 17 00:00:00 2001 From: wangsongsole Date: Sun, 25 Jun 2023 15:26:16 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=92=AA=20optimize:=20=E8=B0=83=E6=95=B4?= =?UTF-8?q?=E7=BA=A2=E5=8C=85=E7=BB=84=E4=BB=B6=E6=9C=80=E5=A4=A7=E6=9C=80?= =?UTF-8?q?=E5=B0=8F=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/redPackets/index.jsx | 930 +++++++++++++--------------- 1 file changed, 445 insertions(+), 485 deletions(-) diff --git a/src/components/redPackets/index.jsx b/src/components/redPackets/index.jsx index 3d69abac..5c0f6e74 100644 --- a/src/components/redPackets/index.jsx +++ b/src/components/redPackets/index.jsx @@ -1,14 +1,14 @@ /* 新增商品 */ -import { Component } from 'react'; -import './index.less'; -import { uuid } from '@/tools/utils.js'; -import Ipt from '@/components/input/main'; -import Form from '@/components/form/main'; -import FormItem from '@/components/form-item/main'; -import rules, { additionalRules } from './rules'; -import moment from 'moment'; -import { deWeightThree } from '@/tools/utils.js'; -import { isSameDay } from 'date-fns'; +import { Component } from "react" +import "./index.less" +import { uuid } from "@/tools/utils.js" +import Ipt from "@/components/input/main" +import Form from "@/components/form/main" +import FormItem from "@/components/form-item/main" +import rules, { additionalRules } from "./rules" +import moment from "moment" +import { deWeightThree } from "@/tools/utils.js" +import { isSameDay } from "date-fns" import { Select, RadioButton, @@ -23,28 +23,28 @@ import { TimeRangePicker, DatePicker, BlockHeader -} from 'zent'; -import isArray from 'lodash/isArray'; -import cloneDeep from 'lodash/cloneDeep'; -import omit from 'lodash/omit'; -import { getVoucherWarningAccount, handelResponse } from '@/assets/api'; -import MobileComponent from './mobileComponent'; -import WangEditor from './wangEditor'; -import { receiveTypeList, week, earlyPerList, model } from './static'; +} from "zent" +import isArray from "lodash/isArray" +import cloneDeep from "lodash/cloneDeep" +import omit from "lodash/omit" +import { getVoucherWarningAccount, handelResponse } from "@/assets/api" +import MobileComponent from "./mobileComponent" +import WangEditor from "./wangEditor" +import { receiveTypeList, week, earlyPerList, model } from "./static" 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(this.props) - }; + } } componentWillMount() { - this.getUserSelectList(); + this.getUserSelectList() } /* 可用时间段组件*/ @@ -53,32 +53,34 @@ export default class addKnockGold extends Component { <> {index > 0 && (

{ - const model = this.state.model; - model.receive_rule.time.splice(index, 1); - this.setState({ model }); - }}> + const model = this.state.model + model.receive_rule.time.splice(index, 1) + this.setState({ model }) + }} + > 删除

)} {index === this.state.model.receive_rule.time.length - 1 && (

{ if (this.state.model.receive_rule.time.length < 3) { - const model = this.state.model; - model.receive_rule.time.push([]); - this.setState({ model }); + const model = this.state.model + model.receive_rule.time.push([]) + this.setState({ model }) } else { - Notify.warn('最多设置3个时段'); + Notify.warn("最多设置3个时段") } - }}> + }} + > 添加

)} - ); + ) } /* 每天时间段组件*/ @@ -87,32 +89,34 @@ export default class addKnockGold extends Component { <> {index > 0 && (

{ - const model = this.state.model; - model.receive_day.splice(index, 1); - this.setState({ model }); - }}> + const model = this.state.model + model.receive_day.splice(index, 1) + this.setState({ model }) + }} + > 删除

)} {index === this.state.model.receive_day.length - 1 && (

{ if (this.state.model.receive_day.length < 3) { - const model = this.state.model; - model.receive_day.push([]); - this.setState({ model }); + const model = this.state.model + model.receive_day.push([]) + this.setState({ model }) } else { - Notify.warn('最多设置3个时段'); + Notify.warn("最多设置3个时段") } - }}> + }} + > 添加

)} - ); + ) } /* 不规则日期组件 */ @@ -122,21 +126,19 @@ export default class addKnockGold extends Component { {this.state.model.receive_irregular.map((item, index) => (
-
+
{ - const model = this.state.model.receive_irregular; - model[index].date = value; - this.onHandleChange(model, 'receive_irregular'); + const model = this.state.model.receive_irregular + model[index].date = value + this.onHandleChange(model, "receive_irregular") }} disabledDate={{ min: this.state.model.effect_date[0], @@ -145,75 +147,79 @@ export default class addKnockGold extends Component { /> {index > 0 && (

{ - const model = this.state.model; - model.receive_irregular.splice(index, 1); - this.setState({ model }); - }}> + const model = this.state.model + model.receive_irregular.splice(index, 1) + this.setState({ model }) + }} + > 删除

)} {index === this.state.model.receive_irregular.length - 1 && (

{ if (this.state.model.receive_irregular.length < 3) { - const model = this.state.model; + const model = this.state.model model.receive_irregular.push({ - date: '', + date: "", time: [[]] - }); - this.setState({ model }); + }) + this.setState({ model }) } else { - Notify.warn('最多设置3个日期'); + Notify.warn("最多设置3个日期") } - }}> + }} + > 添加

)}
{item.time.map((items, indexes) => ( -
+
{ - const model = this.state.model; - model.receive_irregular[index].time[indexes] = value; - this.setState({ model }); + const model = this.state.model + model.receive_irregular[index].time[indexes] = value + this.setState({ model }) }} width={205} // disabledTime={this.onDisabledRange} /> {indexes > 0 && (

{ - const model = this.state.model; - model.receive_irregular[index].time.splice(indexes, 1); - this.setState({ model }); - }}> + const model = this.state.model + model.receive_irregular[index].time.splice(indexes, 1) + this.setState({ model }) + }} + > 删除

)} {indexes === item.time.length - 1 && (

{ if (item.time.length < 3) { - const model = this.state.model; - model.receive_irregular[index].time.push([]); - this.setState({ model }); + const model = this.state.model + model.receive_irregular[index].time.push([]) + this.setState({ model }) } else { - Notify.warn('最多设置3个时段'); + Notify.warn("最多设置3个时段") } - }}> + }} + > 添加

)} @@ -222,39 +228,39 @@ export default class addKnockGold extends Component {
))} - ); + ) } /* 编辑回显 */ echoFun(UserSelectList = []) { - const model = cloneDeep(this.props.data); + const model = cloneDeep(this.props.data) if (model) { - const { early_notifier, early_per, begin_time, end_time } = model; + const { early_notifier, early_per, begin_time, end_time } = model model.early_notifier = 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] }) - .filter((item1) => item1); - model.effect_date = []; - model.effect_date[0] = begin_time; - model.effect_date[1] = end_time; - model.copy && (model.cash_activity_id = uuid()); /* 是否是复制 */ + .filter((item1) => item1) + model.effect_date = [] + model.effect_date[0] = begin_time + model.effect_date[1] = end_time + model.copy && (model.cash_activity_id = uuid()) /* 是否是复制 */ /* 以下操作 筛选出输入框的预警值并经行填充 */ - const copy_early_per = early_per || []; + const copy_early_per = early_per || [] copy_early_per.map((item) => { if (earlyPerList.indexOf(item) === -1) { return this.setState({ input_early_per: item, model - }); + }) } else { - return this.setState({ model }); + return this.setState({ model }) } - }); + }) } } @@ -264,9 +270,9 @@ 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 selectData = []; + const defaultDataName = req.default.map((item) => item.real_name) + const defaultDataMobile = req.default.map((item) => item.mobile) + const selectData = [] const newData = req.data.map((item) => { if ( defaultDataName.indexOf(item.real_name) !== -1 || @@ -277,85 +283,79 @@ export default class addKnockGold extends Component { text: item.real_name, disabled: true, closable: false - }; - selectData.push(obj); - return obj; + } + selectData.push(obj) + return obj } else { return { key: item.mobile, text: item.real_name, closable: true - }; + } } - }); + }) - this.onHandleChange(selectData, 'early_notifier'); + this.onHandleChange(selectData, "early_notifier") this.setState({ userSelectList: newData - }); - this.echoFun(newData); + }) + this.echoFun(newData) }, (err) => { - Notify.error(err); + Notify.error(err) } ) - ); + ) } /* TODO: 生效时间控件 */ onDisabledRange1 = (date, type) => { - let step1 = JSON.parse(sessionStorage.getItem('redPackets_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') { + let step1 = JSON.parse(sessionStorage.getItem("redPackets_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); + isdisabled = moment(str).isBefore(step1.begin_time) || moment(str).isAfter(step1.end_time) } } - if (type == 'end') { + if (type == "end") { isdisabled = - moment(str).add(1, 'days').isBefore(step1.begin_time) || - moment(str).isAfter(step1.end_time); + moment(str).add(1, "days").isBefore(step1.begin_time) || moment(str).isAfter(step1.end_time) } - return isdisabled; - }; + return isdisabled + } /* TODO: 生效时间控件 */ onDisabledTime = (date, type) => { - let step1 = JSON.parse(sessionStorage.getItem('redPackets_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("redPackets_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 ? { disabledHours: () => initArray(hour), - disabledMinutes: (hourValue) => - hourValue === hour ? initArray(minute) : [], + disabledMinutes: (hourValue) => (hourValue === hour ? initArray(minute) : []), disabledSeconds: (hourValue, minuteValue) => - hourValue === hour && minuteValue === minute - ? initArray(second) - : [] + 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") } /* 提交 */ @@ -366,459 +366,434 @@ export default class addKnockGold extends Component { this.refs.form2.validator() && this.refs.form4.validator() ) { - let temp = []; - const redPacketsData = sessionStorage.getItem('redPacketsData'); - redPacketsData && (temp = JSON.parse(redPacketsData)); + let temp = [] + const redPacketsData = sessionStorage.getItem("redPacketsData") + redPacketsData && (temp = JSON.parse(redPacketsData)) if (this.props.data) { let index = temp.findIndex((item) => { - return item.cash_activity_id === this.props.data.cash_activity_id; - }); + return item.cash_activity_id === this.props.data.cash_activity_id + }) /* 校验表单 */ if (additionalRules(this.state) === false) { - return false; + return false } /* 兼容老数据 */ if (this.props.data.cash_activity_id) { - temp[index] = Object.assign( - this.props.data, - this.transformDataCode() - ); + temp[index] = Object.assign(this.props.data, this.transformDataCode()) } else { /* 新增编辑 */ - temp[index] = this.transformDataCode(); + temp[index] = this.transformDataCode() } - sessionStorage.setItem('redPacketsData', JSON.stringify(temp)); - this.setState({ form_data: temp[index] }); - return true; + sessionStorage.setItem("redPacketsData", JSON.stringify(temp)) + this.setState({ form_data: temp[index] }) + return true } else { /* 校验表单 */ if (additionalRules(this.state) === false) { - return false; + return false } //缓存 - let data = temp ? temp : []; + let data = temp ? temp : [] //字段转换 - const models = this.transformDataCode(); + const models = this.transformDataCode() - const isRepeat = data.find( - (item) => item.cash_activity_id === models.cash_activity_id - ); + const isRepeat = data.find((item) => item.cash_activity_id === models.cash_activity_id) if (isRepeat) { - Notify.error('不允许输入重复的平台批次号'); - return false; + Notify.error("不允许输入重复的平台批次号") + return false } - data.push(models); - sessionStorage.setItem('redPacketsData', JSON.stringify(data)); - this.setState({ form_data: models }); - return true; + data.push(models) + sessionStorage.setItem("redPacketsData", JSON.stringify(data)) + this.setState({ form_data: models }) + return true } } } /* 提交 数据转换统一处理函数 */ transformDataCode() { - const { model } = this.state; - const transformData = cloneDeep(model); - transformData.begin_time = model.effect_date[0]; - transformData.end_time = model.effect_date[1]; - const { receive_num, num, early_notifier } = model; - transformData.receive_num = Number(receive_num); - transformData.num = Number(num); + const { model } = this.state + const transformData = cloneDeep(model) + transformData.begin_time = model.effect_date[0] + transformData.end_time = model.effect_date[1] + const { receive_num, num, early_notifier } = model + transformData.receive_num = Number(receive_num) + transformData.num = Number(num) transformData.early_notifier = early_notifier.map(({ text, key }) => ({ real_name: text, mobile: key - })); - return omit(transformData, ['effect_date']); + })) + return omit(transformData, ["effect_date"]) } /* 输入事件和选择事件统一处理 */ 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; + model2[key] = value } - this.setState({ model: model2 }); + this.setState({ model: model2 }) } /* 计算总预算 */ computeAllBudget() { - const { num, cash_amount_type, denomination } = this.state.model; - if (cash_amount_type === '1') { - this.onHandleChange(denomination * num, 'all_budget'); + const { num, cash_amount_type, denomination } = this.state.model + if (cash_amount_type === "1") { + this.onHandleChange(denomination * num, "all_budget") } } /* 计算随机最大面额中的最大值 */ computeMax_Min() { - const { min_denomination, num, all_budget } = this.state.model; - const b = this.state.model.channel === 1 ? 0.01 : 0.1; - const max = all_budget - (num - 1) * min_denomination; - let a = 0; + const { min_denomination, num, all_budget } = this.state.model + const b = this.state.model.channel === 1 ? 0.01 : 0.1 + const max = all_budget - (num - 1) * min_denomination + let a = 0 if (max > 200) { - a = 200; + a = 200 } else if (max < b) { - a = b; + a = b } else { - a = max; + a = max } this.setState({ - computeMax: a - }); - this.onHandleChange('', 'max_denomination'); + computeMax: a.toFixed(2) + }) + this.onHandleChange("", "max_denomination") } /* 计算随机最大面额中的最小值 */ computeMin() { - let data = ''; - const b = this.state.model.channel === 1 ? 0.01 : 0.1; + let data = "" + const b = this.state.model.channel === 1 ? 0.01 : 0.1 if (isFinite(this.state.model.all_budget / this.state.model.num)) { - const a = this.state.model.all_budget / this.state.model.num; + const a = this.state.model.all_budget / this.state.model.num if (a < b) { - data = 0.1; + data = 0.1 } else if (a > 200) { - data = 200; + data = 200 } else { - data = a; + data = a } } else { - data = b; + data = b } - return data; + return data.toFixed(2) } //tag关闭 closeCallback(item) { - const newData = this.state.model.early_notifier.filter( - (items) => items.key !== item.key - ); - this.onHandleChange(newData, 'early_notifier'); /* 调用公用setState */ + const newData = this.state.model.early_notifier.filter((items) => items.key !== item.key) + 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(target.value, 'channel'); + this.onHandleChange(target.value, "channel") // if (target.value == 1) { // this.onHandleChange(defaultInstructionZfb, 'instruction'); // } else { // this.onHandleChange(defaultInstructionWx, 'instruction'); // } }} - value={this.state.model.channel}> + value={this.state.model.channel} + > 支付宝 微信 - + { - this.onHandleChange(target.value, 'cash_amount_type'); - this.onHandleChange('', 'all_budget'); - this.onHandleChange('', 'max_denomination'); - this.onHandleChange('', 'min_denomination'); - this.onHandleChange('', 'denomination'); - this.onHandleChange('', 'total_contract_price'); + this.onHandleChange(target.value, "cash_amount_type") + this.onHandleChange("", "all_budget") + this.onHandleChange("", "max_denomination") + this.onHandleChange("", "min_denomination") + this.onHandleChange("", "denomination") + this.onHandleChange("", "total_contract_price") }} - value={this.state.model.cash_amount_type}> - 固额 - 随机 + value={this.state.model.cash_amount_type} + > + 固额 + 随机 - + { - this.onHandleChange(value, 'cash_activity_id'); + this.onHandleChange(value, "cash_activity_id") }} onClearItem={() => { - this.onHandleChange('', 'cash_activity_id'); + this.onHandleChange("", "cash_activity_id") }} value={this.state.model.cash_activity_id} - placeholder={'请输入'} - labelWidth={'0px'} + placeholder={"请输入"} + labelWidth={"0px"} maxLength={50} - height={'36px'} - width={'520px'} - alignment={'left'} + height={"36px"} + width={"520px"} + alignment={"left"} /> - + { - this.onHandleChange(value, 'batch_goods_name'); + this.onHandleChange(value, "batch_goods_name") }} onClearItem={() => { - this.onHandleChange('', 'batch_goods_name'); + this.onHandleChange("", "batch_goods_name") }} value={this.state.model.batch_goods_name} - placeholder={'请输入'} - labelWidth={'0px'} + placeholder={"请输入"} + labelWidth={"0px"} maxLength={30} - height={'36px'} - width={'520px'} - alignment={'left'} + height={"36px"} + width={"520px"} + alignment={"left"} /> - + { - this.onHandleChange(value, 'wishing'); + this.onHandleChange(value, "wishing") }} onClearItem={() => { - this.onHandleChange('', 'wishing'); + this.onHandleChange("", "wishing") }} value={this.state.model.wishing} - placeholder={'请输入'} - labelWidth={'0px'} + placeholder={"请输入"} + labelWidth={"0px"} maxLength={32} - height={'36px'} - width={'520px'} - alignment={'left'} + height={"36px"} + width={"520px"} + alignment={"left"} /> - -
- + + + { - this.onHandleChange(value, 'all_budget'); - this.onHandleChange('', 'min_denomination'); - this.onHandleChange('', 'num'); - if (this.state.model.cash_amount_type === '2') { - this.computeMax_Min(); + this.onHandleChange(value, "all_budget") + this.onHandleChange("", "min_denomination") + this.onHandleChange("", "num") + if (this.state.model.cash_amount_type === "2") { + this.computeMax_Min() } }} onClearItem={() => { - this.onHandleChange('', 'all_budget'); - this.onHandleChange('', 'min_denomination'); - this.onHandleChange('', 'num'); - if (this.state.model.cash_amount_type === '2') { - this.computeMax_Min(); + this.onHandleChange("", "all_budget") + this.onHandleChange("", "min_denomination") + this.onHandleChange("", "num") + if (this.state.model.cash_amount_type === "2") { + this.computeMax_Min() } }} - labelWidth={'0px'} + labelWidth={"0px"} maxLength={9} - height={'36px'} - unit='元' + height={"36px"} + unit="元" countShow={false} - width={'520px'} - alignment={'left'} + width={"520px"} + alignment={"left"} /> - + { - this.onHandleChange(value, 'num'); - if (this.state.model.cash_amount_type === '1') { - this.computeAllBudget(); + this.onHandleChange(value, "num") + if (this.state.model.cash_amount_type === "1") { + this.computeAllBudget() } else { - this.computeMax_Min(); + this.computeMax_Min() } }} onClearItem={() => { - this.onHandleChange('', 'num'); - if (this.state.model.cash_amount_type === '1') { - this.computeAllBudget(); + this.onHandleChange("", "num") + if (this.state.model.cash_amount_type === "1") { + this.computeAllBudget() } else { - this.computeMax_Min(); + this.computeMax_Min() } }} value={this.state.model.num} - placeholder={'请输入'} + placeholder={"请输入"} disabled={this.state.isEdit} - labelWidth={'0px'} + labelWidth={"0px"} maxLength={9} - height={'36px'} - unit='个' + height={"36px"} + unit="个" countShow={false} - width={'520px'} - alignment={'left'} + width={"520px"} + alignment={"left"} /> - {this.state.model.cash_amount_type === '1' ? ( - + {this.state.model.cash_amount_type === "1" ? ( + { - this.onHandleChange(value, 'denomination'); - this.computeAllBudget(); + this.onHandleChange(value, "denomination") + this.computeAllBudget() }} onClearItem={() => { - this.onHandleChange('', 'denomination'); - this.computeAllBudget(); + this.onHandleChange("", "denomination") + this.computeAllBudget() }} value={this.state.model.denomination} - placeholder={'请输入'} + placeholder={"请输入"} disabled={this.state.isEdit} - labelWidth={'0px'} + labelWidth={"0px"} maxLength={6} - height={'36px'} - unit='元' + height={"36px"} + unit="元" countShow={false} - width={'520px'} - alignment={'left'} + width={"520px"} + alignment={"left"} /> ) : ( - + { - this.onHandleChange(value, 'min_denomination'); - this.computeMax_Min(); + this.onHandleChange(value, "min_denomination") + this.computeMax_Min() }} onClearItem={() => { - this.onHandleChange('', 'min_denomination'); - this.computeMax_Min(); + this.onHandleChange("", "min_denomination") + this.computeMax_Min() }} value={this.state.model.min_denomination} - placeholder={'请输入'} - labelWidth={'0px'} - unit='元' + placeholder={"请输入"} + labelWidth={"0px"} + unit="元" disabled={this.state.isEdit} countShow={false} maxLength={6} - height={'36px'} - width={'245px'} - alignment={'left'} + height={"36px"} + width={"245px"} + alignment={"left"} /> - ~ + ~ { - this.onHandleChange(value, 'max_denomination'); + this.onHandleChange(value, "max_denomination") }} onClearItem={() => { - this.onHandleChange('', 'max_denomination'); + this.onHandleChange("", "max_denomination") }} value={this.state.model.max_denomination} prolong={true} placeholder={ this.state.computeMax - ? `最大面额为${this.computeMin()} ~ ${ - this.state.computeMax - }` - : '请输入' + ? `最大面额为${this.computeMin()} ~ ${this.state.computeMax}` + : "请输入" } - labelWidth={'0px'} - unit='元' + labelWidth={"0px"} + unit="元" disabled={this.state.isEdit} countShow={false} maxLength={6} - height={'36px'} - width={'245px'} - alignment={'left'} + height={"36px"} + width={"245px"} + alignment={"left"} /> )} + key={"amount"} + id="all_budget" + labelname="合同总价" + prop="total_contract_price" + > { - this.onHandleChange(value, 'total_contract_price'); + this.onHandleChange(value, "total_contract_price") }} onClearItem={() => { - this.onHandleChange('', 'total_contract_price'); + this.onHandleChange("", "total_contract_price") }} - placeholder={'请输入'} + placeholder={"请输入"} disabled={this.state.isEdit} - labelWidth={'0px'} + labelWidth={"0px"} maxLength={9} - height={'36px'} - unit='元' + height={"36px"} + unit="元" countShow={false} - width={'520px'} - alignment={'left'} + width={"520px"} + alignment={"left"} /> - + { - this.onHandleChange(value, 'day_budget'); + this.onHandleChange(value, "day_budget") }} onClearItem={() => { - this.onHandleChange('', 'day_budget'); + this.onHandleChange("", "day_budget") }} disabled={this.state.isEdit} value={this.state.model.day_budget} - placeholder={'请输入'} - labelWidth={'0px'} + placeholder={"请输入"} + labelWidth={"0px"} maxLength={9} - height={'36px'} - unit='元' + height={"36px"} + unit="元" countShow={false} - width={'520px'} - alignment={'left'} + width={"520px"} + alignment={"left"} /> - + { - this.onHandleChange(value, 'receive_num'); + this.onHandleChange(value, "receive_num") }} onClearItem={() => { - this.onHandleChange('', 'receive_num'); + this.onHandleChange("", "receive_num") }} disabled={this.state.isEdit} value={this.state.model.receive_num} - placeholder={'请输入'} - labelWidth={'0px'} + placeholder={"请输入"} + labelWidth={"0px"} maxLength={4} - height={'36px'} - unit='个' + height={"36px"} + unit="个" countShow={false} - width={'304px'} - alignment={'left'} + width={"304px"} + alignment={"left"} /> { - this.onHandleChange(target.value, 'receive_every'); + this.onHandleChange(target.value, "receive_every") }} - value={Number(this.state.model.receive_every)}> + value={Number(this.state.model.receive_every)} + > {receiveTypeList.map(({ key, text }) => ( {text} @@ -829,99 +804,95 @@ export default class addKnockGold extends Component { {/*
时间限制
*/} - -
- + + + { - this.onHandleChange(value, 'effect_date'); + this.onHandleChange(value, "effect_date") }} disabledTime={this.onDisabledTime} disabledDate={this.onDisabledRange1} /> - -
+ +
{ - this.onHandleChange(target.value, 'receive_type'); - this.onHandleChange([[]], 'receive_day'); + this.onHandleChange(target.value, "receive_type") + this.onHandleChange([[]], "receive_day") this.onHandleChange( [ { - date: '', + date: "", time: [[]] } ], - 'receive_irregular' - ); + "receive_irregular" + ) this.onHandleChange( { week: [], time: [[]] }, - 'receive_rule' - ); - }}> + "receive_rule" + ) + }} + > 不设置
-
+
{ - this.onHandleChange(target.value, 'receive_type'); + this.onHandleChange(target.value, "receive_type") this.onHandleChange( [ { - date: '', + date: "", time: [[]] } ], - 'receive_irregular' - ); + "receive_irregular" + ) this.onHandleChange( { week: [], time: [[]] }, - 'receive_rule' - ); - }}> + "receive_rule" + ) + }} + > 每日可领 {this.state.model.receive_type === 3 && ( <> {this.state.model.receive_day.map((item, index) => ( -
+
{ - const model = this.state.model; - model.receive_day[index] = value; - this.setState({ model }); + const model = this.state.model + model.receive_day[index] = value + this.setState({ model }) }} // disabledTime={this.onDisabledTime1} /> @@ -931,58 +902,52 @@ export default class addKnockGold extends Component { )}
-
+
{ - this.onHandleChange(target.value, 'receive_type'); + this.onHandleChange(target.value, "receive_type") this.onHandleChange( [ { - date: '', + date: "", time: [[]] } ], - 'receive_irregular' - ); - this.onHandleChange([[]], 'receive_day'); - }}> + "receive_irregular" + ) + this.onHandleChange([[]], "receive_day") + }} + > 有效期内,规则日期可领 {this.state.model.receive_type === 1 && ( <> - this.onHandleChange(va, 'receive_rule', 'week') - } - style={{ marginLeft: '25px', marginTop: '20px' }}> + onChange={(va) => this.onHandleChange(va, "receive_rule", "week")} + style={{ marginLeft: "25px", marginTop: "20px" }} + > {week.map((week) => ( - + {week.text} ))} {this.state.model.receive_rule.time.map((item, index) => ( -
+
{ - const model = this.state.model; - model.receive_rule.time[index] = value; - this.setState({ model }); + const model = this.state.model + model.receive_rule.time[index] = value + this.setState({ model }) }} width={205} // disabledTime={this.onDisabledRange} @@ -990,28 +955,24 @@ export default class addKnockGold extends Component { {this.ruleComponents(index)}
))} -

- 请按照24小时制输入可用时段,最多设置3个时段 -

+

请按照24小时制输入可用时段,最多设置3个时段

)}
-
+
{ - this.onHandleChange(target.value, 'receive_type'); - this.onHandleChange( - { week: [], time: [[]] }, - 'receive_rule' - ); - this.onHandleChange([[]], 'receive_day'); - }}> + this.onHandleChange(target.value, "receive_type") + this.onHandleChange({ week: [], time: [[]] }, "receive_rule") + this.onHandleChange([[]], "receive_day") + }} + > 有效期内,不规则日期可领 {this.state.model.receive_type === 2 && ( <> -

+

可在有效期内任意选择时间天数,以及可用时段。 因当前微信支持问题,如选择不规则时间,微信卡包内当前仅会展示有效期,建议 将具体可用日期以及时间段填写在使用说明内。 @@ -1024,14 +985,15 @@ export default class addKnockGold extends Component {

{/*
预警规则
*/} - -
- + + + { - this.onHandleChange(value, 'early_per'); - }}> + this.onHandleChange(value, "early_per") + }} + > {earlyPerList.map((item) => ( {item}% @@ -1040,56 +1002,54 @@ 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'} + placeholder={""} + labelWidth={"0px"} maxLength={3} - height={'36px'} - unit='%' + height={"36px"} + unit="%" countShow={false} - width={'190px'} - alignment={'left'} + width={"190px"} + alignment={"left"} /> - -
+ +