1、梳理兑换码管理商品范围编辑

2、新增立减金添加uuid
3、封装uuid生成器
This commit is contained in:
wangsongsole 2022-05-18 14:32:26 +08:00
parent dc5b5de264
commit 28bac3845c
3 changed files with 47 additions and 6 deletions

View File

@ -573,6 +573,7 @@ export default class exchangedit extends React.Component {
this.setState({ codeInfo: model2 }) this.setState({ codeInfo: model2 })
} }
//渲染范围列表数据以及数据转换
async productSubmit() { async productSubmit() {
let visible = '' let visible = ''
if (this.state.addIsType === 'addProduct') { if (this.state.addIsType === 'addProduct') {
@ -615,7 +616,7 @@ export default class exchangedit extends React.Component {
data = JSON.parse(sessionStorage.getItem('knockGoldData')) data = JSON.parse(sessionStorage.getItem('knockGoldData'))
temp = _.map(data, (item) => { temp = _.map(data, (item) => {
let index = this.state.tempdata.findIndex((o) => { let index = this.state.tempdata.findIndex((o) => {
return o.product_id === item.id return o.product_id === item.uuid
}) })
if (index > -1) { if (index > -1) {
@ -625,7 +626,7 @@ export default class exchangedit extends React.Component {
/* 转换商品结构 */ /* 转换商品结构 */
// temp // temp
return { return {
product_id: item.id, product_id: item.uuid,
product_name: item.batch_goods_name, //名字 product_name: item.batch_goods_name, //名字
cost_price: '', cost_price: '',
contract_price: item.contract_price, //单价 contract_price: item.contract_price, //单价
@ -689,6 +690,7 @@ export default class exchangedit extends React.Component {
} }
} }
/* 修改商品名称 */
onNameChange(e, row) { onNameChange(e, row) {
let rowIndex = this.state.tempdata.findIndex((o) => { let rowIndex = this.state.tempdata.findIndex((o) => {
return o.product_id == row.product_id return o.product_id == row.product_id
@ -696,6 +698,8 @@ export default class exchangedit extends React.Component {
this.state.tempdata[rowIndex].product_name = e.target.value this.state.tempdata[rowIndex].product_name = e.target.value
this.setState({ tempdata: this.state.tempdata }) this.setState({ tempdata: this.state.tempdata })
} }
/* 修改库存总数 */
onQuantityChange(e, row) { onQuantityChange(e, row) {
this.setState({ tempdata: this.state.tempdata }) this.setState({ tempdata: this.state.tempdata })
let value = e.target.value let value = e.target.value
@ -713,6 +717,8 @@ export default class exchangedit extends React.Component {
value - this.state.tempdata[rowIndex].usage value - this.state.tempdata[rowIndex].usage
this.setState({ tempdata: this.state.tempdata }) this.setState({ tempdata: this.state.tempdata })
} }
/* 修改合同价 */
onPriceChange(e, row) { onPriceChange(e, row) {
let str = e.target.value let str = e.target.value
let value = str let value = str
@ -851,6 +857,7 @@ export default class exchangedit extends React.Component {
}) })
} }
/* 商品范围列表编辑 */
productEditShow(rowData) { productEditShow(rowData) {
console.log('direct_reseller_id ==>', this.state.direct_reseller_id) console.log('direct_reseller_id ==>', this.state.direct_reseller_id)
console.log('rowData 12==>', rowData) console.log('rowData 12==>', rowData)
@ -865,7 +872,7 @@ export default class exchangedit extends React.Component {
if (rowData.type === 'knockGold') { if (rowData.type === 'knockGold') {
const temp = JSON.parse(sessionStorage.getItem('knockGoldData')) const temp = JSON.parse(sessionStorage.getItem('knockGoldData'))
const editData = temp.filter( const editData = temp.filter(
(item) => item.id === rowData.product_id (item) => item.uuid === rowData.product_id
) )
this.setState({ this.setState({

View File

@ -6,6 +6,7 @@ import Form from '../../../components/form/main'
import FormItem from '../../../components/form-item/main' import FormItem from '../../../components/form-item/main'
import rules from './rules' import rules from './rules'
import moment from 'moment' import moment from 'moment'
import { uuid } from './utils'
import { import {
Select, Select,
Button, Button,
@ -30,7 +31,7 @@ export default class adduserinfo extends React.Component {
this.state = { this.state = {
model: { model: {
// //
id: '', uuid: '',
channel: '1', // channel: '1', //
entry_time: '', // entry_time: '', //
expire_time: '', // expire_time: '', //
@ -166,7 +167,7 @@ export default class adduserinfo extends React.Component {
temp = JSON.parse(sessionStorage.getItem('knockGoldData')) temp = JSON.parse(sessionStorage.getItem('knockGoldData'))
let index = temp.findIndex((item) => { let index = temp.findIndex((item) => {
return item.id === this.props.data.id return item.uuid === this.props.data.uuid
}) })
for (let key in this.state.model) { for (let key in this.state.model) {
@ -199,7 +200,9 @@ export default class adduserinfo extends React.Component {
temp = JSON.parse(sessionStorage.getItem('knockGoldData')) temp = JSON.parse(sessionStorage.getItem('knockGoldData'))
} }
let data = temp ? temp : [] let data = temp ? temp : []
data.push(this.state.model) const models = this.state.model
models.uuid = uuid(6, 16)
data.push(models)
sessionStorage.setItem('knockGoldData', JSON.stringify(data)) sessionStorage.setItem('knockGoldData', JSON.stringify(data))
return true return true
} }

View File

@ -0,0 +1,31 @@
/* uuid生成器 */
export function uuid(len, radix) {
var chars =
'0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.split('')
var uuid = [],
i
radix = radix || chars.length
if (len) {
// Compact form
for (i = 0; i < len; i++) uuid[i] = chars[0 | (Math.random() * radix)]
} else {
// rfc4122, version 4 form
var r
// rfc4122 requires these characters
uuid[8] = uuid[13] = uuid[18] = uuid[23] = '-'
uuid[14] = '4'
// Fill in random data. At i==19 set the high bits of clock sequence as
// per rfc4122, sec. 4.1.5
for (i = 0; i < 36; i++) {
if (!uuid[i]) {
r = 0 | (Math.random() * 16)
uuid[i] = chars[i == 19 ? (r & 0x3) | 0x8 : r]
}
}
}
return uuid.join('')
}