1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659 |
- 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 })
- 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 (
- <View
- style={{
- height: HEADERSTYLE.height,
- paddingTop: HEADERSTYLE.paddingTop + 5,
- backgroundColor: '#fff',
- borderBottomColor: '#eee',
- borderBottomWidth: 1 / PixelRatio.get(),
- }}
- >
- <View
- style={{
- flex: 1,
- justifyContent: 'center',
- }}
- >
- <TouchableOpacity
- style={{ position: 'absolute', left: 10, flexDirection: 'row' }}
- onPress={() => this.props.dispatch(NavigationActions.back())}
- >
- <Icon
- name="icon-icon-fanhui"
- size={20}
- color={'#666'}
- style={{ marginTop: 4 }}
- />
- <Text
- style={{
- fontSize: 14,
- lineHeight: 20,
- color: '#666',
- alignSelf: 'center',
- }}
- >
- 返回
- </Text>
- </TouchableOpacity>
- <Text
- style={{
- alignSelf: 'center',
- fontSize: 18,
- lineHeight: 25,
- letterSpacing: 0.19,
- color: '#333',
- }}
- >
- 订单编辑
- </Text>
- <TouchableOpacity
- style={{ position: 'absolute', right: 10 }}
- onPress={
- () =>
- this.setState({
- activeAllCollaps: !this.state.activeAllCollaps,
- })
- // this._info.setActive()
- }
- >
- <Text
- style={{
- fontSize: 14,
- lineHeight: 20,
- letterSpacing: 0.17,
- color: '#666',
- }}
- >
- 折叠
- </Text>
- </TouchableOpacity>
- </View>
- </View>
- )
- }
- // 供应商
- supplier(supplierDefault) {
- return (
- <View
- style={{
- backgroundColor: '#FFF',
- padding: 10,
- flexDirection: 'row',
- borderBottomColor: '#eee',
- borderBottomWidth: 1,
- }}
- >
- <Text
- style={{
- fontSize: 14,
- lineHeight: 20,
- letterSpacing: 0.17,
- color: '#333',
- fontWeight: '600',
- }}
- >
- {supplierDefault.SaleOrSupplierName}
- </Text>
- </View>
- )
- }
- // 底部按钮
- 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(
- <View
- onPress={() => touchAtt[i].itemonpress()}
- key={i}
- style={{
- flex: 1,
- backgroundColor: touchAtt[i].background,
- justifyContent: 'center',
- borderRightColor: '#eee',
- borderRightWidth: 1 / PixelRatio.get(),
- }}
- >
- <ActivityIndicator />
- </View>
- )
- } else {
- touchArr.push(
- <TouchableOpacity
- disabled={
- this.state.temporaryLoading || this.state.submitLoading
- ? true
- : false
- }
- onPress={() => touchAtt[i].itemonpress()}
- key={i}
- style={{
- flex: 1,
- backgroundColor: touchAtt[i].background,
- justifyContent: 'center',
- borderRightColor: '#eee',
- borderRightWidth: 1 / PixelRatio.get(),
- }}
- >
- <Text
- style={{
- fontSize: 14,
- lineHeight: 20,
- color: touchAtt[i].textColor,
- alignSelf: 'center',
- }}
- >
- {touchAtt[i].touchName}
- </Text>
- </TouchableOpacity>
- )
- }
- }
- 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(
- <View key={i}>
- <TouchableOpacity
- onPress={() => 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(),
- }}
- >
- <Text style={styles.text333}>{data[i].viewName}</Text>
- <View style={{ flexDirection: 'row' }}>
- <Text
- style={{
- fontSize: 14,
- lineHeight: 20,
- color: '#666',
- marginRight: 10,
- }}
- >
- {data[i].rightName}
- </Text>
- <Icon name={data[i].iconName} size={size} color={'#ccc'} />
- </View>
- </TouchableOpacity>
- {/* 折叠 */}
- <Collapsible collapsed={i !== this.state.activeMethod}>
- {data[i].dataArr &&
- (data[i].dataArr || []).map((item, key) => (
- <TouchableOpacity
- onPress={() => {
- 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,
- }}
- >
- <Text
- style={{
- fontSize: 14,
- lineHeight: 20,
- color: '#666',
- }}
- >
- {item.name || ''}
- </Text>
- {data[i].viewName == '支付方式' ? (
- this.state.paySel ==
- (this.state.paySel == 0 ? key : item.name) ? (
- <Icon
- name={'icon-icon-duigou'}
- size={16}
- color={'#E14C46'}
- style={{ marginRight: 30 }}
- />
- ) : null
- ) : data[i].viewName == '运输方式' ? (
- this.state.transportSel ==
- (this.state.transportSel == 0 ? key : item.name) ? (
- <Icon
- name={'icon-icon-duigou'}
- size={16}
- color={'#E14C46'}
- style={{ marginRight: 30 }}
- />
- ) : null
- ) : this.state.billWaySel ==
- (this.state.billWaySel == 0 ? key : item.name) ? (
- <Icon
- name={'icon-icon-duigou'}
- size={16}
- color={'#E14C46'}
- style={{ marginRight: 30 }}
- />
- ) : null}
- </TouchableOpacity>
- ))}
- </Collapsible>
- {!inputTextLOck ? null : (
- <View
- style={{
- paddingHorizontal: 10,
- paddingBottom: 3,
- flexDirection: 'row',
- }}
- >
- <Text style={[styles.text333, { alignSelf: 'center' }]}>
- {data[i].inputName}
- </Text>
- <Input
- style={{
- marginTop: 4,
- width: width / 1.15,
- }}
- isICon={false}
- blurOnSubmit={true}
- textInputBacg={'#FFF'}
- placeholder={data[i].inputDefault}
- placeholderTextColor={'#CCC'}
- onchangeFn={e => {
- this.setState({ remark: e })
- }}
- />
- </View>
- )}
- </View>
- )
- }
- 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 (
- <View>
- <View style={{ flex: 1, flexDirection: 'row', marginTop: 10 }}>
- <View
- style={{
- paddingHorizontal: 4,
- paddingVertical: 2,
- borderRadius: 100,
- backgroundColor: '#E70013',
- marginRight: 14,
- alignSelf: 'center',
- }}
- >
- <Text style={{ fontSize: 12, lineHeight: 14, color: '#FFF' }}>
- {promWay}
- </Text>
- </View>
- <Text
- numberOfLines={3}
- style={{ flex: 1, fontSize: 12, lineHeight: 17, color: '#333' }}
- >
- {item.description}
- </Text>
- </View>
- </View>
- )
- }
- goodsInfo(item, indexParent) {
- // let optFlag = true,
- let optFlag = false,
- isOptArrs = []
- if (item.baseGoodsOptId) {
- item.isOptional = 1
- }
- 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 (
- <View>
- <View style={{ padding: 10, marginTop: 10, backgroundColor: '#FFF' }}>
- {/* 满减/买赠 */}
- <View style={{ paddingBottom: 10 }}>
- <FlatList
- keyExtractor={item => item.ruleId}
- data={item.reqOrderPromRels || []}
- extraData={this.state}
- renderItem={({ item, index }) => this.promInfo(item, index)}
- />
- </View>
- {/* 商品行 */}
- <View style={{ flexDirection: 'row' }}>
- <Image
- source={{ uri: ImageBaseUrl + item.goodsImg } || png}
- style={{ width: 80, height: 80 }}
- />
- <View style={{ marginLeft: 10, flex: 1 }}>
- <View style={{flexDirection:'row'}}>
- <Text style={{ fontSize: 13, lineHeight: 18, color: '#333',width:'90%' }}>
- {item.goodsDisplayName}
- </Text>
- <TouchableOpacity onPress={() =>this.deleteGoodsFn(indexParent)}>
- <Image
- source={deletePng}
- style={{ width: 20, height: 20}}
- />
- </TouchableOpacity>
- </View>
- <View
- style={{
- flexDirection: 'row',
- justifyContent: 'space-between',
- marginTop: 10,
- }}
- >
- <Text style={{ fontSize: 12, lineHeight: 17, color: '#666' }}>
- 型号:{item.model?(item.model.length>10?item.model.substr(0,10):item.model):""}
- </Text>
- </View>
- <View
- style={{
- flexDirection: 'row',
- justifyContent: 'space-between',
- marginTop: 10,
- }}
- >
- <Text style={{ fontSize: 12, lineHeight: 17, color: '#666' }}>
- 规格:{item.specification?(item.specification.split("/")[0]+'/'+item.mainNumUnitName):""}
- </Text>
- </View>
- <View
- style={{
- flexDirection: 'row',
- justifyContent: 'space-between',
- marginTop: 7,
- }}
- >
- {/* <CountNum
- defaultValue={item.orderNum}
- size={25}
- callback={nv => {
- this.combinedFn(false, indexParent, nv)
- }}
- /> */}
- <Text style={{ fontSize: 12, lineHeight: 17, color: '#666' }}>
- 数量:{item.mainNum} {item.mainNumUnitName}
- </Text>
- <Text style={{ fontSize: 12, lineHeight: 17, color: '#666' }}>
- 重量:{item.weight*item.mainNum}{'KG'}
- </Text>
- </View>
- <View style={{
- flexDirection: 'row',
- justifyContent: 'space-between',
- marginTop: 7,
- }}>
- <TouchableOpacity
- style={{
- backgroundColor : '#E70013',
- borderRadius : 100,
- }}
- onPress={() =>this.modalVisible(indexParent)}
- >
- <Text style={{fontSize:12,color:'#fff',padding:5}}>修改数量</Text>
- </TouchableOpacity>
- </View>
- </View>
- </View>
- <View
- style={{
- flexDirection: 'row',
- justifyContent: 'space-between',
- marginTop: 10,
- }}
- >
- <Text style={{ fontSize: 12, lineHeight: 17, color: '#666' }}>
- 成交价:<Text
- style={{ fontSize: 14, lineHeight: 17, color: '#E14C46' }}
- >
- {CURRENCY.currencySign}
- {ScaleUtil(
- item.dealPrice || item.basePrice,
- CURRENCY.currencyPriceScale
- )}
- </Text>
- </Text>
- <Text style={{ fontSize: 12, lineHeight: 17, color: '#666' }}>
- 成交金额:<Text
- style={{ fontSize: 14, lineHeight: 17, color: '#E14C46' }}
- >
- {CURRENCY.currencySign}
- {ScaleUtil(item.dealAmount, CURRENCY.currencyAmountScale)}
- </Text>
- </Text>
- </View>
- </View>
- {/* 选配列表 */}
- {optFlag ? (
- <View
- style={{
- backgroundColor: '#FFF',
- borderTopColor: '#EEE',
- borderTopWidth: 1 / PixelRatio.get(),
- }}
- >
- {this.optView(item, indexParent, true)}
- <FlatList
- keyExtractor={item => item.id}
- data={item.reqOrderItemBoms || []}
- extraData={this.state}
- renderItem={itemSec =>
- this.reqItemBoms(itemSec.item, itemSec.index, item)
- }
- />
- <Collapsible collapsed={this.state.optCollapse != indexParent}>
- <FlatList
- keyExtractor={item => item.id}
- data={item.reqOrderItemBoms || []}
- extraData={this.state}
- renderItem={itemSec =>
- this.reqItemBoms(itemSec.item, itemSec.index, item)
- }
- />
- </Collapsible>
- </View>
- ) : null}
- {/* 重量等信息 */}
- <Collapsible collapsed={this.state.activeAllCollaps}>
- <View style={{ padding: 10, backgroundColor: '#FAFAFA' }}>
- <View
- style={{ flexDirection: 'row', justifyContent: 'space-between' }}
- >
- <Text style={styles.text666}>
- 单价:{CURRENCY.currencySign}
- {item.salePrice}
- </Text>
- <Text style={styles.text666}>
- 金额:{CURRENCY.currencySign}
- {accMul(item.salePrice || item.basePrice, item.mainNum)}
- </Text>
- </View>
- <View
- style={{
- flexDirection: 'row',
- justifyContent: 'space-between',
- marginTop: 3,
- }}
- >
- <Text style={styles.text666}>
- 重量:{item.weight}
- {item.weightUnit}
- </Text>
- <Text style={styles.text666}>
- 体积:{item.volume}
- {item.volumeUnit}
- </Text>
- </View>
- </View>
- </Collapsible>
- </View>
- )
- }
- 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 (
- <View
- style={{
- padding: 10,
- flexDirection: 'row',
- justifyContent: 'space-between',
- }}
- >
- <TouchableOpacity
- activeOpacity={1}
- onPress={() => {
- this.openOptView(item)
- }}
- >
- <View style={{ flexDirection: 'row' }}>
- <Text style={{ fontSize: 12, lineHeight: 17, color: '#333' }}>
- {reqBomText && reqBomText.length > 0 ? '选配项:' : '选 配:'}
- </Text>
- <Text
- numberOfLines={1}
- style={{
- width:
- reqBomText && reqBomText.length > 0
- ? width * 0.4
- : width * 0.75,
- fontSize: 12,
- lineHeight: 17,
- color: '#666',
- }}
- >
- {collaseFlag
- ? reqBomText && reqBomText.length > 0
- ? reqBomText.join()
- : item.baseGoodsOptValue
- : item.baseGoodsOptValue}
- </Text>
- <Image
- resizeMode="contain"
- source={morePng}
- style={{ width: 24, height: 5, alignSelf: 'center' }}
- />
- </View>
- </TouchableOpacity>
- {collaseFlag ? (
- <View style={{ flexDirection: 'row' }}>
- {/* <TouchableOpacity
- onPress={() => {
- 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 ? (
- <Text
- style={{ fontSize: 12, lineHeight: 17, color: '#333' }}
- >
- 收起
- </Text>
- ) : (
- <Text
- style={{ fontSize: 12, lineHeight: 17, color: '#333' }}
- >
- 展开
- </Text>
- )
- ) : (
- <Image source={moreDian} style={{ width: 24, height: 5 }} />
- )}
- </TouchableOpacity> */}
- {item.reqOrderItemBoms && item.reqOrderItemBoms.length > 0 ? (
- <View style={{ flexDirection: 'row' }}>
- <Text
- style={{ marginLeft: 8, marginRight: 8, color: '#DDD' }}
- >
- |
- </Text>
- <TouchableOpacity
- onPress={() => {
- this.optional._openModal(
- JSON.parse(JSON.stringify(item)),
- true
- )
- }}
- >
- <Text
- style={{ fontSize: 12, lineHeight: 17, color: '#333' }}
- >
- 选配
- {/* 批量选配 */}
- </Text>
- </TouchableOpacity>
- </View>
- ) : null}
- </View>
- ) : null
- // <TouchableOpacity
- // onPress={() => {
- // this.optional._openModal(JSON.parse(JSON.stringify(item)));
- // }}
- // style={{ alignSelf: "center", paddingRight: 5 }}
- // >
- // <Image source={moreDian} style={{ width: 24, height: 5 }} />
- // </TouchableOpacity>
- }
- </View>
- )
- }
- }
- reqItemBoms(item, index, parentItem) {
- return (
- <View>
- <View
- style={{
- paddingTop: 10,
- paddingHorizontal: 10,
- paddingBottom: item.isOptional ? 0 : 10,
- borderTopColor: '#EEE',
- borderTopWidth: 1 / PixelRatio.get(),
- }}
- >
- <View style={{ flexDirection: 'row' }}>
- <View>
- <Text style={styles.bomTitle}>{`子件${NumberTranslate(
- index
- )}:`}</Text>
- </View>
- <View style={{ flex: 1 }}>
- <Text style={styles.bomTitle}>{item.childGoodsName}</Text>
- <View style={{ flexDirection: 'row', marginTop: 10 }}>
- <Text style={styles.bomText}>编码:{item.childGoodsCode}</Text>
- <Text style={[styles.bomText, { marginLeft: 10 }]}>
- {'v' + item.childGoodsVersion}
- </Text>
- </View>
- <View
- style={{
- flexDirection: 'row',
- justifyContent: 'space-between',
- marginTop: 1,
- }}
- >
- <Text style={styles.bomText}>
- 数量:{accMul(
- accMul(parentItem.conversionRate, parentItem.orderNum),
- item.childGoodsQty
- )}
- {' ' + item.childGoodsUnitName}
- </Text>
- <Text style={styles.bomText}>
- 单价:<Text style={{ color: '#E70013' }}>
- {CURRENCY.currencySign +
- accMul(
- accMul(parentItem.conversionRate, parentItem.orderNum),
- parentItem.basePrice
- )}
- </Text>
- </Text>
- </View>
- </View>
- </View>
- </View>
- <View>{this.optView(item, index, false, item.isOptional)}</View>
- </View>
- )
- }
- 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(
- <TouchableOpacity
- key={index + data.name ? data.name : ''}
- style={{ flexDirection: 'row', width: width / 2 - 10 }}
- onPress={() => {
- this.state.baseIndex == i ? {} : this.setState({ baseIndex: i })
- this.baseOnPromTouch(basePromInfo[i])
- }}
- >
- <Icon
- name={
- this.state.baseIndex == i
- ? 'icon-icon-danxuankuang-xuanzhong'
- : 'icon-icon-danxuankuang-weixuanzhong'
- }
- size={26}
- color={this.state.baseIndex == i ? '#E14C46' : '#CCC'}
- />
- <Text
- style={{
- marginLeft: 5,
- fontSize: 13,
- lineHeight: 17,
- color: '#333',
- alignSelf: 'center',
- marginBottom: 1,
- }}
- >
- {data.name || ''}
- </Text>
- </TouchableOpacity>
- )
- )
- }
- return (
- <View
- style={{
- backgroundColor: '#FFF',
- marginTop: 10,
- paddingVertical: 7,
- paddingHorizontal: 10,
- flexDirection: 'row',
- flexWrap: 'wrap',
- }}
- >
- {basePromData}
- </View>
- )
- }
- 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 (
- <View
- style={[
- styles.container,
- { backgroundColor: '#F7F7F7' },
- // { backgroundColor: appTheme.backgroundColor }
- ]}
- >
- <StatusBar
- animated={true}
- // barStyle={appTheme.barStyle}
- barStyle={'dark-content'}
- backgroundColor={'transparent'}
- translucent={true}
- />
- {/* 头部 */}
- {this.header()}
- <ScrollView
- style={{ flex: 1 }}
- // scrollEventThrottle={200}
- // onScroll={() => {
- // // 判断圆形按钮滑动前后是否变化控制刷新
- // 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)}
- {/*选项行*/}
- <View>
- <View style={{ backgroundColor: '#FFF', marginTop: 10 }}>
- {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 || [],
- // },
- ])}
- </View>
- <View style={{ backgroundColor: '#FFF', marginTop: 10 }}>
- {this.viewRender([
- {
- viewName: '发票',
- rightName:
- (invoiceDefault && invoiceDefault.invoiceTitle) || '发票',
- iconName: 'icon-icon-jianjinzhishiqi',
- onPress: () =>
- this.props.dispatch(
- NavigationActions.navigate({
- routeName: 'SelectInvoice',
- params: e => this.invoiceCallback(e),
- })
- ),
- },
- ])}
- </View>
- {/* <View style={{ backgroundColor: '#FFF', marginTop: 10 }}>
- {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
- )}
- </View> */}
- </View>
- {/* 选地址 */}
- <TouchableOpacity
- activeOpacity={1}
- onPress={() =>
- this.props.dispatch(
- NavigationActions.navigate({
- routeName: 'SelectAdress',
- params: e => this.callback(e),
- })
- )
- }
- style={{
- backgroundColor: '#FFF',
- marginTop: 10,
- flexDirection: 'row',
- paddingTop: 10,
- paddingBottom: 5,
- }}
- >
- <View style={{ flex: 1, justifyContent: 'flex-end' }}>
- <Icon
- name="icon-icon-dizhi"
- size={24}
- color={'#333'}
- style={{ alignSelf: 'center' }}
- />
- </View>
- <View style={{ flex: 8, paddingBottom: 5 }}>
- <View style={{ flexDirection: 'row' }}>
- <Text style={{ fontSize: 15, lineHeight: 21, color: '#333' }}>
- {addressDefault && addressDefault.receiver}
- </Text>
- <Text style={{ marginLeft: 3, alignSelf: 'center' }}>
- {addressDefault && addressDefault.receiverPhone}
- </Text>
- </View>
- <Text
- style={{
- marginTop: 4,
- fontSize: 13,
- lineHeight: 18,
- color: '#333',
- }}
- >
- {((addressDefault && addressDefault.receiverProvince) || '') +
- ((addressDefault && addressDefault.receiverCity) || '') +
- ((addressDefault && addressDefault.receiverDistrict) || '') +
- ((addressDefault && addressDefault.receiverTown) || '') +
- ((addressDefault && addressDefault.receiverAddress) || '')}
- </Text>
- </View>
- <View
- style={{
- flex: 1,
- justifyContent: 'center',
- }}
- >
- <Icon
- name="icon-icon-jianjinzhishiqi"
- size={24}
- color={'#ccc'}
- style={{ alignSelf: 'center' }}
- />
- </View>
- </TouchableOpacity>
- {/* Image地址下边框 */}
- <Image source={redblue} style={{ height: 2, width: width }} />
- {/* 基于原单或基于商品数量选项 */}
- {promData.mutualRelationShip
- ? this.baseOnProm(promData.mutualRelationShip)
- : null}
- {/* 商品信息 */}
- {this.state.Loading ? (
- <View style={{ marginTop: 10 }}>
- <ActivityIndicator />
- </View>
- ) : (
- <FlatList
- keyExtractor={item => item.goodsId}
- data={this.state.EditPromData}
- extraData={this.state}
- renderItem={({ item, index }) => this.goodsInfo(item, index)}
- />
- )}
- {/* 赠品明细 */}
- {promData && promData.giftProms && promData.giftProms.length > 0 ? (
- <View
- style={{
- backgroundColor: '#FFF',
- paddingHorizontal: 10,
- paddingTop: 10,
- marginTop: 10,
- }}
- >
- <TouchableOpacity
- onPress={() => {
- 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',
- }}
- >
- <Text style={{ fontSize: 14, lineHeight: 20, color: '#333' }}>
- 赠品明细
- </Text>
- <View style={{ flexDirection: 'row' }}>
- <Text style={{ fontSize: 14, lineHeight: 20, color: '#666' }}>
- 选择赠品
- </Text>
- <Icon
- name="icon-icon-jianjinzhishiqi"
- color="#666"
- size={24}
- style={{ alignSelf: 'center' }}
- />
- </View>
- </TouchableOpacity>
- {this.state.giftSelected.length > 0 ? (
- <FlatList
- keyExtractor={(item, index) => index}
- data={this.state.giftSelected}
- extraData={this.state}
- style={{
- paddingBottom: 10,
- borderTopColor: '#EEE',
- borderTopWidth: 1 / PixelRatio.get(),
- }}
- renderItem={({ item, index }) => (
- <View
- style={{
- flexDirection: 'row',
- justifyContent: 'space-between',
- paddingTop: 10,
- }}
- >
- <Text
- numberOfLines={1}
- style={{
- flex: 1,
- fontSize: 12,
- lineHeight: 17,
- color: '#333',
- }}
- >
- {item.goodsDisplayName}
- </Text>
- <View style={{ flexDirection: 'row', marginLeft: 30 }}>
- <Icon
- name="icon-icon-guanbianniu"
- size={20}
- color="#666"
- />
- <Text
- style={{
- fontSize: 12,
- lineHeight: 17,
- color: '#333',
- marginLeft: 5,
- }}
- >
- {item.mainNum || 1}
- </Text>
- </View>
- </View>
- )}
- />
- ) : null}
- </View>
- ) : null}
- {/* 总体积、数量 */}
- <View style={{ marginTop: 10, padding: 10, backgroundColor: '#FFF' }}>
- <View
- style={{
- flexDirection: 'row',
- justifyContent: 'space-between',
- }}
- >
- <Text style={styles.text666}>总重量</Text>
- <Text style={styles.text666}>
- {this.state.totalWeight}{"KG"}
- {/* {this.state.weightUnit} */}
- </Text>
- </View>
- {/* <View
- style={{
- flexDirection: 'row',
- justifyContent: 'space-between',
- }}
- >
- <Text style={styles.text666}>总体积</Text>
- <Text style={styles.text666}>
- {this.state.totoalVolume}
- {this.state.volumeUnit}
- </Text>
- </View> */}
- </View>
- {/* 金额显示 */}
- <View style={{ marginTop: 10, backgroundColor: '#FFF', padding: 10 }}>
- <View
- style={{
- flexDirection: 'row',
- justifyContent: 'space-between',
- }}
- >
- <Text style={styles.text666}>商品金额:</Text>
- <Text style={styles.text666red}>
- {CURRENCY.currencySign}
- {ScaleUtil(
- this.state.goodsAmount,
- CURRENCY.currencyAmountScale
- )}
- </Text>
- </View>
- <View
- style={{
- flexDirection: 'row',
- justifyContent: 'space-between',
- }}
- >
- <Text style={styles.text666}>促销金额:</Text>
- <Text style={styles.text666red}>
- {CURRENCY.currencySign}
- {this.state.totalPromAmt}
- </Text>
- </View>
- {/* <View
- style={{
- flexDirection: 'row',
- justifyContent: 'space-between',
- }}
- >
- <Text style={styles.text666}>费用冲抵:</Text>
- <Input
- style={{
- borderWidth: 1,
- borderColor: '#E6E6E6',
- borderRadius: 2,
- width: width / 2.5,
- height: 24,
- padding: 0,
- alignItems: 'center',
- }}
- ref={AverageRef => (this.AverageRef = AverageRef)}
- keyboardType={'numeric'}
- isICon={false}
- blurOnSubmit={true}
- placeholder={''}
- textInputBacg={'#FFF'}
- placeholderTextColor={'#CCC'}
- onchangeFn={e => this.AverageBooth(e, MaxOffset)}
- maxNum={MaxOffset}
- />
- </View> */}
- {/* <View
- style={{
- flexDirection: 'row',
- justifyContent: 'flex-end',
- marginTop: 5,
- }}
- >
- <Text style={[styles.text999, { marginRight: 10 }]}>
- (本次最高冲抵:<Text style={{ color: '#E14C46' }}>
- {CURRENCY.currencySign}
- {ScaleUtil(MaxOffset, CURRENCY.currencyAmountScale)}
- </Text>
- </Text>
- <Text style={styles.text999}>
- 费用总金额:
- <Text style={{ color: '#E14C46' }}>
- {CURRENCY.currencySign}
- {ScaleUtil(
- castRateDataOnly.supplyMaxOccupyMny || 0,
- CURRENCY.currencyAmountScale
- )}
- </Text>)
- </Text>
- </View> */}
- <View
- style={{
- flexDirection: 'row',
- justifyContent: 'space-between',
- marginTop: 20,
- }}
- >
- {/* <TouchableOpacity
- style={{ flexDirection: 'row' }}
- onPress={() => {
- this.credit._openModal(creditData)
- this.setState({ creditShow: true })
- }}
- >
- <Text style={[styles.text999, { alignSelf: 'center' }]}>
- 信用查询
- </Text>
- <Image
- source={orderCreditPng}
- style={{
- width: 14,
- height: 14,
- alignSelf: 'center',
- marginLeft: 4,
- }}
- />
- </TouchableOpacity> */}
- <Text style={styles.text666}>
- 订单总金额:<Text
- style={{ fontSize: 18, lineHeight: 25, color: '#E14C46' }}
- >
- {CURRENCY.currencySign}{' '}
- {ScaleUtil(
- this.state.totalAmount,
- CURRENCY.currencyAmountScale
- )}
- </Text>
- </Text>
- </View>
- <View style={{ marginTop: 10, backgroundColor: '#FFF' }}>
- <View style={{flexDirection: 'row'}}>
- <Text>备注:</Text>
- <TextInput
- style={{
- fontSize: 12,
- color: '#333333',
- padding: 0,
- backgroundColor: '#FFF',
- height: 25,
- borderWidth: 1,
- borderColor: '#DDDDDD',
- width:'60%'
- }}
- // multiline
- // numberOfLines={4}
- value={this.state.remark}
- onChangeText={text=>this.setState({remark:text})}
- underlineColorAndroid="transparent"
- />
- </View>
- </View>
- </View>
- <Modal
- animationType="slide"
- presentationStyle="formSheet"
- transparent={true}
- visible={this.state.showOptModal}
- onRequestClose={() => {
- this.setState({
- showOptModal: false
- })
- }}
- >
- <View
- style={{
- backgroundColor:'#FFF',
- top:'50%',
- paddingBottom: 50,
- width:'100%',
- height:'50%',
- alignItems : 'center',
- elevation : 5,
- }}>
- {this.state.optLoading ? (
- <View style={{marginTop:100}}>
- <ActivityIndicator />
- </View>
- ) : <View>
- <View style={{flexDirection:'row'}}>
- <Text style={{ fontSize: 13, lineHeight: 18, color: '#333',width:'90%',marginTop:10 }}>选择颜色</Text>
- <TouchableOpacity onPress={() =>{
- this.setState({
- showOptModal: false
- })
- }}>
- <Image
- source={deletePng}
- style={{ width: 20, height: 20}}
- />
- </TouchableOpacity>
- </View>
- <OptFlatList colorData={this.state.optionData} optionData={[{saleOrgId: supplierDefault.SaleOrSupplierId, goodsId: this.state.optionData.length > 0 ? this.state.optionData[0].id : ""}]} chooseColor={this._chooseColor.bind(this)}/>
- </View>
- }
- </View>
-
- </Modal>
- <Modal
- animationType="slide"
- presentationStyle="formSheet"
- transparent={true}
- visible={this.state.modalVisible}
- onRequestClose={() => {
- console.log('close');
- }}
- >
- <View
- style={{
- backgroundColor:'#f8f8f8',
- marginTop:'50%',
- marginLeft:'15%',
- width:'70%',
- height:'24%',
- alignItems : 'center',
- shadowColor : '#000',
- shadowOffset: {width: 0,height: 2},
- shadowOpacity : 0.25,
- shadowRadius : 3.84,
- elevation : 5,
- //borderRadius : 20
- }}>
- <Text style={{marginTop:10}}>请输入商品数量</Text>
- <TextInput
- style={{width:'50%'}}
- onChangeText={text => this.setState({num:text})}
- value={this.state.num}
- />
- <View style={{width:"100%",flexDirection:'row',position:'absolute',bottom:0}}>
- <TouchableOpacity style={{backgroundColor : '#E70013',width:'50%',alignItems:'center',fontSize:20,padding:5}}
- onPress= {() => this.onModalOk()}
- >
- <Text>确定</Text>
- </TouchableOpacity>
- <TouchableOpacity style={{backgroundColor : '#fff',width:'50%',alignItems:'center',fontSize:20,padding:5}}
- onPress= {() => this.setState({modalVisible:false})}
- >
- <Text>取消</Text>
- </TouchableOpacity>
- </View>
- </View>
- </Modal>
- </ScrollView>
- {/* 信用弹窗 */}
- <OrderCredit
- ref={credit => (this.credit = credit)}
- cb={() => this.setState({ creditShow: false })}
- />
- <OrderOptional
- {...this.props}
- ref={optional => (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 })
- }}
- />
- {/* 时间弹窗 */}
- <SelectTime
- ref={showTime => (this.showTime = showTime)}
- cb={date => {
- this.setState({
- deliveryTime: moment(date).format('YYYY-MM-DD'),
- })
- }}
- />
- {/* 底部 */}
- <View
- style={{
- height: 45 + HEADERSTYLE.paddingBottom,
- paddingBottom: HEADERSTYLE.paddingBottom,
- backgroundColor: '#FFF',
- flexDirection: 'row',
- borderTopColor: '#EEE',
- borderTopWidth: 1 / PixelRatio.get(),
- }}
- >
- {this.bottomTouch()}
- </View>
- {/* 信用弹窗毛玻璃效果 */}
- {/* {this.state.creditShow ? (
- <View
- style={{
- position: "absolute",
- width: width,
- height: height,
- backgroundColor: "#000",
- opacity: 0.5
- }}
- />
- ) : null} */}
- </View>
- )
- }
- }
- 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
|