key 批次审核
This commit is contained in:
parent
f9c4b9f3a8
commit
623cf6b926
|
@ -137,8 +137,6 @@ const getData = (method, url, params, responseType) => {
|
|||
let http = fetch(url, obj).then((res) => {
|
||||
window.timeshow = res.headers.get("Date-Time");
|
||||
if (res.status == 200) {
|
||||
console.log("当前返回", res.body);
|
||||
|
||||
return res.text();
|
||||
} else {
|
||||
switch (res.status) {
|
||||
|
@ -219,8 +217,6 @@ const req = (method, url, params, responseType) => {
|
|||
let http = fetch(url, obj).then((res) => {
|
||||
window.timeshow = res.headers.get("Date-Time");
|
||||
if (res.status == 200) {
|
||||
console.log("当前返回", res.body);
|
||||
|
||||
return res.json();
|
||||
} else {
|
||||
switch (res.status) {
|
||||
|
|
|
@ -228,7 +228,6 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
|
|||
console.log("arr =>1", arr);
|
||||
// 1.2 优惠券管理判断是新增还是编辑
|
||||
if (editData && editData !== "") {
|
||||
setState({ isEdit: true });
|
||||
// 1.3 设置归属计划数据
|
||||
let plan_row = arr.find(
|
||||
(item) => item.text === editData.plan_title
|
||||
|
@ -275,6 +274,7 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
|
|||
|
||||
// 1.8 编辑
|
||||
if (isState && isState === "2") {
|
||||
setState({ isEdit: true });
|
||||
setState({
|
||||
oldProduct: editData.product,
|
||||
});
|
||||
|
@ -284,7 +284,6 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
|
|||
} else {
|
||||
// 1.3 计划的优惠券编辑
|
||||
if (editData && editData !== "") {
|
||||
setState({ isEdit: true });
|
||||
editFun();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -45,7 +45,9 @@ import "./edit.less";
|
|||
import moment from "moment";
|
||||
import { isSameDay } from "date-fns";
|
||||
import KnockGold from "@/components/knockGold";
|
||||
import UseCouponAddEdit from "@/components/UseCouponAddEdit"; // 优惠券
|
||||
import { divNum } from "@/tools/number"; /* 立减金 */
|
||||
|
||||
const TabPanel = Tabs.TabPanel;
|
||||
|
||||
const initArray = (targetNum) => {
|
||||
|
@ -80,7 +82,6 @@ export default class acclist extends React.Component {
|
|||
},
|
||||
drawerVisible: false,
|
||||
drawerVisible2: false,
|
||||
checkedList: [1],
|
||||
productData: [],
|
||||
codeInfo: {
|
||||
//数据模型不可少
|
||||
|
@ -114,6 +115,113 @@ export default class acclist extends React.Component {
|
|||
direct_reseller_id: 0,
|
||||
addIsType: "",
|
||||
newGoldLoading: false,
|
||||
keyType: 1,
|
||||
couponData: [],
|
||||
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",
|
||||
},
|
||||
],
|
||||
rowCouponData: "",
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -142,7 +250,6 @@ export default class acclist extends React.Component {
|
|||
if (req.status == 7) {
|
||||
this.setState({ isCancel: true });
|
||||
}
|
||||
|
||||
if (req.status == 1) {
|
||||
this.setState({ isEdit: false });
|
||||
} else {
|
||||
|
@ -155,28 +262,12 @@ export default class acclist extends React.Component {
|
|||
req.code_batch = req.code_batch ? req.code_batch : [];
|
||||
this.setState({ pagetitle: "编辑key" });
|
||||
|
||||
let temp = [];
|
||||
for (let i = 0; i < req.code_batch.length; i++) {
|
||||
let code_batch = req.code_batch[i];
|
||||
let range = [];
|
||||
for (let j = 0; j < code_batch.product.length; j++) {
|
||||
let product = code_batch.product[j];
|
||||
/* 区分立减金和商品 */
|
||||
if (product.type === 1) {
|
||||
range.push(product.entity.product_name);
|
||||
} else {
|
||||
range.push(product.entity.batch_goods_name);
|
||||
}
|
||||
}
|
||||
req.code_batch[i].disabled = true;
|
||||
req.code_batch[i].checked = true;
|
||||
req.code_batch[i].range = range.toString();
|
||||
temp.push(req.code_batch[i]);
|
||||
}
|
||||
//获取审批单信息
|
||||
if (approval_id > 0) {
|
||||
getApprovalsInfo(approval_id).then((res) => {
|
||||
handelResponse(res, (req, msg) => {
|
||||
console.log("req =>", req);
|
||||
return;
|
||||
/*当为创建中和审核驳回时 转换数据结构 */
|
||||
req.code_batch.map((item) => {
|
||||
const newProduct = [];
|
||||
|
@ -188,7 +279,6 @@ export default class acclist extends React.Component {
|
|||
...item1,
|
||||
});
|
||||
});
|
||||
|
||||
item.product.reduce.map((item1) => {
|
||||
newProduct.push({
|
||||
type: 2,
|
||||
|
@ -209,10 +299,14 @@ export default class acclist extends React.Component {
|
|||
...item1,
|
||||
});
|
||||
});
|
||||
|
||||
item.product = [...newProduct];
|
||||
});
|
||||
|
||||
if (req.payment_direction) {
|
||||
let index = this.state.payment_direction.indexOf(
|
||||
req.payment_direction
|
||||
);
|
||||
this.setState({ paytype: index + 1 });
|
||||
}
|
||||
for (let i = 0; i < req.code_batch.length; i++) {
|
||||
let code_batch = req.code_batch[i];
|
||||
let range = [];
|
||||
|
@ -223,13 +317,7 @@ export default class acclist extends React.Component {
|
|||
req.code_batch[i].disabled = false;
|
||||
req.code_batch[i].checked = false;
|
||||
req.code_batch[i].range = range.toString();
|
||||
temp.push(req.code_batch[i]);
|
||||
}
|
||||
if (req.payment_direction) {
|
||||
let index = this.state.payment_direction.indexOf(
|
||||
req.payment_direction
|
||||
);
|
||||
this.setState({ paytype: index + 1 });
|
||||
// temp.push(req.code_batch[i]);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
@ -243,15 +331,45 @@ export default class acclist extends React.Component {
|
|||
allow_loss: req.allow_loss,
|
||||
stock: req.stock,
|
||||
code_batch: req.code_batch,
|
||||
coupon: req.coupon,
|
||||
plan_title: req.plan_title,
|
||||
};
|
||||
this.setState({ checkedList: req.bind_object });
|
||||
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({ distdata: temp });
|
||||
this.setState({ mobile_excel: req.mobile_excel });
|
||||
this.setState({ mobile_repeat: req.mobile_repeat });
|
||||
|
||||
// 兑换码
|
||||
if (Number(req.bind_object[0]) === 1) {
|
||||
let temp = [];
|
||||
for (let i = 0; i < req.code_batch.length; i++) {
|
||||
let code_batch = req.code_batch[i];
|
||||
let range = [];
|
||||
for (let j = 0; j < code_batch.product.length; j++) {
|
||||
let product = code_batch.product[j];
|
||||
/* 区分立减金和商品 */
|
||||
if (product.type === 1) {
|
||||
range.push(product.entity.product_name);
|
||||
} else {
|
||||
range.push(product.entity.batch_goods_name);
|
||||
}
|
||||
}
|
||||
req.code_batch[i].disabled = true;
|
||||
req.code_batch[i].checked = true;
|
||||
req.code_batch[i].range = range.toString();
|
||||
temp.push(req.code_batch[i]);
|
||||
}
|
||||
this.setState({ distdata: temp });
|
||||
} else {
|
||||
let temp = _.map(req.coupon, (o) => {
|
||||
o.checked = true;
|
||||
o.disabled = true;
|
||||
return o;
|
||||
});
|
||||
this.setState({ couponData: temp });
|
||||
}
|
||||
},
|
||||
(err) => {}
|
||||
);
|
||||
|
@ -308,9 +426,8 @@ export default class acclist extends React.Component {
|
|||
parentComponent: this,
|
||||
});
|
||||
}
|
||||
onCheckChange = (arr) => {
|
||||
this.setState({ checkedList: arr });
|
||||
let checkedList = arr;
|
||||
onCheckChange = (e) => {
|
||||
this.setState({ keyType: e.target.value });
|
||||
};
|
||||
|
||||
onStyleChange(e) {
|
||||
|
@ -554,6 +671,28 @@ export default class acclist extends React.Component {
|
|||
}
|
||||
|
||||
codeSubmit() {
|
||||
// 优惠券数据
|
||||
if (this.state.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;
|
||||
|
@ -674,6 +813,8 @@ export default class acclist extends React.Component {
|
|||
}
|
||||
|
||||
onConfirm() {
|
||||
// 兑换码
|
||||
if (this.state.keyType === 1) {
|
||||
let selection = this.refs.bindObj.getSelectData();
|
||||
let formdata = selection.filter((item) => {
|
||||
return !item.hasOwnProperty("disabled") || item.disabled == false;
|
||||
|
@ -683,7 +824,6 @@ export default class acclist extends React.Component {
|
|||
dataCopy.map((item) => {
|
||||
item.products = item.product;
|
||||
});
|
||||
|
||||
dataCopy.map((item) =>
|
||||
item.products.map(() => {
|
||||
item.product = {
|
||||
|
@ -694,11 +834,9 @@ export default class acclist extends React.Component {
|
|||
};
|
||||
})
|
||||
);
|
||||
|
||||
dataCopy.map((item) => {
|
||||
delete item.products;
|
||||
});
|
||||
|
||||
//除了创建中 编辑key
|
||||
if (this.state.isEdit) {
|
||||
this.setState({ audit_visible: false });
|
||||
|
@ -786,7 +924,7 @@ export default class acclist extends React.Component {
|
|||
batch_name: this.state.model.batch_name,
|
||||
style: this.state.model.style,
|
||||
quantity: this.state.model.quantity,
|
||||
bind_object: this.state.checkedList,
|
||||
bind_object: this.state.keyType,
|
||||
allow_repetition: this.state.model.allow_repetition,
|
||||
allow_loss: this.state.model.allow_loss,
|
||||
merge_stock: this.state.model.merge_stock,
|
||||
|
@ -834,7 +972,7 @@ export default class acclist extends React.Component {
|
|||
batch_name: this.state.model.batch_name,
|
||||
style: this.state.model.style,
|
||||
quantity: this.state.model.quantity,
|
||||
bind_object: this.state.checkedList,
|
||||
bind_object: this.state.keyType,
|
||||
allow_repetition: this.state.model.allow_repetition,
|
||||
allow_loss: this.state.model.allow_loss,
|
||||
merge_stock: this.state.model.merge_stock,
|
||||
|
@ -845,7 +983,8 @@ export default class acclist extends React.Component {
|
|||
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],
|
||||
payment_direction:
|
||||
this.state.payment_direction[this.state.paytype - 1],
|
||||
};
|
||||
|
||||
let id = sessionStorage.getItem("keybatch_id");
|
||||
|
@ -910,15 +1049,44 @@ export default class acclist extends React.Component {
|
|||
});
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// 优惠券
|
||||
let coupon_data = this.state.couponData.filter((item) => !item.id);
|
||||
let param = {
|
||||
coupon: coupon_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],
|
||||
};
|
||||
let id = sessionStorage.getItem("keybatch_id");
|
||||
console.log("大提交 =>", param);
|
||||
keyEditApproval(id, param).then((res) => {
|
||||
handelResponse(
|
||||
res,
|
||||
(req, msg) => {
|
||||
Notify.success("成功发起审批");
|
||||
setTimeout(() => {
|
||||
window.history.back();
|
||||
}, 1000);
|
||||
},
|
||||
(err) => {
|
||||
Notify.error(err);
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
onBindNum(e, row) {
|
||||
let index = this.state.distdata.findIndex((o) => {
|
||||
return o == row;
|
||||
});
|
||||
|
||||
this.state.distdata[index].restrict = e.target.value;
|
||||
onBindNum(e, row, rowIndex) {
|
||||
if (this.state.keyType === 1) {
|
||||
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 });
|
||||
}
|
||||
}
|
||||
|
||||
onDisabledCombinedDate = (val) => {
|
||||
|
@ -961,6 +1129,8 @@ export default class acclist extends React.Component {
|
|||
}
|
||||
|
||||
rowItemClick(row, rowIndex) {
|
||||
// 编辑兑换码
|
||||
if (this.props.keyType === 1) {
|
||||
let codeInfo = {
|
||||
//数据模型不可少
|
||||
code_name: row.title,
|
||||
|
@ -970,16 +1140,13 @@ export default class acclist extends React.Component {
|
|||
range: row.range,
|
||||
restrict: row.restrict,
|
||||
};
|
||||
|
||||
this.setState({ codeInfo: codeInfo });
|
||||
|
||||
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,
|
||||
|
@ -994,6 +1161,14 @@ export default class acclist extends React.Component {
|
|||
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,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
onUpload = (file, report) => {
|
||||
|
@ -1252,6 +1427,15 @@ export default class acclist extends React.Component {
|
|||
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 <span>{arr}</span>;
|
||||
};
|
||||
|
||||
return (
|
||||
<div id="addkey" className="addkey">
|
||||
<Card
|
||||
|
@ -1298,23 +1482,20 @@ export default class acclist extends React.Component {
|
|||
</FormItem>
|
||||
|
||||
<FormItem labelname="绑定类型" prop="bind_object" id="bind_object">
|
||||
<Checkbox.Group
|
||||
value={this.state.checkedList}
|
||||
<Radio.Group
|
||||
value={this.state.keyType}
|
||||
disabled={this.state.isEdit}
|
||||
onChange={(e) => {
|
||||
this.onCheckChange(e);
|
||||
}}
|
||||
disabled={this.state.isEdit}
|
||||
>
|
||||
<Checkbox value={1}>兑换码</Checkbox>
|
||||
<Checkbox value={2} disabled>
|
||||
优惠券
|
||||
</Checkbox>
|
||||
{/* <Checkbox value={4} disabled>立减金</Checkbox> */}
|
||||
</Checkbox.Group>
|
||||
<Radio value={1}>兑换码</Radio>
|
||||
<Radio value={2}>优惠券</Radio>
|
||||
</Radio.Group>
|
||||
</FormItem>
|
||||
{this.state.checkedList.length > 0 ? (
|
||||
|
||||
<FormItem labelname="" prop="btn" required={false}>
|
||||
{this.state.checkedList.indexOf(1) > -1 ? (
|
||||
{this.state.keyType === 1 ? (
|
||||
<Button
|
||||
onClick={(e) => {
|
||||
this.checkIndex(0);
|
||||
|
@ -1322,17 +1503,33 @@ export default class acclist extends React.Component {
|
|||
>
|
||||
新建兑换码
|
||||
</Button>
|
||||
) : null}
|
||||
) : (
|
||||
<Button
|
||||
onClick={(e) => {
|
||||
this.checkIndex(1);
|
||||
}}
|
||||
>
|
||||
新建优惠券
|
||||
</Button>
|
||||
)}
|
||||
</FormItem>
|
||||
) : null}
|
||||
|
||||
<FormItem labelname="绑定对象" prop="grid">
|
||||
<Grid
|
||||
ref="bindObj"
|
||||
headBackgroud="#f9fafc"
|
||||
isShowPageBar={false}
|
||||
spliteColor={"#fff"}
|
||||
tableData={this.state.distdata}
|
||||
Column={Column}
|
||||
tableData={
|
||||
this.state.keyType === 1
|
||||
? this.state.distdata
|
||||
: this.state.couponData
|
||||
}
|
||||
Column={
|
||||
this.state.keyType === 1
|
||||
? this.state.Column
|
||||
: this.state.Column_coupon
|
||||
}
|
||||
countbarVisible={false}
|
||||
isBorder={true}
|
||||
isSwitch={false}
|
||||
|
@ -1347,12 +1544,16 @@ export default class acclist extends React.Component {
|
|||
placeholder="请输入数量"
|
||||
value={rowData.restrict}
|
||||
onChange={(e) => {
|
||||
this.onBindNum(e, rowData);
|
||||
this.onBindNum(e, rowData, rowIndex);
|
||||
}}
|
||||
disabled={rowData.disabled}
|
||||
/>
|
||||
);
|
||||
}
|
||||
// 优惠券范围
|
||||
if (com === "product" && this.state.keyType === 2) {
|
||||
return coupon_range(rowData.product);
|
||||
}
|
||||
if (com == "edit") {
|
||||
let str = (
|
||||
<span
|
||||
|
@ -1443,6 +1644,7 @@ export default class acclist extends React.Component {
|
|||
}}
|
||||
maskClosable={false}
|
||||
>
|
||||
{this.props.keyType === 1 ? (
|
||||
<div className="draw">
|
||||
<Card
|
||||
style={{ width: "95%", margin: "10px auto" }}
|
||||
|
@ -1627,7 +1829,9 @@ export default class acclist extends React.Component {
|
|||
}}
|
||||
ComponentHandler={(com, rowData, rowIndex) => {
|
||||
if (com == "type") {
|
||||
return <>{rowData.type === 2 ? "立减金" : "商品"}</>;
|
||||
return (
|
||||
<>{rowData.type === 2 ? "立减金" : "商品"}</>
|
||||
);
|
||||
}
|
||||
if (com == "cost_price") {
|
||||
return (
|
||||
|
@ -1657,6 +1861,15 @@ export default class acclist extends React.Component {
|
|||
</div>
|
||||
</Card>
|
||||
</div>
|
||||
) : (
|
||||
<UseCouponAddEdit
|
||||
couponType={1}
|
||||
editData={this.state.rowCouponData}
|
||||
isAuditButton={false}
|
||||
ref="addEditCouponEl"
|
||||
direct_reseller_id={this.state.direct_reseller_id}
|
||||
></UseCouponAddEdit>
|
||||
)}
|
||||
</Drawer>
|
||||
<Drawer
|
||||
className="draw"
|
||||
|
|
|
@ -225,6 +225,40 @@ export default class acclist extends React.Component {
|
|||
};
|
||||
}
|
||||
|
||||
// key 批次的处理
|
||||
keyFormat(data) {
|
||||
console.log("data =>", data);
|
||||
// 兑换码
|
||||
if (Number(data.bind_object[0]) === 1) {
|
||||
let temp = [];
|
||||
for (let i = 0; i < data.code_batch.length; i++) {
|
||||
let code_batch = data.code_batch[i];
|
||||
let range = [];
|
||||
for (let j = 0; j < code_batch.product.length; j++) {
|
||||
let product = code_batch.product[j];
|
||||
/* 区分立减金和商品 */
|
||||
if (product.type === 1) {
|
||||
range.push(product.entity.product_name);
|
||||
} else {
|
||||
range.push(product.entity.batch_goods_name);
|
||||
}
|
||||
}
|
||||
data.code_batch[i].disabled = true;
|
||||
data.code_batch[i].checked = true;
|
||||
data.code_batch[i].range = range.toString();
|
||||
temp.push(data.code_batch[i]);
|
||||
}
|
||||
this.setState({ distdata: temp });
|
||||
} else {
|
||||
let temp = _.map(data.coupon, (o) => {
|
||||
o.checked = true;
|
||||
o.disabled = true;
|
||||
return o;
|
||||
});
|
||||
this.setState({ couponData: temp });
|
||||
}
|
||||
}
|
||||
|
||||
componentDidMount(e) {
|
||||
sessionStorage.setItem("knockGoldData", "");
|
||||
let batch_id = sessionStorage.getItem("keybatch_id");
|
||||
|
@ -256,89 +290,9 @@ export default class acclist extends React.Component {
|
|||
this.setState({ isEdit: true });
|
||||
}
|
||||
this.setState({ key_status: req.status });
|
||||
|
||||
this.setState({ plan_id: req.plan_id });
|
||||
|
||||
req.code_batch = req.code_batch ? req.code_batch : [];
|
||||
this.setState({ pagetitle: "编辑key" });
|
||||
|
||||
let temp = [];
|
||||
for (let i = 0; i < req.code_batch.length; i++) {
|
||||
let code_batch = req.code_batch[i];
|
||||
let range = [];
|
||||
for (let j = 0; j < code_batch.product.length; j++) {
|
||||
let product = code_batch.product[j];
|
||||
/* 区分立减金和商品 */
|
||||
if (product.type === 1) {
|
||||
range.push(product.entity.product_name);
|
||||
} else {
|
||||
range.push(product.entity.batch_goods_name);
|
||||
}
|
||||
}
|
||||
req.code_batch[i].disabled = true;
|
||||
req.code_batch[i].checked = true;
|
||||
req.code_batch[i].range = range.toString();
|
||||
temp.push(req.code_batch[i]);
|
||||
}
|
||||
//获取审批单信息
|
||||
if (approval_id > 0) {
|
||||
getApprovalsInfo(approval_id).then((res) => {
|
||||
handelResponse(res, (req, msg) => {
|
||||
/*当为创建中和审核驳回时 转换数据结构 */
|
||||
req.code_batch.map((item) => {
|
||||
const newProduct = [];
|
||||
item.product.legal.map((item1) => {
|
||||
newProduct.push({
|
||||
type: 1,
|
||||
only: item1.product_id,
|
||||
upstream: "直连天下",
|
||||
...item1,
|
||||
});
|
||||
});
|
||||
item.product.reduce.map((item1) => {
|
||||
newProduct.push({
|
||||
type: 2,
|
||||
only: item1.channel_activity_id,
|
||||
upstream:
|
||||
String(item.channel) === "1" ? "支付宝" : "微信",
|
||||
origin: item1,
|
||||
product_name: item1.batch_goods_name,
|
||||
effectDate:
|
||||
item1.time_limit?.effect_time.start_time +
|
||||
" 至 " +
|
||||
item1.time_limit?.effect_time.end_time, //有效时间
|
||||
contract_price: item1.price, //单价
|
||||
official_price: item1.reduce_amount, //官方价
|
||||
quantity: parseInt(
|
||||
divNum(item1.all_budget, item1.reduce_amount)
|
||||
), //总库
|
||||
...item1,
|
||||
});
|
||||
});
|
||||
item.product = [...newProduct];
|
||||
});
|
||||
if (req.payment_direction) {
|
||||
let index = this.state.payment_direction.indexOf(
|
||||
req.payment_direction
|
||||
);
|
||||
this.setState({ paytype: index + 1 });
|
||||
}
|
||||
for (let i = 0; i < req.code_batch.length; i++) {
|
||||
let code_batch = req.code_batch[i];
|
||||
let range = [];
|
||||
for (let j = 0; j < code_batch.product.length; j++) {
|
||||
let product = code_batch.product[j];
|
||||
range.push(product.product_name);
|
||||
}
|
||||
req.code_batch[i].disabled = false;
|
||||
req.code_batch[i].checked = false;
|
||||
req.code_batch[i].range = range.toString();
|
||||
temp.push(req.code_batch[i]);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
let model = {
|
||||
style: req.style,
|
||||
batch_name: req.batch_name,
|
||||
|
@ -357,16 +311,16 @@ export default class acclist extends React.Component {
|
|||
this.setState({ mobile_excel: req.mobile_excel });
|
||||
this.setState({ mobile_repeat: req.mobile_repeat });
|
||||
|
||||
// 兑换码
|
||||
if (req.bind_object[0] === 1) {
|
||||
this.setState({ distdata: temp });
|
||||
} else {
|
||||
let temp = _.map(req.coupon, (o) => {
|
||||
o.checked = true;
|
||||
o.disabled = true;
|
||||
return o;
|
||||
// 如果有审批单的数据
|
||||
if (approval_id > 0) {
|
||||
console.log("获取审批单数据");
|
||||
getApprovalsInfo(approval_id).then((res) => {
|
||||
handelResponse(res, (appReq, msg) => {
|
||||
this.keyFormat(appReq);
|
||||
});
|
||||
this.setState({ couponData: temp });
|
||||
});
|
||||
} else {
|
||||
this.keyFormat(req);
|
||||
}
|
||||
},
|
||||
(err) => {}
|
||||
|
|
|
@ -307,8 +307,9 @@ export default class acclist extends React.Component {
|
|||
res,
|
||||
(req, msg) => {
|
||||
console.log("req =>", req);
|
||||
if (req.data.length > 0) {
|
||||
sessionStorage.setItem("isKeyAdd", req.data[0].bind_object[0]);
|
||||
|
||||
}
|
||||
const newData = req.data.map((item) => {
|
||||
if (![4, 5].includes(item.status)) {
|
||||
item.disabled = true;
|
||||
|
@ -524,7 +525,6 @@ export default class acclist extends React.Component {
|
|||
});
|
||||
}
|
||||
onEditRow(status, row) {
|
||||
this.props.history.push("/home/key-edit");
|
||||
sessionStorage.setItem("pathname2", "/home/key-edit");
|
||||
let activerou = [
|
||||
{
|
||||
|
@ -549,6 +549,7 @@ export default class acclist extends React.Component {
|
|||
sessionStorage.setItem("keybatch_id", row.id);
|
||||
sessionStorage.setItem("key_reseller_id", row.reseller_id);
|
||||
sessionStorage.setItem("approval_id", row.approval_id);
|
||||
this.props.history.push("/home/key-edit");
|
||||
}
|
||||
|
||||
//敲回车查询
|
||||
|
@ -901,6 +902,7 @@ export default class acclist extends React.Component {
|
|||
str = (
|
||||
<span>
|
||||
<a className="grid-link disabled">编辑</a>
|
||||
|
||||
{[1, 2, 8].includes(rowData.status) ||
|
||||
[2, 6, 8, 7].includes(this.state.planStatus) ? (
|
||||
<a className="grid-link disabled">复制</a>
|
||||
|
|
Loading…
Reference in New Issue