diff --git a/src/components/knockGold/index.jsx b/src/components/knockGold/index.jsx
index 08ebaad1..cefc1eae 100644
--- a/src/components/knockGold/index.jsx
+++ b/src/components/knockGold/index.jsx
@@ -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'
/>
减
@@ -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'
/>
{
- 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
})
diff --git a/src/pages/exchangecode/edit/edit.js b/src/pages/exchangecode/edit/edit.js
index e78c5fff..b1679f84 100644
--- a/src/pages/exchangecode/edit/edit.js
+++ b/src/pages/exchangecode/edit/edit.js
@@ -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)
}
}
diff --git a/src/pages/plan/add/add.js b/src/pages/plan/add/add.js
index ba31ac24..781e6804 100644
--- a/src/pages/plan/add/add.js
+++ b/src/pages/plan/add/add.js
@@ -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) {
diff --git a/src/pages/plan/add/step2.js b/src/pages/plan/add/step2.js
index 56bfe082..202b6985 100644
--- a/src/pages/plan/add/step2.js
+++ b/src/pages/plan/add/step2.js
@@ -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 (
- // {
- // this.onNameChange(e, rowData, rowIndex)
- // }}
- // />
- // )
- // }
- // if (com == 'quantity') {
- // return (
- // {
- // this.onQuantityChange(e, rowData, rowIndex)
- // }}
- // />
- // )
- // }
if (com == 'type') {
return <>{rowData.type === 2 ? '立减金' : '商品'}>
}
- // if (com == 'contract_price') {
- // return (
- // {
- // this.onPriceChange(e, rowData, rowIndex)
- // }}
- // />
- // )
- // }
-
if (com == 'edit') {
return (
{
- 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,