- )
-}
+ );
+};
diff --git a/src/pages/coupon/addEdit/index.jsx b/src/pages/coupon/addEdit/index.jsx
index 91b9af08..a8cf1119 100644
--- a/src/pages/coupon/addEdit/index.jsx
+++ b/src/pages/coupon/addEdit/index.jsx
@@ -34,12 +34,6 @@ const CouponAddEdit = () => {
}
}, []);
- // 获取 计划
- const getPlanList = () => {};
-
- // 编辑-复制流程
- const initEditAndCopy = () => {};
-
return (
{state.isShow ? (
diff --git a/src/pages/plan/add/step2 copy.js b/src/pages/plan/add/step2 copy.js
deleted file mode 100644
index 72d408f1..00000000
--- a/src/pages/plan/add/step2 copy.js
+++ /dev/null
@@ -1,2029 +0,0 @@
-/* 生成key step2 */
-import ReactDOM from "react-dom";
-import React from "react";
-import { deWeightThree } from "@/utils";
-
-import "./step2.less";
-import {
- Card,
- Drawer,
- Button,
- Tabs,
- Notify,
- DateRangePicker,
- Select,
- Input,
- Radio,
- Switch,
- Icon,
- RadioGroup,
- RadioButton,
- BlockLoading,
-} 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 ProductForm from "../product/add"; /* 商品 */
-import KnockGold from "@/components/knockGold"; /* 立减金 */
-import UseCouponAddEdit from "@/components/UseCouponAddEdit"; /* 立减金 */
-import moment from "moment";
-import { uploadImg } from "@/assets/api.js";
-import "./add.less";
-import { isSameDay } from "date-fns";
-import _ from "lodash";
-import Bus from "@/assets/eventBus.js";
-const TabPanel = Tabs.TabPanel;
-
-const initArray = (targetNum) => {
- return Array.from({ length: targetNum }, (_, index) => index);
-};
-
-export default class acclist extends React.Component {
- constructor(props) {
- super(props);
-
- this.state = {
- model: {
- //数据模型不可少
- style: 1,
- quantity: 1,
- allow_repetition: 0,
- allow_loss: 0,
- merge_stock: 1,
- code_batch: "",
- draw_title: "",
- batch_name: "",
- },
- drawerVisible: false,
- drawerVisible2: false,
- productData: [],
- codeInfo: {
- //数据模型不可少
- code_name: "",
- issued: "", //发放总量
- describe: "",
- date_time: "",
- range: "",
- },
- rank: null,
- rankoptions: [],
- tempdata: [],
- distdata: [],
- couponData: [] /* 优惠卷数据 */,
- column_distdata: [],
- exceldata: [],
- oldData: null,
- uploading: false,
- rowIndex: -1,
- isload: props.isload ? props.isload : false,
- import_visible: false,
- white_visible: false,
- success_visible: false,
- fail_visible: false,
- file_loading: false,
- upload_visible: false,
- excel_visible: false,
- accessVerify: false,
- mobile_excel: "",
- mobile_repeat: [],
- execel_path: "",
- excel_count: 0,
- success_count: 0,
- error_count: 0,
- whiteStyle: false,
- import_success: false,
-
- product_title: "新建商品",
- newGoodsBtnLoading: false /* 商品按钮lodging */,
- newGoldLoading: false /* 立减金按钮lodging */,
- direct_reseller_id: 0,
- tableLoading: false,
- isCopy: props.isCopy ? true : false,
- rowCouponData: "",
- Column: [
- {
- title: "兑换名称",
- name: "title",
- prop: "title",
- type: "normal",
- width: "auto",
- },
- {
- title: "兑换码范围",
- type: "normal",
- prop: "range",
- width: "auto",
- },
- {
- title: "有效开始日期",
- prop: "begin_time",
- name: "begin_time",
- width: "auto",
- type: "normal",
- },
- {
- title: "有效结束日期",
- name: "end_time",
- prop: "end_time",
- type: "normal",
- width: "auto",
- },
- {
- title: "兑换码数量",
- name: "quantity",
- type: "normal",
- prop: "quantity",
- defaultText: "PM",
- width: "auto",
- },
- {
- title: "绑定数",
- prop: "restrict",
- name: "restrict",
- 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: "优惠券范围",
- prop: "product",
- name: "product",
- width: "auto",
- type: "slot",
- },
- {
- title: "有效开始日期",
- prop: "begin_time",
- name: "begin_time",
- width: "auto",
- type: "normal",
- },
- {
- title: "有效结束日期",
- name: "end_time",
- prop: "end_time",
- type: "normal",
- width: "auto",
- },
- {
- title: "优惠券数量",
- name: "quantity",
- type: "normal",
- prop: "quantity",
- defaultText: "PM",
- width: "auto",
- },
- {
- title: "绑定数",
- prop: "restrict",
- name: "restrict",
- 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();
- 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 });
- }
- }
-
- submit() {
- let valide = false;
- // 兑换码
- if (this.props.keyType === 1) {
- if (this.refs.form1.validator()) {
- /* 处理数据 区分立减金和商品 开始 2022-05-30 13:40*/
- const dataCopy = this.refs.tempdata.getSelectData();
- dataCopy.map((item) => {
- 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;
- })
- .filter((item3) => item3),
- };
- })
- );
- dataCopy.map((item) => {
- 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.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;
- 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;
- return data;
- }
- }
- return valide;
- }
-
- onCancel() {
- this.refs.form1.cancel();
- }
-
- onCheckChange = ({ target }) => {
- this.props.changeKeyType(target.value);
- // this.setState({ checkedList: target.value });
- };
-
- onStyleChange(e) {
- if (this.props.name == 0) {
- this.props.onStyleChange(e);
- }
-
- 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 });
- } else {
- sessionStorage.setItem("white", 3);
- this.setState({ white_visible: false });
- }
- }
-
- onRepetitionChange(e) {
- 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 });
- }
-
- checkIndex(e) {
- switch (e) {
- case 0:
- this.setState({ draw_title: "新建兑换码" });
- break;
- case 1:
- this.setState({ draw_title: "新建优惠券" });
- break;
- case 2:
- this.setState({ draw_title: "新建立减金" });
- break;
- default:
- break;
- }
- sessionStorage.setItem("productData", "");
- sessionStorage.setItem("knockGoldData", "");
-
- let codeInfo = {
- //数据模型不可少
- code_name: "",
- issued: "", //发放总量
- describe: "",
- date_time: JSON.parse(sessionStorage.getItem("datetime")),
- range: "",
- };
- this.setState({ rank: null });
- this.setState({ rankoptions: [] });
- this.setState({ codeInfo: codeInfo });
- this.setState({ tempdata: [] });
- this.setState({ drawerVisible: true });
- this.setState({ rowIndex: -1 });
- }
- closeDraw() {
- this.setState({ drawerVisible: false });
- }
-
- // 获取直连天下商品数据
- getProductInfoSelectData(reseller_id) {
- return new Promise((resolve, reject) => {
- let param = {
- reseller_id: reseller_id,
- };
- getProductInfoSelect(param).then((res) => {
- if (res.code === 200) {
- resolve(res.data.data);
- } else {
- reject([]);
- }
- });
- });
- }
-
- // 获取 直连天下数据
- addProduct(type) {
- this.setState({ addIsType: type }); /* 类型 */
- /* type: 立减金/商品 */
- let direct_reseller_ids = this.props.direct_reseller_id;
- if (direct_reseller_ids <= 0) {
- // 老数据不能进行新增商品操作
- Notify.error(`请添加映射分销商`);
- return;
- }
-
- if (type === "addProduct") {
- this.setState({ product_title: "新建商品", newGoodsBtnLoading: true });
- } else {
- this.setState({ product_title: "新增立减金", newGoldLoading: true });
- }
-
- this.getProductInfoSelectData(direct_reseller_ids).then((data) => {
- 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 });
- });
- }
-
- async productSubmit() {
- let visible = "";
- if (this.state.addIsType === "addProduct") {
- visible = await this.refs.product.submit();
- } else {
- visible = await this.refs.knockGold.submit();
- }
- if (visible) {
- Notify.success("保存成功");
- this.setState({ drawerVisible2: false });
- setTimeout(() => {
- 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);
-
- temp = _.map(data, (item) => {
- let index = this.state.tempdata.findIndex((o) => {
- return o.product_id == item.product_id;
- });
-
- if (index > -1) {
- item.checked = this.state.tempdata[index].checked;
- }
-
- item.type = 1;
- item.only = item.product_id;
- item.upstream = "直连天下";
- return item;
- });
- } else {
- /* 处理立减金 */
- data = JSON.parse(sessionStorage.getItem("knockGoldData")).filter(
- (item) => item.type !== 1
- );
-
- 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;
- });
-
- if (index > -1) {
- 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";
- 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; //官方价
- newObj.quantity = item.quantity
- ? item.quantity
- : parseInt(divNum(item.all_budget, item.reduce_amount)); //总库
- newObj.origin = item?.origin ? item?.origin : item;
- return newObj;
- });
- }
- let newArray = deWeightThree(temp.concat(concatData), "only");
-
- //select数据
- let arr = [];
- let rank = [];
- _.map(newArray, (res) => {
- arr.push({ key: res.only, text: res.product_name });
- if (res.checked) {
- rank.push({ key: res.only, text: res.product_name });
- }
- });
-
- arr = deWeightThree(arr, "key");
-
- this.setState({ tempdata: newArray, rankoptions: arr, rank });
- }, 500);
- }
- }
- setkeyStyle(style) {
- if (style == 6) {
- this.setState({ whiteStyle: true });
- this.setState({ white_visible: true });
- } else {
- this.setState({ whiteStyle: false });
- this.setState({ white_visible: false });
- }
-
- 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 });
- }
- submit2() {
- 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 });
- }
-
- codeSubmit() {
- // 优惠券数据
- if (this.props.keyType === 2) {
- let coupon_validator = this.refs.addEditCouponEl.submit();
- if (coupon_validator) {
- 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 });
- } else {
- // 优惠券新增
- tempdata.push(param);
- this.setState({ couponData: tempdata });
- }
- this.setState({
- drawerVisible: false,
- });
- }
- return;
- }
-
- // 兑换码数据
- if (this.refs.code_info.validator() && this.refs.code_rule.validator()) {
- let productlist = _.filter(this.state.tempdata, (item) => {
- return item.checked == true;
- });
- let sum = 0;
-
- _.forEach(productlist, (o) => {
- sum += parseInt(o.quantity);
- });
-
- if (sum < this.state.codeInfo.issued) {
- Notify.error("所选商品库存总数小于发放量");
- return;
- }
-
- if (this.state.uploading) {
- Notify.error("还有图片上传中,不可提交");
- return;
- }
-
- this.setState({ drawerVisible: false });
- let rank = _.map(this.state.rank, (item) => {
- return item.text;
- });
- let temp = {
- title: this.state.codeInfo.code_name,
- describe: this.state.codeInfo.describe,
- begin_time: this.state.codeInfo.date_time[0],
- end_time: this.state.codeInfo.date_time[1],
- quantity: this.state.codeInfo.issued,
- restrict: this.state.codeInfo.restrict,
- range: rank.toString(),
- };
- 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.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?.toString();
- obj.detail_url = item.detail_url;
- obj.account_type = item.account_type;
- 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.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 });
- } else {
- let tempdata = this.state.distdata;
- tempdata.push(temp);
- this.setState({ distdata: tempdata });
- }
- }
- }
- addNewKey() {
- this.props.addNewkey();
- }
- onRestrict(e, rowdata, index) {
- let text = e.target.value;
- text = text.replace(/[^\d]/g, "");
- this.state.distdata[index].restrict = text;
- this.setState({ distdata: this.state.distdata });
- }
-
- 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;
- };
-
- onDisabledTime = (date, type) => {
- 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) : [],
- disabledSeconds: (hourValue, minuteValue) =>
- 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") {
- isdisabled =
- moment(str).isBefore(step1.begin_time) ||
- moment(str).subtract(1, "days").isAfter(step1.end_time);
- } else {
- isdisabled =
- moment(str).isBefore(step1.begin_time) ||
- moment(str).isAfter(step1.end_time);
- }
- }
-
- if (type == "end") {
- isdisabled =
- moment(str).add(1, "days").isBefore(step1.begin_time) ||
- moment(str).isAfter(step1.end_time);
- }
- return isdisabled;
- };
-
- edit(data) {
- let model = {
- //数据模型不可少
- batch_name: data.batch_name,
- style: parseInt(data.style),
- quantity: data.quantity,
- allow_repetition: parseInt(data.allow_repetition),
- allow_loss: parseInt(data.allow_loss),
- 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 });
- if (model.style == 6) {
- this.setState({ white_visible: true });
- }
-
- 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;
- });
-
- this.setState({ distdata: temp });
- this.setState({ isload: true });
- }
-
- coupon_edit(data) {
- let model = {
- //数据模型不可少
- batch_name: data.batch_name,
- style: parseInt(data.style),
- quantity: data.quantity,
- allow_repetition: parseInt(data.allow_repetition),
- allow_loss: parseInt(data.allow_loss),
- 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) {
- this.setState({ white_visible: true });
- }
- this.setState({ model: model });
-
- let temp = _.map(data.coupon, (o) => {
- o.checked = true;
- return o;
- });
-
- 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");
- uploadImg(formdata).then((res) => {
- handelResponse(
- res,
- (req, msg) => {
- path = req.path;
- },
- (err) => {
- reject();
- }
- );
- });
-
- let count = 0;
- const update = () => {
- if (path) {
- resolve(path);
- } else {
- if (count < 100) {
- count += 2;
- report(count);
- setTimeout(update, 500);
- } else {
- reject();
- }
- }
- };
- setTimeout(update, 500);
- });
- };
-
- onUploadError = (type, data) => {
- 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") {
- 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 });
- }
- }
- onUploadChange2(file, row) {
- 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 });
- }
- }
-
- onNameChange(e, row, rowIndex) {
- 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 });
- }
- onQuantityChange(e, row, rowIndex) {
- 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 value = str
- .replace(/[^\d^\.]+/g, "")
- .replace(".", "$#$")
- .replace(/\./g, "")
- .replace("$#$", ".");
-
- this.state.tempdata[rowIndex].contract_price = value;
- this.setState({ tempdata: this.state.tempdata });
- }
-
- rowItemClick(row, rowIndex) {
- // 兑换码
- if (this.props.keyType === 1) {
- let codeInfo = {
- //数据模型不可少
- code_name: row.title,
- issued: row.quantity, //发放总量
- describe: row.describe,
- 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;
- });
- this.setState({
- draw_title: "编辑兑换码",
- rankoptions: arr,
- rank: arr,
- codeInfo: codeInfo,
- rowIndex: rowIndex,
- });
-
- let temp = _.map(row.product, (o) => {
- o.checked = true;
- return o;
- });
- sessionStorage.setItem("productData", JSON.stringify(row.product));
- sessionStorage.setItem("knockGoldData", JSON.stringify(row.product));
- this.setState({ tempdata: temp, drawerVisible: true });
- } else {
- this.setState({
- 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 });
- }
-
- importConfirmClick() {
- 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 });
-
- 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 });
- }
-
- importClick() {
- if (this.state.file_loading) {
- Notify.error("文件正在解析中请稍等");
- } else {
- if (this.state.success_visible) {
- this.setState({ accessVerify: false });
- this.setState({ excel_visible: true });
- this.setState({ import_visible: false });
- } else {
- Notify.error("请上传正确的文件");
- }
- }
- }
- fileChange(e) {
- // this.initUpload();
-
- 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")
- ) {
- if (my_file.size > 1024000) {
- Notify.error("文件大小不能大于2M");
- return;
- }
-
- 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 });
- getAccessVerification(data).then((res) => {
- 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 });
- },
- (err) => {
- Notify.error(err);
- this.setState({ success_visible: false });
- }
- );
- });
- },
- (err) => {
- Notify.error(err);
- this.setState({ success_visible: false });
- }
- );
- });
- } else {
- this.setState({ success_visible: false });
- }
- }
-
- resetUpload() {
- this.setState({ excel_visible: false });
- this.setState({ import_visible: true });
- this.setState({ accessVerify: true });
- }
-
- switchChange(e, rowData) {
- if (e) {
- rowData.type = "success";
- } else {
- 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";
- }
- /* 商品范围列表编辑 */
- productEditShow(rowData) {
- if (this.props.direct_reseller_id > 0) {
- this.setState({
- tableLoading: true,
- });
- this.getProductInfoSelectData(this.props.direct_reseller_id).then(
- (data) => {
- sessionStorage.setItem("productsList", JSON.stringify(data));
- /* 区分立减金 */
- if (rowData.type === 2) {
- let obj = rowData.origin;
- // 是否是复制操作
- if (this.state.isCopy) {
- delete obj.id;
- }
- this.setState({
- product_title: "编辑立减金",
- productData: obj,
- addIsType: "addKnockGold",
- });
- } else {
- this.setState({
- product_title: "编辑商品",
- productData: rowData,
- addIsType: "addProduct",
- });
- }
- setTimeout(() => {
- this.setState({
- tableLoading: false,
- });
- this.setState({ drawerVisible2: true });
- }, 300);
- }
- );
- } else {
- // 老数据不能进行新增商品操作
- Notify.error(`请添加映射分销商`);
- return;
- }
- }
-
- /* 区分商品、立减金、优惠卷组件加载 */
- filterComponentFunction() {
- switch (this.state.addIsType) {
- case "addProduct":
- return
;
- case "addKnockGold":
- return (
-
- );
- }
- }
-
- render() {
- //校验规则
- const rules = {
- bind_object: [{ type: "required", message: "请选择绑定类型" }],
-
- batch_name: [{ type: "required", message: "请输入key批次名称" }],
- };
-
- const Column2 = [
- {
- 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: "250px",
- prop: "channel_activity_id",
- name: "channel_activity_id",
- type: "normal",
- },
- {
- title: "类型",
- width: "auto",
- prop: "type",
- name: "type",
- type: "slot",
- },
- {
- title: "上游平台",
- width: "auto",
- prop: "upstream",
- name: "upstream",
- type: "normal",
- },
- {
- title: "有效时间段",
- width: "575px",
- prop: "effectDate",
- name: "effectDate",
- type: "normal",
- },
- {
- title: "当前成本价格",
- prop: "cost_price",
- name: "cost_price",
- width: "200px",
- type: "slot",
- },
- {
- title: "合同价",
- name: "contract_price",
- prop: "contract_price",
- type: "normal",
- width: "auto",
- },
- {
- title: "商品官方价",
- type: "normal",
- prop: "official_price",
- width: "auto",
- },
- {
- title: "库存总数量",
- prop: "quantity",
- name: "quantity",
- type: "normal",
- width: "auto",
- },
- {
- title: "操作",
- prop: "edit",
- name: "edit",
- type: "slot",
- width: "auto",
- },
- ];
-
- const rules2 = {
- codename: [{ type: "required", message: "请输入兑换码名称" }],
- issued: [{ type: "required", message: "请输入发放总量" }],
- tip: [{ type: "required", message: "请输入" }],
- };
-
- //基本信息
- const codeInfo = {
- code_name: [{ type: "required", message: "请输入兑换码名称" }],
- issued: [
- { type: "required", message: "请输入发放总量" },
- {
- type: "regExp",
- message: "请输入正整数",
- reg: "^([1-9][0-9]*){1,3}$",
- },
- ],
- };
-
- //基本规则
- const rulesInfo = {
- date_time: [{ type: "required", message: "请选择生效时间段" }],
- rank: [{ type: "required", message: "请选择商品范围" }],
- };
-
- const excelColumn = [
- {
- title: "行号",
- name: "line",
- prop: "line",
- width: "30px",
- type: "normal",
- },
- {
- title: "手机号",
- width: "80px",
- prop: "mobile",
- name: "mobile",
- type: "normal",
- },
- {
- title: "错误原因",
- width: "80px",
- prop: "tips",
- name: "tips",
- type: "normal",
- },
- {
- title: "是否导入",
- width: "50px",
- prop: "is_import",
- name: "is_import",
- type: "slot",
- },
- ];
-
- // 优惠券范围
- 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};
- };
-
- return (
-
-
-
{
- this.addNewKey();
- }}
- >
- 添加新的批次key
-
-
-
-
-
-
- }
- visible={this.state.drawerVisible}
- onClose={(e) => {
- this.closeDraw();
- }}
- maskClosable={false}
- >
- {this.props.keyType === 1 ? (
-
- ) : (
-
- )}
-
- {this.state.import_visible ? (
-
-
-
-
-
从Excel导入白名单
-
-
{
- this.setState({ import_visible: false });
- }}
- />
-
-
-
-
-
直接上传
-
-
-
支持文件类型:xls,xlsx,csv
-
- - 支持所有基础字段的导入,一次至多导入 10000
- 条手机号(不符合规则整条任务不予以导入)
-
-
-
- {this.state.upload_visible ? (
-
-
-
-
-
- {this.state.myfile.name}
-
-
-
- {this.state.file_loading ? (
-
-
- 解析中
-
- ) : (
-
- this.fileChange(e)}
- />
-
- 更新文件
-
- )}
-
- {this.state.success_visible ? (
-
-
- 文件解析成功,点击确定导入 即可导入
-
- ) : null}
- {this.state.fail_visible ? (
-
-
- 文件解析失败,请查看导入规则并更新文件
-
- ) : null}
-
- ) : (
-
- this.fileChange(e)}
- />
- {" "}
-
- )}
-
-
-
下载模板并填写后上传
-
-
-
- 请先下载「数字世界营销管理系统_白名单_模板」并按照模板填写后再上传。
-
-
-
-
-
-
-
-
-
-
-
-
- ) : null}
-
-
-
-
-
- }
- visible={this.state.drawerVisible2}
- onClose={(e) => {
- this.setState({ drawerVisible2: false });
- }}
- maskClosable={false}
- >
-