1、修正立减金组件 金额长度限制和验证

2、修正新建营销计划bug
3、修正编辑营销计划草稿bug
4、修正新建key的bug
5、修正编辑key的bug
6、修正编辑兑换码中的bug
This commit is contained in:
wangsongsole 2022-06-09 14:29:18 +08:00
parent b2e299cb5e
commit cd13f1486d
6 changed files with 143 additions and 229 deletions

View File

@ -410,6 +410,14 @@ export default class addKnockGold extends Component {
return false
}
if (
!/^[0-9]*$/.test(this.state.model.denomination) ||
!/^[0-9]*$/.test(this.state.model.reduce_amount)
) {
Notify.error('请输入正确的面额金额或立减金额')
return false
}
if (
this.state.model.denomination - 0 <
this.state.model.reduce_amount - 0
@ -559,7 +567,6 @@ export default class addKnockGold extends Component {
maxLength={7}
height={'36px'}
disabled={this.props?.data?.id ? true : false}
kind='number'
width={'520px'}
unit='元'
countShow={false}
@ -583,9 +590,8 @@ export default class addKnockGold extends Component {
unit='元'
countShow={false}
labelWidth={'0px'}
maxLength={7}
maxLength={9}
height={'36px'}
kind='number'
width={'520px'}
alignment={'left'}
/>
@ -617,11 +623,10 @@ export default class addKnockGold extends Component {
unit='元'
disabled={this.props?.data?.id ? true : false}
countShow={false}
maxLength={14}
maxLength={4}
height={'36px'}
width={'231px'}
alignment={'left'}
kind='number'
/>
<span className='JIan'></span>
<Ipt
@ -637,11 +642,10 @@ export default class addKnockGold extends Component {
unit='元'
disabled={this.props?.data?.id ? true : false}
countShow={false}
maxLength={14}
maxLength={4}
height={'36px'}
width={'231px'}
alignment={'left'}
kind='number'
/>
</FormItem>
<FormItem id='all_budget' labelname='总预算' prop='all_budget'>
@ -654,10 +658,9 @@ export default class addKnockGold extends Component {
}}
value={this.state.model.all_budget}
placeholder={'请输入'}
kind='number'
disabled={this.props?.data?.id ? true : false}
labelWidth={'0px'}
maxLength={14}
maxLength={9}
height={'36px'}
unit='元'
countShow={false}
@ -681,13 +684,12 @@ export default class addKnockGold extends Component {
value={this.state.model.day_budget}
placeholder={'请输入'}
labelWidth={'0px'}
maxLength={14}
maxLength={9}
height={'36px'}
unit='元'
countShow={false}
width={'520px'}
alignment={'left'}
kind='number'
/>
</FormItem>
<FormItem
@ -705,13 +707,12 @@ export default class addKnockGold extends Component {
value={this.state.model.receive_number}
placeholder={'请输入'}
labelWidth={'0px'}
maxLength={3}
maxLength={4}
height={'36px'}
unit='个'
countShow={false}
width={'520px'}
alignment={'left'}
kind='number'
/>
<RadioGroup
disabled={this.props?.data?.id ? true : false}
@ -884,8 +885,7 @@ export default class addKnockGold extends Component {
value={this.state.model.effect_date}
placeholder={'请输入'}
labelWidth={'0px'}
maxLength={16}
kind='number'
maxLength={3}
height={'36px'}
unit='天'
countShow={false}
@ -971,11 +971,10 @@ export default class addKnockGold extends Component {
this.filterEarlyPer()
this.setState({ input_early_per: '' })
}}
kind='number'
value={this.state.input_early_per}
placeholder={''}
labelWidth={'0px'}
maxLength={16}
maxLength={3}
height={'36px'}
unit='%'
countShow={false}

View File

@ -425,18 +425,6 @@ export default class acclist extends React.Component {
item.upstream = '直连天下'
return item
})
//select数据
let arr = []
_.map(temp.concat(this.state.tempdata), (res) => {
let obj = {}
obj.key = res.only
obj.text = res.product_name
arr.push(obj)
return obj
})
arr = deWeightThree(arr, 'key')
this.setState({ rankoptions: arr })
} else {
/* 处理立减金 */
data = JSON.parse(sessionStorage.getItem('knockGoldData')).filter(
@ -444,7 +432,7 @@ export default class acclist extends React.Component {
)
temp = _.map(data, (item) => {
let index = this.state.tempdata.findIndex((o) => {
return o.channel_activity_id === item.only
return o.channel_activity_id === item.channel_activity_id
})
if (index > -1) {
@ -453,38 +441,50 @@ 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.map_product_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数据
let arr = []
_.map(temp.concat(this.state.tempdata), (res) => {
let obj = {}
obj.key = res.only
obj.text = res.product_name
arr.push(obj)
return obj
})
arr = deWeightThree(arr, 'key')
this.setState({ rankoptions: arr })
}
let newArray = temp.concat(this.state.tempdata)
newArray = deWeightThree(newArray, 'only')
this.setState({ tempdata: newArray })
//select数据
let arr = []
let rank = []
_.map(newArray, (res) => {
arr.push({ key: res.only, text: res.product_name })
if (res.checked) {
rank.push({ key: res.only, text: res.product_name })
}
})
arr = deWeightThree(arr, 'key')
this.setState({ tempdata: newArray, rankoptions: arr, rank })
}, 500)
}
}
@ -559,6 +559,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
@ -625,10 +626,6 @@ export default class acclist extends React.Component {
} else {
if (this.refs.form1.validator()) {
/* 处理数据 区分立减金和商品 开始 2022-05-30 13:40*/
let reduce = []
if (sessionStorage.getItem('knockGoldData')) {
reduce = JSON.parse(sessionStorage.getItem('knockGoldData'))
}
const dataCopy = this.refs.bindObj.getSelectData()
dataCopy.map((item) => {
@ -640,16 +637,10 @@ export default class acclist extends React.Component {
item.product = {
legal: item.products.filter((item2) => item2.type === 1),
reduce: item.products
.filter((item3) => item3.type === 2)
.map(
(item4) =>
reduce
.map((item5) => {
if (item4.only === item5.channel_activity_id)
return item5
})
.filter((item6) => item6)[0]
)
.map((item2) => {
if (item2.type === 2) return item2.origin
})
.filter((item3) => item3)
}
})
)
@ -768,7 +759,7 @@ export default class acclist extends React.Component {
})
sessionStorage.setItem('productData', JSON.stringify(row.product))
sessionStorage.setItem('knockGoldData', JSON.stringify(row.product))
this.setState({ drawerVisible: true, tempdata: temp })
}
@ -1032,14 +1023,9 @@ export default class acclist extends React.Component {
if (this.state.direct_reseller_id > 0) {
/* 区分立减金 */
if (row.type === 2) {
const temp = JSON.parse(sessionStorage.getItem('knockGoldData'))
const editData = temp.filter(
(item) => item.channel_activity_id === row.only
)
this.setState({
product_title: '编辑立减金',
productData: editData[0],
productData: row.origin,
addIsType: 'addKnockGold',
drawerVisible2: true
})

View File

@ -656,7 +656,6 @@ export default class exchangedit extends React.Component {
//渲染范围列表数据以及数据转换
async productSubmit() {
// sessionStorage.setItem('knockGoldData', '')
let visible = ''
if (this.state.addIsType === 'addProduct') {
visible = await this.refs.product.submit()
@ -687,18 +686,6 @@ export default class exchangedit extends React.Component {
item.upstream = '直连天下'
return item
})
//select数据
let arr = []
_.map(temp.concat(this.state.tempdata), (res) => {
let obj = {}
obj.key = res.only
obj.text = res.product_name
arr.push(obj)
return obj
})
arr = deWeightThree(arr, 'key')
this.setState({ rankoptions: arr })
} else {
/* 处理立减金 */
data = JSON.parse(sessionStorage.getItem('knockGoldData')).filter(
@ -743,22 +730,23 @@ export default class exchangedit extends React.Component {
newObj.id = item.goods_id ? item.goods_id : item.id
return newObj
})
//select数据
let arr = []
_.map(temp.concat(this.state.tempdata), (res) => {
let obj = {}
obj.key = res.only
obj.text = res.product_name
arr.push(obj)
return obj
})
arr = deWeightThree(arr, 'key')
this.setState({ rankoptions: arr })
}
let newArray = temp.concat(this.state.tempdata)
newArray = deWeightThree(newArray, 'only')
this.setState({ tempdata: newArray })
//select数据
let arr = []
let rank = []
_.map(newArray, (res) => {
arr.push({ key: res.only, text: res.product_name })
if (res.checked) {
rank.push({ key: res.only, text: res.product_name })
}
})
arr = deWeightThree(arr, 'key')
this.setState({ tempdata: newArray, rankoptions: arr, rank })
}, 500)
}
}

View File

@ -88,7 +88,6 @@ export default class add extends React.Component {
componentDidMount(e) {
sessionStorage.setItem('white', 3)
sessionStorage.setItem('plan_id', '')
sessionStorage.setItem('knockGoldData', '')
}
onConfirm(e) {

View File

@ -31,7 +31,7 @@ import {
} from '../../../assets/api.js'
import Productform from '../product/add' /* 商品 */
import KnockGold from '@/components/knockGold' /* 立减金 */
import KnockGold from '../../../components/knockGold' /* 立减金 */
import Bus from '../../../assets/eventBus.js'
import _ from 'lodash'
import moment from 'moment'
@ -124,11 +124,6 @@ export default class acclist extends React.Component {
let valide = false
if (this.refs.form1.validator()) {
/* 处理数据 区分立减金和商品 开始 2022-05-30 13:40*/
let reduce = []
if (sessionStorage.getItem('knockGoldData')) {
reduce = JSON.parse(sessionStorage.getItem('knockGoldData'))
}
const dataCopy = this.refs.tempdata.getSelectData()
dataCopy.map((item) => {
@ -140,15 +135,10 @@ export default class acclist extends React.Component {
item.product = {
legal: item.products.filter((item2) => item2.type === 1),
reduce: item.products
.filter((item3) => item3.type === 2)
.map(
(item4) =>
reduce
.map((item5) => {
if (item4.only === item5.channel_activity_id) return item5
})
.filter((item6) => item6)[0]
)
.map((item2) => {
if (item2.type === 2) return item2.origin
})
.filter((item3) => item3)
}
})
)
@ -173,6 +163,7 @@ export default class acclist extends React.Component {
}
return valide
}
onCancel() {
this.refs.form1.cancel()
}
@ -225,6 +216,7 @@ export default class acclist extends React.Component {
break
}
sessionStorage.setItem('productData', '')
sessionStorage.setItem('knockGoldData', '')
let codeInfo = {
//数据模型不可少
@ -321,23 +313,12 @@ export default class acclist extends React.Component {
if (index > -1) {
item.checked = this.state.tempdata[index].checked
}
item.type = 1
item.only = item.product_id
item.upstream = '直连天下'
return item
})
//select数据
let arr = []
_.map(temp.concat(this.state.tempdata), (res) => {
let obj = {}
obj.key = res.only
obj.text = res.product_name
arr.push(obj)
return obj
})
arr = deWeightThree(arr, 'key')
this.setState({ rankoptions: arr })
} else {
/* 处理立减金 */
data = JSON.parse(sessionStorage.getItem('knockGoldData')).filter(
@ -359,6 +340,7 @@ export default class acclist extends React.Component {
newObj.product_name = item.batch_goods_name
? item.batch_goods_name
: item.product_name //名字
newObj.map_product_name = item.product_name
newObj.channel_activity_id = item.channel_activity_id //批次号
newObj.only = item.channel_activity_id //批次号
newObj.type = 2 //类型
@ -382,22 +364,23 @@ export default class acclist extends React.Component {
newObj.origin = item?.origin ? item?.origin : item
return newObj
})
//select数据
let arr = []
_.map(temp.concat(this.state.tempdata), (res) => {
let obj = {}
obj.key = res.only
obj.text = res.product_name
arr.push(obj)
return obj
})
arr = deWeightThree(arr, 'key')
this.setState({ rankoptions: arr })
}
let newArray = temp.concat(this.state.tempdata)
newArray = deWeightThree(newArray, 'only')
this.setState({ tempdata: newArray })
//select数据
let arr = []
let rank = []
_.map(newArray, (res) => {
arr.push({ key: res.only, text: res.product_name })
if (res.checked) {
rank.push({ key: res.only, text: res.product_name })
}
})
arr = deWeightThree(arr, 'key')
this.setState({ tempdata: newArray, rankoptions: arr, rank })
}, 500)
}
}
@ -470,6 +453,7 @@ export default class acclist extends React.Component {
range: rank.toString()
}
console.log(productlist)
let arr = _.map(productlist, (item) => {
let obj = {}
obj.product_id = item.product_id
@ -1482,46 +1466,9 @@ export default class acclist extends React.Component {
this.setState({ rank: arr })
}}
ComponentHandler={(com, rowData, rowIndex) => {
// if (com == 'product_name') {
// return (
// <Input
// width={100}
// placeholder='请输入商品名称'
// value={rowData.product_name}
// onChange={(e) => {
// this.onNameChange(e, rowData, rowIndex)
// }}
// />
// )
// }
// if (com == 'quantity') {
// return (
// <Input
// width={100}
// placeholder='请输入数量'
// value={rowData.quantity}
// onChange={(e) => {
// this.onQuantityChange(e, rowData, rowIndex)
// }}
// />
// )
// }
if (com == 'type') {
return <>{rowData.type === 2 ? '立减金' : '商品'}</>
}
// if (com == 'contract_price') {
// return (
// <Input
// width={100}
// placeholder='请输入合同价'
// value={rowData.contract_price}
// onChange={(e) => {
// this.onPriceChange(e, rowData, rowIndex)
// }}
// />
// )
// }
if (com == 'edit') {
return (
<a

View File

@ -435,18 +435,6 @@ export default class acclist extends React.Component {
item.upstream = '直连天下'
return item
})
//select数据
let arr = []
_.map(temp.concat(this.state.tempdata), (res) => {
let obj = {}
obj.key = res.only
obj.text = res.product_name
arr.push(obj)
return obj
})
arr = deWeightThree(arr, 'key')
this.setState({ rankoptions: arr })
} else {
/* 处理立减金 */
data = JSON.parse(sessionStorage.getItem('knockGoldData')).filter(
@ -454,7 +442,7 @@ export default class acclist extends React.Component {
)
temp = _.map(data, (item) => {
let index = this.state.tempdata.findIndex((o) => {
return o.channel_activity_id === item.only
return o.channel_activity_id === item.channel_activity_id
})
if (index > -1) {
@ -463,39 +451,51 @@ export default class acclist extends React.Component {
/* 转换商品结构 */
// temp
return {
product_name: item.batch_goods_name, //名字
channel_activity_id: item.channel_activity_id, //批次号
type: 2, //类型
only: item.channel_activity_id,
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',
origin: item
}
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
newObj.id = item.goods_id ? item.goods_id : item.id
return newObj
})
//select数据
let arr = []
_.map(temp.concat(this.state.tempdata), (res) => {
let obj = {}
obj.key = res.only
obj.text = res.product_name
arr.push(obj)
return obj
})
arr = deWeightThree(arr, 'key')
this.setState({ rankoptions: arr })
}
let newArray = temp.concat(this.state.tempdata)
newArray = deWeightThree(newArray, 'only')
this.setState({ tempdata: newArray })
//select数据
let arr = []
let rank = []
_.map(newArray, (res) => {
arr.push({ key: res.only, text: res.product_name })
if (res.checked) {
rank.push({ key: res.only, text: res.product_name })
}
})
arr = deWeightThree(arr, 'key')
this.setState({ tempdata: newArray, rankoptions: arr, rank })
}, 500)
}
}
@ -1002,7 +1002,6 @@ export default class acclist extends React.Component {
}
rowItemClick(row, rowIndex) {
debugger
let codeInfo = {
//数据模型不可少
code_name: row.title,
@ -1035,7 +1034,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 })
}
@ -1120,10 +1119,6 @@ export default class acclist extends React.Component {
if (this.state.direct_reseller_id > 0) {
/* 区分立减金 */
if (row.type === 2) {
// const temp = JSON.parse(sessionStorage.getItem('knockGoldData'))
// const editData = temp.filter(
// (item) => item.channel_activity_id === row.only
// )
this.setState({
product_title: '编辑立减金',
productData: row.origin,