From 0d30d79c867da6a8d6750f7257b9e1c5abb69ba5 Mon Sep 17 00:00:00 2001 From: zhangds Date: Thu, 4 Aug 2022 15:19:24 +0800 Subject: [PATCH] =?UTF-8?q?1)=20=E5=A2=9E=E5=8A=A0=E8=90=A5=E9=94=80?= =?UTF-8?q?=E7=B3=BB=E7=BB=9F=E4=B8=80=E9=94=AE=E5=A4=8D=E5=88=B6=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/assets/api.js | 7 +- src/pages/home/home.js | 6 + src/pages/plan/add/copy.less | 3 + src/pages/plan/add/edit-copy.js | 812 +++++++++++++++++++++++++++ src/pages/plan/list/list.js | 959 +++++++++++++++++--------------- 5 files changed, 1325 insertions(+), 462 deletions(-) create mode 100644 src/pages/plan/add/copy.less create mode 100644 src/pages/plan/add/edit-copy.js diff --git a/src/assets/api.js b/src/assets/api.js index dba63a9b..9883fa54 100644 --- a/src/assets/api.js +++ b/src/assets/api.js @@ -421,12 +421,7 @@ export const getIsRequireApproval = (id, data) => { // //蓝色兄弟映射商品 export const getProductInfoSelect = (params) => { - // return req("get", baseurl + "/product/market/products", params); - return req( - "get", - "https://marketapi.1688sup.com" + "/product/market/products", - params - ); + return req("get", baseurl + "/product/market/products", params); }; // 上传 diff --git a/src/pages/home/home.js b/src/pages/home/home.js index f5723e31..2c81654e 100644 --- a/src/pages/home/home.js +++ b/src/pages/home/home.js @@ -30,6 +30,7 @@ import planlist from "../plan/list/list"; import planadd from "../plan/add/add"; import planedit from "../plan/add/edit"; import plancopy from "../plan/copy/index"; +import planeditcopy from "../plan/add/edit-copy"; import keylist from "../plan/key/list"; import keysList from "../plan/keyList"; @@ -479,6 +480,11 @@ export default class App extends Component { component={plancopy} > + 是否返回计划列表?

, + onConfirm: () => { + self.props.history.push("/home/plan-list/"); + }, + onCancel: this.onCancel, + className: "questModal", + parentComponent: this, + }); + } + + componentDidMount(e) { + // let plan_status = sessionStorage.getItem("plan_status"); + // if (plan_status == 3 || plan_status == 4 || plan_status == 5) { + // this.setState({ disabled: true }); + // } + let plan_id = sessionStorage.getItem("plan_id"); + let approval_id = sessionStorage.getItem("approval_id"); + let copy_count_golod = sessionStorage.getItem("copy_count_golod"); + console.log("plan_id =>", plan_id); + console.log("approval_id =>", approval_id); + console.log("copy_count_golod =>", copy_count_golod); + //获取审批接口的编辑信息 + if (Number(approval_id) > 0) { + getApprovalsInfo(approval_id).then((res) => { + handelResponse( + res, + (req, msg) => { + console.log("res 1", res); + try { + //获取分销商 + getReseller(req.info.reseller_id).then((res) => { + handelResponse(res, (req, msg) => { + this.setState({ + direct_reseller_id: req.direct_reseller_id, + }); + }); + }); + } catch (err) { + console.log("err =>", err); + } + + if (req.info) { + this.refs.step1.edit(req.info); + } + if (req.keys.length > 0 && this.state.disabled == false) { + this.setState({ curstep: 2 }); + //转译 + req.keys = this.tranFormData(req); + for (let i = 0; i < req.keys.length; i++) { + this.addNewkey(); + } + + setTimeout(() => { + for (let i = 0; i < this.state.keys.length; i++) { + console.log(req.keys[i]); + this.refs["step2-" + i].edit(req.keys[i]); + } + }, 500); + } + if (req.theme) { + let theme_data = { + theme_id: req.theme.theme_id, + use: req.theme.theme_data.use, + link: req.theme.theme_data.link, + list: req.theme.theme_data.list, + }; + + this.setState({ step3_data: theme_data }); + this.setState({ card_visible: true }); + this.setState({ curstep: 3 }); + } + if (req.payment_direction) { + let index = this.state.payment_direction.indexOf( + req.payment_direction + ); + this.setState({ paytype: index + 1 }); + } + }, + (err) => { + Notify.error(err); + } + ); + }); + } else { + //获取草稿信息 + console.log("获取草稿信息 ==>", plan_id); + getDraftInfo(plan_id).then((res) => { + console.log("res =>", res); + handelResponse( + res, + (req, msg) => { + //获取分销商 + // req.info.reseller_id + getReseller(req.info.reseller_id).then((res) => { + handelResponse(res, (req, msg) => { + console.log("res req=>", req); + this.setState({ + direct_reseller_id: req.direct_reseller_id, + }); + }); + }); + + if (req.info) { + this.refs.step1.edit(req.info); + } + if (req.keys.length > 0 && this.state.disabled == false) { + this.setState({ curstep: 2 }); + //转译 + req.keys = this.tranFormData(req); + + for (let i = 0; i < req.keys.length; i++) { + this.addNewkey(); + } + + setTimeout(() => { + for (let i = 0; i < this.state.keys.length; i++) { + this.refs["step2-" + i].edit(req.keys[i]); + } + }, 500); + } else { + this.addNewkey(); + } + }, + (err) => { + Notify.error(err); + } + ); + }); + } + } + + /* 转译 */ + tranFormData(req) { + req.keys.map((item) => { + item.code_batch.map((item1) => { + item1.products = []; + }); + }); + + req.keys.map((item) => { + item.code_batch.map((item1) => { + item1.product.legal.map((item2) => { + item2.only = item2.product_id; + item2.type = 1; + item2.upstream = "直连天下"; + item1.products.push(item2); + }); + + item1.product.reduce.map((item3) => { + let obj = {}; + obj.product_name = item3.batch_goods_name; //名字 + obj.channel_activity_id = item3.channel_activity_id; //批次号 + obj.only = item3.channel_activity_id; + obj.type = 2; //类型 + obj.upstream = String(item3.channel) === "1" ? "支付宝" : "微信"; //上游 + obj.effectDate = + item3.time_limit.effect_time.start_time + + " 至 " + + item3.time_limit.effect_time.end_time; //有效时间 + obj.contract_price = item3.price; //单价 + obj.official_price = item3.reduce_amount; //官方价 + obj.quantity = Math.trunc(item3.all_budget / item3.reduce_amount); //总库存 + obj.origin = item3; + item1.products.push(obj); + }); + }); + }); + + req.keys.map((item) => { + item.code_batch.map((item1) => { + item1.product = item1.products; + delete item1.products; + }); + }); + + return req.keys; + } + async onNextStep() { + if (this.state.curstep >= 1) { + if ((await this.refs.step1.submit()) == true) { + this.setState({ isload: true }); + this.setState({ curstep: 2 }); + } else { + return; + } + } + + if (this.state.curstep >= 2) { + let temp = []; + for (let i = 0; i < this.state.keys.length; i++) { + let data = null; + if (this.refs[this.state.keys[i]]) { + data = this.refs[this.state.keys[i]].submit(); + } else { + continue; + } + + if (data) { + temp.push(data); + } else { + return; + } + } + + // if (this.state.direct_reseller_id <= 0) { + // // 老数据不能进行新增商品操作 + // Notify.error(`请添加映射分销商2`); + // return; + // } + + let obj = { + info: JSON.parse(sessionStorage.getItem("step1")), + key: temp, + }; + console.log("obj =>", obj); + let plan_id = sessionStorage.getItem("plan_id"); + obj.info.copy_plan_id = plan_id; + await addPlanStep(plan_id, obj).then((res) => { + handelResponse( + res, + (req, msg) => { + this.setState({ curstep: 3 }); + sessionStorage.setItem("step2", JSON.stringify(temp)); + this.setState({ card_visible: true }); + return; + }, + (err) => { + Notify.error(err); + } + ); + }); + } + + if (this.state.curstep == 3) { + let data = this.refs.step3.submit(); + if (data) { + let obj = { + info: JSON.parse(sessionStorage.getItem("step1")), + key: JSON.parse(sessionStorage.getItem("step2")), + theme: data, + complete: true, + }; + + let plan_id = sessionStorage.getItem("plan_id"); + obj.info.copy_plan_id = plan_id; + addPlanStep(plan_id, obj).then((res) => { + handelResponse( + res, + (req, msg) => { + //获取电话 邮箱 + let id = obj.info.reseller_id; + getReseller(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({ audit_visible: true }); + }); + }); + }, + (err) => { + Notify.error(err); + } + ); + }); + } else { + return; + } + } + } + + addNewkey() { + let step = "step2-" + this.state.keys.length; + this.state.keys.push(step); + this.setState({ keys: this.state.keys }); + this.setState({ isload: true }); + } + + onPhoneChange(e) { + this.setState({ phone_radio: e.target.value }); + } + onEmailChange(e) { + this.setState({ email_radio: e.target.value }); + } + cancel(e) { + this.setState({ audit_visible: false }); + } + + closeStep(index) { + this.state.keys[index] = ""; + + this.setState({ keys: this.state.keys }); + } + + // 获取分销商 id + getDirectResellerId = (data) => { + this.setState({ + direct_reseller_id: data.direct_reseller_id, + }); + }; + + send(e) { + let plan_id = sessionStorage.getItem("plan_id"); + let data = { + phone: + this.state.phone_radio > -1 + ? this.state.phone_list[this.state.phone_radio] + : this.state.phone, + email: + this.state.email_radio > -1 + ? this.state.email_list[this.state.email_radio] + : this.state.email, + }; + + let phoneReg = new RegExp("^[1][3,4,5,6,7,8,9][0-9]{9}$"); + if (!phoneReg.test(data.phone)) { + Notify.error("手机号格式不正确"); + return; + } + + planSend(plan_id, data).then((res) => { + handelResponse( + res, + (req, msg) => { + Notify.success("发送成功,请在1-2分钟后查看"); + this.props.history.push("/home/plan-list/"); + }, + (err) => { + Notify.success("发送成功,请在1-2分钟后查看"); + this.props.history.push("/home/plan-list/"); + } + ); + }); + } + + async onEditInfo() { + let plan_id = sessionStorage.getItem("plan_id"); + if (!this.state.is_Edit) { + this.setState({ is_Edit: true }); + if (await this.refs.step1.submit(plan_id)) { + setTimeout(() => { + this.props.history.push("/home/plan-list/"); + this.setState({ is_Edit: false }); + }, 1500); + } + } + } + onConfirm(e) { + if (this.state.btn_loading == true) { + return; + } + this.setState({ btn_loading: true }); + + let plan_id = sessionStorage.getItem("plan_id"); + let plan_status = sessionStorage.getItem("plan_status"); + this.setState({ audit_visible: false }); + + let approval_id = sessionStorage.getItem("approval_id"); + + if (approval_id > 0) { + getApprovalsStatus(approval_id).then((res) => { + setTimeout(() => { + this.setState({ btn_loading: false }); + }, 500); + handelResponse( + res, + (req, msg) => { + if (req.status == 0) { + this.setState({ recall_visible: true }); + } + if (req.status == 1) { + Notify.error("进行中的计划不能提交审核"); + setTimeout(() => { + this.props.history.push("/home/plan-list/"); + }, 2000); + } + if (req.status == 2 || req.status == 3) { + let data = { + reseller_id: this.state.reseller.id, + reseller_name: this.state.reseller.name, + 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.direct_reseller_id <= 0) { + // 老数据不能进行新增商品操作 + Notify.error(`请添加映射分销商1`); + return; + } + approvals(plan_id, data).then((res) => { + handelResponse( + res, + (req, msg) => { + this.setState({ audit_visible: false }); + Notify.success("成功发起审批"); + this.props.history.push("/home/plan-list/"); + }, + (err) => { + Notify.error(err); + } + ); + }); + } + }, + (err) => { + Notify.error(err); + } + ); + }); + } else { + let data = { + reseller_id: this.state.reseller.id, + reseller_name: this.state.reseller.name, + company_name: this.state.reseller.company_name, + receive_email: this.state.email_list[0], + payment_direction: this.state.payment_direction[this.state.paytype - 1], + }; + + approvals(plan_id, data).then((res) => { + handelResponse( + res, + (req, msg) => { + Notify.success("成功发起审批"); + this.setState({ audit_visible: false }); + this.props.history.push("/home/plan-list/"); + }, + (err) => { + Notify.error(err); + } + ); + }); + } + } + + phoneChange = (e) => { + this.setState({ phone: e.target.value }); + }; + emailChange = (e) => { + this.setState({ email: e.target.value }); + }; + + onPayTypeChange(e) { + this.setState({ paytype: e.target.value }); + } + onReCall() { + let approval_id = sessionStorage.getItem("approval_id"); + this.setState({ recall_visible: false }); + terminateApprovals(approval_id).then((res) => { + handelResponse( + res, + (req, msg) => { + this.setState({ approvalLoading: true }); + let timer_c = setInterval(() => { + console.log(this.state.timer); + if (this.state.timer <= 0) { + clearInterval(timer_c); + this.setState({ approvalLoading: false }); + Notify.success("撤销成功,请重新提交审核"); + } + let time = this.state.timer - 1; + this.setState({ timer: time }); + }, 1000); + }, + (err) => { + Notify.error(err); + } + ); + }); + } + onStyleChange(e) { + console.log("状态", e.target.value); + if (e.target.value == 6) { + this.setState({ whiteStyle: true }); + this.setState({ keyStyle: 6 }); + } else { + this.setState({ keyStyle: e.target.value }); + this.setState({ whiteStyle: false }); + } + } + render() { + return ( +
+ {this.state.disabled ? ( +
+
+
+
营销计划
+ + + +
+
+ + +
+
+
+ ) : ( +
+
+
+
营销计划
+ + + this.getDirectResellerId(data) + } + /> + +
+ + {this.state.curstep >= 2 ? ( +
+
key
+ {this.state.keys.map((item, index) => { + return item ? ( + 0 ? ( + { + this.closeStep(index); + }} + > + 关闭 + + ) : null + } + > + { + this.addNewkey(); + }} + name={index} + onStyleChange={(e) => { + this.onStyleChange(e); + }} + is_Edit={true} + whiteStyle={this.state.whiteStyle} + keyStyle={this.state.keyStyle} + isload={this.state.isload} + data={item} + direct_reseller_id={this.state.direct_reseller_id} + disabled={this.state.disabled} + /> + + ) : null; + })} +
+ ) : null} + + {this.state.card_visible ? ( +
+ + + +
+ ) : null} + + {this.state.card_visible ? ( +
+ + +
+ ) : ( +
+ + +
+ )} + + {this.state.audit_visible ? ( +
+
+
+ { + this.setState({ audit_visible: false }); + }} + /> +
提交审核
+
+ { + this.onPayTypeChange(e); + }} + value={this.state.paytype} + className="audit-obj" + > + 预付款扣除 + 对私账户 + 对公账户 + +
+
+ + +
+
+
+ ) : null} + + {this.state.recall_visible ? ( +
+
+
+ { + this.onReturn(e); + }} + /> +
审核中
+
+ 提交审核会将原来审批撤回才可进行提交,是否撤回? +
+
+ + +
+
+
+ ) : null} + + {this.state.approvalLoading ? ( +
+
+
+
撤销审批中
+
+ 正在发起撤销...,请等待 + {this.state.timer} + 秒 +
+
+
+ ) : null} +
+
+ )} +
+ ); + } +} diff --git a/src/pages/plan/list/list.js b/src/pages/plan/list/list.js index c7ef917d..54aa2ac2 100644 --- a/src/pages/plan/list/list.js +++ b/src/pages/plan/list/list.js @@ -1,9 +1,9 @@ /* 营销计划列表 */ -import ReactDOM from 'react-dom' -import React, { Component } from 'react' -import { HashRouter as Router, Route, Link } from 'react-router-dom' -import { Button, Alert } from 'zent' -import './list.less' +import ReactDOM from "react-dom"; +import React, { Component } from "react"; +import { HashRouter as Router, Route, Link } from "react-router-dom"; +import { Button, Alert } from "zent"; +import "./list.less"; import { Input, openDialog, @@ -20,13 +20,13 @@ import { MenuItem, DropdownContent, Menu, - Sweetalert -} from 'zent' -import '../../../assets/comm.css' -import Ipt from '../../../components/input/main' -import Grid from '../../../components/gird/main.js' -import TabPage from '../../../components/tabPage/main.js' -import Filterbar from '../../../components/filterbar/main.js' + Sweetalert, +} from "zent"; +import "../../../assets/comm.css"; +import Ipt from "../../../components/input/main"; +import Grid from "../../../components/gird/main.js"; +import TabPage from "../../../components/tabPage/main.js"; +import Filterbar from "../../../components/filterbar/main.js"; import { planIsSend, planCancel, @@ -39,48 +39,48 @@ import { planSend, planResend, planReceive, - getReseller -} from '../../../assets/api.js' -import _ from 'lodash' -import menu from '../../../assets/enum.js' -const PAGE_SIZE_OPTIONS = [10, 20, 30] + getReseller, +} from "../../../assets/api.js"; +import _ from "lodash"; +import menu from "../../../assets/enum.js"; +const PAGE_SIZE_OPTIONS = [10, 20, 30]; export default class acclist extends React.Component { constructor(props) { - super(props) + super(props); this.state = { dataCount: 0, page: 1, limit: 10, - tabList: [{ title: '营销计划列表' }], + tabList: [{ title: "营销计划列表" }], distdata: [], filterList: [ { id: 0, - label: '状态', - prop: 'status', + label: "状态", + prop: "status", menuList: [ - { id: 999, name: '全部' }, - { id: 0, name: '创建中' }, - { id: 2, name: '审核中' }, - { id: 3, name: '待生效' }, - { id: 4, name: '进行中' }, - { id: 5, name: '暂停中' }, - { id: 6, name: '已完结' }, - { id: 7, name: '未通过' }, - { id: 8, name: '已作废' } - ] - } + { id: 999, name: "全部" }, + { id: 0, name: "创建中" }, + { id: 2, name: "审核中" }, + { id: 3, name: "待生效" }, + { id: 4, name: "进行中" }, + { id: 5, name: "暂停中" }, + { id: 6, name: "已完结" }, + { id: 7, name: "未通过" }, + { id: 8, name: "已作废" }, + ], + }, ], tableHeight: 500, - menuList: [{ id: 0, name: '状态', check: false }], + menuList: [{ id: 0, name: "状态", check: false }], phone_list: [], email_list: [], - phone: '', - email: '', + phone: "", + email: "", email_radio: -1, phone_radio: -1, - key_word: '', + key_word: "", audit_visible: false, cur_item: null, @@ -94,28 +94,28 @@ export default class acclist extends React.Component { usage_total: 0, silent_total: 0, isSend: true, - isCancel: false - } + isCancel: false, + }; } clickFn() { let link = window.location.href.replace( window.location.hash, - '#/home/plan-create' - ) - window.open(link, '_blank') + "#/home/plan-create" + ); + window.open(link, "_blank"); } //分页 onPageChange(e) { - this.setState({ page: e }) + this.setState({ page: e }); setTimeout(() => { - this.getpageFn() - }, 0) + this.getpageFn(); + }, 0); } send(e) { - let phoneReg = new RegExp('^[1][3,4,5,6,7,8,9][0-9]{9}$') - let emailReg = new RegExp('w+@w+.w+(.w+){0,1}') + let phoneReg = new RegExp("^[1][3,4,5,6,7,8,9][0-9]{9}$"); + let emailReg = new RegExp("w+@w+.w+(.w+){0,1}"); - let plan_id = this.state.plan_id + let plan_id = this.state.plan_id; let data = { phone: this.state.phone_radio > -1 @@ -124,208 +124,208 @@ export default class acclist extends React.Component { email: this.state.email_radio > -1 ? this.state.email_list[this.state.email_radio] - : this.state.email - } + : this.state.email, + }; if (!phoneReg.test(data.phone)) { - Notify.error('手机号格式不正确') - return + Notify.error("手机号格式不正确"); + return; } planSend(plan_id, data).then((res) => { handelResponse( res, (req, msg) => { - this.setState({ audit_visible: false }) - Notify.success('发送成功') + this.setState({ audit_visible: false }); + Notify.success("发送成功"); }, (err) => { - Notify.error(err) + Notify.error(err); } - ) - }) + ); + }); } componentDidMount(e) { let data = { page: 1, - limit: 10 - } - this.getPlanList(data) + limit: 10, + }; + this.getPlanList(data); } componentWillMount() { - this.setState({ tableHeight: window.innerHeight - 430 }) + this.setState({ tableHeight: window.innerHeight - 430 }); } getPlanList(data) { let queryParams = _.omitBy(data, (value) => { - return _.isNaN(value) || _.isNil(value) - }) + return _.isNaN(value) || _.isNil(value); + }); getPlanList(queryParams).then((res) => { handelResponse( res, (req, msg) => { - this.setState({ distdata: req.data }) - this.setState({ dataCount: req.total }) + this.setState({ distdata: req.data }); + this.setState({ dataCount: req.total }); }, (err) => {} - ) - }) + ); + }); } onCountChange(e) { this.setState({ page: 1, - limit: e - }) + limit: e, + }); setTimeout(() => { - this.getpageFn() - }, 200) + this.getpageFn(); + }, 200); } getpageFn() { let data = { page: this.state.page, limit: this.state.limit, status: this.state.status, - key_word: this.state.key_word + key_word: this.state.key_word, + }; + if (data.key_word === "") { + delete data.key_word; } - if (data.key_word === '') { - delete data.key_word - } - this.getPlanList(data) + this.getPlanList(data); } //切换siwtch onSwitchChange(status, row) { - let self = this + let self = this; Sweetalert.confirm({ - type: 'warning', + type: "warning", closeBtn: true, - title: '确认操作', + title: "确认操作", content: (

