import React, { Component } from 'react' import { StyleSheet, View, Image, StatusBar, Text, TouchableOpacity, Dimensions, PixelRatio, ScrollView, FlatList, Platform, DatePickerAndroid, ActivityIndicator, Modal, TextInput, Button } from 'react-native' import { connect } from 'react-redux' import Collapsible from 'react-native-collapsible' import CountNum from '../../components/CountNum' import Input from '../../components/input' import png from '../../static/images/defaultimg.jpg' import morePng from '../../static/images/ic-moredian.png' import { ImageBaseUrl } from '../../utils/fetch/Fetchx' import { ScaleUtil, accAdd, accMul, accDiv, accSub, NumberTranslate, setNowFormatDate, } from '../../utils/utils' import Icon from '../../components/Iconfont/Iconfont' import { NavigationActions, createAction } from '../../utils' import redblue from '../../static/images/ic-redblue.png' //import moreDian from '../../static/images/ic-moredian.png' import OrderCredit from './orderamanage/OrderCredit' import OrderOptional from './orderamanage/OrderOptional' import SelectTime from '../common/SelectTime' import * as authService from '../../services/auth' //import orderCreditPng from '../../static/images/order-credit.png' import deletePng from '../../static/images/delete.png' import moment from 'moment' import Toast from 'react-native-root-toast' import DetailModels from '../../models/commodity/DetailModels' import OptFlatList from '../commodity/commoditydetail/OptFlatList' /** * saleModel * * Sale("01", "正向销售", "正向销售"), * Return("02", "退货", "退货"), * Cost("03", "费用货补", "费用货补"), * CostReturn("04", "货补退货", "货补退货"); */ const { width, height } = Dimensions.get('window') let currRow = {} // 当前操作行 @connect(({ theme, mine, orderedit, optional }) => ({ ...theme, ...mine, ...orderedit, ...optional, })) class OrderEdit extends Component { constructor(props) { const date = new Date() super(props) this.state = { optionData: [], showOptModal : false, modalVisible : false, activeSection: true, optLoading: false, // activeAllCollaps: true, optCollapse: 'shouqi', baseIndex: 0, activeAllCollaps: true, transportSel: (props.transportDefault && props.transportDefault.name) || 0, billWaySel: (props.billwayDefault && props.billwayDefault.name) || 0, activeMethod: 'ffsa', cicleActive: true, creditShow: false, // 购物车选中 EditPromData: Object.keys(props.promData).length > 0 && props.promData.reqOrderItems ? props.promData.reqOrderItems : props.navigation.state.params.ShopData, EditPromDataCopy: Object.keys(props.promData).length > 0 && props.promData.reqOrderItems ? props.promData.reqOrderItems : props.navigation.state.params.ShopData, // 选中赠品信息 giftSelected: [], // 产品线id集合 productLineIds: [], // 发货日期 deliveryTime: setNowFormatDate(), // 支付方式 payWayDef: props.navigation.state.params.payWayDef ? props.navigation.state.params.payWayDef : '', paySel: props.navigation.state.params.payWayDef ? props.navigation.state.params.payWayDef.name : 0, //备注 remark: (props.navigation.state.params.ShopData && props.navigation.state.params.ShopData.remark) || '', // 冲抵金额 offsetAmount: 0, // 冲抵前金额 goodsAmount: 0, // 促销金额 totalPromAmt: 0, // 总成交金额最终用 totalAmount: 0, // 成交金额不变的值 totalAmountCopy: 0, // 总数量 totalNum: 0, // 总重量 totalWeight: 0, // 重量单位 volumeUnit: '', // 总体积 totoalVolume: 0, // 体积单位 volumeUnit: '', Loading: false, submitLoading: false, temporaryLoading: false, } // 保存互斥关系,点击之后如果无返回值,则使用上一次互斥关系 this.RelationShipCopy // 圆形按钮滑动前状态 this.cicleActive = true } componentDidMount() { //this.creditCheck() // 费用冲抵比率请求 this.props.dispatch( createAction('orderedit/getCastRate')({ castInfo: { saleOrgId: this.props.navigation.state.params.SaleOrSupplier .SaleOrSupplierId, customerId: CUSTOMERINFO.id, }, }) ) // 地址、结算方式等参照请求 this.props.dispatch( createAction('mine/getAdress')({ // customer: "d4b4677f-93ec-49b5-bcaa-c134df0f7295", customer: CUSTOMERINFO.id, comefrom: { comefrom: this.props.navigation.state.params.comefrom, reqOrderInvoice: this.props.navigation.state.params.reqOrderInvoice, reqOrderReceiveAddress: this.props.navigation.state.params .reqOrderReceiveAddress, transportDefault: this.props.navigation.state.params.transportDefault, billwayDefault: this.props.navigation.state.params.billwayDefault, }, transform: true, billway: true, invoice: true, }) ) if (this.props.navigation.state.params.comefrom == 'temporarily') { let newTime = new Date( this.props.navigation.state.params.data.deliveryDate ) this.setState({ transportSel: this.props.navigation.state.params.transportDefault.name, billWaySel: this.props.navigation.state.params.billwayDefault.name, deliveryTime: this.props.navigation.state.params.data.deliveryDate ? moment(this.props.navigation.state.params.data.deliveryDate).format( 'YYYY-MM-DD' ) : moment().format('YYYY-MM-DD'), }) } // 支付方式 // this.props.dispatch(createAction('mine/payMentMode')()).finally(() => { // if (!this.props.navigation.state.params.payWayDef) { // this.setState({ payWayDef: this.props.orderPayStatus[0] }) // } // }) this.setState({ productLineIds: this.getProductLines(), }) this.combinedFn(true) } // 为选择商品挂载Boom信息 addBoomToData() { const ids = [], EditPromData = this.state.EditPromData EditPromData.forEach(item => { ids.push(item.goodsId) }) let flag = true this.props .dispatch(createAction('optional/getBoomInfo')(ids.join())) .finally(() => { // 如果有子件,则暂时把子件挂在商品行下,便于展示 if (this.props.goodsBoom && this.props.goodsBoom.length > 0) { const goodsBom = this.props.goodsBoom, newOptIds = [] EditPromData.forEach((editData, editIndex) => { goodsBom.forEach((bomData, index) => { bomData.goodsBomChildren.forEach((bomChild, childIndex) => {}) if (editData.goodsId == bomData.parentGoodsId) { editData.reqOrderItemBoms = bomData.goodsBomChildren } if ( editData.baseGoodsOptId && editData.baseGoodsOptId.length > 0 ) { newOptIds.push(editData.baseGoodsOptId) } }) }) // 初始选中; if (newOptIds && newOptIds.length > 0) { const optIdsJoin = newOptIds.join() this.props .dispatch(createAction('optional/optionalByIds')(optIdsJoin)) .finally(() => { if ( this.props.optDataByIds && this.props.optDataByIds.length > 0 ) { const optDataByIds = this.props.optDataByIds optDataByIds.forEach(data => { data.optids = [] data.goodsOptVals.forEach(dataSec => { data.optids.push(dataSec.id) }) }) EditPromData.forEach(itemFir => { itemFir.reqOrderItemBoms.forEach(itemSec => { optDataByIds.forEach(optData => { if (itemSec.childGoodsId == optData.goodsId) { itemSec.baseGoodsOptId = optData.optids.join() itemSec.baseGoodsOptValue = optData.optResult } }) }) }) this.setState({ EditPromData: this.state.EditPromData }) flag = false } }) } } if (flag) { this.setState({ EditPromData: this.state.EditPromData }) } }) } async openOptView(item) { currRow = item this.setState({ optLoading: true, showOptModal: true, optionData: [] }) const result = await authService.getColorByGroups({id:item.goodsId,groupId : "", colourCode : ""}); this.setState({ optLoading: false, optionData: result.data }) this.props.dispatch(createAction("optional/getColorByGroupsReducer")({colorData: result.data})) } //选择的色卡颜色 async _chooseColor(colorData) { console.log(colorData) let selectRow = this.state.EditPromData.findIndex(item => item.goodsId == currRow.goodsId && item.baseGoodsOptId == currRow.baseGoodsOptId) if (selectRow >= 0) { let params = []; params[0] = { goodsId: colorData.children.goodsId, optResult: colorData.children.custDocGroupName + ":" + colorData.children.attrValName, uniqueKey: colorData.children.goodsId + "-" + colorData.children.attrValId, goodsOptVals: [{ prodAttrStrucItemId: colorData.children.prodAttrStrucItemId, prodAttrStrucItemName: colorData.children.name, attrValId: colorData.children.attrValId, attrValCode: colorData.children.attrValCode, attrValName: colorData.children.attrValName }] } let newRow = {...this.state.EditPromData[selectRow]}; console.log(params) const result = await authService.saveOptional([{goodsOptDtos: params}]) console.log(result) if (result.data && result.data.length && result.data[0].goodsOptDtos.length) { newRow.baseGoodsOptId = result.data[0].goodsOptDtos[0].id } newRow.baseGoodsOptValue = colorData.children.custDocGroupName + ":" + colorData.children.attrValName newRow.ext05 = colorData.children.attrValId newRow.dealPrice = colorData.goodsPriceByColor[0].price newRow.dealAmount = newRow.dealPrice * newRow.orderNum newRow.basePrice = newRow.dealPrice newRow.amount = newRow.dealAmount newRow.promPrice = newRow.dealPrice newRow.salePrice = newRow.dealPrice newRow.ext09 = newRow.dealPrice + "" newRow.ext10 = newRow.dealAmount + "" let newEditPromData = [...this.state.EditPromData]; newEditPromData.splice(selectRow, 1, newRow) let totalAmount = 0 newEditPromData.forEach(item => { totalAmount = totalAmount + item.amount }) let goodsAmount = totalAmount let totalAmountCopy = totalAmount this.setState({ showOptModal: false, EditPromData : newEditPromData, totalAmount, goodsAmount, totalAmountCopy }) currRow = {} } else { this.toast = Toast.show("选配商品已被删除!",{position : toastHeight}); this.setState({ showOptModal: false }) currRow = {} } } //删除商品 deleteGoodsFn(indexParent) { this.state.EditPromData.splice(indexParent, 1) this.setState({ Loading: true, giftSelected: [] }) if ( this.props.navigation.state.params.SaleOrSupplier.isPrimaryChannel == 1 ) { this.props .dispatch( createAction('orderedit/getProm')({ promInfo: { customerId: CUSTOMERINFO.id, saleOrgId: this.props.navigation.state.params.SaleOrSupplier .SaleOrSupplierId, isPrimaryChannel: this.props.navigation.state.params .SaleOrSupplier.isPrimaryChannel, reqOrderItems: this.state.EditPromData, }, }) ) .finally(() => { if (this.props.promData) { this.CountNumFn( true, '', '', this.props.promData.reqOrderItems || this.state.EditPromData ) } //this.autoShowGiftRow() this.setState({ Loading: false }) }) } else { this.CountNumFn(true, '', '', this.state.EditPromData) this.setState({ Loading: false }) } } // 抽出所有商品的产品线 getProductLines() { let productLineIds = [] this.state.EditPromData.map(item => { productLineIds.push(item.productLineId) }) return productLineIds } // 检查信用 creditCheck(reqOrderItems) { this.props.dispatch( createAction('orderedit/getCreditCheck')({ searchInfo: { saleOrgId: this.props.navigation.state.params.SaleOrSupplier .SaleOrSupplierId, customerId: CUSTOMERINFO.id, reqOrderItems: reqOrderItems || this.state.EditPromData, saleModel: '01', }, }) ) } // 订单数据集 正常态 getOrderData() { this.state.EditPromData.map( item => (item.id = null) // dealPrice:,//成交价格 // offsetAmount:,//行分摊促销金额 // (dealAmount = (item.basePrice || item.salePrice) * item.orderNum), //成交金额 // (amount = (item.basePrice || item.salePrice) * item.orderNum) // currency,//行币种 ) const { addressDefault, billwayDefault, invoiceDefault, transportDefault, } = this.props const postData = { id: this.props.navigation.state.params.id || '', currency: CURRENCY.id, // 币种 currencySign: CURRENCY.currencySign, // 币符 currencyPriceScale: CURRENCY.currencyPriceScale, // 币种单价精度 currencyAmountScale: CURRENCY.currencyAmountScale, // 币种金额精度 customerId: CUSTOMERINFO.id, // persistStatus: "nrm", //数据操作状态 'nrm'为无变化 'new'为新增 saleOrgId: this.props.navigation.state.params.SaleOrSupplier .SaleOrSupplierId, // 销售组织,即供应商 deliveryDate: new Date(this.state.deliveryTime).getTime(), // 期望收货日期 totalNum: this.state.totalNum, // 总数量 totalDealAmount: this.state.totalAmount, // 总成交金额 totalWeight: this.state.totalWeight, // 总重量 totoalVolume: this.state.totoalVolume, // 总体积 // orderSource: "portal", // 订单来源 remark: this.state.remark, // 订单备注 totalAmount: this.state.goodsAmount, // 冲抵前金额 offsetAmount: this.state.offsetAmount, // 费用冲抵金额 saleModel: '01', //销售模式 具体开头部 reqOrderSource: '01', //订单来源 underPaymentModeId: this.state.payWayDef.code, //订单支付方式 srcOrderId: this.props.navigation.state.params.id || '', reqOrderReceiveAddress: { reqOrderId: addressDefault.id, receiveAddressId: addressDefault.id, // 收货地址id receiver: addressDefault.receiver, // 收货人 receiverTel: addressDefault.receiverTel, // 电话 receiverPhone: addressDefault.receiverPhone, // 手机 receiverProvince: addressDefault.receiverProvince, // 省 receiverCity: addressDefault.receiverCity, // 市 receiverDistrict: addressDefault.receiverDistrict, // 区 receiverTown: addressDefault.receiverTown, // 镇 receiverAddress: addressDefault.receiverAddress, // 详细地址 receiverZipcode: addressDefault.receiverZipcode, // 邮编 }, reqOrderInvoice: { reqOrderId: invoiceDefault.id, invoiceId: invoiceDefault.id, // 发票id invoiceType: invoiceDefault.invoiceType, // 发票类型 invoiceContent: invoiceDefault.invoiceContent, // 开票项目 invoiceTitle: invoiceDefault.invoiceTitle, // 发票抬头 invoiceTaxId: invoiceDefault.invoiceTaxId, // 纳税人识别码 invoiceBank: invoiceDefault.invoiceBank, // 开户银行 invoiceAccount: invoiceDefault.invoiceAccount, // 开户账户 invoiceSubBank: invoiceDefault.invoiceSubBank, // 支行 }, reqOrderItems: this.state.EditPromData, } transportDefault && transportDefault.id ? (postData.transportModeId = transportDefault.id) : null // 运输方式 billwayDefault && billwayDefault.id ? (postData.settleModeId = billwayDefault.id) : null // 结算方式 return postData } // 从订单列表过来的订单数据集 封装暂存态的数据 getOrderFromList() { this.state.EditPromData.map(item => (item.id = null)) let EditDataCopy = JSON.parse(JSON.stringify(this.state.EditPromData)), EditData = {} const { addressDefault, billwayDefault, invoiceDefault, transportDefault, } = this.props EditData.id = this.props.navigation.state.params.type?'':(this.props.navigation.state.params.id || '') EditData.orderCode = this.props.navigation.state.params.type?'':(this.props.navigation.state.params.data.orderCode || '') EditData.currency = CURRENCY.id // 币种 EditData.currencySign = CURRENCY.currencySign // 币符 EditData.currencyPriceScale = CURRENCY.currencyPriceScale // 币种单价精度 EditData.currencyAmountScale = CURRENCY.currencyAmountScale // 币种金额精度 EditData.customerId = CUSTOMERINFO.id // 地址 EditData.reqOrderReceiveAddress = addressDefault // 发票信息 EditData.reqOrderInvoice = invoiceDefault // EditData.orderSource = "portal"; // 订单来源 EditData.srcOrderId = this.props.navigation.state.params.id || '' // 供应商 EditData.saleOrgId = this.props.navigation.state.params.SaleOrSupplier.SaleOrSupplierId EditData.saleOrgCode = this.props.navigation.state.params.SaleOrSupplier.SaleOrSupplierCode EditData.saleOrgName = this.props.navigation.state.params.SaleOrSupplier.SaleOrSupplierName EditData.isPrimaryChannel = this.props.navigation.state.params.SaleOrSupplier.isPrimaryChannel // 结算方式 EditData.settleModeCode = billwayDefault.code EditData.settleModeId = billwayDefault.id EditData.settleModeName = billwayDefault.name // 运输方式 EditData.transportModeId = transportDefault.id EditData.transportModeCode = transportDefault.code EditData.transportModeName = transportDefault.name EditData.reqOrderItems = EditDataCopy ;(EditData.underPaymentModeId = this.state.payWayDef.code), //订单支付方式 (EditData.remark = this.state.remark) // 订单备注 EditData.totalAmount = this.state.goodsAmount // 冲抵前金额 EditData.offsetAmount = this.state.offsetAmount // 费用冲抵金额 EditData.deliveryDate = new Date(this.state.deliveryTime).getTime() // 期望收货日期 EditData.totalNum = this.state.totalNum // 总数量 EditData.totalDealAmount = this.state.totalAmount // 总成交金额 EditData.totalWeight = this.state.totalWeight // 总重量 EditData.totoalVolume = this.state.totoalVolume // 总体积 EditData.saleModel = '01' //销售模式 具体开头部 EditData.reqOrderSource = '01' //订单来源 return EditData } // 促销后补充商品行 transportPromData(postData) { const giftData = JSON.parse(JSON.stringify(this.state.giftSelected)) // 如果为整单则在表头加入促销信息 if ( this.props.promData && this.props.promData.orderPriceProm && Object.keys(this.props.promData.orderPriceProm).length > 0 ) { const orderPriceProm = this.props.promData.orderPriceProm postData.reqOrderPromRels = [ { activityId: orderPriceProm.activityId, ruleId: orderPriceProm.ruleId, description: orderPriceProm.description, promWay: 2, // 1 买赠 2 降价 isWhole: 1, // 1 整单 }, ] } // 如果选择促销商品后,在商品行加入买赠商品,其中商品行中的促销信息在OrderGifts中回调封装 if (giftData && giftData.length > 0) { giftData.map((item,index) => { item.id = null item.isGift = 1 item.basePrice = 0 item.salePrice = 0 item.promPrice = 0 item.dealPrice = 0 item.amount = 0 // 金额 item.promAmount = 0 // 均摊到行上的整单降价促销金额 item.dealAmount = 0 // 成交金额 item.ffsetAmount = 0 // 均摊到行上的费用冲抵金额 item.orderNum = 0 item.rowNum = postData.reqOrderItems.length+parseInt(index)+1 item.promotinId = item.activityId }) postData.reqOrderItems = postData.reqOrderItems.concat(giftData) } return postData } // 补充BOM信息 fillGoodsBomInfo(postData) { // 之前步骤方便显示,将子件信息存在每个母件reqOrderItems中,在补充Bom时,将子件信息抽出赋在外部字段(reqOrderItemBoms)中,并将母件的自己字段删除 let newReqOrderItemBoms = [] postData.reqOrderItems.forEach((data, index) => { data.persistStatus = 'new' data.rowNum = (index + 1) * 10 data.ext09 = data.dealPrice; data.ext10 = data.dealAmount; if (data.reqOrderItemBoms && data.reqOrderItemBoms.length > 0) { data.reqOrderItemBoms.forEach(bomData => { bomData.parentRowNum = data.rowNum bomData.parentGoodsName = data.goodsDisplayName }) newReqOrderItemBoms = newReqOrderItemBoms.concat(data.reqOrderItemBoms) } delete data.reqOrderItemBoms }) postData.reqOrderItemBoms = newReqOrderItemBoms // 判断是否母件是否有子件信息,如果有:则将子件信息集合中数据封装为新结构;如果无,则将商品行复制添加到子件信息集合中 if (postData.reqOrderItemBoms && postData.reqOrderItemBoms.length > 0) { const reqOrderItemBoms = this.bomStructureDeal(postData.reqOrderItemBoms) postData.reqOrderItemBoms = reqOrderItemBoms } else { const reqOrderItems = postData.reqOrderItems const reqOrderItemBoms = reqOrderItems.map((item, index) => { const translate = { parentRowNum: item.rowNum, parentGoodsId: item.goodsId, persistStatus: 'new', parentGoodsCode: '', // item.goodsCode, parentGoodsName: '', // item.goodsDisplayName, childGoodsQty: 1, orderNumUnit: item.orderNumUnitName, mainNumUnit: item.mainNumUnitName, } const newItem = { ...item, ...translate } return newItem }) postData.reqOrderItemBoms = reqOrderItemBoms } return postData } // 子件信息数据结构处理 bomStructureDeal(bomData) { const reqOrderItemBoms = bomData.map((child, index) => { const translate = { baseGoodsOptId: child.baseGoodsOptId, baseGoodsOptValue: child.baseGoodsOptValue, rowNum: (index + 1) * 10, parentRowNum: child.parentRowNum, parentGoodsId: child.parentGoodsId, parentGoodsName: child.parentGoodsName, mainNum: '', goodsName: child.childGoodsName, goodsCode: child.childGoodsCode, goodsId: child.childGoodsId, version: child.childGoodsVersion, measurementUnitId: child.childGoodsUnitId, measurementUnitCode: child.childGoodsUnitCode, measurementUnitName: child.childGoodsUnitName, orderNumUnitId: child.childGoodsUnitId, orderNumUnitCode: child.childGoodsUnitCode, orderNumUnitName: child.childGoodsUnitName, orderNum: child.childGoodsQty, childGoodsQty: child.childGoodsQty, // persistStatus: 'new', mainNumUnit: child.childGoodsUnitName, } return translate }) return reqOrderItemBoms } // 订单提交暂存 async editFinish(ident) { let isReturnTab = false, result = [], flag = false, errReturn = false, editSubmlitData = this.props.navigation.state.params.comefrom == 'temporarily' ? this.getOrderFromList() : this.getOrderData() //运输方式为必选项 if(!editSubmlitData.transportModeId) { this.toast = Toast.show("请选择一种运输方式",{position : toastHeight}); return; } editSubmlitData = this.fillGoodsBomInfo(editSubmlitData) if (this.props.creditData && this.props.creditData.length > 0) { let alertText = [] this.props.creditData.map(item => { if (item.thisProdLineAmount > item.creditBalance) { alertText.push(item.productLineName) flag = true } }) if (flag) { this.toast = Toast.show(`${alertText.join(',')}金额超过信用余额`, { position: toastHeight, }) } } if (ident === 'Temporary') { // 暂存提交 this.setState({ temporaryLoading: true }) result = await authService.temporaryOrder(editSubmlitData).catch(err => { this.setState({ temporaryLoading: false }) errReturn = true if (this.toast) { Toast.hide(this.toast) } this.toast = Toast.show(err.message, { position: toastHeight }) console.log( err, '-----订单编辑-暂存订单报错的完整信息' + '\n' + '具体错误显示--->' + err.response.data.message ) }) this.setState({ temporaryLoading: false }) } else if (ident === 'Submit') { //补充商品行 editSubmlitData = this.transportPromData(editSubmlitData) if (this.state.payWayDef.code == 'PayFirst') { // 在线支付 需要把errReturn设置成false this.setState({ temporaryLoading: true }) result = await authService .temporaryOrder(editSubmlitData) .catch(err => { this.setState({ temporaryLoading: false }) errReturn = false this.toast = Toast.show(err.message, { position: toastHeight }) console.log( err, '-----订单编辑-暂存订单报错的完整信息' + '\n' + '具体错误显示--->' + err.response.data.message ) }) this.setState({ temporaryLoading: false }) this.props.dispatch( NavigationActions.navigate({ routeName: 'OrderPay', params: { submitData: { id: result.data.id }, totalAmount: result.data.totalDealAmount, callBack: () => { this.props.dispatch( NavigationActions.navigate({ routeName: 'OrderHome', }) ) }, }, }) ) } else { this.setState({ submitLoading: true }) result = await authService.postOrder(editSubmlitData).catch(err => { this.setState({ submitLoading: false }) errReturn = true this.toast = Toast.show(err.response.data.message + ";开始暂存订单!", { position: toastHeight }) this.editFinish("Temporary") console.log( err, '-----订单编辑-提交订单报错的完整信息' + '\n' + '具体错误显示||--->:' + err.response.data.message ) }) this.setState({ submitLoading: false }) } } // 请求数据报错,则不进行下一步 if (!errReturn) { if (result.data && Object.keys(result.data).length > 0) { isReturnTab = true } if (isReturnTab) { if ( this.props.navigation.state.params.cartId && this.props.navigation.state.params.cartId.length > 0 ) { this.props.navigation.state.params.cartId.forEach(item => { this.props.dispatch( createAction('shoppingcart/deleteShop')({ params: { id: item, customer: CUSTOMERINFO.id, }, }) ) }) } // 返回OrderHome this.props.dispatch( NavigationActions.navigate({ routeName: 'OrderHome', action: NavigationActions.navigate({ routeName: 'OrderHome' }), }) ) } } } // 头部 header() { return ( this.props.dispatch(NavigationActions.back())} > 返回 订单编辑 this.setState({ activeAllCollaps: !this.state.activeAllCollaps, }) // this._info.setActive() } > 折叠 ) } // 供应商 supplier(supplierDefault) { return ( {supplierDefault.SaleOrSupplierName} ) } // 底部按钮 bottomTouch() { let touchArr = [], touchAtt = [ { touchName: '暂存', background: '#FFF', textColor: '#666', loading: this.state.temporaryLoading, itemonpress: () => { this.editFinish('Temporary') }, }, { touchName: '提交', background: '#E70013', textColor: '#FFF', loading: this.state.submitLoading, itemonpress: () => { this.editFinish('Submit') }, }, ] for (let i = 0; i < touchAtt.length; i++) { if (touchAtt[i].loading) { touchArr.push( touchAtt[i].itemonpress()} key={i} style={{ flex: 1, backgroundColor: touchAtt[i].background, justifyContent: 'center', borderRightColor: '#eee', borderRightWidth: 1 / PixelRatio.get(), }} > ) } else { touchArr.push( touchAtt[i].itemonpress()} key={i} style={{ flex: 1, backgroundColor: touchAtt[i].background, justifyContent: 'center', borderRightColor: '#eee', borderRightWidth: 1 / PixelRatio.get(), }} > {touchAtt[i].touchName} ) } } return touchArr } // 运输方式、结算方式等 viewRender(data, inputTextLOck) { let viewRen = [], size = 16 for (let i = 0; i < data.length; i++) { if (data[i].iconName == 'icon-icon-jianjinzhishiqi') { size = 24 } viewRen.push( data[i].onPress()} style={{ paddingVertical: 10, paddingLeft: 10, paddingRight: data[i].iconName == 'icon-icon-jianjinzhishiqi' ? 3 : 10, flexDirection: 'row', justifyContent: 'space-between', borderBottomColor: '#EEE', borderBottomWidth: 1 / PixelRatio.get(), }} > {data[i].viewName} {data[i].rightName} {/* 折叠 */} {data[i].dataArr && (data[i].dataArr || []).map((item, key) => ( { if (data[i].viewName == '运输方式') { this.props.dispatch( createAction('mine/TransportSetstate')(item) ) this.setState({ transportSel: item.name }) // this.setState({ transportVal: item }); } else if (data[i].viewName == '结算方式') { this.props.dispatch( createAction('mine/BillwaySetstate')(item) ) this.setState({ billWaySel: item.name }) // this.setState({ billWay: item }); } else if (data[i].viewName == '支付方式') { this.setState({ payWayDef: item, paySel: item.name }) } // 继续写发票和发货日期的更新值 // else if(){} // 收起折叠板 this.setState({ activeMethod: 'fjidos' }) }} key={key} style={{ flexDirection: 'row', justifyContent: 'space-between', padding: 10, }} > {item.name || ''} {data[i].viewName == '支付方式' ? ( this.state.paySel == (this.state.paySel == 0 ? key : item.name) ? ( ) : null ) : data[i].viewName == '运输方式' ? ( this.state.transportSel == (this.state.transportSel == 0 ? key : item.name) ? ( ) : null ) : this.state.billWaySel == (this.state.billWaySel == 0 ? key : item.name) ? ( ) : null} ))} {!inputTextLOck ? null : ( {data[i].inputName} { this.setState({ remark: e }) }} /> )} ) } return viewRen } // 地址回调 callback(e) { this.props.dispatch(createAction('mine/AdressSetstate')(e.item)) // this.setState({ addressDefault: e.item }); } // 发票回调 invoiceCallback(e) { this.props.dispatch(createAction('mine/InvoiceSetstate')(e)) } async TimeAndroid() { const { action, year, month, day } = await DatePickerAndroid.open({ date: new Date(), minDate: new Date(), mode: 'spinner', }) if (action !== DatePickerAndroid.dismissedAction) { this.setState({ deliveryTime: moment( `${year}-${month + 1}-${day}`, 'YYYY-MM-DD' ).format('YYYY-MM-DD'), }) // 这里开始可以处理用户选好的年月日三个参数:year, month (0-11), day } } // 清除费用冲抵 输入框 ClearOffset() { //this.AverageRef.setClear() this.setState({ giftSelected: [] }) } async combinedFn(init, item, nv) { this.ClearOffset() if (!init) { this.state.EditPromData[item].orderNum = nv this.state.EditPromData[item].mainNum = accMul( this.state.EditPromData[item].orderNum, this.state.EditPromData[item].conversionRate ) this.setState({ Loading: true }) // await this.promDispatch(this.state.EditPromData); await this.props.dispatch( createAction('orderedit/getProm')({ promInfo: { customerId: CUSTOMERINFO.id, saleOrgId: this.props.navigation.state.params.SaleOrSupplier .SaleOrSupplierId, isPrimaryChannel: this.props.navigation.state.params.SaleOrSupplier .isPrimaryChannel, reqOrderItems: this.state.EditPromData, }, }) ) // this.creditCheck( // this.props.promData.reqOrderItems || this.state.EditPromData // ) // this.creditCheck(this.props.promData.reqOrderItems); } this.setState({ Loading: false }) this.CountNumFn( init, item, nv, this.props.promData.reqOrderItems || this.state.EditPromData ) // this.CountNumFn(init, item, nv, this.props.promData.reqOrderItems); } CountNumFn(init, item, nv, EditPromData) { // this.ClearOffset(); init ? null : (EditPromData[item].orderNum = nv) // init ? null : (item.orderNum = nv); let amount = 0, totalnum = 0, totoalvolume = 0, totalweight = 0, totalProm = 0 ;(EditPromData || []).map(val => { val.dealPrice = val.promPrice val.offsetAmount = 0 val.mainNum = accMul(val.orderNum, val.conversionRate) // 金额 amount = accAdd( accMul(val.salePrice || val.basePrice, val.mainNum), amount ) // 商品行总促销金额 = 促销价格*主数量 totalProm = accAdd( accSub(accMul(val.promPrice, val.mainNum), val.promAmount || 0), totalProm ) totalnum = accAdd(val.orderNum, totalnum) totoalvolume = accAdd(val.volume, totoalvolume) totalweight += accMul(val.weight, val.mainNum) val.dealAmount = accMul(val.dealPrice, val.mainNum) val.amount = accMul(val.salePrice || val.basePrice, val.mainNum) }) this.setState({ totalAmount: accSub(amount, accSub(amount, totalProm)), totalAmountCopy: accSub(amount, accSub(amount, totalProm)), goodsAmount: amount, totalNum: totalnum, // 促销金额 = 总金额 - 商品行总促销金额 totalPromAmt: accSub(amount, totalProm), totoalVolume: totoalvolume, totalWeight: totalweight, // 每次增加商品行数量 对冲抵总金额初始化 offsetAmount: 0, EditPromData: EditPromData, }) this.addBoomToData() } // 当促7销输入数字后对每行商品进行均摊 AverageBooth(e, MaxOffset) { e = parseFloat(e) let ToffsetAmount = 0, EditPromData = this.state.EditPromData // 冲抵输入框的值大于0,则进行--均摊计算--- if (e > 0 && MaxOffset > 0) { // 计算最大可冲抵金额 if (e >= MaxOffset) { ToffsetAmount = MaxOffset } else { ToffsetAmount = e } if (ToffsetAmount > this.state.totalAmountCopy) { ToffsetAmount = this.state.totalAmountCopy } // 大于1行的商品,遍历n-1个商品,最后一个商品用总冲抵金额减去除最后一行冲抵金额 if (EditPromData.length > 1) { // 商品除最后一行分摊总金额 let subOffset = 0, rowPromAmt = 0 for (let i = 0; i < EditPromData.length - 1; i++) { // 行促销金额存在rowPromAmt中 rowPromAmt = accSub( accMul(EditPromData[i].promPrice, EditPromData[i].mainNum), EditPromData[i].promAmount || 0 ) // 行分摊金额 EditPromData[i].offsetAmount = ScaleUtil( accMul( accDiv(rowPromAmt, this.state.totalAmountCopy), ToffsetAmount ) ) // 计算除最后一行分摊总金额 subOffset = accAdd(EditPromData[i].offsetAmount, subOffset) // 分摊后成交金额 EditPromData[i].dealAmount = ScaleUtil( accSub(rowPromAmt, EditPromData[i].offsetAmount) ) // 根据分摊后成交金额反算成交价格 EditPromData[i].dealPrice = ScaleUtil( accDiv(EditPromData[i].dealAmount, EditPromData[i].mainNum) ) } // 商品最后一行处理 EditPromData[EditPromData.length - 1].offsetAmount = ScaleUtil( accSub(ToffsetAmount, subOffset) ) // 促销金额-冲抵金额 (行) EditPromData[EditPromData.length - 1].dealAmount = ScaleUtil( accSub( accSub( accMul( EditPromData[EditPromData.length - 1].promPrice, EditPromData[EditPromData.length - 1].mainNum ), EditPromData[EditPromData.length - 1].promAmount || 0 ), EditPromData[EditPromData.length - 1].offsetAmount ) ) EditPromData[EditPromData.length - 1].dealPrice = ScaleUtil( accDiv( EditPromData[EditPromData.length - 1].dealAmount, EditPromData[EditPromData.length - 1].mainNum ) ) } else { // 如果只有一行数据 // 则直接进行处理 EditPromData[0].offsetAmount = ToffsetAmount EditPromData[0].dealAmount = ScaleUtil( accSub( accSub( accMul(EditPromData[0].promPrice, EditPromData[0].mainNum), EditPromData[0].promAmount || 0 ), EditPromData[0].offsetAmount ) ) EditPromData[0].dealPrice = ScaleUtil( accDiv(EditPromData[0].dealAmount, EditPromData[0].mainNum) ) } this.setState({ totalAmount: accSub( accSub(this.state.goodsAmount, this.state.totalPromAmt), ToffsetAmount ), offsetAmount: ToffsetAmount, EditPromData: EditPromData, }) } else { // 冲抵输入框为0或者输入框为空 // 则还原各行成交价格/金额 为 销售价格/金额,以及冲抵分摊金额还原为0 ;(EditPromData || []).forEach(val => { val.dealAmount = val.amount val.dealPrice = val.promPrice val.offsetAmount = 0 }) this.setState({ totalAmount: accSub(this.state.goodsAmount, this.state.totalPromAmt), offsetAmount: 0, EditPromData: EditPromData, }) } this.addBoomToData() } //控制弹出层隐藏显示 modalVisible(index) { this.setState({ modalVisible : true, index : index, num : "" }) } //弹出框点击确定 onModalOk() { const {num,index} = this.state; if(!(/(^[1-9]\d*$)/.test(num))) { Toast.show("请输入正确的数量",{position : toastHeight}); return; } this.combinedFn(false,index,num); this.setState({ modalVisible : false }) } promInfo(item) { let promWay = item.promWay == 1 ? '买赠' : '降价' return ( {promWay} {item.description} ) } goodsInfo(item, indexParent) { // let optFlag = true, let optFlag = false, isOptArrs = [] if (item.baseGoodsOptId) { item.isOptional = 1 } item.rowNum = (indexParent + 1) * 10 if (item.isOptional) { isOptArrs.push(item.isOptional) } else if (item.reqOrderItemBoms && item.reqOrderItemBoms.length > 0) { item.reqOrderItemBoms.forEach(data => { isOptArrs.push(data.isOptional) }) } if (isOptArrs.some(smdata => smdata == 1)) { optFlag = true } return ( {/* 满减/买赠 */} item.ruleId} data={item.reqOrderPromRels || []} extraData={this.state} renderItem={({ item, index }) => this.promInfo(item, index)} /> {/* 商品行 */} {item.rowNum}--{item.goodsDisplayName} this.deleteGoodsFn(indexParent)}> 型号:{item.model?(item.model.length>10?item.model.substr(0,10):item.model):""} 规格:{item.specification?(item.specification.split("/")[0]+'/'+item.mainNumUnitName):""} {/* { this.combinedFn(false, indexParent, nv) }} /> */} 数量:{item.mainNum} {item.mainNumUnitName} 重量:{item.weight*item.mainNum}{'KG'} this.modalVisible(indexParent)} > 修改数量 成交价: {CURRENCY.currencySign} {ScaleUtil( item.dealPrice || item.basePrice, CURRENCY.currencyPriceScale )} 成交金额: {CURRENCY.currencySign} {ScaleUtil(item.dealAmount, CURRENCY.currencyAmountScale)} {/* 选配列表 */} {optFlag ? ( {this.optView(item, indexParent, true)} item.id} data={item.reqOrderItemBoms || []} extraData={this.state} renderItem={itemSec => this.reqItemBoms(itemSec.item, itemSec.index, item) } /> item.id} data={item.reqOrderItemBoms || []} extraData={this.state} renderItem={itemSec => this.reqItemBoms(itemSec.item, itemSec.index, item) } /> ) : null} {/* 重量等信息 */} 单价:{CURRENCY.currencySign} {item.salePrice} 金额:{CURRENCY.currencySign} {accMul(item.salePrice || item.basePrice, item.mainNum)} 重量:{item.weight} {item.weightUnit} 体积:{item.volume} {item.volumeUnit} ) } optView(item, indexParent, collaseFlag, isOptional) { const reqBomText = [] if (item.reqOrderItemBoms && item.reqOrderItemBoms.length > 0) { item.reqOrderItemBoms.forEach((data, key) => { reqBomText.push(`子件${NumberTranslate(key)}`) }) } if (collaseFlag || isOptional) { return ( { this.openOptView(item) }} > {reqBomText && reqBomText.length > 0 ? '选配项:' : '选 配:'} 0 ? width * 0.4 : width * 0.75, fontSize: 12, lineHeight: 17, color: '#666', }} > {collaseFlag ? reqBomText && reqBomText.length > 0 ? reqBomText.join() : item.baseGoodsOptValue : item.baseGoodsOptValue} {collaseFlag ? ( {/* { item.reqOrderItemBoms && item.reqOrderItemBoms.length > 0 ? this.state.optCollapse == indexParent ? this.setState({ optCollapse: 'shouqi' }) : this.setState({ optCollapse: indexParent }) : this.optional._openModal(JSON.parse(JSON.stringify(item))) }} style={{ alignSelf: 'center' }} > {item.reqOrderItemBoms && item.reqOrderItemBoms.length > 0 ? ( this.state.optCollapse == indexParent ? ( 收起 ) : ( 展开 ) ) : ( )} */} {item.reqOrderItemBoms && item.reqOrderItemBoms.length > 0 ? ( | { this.optional._openModal( JSON.parse(JSON.stringify(item)), true ) }} > 选配 {/* 批量选配 */} ) : null} ) : null // { // this.optional._openModal(JSON.parse(JSON.stringify(item))); // }} // style={{ alignSelf: "center", paddingRight: 5 }} // > // // } ) } } reqItemBoms(item, index, parentItem) { return ( {`子件${NumberTranslate( index )}:`} {item.childGoodsName} 编码:{item.childGoodsCode} {'v' + item.childGoodsVersion} 数量:{accMul( accMul(parentItem.conversionRate, parentItem.orderNum), item.childGoodsQty )} {' ' + item.childGoodsUnitName} 单价: {CURRENCY.currencySign + accMul( accMul(parentItem.conversionRate, parentItem.orderNum), parentItem.basePrice )} {this.optView(item, index, false, item.isOptional)} ) } promInfoFilter(mutualRelationShip) { let result = [] const basePromInfo = [ { number: 1, name: '买赠-基于商品' }, { number: 2, name: '降价-基于商品' }, { number: 3, name: '买赠-基于订单' }, { number: 4, name: '降价-基于订单' }, ] for (let i = 0; i < mutualRelationShip.length; i++) { let groupArr = [] ;(mutualRelationShip[i] || []).map(valsec => { groupArr = groupArr.concat( basePromInfo.filter(item => item.number == valsec) ) }) result.push(groupArr) } return result } baseOnPromTouch(item) { let Arr = [] ;(item || []).map(val => Arr.push(val.number)) this.props.dispatch( createAction('orderedit/getProm')({ promInfo: { customerId: CUSTOMERINFO.id, promotionStyle: Arr, saleOrgId: this.props.navigation.state.params.SaleOrSupplier .SaleOrSupplierId, isPrimaryChannel: this.props.navigation.state.params.SaleOrSupplier .isPrimaryChannel, reqOrderItems: this.state.EditPromData, }, }) ) this.combinedFn(true) } // 赠品回调 giftCb(e, ids) { const {EditPromData} = this.state; let totalWeight = 0; if(EditPromData && EditPromData.length) { EditPromData.map(data => { totalWeight += data.mainNum*data.weight; }) } if(e && e.length) { e.map(data => { totalWeight += data.mainNum*data.weight }) } this.setState({ giftSelected: e,totalWeight }) } baseOnProm(mutualRelationShip) { if (mutualRelationShip) { this.RelationShipCopy = mutualRelationShip } else { mutualRelationShip = this.RelationShipCopy } let basePromInfo = this.promInfoFilter(mutualRelationShip) let basePromData = [] for (let i = 0; i < basePromInfo.length; i++) { ;(basePromInfo[i] || []).map((data, index) => basePromData.push( { this.state.baseIndex == i ? {} : this.setState({ baseIndex: i }) this.baseOnPromTouch(basePromInfo[i]) }} > {data.name || ''} ) ) } return ( {basePromData} ) } checkCast(castRateData) { let financeOrgIds = [], flag = true, productLineIds = Array.from(new Set(this.state.productLineIds)), returnData = {} productLineIds.forEach(lineId => { castRateData.forEach(castitem => { if ( castitem.productLineIds.length == 1 && !castitem.productLineIds[0] ) { flag = false returnData = castitem } else if (castitem.productLineIds.indexOf(lineId) != -1) { financeOrgIds.push(castitem.financeOrgId) } }) }) if (financeOrgIds.length == 1 && flag) { castRateData.forEach(item => { if (item.financeOrgId == financeOrgIds[0]) { returnData = item } }) } return returnData } render() { const { addressDefault, transportData, transportDefault, billwayData, billwayDefault, invoiceDefault, castRateData, promData, creditData, orderPayStatus, } = this.props const supplierDefault = this.props.navigation.state.params.SaleOrSupplier let MaxOffset = 0, castRateDataOnly = { costOffsetRatio: 0, supplyMaxOccupyMny: 0 } if ( castRateData && castRateData.length > 0 && this.state.productLineIds && this.state.productLineIds.length > 0 ) { let checkCastReturn = this.checkCast(castRateData) if (Object.keys(checkCastReturn).length > 0) { castRateDataOnly = checkCastReturn } if ( accMul(this.state.goodsAmount, castRateDataOnly.costOffsetRatio) >= castRateDataOnly.supplyMaxOccupyMny ) { MaxOffset = castRateDataOnly.supplyMaxOccupyMny } else { MaxOffset = accMul( this.state.goodsAmount, castRateDataOnly.costOffsetRatio ) } if (MaxOffset >= this.state.totalAmountCopy) { MaxOffset = this.state.totalAmountCopy } } return ( {/* 头部 */} {this.header()} { // // 判断圆形按钮滑动前后是否变化控制刷新 // if (this.cicleActive == this.state.cicleActive) { // this.setState({ cicleActive: false }); // this.cicleActive = this.state.cicleActive; // } // }} // onScrollEndDrag={() => this.setState({ cicleActive: true })} // onMomentumScrollEnd={() => this.setState({ cicleActive: true })} > {/* 供应商显示 */} {this.supplier(supplierDefault)} {/*选项行*/} {this.viewRender([ { viewName: '运输方式', rightName: (transportDefault && transportDefault.name) || '铁路运输', iconName: 'icon-icon-xiala', onPress: () => { this.state.activeMethod == 0 ? this.setState({ activeMethod: 'nfjdsjf' }) : this.setState({ activeMethod: 0 }) }, dataArr: transportData || [], }, // { // viewName: '结算方式', // rightName: (billwayDefault && billwayDefault.name) || '现金', // iconName: 'icon-icon-xiala', // onPress: () => { // this.state.activeMethod == 1 // ? this.setState({ activeMethod: 'nfjdsjf' }) // : this.setState({ activeMethod: 1 }) // }, // dataArr: billwayData || [], // }, // { // viewName: '支付方式', // rightName: this.state.payWayDef && this.state.payWayDef.name, // iconName: 'icon-icon-xiala', // onPress: () => { // this.state.activeMethod == 2 // ? this.setState({ activeMethod: 'nfjdsjf' }) // : this.setState({ activeMethod: 2 }) // }, // dataArr: orderPayStatus || [], // }, ])} {this.viewRender([ { viewName: '发票', rightName: (invoiceDefault && invoiceDefault.invoiceTitle) || '发票', iconName: 'icon-icon-jianjinzhishiqi', onPress: () => this.props.dispatch( NavigationActions.navigate({ routeName: 'SelectInvoice', params: e => this.invoiceCallback(e), }) ), }, ])} {/* {this.viewRender( [ { viewName: '期望到货日期', rightName: this.state.deliveryTime, iconName: 'icon-icon-xiala', onPress: () => Platform.OS == 'ios' ? this.showTime._openModal() : this.TimeAndroid(), inputName: '备注', inputDefault: this.state.remark || '备注订单内容', inputValue: '', }, ], true )} */} {/* 选地址 */} this.props.dispatch( NavigationActions.navigate({ routeName: 'SelectAdress', params: e => this.callback(e), }) ) } style={{ backgroundColor: '#FFF', marginTop: 10, flexDirection: 'row', paddingTop: 10, paddingBottom: 5, }} > {addressDefault && addressDefault.receiver} {addressDefault && addressDefault.receiverPhone} {((addressDefault && addressDefault.receiverProvince) || '') + ((addressDefault && addressDefault.receiverCity) || '') + ((addressDefault && addressDefault.receiverDistrict) || '') + ((addressDefault && addressDefault.receiverTown) || '') + ((addressDefault && addressDefault.receiverAddress) || '')} {/* Image地址下边框 */} {/* 基于原单或基于商品数量选项 */} {promData.mutualRelationShip ? this.baseOnProm(promData.mutualRelationShip) : null} {/* 商品信息 */} {this.state.Loading ? ( ) : ( item.goodsId} data={this.state.EditPromData} extraData={this.state} renderItem={({ item, index }) => this.goodsInfo(item, index)} /> )} {/* 赠品明细 */} {promData && promData.giftProms && promData.giftProms.length > 0 ? ( { let NavigateGift = JSON.parse(JSON.stringify(promData.giftProms)) || [] ;(NavigateGift || []).map(item => { item.data = item.giftDtos delete item.giftDtos }) this.props.dispatch( NavigationActions.navigate({ routeName: 'OrderGifts', params: { giftProms: NavigateGift, giftCb: (e, ids) => this.giftCb(e, ids), }, }) ) }} style={{ paddingBottom: 6, flexDirection: 'row', justifyContent: 'space-between', }} > 赠品明细 选择赠品 {this.state.giftSelected.length > 0 ? ( index} data={this.state.giftSelected} extraData={this.state} style={{ paddingBottom: 10, borderTopColor: '#EEE', borderTopWidth: 1 / PixelRatio.get(), }} renderItem={({ item, index }) => ( {item.goodsDisplayName} {item.mainNum || 1} )} /> ) : null} ) : null} {/* 总体积、数量 */} 总重量 {this.state.totalWeight}{"KG"} {/* {this.state.weightUnit} */} {/* 总体积 {this.state.totoalVolume} {this.state.volumeUnit} */} {/* 金额显示 */} 商品金额: {CURRENCY.currencySign} {ScaleUtil( this.state.goodsAmount, CURRENCY.currencyAmountScale )} 促销金额: {CURRENCY.currencySign} {this.state.totalPromAmt} {/* 费用冲抵: (this.AverageRef = AverageRef)} keyboardType={'numeric'} isICon={false} blurOnSubmit={true} placeholder={''} textInputBacg={'#FFF'} placeholderTextColor={'#CCC'} onchangeFn={e => this.AverageBooth(e, MaxOffset)} maxNum={MaxOffset} /> */} {/* (本次最高冲抵: {CURRENCY.currencySign} {ScaleUtil(MaxOffset, CURRENCY.currencyAmountScale)} 费用总金额: {CURRENCY.currencySign} {ScaleUtil( castRateDataOnly.supplyMaxOccupyMny || 0, CURRENCY.currencyAmountScale )} ) */} {/* { this.credit._openModal(creditData) this.setState({ creditShow: true }) }} > 信用查询 */} 订单总金额: {CURRENCY.currencySign}{' '} {ScaleUtil( this.state.totalAmount, CURRENCY.currencyAmountScale )} 备注: this.setState({remark:text})} underlineColorAndroid="transparent" /> { this.setState({ showOptModal: false }) }} > {this.state.optLoading ? ( ) : 选择颜色 { this.setState({ showOptModal: false }) }}> 0 ? this.state.optionData[0].id : ""}]} chooseColor={this._chooseColor.bind(this)}/> } { console.log('close'); }} > 请输入商品数量 this.setState({num:text})} value={this.state.num} /> this.onModalOk()} > 确定 this.setState({modalVisible:false})} > 取消 {/* 信用弹窗 */} (this.credit = credit)} cb={() => this.setState({ creditShow: false })} /> (this.optional = optional)} onPressBom={() => { this.addBoomToData() }} // 选配回调处理(将选择的选配结果返回 加到商品行上) optCb={data => { this.state.EditPromData.forEach(item => { let allOptIds = '', allOptVals = '' if (item.reqOrderItemBoms && item.reqOrderItemBoms.length > 0) { item.reqOrderItemBoms.forEach(itemSec => { data.forEach(itemTh => { if (itemSec.childGoodsId == itemTh.goodsId) { itemSec.baseGoodsOptId = itemTh.optIds itemSec.baseGoodsOptValue = itemTh.optVals if (allOptIds && allOptIds.length > 0) { allOptIds = allOptIds.concat( ',' + itemSec.baseGoodsOptId ) allOptVals = allOptVals.concat( ',' + itemSec.baseGoodsOptValue ) } else { allOptIds = itemSec.baseGoodsOptId allOptVals = itemSec.baseGoodsOptValue } } }) }) } else { data.forEach(dataFt => { if (dataFt.goodsId == item.goodsId) { allOptIds = dataFt.optIds allOptVals = dataFt.optVals } }) } item.baseGoodsOptId = allOptIds item.baseGoodsOptValue = allOptVals }) this.addBoomToData() this.setState({ EditPromData: this.state.EditPromData }) }} /> {/* 时间弹窗 */} (this.showTime = showTime)} cb={date => { this.setState({ deliveryTime: moment(date).format('YYYY-MM-DD'), }) }} /> {/* 底部 */} {this.bottomTouch()} {/* 信用弹窗毛玻璃效果 */} {/* {this.state.creditShow ? ( ) : null} */} ) } } const styles = StyleSheet.create({ container: { flex: 1, }, text333: { fontSize: 14, lineHeight: 20, letterSpacing: 0.17, color: '#333', }, text666: { fontSize: 13, lineHeight: 18, color: '#666', }, text666red: { fontSize: 14, lineHeight: 25, color: '#E14C46', }, text999: { fontSize: 12, lineHeight: 17, color: '#999', }, bomTitle: { fontSize: 13, lineHeight: 18, color: '#333', }, bomText: { fontSize: 12, lineHeight: 17, color: '#666', }, modalStyle: { } }) export default OrderEdit