diff --git a/src/pages/exchangecode/exchangecodeAdd/index.jsx b/src/pages/exchangecode/exchangecodeAdd/index.jsx index 5030e262..3f67d0e2 100644 --- a/src/pages/exchangecode/exchangecodeAdd/index.jsx +++ b/src/pages/exchangecode/exchangecodeAdd/index.jsx @@ -285,12 +285,13 @@ export default class exchangeAdd extends React.Component { //获取分销商 this.getResellerFunction(reqCopy.plan.reseller_id) - this.setState({ codeInfo: codeInfo }) - this.setState({ isload: true }) + this.setState({ codeInfo: codeInfo, isload: true }) + _.map(reqCopy.goods, (res) => { res.checked = true return res }) + this.setState({ tempdata: reqCopy.goods || [] }) let a1 = reqCopy.goods.map((item) => { @@ -339,9 +340,9 @@ export default class exchangeAdd extends React.Component { } } + /* 审核中转换数据 */ transFormData1(req, type) { const newData = [] - /* 转换数据结构 */ req.legal.map((item1) => { item1.type = 1 item1.only = item1.product_id @@ -362,6 +363,7 @@ export default class exchangeAdd extends React.Component { obj.id = item1?.goods_id } obj.product_id = item1?.goods_id + obj.code_batch_id = item1?.code_batch_id obj.product_type_text = "立减金" obj.contract_price = item1.price obj.create_time = item1.create_time @@ -392,7 +394,7 @@ export default class exchangeAdd extends React.Component { return newData } - /* 转换数据 */ + /* 无审核转换数据 */ transFormData(reqCopy) { const resData = [] reqCopy.goods.map((item) => { @@ -406,6 +408,8 @@ export default class exchangeAdd extends React.Component { item.entity.weight = item.weight resData.push(item.entity) } else if (item.type === 2) { + /* 复制状态下删除id */ + if (this.state.isState === 1) delete item.entity.id item.entity.weight = item.weight resData.push({ origin: item.entity, @@ -587,16 +591,26 @@ export default class exchangeAdd extends React.Component { end_time: this.state.codeInfo.date_time[1], describe: this.state.codeInfo.describe, quantity: this.state.codeInfo.issued, - range, + range: range.join(), title: this.state.codeInfo.code_name, - product: [ - { - legal: selection.filter((item2) => item2.type == 1), - reduce: selection - .filter((item3) => item3.type === 2) - .map((item4) => item4.origin) - } - ] + restrict: "50", + product: { + legal: selection.filter((item2) => { + if (item2.type == 1) { + delete item2.goods_id + delete item2.id + delete item2.only + delete item2.type + return item2 + } + }), + reduce: selection + .filter((item3) => item3.type === 2) + .map((item4) => { + delete item4.origin.goods_id + return item4.origin + }) + } } if (this.state.isState === 1) { @@ -604,7 +618,7 @@ export default class exchangeAdd extends React.Component { } let data = { - code_batch: newData, + code_batch: [newData], reseller_id: this.state.reseller.id, reseller_name: this.state.reseller.name, company_name: this.state.reseller.company_name, @@ -646,7 +660,7 @@ export default class exchangeAdd extends React.Component { /* 复制\新增状态下数据提交 */ submitCopyOrAddCodeData() { let data = this.copyOrAddBuildData() - let id = sessionStorage.getItem("keybatch_id") + let id = sessionStorage.getItem("keyBatch_id") keyEditApproval(id, data).then((res) => { handelResponse( @@ -937,13 +951,29 @@ export default class exchangeAdd extends React.Component { onDisabledRange = (date, type) => { let isdisabled = false let str = moment(date).format("YYYY-MM-DD HH:mm:ss") + const isDay = moment(this.state.plan_time[1]).format("HH:mm:ss") - if (type === "start") { - isdisabled = moment(str).isBefore(this.state.plan_time[0]) + /* 新增和复制时才生效 */ + if (type === "start" && this.state.isState !== 2) { + if (isDay < "23:59:59") { + isdisabled = + moment(str).isBefore(this.state.plan_time[0]) || + moment(str).subtract(1, "days").isAfter(this.state.plan_time[1]) + } else { + isdisabled = + moment(str).isBefore(this.state.plan_time[0]) || + moment(str).isAfter(this.state.plan_time[1]) + } } if (type === "end") { - isdisabled = moment(str).isAfter(this.state.plan_time[1]) + if (this.state.isState !== 2) { + isdisabled = + moment(str).add(1, "days").isBefore(this.state.plan_time[0]) || + moment(str).isAfter(this.state.plan_time[1]) + } else { + isdisabled = moment(str).isAfter(this.state.plan_time) + } } return isdisabled @@ -1036,6 +1066,22 @@ export default class exchangeAdd extends React.Component { this.setState({ codeInfo: model }) } + /* 新增处理处理归属计划关联数据 */ + vestingPlanFunction(e) { + if (!e?.key) return + this.getKeyBatchSelect(e.key) + this.getResellerFunction(e.reseller_id) + this.handleChange("", "keyBatchSelect") + this.setState({ + plan_time: [e.start_time, e.end_time] + }) + const time = { + start_time: e.start_time, + end_time: e.end_time + } + sessionStorage.setItem("knockGold_effectDate", JSON.stringify(time)) + } + render() { return (