This commit is contained in:
wangsongsole 2022-05-31 16:50:13 +08:00
parent 08ff0e7c3c
commit 56da3bf4b7
4 changed files with 182 additions and 118 deletions

View File

@ -115,7 +115,6 @@ export default class exchangedit extends React.Component {
receive_email: req.receive_email receive_email: req.receive_email
} }
this.setState({ reseller: resller_obj }) this.setState({ reseller: resller_obj })
let codeInfo = { let codeInfo = {
code_name: req.title, code_name: req.title,
issued: req.quantity, issued: req.quantity,
@ -124,7 +123,6 @@ export default class exchangedit extends React.Component {
date_time: [req.begin_time, req.end_time], date_time: [req.begin_time, req.end_time],
range: req.update_product range: req.update_product
} }
if (req.new_product.length > 0) { if (req.new_product.length > 0) {
req.new_product = _.map(req.new_product, (item) => { req.new_product = _.map(req.new_product, (item) => {
item.checked = false item.checked = false
@ -134,7 +132,7 @@ export default class exchangedit extends React.Component {
} }
let new_ids = _.map(req.new_product, (o) => { let new_ids = _.map(req.new_product, (o) => {
return o.product_id return o.only
}) })
this.setState({ new_product: new_ids }) this.setState({ new_product: new_ids })
@ -148,12 +146,13 @@ export default class exchangedit extends React.Component {
codeInfo.stock = req.stock codeInfo.stock = req.stock
this.setState({ plan_time: req.plan.end_time }) this.setState({ plan_time: req.plan.end_time })
this.setState({ oldTable: req.code_batch_stock }) this.setState({ oldTable: req.code_batch_stock })
console.log(req)
let deleteArr = [] let deleteArr = []
for (let i = 0; i < delete_product.length; i++) { for (let i = 0; i < delete_product.length; i++) {
let deleteData = req.code_batch_stock.find( let deleteData = req.code_batch_stock.find(
(o) => o.product_id == delete_product[i] (o) => o.only == delete_product[i]
) )
deleteData.checked = false deleteData.checked = false
deleteArr.push(deleteData) deleteArr.push(deleteData)
@ -163,7 +162,7 @@ export default class exchangedit extends React.Component {
codeInfo.range = codeInfo.range.concat(deleteArr) codeInfo.range = codeInfo.range.concat(deleteArr)
let table = _.map(codeInfo.range, (res) => { let table = _.map(codeInfo.range, (res) => {
let obj = req.code_batch_stock.find( let obj = req.code_batch_stock.find(
(o) => o.product_id == res.product_id (o) => o.only == res.only
) )
res.usage = obj ? obj.usage : 0 res.usage = obj ? obj.usage : 0
@ -186,14 +185,13 @@ export default class exchangedit extends React.Component {
let temp = [] let temp = []
_.map(codeInfo.range, (res) => { _.map(codeInfo.range, (res) => {
let obj = {} let obj = {}
obj.key = res.product_id obj.key = res.only
obj.text = res.product_name obj.text = res.product_name
if (new_ids.indexOf(res.product_id) < 0) { if (new_ids.indexOf(res.only) < 0) {
this.state.oldProduct.push(res.product_id) this.state.oldProduct.push(res.only)
} }
if ( if (
table.find((o) => o.product_id == res.product_id) table.find((o) => o.only == res.only).checked == true
.checked == true
) { ) {
temp.push(obj) temp.push(obj)
} }
@ -227,17 +225,51 @@ export default class exchangedit extends React.Component {
handelResponse( handelResponse(
res, res,
(req, msg) => { (req, msg) => {
let reqCopy = _.cloneDeep(req)
const resData = []
reqCopy.goods.map((item) => {
/* type 1为商品 2为立减金 转译字符方便处理 */
/* 此处only 商品为product_id 立减金为channel_activity_id */
if (item.type === 1) {
item.entity.upstream = '直连天下'
item.entity.only = item.entity.product_id
item.entity.id = item.id
resData.push(item.entity)
} else if (item.type === 2) {
resData.push({
original: item.entity,
type: item.type,
product_type_text: '立减金',
only: item.entity.channel_activity_id,
id: item.id,
upstream: item.entity.channel === '1' ? '支付宝' : '微信',
code_batch_id: item.code_batch_id,
contract_price: item.entity.price,
create_time: item.create_time,
official_price: item.entity.denomination,
channel_activity_id: item.entity.channel_activity_id,
product_name: item.entity.batch_goods_name,
quantity: item.stock,
effectDate:
item.entity.time_limit.effect_time.start_time +
' 至 ' +
item.entity.time_limit.effect_time.end_time //有效时间
})
}
})
reqCopy.goods = resData
let codeInfo = { let codeInfo = {
code_name: req.title, code_name: reqCopy.title,
issued: req.quantity, issued: reqCopy.quantity,
stock: req.stock, stock: reqCopy.stock,
describe: req.describe, describe: reqCopy.describe,
date_time: [req.begin_time, req.end_time], date_time: [reqCopy.begin_time, reqCopy.end_time],
range: req.code_batch_stock range: reqCopy.goods
} }
this.setState({ plan_time: req.plan.end_time })
this.setState({ plan_time: reqCopy.plan.end_time })
//获取分销商 //获取分销商
getReseller(req.plan.reseller_id).then((res) => { getReseller(reqCopy.plan.reseller_id).then((res) => {
handelResponse(res, (req1, msg) => { handelResponse(res, (req1, msg) => {
console.log('req ==>1', req1) console.log('req ==>1', req1)
req1.receive_email = req1.contact_email[0] req1.receive_email = req1.contact_email[0]
@ -252,13 +284,13 @@ export default class exchangedit extends React.Component {
this.setState({ codeInfo: codeInfo }) this.setState({ codeInfo: codeInfo })
this.setState({ isload: true }) this.setState({ isload: true })
let table = _.map(req.code_batch_stock, (res) => { let table = _.map(reqCopy.goods, (res) => {
res.checked = true res.checked = true
return res return res
}) })
this.setState({ tempdata: req.code_batch_stock }) this.setState({ tempdata: reqCopy.goods || [] })
let a1 = req.code_batch_stock.map((item) => { let a1 = reqCopy.goods.map((item) => {
let obj = { let obj = {
...item, ...item,
in: true in: true
@ -267,11 +299,11 @@ export default class exchangedit extends React.Component {
}) })
sessionStorage.setItem('productData', JSON.stringify(a1)) sessionStorage.setItem('productData', JSON.stringify(a1))
let arr = [] let arr = []
_.map(req.code_batch_stock, (res) => { _.map(reqCopy.goods, (res) => {
let obj = {} let obj = {}
obj.key = res.product_id obj.key = res.only
obj.text = res.product_name obj.text = res.product_name
this.state.oldProduct.push(res.product_id) this.state.oldProduct.push(res.only)
arr.push(obj) arr.push(obj)
return obj return obj
}) })
@ -874,7 +906,13 @@ export default class exchangedit extends React.Component {
sessionStorage.setItem('productsList', JSON.stringify(data)) sessionStorage.setItem('productsList', JSON.stringify(data))
/* 区分立减金 */ /* 区分立减金 */
if (rowData.type === 2) { if (rowData.type === 2) {
const temp = JSON.parse(sessionStorage.getItem('knockGoldData')) let temp = ''
/* 区分是否为新增编辑 还是原始数据编辑 */
if (rowData?.original) {
temp = [rowData.original]
} else {
temp = JSON.parse(sessionStorage.getItem('knockGoldData'))
}
const editData = temp.filter( const editData = temp.filter(
(item) => item.channel_activity_id === rowData.only (item) => item.channel_activity_id === rowData.only
) )

View File

@ -1,37 +1,21 @@
/* 编辑 */ /* 编辑 */
import ReactDOM from 'react-dom' import React from 'react'
import React, { Component } from 'react' import { Button, Card, Icon, Notify, Radio, RadioGroup, Sweetalert } from 'zent'
import { HashRouter as Router, Route, Link } from 'react-router-dom'
import {
Button,
Card,
Icon,
Notify,
Radio,
RadioGroup,
smoothScroll,
Sweetalert,
Input
} from 'zent'
import './edit.less' import './edit.less'
import Step1 from './step1.js' import Step1 from './step1.js'
import Step2 from './step2.js' import Step2 from './step2.js'
import Step3 from './step3.js' import Step3 from './step3.js'
import _ from 'lodash' import _ from 'lodash'
import { import {
getThemeChoice,
addPlanStep, addPlanStep,
handelResponse, handelResponse,
getReseller, getReseller,
planSend, planSend,
getDraftInfo, getDraftInfo,
putPlanStep,
uploadImg,
getApprovalsInfo, getApprovalsInfo,
approvals, approvals,
terminateApprovals, terminateApprovals,
getApprovalsStatus, getApprovalsStatus
getCodesDetail
} from '../../../assets/api.js' } from '../../../assets/api.js'
export default class add extends React.Component { export default class add extends React.Component {
@ -102,6 +86,7 @@ export default class add extends React.Component {
parentComponent: this parentComponent: this
}) })
} }
componentDidMount(e) { componentDidMount(e) {
let plan_status = sessionStorage.getItem('plan_status') let plan_status = sessionStorage.getItem('plan_status')
if (plan_status == 3 || plan_status == 4 || plan_status == 5) { if (plan_status == 3 || plan_status == 4 || plan_status == 5) {
@ -140,6 +125,7 @@ export default class add extends React.Component {
} }
setTimeout(() => { setTimeout(() => {
for (let i = 0; i < this.state.keys.length; i++) { for (let i = 0; i < this.state.keys.length; i++) {
console.log(req.keys[i])
this.refs['step2-' + i].edit(req.keys[i]) this.refs['step2-' + i].edit(req.keys[i])
} }
}, 500) }, 500)
@ -169,6 +155,7 @@ export default class add extends React.Component {
) )
}) })
} else { } else {
debugger
//获取草稿信息 //获取草稿信息
console.log('获取草稿信息 ==>') console.log('获取草稿信息 ==>')
getDraftInfo(plan_id).then((res) => { getDraftInfo(plan_id).then((res) => {
@ -593,6 +580,7 @@ export default class add extends React.Component {
onStyleChange={(e) => { onStyleChange={(e) => {
this.onStyleChange(e) this.onStyleChange(e)
}} }}
is_Edit={true}
whiteStyle={this.state.whiteStyle} whiteStyle={this.state.whiteStyle}
keyStyle={this.state.keyStyle} keyStyle={this.state.keyStyle}
isload={this.state.isload} isload={this.state.isload}

View File

@ -108,11 +108,9 @@ export default class acclist extends React.Component {
componentDidMount(e) { componentDidMount(e) {
const dom = ReactDOM.findDOMNode(this) const dom = ReactDOM.findDOMNode(this)
let items = dom.getElementsByClassName('form-Item') let items = dom.getElementsByClassName('form-Item')
let input = items[1].getElementsByTagName('input')[0] let input = items[1].getElementsByTagName('input')[0]
input.focus() input.focus()
if (this.props.name > 0) { if (this.props.name > 0) {
this.setState({ whiteStyle: this.props.whiteStyle }) this.setState({ whiteStyle: this.props.whiteStyle })
this.setState({ white_visible: this.props.whiteStyle }) this.setState({ white_visible: this.props.whiteStyle })
@ -125,6 +123,41 @@ export default class acclist extends React.Component {
submit() { submit() {
let valide = false let valide = false
if (this.refs.form1.validator()) { 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) => {
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) =>
reduce
.map((item5) => {
if (item4.only === item5.channel_activity_id) return item5
})
.filter((item6) => item6)[0]
)
}
})
)
dataCopy.map((item) => {
delete item.products
})
/* 处理数据 区分立减金和商品 完成 2022-05-30 13:40*/
let data = {} let data = {}
data.batch_name = this.state.model.batch_name data.batch_name = this.state.model.batch_name
data.style = this.state.model.style data.style = this.state.model.style
@ -133,7 +166,7 @@ export default class acclist extends React.Component {
data.allow_repetition = this.state.model.allow_repetition data.allow_repetition = this.state.model.allow_repetition
data.allow_loss = this.state.model.allow_loss data.allow_loss = this.state.model.allow_loss
data.merge_stock = this.state.model.merge_stock data.merge_stock = this.state.model.merge_stock
data.code_batch = this.refs.tempdata.getSelectData() data.code_batch = dataCopy
data.mobile_excel = this.state.mobile_excel data.mobile_excel = this.state.mobile_excel
data.mobile_repeat = this.state.mobile_repeat data.mobile_repeat = this.state.mobile_repeat
return data return data
@ -655,6 +688,9 @@ export default class acclist extends React.Component {
restrict: row.restrict restrict: row.restrict
} }
/*审核中编辑 转换数据结构立减金和商品结构 */
const newRowArray = row.product.legal.concat(row.product.reduce)
let arr = _.map(row.product, (res) => { let arr = _.map(row.product, (res) => {
let obj = {} let obj = {}
obj.key = res.only obj.key = res.only

View File

@ -25,7 +25,8 @@ import {
Tag, Tag,
TimeRangePicker TimeRangePicker
} from 'zent' } from 'zent'
import _, { isArray, times } from 'lodash' import _, { isArray } from 'lodash'
import { getVoucherWarningAccount, handelResponse } from '../../../assets/api'
import AddNewDialog from './Dialog' import AddNewDialog from './Dialog'
import MobileComponent from './mobileCmponent' import MobileComponent from './mobileCmponent'
const getTimeList = [ const getTimeList = [
@ -33,6 +34,10 @@ const getTimeList = [
{ key: '1', text: '次日生效' }, { key: '1', text: '次日生效' },
{ key: '2', text: '自定义时间' } { key: '2', text: '自定义时间' }
] ]
const cardTypeList = [
{ key: 1, text: '借记卡' },
{ key: 2, text: '信用卡' }
]
const receiveTypeList = [ const receiveTypeList = [
{ key: 'all', text: '总共' }, { key: 'all', text: '总共' },
@ -61,7 +66,7 @@ export default class addKnockGold extends Component {
reduce_amount: '', // reduce_amount: '', //
all_budget: '', // all_budget: '', //
day_budget: '', // day_budget: '', //
card_type: '', // '', card_type: [], // '',
natural_limit: '1', //'', natural_limit: '1', //'',
brush_limit: '1', //'', brush_limit: '1', //'',
instruction: '', //'使', instruction: '', //'使',
@ -106,8 +111,22 @@ export default class addKnockGold extends Component {
} }
componentWillMount() { componentWillMount() {
const UserSelectList = this.getUserSelectList() /* 此处解决 日期组件不回显问题 提前触发 */
if (this.props.data) {
let model = this.state.model
model.entry_time[0] = this.props.data.time_limit.effect_time.start_time
model.entry_time[1] = this.props.data.time_limit.effect_time.end_time
model.fixed_time[0] =
this.props.data.time_limit.use_time.fiexd_time?.start_time
model.fixed_time[1] =
this.props.data.time_limit.use_time.fiexd_time?.end_time
this.setState({ model: model })
}
this.getUserSelectList()
}
/* 编辑回显 */
echoFun(UserSelectList) {
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) {
@ -115,15 +134,11 @@ export default class addKnockGold extends Component {
} }
model.receive_type = this.props.data.receive_conf.type model.receive_type = this.props.data.receive_conf.type
model.receive_number = this.props.data.receive_conf.num model.receive_number = this.props.data.receive_conf.num
model.entry_time[0] = this.props.data.time_limit.effect_time.start_time
model.entry_time[1] = this.props.data.time_limit.effect_time.end_time
model.timer[0] = this.props.data.time_limit.receive_time.start_time model.timer[0] = this.props.data.time_limit.receive_time.start_time
model.timer[1] = this.props.data.time_limit.receive_time.end_time model.timer[1] = this.props.data.time_limit.receive_time.end_time
model.fixed_time[0] = model.timer_type = !this.props.data.time_limit.receive_time?.start_time
this.props.data.time_limit.use_time.fiexd_time?.start_time ? '1'
model.fixed_time[1] = : '2'
this.props.data.time_limit.use_time.fiexd_time?.end_time
model.timer_type = this.props.data.time_limit.receive_time.type
if (this.props.data.time_limit.use_time.effect_day) { if (this.props.data.time_limit.use_time.effect_day) {
model.effect_date_type = model.effect_date_type =
@ -137,8 +152,8 @@ export default class addKnockGold extends Component {
} }
model.effect_date = this.props.data.time_limit.use_time.effect_day model.effect_date = this.props.data.time_limit.use_time.effect_day
model.usable_time = this.props.data.time_limit.use_time.type model.usable_time = this.props.data.time_limit.use_time.type
model.early_notifier = this.props.data.early_notifier.map((item) => { model.early_notifier = this.props.data.early_notifier?.map((item) => {
return UserSelectList.map((items) => { return UserSelectList?.map((items) => {
if (item.mobile === items.key) return items if (item.mobile === items.key) return items
}).filter((item1) => item1)[0] }).filter((item1) => item1)[0]
}) })
@ -153,60 +168,39 @@ export default class addKnockGold extends Component {
} }
// //
getUserSelectList() { getUserSelectList(cb) {
const data = [
{
real_name: '黎明',
mobile: '18555454545'
},
{
real_name: '彤彤',
mobile: '18547777744'
},
{
real_name: '杨洋',
mobile: '15874574122'
},
{
real_name: '何欢媛',
mobile: '18695241254'
},
{
real_name: '林青松',
mobile: '15184342032'
},
{
real_name: '韦多伦',
mobile: '15874747474'
},
{
real_name: 'zh',
mobile: '15184345036'
}
]
const defaultDta = ['何欢媛', '韦多伦']
const model = this.state.model const model = this.state.model
getVoucherWarningAccount().then((res) =>
const newData = data.map((item) => { handelResponse(
if (defaultDta.indexOf(item.real_name) !== -1) { res,
const obj = { (req, msg) => {
key: item.mobile, const defaultData = req.default.map((item) => item.real_name)
text: item.real_name, const newData = req.data.concat(req.default).map((item) => {
disabled: true, if (defaultData.indexOf(item.real_name) !== -1) {
closable: false const obj = {
key: item.mobile,
text: item.real_name,
disabled: true,
closable: false
}
model.early_notifier.push(obj)
return obj
} else {
return {
key: item.mobile,
text: item.real_name,
closable: true
}
}
})
this.setState({ userSelectList: newData, model: model })
this.echoFun(newData)
},
(err) => {
Notify.error(err)
} }
model.early_notifier.push(obj) )
return obj )
} else {
return {
key: item.mobile,
text: item.real_name,
closable: true
}
}
})
this.setState({ userSelectList: newData, model: model })
return newData
} }
/* x时间控件禁用 */ /* x时间控件禁用 */
@ -352,8 +346,7 @@ export default class addKnockGold extends Component {
receive_time: { receive_time: {
start_time: this.state.model.timer[0], start_time: this.state.model.timer[0],
end_time: this.state.model.timer[1], end_time: this.state.model.timer[1]
type: this.state.model.timer_type
}, },
use_time: { use_time: {
@ -397,7 +390,7 @@ export default class addKnockGold extends Component {
} }
if ( if (
this.state.model.usable_time === 'fixed' && this.state.model.usable_time === 'fiexd' &&
this.setTime(this.state.model.fixed_time) this.setTime(this.state.model.fixed_time)
) { ) {
Notify.error('请完整的选择固定时间段') Notify.error('请完整的选择固定时间段')
@ -439,6 +432,12 @@ export default class addKnockGold extends Component {
Notify.error('请选择结束时间或开始时间') Notify.error('请选择结束时间或开始时间')
return false return false
} }
/* 预警人数 */
if (this.state.model.early_notifier.length > 14) {
Notify.error('目前仅支持新增10个预警通知人')
return false
}
} }
// //
@ -721,8 +720,11 @@ export default class addKnockGold extends Component {
onChange={(value) => { onChange={(value) => {
this.onHandleChange(value, 'card_type') this.onHandleChange(value, 'card_type')
}}> }}>
<Checkbox value='1'>借记卡</Checkbox> {cardTypeList.map((item) => (
<Checkbox value='2'>信用卡</Checkbox> <Checkbox value={item.key} key={item.key}>
{item.text}
</Checkbox>
))}
</CheckboxGroup> </CheckboxGroup>
</FormItem> </FormItem>
<FormItem <FormItem
@ -831,7 +833,7 @@ export default class addKnockGold extends Component {
this.onHandleChange(target.value, 'usable_time') this.onHandleChange(target.value, 'usable_time')
this.onHandleChange([], 'fixed_time') this.onHandleChange([], 'fixed_time')
}}> }}>
<Radio value='receiving'>领取后</Radio> <Radio value='received'>领取后</Radio>
</RadioGroup> </RadioGroup>
<div className='zent-demo-select-basic select-basic'> <div className='zent-demo-select-basic select-basic'>
<Select <Select
@ -886,7 +888,7 @@ export default class addKnockGold extends Component {
this.onHandleChange('', 'effect_date_type') this.onHandleChange('', 'effect_date_type')
this.onHandleChange('', 'effect_date') this.onHandleChange('', 'effect_date')
}}> }}>
<Radio value='fixed'>固定时间</Radio> <Radio value='fiexd'>固定时间</Radio>
</RadioGroup> </RadioGroup>
<DateRangePicker <DateRangePicker
className='zent-datepicker-plan' className='zent-datepicker-plan'