- 是否改变{row.open == 1 ? '关闭' : '开启'} + 是否改变{row.open == 1 ? "关闭" : "开启"} [{row.title}]的状态?

), onConfirm: () => { - this.changeState(status, row) + this.changeState(status, row); }, onCancel: this.onCancel, - className: 'questModal', - parentComponent: this - }) + className: "questModal", + parentComponent: this, + }); } cancel(e) { - this.setState({ audit_visible: false }) + this.setState({ audit_visible: false }); } //修改状态 changeState(status, row) { - let self = this + let self = this; let data = { - operation: status ? 1 : 2 - } + operation: status ? 1 : 2, + }; if (row.status == 3) { - this.setState({ plan_id: row.id }) + this.setState({ plan_id: row.id }); planIsSend(row.id).then((res) => { handelResponse(res, (req, msg) => { if (req.is_send == false) { - this.setState({ cur_item: row }) + this.setState({ cur_item: row }); getReseller(row.reseller_id).then((res) => { handelResponse( res, (req, msg) => { - this.setState({ phone_list: req.contact_phone }) - this.setState({ email_list: req.contact_email }) - this.setState({ isSend: false }) - this.setState({ audit_visible: true }) + this.setState({ phone_list: req.contact_phone }); + this.setState({ email_list: req.contact_email }); + this.setState({ isSend: false }); + this.setState({ audit_visible: true }); }, (err) => { - Notify.error(err) + Notify.error(err); } - ) - }) + ); + }); } else { startOrStopPlan(row.id, data).then((res) => { handelResponse( res, (req, msg) => { let id = _.findIndex(this.state.distdata, (o) => { - return o.id == row.id - }) - this.state.distdata[id].open = status ? 2 : 1 - this.setState({ distdata: this.state.distdata }) + return o.id == row.id; + }); + this.state.distdata[id].open = status ? 2 : 1; + this.setState({ distdata: this.state.distdata }); let data = { page: this.state.page, limit: this.state.limit, status: this.state.status, - key_word: this.state.key_word - } - self.getPlanList(data) - Notify.success('更改状态成功') + key_word: this.state.key_word, + }; + self.getPlanList(data); + Notify.success("更改状态成功"); }, (err) => { - Notify.error(err) + Notify.error(err); } - ) - }) + ); + }); } - }) - }) + }); + }); } else { startOrStopPlan(row.id, data).then((res) => { handelResponse( res, (req, msg) => { let id = _.findIndex(this.state.distdata, (o) => { - return o.id == row.id - }) - this.state.distdata[id].open = status ? 2 : 1 - this.setState({ distdata: this.state.distdata }) + return o.id == row.id; + }); + this.state.distdata[id].open = status ? 2 : 1; + this.setState({ distdata: this.state.distdata }); let data = { page: this.state.page, limit: this.state.limit, status: this.state.status, - key_word: this.state.key_word - } - self.getPlanList(data) - Notify.success('更改状态成功') + key_word: this.state.key_word, + }; + self.getPlanList(data); + Notify.success("更改状态成功"); }, (err) => { - Notify.error(err) + Notify.error(err); } - ) - }) + ); + }); } } //输入值变化 onInputChange(e) {} //营销系统名称 linkTo(row) { - sessionStorage.setItem('showflag', true) + sessionStorage.setItem("showflag", true); let arr = [ { - pagetitle: '编辑', + pagetitle: "编辑", items: [ - { path: '/home/key-list', name: '营销计划管理' }, - { path: '/home/key-list', name: row.title + 'key列表' } - ] - } - ] - sessionStorage.setItem('plan_item', JSON.stringify(row)) - sessionStorage.setItem('knockGold_effectDate', JSON.stringify(row)) - sessionStorage.setItem('breaknav', JSON.stringify(arr)) - sessionStorage.setItem('linkshowname', '营销计划管理') - sessionStorage.setItem('key_plan_id', row.id) - sessionStorage.setItem('key_plan_status', row.status) + { path: "/home/key-list", name: "营销计划管理" }, + { path: "/home/key-list", name: row.title + "key列表" }, + ], + }, + ]; + sessionStorage.setItem("plan_item", JSON.stringify(row)); + sessionStorage.setItem("knockGold_effectDate", JSON.stringify(row)); + sessionStorage.setItem("breaknav", JSON.stringify(arr)); + sessionStorage.setItem("linkshowname", "营销计划管理"); + sessionStorage.setItem("key_plan_id", row.id); + sessionStorage.setItem("key_plan_status", row.status); // this.props.history.push('/home/key-list'); - window.open('#/home/key-list') + window.open("#/home/key-list"); } menuItemClick(e, key, row) { - this.setState({ plan_id: row.id }) + this.setState({ plan_id: row.id }); if (row.status == 6) { - Notify.clear() - Notify.error('该状态下的数据不允许编辑') - return + Notify.clear(); + Notify.error("该状态下的数据不允许编辑"); + return; } if (key == 1) { @@ -333,114 +333,114 @@ export default class acclist extends React.Component { handelResponse( res, (req, msg) => { - this.setState({ phone_list: req.contact_phone }) - this.setState({ email_list: req.contact_email }) - this.setState({ audit_visible: true }) + this.setState({ phone_list: req.contact_phone }); + this.setState({ email_list: req.contact_email }); + this.setState({ audit_visible: true }); }, (err) => { - Notify.error(err) + Notify.error(err); } - ) - }) + ); + }); } if (key == 3) { - let self = this + let self = this; Sweetalert.confirm({ - type: 'warning', + type: "warning", closeBtn: true, - title: '确认操作', + title: "确认操作", content:

