修复 营销计划编辑

This commit is contained in:
wangsongsole 2022-06-02 18:19:06 +08:00
parent be3e067e79
commit 5e17abf86d
3 changed files with 68 additions and 59 deletions

View File

@ -217,20 +217,23 @@ export default class add extends React.Component {
item2.upstream = '直连天下'
item1.products.push(item2)
})
item1.product.reduce.map((item3) => {
item3.product_name = item3.batch_goods_name //名字
item3.channel_activity_id = item3.channel_activity_id //批次号
item3.only = item3.channel_activity_id
item3.type = 2 //类型
item3.upstream = item3.channel === '1' ? '支付宝' : '微信' //上游
item3.effectDate =
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 = item3.channel === '1' ? '支付宝' : '微信' //上游
obj.effectDate =
item3.time_limit.effect_time.start_time +
' 至 ' +
item3.time_limit.effect_time.end_time //有效时间
item3.contract_price = item3.price //单价
item3.official_price = item3.denomination //官方价
item3.quantity = (item3.all_budget / item3.denomination).toFixed(0) //总库存
item1.products.push(item3)
obj.contract_price = item3.price //单价
obj.official_price = item3.denomination //官方价
obj.quantity = (item3.all_budget / item3.denomination).toFixed(0) //总库存
obj.origin = item3
item1.products.push(obj)
})
})
})

View File

@ -343,6 +343,7 @@ export default class acclist extends React.Component {
data = JSON.parse(sessionStorage.getItem('knockGoldData')).filter(
(item) => item.type !== 1
)
temp = _.map(data, (item) => {
let index = this.state.tempdata.findIndex((o) => {
return o.channel_activity_id === item.channel_activity_id
@ -354,21 +355,32 @@ export default class acclist extends React.Component {
/* 转换商品结构 */
// temp
return {
product_name: item.batch_goods_name, //名字
channel_activity_id: item.channel_activity_id, //批次号
only: item.channel_activity_id,
type: 2, //类型
upstream: item.channel === '1' ? '支付宝' : '微信', //上游
effectDate:
item.time_limit.effect_time.start_time +
const newObj = {}
newObj.product_name = item.batch_goods_name
? item.batch_goods_name
: item.product_name //名字
newObj.channel_activity_id = item.channel_activity_id //批次号
newObj.only = item.channel_activity_id //批次号
newObj.type = 2 //类型
newObj.checked = item?.checked
newObj.upstream = 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, //有效时间
contract_price: item.price, //单价
official_price: item.denomination, //官方价
quantity: (item.all_budget / item.denomination).toFixed(0), //总库存
edit: 'edit'
}
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.denomination //官方价
newObj.quantity = item.quantity
? item.quantity
: (item.all_budget / item.denomination).toFixed(0) //总库
newObj.origin = item?.origin ? item?.origin : item
return newObj
})
//select数据
@ -443,7 +455,6 @@ export default class acclist extends React.Component {
Notify.error('还有图片上传中,不可提交')
return
}
let productList = JSON.parse(sessionStorage.getItem('productsList'))
this.setState({ drawerVisible: false })
let rank = _.map(this.state.rank, (item) => {
@ -476,6 +487,7 @@ export default class acclist extends React.Component {
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.type = item.type
@ -555,6 +567,7 @@ export default class acclist extends React.Component {
}
edit(data) {
debugger
let model = {
//数据模型不可少
batch_name: data.batch_name,
@ -709,6 +722,7 @@ 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 })
}
@ -834,6 +848,7 @@ export default class acclist extends React.Component {
}
/* 商品范围列表编辑 */
productEditShow(rowData) {
debugger
console.log('rowData 12==>', rowData)
if (this.props.direct_reseller_id > 0) {
this.setState({
@ -844,18 +859,9 @@ export default class acclist extends React.Component {
sessionStorage.setItem('productsList', JSON.stringify(data))
/* 区分立减金 */
if (rowData.type === 2) {
let editData = ''
if (sessionStorage.getItem('knockGoldData')) {
const temp = JSON.parse(sessionStorage.getItem('knockGoldData'))
editData = temp.filter(
(item) =>
item.channel_activity_id === rowData.channel_activity_id
)
}
this.setState({
product_title: '编辑立减金',
productData: editData[0] ? editData[0] : rowData.origin,
productData: rowData.origin,
addIsType: 'addKnockGold'
})
} else {

View File

@ -127,6 +127,7 @@ export default class addKnockGold extends Component {
/* 编辑回显 */
echoFun(UserSelectList) {
console.log(this.props.data)
if (this.props.data) {
let model = this.state.model
for (let key in this.props.data) {
@ -275,31 +276,30 @@ export default class addKnockGold extends Component {
let temp = []
if (sessionStorage.getItem('knockGoldData')) {
temp = JSON.parse(sessionStorage.getItem('knockGoldData'))
let index = temp.findIndex((item) => {
return (
item.channel_activity_id === this.props.data.channel_activity_id
)
})
/* 校验表单 */
if (this.limitFunction() === false) {
return false
}
/* 兼容老数据 */
if (this.props.data?.goods_id) {
temp[index] = Object.assign({
...this.state.model.origin,
...this.transformDataCode()
})
} else {
/* 新增编辑 */
temp[index] = this.transformDataCode()
}
sessionStorage.setItem('knockGoldData', JSON.stringify(temp))
return true
}
let index = temp.findIndex((item) => {
return (
item.channel_activity_id === this.props.data.channel_activity_id
)
})
/* 校验表单 */
if (this.limitFunction() === false) {
return false
}
/* 兼容老数据 */
if (this.props.data?.goods_id) {
temp[index] = Object.assign({
...this.state.model.origin,
...this.transformDataCode()
})
} else {
/* 新增编辑 */
temp[index] = this.transformDataCode()
}
sessionStorage.setItem('knockGoldData', JSON.stringify(temp))
return true
} else {
/* 校验表单 */
if (this.limitFunction() === false) {