12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660 |
- 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
- }
- 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 (
- <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.rowNum}--{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
|