是否确定作废[{row.title}]?

, onConfirm: () => { - self.setState({ isCancel: true }) + self.setState({ isCancel: true }); planCancel(row.id).then((res) => { - self.setState({ isCancel: false }) + self.setState({ isCancel: false }); handelResponse( res, (req, msg) => { - Notify.success('作废成功') - self.setState({ page: 1 }) - self.setState({ limit: 10 }) + Notify.success("作废成功"); + self.setState({ page: 1 }); + self.setState({ limit: 10 }); let data = { page: 1, - limit: 10 - } - self.getPlanList(data) + limit: 10, + }; + self.getPlanList(data); }, (err) => { - Notify.error(err) + Notify.error(err); } - ) - }) + ); + }); }, onCancel: this.onCancel, - className: 'questModal', - parentComponent: this - }) + className: "questModal", + parentComponent: this, + }); } //删除 if (key == 4) { - let self = this + let self = this; Sweetalert.confirm({ - type: 'warning', + type: "warning", closeBtn: true, - title: '确认操作', + title: "确认操作", content:

是否确定删除[{row.title}]?

, onConfirm: () => { deldraftCode(row.id).then((res) => { handelResponse( res, (req, msg) => { - Notify.success(msg) - self.setState({ page: 1 }) - self.setState({ limit: 10 }) + Notify.success(msg); + self.setState({ page: 1 }); + self.setState({ limit: 10 }); let data = { page: 1, limit: 10, status: this.state.status, - key_word: this.state.key_word + key_word: this.state.key_word, + }; + if (data.key_word === "") { + delete data.key_word; } - if (data.key_word === '') { - delete data.key_word - } - self.getPlanList(data) + self.getPlanList(data); }, (err) => { - Notify.error(err) + Notify.error(err); } - ) - }) + ); + }); }, onCancel: this.onCancel, - className: 'questModal', - parentComponent: this - }) + className: "questModal", + parentComponent: this, + }); } } //清空 clearFn() { - this.refs.plan_list.allChecked(false) - this.setState({ selectiondata: [] }) + this.refs.plan_list.allChecked(false); + this.setState({ selectiondata: [] }); } //选中表格的选框 selection(selection) { - this.setState({ selectiondata: selection }) - let grantTotal = 0 - let receiveTotal = 0 - let usageTotal = 0 - let silentTotal = 0 - let receive_total = 0 - let usage_total = 0 - let silent_total = 0 + this.setState({ selectiondata: selection }); + let grantTotal = 0; + let receiveTotal = 0; + let usageTotal = 0; + let silentTotal = 0; + let receive_total = 0; + let usage_total = 0; + let silent_total = 0; selection.forEach((item) => { - grantTotal += Number(item.grant) - receiveTotal += Number(item.receive) - usageTotal += Number(item.usage) - silentTotal += Number(item.silent) - receive_total += Number(item.receive_total) - usage_total += Number(item.usage_total) - silent_total += Number(item.silent_total) - }) + grantTotal += Number(item.grant); + receiveTotal += Number(item.receive); + usageTotal += Number(item.usage); + silentTotal += Number(item.silent); + receive_total += Number(item.receive_total); + usage_total += Number(item.usage_total); + silent_total += Number(item.silent_total); + }); this.setState({ grantTotal, receiveTotal, @@ -448,33 +448,33 @@ export default class acclist extends React.Component { silentTotal, receive_total, usage_total, - silent_total - }) + silent_total, + }); } onFilter(e, prop) { - this.setState({ page: 1 }) - this.setState({ limit: 10 }) + this.setState({ page: 1 }); + this.setState({ limit: 10 }); let data = { page: 1, limit: 10, - key_word: this.state.key_word - } - data[prop] = e + key_word: this.state.key_word, + }; + data[prop] = e; if (e == 999) { - delete data[prop] + delete data[prop]; } else { - let params = {} - params[prop] = e - this.setState(params) + let params = {}; + params[prop] = e; + this.setState(params); } - this.getPlanList(data) + this.getPlanList(data); } 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 }); + }; // 监听组件内部状态的变化: componentDidUpdate(prevProps, prevState) { @@ -484,201 +484,226 @@ export default class acclist extends React.Component { prevState.key_word != this.state.key_word && prevState.status != this.state.status ) { - this.iptsureFn() + this.iptsureFn(); } } iptsureFn(e) { - this.setState({ page: 1 }) - this.setState({ limit: 10 }) + this.setState({ page: 1 }); + this.setState({ limit: 10 }); let data = { page: 1, limit: 10, status: this.state.status, - key_word: this.state.key_word - } - this.getPlanList(data) + key_word: this.state.key_word, + }; + this.getPlanList(data); } 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 }); } onEdit(e, row) { - sessionStorage.setItem('showflag', true) + sessionStorage.setItem("showflag", true); let editarr = [ { - pagetitle: '编辑', + pagetitle: "编辑", items: [ - { path: '/home/key-list', name: '营销计划管理' }, - { path: '/home/key-list', name: '编辑:' + row.title } - ] - } - ] - sessionStorage.setItem('breakchangenav', JSON.stringify(editarr)) + { path: "/home/key-list", name: "营销计划管理" }, + { path: "/home/key-list", name: "编辑:" + row.title }, + ], + }, + ]; + sessionStorage.setItem("breakchangenav", JSON.stringify(editarr)); if (row.status == 6) { - Notify.clear() - Notify.error('不可编辑') - return + Notify.clear(); + Notify.error("不可编辑"); + return; } - sessionStorage.setItem('plan_id', row.id) - sessionStorage.setItem('plan_status', row.status) - sessionStorage.setItem('approval_id', row.approval_id) + sessionStorage.setItem("plan_id", row.id); + sessionStorage.setItem("plan_status", row.status); + sessionStorage.setItem("approval_id", row.approval_id); let link = window.location.href.replace( window.location.hash, - '#/home/plan-edit' - ) - window.open(link, '_blank') + "#/home/plan-edit" + ); + window.open(link, "_blank"); - sessionStorage.setItem('showflag', true) + sessionStorage.setItem("showflag", true); let arr = [ { - pagetitle: '编辑', + pagetitle: "编辑", items: [ - { path: '/home/key-list', name: '营销计划管理' }, - { path: '/home/key-list', name: '编辑:' + row.title } - ] - } - ] - sessionStorage.setItem('breaknav', JSON.stringify(arr)) - sessionStorage.setItem('linkshowname', '营销计划管理') + { path: "/home/key-list", name: "营销计划管理" }, + { path: "/home/key-list", name: "编辑:" + row.title }, + ], + }, + ]; + sessionStorage.setItem("breaknav", JSON.stringify(arr)); + sessionStorage.setItem("linkshowname", "营销计划管理"); } // 一键复制 - onCopy(e, data) { - console.log('data =>', data) - if (data.status === 0) { - return - } + onCopy(e, row) { + console.log("row =>", row); + sessionStorage.setItem("showflag", true); + let editarr = [ + { + pagetitle: "复制", + items: [ + { path: "/home/key-list", name: "营销计划管理" }, + { path: "/home/key-list", name: "复制:" + row.title }, + ], + }, + ]; + sessionStorage.setItem("breakchangenav", JSON.stringify(editarr)); + sessionStorage.setItem("plan_id", row.id); + sessionStorage.setItem("plan_status", row.status); + sessionStorage.setItem("approval_id", row.approval_id); + sessionStorage.setItem("copy_count_golod", row.copy_count); let link = window.location.href.replace( window.location.hash, - '#/home/plan-copy' - ) - window.open(link, '_blank') + "#/home/plan-edit-copy" + ); + window.open(link, "_blank"); + + sessionStorage.setItem("showflag", true); + let arr = [ + { + pagetitle: "复制", + items: [ + { path: "/home/plan-edit-copy", name: "营销计划管理" }, + { path: "/home/plan-edit-copy", name: "复制:" + row.title }, + ], + }, + ]; + sessionStorage.setItem("breaknav", JSON.stringify(arr)); + sessionStorage.setItem("linkshowname", "营销计划管理"); } onFilterClose(prop) { - let data = {} - data[prop] = null - this.setState(data) - this.setState({ page: 1 }) - this.setState({ limit: 10 }) + let data = {}; + data[prop] = null; + this.setState(data); + this.setState({ page: 1 }); + this.setState({ limit: 10 }); let params = { page: 1, limit: 10, - key_word: this.state.key_word - } - this.getPlanList(params) + key_word: this.state.key_word, + }; + this.getPlanList(params); } render() { - const { current, pageSize } = this.state + const { current, pageSize } = this.state; const Column = [ { - title: '营销计划名称', - name: 'title', - prop: 'title', - type: 'slot', - width: 'auto' + title: "营销计划名称", + name: "title", + prop: "title", + type: "slot", + width: "auto", }, { - title: '启用', - width: 'auto', - type: 'slot', - prop: 'switch' + title: "启用", + width: "auto", + type: "slot", + prop: "switch", }, { - title: '分销商', - prop: 'reseller_name', - name: 'reseller_name', - width: 'auto', - type: 'normal' + title: "分销商", + prop: "reseller_name", + name: "reseller_name", + width: "auto", + type: "normal", }, { - title: '状态', - name: 'status', - prop: 'status', - type: 'slot', - width: 'auto' + title: "状态", + name: "status", + prop: "status", + type: "slot", + width: "auto", }, { - title: '创建人', - name: 'creator_name', - prop: 'creator_name', - type: 'normal', - width: 'auto' + title: "创建人", + name: "creator_name", + prop: "creator_name", + type: "normal", + width: "auto", }, { - title: '时间范围', - type: 'slot', - prop: 'dates', - width: '260px' + title: "时间范围", + type: "slot", + prop: "dates", + width: "260px", }, { - title: '操作', - prop: 'opearo', - name: 'opearo', - type: 'slot', - width: '120px' + title: "操作", + prop: "opearo", + name: "opearo", + type: "slot", + width: "120px", }, { - title: '发放key码总数', - name: 'grant', - type: 'normal', - prop: 'grant', - width: 'auto' + title: "发放key码总数", + name: "grant", + type: "normal", + prop: "grant", + width: "auto", }, { - title: '领取key总数', - name: 'receive', - type: 'normal', - prop: 'receive', - width: 'auto' + title: "领取key总数", + name: "receive", + type: "normal", + prop: "receive", + width: "auto", }, { - title: '使用key码总数', - name: 'usage', - type: 'normal', - prop: 'usage', - width: 'auto' + title: "使用key码总数", + name: "usage", + type: "normal", + prop: "usage", + width: "auto", }, { - title: '失效key码总数', - name: 'overdue', - type: 'normal', - prop: 'overdue', - width: 'auto' + title: "失效key码总数", + name: "overdue", + type: "normal", + prop: "overdue", + width: "auto", }, { - title: '作废key码总数', - name: 'invalid', - type: 'normal', - prop: 'invalid', - width: 'auto' + title: "作废key码总数", + name: "invalid", + type: "normal", + prop: "invalid", + width: "auto", }, { - title: '可用key码总数', - name: 'silent', - type: 'normal', - prop: 'silent', - width: 'auto' + title: "可用key码总数", + name: "silent", + type: "normal", + prop: "silent", + width: "auto", }, { - title: '完结key码总数', - name: 'end', - type: 'normal', - prop: 'end', - width: 'auto' + title: "完结key码总数", + name: "end", + type: "normal", + prop: "end", + width: "auto", }, { - title: '更新时间', - name: 'update_time', - type: 'normal', - prop: 'update_time', - width: '140px' - } + title: "更新时间", + name: "update_time", + type: "normal", + prop: "update_time", + width: "140px", + }, // { // title: "发放总价(预估)", // name: "grant_total", @@ -719,15 +744,16 @@ export default class acclist extends React.Component { // width: "auto", // valueType: "price", // }, - ] + ]; return ( -
+
-
+
{/* */} @@ -735,42 +761,44 @@ export default class acclist extends React.Component { onChange={(e) => this.setState({ key_word: e })} value={this.state.key_word} wordSearch={this.iptsureFn.bind(this)} - icon='search' - placeholder={'请输入营销计划名称、分销商名称查询'} + icon="search" + placeholder={"请输入营销计划名称、分销商名称查询"} countShow={false} - height={'36px'} - width={'260px'} + height={"36px"} + width={"260px"} onClearItem={(e) => { - this.setState({ key_word: '' }) + this.setState({ key_word: "" }); let data = { page: 1, - limit: 10 - } - this.getPlanList(data) + limit: 10, + }; + this.getPlanList(data); }} - alignment={'left'} + alignment={"left"} />
{ - this.onFilter(e, prop) + this.onFilter(e, prop); }} onClose={(e) => { - this.onFilterClose(e) - }}> + this.onFilterClose(e); + }} + >
{this.state.selectiondata.length > 0 ? ( + - }> + } + > 已选择 - + {this.state.selectiondata.length} 发放key总数:{this.state.grantTotal},领取key总数: @@ -782,113 +810,119 @@ export default class acclist extends React.Component { ) : null} { - this.onPageChange(e) + this.onPageChange(e); }} countChange={(e) => { - this.onCountChange(e) + this.onCountChange(e); }} checkChange={this.selection.bind(this)} ComponentHandler={(com, rowData) => { - if (com == 'dates') { + if (com == "dates") { return ( {rowData.begin_time} 至 {rowData.end_time} - ) + ); } - if (com == 'title') { + if (com == "title") { return ( { - this.linkTo(rowData) - }}> + this.linkTo(rowData); + }} + > {rowData.title} - ) + ); } - if (com == 'switch') { + if (com == "switch") { return ( { - this.onSwitchChange(e, rowData) - }}> - ) + this.onSwitchChange(e, rowData); + }} + > + ); } - if (com == 'status') { + if (com == "status") { return ( -

+

+ ), + }} + > {rowData.status_text}

