修复 营销计划编辑

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

View File

@ -127,6 +127,7 @@ export default class addKnockGold extends Component {
/* 编辑回显 */ /* 编辑回显 */
echoFun(UserSelectList) { echoFun(UserSelectList) {
console.log(this.props.data)
if (this.props.data) { if (this.props.data) {
let model = this.state.model let model = this.state.model
for (let key in this.props.data) { for (let key in this.props.data) {
@ -275,31 +276,30 @@ export default class addKnockGold extends Component {
let temp = [] let temp = []
if (sessionStorage.getItem('knockGoldData')) { if (sessionStorage.getItem('knockGoldData')) {
temp = JSON.parse(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 { } else {
/* 校验表单 */ /* 校验表单 */
if (this.limitFunction() === false) { if (this.limitFunction() === false) {