From d90bb154e3d0a704915e8b758cb389c81de93d67 Mon Sep 17 00:00:00 2001 From: wangsongsole Date: Tue, 11 Jul 2023 14:29:40 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat:=20=E6=96=B0=E5=A2=9E=E4=BA=91?= =?UTF-8?q?=E9=97=AA=E4=BB=98=E6=A8=A1=E5=9D=97=EF=BC=8C=E5=B9=B6=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=E5=95=86=E5=93=81=E7=B1=BB=E5=9E=8B=E6=9E=9A=E4=B8=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/redPackets/index.jsx | 20 +- src/components/redPackets/index.less | 196 ++ src/components/redPackets/static.js | 10 + src/components/redPackets/wangEditor.jsx | 73 +- .../redPackets/ysf-mobileComponent.jsx | 134 ++ src/pages/coupon/commodity/index.jsx | 140 +- src/pages/exchangecode/add/add.js | 2140 ++++++++--------- src/pages/exchangecode/commodity/commodity.js | 5 +- .../exchangecode/exchangecodeAdd/utils.js | 5 +- src/pages/plan/add/step2.js | 1504 ++++++------ src/pages/plan/key/edit.js | 1364 ++++++----- src/tools/index.js | 17 +- 12 files changed, 2918 insertions(+), 2690 deletions(-) create mode 100644 src/components/redPackets/ysf-mobileComponent.jsx diff --git a/src/components/redPackets/index.jsx b/src/components/redPackets/index.jsx index 8fb0e5cd..c35ad90a 100644 --- a/src/components/redPackets/index.jsx +++ b/src/components/redPackets/index.jsx @@ -30,8 +30,9 @@ import cloneDeep from "lodash/cloneDeep" import omit from "lodash/omit" import { getVoucherWarningAccount, handelResponse } from "@/assets/api" import MobileComponent from "./mobileComponent" +import YSFMobileComponent from "./ysf-mobileComponent" import WangEditor from "./wangEditor" -import { receiveTypeList, week, earlyPerList, model } from "./static" +import { receiveTypeList, week, earlyPerList, model, ysf } from "./static" const initArray = (targetNum) => { return Array.from({ length: targetNum }, (_, index) => index) } @@ -519,15 +520,16 @@ export default class addKnockGold extends Component { disabled={this.state.isEdit} onChange={({ target }) => { this.onHandleChange(target.value, "channel") - // if (target.value == 1) { - // this.onHandleChange(defaultInstructionZfb, 'instruction'); - // } else { - // this.onHandleChange(defaultInstructionWx, 'instruction'); - // } + if (target.value === 3) { + this.onHandleChange(ysf, "instruction") + } else { + this.onHandleChange("", "instruction") + } }} value={this.state.model.channel} > 支付宝 + 云闪付 微信 @@ -1096,7 +1098,11 @@ export default class addKnockGold extends Component { - + {this.state.model.channel !== 3 ? ( + + ) : ( + + )} ) } diff --git a/src/components/redPackets/index.less b/src/components/redPackets/index.less index dc95f0c9..773256bf 100644 --- a/src/components/redPackets/index.less +++ b/src/components/redPackets/index.less @@ -192,6 +192,202 @@ } } +#ysf-redPacketsViews { + position: fixed !important; + top: 130px !important; + right: 90px !important; + border: 1px solid #e4e4e4; + border-radius: 5px; + font-size: 16px; + width: 375px !important; + box-sizing: border-box; + z-index: 1003; + overflow: auto; + scrollbar-width: none; + background-color: rgb(238 25 32); + padding: 25px 16px; + + &::-webkit-scrollbar { + display: none + } + + .available_time { + text-align: left; + margin-bottom: 8px; + + .available_time_text { + font-size: 16px; + padding-bottom: 5px; + margin-top: 5px; + box-sizing: border-box; + + } + + .timeList { + display: grid; + grid-template-columns: repeat(3, 33.33%); + text-align: center; + + li { + margin: 3px 0; + font-size: 11px; + color: #a8a8a8; + } + + } + } + + .type { + color: #fff; + font-size: 10px; + text-align: center; + margin-top: 10px; + } + + .type>span { + padding: 4px 14px; + background-color: rgb(238 25 32); + border-radius: 20px; + } + + .content { + min-height: 100%; + background: #fff; + position: relative; + padding: 0 14px 16px; + box-sizing: border-box; + border-radius: 0 0 6px 6px; + } + + .bubble { + width: 100%; + border-radius: 1.28px 1.28px 0 0; + display: flex; + margin-bottom: -1.2px; + } + + .segmentation { + display: flex; + justify-content: space-between; + width: 100%; + align-items: center; + } + + .left, + .right { + width: 10px; + height: 18px; + background: rgb(238 25 32); + display: inline-block; + } + + .left { + border-radius: 0 18px 18px 0; + margin-left: -15px; + } + + .right { + border-radius: 18px 0 0 18px; + margin-right: -15px; + } + + .middle { + width: 100%; + height: 1px; + background-image: linear-gradient(to right, + rgb(223, 222, 222) 0%, + rgb(223, 222, 222) 50%, + transparent 50%); + background-size: 8px 2px; + background-repeat: repeat-x; + } + + .title { + color: rgb(163, 160, 163); + text-align: center; + } + + .information { + text-align: center; + } + + .information-p2 { + color: rgb(145, 143, 146); + font-size: 12px; + } + + .money { + margin: 6px 0; + } + + .form { + margin: 30px 0; + } + + .mt0 { + margin-top: 0 !important; + } + + .form-label { + font-size: 16px; + } + + .form-input { + width: 100%; + height: 32px; + border-radius: 8px; + outline: 0; + border: .16px solid rgb(217, 216, 218); + background: #fffefe; + padding: 0 10px; + box-sizing: border-box; + margin: 10px 0; + font-size: 12px; + } + + .form-input::placeholder { + color: rgb(204, 205, 209); + font-size: 12px; + } + + .form-note { + color: red; + font-size: 11px; + } + + .text-center { + text-align: center; + } + + .form-button { + width: 100%; + height: 38px; + border-radius: 19.2px; + outline: 0; + border: 0; + font-size: 16px; + color: white; + background: rgb(238 25 32); + margin-top: 30px; + } + + .illustrate { + margin-top: 18px; + } + + .illustrate-title { + font-size: 16px; + margin-bottom: 6px; + } + + .illustrate-text { + color: rgb(150, 152, 158); + font-size: 12px; + line-height: 22px; + min-height: 200px; + } +} + #redPackets { diff --git a/src/components/redPackets/static.js b/src/components/redPackets/static.js index 0ca7eb54..194f858e 100644 --- a/src/components/redPackets/static.js +++ b/src/components/redPackets/static.js @@ -16,6 +16,16 @@ export const week = [ { key: "7", text: "周日" } ] +export const ysf = `用户可在云闪付APP-我的红包中查看最近60天内即将过期的云闪付红包金额及到期时间。用户参加活动 (如天天领红包、移动积分兑换红包等活动)获得的云闪付红包有效期以营销活动页面规则说明为准,到期后自动失效。 +
(一)在云闪付红包的有效期内不限使用时间 +
(二) 使用商户:专享红包支持云闪付APP内手机充值、水电煤缴费商城购物等多场景抵扣支付。也可通过云闪付APP在云闪付线下受理商户进行二维码主扫或被扫支付时抵扣。个别商户不支持红包抵扣,具体以支付结果为准。 +
(三) 使用规则: +
1、线下商户:用户在云闪付线下受理商户使用云闪付APP,出示付款码支付时,可使用云闪付红包抵扣订单金额,如肯德基、全家便利店、星巴克、屈臣氏、罗森便利店、DQ、来伊份等。 +
2、线上商户:在云闪付APP内或线上商户,选择云闪付APP支付时,可使用云闪付红包抵扣订单金额,如12306、京东到家、本来生活等。 +
3、1元云闪付红包可抵扣1元人民币订单金额。 +
4、订单金额满0.01元时,方可使用云闪付红包;抵扣订单金额时,需至少支付0.01元。 +
5、云闪付红包不可用于提现、购买活期+或者其他理财产品。` + //预警百分比 export const earlyPerList = ["70", "50", "30", "20"] diff --git a/src/components/redPackets/wangEditor.jsx b/src/components/redPackets/wangEditor.jsx index d459a7d6..39ed94dd 100644 --- a/src/components/redPackets/wangEditor.jsx +++ b/src/components/redPackets/wangEditor.jsx @@ -1,67 +1,56 @@ -import React from 'react'; -import Editor from 'wangeditor'; -import './index.less'; +import React from "react" +import Editor from "wangeditor" +import "./index.less" export default class wangEditor extends React.Component { constructor(props) { - super(props); + super(props) this.state = { - editorHtml: '', + editorHtml: "", count: 0 - }; + } } componentDidMount() { - let self = this; - const editor = new Editor('#wangeditorDom'); - this.setState({ editor }); - editor.config.colors = ['#696969', '#9093a2', '#fgddbb', '#e3e7eb']; - editor.config.pasteText = true; + let self = this + const editor = new Editor("#wangeditorDom") + this.setState({ editor }) + editor.config.colors = ["#696969", "#9093a2", "#fgddbb", "#e3e7eb"] + editor.config.pasteText = true // 设置编辑区域高度为 500px - editor.config.height = 200; - editor.config.showFullScreen = false; - editor.config.menus = [ - 'bold', - 'foreColor', - 'italic', - 'indent', - 'link', - 'justify' - ]; + editor.config.height = 200 + editor.config.showFullScreen = false + editor.config.menus = ["bold", "foreColor", "italic", "indent", "link", "justify"] // 注意,先配置 height ,再执行 create() // 注意,先配置 height ,再执行 create() editor.config.onchange = function (newHtml) { - var text = editor.txt.text(); + var text = editor.txt.text() if (text.length == 0) { //没有文字 - self.props.setEdittext(''); + self.props.setEdittext("") } if (text.length > self.props.limitLength) { - let str = text.slice(0, self.props.limitLength); - self.setState({ editorHtml: str }); - editor.txt.html(str); - self.props.setEdittext(str); - return; + let str = text.slice(0, self.props.limitLength) + self.setState({ editorHtml: str }) + editor.txt.html(str) + self.props.setEdittext(str) + return } - self.setState({ count: text.length }); - self.setState({ editorHtml: newHtml }); - self.props.setEdittext(newHtml); - }; + self.setState({ count: text.length }) + self.setState({ editorHtml: newHtml }) + self.props.setEdittext(newHtml) + } - editor.create(); + editor.create() //列表悬浮富文本 - setTimeout(() => { - editor.txt.html(this.props.text); - }, 100); + editor.txt.html(this.props.text) } render() { return ( -
-
-

- {this.state.count + '/' + this.props.limitLength} -

+
+
+

{this.state.count + "/" + this.props.limitLength}

- ); + ) } } diff --git a/src/components/redPackets/ysf-mobileComponent.jsx b/src/components/redPackets/ysf-mobileComponent.jsx new file mode 100644 index 00000000..18c09448 --- /dev/null +++ b/src/components/redPackets/ysf-mobileComponent.jsx @@ -0,0 +1,134 @@ +import "./index.less" +import { Placeholder } from "zent" +import { useState, useEffect } from "react" +import { sortWeeks } from "@/tools/utils.js" +const widths = [24, 100, 100, 100, 80, 100, 100, 100, 80, 100, 100, 100, 80, 100, 100, 100, 100] +export default ({ data }) => { + const [newWeek, setNewWeek] = useState([]) + useEffect(() => { + setNewWeek(sortWeeks(data.receive_rule.week)) + }, [data.receive_rule.week, data.receive_irregular]) + + function createElement() { + if (data.receive_type === 1) { + return ( +
+

领取时间

+
    + {newWeek?.map((item) => ( +
  • + {item} + {data.receive_rule.time.map((item1, index) => { + if (item1[1]) + return ( +

    + {item1[0]}~{item1[1]} +

    + ) + })} +
  • + ))} +
+
+ ) + } else if (data.receive_type === 2) { + return ( +
+

领取时间

+
    + {data.receive_irregular?.map((item) => ( +
  • + {item.date} + {item.time.map((item1) => { + if (item1[1]) + return ( +

    + {item1[0]}~{item1[1]} +

    + ) + })} +
  • + ))} +
+
+ ) + } else if (data.receive_type === 3) { + return ( +
+

领取时间

+
    + {data.receive_day?.map((item) => ( +
  • {item.join(" ~ ")}
  • + ))} +
+
+ ) + } + } + return ( +
+ +
+

云闪付

+
+

+ + ¥ + + {data.cash_amount_type === "1" + ? parseFloat(data.denomination || 0.01) + : `${parseFloat(data.min_denomination || 0.01)} ~ ${parseFloat( + data.max_denomination || 88.88 + )}`} +

+

+ 请在  + {data.effect_date[1] || "2023-12-30 23:59:59"} +  内领取 +

+

+ {data.cash_amount_type === "1" ? "固额红包" : "随机红包"} +

+
+
+

云闪付账号

+ + +

您可在云闪付的个人信息中查看【云闪付账号】

+ +
+
+ + + +
+
+ {data.instruction || [1, 2, 3].includes(data.receive_type) ? ( + <> + {createElement()} +

活动说明

+

+ + ) : ( + + )} +
+
+
+ ) +} diff --git a/src/pages/coupon/commodity/index.jsx b/src/pages/coupon/commodity/index.jsx index 21793b9d..23135269 100644 --- a/src/pages/coupon/commodity/index.jsx +++ b/src/pages/coupon/commodity/index.jsx @@ -1,17 +1,14 @@ -import React, { useRef, useEffect } from "react"; -import { useSetState } from "ahooks"; -import { Sweetalert, Notify } from "zent"; -import isNaN from "lodash/isNaN"; -import isNil from "lodash/isNil"; -import omitBy from "lodash/omitBy"; -import TabPage from "@/components/tabPage/main.js"; -import Ipt from "@/components/input/main"; -import Grid from "@/components/gird/main.js"; -import { - getCodeProductList, - handelResponse, - deleteGoodsScope -} from "@/assets/api.js"; +import React, { useRef, useEffect } from "react" +import { useSetState } from "ahooks" +import { Sweetalert, Notify } from "zent" +import isNaN from "lodash/isNaN" +import isNil from "lodash/isNil" +import omitBy from "lodash/omitBy" +import TabPage from "@/components/tabPage/main.js" +import Ipt from "@/components/input/main" +import Grid from "@/components/gird/main.js" +import { getCodeProductList, handelResponse, deleteGoodsScope } from "@/assets/api.js" +import { productTypeMenu } from "@/tools" const tableColumn = [ { @@ -92,7 +89,7 @@ const tableColumn = [ type: "slot", width: "200px" } -]; +] const UseCouponCommodity = () => { const [state, setState] = useSetState({ @@ -106,8 +103,8 @@ const UseCouponCommodity = () => { limit: 10, total: 0, isQuery: false - }); - const table_el = useRef(null); + }) + const table_el = useRef(null) /** * @@ -119,42 +116,42 @@ const UseCouponCommodity = () => { code_batch_id: sessionStorage.getItem("code_id"), page: state.page, limit: state.limit - }; + } param = omitBy( { ...param }, (value) => { - return isNaN(value) || isNil(value); + return isNaN(value) || isNil(value) } - ); - return param; - }; + ) + return param + } const getTable = () => { - let param = getParam(); + let param = getParam() getCodeProductList(param).then((res) => { handelResponse(res, (req, msg) => { - let resData = []; + let resData = [] req.data.map((item) => { /* type 1为商品 2为立减金 转译字符方便处理 */ /* 此处only 商品为product_id 立减金为channel_activity_id */ if (item.type === 1) { - item.entity.upstream = "直连天下"; - item.entity.only = item.entity.product_id; - item.entity.id = item.id; - item.entity.weight = item.weight; + item.entity.upstream = "直连天下" + item.entity.only = item.entity.product_id + item.entity.id = item.id + item.entity.weight = item.weight item.entity.all_budget = - Number(item.entity.contract_price) * Number(item.entity.quantity); - item.entity.type = 1; - resData.push(item.entity); + Number(item.entity.contract_price) * Number(item.entity.quantity) + item.entity.type = 1 + resData.push(item.entity) } else if (item.type === 2) { resData.push({ product_id: item.entity.goods_id, product_type_text: "立减金", only: item.entity.channel_activity_id, id: item.id, - upstream: String(item.entity.channel) === "1" ? "支付宝" : "微信", + upstream: productTypeMenu(item.entity.channel), code_batch_id: item.code_batch_id, contract_price: item.entity.price, create_time: item.create_time, @@ -167,31 +164,31 @@ const UseCouponCommodity = () => { item.entity.time_limit.effect_time.start_time + " 至 " + item.entity.time_limit.effect_time.end_time //有效时间 - }); + }) } - }); - setState({ tableData: resData }); - }); - }); - }; + }) + setState({ tableData: resData }) + }) + }) + } useEffect(() => { - getTable(); - }, [state.isQuery]); + getTable() + }, [state.isQuery]) - const selectionFun = () => {}; + const selectionFun = () => {} const searchCallback = () => { - getTable(); - }; + getTable() + } const onPageChange = (data) => { - setState({ page: data, isQuery: !state.isQuery }); - }; + setState({ page: data, isQuery: !state.isQuery }) + } const onCountChange = (data) => { - setState({ limit: data, isQuery: !state.isQuery }); - }; + setState({ limit: data, isQuery: !state.isQuery }) + } const tabChange = (data) => { - setState({ page: 1, limit: 10, status: data, isQuery: !state.isQuery }); - }; + setState({ page: 1, limit: 10, status: data, isQuery: !state.isQuery }) + } const deleteRow = (row) => { Sweetalert.confirm({ type: "warning", @@ -204,41 +201,37 @@ const UseCouponCommodity = () => { handelResponse( res, (response, msg) => { - Notify.clear(); - Notify.success(msg); - setState({ isQuery: !state.isQuery }); + Notify.clear() + Notify.success(msg) + setState({ isQuery: !state.isQuery }) }, (err) => { - Notify.error(err); + Notify.error(err) } - ); + ) }) - .catch((err) => {}); + .catch((err) => {}) }, onCancel() {}, className: "questModal", parentComponent: this - }); - }; + }) + } return ( -
- tabChange(data)}> -
+
+ tabChange(data)}> +
setState({ key_word: e })} value={state.key_word} wordSearch={() => searchCallback()} - icon='search' + icon="search" placeholder={"请输入商品名称进行匹配查询"} countShow={false} height={"36px"} width={"260px"} - onClearItem={(e) => - setState({ key_word: "", isQuery: !state.isQuery }) - } + onClearItem={(e) => setState({ key_word: "", isQuery: !state.isQuery })} alignment={"left"} />
@@ -267,7 +260,7 @@ const UseCouponCommodity = () => { {rowData.begin_time} 至 {rowData.end_time} - ); + ) } if (com === "opearo") { @@ -275,17 +268,18 @@ const UseCouponCommodity = () => {
deleteRow(rowData)}> + className="grid-link" + onClick={() => deleteRow(rowData)} + > 删除
- ); + ) } }} />
- ); -}; + ) +} -export default UseCouponCommodity; +export default UseCouponCommodity diff --git a/src/pages/exchangecode/add/add.js b/src/pages/exchangecode/add/add.js index 2d5f8137..968dcda9 100644 --- a/src/pages/exchangecode/add/add.js +++ b/src/pages/exchangecode/add/add.js @@ -1,5 +1,6 @@ -import { deWeightThree } from '@/tools/utils.js'; -import React from 'react'; +import { deWeightThree } from "@/tools/utils.js" +import { productTypeMenu } from "@/tools" +import React from "react" import { Card, Sweetalert, @@ -14,12 +15,12 @@ import { Icon, RadioGroup, RadioButton -} from 'zent'; -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 { divNum } from '@/tools/number'; +} from "zent" +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 { divNum } from "@/tools/number" import { addPlanStep, handelResponse, @@ -30,70 +31,70 @@ import { getReseller, getAccessVerification, getProductInfoSelect -} from '@/assets/api.js'; -import Productform from '@/pages/plan/product/add'; /* 商品 */ -import KnockGold from '@/components/knockGold'; /* 立减金 */ -import UseCouponAddEdit from '@/components/UseCouponAddEdit'; // 优惠券 +} from "@/assets/api.js" +import Productform from "@/pages/plan/product/add" /* 商品 */ +import KnockGold from "@/components/knockGold" /* 立减金 */ +import UseCouponAddEdit from "@/components/UseCouponAddEdit" // 优惠券 -import Bus from '@/assets/eventBus.js'; -import map from 'lodash/map'; -import filter from 'lodash/filter'; -import forEach from 'lodash/forEach'; -import './add.less'; -import moment from 'moment'; -import { isSameDay } from 'date-fns'; +import Bus from "@/assets/eventBus.js" +import map from "lodash/map" +import filter from "lodash/filter" +import forEach from "lodash/forEach" +import "./add.less" +import moment from "moment" +import { isSameDay } from "date-fns" const initArray = (targetNum) => { - return Array.from({ length: targetNum }, (_, index) => index); -}; + return Array.from({ length: targetNum }, (_, index) => index) +} export default class accList extends React.Component { constructor(props) { - super(props); + super(props) this.state = { keys: [ { style: 1, - quantity: '', + quantity: "", allow_repetition: 0, allow_loss: 0, merge_stock: 1, - code_batch: '', - draw_title: '' + code_batch: "", + draw_title: "" } ], model: { //数据模型不可少 style: 1, quantity: 0, - plan_id: '', - title: '', + plan_id: "", + title: "", allow_repetition: 0, allow_loss: 0, merge_stock: 1, - code_batch: '', - draw_title: '', - batch_name: '' + code_batch: "", + draw_title: "", + batch_name: "" }, drawerVisible: false, drawerVisible2: false, productData: [], codeInfo: { //数据模型不可少 - code_name: '', - issued: '', //发放总量 - describe: '', - date_time: '', - range: '' + code_name: "", + issued: "", //发放总量 + describe: "", + date_time: "", + range: "" }, rank: null, rankoptions: [], tempdata: [], distdata: [], - pagetitle: '新建key', + pagetitle: "新建key", isEdit: false, - begintime: '', - endtime: '', + begintime: "", + endtime: "", rowIndex: -1, uploading: false, audit_visible: false, @@ -103,7 +104,7 @@ export default class accList extends React.Component { phone_radio: -1, paytype: 3, reseller: null, - payment_direction: ['对私账户', '对公账户', '预付款扣除'], + payment_direction: ["对私账户", "对公账户", "预付款扣除"], import_visible: false, white_visible: false, success_visible: false, @@ -112,140 +113,140 @@ export default class accList extends React.Component { upload_visible: false, excel_visible: false, accessVerify: false, - mobile_excel: '', + mobile_excel: "", mobile_repeat: [], - execel_path: '', + execel_path: "", excel_count: 0, success_count: 0, error_count: 0, direct_reseller_id: 0, newGoodsBtnLoading: false, newGoldLoading: false, - product_title: '新建商品', - addIsType: '', - keyCodeId: '', //key批次ID - keyType: sessionStorage.getItem('bind_object') - ? Number(sessionStorage.getItem('bind_object')) + product_title: "新建商品", + addIsType: "", + keyCodeId: "", //key批次ID + keyType: sessionStorage.getItem("bind_object") + ? Number(sessionStorage.getItem("bind_object")) : 1, couponData: [], Column: [ { - title: '兑换名称', - name: 'title', - prop: 'title', - type: 'normal', - width: 'auto' + title: "兑换名称", + name: "title", + prop: "title", + type: "normal", + width: "auto" }, { - title: '兑换码范围', + title: "兑换码范围", - type: 'normal', - prop: 'range', - width: 'auto' + type: "normal", + prop: "range", + width: "auto" }, { - title: '有效开始日期', - prop: 'begin_time', - name: 'begin_time', - width: 'auto', - type: 'normal' + title: "有效开始日期", + prop: "begin_time", + name: "begin_time", + width: "auto", + type: "normal" }, { - title: '有效结束日期', - name: 'end_time', - prop: 'end_time', - type: 'normal', - width: 'auto' + title: "有效结束日期", + name: "end_time", + prop: "end_time", + type: "normal", + width: "auto" }, { - title: '兑换码数量', - name: 'quantity', - type: 'normal', - prop: 'quantity', - defaultText: 'PM', - width: 'auto' + title: "兑换码数量", + name: "quantity", + type: "normal", + prop: "quantity", + defaultText: "PM", + width: "auto" }, { - title: '绑定数', - prop: 'restrict', - name: 'restrict', - type: 'slot', - width: 'auto' + title: "绑定数", + prop: "restrict", + name: "restrict", + type: "slot", + width: "auto" }, { - title: '操作', - prop: 'edit', - name: 'edit', - type: 'slot', - width: 'auto' + title: "操作", + prop: "edit", + name: "edit", + type: "slot", + width: "auto" } ], Column_coupon: [ { - title: '优惠券名称', - name: 'title', - prop: 'title', - type: 'normal', - width: 'auto' + title: "优惠券名称", + name: "title", + prop: "title", + type: "normal", + width: "auto" }, { - title: '优惠券范围', - prop: 'product', - name: 'product', - width: 'auto', - type: 'slot' + title: "优惠券范围", + prop: "product", + name: "product", + width: "auto", + type: "slot" }, { - title: '有效开始日期', - prop: 'begin_time', - name: 'begin_time', - width: 'auto', - type: 'normal' + title: "有效开始日期", + prop: "begin_time", + name: "begin_time", + width: "auto", + type: "normal" }, { - title: '有效结束日期', - name: 'end_time', - prop: 'end_time', - type: 'normal', - width: 'auto' + title: "有效结束日期", + name: "end_time", + prop: "end_time", + type: "normal", + width: "auto" }, { - title: '优惠券数量', - name: 'quantity', - type: 'normal', - prop: 'quantity', - defaultText: 'PM', - width: 'auto' + title: "优惠券数量", + name: "quantity", + type: "normal", + prop: "quantity", + defaultText: "PM", + width: "auto" }, { - title: '绑定数', - prop: 'restrict', - name: 'restrict', - type: 'slot', - width: 'auto' + title: "绑定数", + prop: "restrict", + name: "restrict", + type: "slot", + width: "auto" }, { - title: '操作', - prop: 'edit', - name: 'edit', - type: 'slot', - width: 'auto' + title: "操作", + prop: "edit", + name: "edit", + type: "slot", + width: "auto" } ], - rowCouponData: '' - }; + rowCouponData: "" + } } componentDidMount(e) { - let batch_id = sessionStorage.getItem('keybatch_id'); - let copyOpearo = sessionStorage.getItem('copyOpearo'); + let batch_id = sessionStorage.getItem("keybatch_id") + let copyOpearo = sessionStorage.getItem("copyOpearo") //key样式 - let keystyle = sessionStorage.getItem('keyStyle'); + let keystyle = sessionStorage.getItem("keyStyle") if (keystyle == 1) { - let model = this.state.model; - model.style = 6; - this.setState({ model: model }); - this.setState({ white_visible: true }); + let model = this.state.model + model.style = 6 + this.setState({ model: model }) + this.setState({ white_visible: true }) } //复制 if (batch_id > 0 || copyOpearo == 2) { @@ -253,7 +254,7 @@ export default class accList extends React.Component { handelResponse( res, (req, msg) => { - this.setState({ pagetitle: '复制key' }); + this.setState({ pagetitle: "复制key" }) getReseller(req.reseller_id).then((res) => { handelResponse(res, (req, msg) => { this.setState({ @@ -261,10 +262,10 @@ export default class accList extends React.Component { phone_list: req.contact_phone, direct_reseller_id: req.direct_reseller_id, reseller: req - }); - this.getProductFunction(req.direct_reseller_id); - }); - }); + }) + this.getProductFunction(req.direct_reseller_id) + }) + }) let model = { title: req.plan_title, style: req.style, @@ -274,47 +275,47 @@ export default class accList extends React.Component { merge_stock: req.merge_stock, batch_name: `${req.batch_name}_${++req.copy_count}`, plan_id: req.plan_id - }; + } // 兑换码 if (req.bind_object[0] === 1) { - model.code_batch = req.code_batch; - console.log('详情 =>', req); + model.code_batch = req.code_batch + console.log("详情 =>", req) let list = map(req.code_batch, (item) => { - item.product = this.transFormData1(item.product); - return item; - }); - this.setState({ distdata: list }); + item.product = this.transFormData1(item.product) + return item + }) + this.setState({ distdata: list }) } else { // 优惠券 let temp = map(req.coupon, (o) => { - o.checked = true; - return o; - }); - model.coupon = temp; - this.setState({ couponData: temp }); + o.checked = true + return o + }) + model.coupon = temp + this.setState({ couponData: temp }) } - this.setState({ keyType: req.bind_object[0] }); - this.setState({ model: model }); - this.setState({ endtime: req.end_time }); - this.setState({ begintime: req.begin_time }); - this.setState({ keyCodeId: req.id }); + this.setState({ keyType: req.bind_object[0] }) + this.setState({ model: model }) + this.setState({ endtime: req.end_time }) + this.setState({ begintime: req.begin_time }) + this.setState({ keyCodeId: req.id }) }, (err) => {} - ); - }); + ) + }) } else { - let plan_item = sessionStorage.getItem('plan_item'); + let plan_item = sessionStorage.getItem("plan_item") if (plan_item) { - plan_item = JSON.parse(plan_item); - let model = this.state.model; - model.title = plan_item.title; - model.plan_id = plan_item.id; - this.setState({ model: model }); - this.setState({ endtime: plan_item.end_time }); - this.setState({ begintime: plan_item.begin_time }); + plan_item = JSON.parse(plan_item) + let model = this.state.model + model.title = plan_item.title + model.plan_id = plan_item.id + this.setState({ model: model }) + this.setState({ endtime: plan_item.end_time }) + this.setState({ begintime: plan_item.begin_time }) - let id = plan_item.reseller_id; + let id = plan_item.reseller_id getReseller(id).then((res) => { handelResponse(res, (req, msg) => { @@ -323,413 +324,403 @@ export default class accList extends React.Component { direct_reseller_id: req.direct_reseller_id, email_list: req.contact_email, phone_list: req.contact_phone - }); - this.getProductFunction(req.direct_reseller_id); - }); - }); + }) + this.getProductFunction(req.direct_reseller_id) + }) + }) let codeInfo = { //数据模型不可少 - code_name: '', - issued: '', //发放总量 - describe: '', + code_name: "", + issued: "", //发放总量 + describe: "", date_time: [plan_item.begin_time, plan_item.end_time], - range: '' - }; + range: "" + } - this.setState({ codeInfo: codeInfo }); + this.setState({ codeInfo: codeInfo }) } } } onPayTypeChange(e) { - this.setState({ paytype: e.target.value }); + this.setState({ paytype: e.target.value }) } transFormData1(req) { - const newData = []; + const newData = [] req.legal.map((item1) => { - item1.type = 1; - item1.only = item1.product_id; - item1.upstream = '直连天下'; + item1.type = 1 + item1.only = item1.product_id + item1.upstream = "直连天下" if (item1?.goods_id) { - item1.id = item1.goods_id; + item1.id = item1.goods_id } - newData.push(item1); - }); + newData.push(item1) + }) req.reduce.map((item1) => { - let obj = {}; - obj.type = 2; - obj.only = item1.channel_activity_id; - obj.upstream = String(item1.channel) === '1' ? '支付宝' : '微信'; //上游 - obj.origin = item1; + let obj = {} + obj.type = 2 + obj.only = item1.channel_activity_id + obj.upstream = productTypeMenu(item1.channel) //上游 + obj.origin = item1 /* 复制状态删除id */ if (this.state.isState === 1) { - delete item1.id; + delete item1.id } if (item1?.goods_id) { - obj.id = item1?.goods_id; + 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; - obj.official_price = item1.reduce_amount; - obj.channel_activity_id = item1.channel_activity_id; - obj.product_name = item1.batch_goods_name; + 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 + obj.official_price = item1.reduce_amount + obj.channel_activity_id = item1.channel_activity_id + obj.product_name = item1.batch_goods_name obj.stock = parseInt( divNum(item1.all_budget, item1.reduce_amount) - divNum(item1.used_amount, item1.reduce_amount) - ); + ) obj.quantity = parseInt( divNum(item1.all_budget, item1.reduce_amount) - divNum(item1.used_amount, item1.reduce_amount) - ); + ) obj.usage = parseInt( divNum(item1.all_budget, item1.reduce_amount) - divNum(item1.all_budget - item1.used_amount, item1.reduce_amount) - ); + ) obj.effectDate = - item1.time_limit.effect_time.start_time + - ' 至 ' + - item1.time_limit.effect_time.end_time; - newData.push(obj); - }); //有效时间 - return newData; + item1.time_limit.effect_time.start_time + " 至 " + item1.time_limit.effect_time.end_time + newData.push(obj) + }) //有效时间 + return newData } /* 获取商品列表 */ getProductFunction(id) { getProductInfoSelect({ reseller_id: id }).then((res) => { if (res.code === 200) { - sessionStorage.setItem('productsList', JSON.stringify(res.data.data)); + sessionStorage.setItem("productsList", JSON.stringify(res.data.data)) } - }); + }) } async submit() { - let valide = false; + let valide = false if (this.refs.form1.validator()) { - let data = {}; - data.batch_name = this.state.model.batch_name; - data.style = this.state.model.style; - data.quantity = this.state.model.quantity; - data.bind_object = this.state.model.bind_object; - data.allow_repetition = this.state.model.allow_repetition; - data.allow_loss = this.state.model.allow_loss; - data.merge_stock = this.state.model.merge_stock; - data.code_batch = this.state.distdata; - let formdata = {}; - formdata.step = 'key'; - formdata.data = data; - await addPlanStep('', formdata).then((res) => { + let data = {} + data.batch_name = this.state.model.batch_name + data.style = this.state.model.style + data.quantity = this.state.model.quantity + data.bind_object = this.state.model.bind_object + data.allow_repetition = this.state.model.allow_repetition + data.allow_loss = this.state.model.allow_loss + data.merge_stock = this.state.model.merge_stock + data.code_batch = this.state.distdata + let formdata = {} + formdata.step = "key" + formdata.data = data + await addPlanStep("", formdata).then((res) => { handelResponse( res, (req, msg) => { - sessionStorage.setItem('plan_id', req.id); - valide = true; - return; + sessionStorage.setItem("plan_id", req.id) + valide = true + return }, (err) => { - Notify.error(err); + Notify.error(err) } - ); - }); + ) + }) } - return valide; + return valide } importClick() { if (this.state.file_loading) { - Notify.error('文件正在解析中请稍等'); + Notify.error("文件正在解析中请稍等") } else { if (this.state.success_visible) { - this.setState({ accessVerify: false }); - this.setState({ excel_visible: true }); - this.setState({ import_visible: false }); + this.setState({ accessVerify: false }) + this.setState({ excel_visible: true }) + this.setState({ import_visible: false }) } else { - Notify.error('请上传正确的文件'); + Notify.error("请上传正确的文件") } } } Cancel() { Sweetalert.confirm({ - type: 'warning', + type: "warning", closeBtn: true, - title: '确认操作', + title: "确认操作", content:

是否取消本次操作?

, onConfirm: () => { - window.history.back(); + window.history.back() }, onCancel: this.onCancel, - className: 'questModal', + className: "questModal", parentComponent: this - }); + }) } onCheckChange = (e) => { - this.setState({ keyType: e.target.value }); - }; + this.setState({ keyType: e.target.value }) + } onStyleChange(e) { - let model2 = this.state.model; - model2.style = e.target.value; - model2.quantity = 0; - this.setState({ model: model2 }); + let model2 = this.state.model + model2.style = e.target.value + model2.quantity = 0 + this.setState({ model: model2 }) if (e.target.value == 6) { - this.setState({ white_visible: true }); + this.setState({ white_visible: true }) } else { - this.setState({ white_visible: false }); + this.setState({ white_visible: false }) } } onRepetitionChange(e) { - let model2 = this.state.model; - model2.allow_repetition = e.target.value; - this.setState({ model: model2 }); + let model2 = this.state.model + model2.allow_repetition = e.target.value + this.setState({ model: model2 }) } onLossChange(e) { - let model2 = this.state.model; - model2.allow_loss = e.target.value; - this.setState({ model: model2 }); + let model2 = this.state.model + model2.allow_loss = e.target.value + this.setState({ model: model2 }) } checkIndex(e) { switch (e) { case 0: - this.setState({ draw_title: '新建兑换码' }); - break; + this.setState({ draw_title: "新建兑换码" }) + break case 1: - this.setState({ draw_title: '新建优惠券' }); - break; + this.setState({ draw_title: "新建优惠券" }) + break case 2: - this.setState({ draw_title: '新建立减金' }); - break; + this.setState({ draw_title: "新建立减金" }) + break default: - return; + return } - this.setState({ drawerVisible: false, rowIndex: -1 }); + this.setState({ drawerVisible: false, rowIndex: -1 }) this.state.codeInfo = { //数据模型不可少 - code_name: '', - issued: '', //发放总量 - describe: '', + code_name: "", + issued: "", //发放总量 + describe: "", date_time: [this.state.begintime, this.state.endtime], - range: '' - }; - this.setState({ tempdata: [] }); - this.setState({ rank: null }); - this.setState({ rankoptions: [] }); - this.setState({ drawerVisible: true }); + range: "" + } + this.setState({ tempdata: [] }) + this.setState({ rank: null }) + this.setState({ rankoptions: [] }) + this.setState({ drawerVisible: true }) if (this.state.keyType === 2) { setTimeout(() => { - this.refs.addEditCouponEl.clearCouponForm(); - }); + this.refs.addEditCouponEl.clearCouponForm() + }) } - sessionStorage.setItem('productData', ''); - sessionStorage.setItem('knockGoldData', ''); + sessionStorage.setItem("productData", "") + sessionStorage.setItem("knockGoldData", "") } closeDraw() { if (this.state.keyType === 2) { setTimeout(() => { - this.refs.addEditCouponEl.clearCouponForm(); - }); + this.refs.addEditCouponEl.clearCouponForm() + }) } - this.setState({ drawerVisible: false }); + this.setState({ drawerVisible: false }) } addProduct(type) { - this.setState({ addIsType: type }); /* 类型 */ - let direct_reseller_ids = this.state.direct_reseller_id; + this.setState({ addIsType: type }) /* 类型 */ + let direct_reseller_ids = this.state.direct_reseller_id if (direct_reseller_ids <= 0) { // 老数据不能进行新增商品操作 - Notify.error(`请添加映射分销商`); - return; + Notify.error(`请添加映射分销商`) + return } - if (type === 'addProduct') { - this.setState({ product_title: '新建商品', newGoodsBtnLoading: true }); + if (type === "addProduct") { + this.setState({ product_title: "新建商品", newGoodsBtnLoading: true }) } else { - this.setState({ product_title: '新增立减金', newGoldLoading: true }); + this.setState({ product_title: "新增立减金", newGoldLoading: true }) } try { - this.setState({ productData: null }); - this.setState({ drawerVisible2: true }); + this.setState({ productData: null }) + this.setState({ drawerVisible2: true }) - if (type === 'addProduct') { + if (type === "addProduct") { this.setState({ newGoodsBtnLoading: false - }); + }) } else { this.setState({ newGoldLoading: false - }); + }) } } catch (err) { - if (type === 'addProduct') { + if (type === "addProduct") { this.setState({ newGoodsBtnLoading: false - }); + }) } else { this.setState({ newGoldLoading: false - }); + }) } } } //渲染范围列表数据以及数据转换 async productSubmit() { - let visible = ''; - if (this.state.addIsType === 'addProduct') { - visible = await this.refs.product.submit(); + let visible = "" + if (this.state.addIsType === "addProduct") { + visible = await this.refs.product.submit() } else { - visible = await this.refs.knockGold.submit(); + visible = await this.refs.knockGold.submit() } if (visible) { - Notify.success('保存成功'); - this.setState({ drawerVisible2: false }); + Notify.success("保存成功") + this.setState({ drawerVisible2: false }) setTimeout(() => { - let data = null; - let temp = null; - let concatData = []; + let data = null + let temp = null + let concatData = [] /* 处理商品 */ - if (this.state.addIsType === 'addProduct') { - data = JSON.parse(sessionStorage.getItem('productData')).filter( - (item) => item.type !== 2 - ); - concatData = this.state.tempdata.filter((item) => item.type !== 1); + if (this.state.addIsType === "addProduct") { + data = JSON.parse(sessionStorage.getItem("productData")).filter((item) => item.type !== 2) + concatData = this.state.tempdata.filter((item) => item.type !== 1) temp = map(data, (item) => { let index = this.state.tempdata.findIndex((o) => { - return o.product_id == item.product_id; - }); + return o.product_id == item.product_id + }) if (index > -1) { - item.checked = this.state.tempdata[index].checked; + item.checked = this.state.tempdata[index].checked } - item.type = 1; - item.only = item.product_id; - item.upstream = '直连天下'; - return item; - }); + item.type = 1 + item.only = item.product_id + item.upstream = "直连天下" + return item + }) } else { /* 处理立减金 */ - data = JSON.parse(sessionStorage.getItem('knockGoldData')).filter( + data = JSON.parse(sessionStorage.getItem("knockGoldData")).filter( (item) => item.type !== 1 - ); - concatData = this.state.tempdata.filter((item) => item.type !== 2); + ) + concatData = this.state.tempdata.filter((item) => item.type !== 2) temp = map(data, (item) => { let index = this.state.tempdata.findIndex((o) => { - return o.channel_activity_id === item.channel_activity_id; - }); + return o.channel_activity_id === item.channel_activity_id + }) if (index > -1) { - item.checked = this.state.tempdata[index].checked; + item.checked = this.state.tempdata[index].checked } /* 转换商品结构 */ // temp - const newObj = {}; - newObj.product_name = item.batch_goods_name - ? item.batch_goods_name - : item.product_name; //名字 - newObj.map_product_name = item.product_name; - newObj.channel_activity_id = item.channel_activity_id; //批次号 - newObj.only = item.channel_activity_id; //批次号 - newObj.type = 2; //类型 - newObj.checked = item?.checked; - newObj.upstream = String(item.channel) === '1' ? '支付宝' : '微信'; //上游 - newObj.edit = 'edit'; + const newObj = {} + newObj.product_name = item.batch_goods_name ? item.batch_goods_name : item.product_name //名字 + newObj.map_product_name = item.product_name + newObj.channel_activity_id = item.channel_activity_id //批次号 + newObj.only = item.channel_activity_id //批次号 + newObj.type = 2 //类型 + newObj.checked = item?.checked + newObj.upstream = productTypeMenu(item.channel) //上游 + newObj.edit = "edit" newObj.effectDate = item.effectDate ? item.effectDate : item.time_limit?.effect_time.start_time + - ' 至 ' + - item.time_limit?.effect_time.end_time; //有效时间 - newObj.contract_price = item.contract_price - ? item.contract_price - : item.price; //单价 - newObj.official_price = item.official_price - ? item.official_price - : item.reduce_amount; //官方价 + " 至 " + + item.time_limit?.effect_time.end_time //有效时间 + newObj.contract_price = item.contract_price ? item.contract_price : item.price //单价 + newObj.official_price = item.official_price ? item.official_price : item.reduce_amount //官方价 newObj.quantity = item.quantity ? item.quantity - : parseInt(divNum(item.all_budget, item.reduce_amount)); //总库 - newObj.origin = item?.origin ? item?.origin : item; - return newObj; - }); + : parseInt(divNum(item.all_budget, item.reduce_amount)) //总库 + newObj.origin = item?.origin ? item?.origin : item + return newObj + }) } - let newArray = deWeightThree(temp.concat(concatData), 'only'); + let newArray = deWeightThree(temp.concat(concatData), "only") //select数据 - let arr = []; - let rank = []; + let arr = [] + let rank = [] map(newArray, (res) => { - arr.push({ key: res.only, text: res.product_name }); + arr.push({ key: res.only, text: res.product_name }) if (res.checked) { - rank.push({ key: res.only, text: res.product_name }); + rank.push({ key: res.only, text: res.product_name }) } - }); - arr = deWeightThree(arr, 'key'); - this.setState({ tempdata: newArray, rankoptions: arr, rank }); - }, 500); + }) + arr = deWeightThree(arr, "key") + this.setState({ tempdata: newArray, rankoptions: arr, rank }) + }, 500) } } onChangeCombinedDate(e) { - let model2 = this.state.codeInfo; - model2.date_time = e; - this.setState({ codeInfo: model2 }); + let model2 = this.state.codeInfo + model2.date_time = e + this.setState({ codeInfo: model2 }) } submit2() { - this.refs.form2.validator(); + this.refs.form2.validator() } //select onRankChange(e) { forEach(this.state.tempdata, (item) => { item.checked = e.findIndex((checks) => { - return checks.key == item.only; - }) > -1; - }); - this.setState({ tempdata: this.state.tempdata }); - this.setState({ rank: e }); + return checks.key == item.only + }) > -1 + }) + this.setState({ tempdata: this.state.tempdata }) + this.setState({ rank: e }) } codeSubmit() { // 优惠券 if (this.state.keyType === 2) { - let coupon_validator = this.refs.addEditCouponEl.submit(); + let coupon_validator = this.refs.addEditCouponEl.submit() if (coupon_validator) { - let param = this.refs.addEditCouponEl.getModel(); - let tempdata = this.state.couponData; + let param = this.refs.addEditCouponEl.getModel() + let tempdata = this.state.couponData // 优惠券编辑 if (this.state.rowIndex > -1) { - tempdata[this.state.rowIndex] = param; - this.setState({ couponData: tempdata }); + tempdata[this.state.rowIndex] = param + this.setState({ couponData: tempdata }) } else { // 优惠券新增 - tempdata.push(param); - this.setState({ couponData: tempdata }); + tempdata.push(param) + this.setState({ couponData: tempdata }) } this.setState({ drawerVisible: false - }); + }) } - return; + return } if (this.refs.code_info.validator() && this.refs.code_rule.validator()) { if (this.state.uploading) { - Notify.error('还有图片上传中,不可提交'); - return; + Notify.error("还有图片上传中,不可提交") + return } let productlist = filter(this.state.tempdata, (item) => { - return item.checked == true; - }); - let sum = 0; + return item.checked == true + }) + let sum = 0 forEach(productlist, (o) => { - sum += parseInt(o.quantity); - }); + sum += parseInt(o.quantity) + }) if (sum < this.state.codeInfo.issued) { - Notify.error('所选商品库存总数小于发放量'); - return; + Notify.error("所选商品库存总数小于发放量") + return } //let productList = JSON.parse(sessionStorage.getItem("productsList")); - this.setState({ drawerVisible: false }); + this.setState({ drawerVisible: false }) let rank = map(this.state.rank, (item) => { - return item.text; - }); + return item.text + }) let temp = { title: this.state.codeInfo.code_name, @@ -739,214 +730,209 @@ export default class accList extends React.Component { quantity: this.state.codeInfo.issued, range: rank.toString(), restrict: this.state.codeInfo.restrict - }; + } let arr = map(productlist, (item) => { - let obj = {}; - obj.product_id = item.product_id; - obj.product_type = item.product_type; - obj.product_name = item.product_name; - obj.account_type = item.account_type; - obj.contract_price = item.contract_price; - obj.cost_price = item.cost_price; - obj.official_price = item.official_price; - obj.quantity = item.quantity; - obj.show_url = item.show_url; - obj.describe_url = item.describe_url; - obj.detail_url = item.detail_url; - obj.map_product_name = item.map_product_name; + let obj = {} + obj.product_id = item.product_id + obj.product_type = item.product_type + obj.product_name = item.product_name + obj.account_type = item.account_type + obj.contract_price = item.contract_price + obj.cost_price = item.cost_price + obj.official_price = item.official_price + obj.quantity = item.quantity + obj.show_url = item.show_url + obj.describe_url = item.describe_url + obj.detail_url = item.detail_url + obj.map_product_name = item.map_product_name if (item.type === 2) { - obj.channel_activity_id = item.channel_activity_id; //批次号 - obj.effectDate = item.effectDate; //有效时间 - obj.origin = item.origin; // 原始数据 + obj.channel_activity_id = item.channel_activity_id //批次号 + obj.effectDate = item.effectDate //有效时间 + obj.origin = item.origin // 原始数据 } - obj.only = item.only; - obj.weight = item.weight; - obj.type = item.type; - obj.upstream = item.upstream; - return obj; - }); - temp.product = arr; + obj.only = item.only + obj.weight = item.weight + obj.type = item.type + obj.upstream = item.upstream + return obj + }) + temp.product = arr if (this.state.rowIndex > -1) { - this.state.distdata[this.state.rowIndex] = temp; - this.setState({ distdata: this.state.distdata }); + this.state.distdata[this.state.rowIndex] = temp + this.setState({ distdata: this.state.distdata }) } else { - let tempdata = this.state.distdata; - tempdata.push(temp); - this.setState({ distdata: tempdata }); + let tempdata = this.state.distdata + tempdata.push(temp) + this.setState({ distdata: tempdata }) } } } onAddKey() { let obj = { - style: '1', - quantity: '', + style: "1", + quantity: "", allow_repetition: 0, allow_loss: 0, - merge_stock: '1', - code_batch: '', - draw_title: '', - batch_name: '' - }; - let keys = this.state.keys; - keys.push(obj); - this.setState({ keys: keys }); + merge_stock: "1", + code_batch: "", + draw_title: "", + batch_name: "" + } + let keys = this.state.keys + keys.push(obj) + this.setState({ keys: keys }) } onAudit() { if (!this.state.reseller) { - Notify.error('对应分销商数据不存在'); - return; + Notify.error("对应分销商数据不存在") + return } // 兑换码 if (this.state.keyType === 1) { - let id = sessionStorage.getItem('keybatch_id'); + let id = sessionStorage.getItem("keybatch_id") if (this.state.isEdit) { - let selection = this.refs.bindObj.getSelectData(); + let selection = this.refs.bindObj.getSelectData() let formdata = selection.filter((item) => { - return !item.hasOwnProperty('disabled'); - }); + return !item.hasOwnProperty("disabled") + }) let data = { code_batch: formdata - }; + } putKeyBatchDetail(id, data).then((res) => { handelResponse( res, (req, msg) => { setTimeout(() => { - window.history.back(); - }, 1000); + window.history.back() + }, 1000) }, (err) => { - Notify.error(err); + Notify.error(err) } - ); - }); + ) + }) } else { if (this.refs.form1.validator()) { /* 处理数据 区分立减金和商品 开始 2022-05-30 13:40*/ - const dataCopy = this.refs.bindObj.getSelectData(); + const dataCopy = this.refs.bindObj.getSelectData() dataCopy.map((item) => { - item.products = item.product; - }); + item.products = item.product + }) dataCopy.map((item) => item.products.map(() => { item.product = { legal: item.products.filter((item2) => item2.type === 1), reduce: item.products .map((item2) => { - if (item2.type === 2) return item2.origin; + if (item2.type === 2) return item2.origin }) .filter((item3) => item3) - }; + } }) - ); + ) dataCopy.map((item) => { - delete item.products; - }); + delete item.products + }) /* 处理数据 区分立减金和商品 完成 2022-05-30 13:40*/ - let data = {}; - data.batch_name = this.state.model.batch_name; - data.style = this.state.model.style; - data.quantity = this.state.model.quantity; - data.bind_object = [this.state.keyType]; - data.allow_repetition = this.state.model.allow_repetition; - data.allow_loss = this.state.model.allow_loss; - data.merge_stock = this.state.model.merge_stock; - data.code_batch = dataCopy; - data.reseller_id = this.state.reseller.id; - data.reseller_name = this.state.reseller.name; - data.company_name = this.state.reseller.company_name; - data.receive_email = this.state.reseller.contact_email[0]; - data.payment_direction = - this.state.payment_direction[this.state.paytype - 1]; - data.mobile_excel = this.state.mobile_excel; - data.mobile_repeat = this.state.mobile_repeat; + let data = {} + data.batch_name = this.state.model.batch_name + data.style = this.state.model.style + data.quantity = this.state.model.quantity + data.bind_object = [this.state.keyType] + data.allow_repetition = this.state.model.allow_repetition + data.allow_loss = this.state.model.allow_loss + data.merge_stock = this.state.model.merge_stock + data.code_batch = dataCopy + data.reseller_id = this.state.reseller.id + data.reseller_name = this.state.reseller.name + data.company_name = this.state.reseller.company_name + data.receive_email = this.state.reseller.contact_email[0] + data.payment_direction = this.state.payment_direction[this.state.paytype - 1] + data.mobile_excel = this.state.mobile_excel + data.mobile_repeat = this.state.mobile_repeat if (data.code_batch.length == 0) { - Notify.error('请绑定对象'); - return; + Notify.error("请绑定对象") + return } - this.setState({ audit_visible: false }); - data.copy_key_batch_id = this.state.keyCodeId; + this.setState({ audit_visible: false }) + data.copy_key_batch_id = this.state.keyCodeId addKeysBatchInfo(this.state.model.plan_id, data).then((res) => { handelResponse( res, (req, msg) => { - Notify.success(res.message); + Notify.success(res.message) setTimeout(() => { - window.history.back(); - }, 2000); + window.history.back() + }, 2000) }, (err) => { - Notify.error(err); + Notify.error(err) } - ); - }); + ) + }) } } } else { // 优惠券 if (this.refs.form1.validator()) { - let data = {}; - data.batch_name = this.state.model.batch_name; - data.style = this.state.model.style; - data.quantity = this.state.model.quantity; - data.bind_object = [this.state.keyType]; - data.allow_repetition = this.state.model.allow_repetition; - data.allow_loss = this.state.model.allow_loss; - data.merge_stock = this.state.model.merge_stock; - data.coupon = this.state.couponData.filter((item) => item.checked); - data.mobile_excel = this.state.mobile_excel; - data.mobile_repeat = this.state.mobile_repeat; - data.payment_direction = - this.state.payment_direction[this.state.paytype - 1]; - data.copy_key_batch_id = this.state.keyCodeId; - console.log('大提交 =>', data); - let id = sessionStorage.getItem('key_plan_id'); + let data = {} + data.batch_name = this.state.model.batch_name + data.style = this.state.model.style + data.quantity = this.state.model.quantity + data.bind_object = [this.state.keyType] + data.allow_repetition = this.state.model.allow_repetition + data.allow_loss = this.state.model.allow_loss + data.merge_stock = this.state.model.merge_stock + data.coupon = this.state.couponData.filter((item) => item.checked) + data.mobile_excel = this.state.mobile_excel + data.mobile_repeat = this.state.mobile_repeat + data.payment_direction = this.state.payment_direction[this.state.paytype - 1] + data.copy_key_batch_id = this.state.keyCodeId + console.log("大提交 =>", data) + let id = sessionStorage.getItem("key_plan_id") addKeysBatchInfo(id, data).then((res) => { handelResponse( res, (req, msg) => { - Notify.success(res.message); + Notify.success(res.message) setTimeout(() => { - window.history.back(); - }, 2000); + window.history.back() + }, 2000) }, (err) => { - Notify.error(err); + Notify.error(err) } - ); - }); + ) + }) } } } onBindNum(e, row, rowIndex) { if (this.state.keyType === 1) { - this.state.distdata[rowIndex].restrict = e.target.value; - this.setState({ distdata: this.state.distdata }); + this.state.distdata[rowIndex].restrict = e.target.value + this.setState({ distdata: this.state.distdata }) } else { - this.state.couponData[rowIndex].restrict = e.target.value; - this.setState({ couponData: this.state.couponData }); + this.state.couponData[rowIndex].restrict = e.target.value + this.setState({ couponData: this.state.couponData }) } } onDisabledRange = (date, type) => { - let step1 = JSON.parse(sessionStorage.getItem('plan_item')); - let isdisabled = false; - let str = moment(date).format('YYYY-MM-DD HH:mm:ss'); - if (type == 'start') { - isdisabled = - moment(str).isBefore(step1.begin_time) || - moment(str).isAfter(step1.end_time); + let step1 = JSON.parse(sessionStorage.getItem("plan_item")) + let isdisabled = false + let str = moment(date).format("YYYY-MM-DD HH:mm:ss") + if (type == "start") { + 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 + } rowItemClick(row, rowIndex) { // 兑换码 @@ -959,508 +945,505 @@ export default class accList extends React.Component { date_time: [row.begin_time, row.end_time], range: row.range, restrict: row.restrict - }; + } let arr = map(row.product, (res) => { - let obj = {}; - obj.key = res.only; - obj.text = res.product_name; - return obj; - }); + let obj = {} + obj.key = res.only + obj.text = res.product_name + return obj + }) this.setState({ - draw_title: '编辑兑换码', + draw_title: "编辑兑换码", rankoptions: arr, rank: arr, codeInfo: codeInfo, rowIndex: rowIndex - }); + }) let temp = map(row.product, (o) => { - o.checked = true; - return o; - }); + o.checked = true + return o + }) - sessionStorage.setItem('productData', JSON.stringify(row.product)); - sessionStorage.setItem('knockGoldData', JSON.stringify(row.product)); - this.setState({ drawerVisible: true, tempdata: temp }); + sessionStorage.setItem("productData", JSON.stringify(row.product)) + sessionStorage.setItem("knockGoldData", JSON.stringify(row.product)) + this.setState({ drawerVisible: true, tempdata: temp }) } else { this.setState({ - draw_title: '编辑优惠券', + draw_title: "编辑优惠券", rowIndex: rowIndex, rowCouponData: row, drawerVisible: true - }); + }) } } onUpload = (file, report) => { return new Promise((resolve, reject) => { - let path = ''; - let formdata = new FormData(); - formdata.append('file', file); - formdata.append('path', 'common_image'); + let path = "" + let formdata = new FormData() + formdata.append("file", file) + formdata.append("path", "common_image") uploadImg(formdata).then((res) => { handelResponse( res, (req, msg) => { - path = req.path; + path = req.path }, (err) => { - reject(); + reject() } - ); - }); + ) + }) - let count = 0; + let count = 0 const update = () => { if (path) { - resolve(path); + resolve(path) } else { if (count < 100) { - count += 2; - report(count); - setTimeout(update, 500); + count += 2 + report(count) + setTimeout(update, 500) } else { - reject(); + reject() } } - }; - setTimeout(update, 500); - }); - }; + } + setTimeout(update, 500) + }) + } onUploadError = (type, data) => { - if (type === 'overMaxAmount') { - Notify.error(`最多可上传 ${data.maxAmount} 张图片`); - } else if (type === 'overMaxSize') { - Notify.error(`图片大小不能超过 ${data.formattedMaxSize}`); + if (type === "overMaxAmount") { + Notify.error(`最多可上传 ${data.maxAmount} 张图片`) + } else if (type === "overMaxSize") { + Notify.error(`图片大小不能超过 ${data.formattedMaxSize}`) } - }; + } onUploadChange1(file, row) { - if (file.length > 0 && file[0].status == 'success') { + if (file.length > 0 && file[0].status == "success") { let rowIndex = this.state.tempdata.findIndex((o) => { - return o.product_id == row.product_id; - }); - this.state.tempdata[rowIndex].describe_url = file[0].src; - this.setState({ tempdata: this.state.tempdata }); + return o.product_id == row.product_id + }) + this.state.tempdata[rowIndex].describe_url = file[0].src + this.setState({ tempdata: this.state.tempdata }) } } onUploadChange2(file, row) { - if (file.length > 0 && file[0].status == 'success') { + if (file.length > 0 && file[0].status == "success") { let rowIndex = this.state.tempdata.findIndex((o) => { - return o.product_id == row.product_id; - }); + return o.product_id == row.product_id + }) - this.state.tempdata[rowIndex].describe_url = file[0].src; - this.setState({ tempdata: this.state.tempdata }); + this.state.tempdata[rowIndex].describe_url = file[0].src + this.setState({ tempdata: this.state.tempdata }) } } onNameChange(e, row, rowIndex) { - this.state.tempdata[rowIndex].product_name = e.target.value; - this.setState({ tempdata: this.state.tempdata }); + this.state.tempdata[rowIndex].product_name = e.target.value + this.setState({ tempdata: this.state.tempdata }) } onQuantityChange(e, row, rowIndex) { - this.state.tempdata[rowIndex].quantity = - e.target.value == '' ? 0 : e.target.value; - this.setState({ tempdata: this.state.tempdata }); + this.state.tempdata[rowIndex].quantity = e.target.value == "" ? 0 : e.target.value + this.setState({ tempdata: this.state.tempdata }) } onPriceChange(e, row, rowIndex) { - let str = e.target.value; + let str = e.target.value let value = str - .replace(/[^\d^\.]+/g, '') - .replace('.', '$#$') - .replace(/\./g, '') - .replace('$#$', '.'); + .replace(/[^\d^\.]+/g, "") + .replace(".", "$#$") + .replace(/\./g, "") + .replace("$#$", ".") - this.state.tempdata[rowIndex].contract_price = value; - this.setState({ tempdata: this.state.tempdata }); + this.state.tempdata[rowIndex].contract_price = value + this.setState({ tempdata: this.state.tempdata }) } onDisabledTime = (date, type) => { - const min = new Date(); - const hour = min.getHours(); - const minute = min.getMinutes(); - const second = min.getSeconds(); - const isSame = isSameDay(date, min); + const min = new Date() + 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) : [] } - : {}; - }; + : {} + } onReturn() { - let self = this; + let self = this Sweetalert.confirm({ - type: 'warning', + type: "warning", closeBtn: true, - title: '确认操作', + title: "确认操作", content:

是否返回key列表?

, onConfirm: () => { - self.props.history.push('/home/key-list/'); + self.props.history.push("/home/key-list/") }, onCancel: this.onCancel, - className: 'questModal', + className: "questModal", parentComponent: this - }); + }) } onPhoneChange(e) { - this.setState({ phone_radio: e.target.value }); + this.setState({ phone_radio: e.target.value }) } onEmailChange(e) { - this.setState({ email_radio: e.target.value }); + this.setState({ email_radio: e.target.value }) } cancel(e) { - this.setState({ audit_visible: false }); + this.setState({ audit_visible: false }) } phoneChange = (e) => { - this.setState({ phone: e.target.value }); - }; + this.setState({ phone: e.target.value }) + } emailChange = (e) => { - this.setState({ email: e.target.value }); - }; + this.setState({ email: e.target.value }) + } initUpload() { - this.setState({ import_visible: false }); - this.setState({ success_visible: false }); - this.setState({ fail_visible: false }); - this.setState({ file_loading: false }); - this.setState({ upload_visible: false }); - this.setState({ excel_visible: false }); - this.setState({ accessVerify: false }); + this.setState({ import_visible: false }) + this.setState({ success_visible: false }) + this.setState({ fail_visible: false }) + this.setState({ file_loading: false }) + this.setState({ upload_visible: false }) + this.setState({ excel_visible: false }) + this.setState({ accessVerify: false }) } fileChange(e) { // this.initUpload(); - let my_file = e.target.files[0]; - this.setState({ myfile: my_file }); - this.setState({ upload_visible: true }); + let my_file = e.target.files[0] + this.setState({ myfile: my_file }) + this.setState({ upload_visible: true }) if ( - my_file.name.indexOf('.xls') || - my_file.name.indexOf('.xlsx') || - my_file.name.indexOf('.csv') + my_file.name.indexOf(".xls") || + my_file.name.indexOf(".xlsx") || + my_file.name.indexOf(".csv") ) { if (my_file.size > 1024000) { - Notify.error('文件大小不能大于2M'); - return; + Notify.error("文件大小不能大于2M") + return } - let formdata = new FormData(); - formdata.append('file', my_file); - formdata.append('path', 'white_list_excel'); - this.setState({ file_loading: true }); + let formdata = new FormData() + formdata.append("file", my_file) + formdata.append("path", "white_list_excel") + this.setState({ file_loading: true }) uploadImg(formdata).then((res) => { handelResponse( res, (req, msg) => { let data = { excel: req.path - }; + } - this.setState({ mobile_excel: req.path }); + this.setState({ mobile_excel: req.path }) getAccessVerification(data).then((res) => { - this.setState({ file_loading: false }); + this.setState({ file_loading: false }) handelResponse( res, (req, msg) => { - this.setState({ accessVerify: true }); - this.setState({ excel_count: req.count }); - this.setState({ error_count: req.errorCount }); - let success = req.count - req.errorCount; - this.setState({ success_count: success }); - this.setState({ exceldata: req.validationFailed }); + this.setState({ accessVerify: true }) + this.setState({ excel_count: req.count }) + this.setState({ error_count: req.errorCount }) + let success = req.count - req.errorCount + this.setState({ success_count: success }) + this.setState({ exceldata: req.validationFailed }) - this.setState({ success_visible: true }); + this.setState({ success_visible: true }) }, (err) => { - Notify.error(err); - this.setState({ success_visible: false }); + Notify.error(err) + this.setState({ success_visible: false }) } - ); - }); + ) + }) }, (err) => { - Notify.error(err); - this.setState({ success_visible: false }); + Notify.error(err) + this.setState({ success_visible: false }) } - ); - }); + ) + }) } else { - this.setState({ success_visible: false }); + this.setState({ success_visible: false }) } } resetUpload() { - this.setState({ excel_visible: false }); - this.setState({ import_visible: true }); - this.setState({ accessVerify: true }); + this.setState({ excel_visible: false }) + this.setState({ import_visible: true }) + this.setState({ accessVerify: true }) } allowImport(data) { - let arr = this.state.mobile_repeat; + let arr = this.state.mobile_repeat if (arr.indexOf(data.mobile) < 0) { - arr.push(data.mobile); + arr.push(data.mobile) } - data.type = 'success'; - this.setState({ mobile_repeat: arr }); + data.type = "success" + this.setState({ mobile_repeat: arr }) } importConfirmClick() { - let temp = this.state.exceldata.filter((o) => o.type == 'success'); + let temp = this.state.exceldata.filter((o) => o.type == "success") let mobile_repeat = map(temp, (o) => { - return o.mobile; - }); - this.setState({ mobile_repeat: mobile_repeat }); + return o.mobile + }) + this.setState({ mobile_repeat: mobile_repeat }) - let model = this.state.model; - model.quantity = - this.state.excel_count - this.state.error_count + mobile_repeat.length; - this.setState({ model: model }); - this.setState({ accessVerify: false }); - this.setState({ excel_visible: false }); - this.setState({ import_visible: false }); - this.setState({ import_success: true }); + let model = this.state.model + model.quantity = this.state.excel_count - this.state.error_count + mobile_repeat.length + this.setState({ model: model }) + this.setState({ accessVerify: false }) + this.setState({ excel_visible: false }) + this.setState({ import_visible: false }) + this.setState({ import_success: true }) } resetUpload() { - this.setState({ excel_visible: false }); - this.setState({ import_visible: true }); - this.setState({ accessVerify: true }); + this.setState({ excel_visible: false }) + this.setState({ import_visible: true }) + this.setState({ accessVerify: true }) } switchChange(e, rowData) { if (e) { - rowData.type = 'success'; + rowData.type = "success" } else { - rowData.type = rowData.type == 'success' ? 'repeat' : 'error'; + rowData.type = rowData.type == "success" ? "repeat" : "error" } } downLoadTemplate() { window.location.href = - 'https://lsxdemall.oss-cn-beijing.aliyuncs.com/MarketingSystem/%E7%99%BD%E5%90%8D%E5%8D%95%E6%A8%A1%E6%9D%BF.xlsx'; + "https://lsxdemall.oss-cn-beijing.aliyuncs.com/MarketingSystem/%E7%99%BD%E5%90%8D%E5%8D%95%E6%A8%A1%E6%9D%BF.xlsx" } submitAudit() { if (this.refs.form1.validator()) { - this.setState({ audit_visible: true }); + this.setState({ audit_visible: true }) } } // 优惠券范围 coupon_range(product) { - let arr_legal = product.legal.map((item) => item.product_name); - let arr_reduce = product.reduce.map((item) => item.batch_goods_name); - let arr = arr_legal.concat(arr_reduce); - arr = arr.join(','); - return {arr}; + let arr_legal = product.legal.map((item) => item.product_name) + let arr_reduce = product.reduce.map((item) => item.batch_goods_name) + let arr = arr_legal.concat(arr_reduce) + arr = arr.join(",") + return {arr} } keyProductClick(row, index) { if (this.state.direct_reseller_id > 0) { /* 区分立减金 */ if (row.type === 2) { this.setState({ - product_title: '编辑立减金', + product_title: "编辑立减金", productData: row.origin, - addIsType: 'addKnockGold', + addIsType: "addKnockGold", drawerVisible2: true - }); + }) } else { this.setState({ - product_title: '编辑商品', + product_title: "编辑商品", productData: row, - addIsType: 'addProduct', + addIsType: "addProduct", drawerVisible2: true - }); + }) } } else { // 老数据不能进行新增商品操作 - Notify.error(`请添加映射分销商`); - return; + Notify.error(`请添加映射分销商`) + return } } render() { //校验规则 const rules = { quantity: [ - { type: 'required', message: 'key数量不能为0' }, + { type: "required", message: "key数量不能为0" }, { - type: 'regExp', - message: '请输入正整数', - reg: '^([1-9][0-9]*){1,3}$' + type: "regExp", + message: "请输入正整数", + reg: "^([1-9][0-9]*){1,3}$" } ], - bind_object: [{ type: 'required', message: '请选择绑定类型' }], + bind_object: [{ type: "required", message: "请选择绑定类型" }], - batch_name: [{ type: 'required', message: '请输入key批次名称' }] - }; + batch_name: [{ type: "required", message: "请输入key批次名称" }] + } const Column2 = [ { - title: '商品ID', - name: 'product_id', - prop: 'product_id', - width: 'auto', - type: 'normal' + title: "商品ID", + name: "product_id", + prop: "product_id", + width: "auto", + type: "normal" }, { - title: '立减金平台批次号', - width: '250px', - prop: 'channel_activity_id', - name: 'channel_activity_id', - type: 'normal' + title: "立减金平台批次号", + width: "250px", + prop: "channel_activity_id", + name: "channel_activity_id", + type: "normal" }, { - title: '类型', - width: 'auto', - prop: 'type', - name: 'type', - type: 'slot' + title: "类型", + width: "auto", + prop: "type", + name: "type", + type: "slot" }, { - title: '上游平台', - width: 'auto', - prop: 'upstream', - name: 'upstream', - type: 'normal' + title: "上游平台", + width: "auto", + prop: "upstream", + name: "upstream", + type: "normal" }, { - title: '有效时间段', - width: '575px', - prop: 'effectDate', - name: 'effectDate', - type: 'normal' + title: "有效时间段", + width: "575px", + prop: "effectDate", + name: "effectDate", + type: "normal" }, { - title: '商品名称', - width: 'auto', - prop: 'product_name', - name: 'product_name', - type: 'normal' + title: "商品名称", + width: "auto", + prop: "product_name", + name: "product_name", + type: "normal" }, { - title: '当前成本价格', - prop: 'cost_price', - name: 'cost_price', - width: '250px', - type: 'slot' + title: "当前成本价格", + prop: "cost_price", + name: "cost_price", + width: "250px", + type: "slot" }, { - title: '合同价', - name: 'contract_price', - prop: 'contract_price', - type: 'normal', - width: 'auto' + title: "合同价", + name: "contract_price", + prop: "contract_price", + type: "normal", + width: "auto" }, { - title: '商品官方价', - type: 'normal', - prop: 'official_price', - width: 'auto' + title: "商品官方价", + type: "normal", + prop: "official_price", + width: "auto" }, { - title: '库存数量', - prop: 'quantity', - name: 'quantity', - type: 'normal', - width: 'auto' + title: "库存数量", + prop: "quantity", + name: "quantity", + type: "normal", + width: "auto" }, { - title: '操作', - prop: 'edit', - name: 'edit', - type: 'slot', - width: 'auto' + title: "操作", + prop: "edit", + name: "edit", + type: "slot", + width: "auto" } - ]; + ] //基本信息 const codeInfo = { - code_name: [{ type: 'required', message: '请输入兑换码名称' }], + code_name: [{ type: "required", message: "请输入兑换码名称" }], issued: [ - { type: 'required', message: '请输入发放总量' }, + { type: "required", message: "请输入发放总量" }, { - type: 'regExp', - message: '请输入正整数', - reg: '^([1-9][0-9]*){1,3}$' + type: "regExp", + message: "请输入正整数", + reg: "^([1-9][0-9]*){1,3}$" } ] - }; + } //基本规则 const rulesInfo = { - date_time: [{ type: 'required', message: '请选择生效时间段' }], - rank: [{ type: 'required', message: '请选择商品范围' }] - }; + date_time: [{ type: "required", message: "请选择生效时间段" }], + rank: [{ type: "required", message: "请选择商品范围" }] + } const excelColumn = [ { - title: '行号', - name: 'line', - prop: 'line', - width: '30px', - type: 'normal' + title: "行号", + name: "line", + prop: "line", + width: "30px", + type: "normal" }, { - title: '手机号', - width: '80px', - prop: 'mobile', - name: 'mobile', - type: 'normal' + title: "手机号", + width: "80px", + prop: "mobile", + name: "mobile", + type: "normal" }, { - title: '错误原因', - width: '80px', - prop: 'tips', - name: 'tips', - type: 'normal' + title: "错误原因", + width: "80px", + prop: "tips", + name: "tips", + type: "normal" }, { - title: '是否导入', - width: '50px', - prop: 'is_import', - name: 'is_import', - type: 'slot' + title: "是否导入", + width: "50px", + prop: "is_import", + name: "is_import", + type: "slot" } - ]; + ] return ( -
+
-
- -
{this.state.model.title}
+ style={{ width: "98%", height: "auto", margin: "10px auto" }} + title={this.state.pagetitle} + > + + +
{this.state.model.title}
- + { - let model2 = this.state.model; - model2.batch_name = e; - this.setState({ model: model2 }); + let model2 = this.state.model + model2.batch_name = e + this.setState({ model: model2 }) }} onClearItem={(e) => { - let model2 = this.state.model; - model2.batch_name = ''; - this.setState({ model: model2 }); + let model2 = this.state.model + model2.batch_name = "" + this.setState({ model: model2 }) }} value={this.state.model.batch_name} - placeholder={'请输入'} - labelWidth={'0px'} + placeholder={"请输入"} + labelWidth={"0px"} maxLength={12} - height={'36px'} - width={'400px'} - alignment={'left'} + height={"36px"} + width={"400px"} + alignment={"left"} /> - + { - this.onStyleChange(e); + this.onStyleChange(e) }} value={this.state.model.style} - disabled={this.state.isEdit}> + disabled={this.state.isEdit} + > 串码 @@ -1476,150 +1459,139 @@ export default class accList extends React.Component { - -
+ +
{this.state.isEdit ? (
{this.state.model.quantity}
) : ( { - let model2 = this.state.model; - model2.quantity = e; - this.setState({ model: model2 }); + let model2 = this.state.model + model2.quantity = e + this.setState({ model: model2 }) }} value={this.state.model.quantity} disabled={this.state.model.style == 6} - placeholder={'请输入'} - labelWidth={'0px'} + placeholder={"请输入"} + labelWidth={"0px"} maxLength={5} - height={'36px'} - width={'400px'} - alignment={'left'} + height={"36px"} + width={"400px"} + alignment={"left"} /> )} {this.state.white_visible ? ( ) : null}
- + { - this.onCheckChange(e); - }}> + this.onCheckChange(e) + }} + > 兑换码 优惠券 - + {this.state.keyType === 1 ? ( ) : ( )} - + { - this.pageChange(e); + this.pageChange(e) }} checkChange={(selection) => {}} ComponentHandler={(com, rowData, rowIndex) => { - if (com == 'restrict') { + if (com == "restrict") { return ( { - this.onBindNum(e, rowData, rowIndex); + this.onBindNum(e, rowData, rowIndex) }} disabled={rowData.disabled} /> - ); + ) } // 优惠券范围 - if (com === 'product' && this.state.keyType === 2) { - return this.coupon_range(rowData.product); + if (com === "product" && this.state.keyType === 2) { + return this.coupon_range(rowData.product) } - if (com == 'edit') { + if (com == "edit") { return ( { - this.rowItemClick(rowData, rowIndex); + this.rowItemClick(rowData, rowIndex) }} - style={{ color: '#2B66F2' }}> + style={{ color: "#2B66F2" }} + > 编辑 - ); + ) } }} /> - + this.onRepetitionChange(e)} - value={this.state.model.allow_repetition}> + value={this.state.model.allow_repetition} + > - + this.onLossChange(e)} - value={this.state.model.allow_loss}> + value={this.state.model.allow_loss} + > @@ -1627,192 +1599,181 @@ export default class accList extends React.Component { -
- -
+
} visible={this.state.drawerVisible} onClose={(e) => { - this.closeDraw(); + this.closeDraw() }} - maskClosable={false}> + maskClosable={false} + > {this.state.keyType === 1 ? ( -
- -
+
+ +
- + ref="code_info" + className="addform" + > + { - let model = this.state.codeInfo; - model.code_name = e; - this.setState({ codeInfo: model }); + let model = this.state.codeInfo + model.code_name = e + this.setState({ codeInfo: model }) }} onClearItem={(e) => { - let model = this.state.codeInfo; - model.code_name = ''; - this.setState({ codeInfo: model }); + let model = this.state.codeInfo + model.code_name = "" + this.setState({ codeInfo: model }) }} value={this.state.codeInfo.code_name} - placeholder={'请输入兑换码名称'} - labelWidth={'0px'} + placeholder={"请输入兑换码名称"} + labelWidth={"0px"} maxLength={10} - height={'36px'} - width={'520px'} - alignment={'left'} + height={"36px"} + width={"520px"} + alignment={"left"} /> - + { - let model = this.state.codeInfo; - model.issued = e; - this.setState({ codeInfo: model }); + let model = this.state.codeInfo + model.issued = e + this.setState({ codeInfo: model }) }} onClearItem={(e) => { - let model = this.state.codeInfo; - model.issued = ''; - this.setState({ codeInfo: model }); + let model = this.state.codeInfo + model.issued = "" + this.setState({ codeInfo: model }) }} - unit='条' + unit="条" countShow={false} value={this.state.codeInfo.issued} - placeholder={'请输入发放总量'} - labelWidth={'0px'} + placeholder={"请输入发放总量"} + labelWidth={"0px"} maxLength={12} - height={'36px'} - width={'520px'} - alignment={'left'} + height={"36px"} + width={"520px"} + alignment={"left"} /> - + { - let model = this.state.codeInfo; - model.describe = e.target.value; - this.setState({ codeInfo: model }); + let model = this.state.codeInfo + model.describe = e.target.value + this.setState({ codeInfo: model }) }} />
- +
- + ref="code_rule" + className="addform" + > + { - Bus.emit('change', 'date_time', e); - this.onChangeCombinedDate(e); + Bus.emit("change", "date_time", e) + this.onChangeCombinedDate(e) }} disabledTime={this.onDisabledTime} disabledDate={this.onDisabledRange} /> - -
+ +
this.fileChange(e)} /> - - 更新文件 + + 更新文件
)}
{this.state.success_visible ? ( -
- +
+ 文件解析成功,点击确定导入 即可导入
) : null} {this.state.fail_visible ? ( -
- +
+ 文件解析失败,请查看导入规则并更新文件
) : null} @@ -2001,58 +1955,60 @@ export default class accList extends React.Component { ) : (
this.fileChange(e)} /> {' '} + {" "}
)} -
-
下载模板并填写后上传
+
+
下载模板并填写后上传
-
-
- 请先下载「数字世界营销管理系统_白名单_模板」并按照模板填写后再上传。 -
+
+
请先下载「数字世界营销管理系统_白名单_模板」并按照模板填写后再上传。
-
-
+
+
@@ -2062,41 +2018,44 @@ export default class accList extends React.Component { ) : null} {this.state.audit_visible ? ( -
-
-
+
+
+
{ - this.setState({ audit_visible: false }); + this.setState({ audit_visible: false }) }} /> -
提交审核
-
+
提交审核
+
{ - this.onPayTypeChange(e); + this.onPayTypeChange(e) }} value={this.state.paytype} - className='audit-obj'> + className="audit-obj" + > 预付款扣除 对私账户 对公账户
-
+
@@ -2106,33 +2065,33 @@ export default class accList extends React.Component { {this.state.excel_visible ? (
-
-
-
-
从Excel导入白名单
+
+
+
+
从Excel导入白名单
{ - this.setState({ excel_visible: false }); + this.setState({ excel_visible: false }) }} />
-
+
文件上传成功.共{this.state.excel_count}条手机号,其中 {this.state.success_count}条可成功导入
-
+
发现以下{this.state.error_count}条不符合要求,将不会被导入
-
+
{ - this.pageChange(e); + this.pageChange(e) }} ComponentHandler={(com, rowData, rowIndex) => { - if (com == 'is_import') { - if ( - rowData.type == 'success' || - rowData.type == 'repeat' - ) { - let checked = rowData.type == 'success'; + if (com == "is_import") { + if (rowData.type == "success" || rowData.type == "repeat") { + let checked = rowData.type == "success" return ( { - this.switchChange(e, rowData); + this.switchChange(e, rowData) }} /> - ); + ) } else { - return
-
; + return
-
} } }} />
-
-
+
+
@@ -2193,6 +2151,6 @@ export default class accList extends React.Component {
) : null}
- ); + ) } } diff --git a/src/pages/exchangecode/commodity/commodity.js b/src/pages/exchangecode/commodity/commodity.js index ba4b54b4..ae5f2083 100644 --- a/src/pages/exchangecode/commodity/commodity.js +++ b/src/pages/exchangecode/commodity/commodity.js @@ -6,6 +6,7 @@ import Ipt from "@/components/input/main" import Grid from "@/components/gird/main.js" import TabPage from "@/components/tabPage/main.js" import { getCodeProductList, handelResponse, delCodeProduct } from "@/assets/api.js" +import { productTypeMenu } from "@/tools" const Column = [ { @@ -140,7 +141,7 @@ export default class commodityList extends React.Component { resData.push({ product_id: item.entity.goods_id, product_type_text: "立减金", - upstream: String(item.entity.channel) === "1" ? "支付宝" : "微信", + upstream: productTypeMenu(item.entity.channel), contract_price: item.entity.price, create_time: item.entity.create_time, official_price: item.entity.reduce_amount, @@ -160,7 +161,7 @@ export default class commodityList extends React.Component { resData.push({ product_id: item.entity.goods_id, product_type_text: item.entity.cash_amount_type === "2" ? "随机红包" : "固额红包", - upstream: item.entity.channel === 1 ? "支付宝" : "微信", + upstream: productTypeMenu(item.entity.channel), contract_price: (item.entity.total_contract_price / item.entity.num).toFixed(2), //合同单价, create_time: item.entity.create_time, official_price: price, diff --git a/src/pages/exchangecode/exchangecodeAdd/utils.js b/src/pages/exchangecode/exchangecodeAdd/utils.js index 8977c84b..42c329e9 100644 --- a/src/pages/exchangecode/exchangecodeAdd/utils.js +++ b/src/pages/exchangecode/exchangecodeAdd/utils.js @@ -1,4 +1,5 @@ import { divNum } from "@/tools/number" +import { productTypeMenu } from "@/tools" //基本信息 export const codeInfo = { code_name: [{ type: "required", message: "请输入兑换码名称" }], @@ -198,7 +199,7 @@ export function redPacketsDataFn(params) { newObj.only = params.cash_activity_id //批次号 newObj.type = 3 //类型 newObj.checked = params?.checked - newObj.upstream = params.channel === 1 ? "支付宝" : "微信" //上游 + newObj.upstream = productTypeMenu(params.channel) //上游 newObj.edit = "edit" newObj.all_budget = params.all_budget newObj.effectDate = params.begin_time + " 至 " + params.end_time //有效时间 @@ -222,7 +223,7 @@ export function reductionFn(params) { newObj.only = params.channel_activity_id //批次号 newObj.type = 2 //类型 newObj.checked = params?.checked - newObj.upstream = String(params.channel) === "1" ? "支付宝" : "微信" //上游 + newObj.upstream = productTypeMenu(params.channel) //上游 newObj.edit = "edit" newObj.all_budget = params.all_budget newObj.effectDate = diff --git a/src/pages/plan/add/step2.js b/src/pages/plan/add/step2.js index bce8e768..0e0b36c7 100644 --- a/src/pages/plan/add/step2.js +++ b/src/pages/plan/add/step2.js @@ -1,77 +1,63 @@ /* 生成key step2 */ -import ReactDOM from 'react-dom'; -import React from 'react'; -import { deWeightThree } from '@/tools/utils.js'; -import './step2.less'; -import { - Drawer, - Button, - Notify, - Input, - Radio, - Switch, - Icon, - RadioGroup, - RadioButton -} from 'zent'; -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 { - handelResponse, - getAccessVerification, - getProductInfoSelect -} from '@/assets/api.js'; -import { divNum } from '@/tools/number'; -import UseCouponAddEdit from '@/components/UseCouponAddEdit'; // 优惠券 -import UseExchangeAddEdit from '@/components/UseExchangeAddEdit'; // 兑换码 -import moment from 'moment'; -import { uploadImg } from '@/assets/api.js'; -import { submitIsKm } from '@/tools/index'; -import './add.less'; -import { isSameDay } from 'date-fns'; -import map from 'lodash/map'; -import forEach from 'lodash/forEach'; +import ReactDOM from "react-dom" +import React from "react" +import { deWeightThree } from "@/tools/utils.js" +import "./step2.less" +import { Drawer, Button, Notify, Input, Radio, Switch, Icon, RadioGroup, RadioButton } from "zent" +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 { handelResponse, getAccessVerification, getProductInfoSelect } from "@/assets/api.js" +import { divNum } from "@/tools/number" +import UseCouponAddEdit from "@/components/UseCouponAddEdit" // 优惠券 +import UseExchangeAddEdit from "@/components/UseExchangeAddEdit" // 兑换码 +import moment from "moment" +import { uploadImg } from "@/assets/api.js" +import { submitIsKm, productTypeMenu } from "@/tools/index" +import "./add.less" +import { isSameDay } from "date-fns" +import map from "lodash/map" +import forEach from "lodash/forEach" const initArray = (targetNum) => { - return Array.from({ length: targetNum }, (_, index) => index); -}; + return Array.from({ length: targetNum }, (_, index) => index) +} const excelColumn = [ { - title: '行号', - name: 'line', - prop: 'line', - width: '30px', - type: 'normal' + title: "行号", + name: "line", + prop: "line", + width: "30px", + type: "normal" }, { - title: '手机号', - width: '80px', - prop: 'mobile', - name: 'mobile', - type: 'normal' + title: "手机号", + width: "80px", + prop: "mobile", + name: "mobile", + type: "normal" }, { - title: '错误原因', - width: '80px', - prop: 'tips', - name: 'tips', - type: 'normal' + title: "错误原因", + width: "80px", + prop: "tips", + name: "tips", + type: "normal" }, { - title: '是否导入', - width: '50px', - prop: 'is_import', - name: 'is_import', - type: 'slot' + title: "是否导入", + width: "50px", + prop: "is_import", + name: "is_import", + type: "slot" } -]; +] export default class acclist extends React.Component { constructor(props) { - super(props); + super(props) this.state = { model: { @@ -81,20 +67,20 @@ export default class acclist extends React.Component { allow_repetition: 0, allow_loss: 0, merge_stock: 1, - code_batch: '', - draw_title: '', - batch_name: '' + code_batch: "", + draw_title: "", + batch_name: "" }, drawerVisible: false, drawerVisible2: false, productData: [], codeInfo: { //数据模型不可少 - code_name: '', - issued: '', //发放总量 - describe: '', - date_time: '', - range: '' + code_name: "", + issued: "", //发放总量 + describe: "", + date_time: "", + range: "" }, rank: null, rankoptions: [], @@ -115,273 +101,273 @@ export default class acclist extends React.Component { upload_visible: false, excel_visible: false, accessVerify: false, - mobile_excel: '', + mobile_excel: "", mobile_repeat: [], - execel_path: '', + execel_path: "", excel_count: 0, success_count: 0, error_count: 0, whiteStyle: false, import_success: false, - product_title: '新建商品', + product_title: "新建商品", newGoodsBtnLoading: false /* 商品按钮lodging */, newGoldLoading: false /* 立减金按钮lodging */, direct_reseller_id: 0, tableLoading: false, isCopy: props.isCopy ? true : false, - rowCouponData: '', - rowExchangeData: '', + rowCouponData: "", + rowExchangeData: "", Column: [ { - title: '兑换名称', - name: 'title', - prop: 'title', - type: 'normal', - width: 'auto' + title: "兑换名称", + name: "title", + prop: "title", + type: "normal", + width: "auto" }, { - title: '兑换码范围', - prop: 'product', - name: 'product', - width: 'auto', - type: 'slot' + title: "兑换码范围", + prop: "product", + name: "product", + width: "auto", + type: "slot" }, { - title: '有效开始日期', - prop: 'begin_time', - name: 'begin_time', - width: 'auto', - type: 'normal' + title: "有效开始日期", + prop: "begin_time", + name: "begin_time", + width: "auto", + type: "normal" }, { - title: '有效结束日期', - name: 'end_time', - prop: 'end_time', - type: 'normal', - width: 'auto' + title: "有效结束日期", + name: "end_time", + prop: "end_time", + type: "normal", + width: "auto" }, { - title: '兑换码数量', - name: 'quantity', - type: 'normal', - prop: 'quantity', - defaultText: 'PM', - width: 'auto' + title: "兑换码数量", + name: "quantity", + type: "normal", + prop: "quantity", + defaultText: "PM", + width: "auto" }, { - title: '绑定数', - prop: 'restrict', - name: 'restrict', - type: 'slot', - width: 'auto' + title: "绑定数", + prop: "restrict", + name: "restrict", + type: "slot", + width: "auto" }, { - title: '操作', - prop: 'edit', - name: 'edit', - type: 'slot', - width: 'auto' + title: "操作", + prop: "edit", + name: "edit", + type: "slot", + width: "auto" } ], Column_coupon: [ { - title: '优惠券名称', - name: 'title', - prop: 'title', - type: 'normal', - width: 'auto' + title: "优惠券名称", + name: "title", + prop: "title", + type: "normal", + width: "auto" }, { - title: '优惠券范围', - prop: 'product', - name: 'product', - width: 'auto', - type: 'slot' + title: "优惠券范围", + prop: "product", + name: "product", + width: "auto", + type: "slot" }, { - title: '有效开始日期', - prop: 'begin_time', - name: 'begin_time', - width: 'auto', - type: 'normal' + title: "有效开始日期", + prop: "begin_time", + name: "begin_time", + width: "auto", + type: "normal" }, { - title: '有效结束日期', - name: 'end_time', - prop: 'end_time', - type: 'normal', - width: 'auto' + title: "有效结束日期", + name: "end_time", + prop: "end_time", + type: "normal", + width: "auto" }, { - title: '优惠券数量', - name: 'quantity', - type: 'normal', - prop: 'quantity', - defaultText: 'PM', - width: 'auto' + title: "优惠券数量", + name: "quantity", + type: "normal", + prop: "quantity", + defaultText: "PM", + width: "auto" }, { - title: '绑定数', - prop: 'restrict', - name: 'restrict', - type: 'slot', - width: 'auto' + title: "绑定数", + prop: "restrict", + name: "restrict", + type: "slot", + width: "auto" }, { - title: '操作', - prop: 'edit', - name: 'edit', - type: 'slot', - width: 'auto' + title: "操作", + prop: "edit", + name: "edit", + type: "slot", + width: "auto" } ] - }; + } } componentDidMount(e) { - const dom = ReactDOM.findDOMNode(this); - let items = dom.getElementsByClassName('form-Item'); - let input = items[1].getElementsByTagName('input')[0]; - input.focus(); + const dom = ReactDOM.findDOMNode(this) + let items = dom.getElementsByClassName("form-Item") + let input = items[1].getElementsByTagName("input")[0] + input.focus() if (this.props.name > 0) { - this.setState({ whiteStyle: this.props.whiteStyle }); - this.setState({ white_visible: this.props.whiteStyle }); - let model = this.state.model; - model.style = this.props.keyStyle; - this.setState({ model: model }); + this.setState({ whiteStyle: this.props.whiteStyle }) + this.setState({ white_visible: this.props.whiteStyle }) + let model = this.state.model + model.style = this.props.keyStyle + this.setState({ model: model }) } } submit() { - let valide = false; + let valide = false // 兑换码 if (this.props.keyType === 1) { if (this.refs.form1.validator()) { /* 处理数据 区分立减金和商品 开始 2022-05-30 13:40*/ - const dataCopy = this.refs.tempdata.getSelectData(); + const dataCopy = this.refs.tempdata.getSelectData() /* 处理数据 区分立减金和商品 完成 2022-05-30 13:40*/ - let data = {}; - data.batch_name = this.state.model.batch_name; - data.style = this.state.model.style; - data.quantity = this.state.model.quantity; - data.bind_object = [this.props.keyType]; - data.allow_repetition = this.state.model.allow_repetition; - data.allow_loss = this.state.model.allow_loss; - data.merge_stock = this.state.model.merge_stock; - data.code_batch = dataCopy; - data.mobile_excel = this.state.mobile_excel; - data.mobile_repeat = this.state.mobile_repeat; - return data; + let data = {} + data.batch_name = this.state.model.batch_name + data.style = this.state.model.style + data.quantity = this.state.model.quantity + data.bind_object = [this.props.keyType] + data.allow_repetition = this.state.model.allow_repetition + data.allow_loss = this.state.model.allow_loss + data.merge_stock = this.state.model.merge_stock + data.code_batch = dataCopy + data.mobile_excel = this.state.mobile_excel + data.mobile_repeat = this.state.mobile_repeat + return data } } else { // 优惠券 if (this.refs.form1.validator()) { - let param = this.state.couponData.filter((item) => item.checked); - let data = {}; - data.batch_name = this.state.model.batch_name; - data.style = this.state.model.style; - data.quantity = this.state.model.quantity; - data.bind_object = [this.props.keyType]; - data.allow_repetition = this.state.model.allow_repetition; - data.allow_loss = this.state.model.allow_loss; - data.merge_stock = this.state.model.merge_stock; - data.coupon = param; - data.mobile_excel = this.state.mobile_excel; - data.mobile_repeat = this.state.mobile_repeat; - console.log('data =>', data); + let param = this.state.couponData.filter((item) => item.checked) + let data = {} + data.batch_name = this.state.model.batch_name + data.style = this.state.model.style + data.quantity = this.state.model.quantity + data.bind_object = [this.props.keyType] + data.allow_repetition = this.state.model.allow_repetition + data.allow_loss = this.state.model.allow_loss + data.merge_stock = this.state.model.merge_stock + data.coupon = param + data.mobile_excel = this.state.mobile_excel + data.mobile_repeat = this.state.mobile_repeat + console.log("data =>", data) // 校验 卡密时间判断 for (let i = 0; i < param.length; i++) { if (submitIsKm(param[i].product.legal) === false) { - return valide; + return valide } } - return data; + return data } } - return valide; + return valide } onCancel() { - this.refs.form1.cancel(); + this.refs.form1.cancel() } onCheckChange = ({ target }) => { - sessionStorage.setItem('keyType', target.value); - this.props.setKeyType(target.value); + sessionStorage.setItem("keyType", target.value) + this.props.setKeyType(target.value) // 获取落地页 select if (this.props.getStep3Theme) { - this.props.getStep3Theme(); + this.props.getStep3Theme() } - }; + } onStyleChange(e) { if (this.props.name == 0) { - this.props.onStyleChange(e); + this.props.onStyleChange(e) } - let model2 = this.state.model; - model2.style = e.target.value; - model2.quantity = 0; - this.setState({ model: model2 }); + let model2 = this.state.model + model2.style = e.target.value + model2.quantity = 0 + this.setState({ model: model2 }) if (e.target.value == 6) { - sessionStorage.setItem('white', 1); - this.setState({ white_visible: true }); + sessionStorage.setItem("white", 1) + this.setState({ white_visible: true }) } else { - sessionStorage.setItem('white', 3); - this.setState({ white_visible: false }); + sessionStorage.setItem("white", 3) + this.setState({ white_visible: false }) } // 获取落地页 select if (this.props.getStep3Theme) { - this.props.getStep3Theme(); + this.props.getStep3Theme() } } onRepetitionChange(e) { - let model2 = this.state.model; - model2.allow_repetition = e.target.value; - this.setState({ model: model2 }); + let model2 = this.state.model + model2.allow_repetition = e.target.value + this.setState({ model: model2 }) } onLossChange(e) { - let model2 = this.state.model; - model2.allow_loss = e.target.value; - this.setState({ model: model2 }); + let model2 = this.state.model + model2.allow_loss = e.target.value + this.setState({ model: model2 }) } // 计划-增加兑换码或者优惠券 planAddExchangeCoupon(type) { if (type === 0) { - this.setState({ draw_title: '新建兑换码' }); + this.setState({ draw_title: "新建兑换码" }) setTimeout(() => { - this.refs.addEditExchangeEl.clearExchangeForm(); - }, 300); + this.refs.addEditExchangeEl.clearExchangeForm() + }, 300) } else { - this.setState({ draw_title: '新建优惠券' }); + this.setState({ draw_title: "新建优惠券" }) setTimeout(() => { - this.refs.addEditCouponEl.clearCouponForm(); - }, 300); + this.refs.addEditCouponEl.clearCouponForm() + }, 300) } - this.setState({ rowIndex: -1 }); - this.setState({ drawerVisible: true }); + this.setState({ rowIndex: -1 }) + this.setState({ drawerVisible: true }) } closeDraw() { if (this.props.keyType === 2) { setTimeout(() => { - this.refs.addEditCouponEl.clearCouponForm(); - }, 300); + this.refs.addEditCouponEl.clearCouponForm() + }, 300) } if (this.props.keyType === 1) { setTimeout(() => { - this.refs.addEditExchangeEl.clearExchangeForm(); - }, 300); + this.refs.addEditExchangeEl.clearExchangeForm() + }, 300) } - this.setState({ drawerVisible: false }); + this.setState({ drawerVisible: false }) } // 获取直连天下商品数据 @@ -389,304 +375,285 @@ export default class acclist extends React.Component { return new Promise((resolve, reject) => { let param = { reseller_id: reseller_id - }; + } getProductInfoSelect(param).then((res) => { if (res.code === 200) { - resolve(res.data.data); + resolve(res.data.data) } else { - reject([]); + reject([]) } - }); - }); + }) + }) } // 获取 直连天下数据 addProduct(type) { - this.setState({ addIsType: type }); /* 类型 */ + this.setState({ addIsType: type }) /* 类型 */ /* type: 立减金/商品 */ - let direct_reseller_ids = this.props.direct_reseller_id; + let direct_reseller_ids = this.props.direct_reseller_id if (direct_reseller_ids <= 0) { // 老数据不能进行新增商品操作 - Notify.error(`请添加映射分销商`); - return; + Notify.error(`请添加映射分销商`) + return } - if (type === 'addProduct') { - this.setState({ product_title: '新建商品', newGoodsBtnLoading: true }); + if (type === "addProduct") { + this.setState({ product_title: "新建商品", newGoodsBtnLoading: true }) } else { - this.setState({ product_title: '新增立减金', newGoldLoading: true }); + this.setState({ product_title: "新增立减金", newGoldLoading: true }) } this.getProductInfoSelectData(direct_reseller_ids).then((data) => { - sessionStorage.setItem('productsList', JSON.stringify(data)); - if (type === 'addProduct') { + sessionStorage.setItem("productsList", JSON.stringify(data)) + if (type === "addProduct") { this.setState({ newGoodsBtnLoading: false - }); + }) } else { this.setState({ newGoldLoading: false - }); + }) } - this.setState({ productData: null }); - this.setState({ drawerVisible2: true }); - }); + this.setState({ productData: null }) + this.setState({ drawerVisible2: true }) + }) } async productSubmit() { - console.log(1); - let visible = ''; - if (this.state.addIsType === 'addProduct') { - visible = await this.refs.product.submit(); + console.log(1) + let visible = "" + if (this.state.addIsType === "addProduct") { + visible = await this.refs.product.submit() } else { - visible = await this.refs.knockGold.submit(); + visible = await this.refs.knockGold.submit() } if (visible) { - Notify.success('保存成功'); - this.setState({ drawerVisible2: false }); + Notify.success("保存成功") + this.setState({ drawerVisible2: false }) setTimeout(() => { - let data = null; - let temp = null; - let concatData = []; + let data = null + let temp = null + let concatData = [] /* 处理商品 */ - if (this.state.addIsType === 'addProduct') { - data = JSON.parse(sessionStorage.getItem('productData')).filter( - (item) => item.type !== 2 - ); - concatData = this.state.tempdata.filter((item) => item.type !== 1); + if (this.state.addIsType === "addProduct") { + data = JSON.parse(sessionStorage.getItem("productData")).filter((item) => item.type !== 2) + concatData = this.state.tempdata.filter((item) => item.type !== 1) temp = map(data, (item) => { let index = this.state.tempdata.findIndex((o) => { - return o.product_id == item.product_id; - }); + return o.product_id == item.product_id + }) if (index > -1) { - item.checked = this.state.tempdata[index].checked; + item.checked = this.state.tempdata[index].checked } - item.type = 1; - item.only = item.product_id; - item.upstream = '直连天下'; - return item; - }); + item.type = 1 + item.only = item.product_id + item.upstream = "直连天下" + return item + }) } else { /* 处理立减金 */ - data = JSON.parse(sessionStorage.getItem('knockGoldData')).filter( + data = JSON.parse(sessionStorage.getItem("knockGoldData")).filter( (item) => item.type !== 1 - ); + ) - concatData = this.state.tempdata.filter((item) => item.type !== 2); + concatData = this.state.tempdata.filter((item) => item.type !== 2) temp = map(data, (item) => { let index = this.state.tempdata.findIndex((o) => { - return o.channel_activity_id === item.channel_activity_id; - }); + return o.channel_activity_id === item.channel_activity_id + }) if (index > -1) { - item.checked = this.state.tempdata[index].checked; + item.checked = this.state.tempdata[index].checked } /* 转换商品结构 */ // temp - const newObj = {}; - newObj.product_name = item.batch_goods_name - ? item.batch_goods_name - : item.product_name; //名字 - newObj.map_product_name = item.product_name; - newObj.channel_activity_id = item.channel_activity_id; //批次号 - newObj.only = item.channel_activity_id; //批次号 - newObj.type = 2; //类型 - newObj.checked = item?.checked; - newObj.upstream = String(item.channel) === '1' ? '支付宝' : '微信'; //上游 - newObj.edit = 'edit'; + const newObj = {} + newObj.product_name = item.batch_goods_name ? item.batch_goods_name : item.product_name //名字 + newObj.map_product_name = item.product_name + newObj.channel_activity_id = item.channel_activity_id //批次号 + newObj.only = item.channel_activity_id //批次号 + newObj.type = 2 //类型 + newObj.checked = item?.checked + newObj.upstream = productTypeMenu(item.channel) //上游 + newObj.edit = "edit" newObj.effectDate = item.effectDate ? item.effectDate : item.time_limit?.effect_time.start_time + - ' 至 ' + - item.time_limit?.effect_time.end_time; //有效时间 - newObj.contract_price = item.contract_price - ? item.contract_price - : item.price; //单价 - newObj.official_price = item.official_price - ? item.official_price - : item.reduce_amount; //官方价 + " 至 " + + item.time_limit?.effect_time.end_time //有效时间 + newObj.contract_price = item.contract_price ? item.contract_price : item.price //单价 + newObj.official_price = item.official_price ? item.official_price : item.reduce_amount //官方价 newObj.quantity = item.quantity ? item.quantity - : parseInt(divNum(item.all_budget, item.reduce_amount)); //总库 - newObj.origin = item?.origin ? item?.origin : item; - return newObj; - }); + : parseInt(divNum(item.all_budget, item.reduce_amount)) //总库 + newObj.origin = item?.origin ? item?.origin : item + return newObj + }) } - let newArray = deWeightThree(temp.concat(concatData), 'only'); + let newArray = deWeightThree(temp.concat(concatData), "only") //select数据 - let arr = []; - let rank = []; + let arr = [] + let rank = [] map(newArray, (res) => { - arr.push({ key: res.only, text: res.product_name }); + arr.push({ key: res.only, text: res.product_name }) if (res.checked) { - rank.push({ key: res.only, text: res.product_name }); + rank.push({ key: res.only, text: res.product_name }) } - }); + }) - arr = deWeightThree(arr, 'key'); + arr = deWeightThree(arr, "key") - this.setState({ tempdata: newArray, rankoptions: arr, rank }); - }, 500); + this.setState({ tempdata: newArray, rankoptions: arr, rank }) + }, 500) } } setkeyStyle(style) { if (style == 6) { - this.setState({ whiteStyle: true }); - this.setState({ white_visible: true }); + this.setState({ whiteStyle: true }) + this.setState({ white_visible: true }) } else { - this.setState({ whiteStyle: false }); - this.setState({ white_visible: false }); + this.setState({ whiteStyle: false }) + this.setState({ white_visible: false }) } - let model = this.state.model; - model.style = style; - this.setState({ model: model }); + let model = this.state.model + model.style = style + this.setState({ model: model }) } componentWillReceiveProps(nextProps) {} onChangeCombinedDate(e) { - let model2 = this.state.codeInfo; - model2.date_time = e; - this.setState({ codeInfo: model2 }); + let model2 = this.state.codeInfo + model2.date_time = e + this.setState({ codeInfo: model2 }) } submit2() { - this.refs.form2.validator(); + this.refs.form2.validator() } onRankChange(e) { forEach(this.state.tempdata, (item) => { item.checked = e.findIndex((checks) => { - return checks.key == item.only; - }) > -1; - }); - this.setState({ tempdata: this.state.tempdata }); - this.setState({ rank: e }); + return checks.key == item.only + }) > -1 + }) + this.setState({ tempdata: this.state.tempdata }) + this.setState({ rank: e }) } codeSubmit() { // 优惠券数据 if (this.props.keyType === 2) { - let coupon_validator = this.refs.addEditCouponEl.submit(); + let coupon_validator = this.refs.addEditCouponEl.submit() if (coupon_validator) { - let param = this.refs.addEditCouponEl.getModel(); - console.log('param =>', param); - let tempdata = this.state.couponData; + let param = this.refs.addEditCouponEl.getModel() + console.log("param =>", param) + let tempdata = this.state.couponData // 优惠券编辑 if (this.state.rowIndex > -1) { - tempdata[this.state.rowIndex] = param; - this.setState({ couponData: tempdata }); + tempdata[this.state.rowIndex] = param + this.setState({ couponData: tempdata }) } else { // 优惠券新增 - tempdata.push(param); - this.setState({ couponData: tempdata }); + tempdata.push(param) + this.setState({ couponData: tempdata }) } this.setState({ drawerVisible: false - }); + }) } - return; + return } // 兑换码数据 if (this.props.keyType === 1) { - let validator = this.refs.addEditExchangeEl.submit(); + let validator = this.refs.addEditExchangeEl.submit() if (validator) { - let param = this.refs.addEditExchangeEl.getModel(); - let tempdata = this.state.distdata; + let param = this.refs.addEditExchangeEl.getModel() + let tempdata = this.state.distdata // 优惠券编辑 if (this.state.rowIndex > -1) { - tempdata[this.state.rowIndex] = param; - this.setState({ distdata: tempdata }); + tempdata[this.state.rowIndex] = param + this.setState({ distdata: tempdata }) } else { // 优惠券新增 - tempdata.push(param); - this.setState({ distdata: tempdata }); + tempdata.push(param) + this.setState({ distdata: tempdata }) } this.setState({ drawerVisible: false - }); + }) } - return; + return } } addNewKey() { - this.props.addNewkey(); + this.props.addNewkey() } onRestrict(e, rowdata, index) { - let text = e.target.value; - text = text.replace(/[^\d]/g, ''); + let text = e.target.value + text = text.replace(/[^\d]/g, "") if (this.props.keyType === 1) { - this.state.distdata[index].restrict = text; - this.setState({ distdata: this.state.distdata }); + this.state.distdata[index].restrict = text + this.setState({ distdata: this.state.distdata }) } else { - this.state.couponData[index].restrict = text; - this.setState({ couponData: this.state.couponData }); + this.state.couponData[index].restrict = text + this.setState({ couponData: this.state.couponData }) } } onDisabledCombinedDate = (val) => { - let step1 = JSON.parse(sessionStorage.getItem('step1')); - let str = moment(val).format('YYYY-MM-DD HH:mm:ss'); - let isBetween = moment(str).isBetween( - step1.begin_time, - step1.end_time, - null, - '(]' - ); - return !isBetween; - }; + let step1 = JSON.parse(sessionStorage.getItem("step1")) + let str = moment(val).format("YYYY-MM-DD HH:mm:ss") + let isBetween = moment(str).isBetween(step1.begin_time, step1.end_time, null, "(]") + return !isBetween + } onDisabledTime = (date, type) => { - const min = new Date(); - const hour = min.getHours(); - const minute = min.getMinutes(); - const second = min.getSeconds(); - const isSame = isSameDay(date, min); + const min = new Date() + 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) : [] } - : {}; - }; + : {} + } onDisabledRange = (date, type) => { - let step1 = JSON.parse(sessionStorage.getItem('knockGold_effectDate')); - let isdisabled = false; - let str = moment(date).format('YYYY-MM-DD HH:mm:ss'); - let isDay = moment(step1.end_time).format('HH:mm:ss'); - if (type == 'start') { - if (isDay < '23:59:59') { + let step1 = JSON.parse(sessionStorage.getItem("knockGold_effectDate")) + let isdisabled = false + let str = moment(date).format("YYYY-MM-DD HH:mm:ss") + let 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 + } edit(data) { let model = { @@ -699,26 +666,26 @@ export default class acclist extends React.Component { merge_stock: data.merge_stock, code_batch: data.code_batch, draw_title: data.draw_title - }; - this.setState({ mobile_excel: data.mobile_excel }); - this.setState({ mobile_repeat: data.mobile_repeat }); + } + this.setState({ mobile_excel: data.mobile_excel }) + this.setState({ mobile_repeat: data.mobile_repeat }) if (model.style == 6) { - sessionStorage.setItem('white', 1); - this.setState({ white_visible: true }); + sessionStorage.setItem("white", 1) + this.setState({ white_visible: true }) } else { - sessionStorage.setItem('white', 3); + sessionStorage.setItem("white", 3) } - this.setState({ model: model }); - this.setState({ checkedList: data.bind_object.map(Number)[0] }); + this.setState({ model: model }) + this.setState({ checkedList: data.bind_object.map(Number)[0] }) let temp = map(data.code_batch, (o) => { - o.checked = true; - return o; - }); + o.checked = true + return o + }) - this.setState({ distdata: temp }); - this.setState({ isload: true }); + this.setState({ distdata: temp }) + this.setState({ isload: true }) } coupon_edit(data) { @@ -732,446 +699,437 @@ export default class acclist extends React.Component { merge_stock: data.merge_stock, draw_title: data.draw_title, coupon: data.coupon - }; - this.setState({ mobile_excel: data.mobile_excel }); - this.setState({ mobile_repeat: data.mobile_repeat }); - if (model.style == 6) { - sessionStorage.setItem('white', 1); - this.setState({ white_visible: true }); - } else { - sessionStorage.setItem('white', 3); } - this.setState({ model: model }); + this.setState({ mobile_excel: data.mobile_excel }) + this.setState({ mobile_repeat: data.mobile_repeat }) + if (model.style == 6) { + sessionStorage.setItem("white", 1) + this.setState({ white_visible: true }) + } else { + sessionStorage.setItem("white", 3) + } + this.setState({ model: model }) let temp = map(data.coupon, (o) => { - o.checked = true; - return o; - }); + o.checked = true + return o + }) - this.setState({ couponData: temp }); - this.setState({ isload: true }); + this.setState({ couponData: temp }) + this.setState({ isload: true }) } onUpload = (file, report) => { return new Promise((resolve, reject) => { - let path = ''; - let formdata = new FormData(); - formdata.append('file', file); - formdata.append('path', 'common_image'); + let path = "" + let formdata = new FormData() + formdata.append("file", file) + formdata.append("path", "common_image") uploadImg(formdata).then((res) => { handelResponse( res, (req, msg) => { - path = req.path; + path = req.path }, (err) => { - reject(); + reject() } - ); - }); + ) + }) - let count = 0; + let count = 0 const update = () => { if (path) { - resolve(path); + resolve(path) } else { if (count < 100) { - count += 2; - report(count); - setTimeout(update, 500); + count += 2 + report(count) + setTimeout(update, 500) } else { - reject(); + reject() } } - }; - setTimeout(update, 500); - }); - }; + } + setTimeout(update, 500) + }) + } onUploadError = (type, data) => { - if (type === 'overMaxAmount') { - Notify.error(`最多可上传 ${data.maxAmount} 张图片`); - } else if (type === 'overMaxSize') { - Notify.error(`图片大小不能超过 ${data.formattedMaxSize}`); + if (type === "overMaxAmount") { + Notify.error(`最多可上传 ${data.maxAmount} 张图片`) + } else if (type === "overMaxSize") { + Notify.error(`图片大小不能超过 ${data.formattedMaxSize}`) } - }; + } onUploadChange1(file, row) { - if (file.length > 0 && file[0].status == 'success') { + if (file.length > 0 && file[0].status == "success") { let rowIndex = this.state.tempdata.findIndex((o) => { - return o.product_id == row.product_id; - }); - this.state.tempdata[rowIndex].describe_url = file[0].src; - this.setState({ tempdata: this.state.tempdata }); + return o.product_id == row.product_id + }) + this.state.tempdata[rowIndex].describe_url = file[0].src + this.setState({ tempdata: this.state.tempdata }) } } onUploadChange2(file, row) { - if (file.length > 0 && file[0].status == 'success') { + if (file.length > 0 && file[0].status == "success") { let rowIndex = this.state.tempdata.findIndex((o) => { - return o.product_id == row.product_id; - }); - this.state.tempdata[rowIndex].describe_url = file[0].src; - this.setState({ tempdata: this.state.tempdata }); + return o.product_id == row.product_id + }) + this.state.tempdata[rowIndex].describe_url = file[0].src + this.setState({ tempdata: this.state.tempdata }) } } onNameChange(e, row, rowIndex) { - this.state.tempdata[rowIndex].product_name = e.target.value; + this.state.tempdata[rowIndex].product_name = e.target.value let arr = map(this.state.tempdata, (res) => { - let obj = {}; - obj.key = res.product_id; - obj.text = res.product_name; - return obj; - }); - this.setState({ rankoptions: arr }); - this.setState({ rank: arr }); - this.setState({ tempdata: this.state.tempdata }); + let obj = {} + obj.key = res.product_id + obj.text = res.product_name + return obj + }) + this.setState({ rankoptions: arr }) + this.setState({ rank: arr }) + this.setState({ tempdata: this.state.tempdata }) } onQuantityChange(e, row, rowIndex) { - this.state.tempdata[rowIndex].quantity = - e.target.value == '' ? 0 : e.target.value; - this.setState({ tempdata: this.state.tempdata }); + this.state.tempdata[rowIndex].quantity = e.target.value == "" ? 0 : e.target.value + this.setState({ tempdata: this.state.tempdata }) } onPriceChange(e, row, rowIndex) { - let str = e.target.value; + let str = e.target.value let value = str - .replace(/[^\d^\.]+/g, '') - .replace('.', '$#$') - .replace(/\./g, '') - .replace('$#$', '.'); + .replace(/[^\d^\.]+/g, "") + .replace(".", "$#$") + .replace(/\./g, "") + .replace("$#$", ".") - this.state.tempdata[rowIndex].contract_price = value; - this.setState({ tempdata: this.state.tempdata }); + this.state.tempdata[rowIndex].contract_price = value + this.setState({ tempdata: this.state.tempdata }) } rowItemClick(row, rowIndex) { // 兑换码 if (this.props.keyType === 1) { this.setState({ - draw_title: '编辑兑换码', + draw_title: "编辑兑换码", rowIndex: rowIndex, rowExchangeData: row, drawerVisible: true - }); + }) } else { // 编辑优惠券 this.setState({ - draw_title: '编辑优惠券', + draw_title: "编辑优惠券", rowIndex: rowIndex, rowCouponData: row, drawerVisible: true - }); + }) } } initUpload() { - this.setState({ import_visible: false }); - this.setState({ success_visible: false }); - this.setState({ fail_visible: false }); - this.setState({ file_loading: false }); - this.setState({ upload_visible: false }); - this.setState({ excel_visible: false }); - this.setState({ accessVerify: false }); + this.setState({ import_visible: false }) + this.setState({ success_visible: false }) + this.setState({ fail_visible: false }) + this.setState({ file_loading: false }) + this.setState({ upload_visible: false }) + this.setState({ excel_visible: false }) + this.setState({ accessVerify: false }) } importConfirmClick() { - let temp = this.state.exceldata.filter((o) => o.type == 'success'); + let temp = this.state.exceldata.filter((o) => o.type == "success") let mobile_repeat = map(temp, (o) => { - return o.mobile; - }); - this.setState({ mobile_repeat: mobile_repeat }); + return o.mobile + }) + this.setState({ mobile_repeat: mobile_repeat }) - let model = this.state.model; - model.quantity = - this.state.excel_count - this.state.error_count + mobile_repeat.length; + let model = this.state.model + model.quantity = this.state.excel_count - this.state.error_count + mobile_repeat.length - this.setState({ model: model }); - this.setState({ accessVerify: false }); - this.setState({ excel_visible: false }); - this.setState({ import_visible: false }); + this.setState({ model: model }) + this.setState({ accessVerify: false }) + this.setState({ excel_visible: false }) + this.setState({ import_visible: false }) - this.setState({ import_success: true }); + this.setState({ import_success: true }) } importClick() { if (this.state.file_loading) { - Notify.error('文件正在解析中请稍等'); + Notify.error("文件正在解析中请稍等") } else { if (this.state.success_visible) { - this.setState({ accessVerify: false }); - this.setState({ excel_visible: true }); - this.setState({ import_visible: false }); + this.setState({ accessVerify: false }) + this.setState({ excel_visible: true }) + this.setState({ import_visible: false }) } else { - Notify.error('请上传正确的文件'); + Notify.error("请上传正确的文件") } } } fileChange(e) { // this.initUpload(); - let my_file = e.target.files[0]; - this.setState({ myfile: my_file }); - this.setState({ upload_visible: true }); + let my_file = e.target.files[0] + this.setState({ myfile: my_file }) + this.setState({ upload_visible: true }) if ( - my_file.name.indexOf('.xls') || - my_file.name.indexOf('.xlsx') || - my_file.name.indexOf('.csv') + my_file.name.indexOf(".xls") || + my_file.name.indexOf(".xlsx") || + my_file.name.indexOf(".csv") ) { if (my_file.size > 1024000) { - Notify.error('文件大小不能大于2M'); - return; + Notify.error("文件大小不能大于2M") + return } - let formdata = new FormData(); - formdata.append('file', my_file); - formdata.append('path', 'white_list_excel'); - this.setState({ file_loading: true }); + let formdata = new FormData() + formdata.append("file", my_file) + formdata.append("path", "white_list_excel") + this.setState({ file_loading: true }) uploadImg(formdata).then((res) => { handelResponse( res, (req, msg) => { let data = { excel: req.path - }; - this.setState({ mobile_excel: req.path }); + } + this.setState({ mobile_excel: req.path }) getAccessVerification(data).then((res) => { - this.setState({ file_loading: false }); + this.setState({ file_loading: false }) handelResponse( res, (req, msg) => { - this.setState({ accessVerify: true }); - this.setState({ excel_count: req.count }); - this.setState({ error_count: req.errorCount }); - let success = req.count - req.errorCount; - this.setState({ success_count: success }); - this.setState({ exceldata: req.validationFailed }); - this.setState({ success_visible: true }); + this.setState({ accessVerify: true }) + this.setState({ excel_count: req.count }) + this.setState({ error_count: req.errorCount }) + let success = req.count - req.errorCount + this.setState({ success_count: success }) + this.setState({ exceldata: req.validationFailed }) + this.setState({ success_visible: true }) }, (err) => { - Notify.error(err); - this.setState({ success_visible: false }); + Notify.error(err) + this.setState({ success_visible: false }) } - ); - }); + ) + }) }, (err) => { - Notify.error(err); - this.setState({ success_visible: false }); + Notify.error(err) + this.setState({ success_visible: false }) } - ); - }); + ) + }) } else { - this.setState({ success_visible: false }); + this.setState({ success_visible: false }) } } resetUpload() { - this.setState({ excel_visible: false }); - this.setState({ import_visible: true }); - this.setState({ accessVerify: true }); + this.setState({ excel_visible: false }) + this.setState({ import_visible: true }) + this.setState({ accessVerify: true }) } switchChange(e, rowData) { if (e) { - rowData.type = 'success'; + rowData.type = "success" } else { - rowData.type = rowData.type == 'success' ? 'repeat' : 'error'; + rowData.type = rowData.type == "success" ? "repeat" : "error" } } downLoadTemplate() { window.location.href = - 'https://lsxdemall.oss-cn-beijing.aliyuncs.com/MarketingSystem/%E7%99%BD%E5%90%8D%E5%8D%95%E6%A8%A1%E6%9D%BF.xlsx'; + "https://lsxdemall.oss-cn-beijing.aliyuncs.com/MarketingSystem/%E7%99%BD%E5%90%8D%E5%8D%95%E6%A8%A1%E6%9D%BF.xlsx" } /* 商品范围列表编辑 */ productEditShow(rowData) { if (this.props.direct_reseller_id > 0) { this.setState({ tableLoading: true - }); + }) /* 区分立减金 */ if (rowData.type === 2) { - let obj = rowData.origin; + let obj = rowData.origin // 是否是复制操作 if (this.state.isCopy) { - delete obj.id; + delete obj.id } this.setState({ - product_title: '编辑立减金', + product_title: "编辑立减金", productData: obj, - addIsType: 'addKnockGold' - }); + addIsType: "addKnockGold" + }) setTimeout(() => { this.setState({ tableLoading: false - }); - this.setState({ drawerVisible2: true }); - }, 300); + }) + this.setState({ drawerVisible2: true }) + }, 300) } else if (rowData.type === 3) { - let obj = rowData.origin; + let obj = rowData.origin // 是否是复制操作 if (this.state.isCopy) { - delete obj.id; + delete obj.id } this.setState({ - product_title: '编辑红包', + product_title: "编辑红包", productData: obj, - addIsType: 'redPackets' - }); + addIsType: "redPackets" + }) setTimeout(() => { this.setState({ tableLoading: false - }); - this.setState({ drawerVisible2: true }); - }, 300); + }) + this.setState({ drawerVisible2: true }) + }, 300) } else { - this.getProductInfoSelectData(this.props.direct_reseller_id).then( - (data) => { - sessionStorage.setItem('productsList', JSON.stringify(data)); - // 如果是复制 删除 code_batch_id - if (sessionStorage.getItem('KeyPcType') === '2') { - delete rowData.code_batch_id; - } - this.setState({ - product_title: '编辑商品', - productData: rowData, - addIsType: 'addProduct' - }); - setTimeout(() => { - this.setState({ - tableLoading: false - }); - this.setState({ drawerVisible2: true }); - }, 300); + this.getProductInfoSelectData(this.props.direct_reseller_id).then((data) => { + sessionStorage.setItem("productsList", JSON.stringify(data)) + // 如果是复制 删除 code_batch_id + if (sessionStorage.getItem("KeyPcType") === "2") { + delete rowData.code_batch_id } - ); + this.setState({ + product_title: "编辑商品", + productData: rowData, + addIsType: "addProduct" + }) + setTimeout(() => { + this.setState({ + tableLoading: false + }) + this.setState({ drawerVisible2: true }) + }, 300) + }) } } else { // 老数据不能进行新增商品操作 - Notify.error(`请添加映射分销商`); - return; + Notify.error(`请添加映射分销商`) + return } } render() { //校验规则 const rules = { - bind_object: [{ type: 'required', message: '请选择绑定类型' }], - batch_name: [{ type: 'required', message: '请输入key批次名称' }] - }; + bind_object: [{ type: "required", message: "请选择绑定类型" }], + batch_name: [{ type: "required", message: "请输入key批次名称" }] + } // 优惠券范围 const coupon_range = (product) => { - let arr_legal = product.legal.map((item) => item.product_name); - let arr_reduce = product.reduce.map((item) => item.batch_goods_name); - let arr_redPackets = product.cash?.map((item) => item.batch_goods_name); - let arr = arr_legal.concat(arr_reduce, arr_redPackets); - arr = arr.join(','); - return {arr}; - }; + let arr_legal = product.legal.map((item) => item.product_name) + let arr_reduce = product.reduce.map((item) => item.batch_goods_name) + let arr_redPackets = product.cash?.map((item) => item.batch_goods_name) + let arr = arr_legal.concat(arr_reduce, arr_redPackets) + arr = arr.join(",") + return {arr} + } return ( -
- - +
+ + { - this.onStyleChange(e); + this.onStyleChange(e) }} - value={this.state.model.style}> - 0 && this.state.model.style == 6}> + value={this.state.model.style} + > + 0 && this.state.model.style == 6}> 串码 - 0 && this.state.model.style == 6}> + 0 && this.state.model.style == 6}> 链接 - 0 && this.state.model.style == 6}> + 0 && this.state.model.style == 6}> 二维码 - 0 && this.state.model.style != 6}> + 0 && this.state.model.style != 6}> 白名单 {this.state.isload ? ( - + { - let model2 = this.state.model; - model2.batch_name = e; - this.setState({ model: model2 }); + let model2 = this.state.model + model2.batch_name = e + this.setState({ model: model2 }) }} onClearItem={(e) => { - let model2 = this.state.model; - model2.batch_name = ''; - this.setState({ model: model2 }); + let model2 = this.state.model + model2.batch_name = "" + this.setState({ model: model2 }) }} value={this.state.model.batch_name} - placeholder={'请输入'} - labelWidth={'0px'} + placeholder={"请输入"} + labelWidth={"0px"} maxLength={12} - height={'36px'} - width={'520px'} - alignment={'left'} + height={"36px"} + width={"520px"} + alignment={"left"} /> ) : null} {this.state.isload ? ( - -
+ +
{ - let model2 = this.state.model; - model2.quantity = e; - this.setState({ model: model2 }); + let model2 = this.state.model + model2.quantity = e + this.setState({ model: model2 }) }} onClearItem={(e) => { - let model2 = this.state.model; - model2.quantity = ''; - this.setState({ model: model2 }); + let model2 = this.state.model + model2.quantity = "" + this.setState({ model: model2 }) }} value={this.state.model.quantity} disabled={this.state.model.style == 6} - placeholder={'请输入'} - labelWidth={'0px'} + placeholder={"请输入"} + labelWidth={"0px"} maxLength={5} - height={'36px'} - width={'520px'} - alignment={'left'} + height={"36px"} + width={"520px"} + alignment={"left"} /> {this.state.white_visible ? ( ) : null}
) : null} - + { - this.onCheckChange(e); - }}> + this.onCheckChange(e) + }} + > 兑换码 @@ -1181,185 +1139,178 @@ export default class acclist extends React.Component { - + {this.props.keyType === 1 ? ( ) : ( )} - + { - this.pageChange(e); + this.pageChange(e) }} checkChange={(selection) => {}} ComponentHandler={(com, rowData, rowIndex) => { - if (com == 'restrict') { + if (com == "restrict") { return ( { - this.onRestrict(e, rowData, rowIndex); + this.onRestrict(e, rowData, rowIndex) }} /> - ); + ) } // 优惠券范围 - if (com === 'product') { - return coupon_range(rowData.product); + if (com === "product") { + return coupon_range(rowData.product) } - if (com == 'edit') { + if (com == "edit") { return ( { - this.rowItemClick(rowData, rowIndex); + this.rowItemClick(rowData, rowIndex) }} - style={{ color: '#2B66F2' }}> + style={{ color: "#2B66F2" }} + > 编辑 - ); + ) } }} /> - + this.onRepetitionChange(e)} - value={this.state.model.allow_repetition}> + value={this.state.model.allow_repetition} + > - - this.onLossChange(e)} - value={this.state.model.allow_loss}> + + this.onLossChange(e)} value={this.state.model.allow_loss}>
{ - this.addNewKey(); - }}> + this.addNewKey() + }} + > 添加新的批次key
+
} visible={this.state.drawerVisible} onClose={(e) => { - this.closeDraw(); + this.closeDraw() }} - maskClosable={false}> + maskClosable={false} + > {this.props.keyType === 1 ? ( + direct_reseller_id={this.props.direct_reseller_id} + > ) : ( + ref="addEditCouponEl" + direct_reseller_id={this.props.direct_reseller_id} + > )}
{this.state.import_visible ? (
-
-
-
-
从Excel导入白名单
+
+
+
+
从Excel导入白名单
{ - this.setState({ import_visible: false }); + this.setState({ import_visible: false }) }} />
-
-
-
1
- 上传文件 +
+
+
1
+ 上传文件
-
-
+
+
-
-
2
- 导入完成 +
+
2
+ 导入完成
-
-
直接上传
+
+
直接上传
-
+
支持文件类型:xls,xlsx,csv
- 支持所有基础字段的导入,一次至多导入 10000 @@ -1369,40 +1320,38 @@ export default class acclist extends React.Component {
{this.state.upload_visible ? (
-
-
- - - {this.state.myfile.name} - +
+
+ + {this.state.myfile.name}
{this.state.file_loading ? ( -
- - 解析中 +
+ + 解析中
) : ( -
+
this.fileChange(e)} /> - - 更新文件 + + 更新文件
)}
{this.state.success_visible ? ( -
- +
+ 文件解析成功,点击确定导入 即可导入
) : null} {this.state.fail_visible ? ( -
- +
+ 文件解析失败,请查看导入规则并更新文件
) : null} @@ -1410,58 +1359,60 @@ export default class acclist extends React.Component { ) : (
this.fileChange(e)} /> {' '} + {" "}
)} -
-
下载模板并填写后上传
+
+
下载模板并填写后上传
-
-
- 请先下载「数字世界营销管理系统_白名单_模板」并按照模板填写后再上传。 -
+
+
请先下载「数字世界营销管理系统_白名单_模板」并按照模板填写后再上传。
-
-
+
+
@@ -1472,33 +1423,33 @@ export default class acclist extends React.Component { {this.state.excel_visible ? (
-
-
-
-
从Excel导入白名单
+
+
+
+
从Excel导入白名单
{ - this.setState({ excel_visible: false }); + this.setState({ excel_visible: false }) }} />
-
+
文件上传成功.共{this.state.excel_count}条手机号,其中 {this.state.success_count}条可成功导入
-
+
发现以下{this.state.error_count}条不符合要求,将不会被导入
-
+
{ - this.pageChange(e); + this.pageChange(e) }} ComponentHandler={(com, rowData, rowIndex) => { - if (com == 'is_import') { - if ( - rowData.type == 'success' || - rowData.type == 'repeat' - ) { - let checked = rowData.type == 'success'; + if (com == "is_import") { + if (rowData.type == "success" || rowData.type == "repeat") { + let checked = rowData.type == "success" return ( { - this.switchChange(e, rowData); + this.switchChange(e, rowData) }} /> - ); + ) } else { - return
-
; + return
-
} } }} />
-
-
+
+
@@ -1559,6 +1509,6 @@ export default class acclist extends React.Component {
) : null}
- ); + ) } } diff --git a/src/pages/plan/key/edit.js b/src/pages/plan/key/edit.js index 530480ad..b8f0ee40 100644 --- a/src/pages/plan/key/edit.js +++ b/src/pages/plan/key/edit.js @@ -1,6 +1,7 @@ /*此页面 创建中 进行中 审核驳回可编辑 */ -import React from 'react'; -import { deWeightThree } from '@/tools/utils.js'; +import React from "react" +import { deWeightThree } from "@/tools/utils.js" +import { productTypeMenu } from "@/tools" import { Radio, Card, @@ -13,11 +14,11 @@ import { Icon, RadioGroup, RadioButton -} from 'zent'; -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'; +} from "zent" +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 { addPlanStep, handelResponse, @@ -27,227 +28,227 @@ import { keyEditApproval, terminateApprovals, addKeysBatchInfo -} from '@/assets/api.js'; -import ProductForm from '@/pages/plan/product/add'; -import map from 'lodash/map'; -import forEach from 'lodash/forEach'; -import './edit.less'; -import moment from 'moment'; -import { isSameDay } from 'date-fns'; -import KnockGold from '@/components/knockGold'; -import UseCouponAddEdit from '@/components/UseCouponAddEdit'; // 优惠券 -import UseExchangeAddEdit from '@/components/UseExchangeAddEdit'; // 兑换码 -import { divNum } from '@/tools/number'; /* 立减金 */ +} from "@/assets/api.js" +import ProductForm from "@/pages/plan/product/add" +import map from "lodash/map" +import forEach from "lodash/forEach" +import "./edit.less" +import moment from "moment" +import { isSameDay } from "date-fns" +import KnockGold from "@/components/knockGold" +import UseCouponAddEdit from "@/components/UseCouponAddEdit" // 优惠券 +import UseExchangeAddEdit from "@/components/UseExchangeAddEdit" // 兑换码 +import { divNum } from "@/tools/number" /* 立减金 */ const initArray = (targetNum) => { - return Array.from({ length: targetNum }, (_, index) => index); -}; + return Array.from({ length: targetNum }, (_, index) => index) +} export default class acclist extends React.Component { constructor(props) { - super(props); + super(props) this.state = { keys: [ { style: 1, - quantity: '', + quantity: "", allow_repetition: 0, allow_loss: 0, merge_stock: 1, - code_batch: '', - draw_title: '' + code_batch: "", + draw_title: "" } ], model: { //数据模型不可少 - plan_title: '', + plan_title: "", style: 1, - quantity: '', + quantity: "", allow_repetition: 0, allow_loss: 0, merge_stock: 1, - code_batch: '', - draw_title: '', - batch_name: '' + code_batch: "", + draw_title: "", + batch_name: "" }, drawerVisible: false, drawerVisible2: false, productData: [], codeInfo: { //数据模型不可少 - code_name: '', - issued: '', //发放总量 - describe: '', - date_time: '', - range: '' + code_name: "", + issued: "", //发放总量 + describe: "", + date_time: "", + range: "" }, - product_title: '新建商品', + product_title: "新建商品", rank: null, rankoptions: [], tempdata: [], distdata: [], - pagetitle: '编辑key', + pagetitle: "编辑key", isEdit: false, - begintime: '', - endtime: '', + begintime: "", + endtime: "", isCancel: false, rowIndex: -1, paytype: 3, reseller: null, - payment_direction: ['对私账户', '对公账户', '预付款扣除'], + payment_direction: ["对私账户", "对公账户", "预付款扣除"], recall_visible: false, timer: 3, plan_id: 0, key_status: -1, - mobile_excel: '', - mobile_repeat: '', + mobile_excel: "", + mobile_repeat: "", newGoodsBtnLoading: false, direct_reseller_id: 0, - addIsType: '', + addIsType: "", newGoldLoading: false, keyType: 1, couponData: [], Column: [ { - title: '兑换名称', - name: 'title', - prop: 'title', - type: 'normal', - width: 'auto' + title: "兑换名称", + name: "title", + prop: "title", + type: "normal", + width: "auto" }, { - title: '兑换码范围', - prop: 'product', - name: 'product', - width: 'auto', - type: 'slot' + title: "兑换码范围", + prop: "product", + name: "product", + width: "auto", + type: "slot" }, { - title: '有效开始日期', - prop: 'begin_time', - name: 'begin_time', - width: 'auto', - type: 'normal' + title: "有效开始日期", + prop: "begin_time", + name: "begin_time", + width: "auto", + type: "normal" }, { - title: '有效结束日期', - name: 'end_time', - prop: 'end_time', - type: 'normal', - width: 'auto' + title: "有效结束日期", + name: "end_time", + prop: "end_time", + type: "normal", + width: "auto" }, { - title: '兑换码数量', - name: 'quantity', - type: 'normal', - prop: 'quantity', - defaultText: 'PM', - width: 'auto' + title: "兑换码数量", + name: "quantity", + type: "normal", + prop: "quantity", + defaultText: "PM", + width: "auto" }, { - title: '绑定数', - prop: 'restrict', - name: 'restrict', - type: 'slot', - width: 'auto' + title: "绑定数", + prop: "restrict", + name: "restrict", + type: "slot", + width: "auto" }, { - title: '操作', - prop: 'edit', - name: 'edit', - type: 'slot', - width: 'auto' + title: "操作", + prop: "edit", + name: "edit", + type: "slot", + width: "auto" } ], Column_coupon: [ { - title: '优惠券名称', - name: 'title', - prop: 'title', - type: 'normal', - width: 'auto' + title: "优惠券名称", + name: "title", + prop: "title", + type: "normal", + width: "auto" }, { - title: '优惠券范围', - prop: 'product', - name: 'product', - width: 'auto', - type: 'slot' + title: "优惠券范围", + prop: "product", + name: "product", + width: "auto", + type: "slot" }, { - title: '有效开始日期', - prop: 'begin_time', - name: 'begin_time', - width: 'auto', - type: 'normal' + title: "有效开始日期", + prop: "begin_time", + name: "begin_time", + width: "auto", + type: "normal" }, { - title: '有效结束日期', - name: 'end_time', - prop: 'end_time', - type: 'normal', - width: 'auto' + title: "有效结束日期", + name: "end_time", + prop: "end_time", + type: "normal", + width: "auto" }, { - title: '优惠券数量', - name: 'quantity', - type: 'normal', - prop: 'quantity', - defaultText: 'PM', - width: 'auto' + title: "优惠券数量", + name: "quantity", + type: "normal", + prop: "quantity", + defaultText: "PM", + width: "auto" }, { - title: '绑定数', - prop: 'restrict', - name: 'restrict', - type: 'slot', - width: 'auto' + title: "绑定数", + prop: "restrict", + name: "restrict", + type: "slot", + width: "auto" }, { - title: '操作', - prop: 'edit', - name: 'edit', - type: 'slot', - width: 'auto' + title: "操作", + prop: "edit", + name: "edit", + type: "slot", + width: "auto" } ], - rowCouponData: '', - rowExChangeData: '', - id: '', + rowCouponData: "", + rowExChangeData: "", + id: "", white_visible: false, - planTime: '', + planTime: "", audit_visible: false - }; + } } // key 批次的处理 keyFormat(data) { - let newData = []; + let newData = [] // 兑换码 if (Number(data.bind_object[0]) === 1) { - newData = data.code_batch; + newData = data.code_batch } else { - newData = data.coupon; + newData = data.coupon } // 注意!!!!!!!!!!7审核驳回 -1创建中 可编辑 status 是优惠券或者兑换码的状态不是key批次状态!!!!!!!!!!!!!!! let temp = map(newData, (o) => { - o.checked = true; + o.checked = true if (o.status && o.status !== -1 && o.status !== 7) { - o.disabled = true; + o.disabled = true } - return o; - }); + return o + }) if (Number(data.bind_object[0]) === 1) { - this.setState({ distdata: temp }); + this.setState({ distdata: temp }) } else { - this.setState({ couponData: temp }); + this.setState({ couponData: temp }) } } componentDidMount(e) { - sessionStorage.setItem('knockGoldData', ''); - let batch_id = sessionStorage.getItem('keybatch_id'); - let reseller_id = sessionStorage.getItem('key_reseller_id'); + sessionStorage.setItem("knockGoldData", "") + let batch_id = sessionStorage.getItem("keybatch_id") + let reseller_id = sessionStorage.getItem("key_reseller_id") // let planTime = sessionStorage.getItem("datetime"); // if (planTime) { @@ -259,31 +260,31 @@ export default class acclist extends React.Component { if (batch_id > 0) { getReseller(reseller_id).then((res) => { handelResponse(res, (req, msg) => { - this.setState({ reseller: req }); - this.setState({ phone_list: req.contact_phone }); - this.setState({ email_list: req.contact_email }); + this.setState({ reseller: req }) + this.setState({ phone_list: req.contact_phone }) + this.setState({ email_list: req.contact_email }) this.setState({ direct_reseller_id: req.direct_reseller_id - }); - }); - }); + }) + }) + }) getKeyBatchDetail(batch_id).then((res) => { handelResponse( res, (req, msg) => { - console.log('详情 =>', req); + console.log("详情 =>", req) if (req.status == 7) { - this.setState({ isCancel: true }); + this.setState({ isCancel: true }) } if (req.status == 1) { - this.setState({ isEdit: false }); + this.setState({ isEdit: false }) } else { - this.setState({ isEdit: true }); + this.setState({ isEdit: true }) } - this.setState({ key_status: req.status }); - this.setState({ plan_id: req.plan_id }); - this.setState({ pagetitle: '编辑key' }); + this.setState({ key_status: req.status }) + this.setState({ plan_id: req.plan_id }) + this.setState({ pagetitle: "编辑key" }) let model = { style: req.style, @@ -295,366 +296,358 @@ export default class acclist extends React.Component { code_batch: req.code_batch, coupon: req.coupon, plan_title: req.plan_title - }; - this.setState({ keyType: Number(req.bind_object[0]) }); - this.setState({ model: model }); - this.setState({ endtime: req.end_time }); - this.setState({ begintime: req.begin_time }); - this.setState({ mobile_excel: req.mobile_excel }); - this.setState({ mobile_repeat: req.mobile_repeat }); - this.setState({ status: req.status }); - this.setState({ id: req.id }); - console.log('详情 =>', req); - this.keyFormat(req); + } + this.setState({ keyType: Number(req.bind_object[0]) }) + this.setState({ model: model }) + this.setState({ endtime: req.end_time }) + this.setState({ begintime: req.begin_time }) + this.setState({ mobile_excel: req.mobile_excel }) + this.setState({ mobile_repeat: req.mobile_repeat }) + this.setState({ status: req.status }) + this.setState({ id: req.id }) + console.log("详情 =>", req) + this.keyFormat(req) }, (err) => {} - ); - }); + ) + }) } } async submit() { - let valide = false; + let valide = false if (this.state.direct_reseller_id <= 0) { // 老数据不能进行新增商品操作 - Notify.error(`请添加映射分销商`); - return; + Notify.error(`请添加映射分销商`) + return } if (this.refs.form1.validator()) { - let data = {}; - data.style = this.state.model.style; - data.quantity = this.state.model.quantity; - data.bind_object = [this.state.model.bind_object]; - data.allow_repetition = this.state.model.allow_repetition; - data.allow_loss = this.state.model.allow_loss; - data.stock = this.state.model.stock; - data.code_batch = this.state.distdata; - let formdata = {}; - formdata.step = 'key'; - formdata.data = data; - await addPlanStep('', formdata).then((res) => { + let data = {} + data.style = this.state.model.style + data.quantity = this.state.model.quantity + data.bind_object = [this.state.model.bind_object] + data.allow_repetition = this.state.model.allow_repetition + data.allow_loss = this.state.model.allow_loss + data.stock = this.state.model.stock + data.code_batch = this.state.distdata + let formdata = {} + formdata.step = "key" + formdata.data = data + await addPlanStep("", formdata).then((res) => { handelResponse( res, (req, msg) => { - sessionStorage.setItem('plan_id', req.id); - valide = true; - return; + sessionStorage.setItem("plan_id", req.id) + valide = true + return }, (err) => { - Notify.error(err); + Notify.error(err) } - ); - }); + ) + }) } - return valide; + return valide } Cancel() { Sweetalert.confirm({ - type: 'warning', + type: "warning", closeBtn: true, - title: '确认操作', + title: "确认操作", content:

是否取消本次操作?

, onConfirm: () => { - window.history.back(); + window.history.back() }, onCancel: this.onCancel, - className: 'questModal', + className: "questModal", parentComponent: this - }); + }) } onCheckChange = (e) => { - this.setState({ keyType: e.target.value }); - }; + this.setState({ keyType: e.target.value }) + } onStyleChange(e) { - let model2 = this.state.model; - model2.style = e.target.value; - this.setState({ model: model2 }); + let model2 = this.state.model + model2.style = e.target.value + this.setState({ model: model2 }) } onRepetitionChange(e) { - let model2 = this.state.model; - model2.allow_repetition = e.target.value; - this.setState({ model: model2 }); + let model2 = this.state.model + model2.allow_repetition = e.target.value + this.setState({ model: model2 }) } onLossChange(e) { - let model2 = this.state.model; - model2.allow_loss = e.target.value; - this.setState({ model: model2 }); + let model2 = this.state.model + model2.allow_loss = e.target.value + this.setState({ model: model2 }) } checkIndex(e) { switch (e) { case 0: - this.setState({ draw_title: '新建兑换码' }); - break; + this.setState({ draw_title: "新建兑换码" }) + break case 1: - this.setState({ draw_title: '新建优惠券' }); - break; + this.setState({ draw_title: "新建优惠券" }) + break case 2: - this.setState({ draw_title: '新建立减金' }); - break; + this.setState({ draw_title: "新建立减金" }) + break default: - return; + return } - this.setState({ rowIndex: -1 }); - this.setState({ drawerVisible: true }); + this.setState({ rowIndex: -1 }) + this.setState({ drawerVisible: true }) if (this.state.keyType === 2) { setTimeout(() => { - this.refs.addEditCouponEl.clearCouponForm(); - }); + this.refs.addEditCouponEl.clearCouponForm() + }) } else { setTimeout(() => { - this.refs.addEditExChangeEl.clearCouponForm(); - }); + this.refs.addEditExChangeEl.clearCouponForm() + }) } - sessionStorage.setItem('productData', ''); - sessionStorage.setItem('knockGoldData', ''); + sessionStorage.setItem("productData", "") + sessionStorage.setItem("knockGoldData", "") } closeDraw() { if (this.state.keyType === 2) { setTimeout(() => { - this.refs.addEditCouponEl.clearCouponForm(); - }); + this.refs.addEditCouponEl.clearCouponForm() + }) } - this.setState({ drawerVisible: false }); + this.setState({ drawerVisible: false }) } async productSubmit() { - let visible = ''; - if (this.state.addIsType === 'addProduct') { - visible = await this.refs.product.submit(); + let visible = "" + if (this.state.addIsType === "addProduct") { + visible = await this.refs.product.submit() } else { - visible = await this.refs.knockGold.submit(); + visible = await this.refs.knockGold.submit() } if (visible) { - Notify.success('保存成功'); - this.setState({ drawerVisible2: false }); + Notify.success("保存成功") + this.setState({ drawerVisible2: false }) setTimeout(() => { - let data = null; - let temp = null; - let concatData = []; + let data = null + let temp = null + let concatData = [] /* 处理商品 */ - if (this.state.addIsType === 'addProduct') { - data = JSON.parse(sessionStorage.getItem('productData')).filter( - (item) => item.type != 2 - ); - concatData = this.state.tempdata.filter((item) => item.type !== 1); + if (this.state.addIsType === "addProduct") { + data = JSON.parse(sessionStorage.getItem("productData")).filter((item) => item.type != 2) + concatData = this.state.tempdata.filter((item) => item.type !== 1) temp = map(data, (item) => { let index = this.state.tempdata.findIndex((o) => { - return o.product_id == item.product_id; - }); + return o.product_id == item.product_id + }) if (index > -1) { - item.checked = this.state.tempdata[index].checked; + item.checked = this.state.tempdata[index].checked } - item.type = 1; - item.only = item.product_id; - item.upstream = '直连天下'; - return item; - }); + item.type = 1 + item.only = item.product_id + item.upstream = "直连天下" + return item + }) } else { /* 处理立减金 */ - data = JSON.parse(sessionStorage.getItem('knockGoldData')).filter( + data = JSON.parse(sessionStorage.getItem("knockGoldData")).filter( (item) => item.type != 1 - ); - concatData = this.state.tempdata.filter((item) => item.type !== 2); + ) + concatData = this.state.tempdata.filter((item) => item.type !== 2) temp = map(data, (item) => { let index = this.state.tempdata.findIndex((o) => { - return o.channel_activity_id === item.channel_activity_id; - }); + return o.channel_activity_id === item.channel_activity_id + }) if (index > -1) { - item.checked = this.state.tempdata[index].checked; + item.checked = this.state.tempdata[index].checked } /* 转换商品结构 */ // temp - const newObj = {}; - newObj.product_name = item.batch_goods_name - ? item.batch_goods_name - : item.product_name; //名字 - newObj.channel_activity_id = item.channel_activity_id; //批次号 - newObj.only = item.channel_activity_id; //批次号 - newObj.type = 2; //类型 - newObj.checked = item?.checked; - newObj.upstream = String(item.channel) === '1' ? '支付宝' : '微信'; //上游 - newObj.edit = 'edit'; + const newObj = {} + newObj.product_name = item.batch_goods_name ? item.batch_goods_name : item.product_name //名字 + newObj.channel_activity_id = item.channel_activity_id //批次号 + newObj.only = item.channel_activity_id //批次号 + newObj.type = 2 //类型 + newObj.checked = item?.checked + newObj.upstream = productTypeMenu(item.channel) //上游 + newObj.edit = "edit" newObj.effectDate = item.effectDate ? item.effectDate : item.time_limit?.effect_time.start_time + - ' 至 ' + - item.time_limit?.effect_time.end_time; //有效时间 - newObj.contract_price = item.contract_price - ? item.contract_price - : item.price; //单价 - newObj.official_price = item.official_price - ? item.official_price - : item.reduce_amount; //官方价 + " 至 " + + item.time_limit?.effect_time.end_time //有效时间 + newObj.contract_price = item.contract_price ? item.contract_price : item.price //单价 + newObj.official_price = item.official_price ? item.official_price : item.reduce_amount //官方价 newObj.quantity = item.quantity ? item.quantity - : parseInt(divNum(item.all_budget, item.reduce_amount)); //总库 - newObj.origin = item.origin ? item.origin : item; - newObj.id = item.goods_id ? item.goods_id : item.id; - return newObj; - }); + : parseInt(divNum(item.all_budget, item.reduce_amount)) //总库 + newObj.origin = item.origin ? item.origin : item + newObj.id = item.goods_id ? item.goods_id : item.id + return newObj + }) } - let newArray = deWeightThree(temp.concat(concatData), 'only'); + let newArray = deWeightThree(temp.concat(concatData), "only") //select数据 - let arr = []; - let rank = []; + let arr = [] + let rank = [] map(newArray, (res) => { - arr.push({ key: res.only, text: res.product_name }); + arr.push({ key: res.only, text: res.product_name }) if (res.checked) { - rank.push({ key: res.only, text: res.product_name }); + rank.push({ key: res.only, text: res.product_name }) } - }); + }) - arr = deWeightThree(arr, 'key'); + arr = deWeightThree(arr, "key") - this.setState({ tempdata: newArray, rankoptions: arr, rank }); - }, 500); + this.setState({ tempdata: newArray, rankoptions: arr, rank }) + }, 500) } } onChangeCombinedDate(e) { - let model2 = this.state.codeInfo; - model2.date_time = e; - this.setState({ codeInfo: model2 }); + let model2 = this.state.codeInfo + model2.date_time = e + this.setState({ codeInfo: model2 }) } submit2() { - this.refs.form2.validator(); + this.refs.form2.validator() } onRankChange(e) { forEach(this.state.tempdata, (item) => { item.checked = e.findIndex((checks) => { - return checks.key == item.only; - }) > -1; - }); - this.setState({ tempdata: this.state.tempdata }); - this.setState({ rank: e }); + return checks.key == item.only + }) > -1 + }) + this.setState({ tempdata: this.state.tempdata }) + this.setState({ rank: e }) } onUploadChange1(file, row) { - if (file.length > 0 && file[0].status == 'success') { + if (file.length > 0 && file[0].status == "success") { let rowIndex = this.state.tempdata.findIndex((o) => { - return o.product_id == row.product_id; - }); - this.state.tempdata[rowIndex].show_url = file[0].src; - this.setState({ tempdata: this.state.tempdata }); + return o.product_id == row.product_id + }) + this.state.tempdata[rowIndex].show_url = file[0].src + this.setState({ tempdata: this.state.tempdata }) } } onUploadChange2(file, row) { - if (file.length > 0 && file[0].status == 'success') { + if (file.length > 0 && file[0].status == "success") { let rowIndex = this.state.tempdata.findIndex((o) => { - return o.product_id == row.product_id; - }); + return o.product_id == row.product_id + }) - this.state.tempdata[rowIndex].describe_url = file[0].src; - this.setState({ tempdata: this.state.tempdata }); + this.state.tempdata[rowIndex].describe_url = file[0].src + this.setState({ tempdata: this.state.tempdata }) } } codeSubmit() { // 优惠券数据 if (this.state.keyType === 2) { - let coupon_validator = this.refs.addEditCouponEl.submit(); + let coupon_validator = this.refs.addEditCouponEl.submit() if (coupon_validator) { - let param = this.refs.addEditCouponEl.getModel(); - console.log('param =>', param); - let tempdata = this.state.couponData; + let param = this.refs.addEditCouponEl.getModel() + console.log("param =>", param) + let tempdata = this.state.couponData // 优惠券编辑 if (this.state.rowIndex > -1) { - tempdata[this.state.rowIndex] = param; - this.setState({ couponData: tempdata }); + tempdata[this.state.rowIndex] = param + this.setState({ couponData: tempdata }) } else { // 优惠券新增 - tempdata.push(param); - this.setState({ couponData: tempdata }); + tempdata.push(param) + this.setState({ couponData: tempdata }) } this.setState({ drawerVisible: false - }); + }) } - return; + return } else { // 兑换码 - let ex_validator = this.refs.addEditExChangeEl.submit(); + let ex_validator = this.refs.addEditExChangeEl.submit() if (ex_validator) { - let param = this.refs.addEditExChangeEl.getModel(); - console.log('兑换码 param =>', param); - let tempdata = this.state.distdata; + let param = this.refs.addEditExChangeEl.getModel() + console.log("兑换码 param =>", param) + let tempdata = this.state.distdata // 优惠券编辑 if (this.state.rowIndex > -1) { - tempdata[this.state.rowIndex] = param; - this.setState({ distdata: tempdata }); + tempdata[this.state.rowIndex] = param + this.setState({ distdata: tempdata }) } else { // 优惠券新增 - tempdata.push(param); - this.setState({ distdata: tempdata }); + tempdata.push(param) + this.setState({ distdata: tempdata }) } this.setState({ drawerVisible: false - }); + }) } } } onAddKey() { let obj = { - style: '1', - quantity: '', - allow_repetition: '1', - allow_loss: '1', - merge_stock: '1', - code_batch: '', - draw_title: '' - }; - let keys = this.state.keys; - keys.push(obj); + style: "1", + quantity: "", + allow_repetition: "1", + allow_loss: "1", + merge_stock: "1", + code_batch: "", + draw_title: "" + } + let keys = this.state.keys + keys.push(obj) - this.setState({ keys: keys }); + this.setState({ keys: keys }) } onReCall() { - let approval_id = sessionStorage.getItem('approval_id'); - this.setState({ recall_visible: false }); + let approval_id = sessionStorage.getItem("approval_id") + this.setState({ recall_visible: false }) if (approval_id > 0) { terminateApprovals(approval_id).then((res) => { handelResponse( res, (req, msg) => { - this.setState({ approvalLoading: true }); + this.setState({ approvalLoading: true }) let timer_c = setInterval(() => { if (this.state.timer <= 0) { - clearInterval(timer_c); - this.setState({ approvalLoading: false }); - Notify.success('撤销成功,请重新提交审核'); + clearInterval(timer_c) + this.setState({ approvalLoading: false }) + Notify.success("撤销成功,请重新提交审核") } - let time = this.state.timer - 1; - this.setState({ timer: time }); - }, 1000); + let time = this.state.timer - 1 + this.setState({ timer: time }) + }, 1000) }, (err) => { - Notify.error(err); + Notify.error(err) } - ); - }); + ) + }) } } onSubmit() { - this.setState({ audit_visible: true }); + this.setState({ audit_visible: true }) } onConfirm() { // 判断类型 keyType 1兑换码 2优惠券 if (this.state.keyType === 1) { - this.exchangeSubmit(); + this.exchangeSubmit() } else { - this.couponSubmit(); + this.couponSubmit() } } @@ -664,7 +657,7 @@ export default class acclist extends React.Component { * @param {*} data */ couponExchangeSubmitApi(apiType, data) { - let keybatch_id = sessionStorage.getItem('keybatch_id'); + let keybatch_id = sessionStorage.getItem("keybatch_id") if (apiType === 0) { let create_param = { id: this.state.id, @@ -682,27 +675,27 @@ export default class acclist extends React.Component { company_name: this.state.reseller.company_name, receive_email: this.state.reseller.contact_email[0], payment_direction: this.state.payment_direction[this.state.paytype - 1] - }; + } // 参数 是否是优惠券还是兑换码 if (this.state.keyType === 1) { - create_param.code_batch = data; + create_param.code_batch = data } else { - create_param.coupon = data; + create_param.coupon = data } addKeysBatchInfo(this.state.plan_id, create_param).then((res) => { handelResponse( res, (req, msg) => { - Notify.success('成功发起审批'); + Notify.success("成功发起审批") setTimeout(() => { - window.history.back(); - }, 1000); + window.history.back() + }, 1000) }, (err) => { - Notify.error(err); + Notify.error(err) } - ); - }); + ) + }) } else { let edit_param = { reseller_id: this.state.reseller.id, @@ -710,27 +703,27 @@ export default class acclist extends React.Component { company_name: this.state.reseller.company_name, receive_email: this.state.reseller.contact_email[0], payment_direction: this.state.payment_direction[this.state.paytype - 1] - }; + } // 参数 是否是优惠券还是兑换码 if (this.state.keyType === 1) { - edit_param.code_batch = data; + edit_param.code_batch = data } else { - edit_param.coupon = data; + edit_param.coupon = data } keyEditApproval(keybatch_id, edit_param).then((res) => { handelResponse( res, (req, msg) => { - Notify.success('成功发起审批'); + Notify.success("成功发起审批") setTimeout(() => { - window.history.back(); - }, 1000); + window.history.back() + }, 1000) }, (err) => { - Notify.error(err); + Notify.error(err) } - ); - }); + ) + }) } } @@ -740,27 +733,25 @@ export default class acclist extends React.Component { let editCouponData = this.state.couponData.filter( (item) => item.checked === true && - (item.status === -1 || item.status === 7 || item.id === '' || !item.id) - ); + (item.status === -1 || item.status === 7 || item.id === "" || !item.id) + ) // 第二步:是否是 创建中或者驳回 if (this.state.key_status === 1) { // 第三步:是否有原数据 - let couponArr = this.state.couponData.filter( - (item) => item.id && item.id !== '' - ); + let couponArr = this.state.couponData.filter((item) => item.id && item.id !== "") if (couponArr.length > 0) { // 编辑接口 - this.couponExchangeSubmitApi(1, editCouponData); + this.couponExchangeSubmitApi(1, editCouponData) } else { // 新增接口 let addCouponData = this.state.couponData.filter( (item) => item.checked === true && !item.id - ); - this.couponExchangeSubmitApi(0, addCouponData); + ) + this.couponExchangeSubmitApi(0, addCouponData) } } else { // 其它状态 - this.couponExchangeSubmitApi(1, editCouponData); + this.couponExchangeSubmitApi(1, editCouponData) } } @@ -770,357 +761,346 @@ export default class acclist extends React.Component { let editExchangeData = this.state.distdata.filter( (item) => item.checked === true && - (item.status === -1 || item.status === 7 || item.id === '' || !item.id) - ); + (item.status === -1 || item.status === 7 || item.id === "" || !item.id) + ) // 第一步:判断是否是新增还是编辑 // 第二步:是否是 创建中或者驳回 if (this.state.key_status === 1) { // 第三步:是否有原数据 - let arr = editExchangeData.filter((item) => item.id && item.id !== ''); + let arr = editExchangeData.filter((item) => item.id && item.id !== "") if (arr.length > 0) { // 编辑接口 - this.couponExchangeSubmitApi(1, editExchangeData); + this.couponExchangeSubmitApi(1, editExchangeData) } else { // 新增接口 - let addArr = this.state.distdata.filter( - (item) => item.checked === true && !item.id - ); - this.couponExchangeSubmitApi(0, addArr); + let addArr = this.state.distdata.filter((item) => item.checked === true && !item.id) + this.couponExchangeSubmitApi(0, addArr) } } else { // 其它状态 - this.couponExchangeSubmitApi(1, editExchangeData); + this.couponExchangeSubmitApi(1, editExchangeData) } } onBindNum(e, row, rowIndex) { if (this.state.keyType === 1) { - this.state.distdata[rowIndex].restrict = e.target.value; - this.setState({ distdata: this.state.distdata }); + this.state.distdata[rowIndex].restrict = e.target.value + this.setState({ distdata: this.state.distdata }) } else { - this.state.couponData[rowIndex].restrict = e.target.value; - this.setState({ couponData: this.state.couponData }); + this.state.couponData[rowIndex].restrict = e.target.value + this.setState({ couponData: this.state.couponData }) } } onDisabledCombinedDate = (val) => { - let str = moment(val).format('YYYY-MM-DD HH:mm:ss'); + let str = moment(val).format("YYYY-MM-DD HH:mm:ss") - let now = moment(new Date().getTime()).format('YYYY-MM-DD HH:mm:ss'); - let isBetween = moment(str).isBetween(now, this.state.endtime, null, '(]'); - return !isBetween; - }; + let now = moment(new Date().getTime()).format("YYYY-MM-DD HH:mm:ss") + let isBetween = moment(str).isBetween(now, this.state.endtime, null, "(]") + return !isBetween + } onNameChange(e, row, rowIndex) { - this.state.tempdata[rowIndex].product_name = e.target.value; + this.state.tempdata[rowIndex].product_name = e.target.value let arr = map(this.state.tempdata, (res) => { - let obj = {}; - obj.key = res.product_id; - obj.text = res.product_name; - return obj; - }); - this.setState({ rankoptions: arr }); - this.setState({ rank: arr }); - this.setState({ tempdata: this.state.tempdata }); + let obj = {} + obj.key = res.product_id + obj.text = res.product_name + return obj + }) + this.setState({ rankoptions: arr }) + this.setState({ rank: arr }) + this.setState({ tempdata: this.state.tempdata }) } onQuantityChange(e, row, rowIndex) { - let value = e.target.value == '' ? 0 : e.target.value; + let value = e.target.value == "" ? 0 : e.target.value - this.state.tempdata[rowIndex].quantity = value; - this.setState({ tempdata: this.state.tempdata }); + this.state.tempdata[rowIndex].quantity = value + this.setState({ tempdata: this.state.tempdata }) } onPriceChange(e, row, rowIndex) { - let str = e.target.value; + let str = e.target.value let value = str - .replace(/[^\d^\.]+/g, '') - .replace('.', '$#$') - .replace(/\./g, '') - .replace('$#$', '.'); + .replace(/[^\d^\.]+/g, "") + .replace(".", "$#$") + .replace(/\./g, "") + .replace("$#$", ".") - this.state.tempdata[rowIndex].contract_price = value; - this.setState({ tempdata: this.state.tempdata }); + this.state.tempdata[rowIndex].contract_price = value + this.setState({ tempdata: this.state.tempdata }) } rowItemClick(row, rowIndex) { - console.log('row =>', row); + console.log("row =>", row) // 编辑兑换码 if (this.state.keyType === 1) { this.setState({ - draw_title: '编辑兑换码', + draw_title: "编辑兑换码", rowIndex: rowIndex, rowExChangeData: row, drawerVisible: true - }); + }) } else { this.setState({ - draw_title: '编辑优惠券', + draw_title: "编辑优惠券", rowIndex: rowIndex, rowCouponData: row, drawerVisible: true - }); + }) } } onUpload = (file, report) => { return new Promise((resolve, reject) => { - let path = ''; - let formdata = new FormData(); - formdata.append('file', file); - formdata.append('path', 'common_image'); + let path = "" + let formdata = new FormData() + formdata.append("file", file) + formdata.append("path", "common_image") uploadImg(formdata).then((res) => { handelResponse( res, (req, msg) => { - path = req.path; + path = req.path }, (err) => { - reject(); + reject() } - ); - }); + ) + }) - let count = 0; + let count = 0 const update = () => { if (path) { - resolve(path); + resolve(path) } else { if (count < 100) { - count += 2; - report(count); - setTimeout(update, 500); + count += 2 + report(count) + setTimeout(update, 500) } else { - reject(); + reject() } } - }; - setTimeout(update, 500); - }); - }; + } + setTimeout(update, 500) + }) + } onDisabledTime = (date, type) => { - const min = new Date(); - const hour = min.getHours(); - const minute = min.getMinutes(); - const second = min.getSeconds(); - const isSame = isSameDay(date, min); + const min = new Date() + 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) : [] } - : {}; - }; + : {} + } onDisabledRange = (date, type) => { - let isdisabled = false; - let str = moment(date).format('YYYY-MM-DD HH:mm:ss'); - let beign_time = this.state.codeInfo.date_time[0]; - let end_time = this.state.codeInfo.date_time[1]; - if (type == 'start') { - isdisabled = - moment(str).isBefore(beign_time) || moment(str).isAfter(end_time); + let isdisabled = false + let str = moment(date).format("YYYY-MM-DD HH:mm:ss") + let beign_time = this.state.codeInfo.date_time[0] + let end_time = this.state.codeInfo.date_time[1] + if (type == "start") { + isdisabled = moment(str).isBefore(beign_time) || moment(str).isAfter(end_time) } - if (type == 'end') { - isdisabled = - moment(str).isBefore(beign_time) || moment(str).isAfter(end_time); + if (type == "end") { + isdisabled = moment(str).isBefore(beign_time) || moment(str).isAfter(end_time) } - return isdisabled; - }; + return isdisabled + } onPayTypeChange(e) { - this.setState({ paytype: e.target.value }); + this.setState({ paytype: e.target.value }) } keyProductClick(row, index) { - console.log('keyProductClick 13==>', row); + console.log("keyProductClick 13==>", row) if (this.state.direct_reseller_id > 0) { /* 区分立减金 */ if (row.type === 2) { this.setState({ - product_title: '编辑立减金', + product_title: "编辑立减金", productData: row.origin, - addIsType: 'addKnockGold', + addIsType: "addKnockGold", drawerVisible2: true - }); + }) } else { this.setState({ - product_title: '编辑商品', + product_title: "编辑商品", productData: row, - addIsType: 'addProduct', + addIsType: "addProduct", drawerVisible2: true - }); + }) } } else { // 老数据不能进行新增商品操作 - Notify.error(`请添加映射分销商`); - return; + Notify.error(`请添加映射分销商`) + return } } render() { //校验规则 const rules = { - bind_object: [{ type: 'required', message: '请选择绑定类型' }] - }; + bind_object: [{ type: "required", message: "请选择绑定类型" }] + } const Column2 = [ { - title: '商品ID', - name: 'product_id', - prop: 'product_id', - width: 'auto', - type: 'normal' + title: "商品ID", + name: "product_id", + prop: "product_id", + width: "auto", + type: "normal" }, { - title: '商品名称', - width: 'auto', - prop: 'product_name', - name: 'product_name', - type: 'normal' + title: "商品名称", + width: "auto", + prop: "product_name", + name: "product_name", + type: "normal" }, { - title: '立减金平台批次号', - width: '250px', - prop: 'channel_activity_id', - name: 'channel_activity_id', - type: 'normal' + title: "立减金平台批次号", + width: "250px", + prop: "channel_activity_id", + name: "channel_activity_id", + type: "normal" }, { - title: '类型', - width: 'auto', - prop: 'type', - name: 'type', - type: 'slot' + title: "类型", + width: "auto", + prop: "type", + name: "type", + type: "slot" }, { - title: '上游平台', - width: 'auto', - prop: 'upstream', - name: 'upstream', - type: 'normal' + title: "上游平台", + width: "auto", + prop: "upstream", + name: "upstream", + type: "normal" }, { - title: '有效时间段', - width: '575px', - prop: 'effectDate', - name: 'effectDate', - type: 'normal' + title: "有效时间段", + width: "575px", + prop: "effectDate", + name: "effectDate", + type: "normal" }, { - title: '当前成本价格', - prop: 'cost_price', - name: 'cost_price', - width: '200px', - type: 'slot' + title: "当前成本价格", + prop: "cost_price", + name: "cost_price", + width: "200px", + type: "slot" }, { - title: '合同价', - name: 'contract_price', - prop: 'contract_price', - type: 'normal', - width: 'auto' + title: "合同价", + name: "contract_price", + prop: "contract_price", + type: "normal", + width: "auto" }, { - title: '商品官方价', - type: 'normal', - prop: 'official_price', - width: 'auto' + title: "商品官方价", + type: "normal", + prop: "official_price", + width: "auto" }, { - title: '库存', - type: 'normal', - prop: 'quantity', - width: 'auto' + title: "库存", + type: "normal", + prop: "quantity", + width: "auto" }, { - title: '操作', - prop: 'edit', - name: 'edit', - type: 'slot', - width: 'auto' + title: "操作", + prop: "edit", + name: "edit", + type: "slot", + width: "auto" } - ]; + ] //基本信息 const codeInfo = { - code_name: [{ type: 'required', message: '请输入兑换码名称' }], + code_name: [{ type: "required", message: "请输入兑换码名称" }], issued: [ - { type: 'required', message: '请输入发放总量' }, + { type: "required", message: "请输入发放总量" }, { - type: 'regExp', - message: '请输入正整数', - reg: '^([1-9][0-9]*){1,3}$' + type: "regExp", + message: "请输入正整数", + reg: "^([1-9][0-9]*){1,3}$" } ] - }; + } //基本规则 const rulesInfo = { - date_time: [{ type: 'required', message: '请选择生效时间段' }], - rank: [{ type: 'required', message: '请选择商品范围' }] - }; + date_time: [{ type: "required", message: "请选择生效时间段" }], + rank: [{ type: "required", message: "请选择商品范围" }] + } // 优惠券范围 const coupon_range = (product) => { - let arr_legal = product.legal.map((item) => item.product_name); - let arr_reduce = product.reduce.map((item) => item.batch_goods_name); - let arr = arr_legal.concat(arr_reduce); - arr = arr.join(','); - return {arr}; - }; + let arr_legal = product.legal.map((item) => item.product_name) + let arr_reduce = product.reduce.map((item) => item.batch_goods_name) + let arr = arr_legal.concat(arr_reduce) + arr = arr.join(",") + return {arr} + } return ( -
+
-
- -
{this.state.model.plan_title}
+ style={{ width: "98%", height: "auto", margin: "10px auto" }} + title={this.state.pagetitle} + > + + +
{this.state.model.plan_title}
- + { - let model2 = this.state.model; - model2.batch_name = e; - this.setState({ model: model2 }); + let model2 = this.state.model + model2.batch_name = e + this.setState({ model: model2 }) }} onClearItem={(e) => { - let model2 = this.state.model; - model2.batch_name = ''; - this.setState({ model: model2 }); + let model2 = this.state.model + model2.batch_name = "" + this.setState({ model: model2 }) }} value={this.state.model.batch_name} - placeholder={'请输入'} - labelWidth={'0px'} + placeholder={"请输入"} + labelWidth={"0px"} maxLength={12} - height={'36px'} - width={'400px'} - alignment={'left'} + height={"36px"} + width={"400px"} + alignment={"left"} /> - + { - this.onStyleChange(e); + this.onStyleChange(e) }} value={this.state.model.style} - disabled={this.state.isEdit}> + disabled={this.state.isEdit} + > 串码 @@ -1138,151 +1118,144 @@ export default class acclist extends React.Component { {this.state.white_visible ? ( ) : null} - + {this.state.key_status === 1 ? ( { - let model2 = this.state.model; - model2.quantity = e; - this.setState({ model: model2 }); + let model2 = this.state.model + model2.quantity = e + this.setState({ model: model2 }) }} value={this.state.model.quantity} disabled={this.state.model.style == 6} - placeholder={'请输入'} - labelWidth={'0px'} + placeholder={"请输入"} + labelWidth={"0px"} maxLength={5} - height={'36px'} - width={'400px'} - alignment={'left'} + height={"36px"} + width={"400px"} + alignment={"left"} /> ) : ( -
{this.state.model.quantity}
+
{this.state.model.quantity}
)}
{this.state.key_status === 1 ? null : ( - -
{this.state.model.stock}
+ +
{this.state.model.stock}
)} - + { - this.onCheckChange(e); - }}> + this.onCheckChange(e) + }} + > 兑换码 优惠券 - + {this.state.keyType === 1 ? ( ) : ( )} - + { - this.pageChange(e); + this.pageChange(e) }} checkChange={(selection) => {}} ComponentHandler={(com, rowData, rowIndex) => { - if (com == 'restrict') { + if (com == "restrict") { return ( { - this.onBindNum(e, rowData, rowIndex); + this.onBindNum(e, rowData, rowIndex) }} disabled={rowData.disabled} /> - ); + ) } // 优惠券范围 - if (com === 'product') { - return coupon_range(rowData.product); + if (com === "product") { + return coupon_range(rowData.product) } - if (com == 'edit') { + if (com == "edit") { let str = ( { - this.rowItemClick(rowData, rowIndex); + this.rowItemClick(rowData, rowIndex) }} - style={{ color: '#2B66F2' }}> + style={{ color: "#2B66F2" }} + > 编辑 - ); - let str1 = 编辑; + ) + let str1 = 编辑 - return rowData.disabled ? str1 : str; + return rowData.disabled ? str1 : str } }} /> - + this.onRepetitionChange(e)} - value={this.state.model.allow_repetition}> + value={this.state.model.allow_repetition} + > - + this.onLossChange(e)} - value={this.state.model.allow_loss}> + value={this.state.model.allow_loss} + > @@ -1290,137 +1263,142 @@ export default class acclist extends React.Component {
-
+
{this.state.isCancel ? null : ( - )} -
+
} visible={this.state.drawerVisible} onClose={(e) => { - this.closeDraw(); + this.closeDraw() }} - maskClosable={false}> + maskClosable={false} + > {this.state.keyType === 1 ? ( + ref="addEditExchangeEl" + > ) : ( + ref="addEditCouponEl" + direct_reseller_id={this.state.direct_reseller_id} + > )}
+
} visible={this.state.drawerVisible2} onClose={(e) => { - this.setState({ drawerVisible2: false }); + this.setState({ drawerVisible2: false }) }} - maskClosable={false}> -
- - {this.state.addIsType === 'addKnockGold' ? ( - + maskClosable={false} + > +
+ + {this.state.addIsType === "addKnockGold" ? ( + ) : ( - + )}
{this.state.audit_visible ? ( -
-
-
+
+
+
{ - this.setState({ audit_visible: false }); + this.setState({ audit_visible: false }) }} /> -
提交审核
-
+
提交审核
+
{ - this.onPayTypeChange(e); + this.onPayTypeChange(e) }} value={this.state.paytype} - className='audit-obj'> + className="audit-obj" + > 预付款扣除 对私账户 对公账户
-
+
@@ -1429,32 +1407,32 @@ export default class acclist extends React.Component { ) : null} {this.state.recall_visible ? ( -
-
-
+
+
+
{ - this.setState({ recall_visible: false }); + this.setState({ recall_visible: false }) }} /> -
当前正在审核中
-
- 提交审核会将原来审批撤回才可进行提交,是否撤回? -
-
+
当前正在审核中
+
提交审核会将原来审批撤回才可进行提交,是否撤回?
+
@@ -1463,18 +1441,18 @@ export default class acclist extends React.Component { ) : null} {this.state.approvalLoading ? ( -
-
-
-
撤销审批中
-
+
+
+
+
撤销审批中
+
正在发起撤销...,请等待 - {this.state.timer}秒 + {this.state.timer}
) : null}
- ); + ) } } diff --git a/src/tools/index.js b/src/tools/index.js index 4a29f844..c39ab7e4 100644 --- a/src/tools/index.js +++ b/src/tools/index.js @@ -19,7 +19,7 @@ const kgType = (item) => { export const knockGoldFun = (item) => { let table_obj = {} table_obj.type = 2 // 类型 - table_obj.upstream = String(item.channel) === "1" ? "支付宝" : "微信" // 上游平台 + table_obj.upstream = productTypeMenu(item.channel) // 上游平台 table_obj.only = item // 存储就数据 编辑好用 table_obj.product_id = item.goods_id ? item.goods_id : item.channel_activity_id // 商品编号 table_obj.product_name = item.batch_goods_name // 商品名 @@ -42,7 +42,7 @@ export const redPacketsFun = (item) => { ? item.denomination : `${item.min_denomination}~${item.max_denomination}` table_obj.type = 3 // 类型 - table_obj.upstream = item.channel === 1 ? "支付宝" : "微信" // 上游平台 + table_obj.upstream = productTypeMenu(item.channel) // 上游平台 table_obj.only = item // 存储就数据 编辑好用 table_obj.product_id = item.goods_id || item.id || item.cash_activity_id // 商品编号 table_obj.product_name = item.batch_goods_name // 商品名 @@ -59,7 +59,6 @@ export const redPacketsFun = (item) => { // 卡密判断 export const submitIsKm = (data) => { - console.log("submitIsKm =>", data) let visible = true let deDateTime = JSON.parse(sessionStorage.getItem("knockGold_effectDate")) let end_time = new Date(deDateTime.end_time).getTime() // 计划结束时间 @@ -75,3 +74,15 @@ export const submitIsKm = (data) => { } return visible } + +/* 商品类型 */ +export function productTypeMenu(type) { + switch (type) { + case 1: + return "支付宝" + case 2: + return "微信" + case 3: + return "云闪付" + } +}