- ) + ); } - if (com == 'opearo') { + if (com == "opearo") { let str = ( { - this.onEdit(e, rowData) - }}> + this.onEdit(e, rowData); + }} + > 编辑 { - this.onCopy(e, rowData) - }}> + this.onCopy(e, rowData); + }} + > 复制 -
{}}> - {' '} - 更多 {' '} +
{}}> + {" "} + 更多 {" "}
this.menuItemClick(e, key, rowData) - }> - 发送密码及压缩包 - + } + > + 发送密码及压缩包 + 日志 - + 作废 - ) + ); // if(rowData.status ==6 ||rowData.status == 0 ) // { @@ -912,51 +946,55 @@ export default class acclist extends React.Component { if (rowData.status == 0) { str = (
- {' '} + {" "} { - this.onEdit(e, rowData) - }}> + this.onEdit(e, rowData); + }} + > 编辑 { - this.onCopy(e, rowData) - }}> + this.onCopy(e, rowData); + }} + > 复制
{}}> - {' '} - 更多 {' '} + className="linkmore" + style={{ paddingLeft: "2px" }} + onClick={(e) => {}} + > + {" "} + 更多 {" "}
this.menuItemClick(e, key, rowData) - }> - 删除 + } + > + 删除
- ) + ); } if (rowData.status == 6) { str = (
- {' '} - + {" "} + 编辑
{}}> - {' '} - 更多 {' '} + className="linkmore" + style={{ paddingLeft: "2px", color: "#d8dbdd" }} + onClick={(e) => {}} + > + {" "} + 更多 {" "}
- ) + ); } - return str + return str; } }} /> {this.state.audit_visible ? (
-
-
+
+
{ - this.cancel(e) + this.cancel(e); }} /> -
发送
-
+
发送
+
是否立即发送key以及解压密码?
-
+
接收手机号
-
+
{ - this.onPhoneChange(e) - }}> + this.onPhoneChange(e); + }} + > {this.state.phone_list.map((item, index) => { return ( + }} + > {item} - ) + ); })}
-
+
接收邮箱
-
+
{ - this.onEmailChange(e) - }}> + this.onEmailChange(e); + }} + > {this.state.email_list.map((item, index) => { return ( + }} + > {item} - ) + ); })}
-
+
-1}> + disabled={this.state.phone_radio > -1} + >
-
+
-1}> + disabled={this.state.email_radio > -1} + >
-
+
@@ -1095,6 +1142,6 @@ export default class acclist extends React.Component {
- ) + ); } }