🎈 per: 优化兑换码编辑、新增、复制代码

This commit is contained in:
wangsongsole 2023-06-01 14:04:27 +08:00
parent 7b0e2f2fb8
commit e6a32a6e24
1 changed files with 14 additions and 19 deletions

View File

@ -221,10 +221,6 @@ export default class exchangeAdd extends React.Component {
rank: checkedArray, rank: checkedArray,
rankoptions: arr rankoptions: arr
}); });
this.storage(reqCopy.goods, 1, 'productData');
this.storage(reqCopy.goods, 2, 'knockGoldData');
this.storage(reqCopy.goods, 3, 'redPacketsData');
}, },
(err) => {} (err) => {}
); );
@ -232,18 +228,6 @@ export default class exchangeAdd extends React.Component {
.catch((err) => {}); .catch((err) => {});
} }
/* 分类缓存到本地 */
storage(data = [], type, key) {
const filterData = data
.map((item) => {
if (item.type === type) {
return item.origin || item;
}
})
.filter((item) => item);
sessionStorage.setItem(key, JSON.stringify(filterData));
}
/* 获取直连天下商品数据 */ /* 获取直连天下商品数据 */
getProductInfoSelectData(reseller_id) { getProductInfoSelectData(reseller_id) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
@ -280,6 +264,9 @@ export default class exchangeAdd extends React.Component {
/* 编辑/复制转换数据 */ /* 编辑/复制转换数据 */
transFormData(req) { transFormData(req) {
const newData = []; const newData = [];
const legal = [];
const reduce = [];
const cash = [];
req.legal.map((item) => { req.legal.map((item) => {
item.type = 1; item.type = 1;
item.only = item.product_id; item.only = item.product_id;
@ -296,6 +283,7 @@ export default class exchangeAdd extends React.Component {
item = omit(item, ['code_batch_id']); item = omit(item, ['code_batch_id']);
} }
newData.push(item); newData.push(item);
legal.push(item);
}); });
/* 立减金 */ /* 立减金 */
@ -329,6 +317,7 @@ export default class exchangeAdd extends React.Component {
data = omit(data, exclude); data = omit(data, exclude);
} }
newData.push(data); newData.push(data);
reduce.push(data.origin);
}); });
/* 红包 */ /* 红包 */
@ -349,7 +338,9 @@ export default class exchangeAdd extends React.Component {
'total_stock', 'total_stock',
'use_stock', 'use_stock',
'stock', 'stock',
'goods_id' 'goods_id',
'update_time',
'delete_time'
]); ]);
data = omit(data, ['product_id']); data = omit(data, ['product_id']);
} }
@ -362,7 +353,13 @@ export default class exchangeAdd extends React.Component {
data = omit(data, exclude); data = omit(data, exclude);
} }
newData.push(data); newData.push(data);
cash.push(data.origin);
}); });
/* 暂存到本地 */
sessionStorage.setItem('productData', JSON.stringify(legal));
sessionStorage.setItem('knockGoldData', JSON.stringify(reduce));
sessionStorage.setItem('redPacketsData', JSON.stringify(cash));
return newData; return newData;
} }
@ -803,9 +800,7 @@ export default class exchangeAdd extends React.Component {
/* 处理商品 */ /* 处理商品 */
if (this.state.addIsType === 'addProduct') { if (this.state.addIsType === 'addProduct') {
data = JSON.parse(sessionStorage.getItem('productData')); data = JSON.parse(sessionStorage.getItem('productData'));
concatData = this.state.tempdata.filter((item) => item.type !== 1); concatData = this.state.tempdata.filter((item) => item.type !== 1);
temp = map(data, (item) => { temp = map(data, (item) => {
let index = this.state.tempdata.findIndex((o) => { let index = this.state.tempdata.findIndex((o) => {
return o.product_id == item.product_id; return o.product_id == item.product_id;