key码编辑完成

This commit is contained in:
wangsongsole 2022-05-31 16:49:52 +08:00
parent bf4f94714b
commit 08ff0e7c3c
1 changed files with 89 additions and 16 deletions

View File

@ -1,6 +1,7 @@
/*此页面 创建中 进行中 审核驳回可编辑 */
import React from 'react' import React from 'react'
import { deWeightThree } from '../../../utils' import { deWeightThree } from '../../../utils'
import { import {
Radio, Radio,
Card, Card,
@ -149,15 +150,37 @@ export default class acclist extends React.Component {
this.setState({ plan_id: req.plan_id }) this.setState({ plan_id: req.plan_id })
this.setState({ pagetitle: '编辑key' })
req.code_batch = req.code_batch ? req.code_batch : [] req.code_batch = req.code_batch ? req.code_batch : []
this.setState({ pagetitle: '编辑key' })
/* 转换数据结构 */
// req.code_batch.map((item) => {
// item.product?.legal?.map((item1) => {
// item1.type = 1
// item1.only = item1.product_id
// item1.upstream = '直连天下'
// })
// item.product?.reduce?.map((item1) => {
// item1.type = 2
// item1.only = item1.channel_activity_id
// item1.upstream = item.channel === '1' ? '支付宝' : '微信' //上游
// item1.origin = item1
// })
// item.product = [...item.product?.legal, ...item.product?.reduce]
// })
let temp = [] let temp = []
for (let i = 0; i < req.code_batch.length; i++) { for (let i = 0; i < req.code_batch.length; i++) {
let code_batch = req.code_batch[i] let code_batch = req.code_batch[i]
let range = [] let range = []
for (let j = 0; j < code_batch.product.length; j++) { for (let j = 0; j < code_batch.product.length; j++) {
let product = code_batch.product[j] let product = code_batch.product[j]
/* 区分立减金和商品 */
if (product.type === 1) {
range.push(product.product_name) range.push(product.product_name)
} else {
range.push(product.channel)
}
} }
req.code_batch[i].disabled = true req.code_batch[i].disabled = true
req.code_batch[i].checked = true req.code_batch[i].checked = true
@ -168,12 +191,36 @@ export default class acclist extends React.Component {
if (approval_id > 0) { if (approval_id > 0) {
getApprovalsInfo(approval_id).then((res) => { getApprovalsInfo(approval_id).then((res) => {
handelResponse(res, (req, msg) => { handelResponse(res, (req, msg) => {
/*当为创建中和审核驳回时 转换数据结构 */
req.code_batch.map((item) => {
item.product.legal.map((item1) => {
item1.type = 1
item1.only = item1.product_id
item1.upstream = '直连天下'
})
item.product.reduce.map((item1) => {
item1.type = 2
item1.only = item1.channel_activity_id
item1.upstream = item.channel === '1' ? '支付宝' : '微信' //上游
item1.origin = item1
})
item.product = [
...item.product.legal,
...item.product.reduce
]
})
for (let i = 0; i < req.code_batch.length; i++) { for (let i = 0; i < req.code_batch.length; i++) {
let code_batch = req.code_batch[i] let code_batch = req.code_batch[i]
let range = [] let range = []
for (let j = 0; j < code_batch.product.length; j++) { for (let j = 0; j < code_batch.product.length; j++) {
let product = code_batch.product[j] let product = code_batch.product[j]
/* 区分立减金和商品 */
if (product.type === 1) {
range.push(product.product_name) range.push(product.product_name)
} else {
range.push(product.channel)
}
} }
req.code_batch[i].disabled = false req.code_batch[i].disabled = false
req.code_batch[i].checked = false req.code_batch[i].checked = false
@ -443,7 +490,8 @@ export default class acclist extends React.Component {
contract_price: item.price, //单价 contract_price: item.price, //单价
official_price: item.denomination, //官方价 official_price: item.denomination, //官方价
quantity: (item.all_budget / item.denomination).toFixed(0), //总库存 quantity: (item.all_budget / item.denomination).toFixed(0), //总库存
edit: 'edit' edit: 'edit',
origin: item
} }
}) })
@ -559,6 +607,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
@ -628,6 +677,29 @@ export default class acclist extends React.Component {
let formdata = selection.filter((item) => { let formdata = selection.filter((item) => {
return !item.hasOwnProperty('disabled') || item.disabled == false return !item.hasOwnProperty('disabled') || item.disabled == false
}) })
// 转换数据
let dataCopy = _.cloneDeep(formdata)
dataCopy.map((item) => {
item.products = item.product
})
dataCopy.map((item) =>
item.products.map(() => {
item.product = {
legal: item.products.filter((item2) => item2.type === 1),
reduce: item.products
.filter((item3) => item3.type === 2)
.map((item4) => item4.origin)
}
})
)
dataCopy.map((item) => {
delete item.products
})
//除了创建中 编辑key
if (this.state.isEdit) { if (this.state.isEdit) {
this.setState({ audit_visible: false }) this.setState({ audit_visible: false })
let approval_id = sessionStorage.getItem('approval_id') let approval_id = sessionStorage.getItem('approval_id')
@ -644,7 +716,7 @@ export default class acclist extends React.Component {
} }
if (req.status == 2 || req.status == 3) { if (req.status == 2 || req.status == 3) {
let selection = this.refs.bindObj.getSelectData() let selection = this.refs.bindObj.getSelectData()
let formdata = selection.filter((item) => { let dataCopy = selection.filter((item) => {
return ( return (
!item.hasOwnProperty('disabled') || item.disabled == false !item.hasOwnProperty('disabled') || item.disabled == false
) )
@ -652,7 +724,7 @@ export default class acclist extends React.Component {
let id = sessionStorage.getItem('keybatch_id') let id = sessionStorage.getItem('keybatch_id')
let data = { let data = {
code_batch: formdata, code_batch: dataCopy,
reseller_id: this.state.reseller.id, reseller_id: this.state.reseller.id,
reseller_name: this.state.reseller.name, reseller_name: this.state.reseller.name,
company_name: this.state.reseller.company_name, company_name: this.state.reseller.company_name,
@ -686,7 +758,7 @@ export default class acclist extends React.Component {
if (this.state.key_status != 1) { if (this.state.key_status != 1) {
let id = sessionStorage.getItem('keybatch_id') let id = sessionStorage.getItem('keybatch_id')
let data = { let data = {
code_batch: formdata, code_batch: dataCopy,
reseller_id: this.state.reseller.id, reseller_id: this.state.reseller.id,
reseller_name: this.state.reseller.name, reseller_name: this.state.reseller.name,
company_name: this.state.reseller.company_name, company_name: this.state.reseller.company_name,
@ -720,7 +792,7 @@ export default class acclist extends React.Component {
merge_stock: this.state.model.merge_stock, merge_stock: this.state.model.merge_stock,
mobile_excel: this.state.mobile_excel, mobile_excel: this.state.mobile_excel,
mobile_repeat: this.state.mobile_repeat, mobile_repeat: this.state.mobile_repeat,
code_batch: formdata, code_batch: dataCopy,
reseller_id: this.state.reseller.id, reseller_id: this.state.reseller.id,
reseller_name: this.state.reseller.name, reseller_name: this.state.reseller.name,
company_name: this.state.reseller.company_name, company_name: this.state.reseller.company_name,
@ -781,6 +853,7 @@ export default class acclist extends React.Component {
// }) // })
} }
} else { } else {
//创建中 编辑key
let data = { let data = {
batch_name: this.state.model.batch_name, batch_name: this.state.model.batch_name,
style: this.state.model.style, style: this.state.model.style,
@ -791,7 +864,7 @@ export default class acclist extends React.Component {
merge_stock: this.state.model.merge_stock, merge_stock: this.state.model.merge_stock,
mobile_excel: this.state.mobile_excel, mobile_excel: this.state.mobile_excel,
mobile_repeat: this.state.mobile_repeat, mobile_repeat: this.state.mobile_repeat,
code_batch: formdata, code_batch: dataCopy,
reseller_id: this.state.reseller.id, reseller_id: this.state.reseller.id,
reseller_name: this.state.reseller.name, reseller_name: this.state.reseller.name,
company_name: this.state.reseller.company_name, company_name: this.state.reseller.company_name,
@ -943,6 +1016,7 @@ export default class acclist extends React.Component {
} }
rowItemClick(row, rowIndex) { rowItemClick(row, rowIndex) {
debugger
let codeInfo = { let codeInfo = {
//数据模型不可少 //数据模型不可少
code_name: row.title, code_name: row.title,
@ -1060,14 +1134,13 @@ export default class acclist extends React.Component {
if (this.state.direct_reseller_id > 0) { if (this.state.direct_reseller_id > 0) {
/* 区分立减金 */ /* 区分立减金 */
if (row.type === 2) { if (row.type === 2) {
const temp = JSON.parse(sessionStorage.getItem('knockGoldData')) // const temp = JSON.parse(sessionStorage.getItem('knockGoldData'))
const editData = temp.filter( // const editData = temp.filter(
(item) => item.channel_activity_id === row.only // (item) => item.channel_activity_id === row.only
) // )
this.setState({ this.setState({
product_title: '编辑立减金', product_title: '编辑立减金',
productData: editData[0], productData: row.origin,
addIsType: 'addKnockGold', addIsType: 'addKnockGold',
drawerVisible2: true drawerVisible2: true
}) })