123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832 |
- 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'
- import GoodsFlatList from '../commodity/commoditydetail/GoodsFlatList'
- /**
- * 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: [],
- showGoodsModal: false, // 增加商品列表
- 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
- let existIndex = this.state.EditPromData.findIndex(e => e.goodsId == newRow.goodsId && e.ext05 == colorData.children.attrValId);
- if (existIndex >= 0 && existIndex != selectRow) {
- Toast.show("已存在相同颜色的商品,请重新选择颜色!",{position : toastHeight});
- return
- }
- } else {
- this.toast = Toast.show("改颜色未设置价格,请重新选择颜色!",{position : toastHeight});
- return
- }
- 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
- let totalNum = 0
- newEditPromData.forEach(item => {
- totalAmount = totalAmount + item.amount
- totalNum = totalNum + item.orderNum
- })
- let goodsAmount = totalAmount
- let totalAmountCopy = totalAmount
- this.setState({
- showOptModal: false,
- EditPromData : newEditPromData,
- totalAmount,
- goodsAmount,
- totalNum,
- totalAmountCopy
- })
- currRow = {}
- } else {
- this.toast = Toast.show("选配商品已被删除!",{position : toastHeight});
- this.setState({
- showOptModal: false
- })
- currRow = {}
- }
- }
- addGoods(goods) {
- console.log('goods==========>',goods)
- console.log('this.state.EditPromData======>',this.state.EditPromData)
- let existItem = this.state.EditPromData.find(e => e.goodsCode == goods.code && !e.baseGoodsOptId)
- if (existItem) {
- Toast.show("已存在重复的商品,请重新选择!",{position : toastHeight});
- return
- }
- if (goods.id) {
- let newItem = {
- amount: goods.basePrice,
- baseGoodsOptId: "",
- baseGoodsOptValue: "",
- basePrice: goods.basePrice,
- conversionRate: 1,
- dealAmount: goods.basePrice,
- dealPrice: goods.basePrice,
- deliveryNum: 0,
- dr: 0,
- expenseOrderCode: "",
- ext14: goods.categoryCode,
- ext15: goods.categoryName,
- goodsCode: goods.code,
- goodsDisplayName: goods.displayName,
- goodsId: goods.id,
- goodsName: goods.name,
- id: '',
- isGift: 0,
- isOptional: goods.isOptional,
- mainNum: 1,
- mainNumUnitCode: goods.basicUnitCode,
- mainNumUnitId: goods.basicUnitId,
- mainNumUnitName: goods.basicUnitName,
- model: goods.model,
- ncProductCode: goods.ncProductCode,
- offsetAmount: 0,
- orderNum: 1,
- orderNumUnitCode: goods.basicUnitCode,
- orderNumUnitId: goods.basicUnitId,
- orderNumUnitName: goods.basicUnitName,
- originalGoodsId: goods.id,
- persistStatus: 'nrm',
- productGradeCode: goods.productGradeCode,
- productGradeId: goods.productGradeId,
- productGradeName: goods.productGradeName,
- productId: goods.productId,
- productLineCode: goods.productLineCode,
- productLineId: goods.productLineId,
- productLineName: goods.productLineName,
- promAmount: 0,
- promPrice: goods.basePrice,
- refundNum: 0,
- reqOrderAttachments: [],
- reqOrderId: this.props.promData.reqOrderItems[0].reqOrderId,
- reqOrderItemBoms: [],
- reqOrderPromRels: [],
- returnMaxOrderNum: 0,
- returnNum: 0,
- // rowNum: (this.state.EditPromData.length * 10) + "",
- salePrice: goods.basePrice,
- signNum: 0,
- specification: goods.specification,
- stockInNum: 0,
- stockOutNum: 0,
- weight: goods.netWeight
- }
- const newData = [...this.state.EditPromData];
- newData.push(newItem);
- console.log('this.props.promData.reqOrderItems[0].reqOrderId',this.props.promData.reqOrderItems[0].reqOrderId)
- let totalAmount = 0
- let totalNum = 0
- newData.forEach(item => {
- totalAmount = totalAmount + item.amount
- totalNum = totalNum + item.orderNum
- })
- let goodsAmount = totalAmount
- let totalAmountCopy = totalAmount
- this.setState({EditPromData: newData,
- showGoodsModal: false,
- totalAmount,
- totalNum,
- goodsAmount,
- totalAmountCopy})
- }
- }
- //删除商品
- deleteGoodsFn(indexParent) {
- this.state.EditPromData.splice(indexParent, 1)
- this.setState({ Loading: true, giftSelected: [] })
- if (
- this.props.navigation.state.params.SaleOrSupplier.isPrimaryChannel == 1
- ) {
- this.props
- .dispatch(
- createAction('orderedit/getProm')({
- promInfo: {
- customerId: CUSTOMERINFO.id,
- saleOrgId: this.props.navigation.state.params.SaleOrSupplier
- .SaleOrSupplierId,
- isPrimaryChannel: this.props.navigation.state.params
- .SaleOrSupplier.isPrimaryChannel,
- reqOrderItems: this.state.EditPromData,
- },
- })
- )
- .finally(() => {
- if (this.props.promData) {
- this.CountNumFn(
- true,
- '',
- '',
- this.props.promData.reqOrderItems || this.state.EditPromData
- )
- }
- //this.autoShowGiftRow()
- this.setState({ Loading: false })
- })
- } else {
- this.CountNumFn(true, '', '', this.state.EditPromData)
- this.setState({ Loading: false })
- }
- }
- // 抽出所有商品的产品线
- getProductLines() {
- let productLineIds = []
- this.state.EditPromData.map(item => {
- productLineIds.push(item.productLineId)
- })
- return productLineIds
- }
- // 检查信用
- creditCheck(reqOrderItems) {
- this.props.dispatch(
- createAction('orderedit/getCreditCheck')({
- searchInfo: {
- saleOrgId: this.props.navigation.state.params.SaleOrSupplier
- .SaleOrSupplierId,
- customerId: CUSTOMERINFO.id,
- reqOrderItems: reqOrderItems || this.state.EditPromData,
- saleModel: '01',
- },
- })
- )
- }
- // 订单数据集 正常态
- getOrderData() {
- this.state.EditPromData.map(
- item => (item.id = null)
- // dealPrice:,//成交价格
- // offsetAmount:,//行分摊促销金额
- // (dealAmount = (item.basePrice || item.salePrice) * item.orderNum), //成交金额
- // (amount = (item.basePrice || item.salePrice) * item.orderNum)
- // currency,//行币种
- )
- const {
- addressDefault,
- billwayDefault,
- invoiceDefault,
- transportDefault,
- } = this.props
- const postData = {
- id: this.props.navigation.state.params.id || '',
- currency: CURRENCY.id, // 币种
- currencySign: CURRENCY.currencySign, // 币符
- currencyPriceScale: CURRENCY.currencyPriceScale, // 币种单价精度
- currencyAmountScale: CURRENCY.currencyAmountScale, // 币种金额精度
- customerId: CUSTOMERINFO.id,
- // persistStatus: "nrm", //数据操作状态 'nrm'为无变化 'new'为新增
- saleOrgId: this.props.navigation.state.params.SaleOrSupplier
- .SaleOrSupplierId, // 销售组织,即供应商
- deliveryDate: new Date(this.state.deliveryTime).getTime(), // 期望收货日期
- totalNum: this.state.totalNum, // 总数量
- totalDealAmount: this.state.totalAmount, // 总成交金额
- totalWeight: this.state.totalWeight, // 总重量
- totoalVolume: this.state.totoalVolume, // 总体积
- // orderSource: "portal", // 订单来源
- remark: this.state.remark, // 订单备注
- totalAmount: this.state.goodsAmount, // 冲抵前金额
- offsetAmount: this.state.offsetAmount, // 费用冲抵金额
- saleModel: '01', //销售模式 具体开头部
- reqOrderSource: '01', //订单来源
- underPaymentModeId: this.state.payWayDef.code, //订单支付方式
- srcOrderId: this.props.navigation.state.params.id || '',
- reqOrderReceiveAddress: {
- reqOrderId: addressDefault.id,
- receiveAddressId: addressDefault.id, // 收货地址id
- receiver: addressDefault.receiver, // 收货人
- receiverTel: addressDefault.receiverTel, // 电话
- receiverPhone: addressDefault.receiverPhone, // 手机
- receiverProvince: addressDefault.receiverProvince, // 省
- receiverCity: addressDefault.receiverCity, // 市
- receiverDistrict: addressDefault.receiverDistrict, // 区
- receiverTown: addressDefault.receiverTown, // 镇
- receiverAddress: addressDefault.receiverAddress, // 详细地址
- receiverZipcode: addressDefault.receiverZipcode, // 邮编
- },
- reqOrderInvoice: {
- reqOrderId: invoiceDefault.id,
- invoiceId: invoiceDefault.id, // 发票id
- invoiceType: invoiceDefault.invoiceType, // 发票类型
- invoiceContent: invoiceDefault.invoiceContent, // 开票项目
- invoiceTitle: invoiceDefault.invoiceTitle, // 发票抬头
- invoiceTaxId: invoiceDefault.invoiceTaxId, // 纳税人识别码
- invoiceBank: invoiceDefault.invoiceBank, // 开户银行
- invoiceAccount: invoiceDefault.invoiceAccount, // 开户账户
- invoiceSubBank: invoiceDefault.invoiceSubBank, // 支行
- },
- reqOrderItems: this.state.EditPromData,
- }
- transportDefault && transportDefault.id
- ? (postData.transportModeId = transportDefault.id)
- : null // 运输方式
- billwayDefault && billwayDefault.id
- ? (postData.settleModeId = billwayDefault.id)
- : null // 结算方式
- return postData
- }
- // 从订单列表过来的订单数据集 封装暂存态的数据
- getOrderFromList() {
- this.state.EditPromData.map(item => (item.id = null))
- let EditDataCopy = JSON.parse(JSON.stringify(this.state.EditPromData)),
- EditData = {}
- const {
- addressDefault,
- billwayDefault,
- invoiceDefault,
- transportDefault,
- } = this.props
- EditData.id = this.props.navigation.state.params.type?'':(this.props.navigation.state.params.id || '')
- EditData.orderCode = this.props.navigation.state.params.type?'':(this.props.navigation.state.params.data.orderCode || '')
- EditData.currency = CURRENCY.id // 币种
- EditData.currencySign = CURRENCY.currencySign // 币符
- EditData.currencyPriceScale = CURRENCY.currencyPriceScale // 币种单价精度
- EditData.currencyAmountScale = CURRENCY.currencyAmountScale // 币种金额精度
- EditData.customerId = CUSTOMERINFO.id
- // 地址
- EditData.reqOrderReceiveAddress = addressDefault
- // 发票信息
- EditData.reqOrderInvoice = invoiceDefault
- // EditData.orderSource = "portal"; // 订单来源
- EditData.srcOrderId = this.props.navigation.state.params.id || ''
- // 供应商
- EditData.saleOrgId = this.props.navigation.state.params.SaleOrSupplier.SaleOrSupplierId
- EditData.saleOrgCode = this.props.navigation.state.params.SaleOrSupplier.SaleOrSupplierCode
- EditData.saleOrgName = this.props.navigation.state.params.SaleOrSupplier.SaleOrSupplierName
- EditData.isPrimaryChannel = this.props.navigation.state.params.SaleOrSupplier.isPrimaryChannel
- // 结算方式
- EditData.settleModeCode = billwayDefault.code
- EditData.settleModeId = billwayDefault.id
- EditData.settleModeName = billwayDefault.name
- // 运输方式
- EditData.transportModeId = transportDefault.id
- EditData.transportModeCode = transportDefault.code
- EditData.transportModeName = transportDefault.name
- EditData.reqOrderItems = EditDataCopy
- ;(EditData.underPaymentModeId = this.state.payWayDef.code), //订单支付方式
- (EditData.remark = this.state.remark) // 订单备注
- EditData.totalAmount = this.state.goodsAmount // 冲抵前金额
- EditData.offsetAmount = this.state.offsetAmount // 费用冲抵金额
- EditData.deliveryDate = new Date(this.state.deliveryTime).getTime() // 期望收货日期
- EditData.totalNum = this.state.totalNum // 总数量
- EditData.totalDealAmount = this.state.totalAmount // 总成交金额
- EditData.totalWeight = this.state.totalWeight // 总重量
- EditData.totoalVolume = this.state.totoalVolume // 总体积
- EditData.saleModel = '01' //销售模式 具体开头部
- EditData.reqOrderSource = '01' //订单来源
- return EditData
- }
- // 促销后补充商品行
- transportPromData(postData) {
- const giftData = JSON.parse(JSON.stringify(this.state.giftSelected))
- // 如果为整单则在表头加入促销信息
- if (
- this.props.promData &&
- this.props.promData.orderPriceProm &&
- Object.keys(this.props.promData.orderPriceProm).length > 0
- ) {
- const orderPriceProm = this.props.promData.orderPriceProm
- postData.reqOrderPromRels = [
- {
- activityId: orderPriceProm.activityId,
- ruleId: orderPriceProm.ruleId,
- description: orderPriceProm.description,
- promWay: 2, // 1 买赠 2 降价
- isWhole: 1, // 1 整单
- },
- ]
- }
- // 如果选择促销商品后,在商品行加入买赠商品,其中商品行中的促销信息在OrderGifts中回调封装
- if (giftData && giftData.length > 0) {
- giftData.map((item,index) => {
- item.id = null
- item.isGift = 1
- item.basePrice = 0
- item.salePrice = 0
- item.promPrice = 0
- item.dealPrice = 0
- item.amount = 0 // 金额
- item.promAmount = 0 // 均摊到行上的整单降价促销金额
- item.dealAmount = 0 // 成交金额
- item.ffsetAmount = 0 // 均摊到行上的费用冲抵金额
- item.orderNum = 0
- item.rowNum = postData.reqOrderItems.length+parseInt(index)+1
- item.promotinId = item.activityId
- })
- postData.reqOrderItems = postData.reqOrderItems.concat(giftData)
- }
- return postData
- }
- // 补充BOM信息
- fillGoodsBomInfo(postData) {
- // 之前步骤方便显示,将子件信息存在每个母件reqOrderItems中,在补充Bom时,将子件信息抽出赋在外部字段(reqOrderItemBoms)中,并将母件的自己字段删除
- let newReqOrderItemBoms = []
- postData.reqOrderItems.forEach((data, index) => {
- data.persistStatus = 'new'
- data.rowNum = (index + 1) * 10
- data.ext09 = data.dealPrice;
- data.ext10 = data.dealAmount;
- if (data.reqOrderItemBoms && data.reqOrderItemBoms.length > 0) {
- data.reqOrderItemBoms.forEach(bomData => {
- bomData.parentRowNum = data.rowNum
- bomData.parentGoodsName = data.goodsDisplayName
- })
- newReqOrderItemBoms = newReqOrderItemBoms.concat(data.reqOrderItemBoms)
- }
- delete data.reqOrderItemBoms
- })
- postData.reqOrderItemBoms = newReqOrderItemBoms
- // 判断是否母件是否有子件信息,如果有:则将子件信息集合中数据封装为新结构;如果无,则将商品行复制添加到子件信息集合中
- if (postData.reqOrderItemBoms && postData.reqOrderItemBoms.length > 0) {
- const reqOrderItemBoms = this.bomStructureDeal(postData.reqOrderItemBoms)
- postData.reqOrderItemBoms = reqOrderItemBoms
- } else {
- const reqOrderItems = postData.reqOrderItems
- const reqOrderItemBoms = reqOrderItems.map((item, index) => {
- const translate = {
- parentRowNum: item.rowNum,
- parentGoodsId: item.goodsId,
- persistStatus: 'new',
- parentGoodsCode: '', // item.goodsCode,
- parentGoodsName: '', // item.goodsDisplayName,
- childGoodsQty: 1,
- orderNumUnit: item.orderNumUnitName,
- mainNumUnit: item.mainNumUnitName,
- }
- const newItem = { ...item, ...translate }
- return newItem
- })
- postData.reqOrderItemBoms = reqOrderItemBoms
- }
- return postData
- }
- // 子件信息数据结构处理
- bomStructureDeal(bomData) {
- const reqOrderItemBoms = bomData.map((child, index) => {
- const translate = {
- baseGoodsOptId: child.baseGoodsOptId,
- baseGoodsOptValue: child.baseGoodsOptValue,
- rowNum: (index + 1) * 10,
- parentRowNum: child.parentRowNum,
- parentGoodsId: child.parentGoodsId,
- parentGoodsName: child.parentGoodsName,
- mainNum: '',
- goodsName: child.childGoodsName,
- goodsCode: child.childGoodsCode,
- goodsId: child.childGoodsId,
- version: child.childGoodsVersion,
- measurementUnitId: child.childGoodsUnitId,
- measurementUnitCode: child.childGoodsUnitCode,
- measurementUnitName: child.childGoodsUnitName,
- orderNumUnitId: child.childGoodsUnitId,
- orderNumUnitCode: child.childGoodsUnitCode,
- orderNumUnitName: child.childGoodsUnitName,
- orderNum: child.childGoodsQty,
- childGoodsQty: child.childGoodsQty,
- //
- persistStatus: 'new',
- mainNumUnit: child.childGoodsUnitName,
- }
- return translate
- })
- return reqOrderItemBoms
- }
- // 订单提交暂存
- async editFinish(ident) {
- let isReturnTab = false,
- result = [],
- flag = false,
- errReturn = false,
- editSubmlitData =
- this.props.navigation.state.params.comefrom == 'temporarily'
- ? this.getOrderFromList()
- : this.getOrderData()
- //运输方式为必选项
- if(!editSubmlitData.transportModeId) {
- this.toast = Toast.show("请选择一种运输方式",{position : toastHeight});
- return;
- }
- editSubmlitData = this.fillGoodsBomInfo(editSubmlitData)
- if (this.props.creditData && this.props.creditData.length > 0) {
- let alertText = []
- this.props.creditData.map(item => {
- if (item.thisProdLineAmount > item.creditBalance) {
- alertText.push(item.productLineName)
- flag = true
- }
- })
- if (flag) {
- this.toast = Toast.show(`${alertText.join(',')}金额超过信用余额`, {
- position: toastHeight,
- })
- }
- }
- if (ident === 'Temporary') {
- // 暂存提交
- this.setState({ temporaryLoading: true })
- result = await authService.temporaryOrder(editSubmlitData).catch(err => {
- this.setState({ temporaryLoading: false })
- errReturn = true
- if (this.toast) {
- Toast.hide(this.toast)
- }
- this.toast = Toast.show(err.message, { position: toastHeight })
- console.log(
- err,
- '-----订单编辑-暂存订单报错的完整信息' +
- '\n' +
- '具体错误显示--->' +
- err.response.data.message
- )
- })
- this.setState({ temporaryLoading: false })
- } else if (ident === 'Submit') {
- //补充商品行
- editSubmlitData = this.transportPromData(editSubmlitData)
- if (this.state.payWayDef.code == 'PayFirst') {
- // 在线支付 需要把errReturn设置成false
- this.setState({ temporaryLoading: true })
- result = await authService
- .temporaryOrder(editSubmlitData)
- .catch(err => {
- this.setState({ temporaryLoading: false })
- errReturn = false
- this.toast = Toast.show(err.message, { position: toastHeight })
- console.log(
- err,
- '-----订单编辑-暂存订单报错的完整信息' +
- '\n' +
- '具体错误显示--->' +
- err.response.data.message
- )
- })
- this.setState({ temporaryLoading: false })
- this.props.dispatch(
- NavigationActions.navigate({
- routeName: 'OrderPay',
- params: {
- submitData: { id: result.data.id },
- totalAmount: result.data.totalDealAmount,
- callBack: () => {
- this.props.dispatch(
- NavigationActions.navigate({
- routeName: 'OrderHome',
- })
- )
- },
- },
- })
- )
- } else {
- this.setState({ submitLoading: true })
- result = await authService.postOrder(editSubmlitData).catch(err => {
- this.setState({ submitLoading: false })
- errReturn = true
- this.toast = Toast.show(err.response.data.message + ";开始暂存订单!", { position: toastHeight })
- this.editFinish("Temporary")
- console.log(
- err,
- '-----订单编辑-提交订单报错的完整信息' +
- '\n' +
- '具体错误显示||--->:' +
- err.response.data.message
- )
- })
- this.setState({ submitLoading: false })
- }
- }
- // 请求数据报错,则不进行下一步
- if (!errReturn) {
- if (result.data && Object.keys(result.data).length > 0) {
- isReturnTab = true
- }
- if (isReturnTab) {
- if (
- this.props.navigation.state.params.cartId &&
- this.props.navigation.state.params.cartId.length > 0
- ) {
- this.props.navigation.state.params.cartId.forEach(item => {
- this.props.dispatch(
- createAction('shoppingcart/deleteShop')({
- params: {
- id: item,
- customer: CUSTOMERINFO.id,
- },
- })
- )
- })
- }
- // 返回OrderHome
- this.props.dispatch(
- NavigationActions.navigate({
- routeName: 'OrderHome',
- action: NavigationActions.navigate({ routeName: 'OrderHome' }),
- })
- )
- }
- }
- }
- // 头部
- header() {
- return (
- <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 key={item.rowNum}>
- <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' }}>
- <View style={{ marginLeft: 10}}>
- <Text style={{ fontSize: 13, lineHeight: 18, color: '#333' }}>
- {(indexParent + 1)}
- </Text>
- </View>
- <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: 'center',
- }}
- >
- <TouchableOpacity onPress={() =>{
- this.setState({
- showGoodsModal: true
- })
- }}>
- <Text style={styles.text666}>增加商品+</Text>
- </TouchableOpacity>
- </View>
- </View>
- {/* 总体积、数量 */}
- <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.showGoodsModal}
- onRequestClose={() => {
- this.setState({
- showGoodsModal: 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({
- showGoodsModal: false
- })
- }}>
- <Image
- source={deletePng}
- style={{ width: 20, height: 20}}
- />
- </TouchableOpacity>
- </View>
- <GoodsFlatList addGoods={this.addGoods.bind(this)}/>
- </View>
- }
- </View>
- </Modal>
- {/* 颜色选配 */}
- <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
|