OrderEdit.js 94 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832
  1. import React, { Component } from 'react'
  2. import {
  3. StyleSheet,
  4. View,
  5. Image,
  6. StatusBar,
  7. Text,
  8. TouchableOpacity,
  9. Dimensions,
  10. PixelRatio,
  11. ScrollView,
  12. FlatList,
  13. Platform,
  14. DatePickerAndroid,
  15. ActivityIndicator,
  16. Modal,
  17. TextInput,
  18. Button
  19. } from 'react-native'
  20. import { connect } from 'react-redux'
  21. import Collapsible from 'react-native-collapsible'
  22. import CountNum from '../../components/CountNum'
  23. import Input from '../../components/input'
  24. import png from '../../static/images/defaultimg.jpg'
  25. import morePng from '../../static/images/ic-moredian.png'
  26. import { ImageBaseUrl } from '../../utils/fetch/Fetchx'
  27. import {
  28. ScaleUtil,
  29. accAdd,
  30. accMul,
  31. accDiv,
  32. accSub,
  33. NumberTranslate,
  34. setNowFormatDate,
  35. } from '../../utils/utils'
  36. import Icon from '../../components/Iconfont/Iconfont'
  37. import { NavigationActions, createAction } from '../../utils'
  38. import redblue from '../../static/images/ic-redblue.png'
  39. //import moreDian from '../../static/images/ic-moredian.png'
  40. import OrderCredit from './orderamanage/OrderCredit'
  41. import OrderOptional from './orderamanage/OrderOptional'
  42. import SelectTime from '../common/SelectTime'
  43. import * as authService from '../../services/auth'
  44. //import orderCreditPng from '../../static/images/order-credit.png'
  45. import deletePng from '../../static/images/delete.png'
  46. import moment from 'moment'
  47. import Toast from 'react-native-root-toast'
  48. import DetailModels from '../../models/commodity/DetailModels'
  49. import OptFlatList from '../commodity/commoditydetail/OptFlatList'
  50. import GoodsFlatList from '../commodity/commoditydetail/GoodsFlatList'
  51. /**
  52. * saleModel
  53. *
  54. * Sale("01", "正向销售", "正向销售"),
  55. * Return("02", "退货", "退货"),
  56. * Cost("03", "费用货补", "费用货补"),
  57. * CostReturn("04", "货补退货", "货补退货");
  58. */
  59. const { width, height } = Dimensions.get('window')
  60. let currRow = {} // 当前操作行
  61. @connect(({ theme, mine, orderedit, optional }) => ({
  62. ...theme,
  63. ...mine,
  64. ...orderedit,
  65. ...optional,
  66. }))
  67. class OrderEdit extends Component {
  68. constructor(props) {
  69. const date = new Date()
  70. super(props)
  71. this.state = {
  72. optionData: [],
  73. showGoodsModal: false, // 增加商品列表
  74. showOptModal : false,
  75. modalVisible : false,
  76. activeSection: true,
  77. optLoading: false,
  78. // activeAllCollaps: true,
  79. optCollapse: 'shouqi',
  80. baseIndex: 0,
  81. activeAllCollaps: true,
  82. transportSel:
  83. (props.transportDefault && props.transportDefault.name) || 0,
  84. billWaySel: (props.billwayDefault && props.billwayDefault.name) || 0,
  85. activeMethod: 'ffsa',
  86. cicleActive: true,
  87. creditShow: false,
  88. // 购物车选中
  89. EditPromData:
  90. Object.keys(props.promData).length > 0 && props.promData.reqOrderItems
  91. ? props.promData.reqOrderItems
  92. : props.navigation.state.params.ShopData,
  93. EditPromDataCopy:
  94. Object.keys(props.promData).length > 0 && props.promData.reqOrderItems
  95. ? props.promData.reqOrderItems
  96. : props.navigation.state.params.ShopData,
  97. // 选中赠品信息
  98. giftSelected: [],
  99. // 产品线id集合
  100. productLineIds: [],
  101. // 发货日期
  102. deliveryTime: setNowFormatDate(),
  103. // 支付方式
  104. payWayDef: props.navigation.state.params.payWayDef
  105. ? props.navigation.state.params.payWayDef
  106. : '',
  107. paySel: props.navigation.state.params.payWayDef
  108. ? props.navigation.state.params.payWayDef.name
  109. : 0,
  110. //备注
  111. remark:
  112. (props.navigation.state.params.ShopData &&
  113. props.navigation.state.params.ShopData.remark) ||
  114. '',
  115. // 冲抵金额
  116. offsetAmount: 0,
  117. // 冲抵前金额
  118. goodsAmount: 0,
  119. // 促销金额
  120. totalPromAmt: 0,
  121. // 总成交金额最终用
  122. totalAmount: 0,
  123. // 成交金额不变的值
  124. totalAmountCopy: 0,
  125. // 总数量
  126. totalNum: 0,
  127. // 总重量
  128. totalWeight: 0,
  129. // 重量单位
  130. volumeUnit: '',
  131. // 总体积
  132. totoalVolume: 0,
  133. // 体积单位
  134. volumeUnit: '',
  135. Loading: false,
  136. submitLoading: false,
  137. temporaryLoading: false,
  138. }
  139. // 保存互斥关系,点击之后如果无返回值,则使用上一次互斥关系
  140. this.RelationShipCopy
  141. // 圆形按钮滑动前状态
  142. this.cicleActive = true
  143. }
  144. componentDidMount() {
  145. //this.creditCheck()
  146. // 费用冲抵比率请求
  147. this.props.dispatch(
  148. createAction('orderedit/getCastRate')({
  149. castInfo: {
  150. saleOrgId: this.props.navigation.state.params.SaleOrSupplier
  151. .SaleOrSupplierId,
  152. customerId: CUSTOMERINFO.id,
  153. },
  154. })
  155. )
  156. // 地址、结算方式等参照请求
  157. this.props.dispatch(
  158. createAction('mine/getAdress')({
  159. // customer: "d4b4677f-93ec-49b5-bcaa-c134df0f7295",
  160. customer: CUSTOMERINFO.id,
  161. comefrom: {
  162. comefrom: this.props.navigation.state.params.comefrom,
  163. reqOrderInvoice: this.props.navigation.state.params.reqOrderInvoice,
  164. reqOrderReceiveAddress: this.props.navigation.state.params
  165. .reqOrderReceiveAddress,
  166. transportDefault: this.props.navigation.state.params.transportDefault,
  167. billwayDefault: this.props.navigation.state.params.billwayDefault,
  168. },
  169. transform: true,
  170. billway: true,
  171. invoice: true,
  172. })
  173. )
  174. if (this.props.navigation.state.params.comefrom == 'temporarily') {
  175. let newTime = new Date(
  176. this.props.navigation.state.params.data.deliveryDate
  177. )
  178. this.setState({
  179. transportSel: this.props.navigation.state.params.transportDefault.name,
  180. billWaySel: this.props.navigation.state.params.billwayDefault.name,
  181. deliveryTime: this.props.navigation.state.params.data.deliveryDate
  182. ? moment(this.props.navigation.state.params.data.deliveryDate).format(
  183. 'YYYY-MM-DD'
  184. )
  185. : moment().format('YYYY-MM-DD'),
  186. })
  187. }
  188. // 支付方式
  189. // this.props.dispatch(createAction('mine/payMentMode')()).finally(() => {
  190. // if (!this.props.navigation.state.params.payWayDef) {
  191. // this.setState({ payWayDef: this.props.orderPayStatus[0] })
  192. // }
  193. // })
  194. this.setState({
  195. productLineIds: this.getProductLines(),
  196. })
  197. this.combinedFn(true)
  198. }
  199. // 为选择商品挂载Boom信息
  200. addBoomToData() {
  201. const ids = [],
  202. EditPromData = this.state.EditPromData
  203. EditPromData.forEach(item => {
  204. ids.push(item.goodsId)
  205. })
  206. let flag = true
  207. this.props
  208. .dispatch(createAction('optional/getBoomInfo')(ids.join()))
  209. .finally(() => {
  210. // 如果有子件,则暂时把子件挂在商品行下,便于展示
  211. if (this.props.goodsBoom && this.props.goodsBoom.length > 0) {
  212. const goodsBom = this.props.goodsBoom,
  213. newOptIds = []
  214. EditPromData.forEach((editData, editIndex) => {
  215. goodsBom.forEach((bomData, index) => {
  216. bomData.goodsBomChildren.forEach((bomChild, childIndex) => {})
  217. if (editData.goodsId == bomData.parentGoodsId) {
  218. editData.reqOrderItemBoms = bomData.goodsBomChildren
  219. }
  220. if (
  221. editData.baseGoodsOptId &&
  222. editData.baseGoodsOptId.length > 0
  223. ) {
  224. newOptIds.push(editData.baseGoodsOptId)
  225. }
  226. })
  227. })
  228. // 初始选中;
  229. if (newOptIds && newOptIds.length > 0) {
  230. const optIdsJoin = newOptIds.join()
  231. this.props
  232. .dispatch(createAction('optional/optionalByIds')(optIdsJoin))
  233. .finally(() => {
  234. if (
  235. this.props.optDataByIds &&
  236. this.props.optDataByIds.length > 0
  237. ) {
  238. const optDataByIds = this.props.optDataByIds
  239. optDataByIds.forEach(data => {
  240. data.optids = []
  241. data.goodsOptVals.forEach(dataSec => {
  242. data.optids.push(dataSec.id)
  243. })
  244. })
  245. EditPromData.forEach(itemFir => {
  246. itemFir.reqOrderItemBoms.forEach(itemSec => {
  247. optDataByIds.forEach(optData => {
  248. if (itemSec.childGoodsId == optData.goodsId) {
  249. itemSec.baseGoodsOptId = optData.optids.join()
  250. itemSec.baseGoodsOptValue = optData.optResult
  251. }
  252. })
  253. })
  254. })
  255. this.setState({ EditPromData: this.state.EditPromData })
  256. flag = false
  257. }
  258. })
  259. }
  260. }
  261. if (flag) {
  262. this.setState({ EditPromData: this.state.EditPromData })
  263. }
  264. })
  265. }
  266. async openOptView(item) {
  267. currRow = item
  268. this.setState({
  269. optLoading: true,
  270. showOptModal: true,
  271. optionData: []
  272. })
  273. const result = await authService.getColorByGroups({id:item.goodsId,groupId : "", colourCode : ""});
  274. this.setState({
  275. optLoading: false,
  276. optionData: result.data
  277. })
  278. this.props.dispatch(createAction("optional/getColorByGroupsReducer")({colorData: result.data}))
  279. }
  280. //选择的色卡颜色
  281. async _chooseColor(colorData) {
  282. console.log(colorData)
  283. let selectRow = this.state.EditPromData.findIndex(item => item.goodsId == currRow.goodsId && item.baseGoodsOptId == currRow.baseGoodsOptId)
  284. if (selectRow >= 0) {
  285. let params = [];
  286. params[0] = {
  287. goodsId: colorData.children.goodsId,
  288. optResult: colorData.children.custDocGroupName + ":" + colorData.children.attrValName,
  289. uniqueKey: colorData.children.goodsId + "-" + colorData.children.attrValId,
  290. goodsOptVals: [{
  291. prodAttrStrucItemId: colorData.children.prodAttrStrucItemId,
  292. prodAttrStrucItemName: colorData.children.name,
  293. attrValId: colorData.children.attrValId,
  294. attrValCode: colorData.children.attrValCode,
  295. attrValName: colorData.children.attrValName
  296. }]
  297. }
  298. let newRow = {...this.state.EditPromData[selectRow]};
  299. console.log(params)
  300. const result = await authService.saveOptional([{goodsOptDtos: params}])
  301. console.log(result)
  302. if (result.data && result.data.length && result.data[0].goodsOptDtos.length) {
  303. newRow.baseGoodsOptId = result.data[0].goodsOptDtos[0].id
  304. let existIndex = this.state.EditPromData.findIndex(e => e.goodsId == newRow.goodsId && e.ext05 == colorData.children.attrValId);
  305. if (existIndex >= 0 && existIndex != selectRow) {
  306. Toast.show("已存在相同颜色的商品,请重新选择颜色!",{position : toastHeight});
  307. return
  308. }
  309. } else {
  310. this.toast = Toast.show("改颜色未设置价格,请重新选择颜色!",{position : toastHeight});
  311. return
  312. }
  313. newRow.baseGoodsOptValue = colorData.children.custDocGroupName + ":" + colorData.children.attrValName
  314. newRow.ext05 = colorData.children.attrValId
  315. newRow.dealPrice = colorData.goodsPriceByColor[0].price
  316. newRow.dealAmount = newRow.dealPrice * newRow.orderNum
  317. newRow.basePrice = newRow.dealPrice
  318. newRow.amount = newRow.dealAmount
  319. newRow.promPrice = newRow.dealPrice
  320. newRow.salePrice = newRow.dealPrice
  321. newRow.ext09 = newRow.dealPrice + ""
  322. newRow.ext10 = newRow.dealAmount + ""
  323. let newEditPromData = [...this.state.EditPromData];
  324. newEditPromData.splice(selectRow, 1, newRow)
  325. let totalAmount = 0
  326. let totalNum = 0
  327. newEditPromData.forEach(item => {
  328. totalAmount = totalAmount + item.amount
  329. totalNum = totalNum + item.orderNum
  330. })
  331. let goodsAmount = totalAmount
  332. let totalAmountCopy = totalAmount
  333. this.setState({
  334. showOptModal: false,
  335. EditPromData : newEditPromData,
  336. totalAmount,
  337. goodsAmount,
  338. totalNum,
  339. totalAmountCopy
  340. })
  341. currRow = {}
  342. } else {
  343. this.toast = Toast.show("选配商品已被删除!",{position : toastHeight});
  344. this.setState({
  345. showOptModal: false
  346. })
  347. currRow = {}
  348. }
  349. }
  350. addGoods(goods) {
  351. console.log('goods==========>',goods)
  352. console.log('this.state.EditPromData======>',this.state.EditPromData)
  353. let existItem = this.state.EditPromData.find(e => e.goodsCode == goods.code && !e.baseGoodsOptId)
  354. if (existItem) {
  355. Toast.show("已存在重复的商品,请重新选择!",{position : toastHeight});
  356. return
  357. }
  358. if (goods.id) {
  359. let newItem = {
  360. amount: goods.basePrice,
  361. baseGoodsOptId: "",
  362. baseGoodsOptValue: "",
  363. basePrice: goods.basePrice,
  364. conversionRate: 1,
  365. dealAmount: goods.basePrice,
  366. dealPrice: goods.basePrice,
  367. deliveryNum: 0,
  368. dr: 0,
  369. expenseOrderCode: "",
  370. ext14: goods.categoryCode,
  371. ext15: goods.categoryName,
  372. goodsCode: goods.code,
  373. goodsDisplayName: goods.displayName,
  374. goodsId: goods.id,
  375. goodsName: goods.name,
  376. id: '',
  377. isGift: 0,
  378. isOptional: goods.isOptional,
  379. mainNum: 1,
  380. mainNumUnitCode: goods.basicUnitCode,
  381. mainNumUnitId: goods.basicUnitId,
  382. mainNumUnitName: goods.basicUnitName,
  383. model: goods.model,
  384. ncProductCode: goods.ncProductCode,
  385. offsetAmount: 0,
  386. orderNum: 1,
  387. orderNumUnitCode: goods.basicUnitCode,
  388. orderNumUnitId: goods.basicUnitId,
  389. orderNumUnitName: goods.basicUnitName,
  390. originalGoodsId: goods.id,
  391. persistStatus: 'nrm',
  392. productGradeCode: goods.productGradeCode,
  393. productGradeId: goods.productGradeId,
  394. productGradeName: goods.productGradeName,
  395. productId: goods.productId,
  396. productLineCode: goods.productLineCode,
  397. productLineId: goods.productLineId,
  398. productLineName: goods.productLineName,
  399. promAmount: 0,
  400. promPrice: goods.basePrice,
  401. refundNum: 0,
  402. reqOrderAttachments: [],
  403. reqOrderId: this.props.promData.reqOrderItems[0].reqOrderId,
  404. reqOrderItemBoms: [],
  405. reqOrderPromRels: [],
  406. returnMaxOrderNum: 0,
  407. returnNum: 0,
  408. // rowNum: (this.state.EditPromData.length * 10) + "",
  409. salePrice: goods.basePrice,
  410. signNum: 0,
  411. specification: goods.specification,
  412. stockInNum: 0,
  413. stockOutNum: 0,
  414. weight: goods.netWeight
  415. }
  416. const newData = [...this.state.EditPromData];
  417. newData.push(newItem);
  418. console.log('this.props.promData.reqOrderItems[0].reqOrderId',this.props.promData.reqOrderItems[0].reqOrderId)
  419. let totalAmount = 0
  420. let totalNum = 0
  421. newData.forEach(item => {
  422. totalAmount = totalAmount + item.amount
  423. totalNum = totalNum + item.orderNum
  424. })
  425. let goodsAmount = totalAmount
  426. let totalAmountCopy = totalAmount
  427. this.setState({EditPromData: newData,
  428. showGoodsModal: false,
  429. totalAmount,
  430. totalNum,
  431. goodsAmount,
  432. totalAmountCopy})
  433. }
  434. }
  435. //删除商品
  436. deleteGoodsFn(indexParent) {
  437. this.state.EditPromData.splice(indexParent, 1)
  438. this.setState({ Loading: true, giftSelected: [] })
  439. if (
  440. this.props.navigation.state.params.SaleOrSupplier.isPrimaryChannel == 1
  441. ) {
  442. this.props
  443. .dispatch(
  444. createAction('orderedit/getProm')({
  445. promInfo: {
  446. customerId: CUSTOMERINFO.id,
  447. saleOrgId: this.props.navigation.state.params.SaleOrSupplier
  448. .SaleOrSupplierId,
  449. isPrimaryChannel: this.props.navigation.state.params
  450. .SaleOrSupplier.isPrimaryChannel,
  451. reqOrderItems: this.state.EditPromData,
  452. },
  453. })
  454. )
  455. .finally(() => {
  456. if (this.props.promData) {
  457. this.CountNumFn(
  458. true,
  459. '',
  460. '',
  461. this.props.promData.reqOrderItems || this.state.EditPromData
  462. )
  463. }
  464. //this.autoShowGiftRow()
  465. this.setState({ Loading: false })
  466. })
  467. } else {
  468. this.CountNumFn(true, '', '', this.state.EditPromData)
  469. this.setState({ Loading: false })
  470. }
  471. }
  472. // 抽出所有商品的产品线
  473. getProductLines() {
  474. let productLineIds = []
  475. this.state.EditPromData.map(item => {
  476. productLineIds.push(item.productLineId)
  477. })
  478. return productLineIds
  479. }
  480. // 检查信用
  481. creditCheck(reqOrderItems) {
  482. this.props.dispatch(
  483. createAction('orderedit/getCreditCheck')({
  484. searchInfo: {
  485. saleOrgId: this.props.navigation.state.params.SaleOrSupplier
  486. .SaleOrSupplierId,
  487. customerId: CUSTOMERINFO.id,
  488. reqOrderItems: reqOrderItems || this.state.EditPromData,
  489. saleModel: '01',
  490. },
  491. })
  492. )
  493. }
  494. // 订单数据集 正常态
  495. getOrderData() {
  496. this.state.EditPromData.map(
  497. item => (item.id = null)
  498. // dealPrice:,//成交价格
  499. // offsetAmount:,//行分摊促销金额
  500. // (dealAmount = (item.basePrice || item.salePrice) * item.orderNum), //成交金额
  501. // (amount = (item.basePrice || item.salePrice) * item.orderNum)
  502. // currency,//行币种
  503. )
  504. const {
  505. addressDefault,
  506. billwayDefault,
  507. invoiceDefault,
  508. transportDefault,
  509. } = this.props
  510. const postData = {
  511. id: this.props.navigation.state.params.id || '',
  512. currency: CURRENCY.id, // 币种
  513. currencySign: CURRENCY.currencySign, // 币符
  514. currencyPriceScale: CURRENCY.currencyPriceScale, // 币种单价精度
  515. currencyAmountScale: CURRENCY.currencyAmountScale, // 币种金额精度
  516. customerId: CUSTOMERINFO.id,
  517. // persistStatus: "nrm", //数据操作状态 'nrm'为无变化 'new'为新增
  518. saleOrgId: this.props.navigation.state.params.SaleOrSupplier
  519. .SaleOrSupplierId, // 销售组织,即供应商
  520. deliveryDate: new Date(this.state.deliveryTime).getTime(), // 期望收货日期
  521. totalNum: this.state.totalNum, // 总数量
  522. totalDealAmount: this.state.totalAmount, // 总成交金额
  523. totalWeight: this.state.totalWeight, // 总重量
  524. totoalVolume: this.state.totoalVolume, // 总体积
  525. // orderSource: "portal", // 订单来源
  526. remark: this.state.remark, // 订单备注
  527. totalAmount: this.state.goodsAmount, // 冲抵前金额
  528. offsetAmount: this.state.offsetAmount, // 费用冲抵金额
  529. saleModel: '01', //销售模式 具体开头部
  530. reqOrderSource: '01', //订单来源
  531. underPaymentModeId: this.state.payWayDef.code, //订单支付方式
  532. srcOrderId: this.props.navigation.state.params.id || '',
  533. reqOrderReceiveAddress: {
  534. reqOrderId: addressDefault.id,
  535. receiveAddressId: addressDefault.id, // 收货地址id
  536. receiver: addressDefault.receiver, // 收货人
  537. receiverTel: addressDefault.receiverTel, // 电话
  538. receiverPhone: addressDefault.receiverPhone, // 手机
  539. receiverProvince: addressDefault.receiverProvince, // 省
  540. receiverCity: addressDefault.receiverCity, // 市
  541. receiverDistrict: addressDefault.receiverDistrict, // 区
  542. receiverTown: addressDefault.receiverTown, // 镇
  543. receiverAddress: addressDefault.receiverAddress, // 详细地址
  544. receiverZipcode: addressDefault.receiverZipcode, // 邮编
  545. },
  546. reqOrderInvoice: {
  547. reqOrderId: invoiceDefault.id,
  548. invoiceId: invoiceDefault.id, // 发票id
  549. invoiceType: invoiceDefault.invoiceType, // 发票类型
  550. invoiceContent: invoiceDefault.invoiceContent, // 开票项目
  551. invoiceTitle: invoiceDefault.invoiceTitle, // 发票抬头
  552. invoiceTaxId: invoiceDefault.invoiceTaxId, // 纳税人识别码
  553. invoiceBank: invoiceDefault.invoiceBank, // 开户银行
  554. invoiceAccount: invoiceDefault.invoiceAccount, // 开户账户
  555. invoiceSubBank: invoiceDefault.invoiceSubBank, // 支行
  556. },
  557. reqOrderItems: this.state.EditPromData,
  558. }
  559. transportDefault && transportDefault.id
  560. ? (postData.transportModeId = transportDefault.id)
  561. : null // 运输方式
  562. billwayDefault && billwayDefault.id
  563. ? (postData.settleModeId = billwayDefault.id)
  564. : null // 结算方式
  565. return postData
  566. }
  567. // 从订单列表过来的订单数据集 封装暂存态的数据
  568. getOrderFromList() {
  569. this.state.EditPromData.map(item => (item.id = null))
  570. let EditDataCopy = JSON.parse(JSON.stringify(this.state.EditPromData)),
  571. EditData = {}
  572. const {
  573. addressDefault,
  574. billwayDefault,
  575. invoiceDefault,
  576. transportDefault,
  577. } = this.props
  578. EditData.id = this.props.navigation.state.params.type?'':(this.props.navigation.state.params.id || '')
  579. EditData.orderCode = this.props.navigation.state.params.type?'':(this.props.navigation.state.params.data.orderCode || '')
  580. EditData.currency = CURRENCY.id // 币种
  581. EditData.currencySign = CURRENCY.currencySign // 币符
  582. EditData.currencyPriceScale = CURRENCY.currencyPriceScale // 币种单价精度
  583. EditData.currencyAmountScale = CURRENCY.currencyAmountScale // 币种金额精度
  584. EditData.customerId = CUSTOMERINFO.id
  585. // 地址
  586. EditData.reqOrderReceiveAddress = addressDefault
  587. // 发票信息
  588. EditData.reqOrderInvoice = invoiceDefault
  589. // EditData.orderSource = "portal"; // 订单来源
  590. EditData.srcOrderId = this.props.navigation.state.params.id || ''
  591. // 供应商
  592. EditData.saleOrgId = this.props.navigation.state.params.SaleOrSupplier.SaleOrSupplierId
  593. EditData.saleOrgCode = this.props.navigation.state.params.SaleOrSupplier.SaleOrSupplierCode
  594. EditData.saleOrgName = this.props.navigation.state.params.SaleOrSupplier.SaleOrSupplierName
  595. EditData.isPrimaryChannel = this.props.navigation.state.params.SaleOrSupplier.isPrimaryChannel
  596. // 结算方式
  597. EditData.settleModeCode = billwayDefault.code
  598. EditData.settleModeId = billwayDefault.id
  599. EditData.settleModeName = billwayDefault.name
  600. // 运输方式
  601. EditData.transportModeId = transportDefault.id
  602. EditData.transportModeCode = transportDefault.code
  603. EditData.transportModeName = transportDefault.name
  604. EditData.reqOrderItems = EditDataCopy
  605. ;(EditData.underPaymentModeId = this.state.payWayDef.code), //订单支付方式
  606. (EditData.remark = this.state.remark) // 订单备注
  607. EditData.totalAmount = this.state.goodsAmount // 冲抵前金额
  608. EditData.offsetAmount = this.state.offsetAmount // 费用冲抵金额
  609. EditData.deliveryDate = new Date(this.state.deliveryTime).getTime() // 期望收货日期
  610. EditData.totalNum = this.state.totalNum // 总数量
  611. EditData.totalDealAmount = this.state.totalAmount // 总成交金额
  612. EditData.totalWeight = this.state.totalWeight // 总重量
  613. EditData.totoalVolume = this.state.totoalVolume // 总体积
  614. EditData.saleModel = '01' //销售模式 具体开头部
  615. EditData.reqOrderSource = '01' //订单来源
  616. return EditData
  617. }
  618. // 促销后补充商品行
  619. transportPromData(postData) {
  620. const giftData = JSON.parse(JSON.stringify(this.state.giftSelected))
  621. // 如果为整单则在表头加入促销信息
  622. if (
  623. this.props.promData &&
  624. this.props.promData.orderPriceProm &&
  625. Object.keys(this.props.promData.orderPriceProm).length > 0
  626. ) {
  627. const orderPriceProm = this.props.promData.orderPriceProm
  628. postData.reqOrderPromRels = [
  629. {
  630. activityId: orderPriceProm.activityId,
  631. ruleId: orderPriceProm.ruleId,
  632. description: orderPriceProm.description,
  633. promWay: 2, // 1 买赠 2 降价
  634. isWhole: 1, // 1 整单
  635. },
  636. ]
  637. }
  638. // 如果选择促销商品后,在商品行加入买赠商品,其中商品行中的促销信息在OrderGifts中回调封装
  639. if (giftData && giftData.length > 0) {
  640. giftData.map((item,index) => {
  641. item.id = null
  642. item.isGift = 1
  643. item.basePrice = 0
  644. item.salePrice = 0
  645. item.promPrice = 0
  646. item.dealPrice = 0
  647. item.amount = 0 // 金额
  648. item.promAmount = 0 // 均摊到行上的整单降价促销金额
  649. item.dealAmount = 0 // 成交金额
  650. item.ffsetAmount = 0 // 均摊到行上的费用冲抵金额
  651. item.orderNum = 0
  652. item.rowNum = postData.reqOrderItems.length+parseInt(index)+1
  653. item.promotinId = item.activityId
  654. })
  655. postData.reqOrderItems = postData.reqOrderItems.concat(giftData)
  656. }
  657. return postData
  658. }
  659. // 补充BOM信息
  660. fillGoodsBomInfo(postData) {
  661. // 之前步骤方便显示,将子件信息存在每个母件reqOrderItems中,在补充Bom时,将子件信息抽出赋在外部字段(reqOrderItemBoms)中,并将母件的自己字段删除
  662. let newReqOrderItemBoms = []
  663. postData.reqOrderItems.forEach((data, index) => {
  664. data.persistStatus = 'new'
  665. data.rowNum = (index + 1) * 10
  666. data.ext09 = data.dealPrice;
  667. data.ext10 = data.dealAmount;
  668. if (data.reqOrderItemBoms && data.reqOrderItemBoms.length > 0) {
  669. data.reqOrderItemBoms.forEach(bomData => {
  670. bomData.parentRowNum = data.rowNum
  671. bomData.parentGoodsName = data.goodsDisplayName
  672. })
  673. newReqOrderItemBoms = newReqOrderItemBoms.concat(data.reqOrderItemBoms)
  674. }
  675. delete data.reqOrderItemBoms
  676. })
  677. postData.reqOrderItemBoms = newReqOrderItemBoms
  678. // 判断是否母件是否有子件信息,如果有:则将子件信息集合中数据封装为新结构;如果无,则将商品行复制添加到子件信息集合中
  679. if (postData.reqOrderItemBoms && postData.reqOrderItemBoms.length > 0) {
  680. const reqOrderItemBoms = this.bomStructureDeal(postData.reqOrderItemBoms)
  681. postData.reqOrderItemBoms = reqOrderItemBoms
  682. } else {
  683. const reqOrderItems = postData.reqOrderItems
  684. const reqOrderItemBoms = reqOrderItems.map((item, index) => {
  685. const translate = {
  686. parentRowNum: item.rowNum,
  687. parentGoodsId: item.goodsId,
  688. persistStatus: 'new',
  689. parentGoodsCode: '', // item.goodsCode,
  690. parentGoodsName: '', // item.goodsDisplayName,
  691. childGoodsQty: 1,
  692. orderNumUnit: item.orderNumUnitName,
  693. mainNumUnit: item.mainNumUnitName,
  694. }
  695. const newItem = { ...item, ...translate }
  696. return newItem
  697. })
  698. postData.reqOrderItemBoms = reqOrderItemBoms
  699. }
  700. return postData
  701. }
  702. // 子件信息数据结构处理
  703. bomStructureDeal(bomData) {
  704. const reqOrderItemBoms = bomData.map((child, index) => {
  705. const translate = {
  706. baseGoodsOptId: child.baseGoodsOptId,
  707. baseGoodsOptValue: child.baseGoodsOptValue,
  708. rowNum: (index + 1) * 10,
  709. parentRowNum: child.parentRowNum,
  710. parentGoodsId: child.parentGoodsId,
  711. parentGoodsName: child.parentGoodsName,
  712. mainNum: '',
  713. goodsName: child.childGoodsName,
  714. goodsCode: child.childGoodsCode,
  715. goodsId: child.childGoodsId,
  716. version: child.childGoodsVersion,
  717. measurementUnitId: child.childGoodsUnitId,
  718. measurementUnitCode: child.childGoodsUnitCode,
  719. measurementUnitName: child.childGoodsUnitName,
  720. orderNumUnitId: child.childGoodsUnitId,
  721. orderNumUnitCode: child.childGoodsUnitCode,
  722. orderNumUnitName: child.childGoodsUnitName,
  723. orderNum: child.childGoodsQty,
  724. childGoodsQty: child.childGoodsQty,
  725. //
  726. persistStatus: 'new',
  727. mainNumUnit: child.childGoodsUnitName,
  728. }
  729. return translate
  730. })
  731. return reqOrderItemBoms
  732. }
  733. // 订单提交暂存
  734. async editFinish(ident) {
  735. let isReturnTab = false,
  736. result = [],
  737. flag = false,
  738. errReturn = false,
  739. editSubmlitData =
  740. this.props.navigation.state.params.comefrom == 'temporarily'
  741. ? this.getOrderFromList()
  742. : this.getOrderData()
  743. //运输方式为必选项
  744. if(!editSubmlitData.transportModeId) {
  745. this.toast = Toast.show("请选择一种运输方式",{position : toastHeight});
  746. return;
  747. }
  748. editSubmlitData = this.fillGoodsBomInfo(editSubmlitData)
  749. if (this.props.creditData && this.props.creditData.length > 0) {
  750. let alertText = []
  751. this.props.creditData.map(item => {
  752. if (item.thisProdLineAmount > item.creditBalance) {
  753. alertText.push(item.productLineName)
  754. flag = true
  755. }
  756. })
  757. if (flag) {
  758. this.toast = Toast.show(`${alertText.join(',')}金额超过信用余额`, {
  759. position: toastHeight,
  760. })
  761. }
  762. }
  763. if (ident === 'Temporary') {
  764. // 暂存提交
  765. this.setState({ temporaryLoading: true })
  766. result = await authService.temporaryOrder(editSubmlitData).catch(err => {
  767. this.setState({ temporaryLoading: false })
  768. errReturn = true
  769. if (this.toast) {
  770. Toast.hide(this.toast)
  771. }
  772. this.toast = Toast.show(err.message, { position: toastHeight })
  773. console.log(
  774. err,
  775. '-----订单编辑-暂存订单报错的完整信息' +
  776. '\n' +
  777. '具体错误显示--->' +
  778. err.response.data.message
  779. )
  780. })
  781. this.setState({ temporaryLoading: false })
  782. } else if (ident === 'Submit') {
  783. //补充商品行
  784. editSubmlitData = this.transportPromData(editSubmlitData)
  785. if (this.state.payWayDef.code == 'PayFirst') {
  786. // 在线支付 需要把errReturn设置成false
  787. this.setState({ temporaryLoading: true })
  788. result = await authService
  789. .temporaryOrder(editSubmlitData)
  790. .catch(err => {
  791. this.setState({ temporaryLoading: false })
  792. errReturn = false
  793. this.toast = Toast.show(err.message, { position: toastHeight })
  794. console.log(
  795. err,
  796. '-----订单编辑-暂存订单报错的完整信息' +
  797. '\n' +
  798. '具体错误显示--->' +
  799. err.response.data.message
  800. )
  801. })
  802. this.setState({ temporaryLoading: false })
  803. this.props.dispatch(
  804. NavigationActions.navigate({
  805. routeName: 'OrderPay',
  806. params: {
  807. submitData: { id: result.data.id },
  808. totalAmount: result.data.totalDealAmount,
  809. callBack: () => {
  810. this.props.dispatch(
  811. NavigationActions.navigate({
  812. routeName: 'OrderHome',
  813. })
  814. )
  815. },
  816. },
  817. })
  818. )
  819. } else {
  820. this.setState({ submitLoading: true })
  821. result = await authService.postOrder(editSubmlitData).catch(err => {
  822. this.setState({ submitLoading: false })
  823. errReturn = true
  824. this.toast = Toast.show(err.response.data.message + ";开始暂存订单!", { position: toastHeight })
  825. this.editFinish("Temporary")
  826. console.log(
  827. err,
  828. '-----订单编辑-提交订单报错的完整信息' +
  829. '\n' +
  830. '具体错误显示||--->:' +
  831. err.response.data.message
  832. )
  833. })
  834. this.setState({ submitLoading: false })
  835. }
  836. }
  837. // 请求数据报错,则不进行下一步
  838. if (!errReturn) {
  839. if (result.data && Object.keys(result.data).length > 0) {
  840. isReturnTab = true
  841. }
  842. if (isReturnTab) {
  843. if (
  844. this.props.navigation.state.params.cartId &&
  845. this.props.navigation.state.params.cartId.length > 0
  846. ) {
  847. this.props.navigation.state.params.cartId.forEach(item => {
  848. this.props.dispatch(
  849. createAction('shoppingcart/deleteShop')({
  850. params: {
  851. id: item,
  852. customer: CUSTOMERINFO.id,
  853. },
  854. })
  855. )
  856. })
  857. }
  858. // 返回OrderHome
  859. this.props.dispatch(
  860. NavigationActions.navigate({
  861. routeName: 'OrderHome',
  862. action: NavigationActions.navigate({ routeName: 'OrderHome' }),
  863. })
  864. )
  865. }
  866. }
  867. }
  868. // 头部
  869. header() {
  870. return (
  871. <View
  872. style={{
  873. height: HEADERSTYLE.height,
  874. paddingTop: HEADERSTYLE.paddingTop + 5,
  875. backgroundColor: '#fff',
  876. borderBottomColor: '#eee',
  877. borderBottomWidth: 1 / PixelRatio.get(),
  878. }}
  879. >
  880. <View
  881. style={{
  882. flex: 1,
  883. justifyContent: 'center',
  884. }}
  885. >
  886. <TouchableOpacity
  887. style={{ position: 'absolute', left: 10, flexDirection: 'row' }}
  888. onPress={() => this.props.dispatch(NavigationActions.back())}
  889. >
  890. <Icon
  891. name="icon-icon-fanhui"
  892. size={20}
  893. color={'#666'}
  894. style={{ marginTop: 4 }}
  895. />
  896. <Text
  897. style={{
  898. fontSize: 14,
  899. lineHeight: 20,
  900. color: '#666',
  901. alignSelf: 'center',
  902. }}
  903. >
  904. 返回
  905. </Text>
  906. </TouchableOpacity>
  907. <Text
  908. style={{
  909. alignSelf: 'center',
  910. fontSize: 18,
  911. lineHeight: 25,
  912. letterSpacing: 0.19,
  913. color: '#333',
  914. }}
  915. >
  916. 订单编辑
  917. </Text>
  918. <TouchableOpacity
  919. style={{ position: 'absolute', right: 10 }}
  920. onPress={
  921. () =>
  922. this.setState({
  923. activeAllCollaps: !this.state.activeAllCollaps,
  924. })
  925. // this._info.setActive()
  926. }
  927. >
  928. <Text
  929. style={{
  930. fontSize: 14,
  931. lineHeight: 20,
  932. letterSpacing: 0.17,
  933. color: '#666',
  934. }}
  935. >
  936. 折叠
  937. </Text>
  938. </TouchableOpacity>
  939. </View>
  940. </View>
  941. )
  942. }
  943. // 供应商
  944. supplier(supplierDefault) {
  945. return (
  946. <View
  947. style={{
  948. backgroundColor: '#FFF',
  949. padding: 10,
  950. flexDirection: 'row',
  951. borderBottomColor: '#eee',
  952. borderBottomWidth: 1,
  953. }}
  954. >
  955. <Text
  956. style={{
  957. fontSize: 14,
  958. lineHeight: 20,
  959. letterSpacing: 0.17,
  960. color: '#333',
  961. fontWeight: '600',
  962. }}
  963. >
  964. {supplierDefault.SaleOrSupplierName}
  965. </Text>
  966. </View>
  967. )
  968. }
  969. // 底部按钮
  970. bottomTouch() {
  971. let touchArr = [],
  972. touchAtt = [
  973. {
  974. touchName: '暂存',
  975. background: '#FFF',
  976. textColor: '#666',
  977. loading: this.state.temporaryLoading,
  978. itemonpress: () => {
  979. this.editFinish('Temporary')
  980. },
  981. },
  982. {
  983. touchName: '提交',
  984. background: '#E70013',
  985. textColor: '#FFF',
  986. loading: this.state.submitLoading,
  987. itemonpress: () => {
  988. this.editFinish('Submit')
  989. },
  990. },
  991. ]
  992. for (let i = 0; i < touchAtt.length; i++) {
  993. if (touchAtt[i].loading) {
  994. touchArr.push(
  995. <View
  996. onPress={() => touchAtt[i].itemonpress()}
  997. key={i}
  998. style={{
  999. flex: 1,
  1000. backgroundColor: touchAtt[i].background,
  1001. justifyContent: 'center',
  1002. borderRightColor: '#eee',
  1003. borderRightWidth: 1 / PixelRatio.get(),
  1004. }}
  1005. >
  1006. <ActivityIndicator />
  1007. </View>
  1008. )
  1009. } else {
  1010. touchArr.push(
  1011. <TouchableOpacity
  1012. disabled={
  1013. this.state.temporaryLoading || this.state.submitLoading
  1014. ? true
  1015. : false
  1016. }
  1017. onPress={() => touchAtt[i].itemonpress()}
  1018. key={i}
  1019. style={{
  1020. flex: 1,
  1021. backgroundColor: touchAtt[i].background,
  1022. justifyContent: 'center',
  1023. borderRightColor: '#eee',
  1024. borderRightWidth: 1 / PixelRatio.get(),
  1025. }}
  1026. >
  1027. <Text
  1028. style={{
  1029. fontSize: 14,
  1030. lineHeight: 20,
  1031. color: touchAtt[i].textColor,
  1032. alignSelf: 'center',
  1033. }}
  1034. >
  1035. {touchAtt[i].touchName}
  1036. </Text>
  1037. </TouchableOpacity>
  1038. )
  1039. }
  1040. }
  1041. return touchArr
  1042. }
  1043. // 运输方式、结算方式等
  1044. viewRender(data, inputTextLOck) {
  1045. let viewRen = [],
  1046. size = 16
  1047. for (let i = 0; i < data.length; i++) {
  1048. if (data[i].iconName == 'icon-icon-jianjinzhishiqi') {
  1049. size = 24
  1050. }
  1051. viewRen.push(
  1052. <View key={i}>
  1053. <TouchableOpacity
  1054. onPress={() => data[i].onPress()}
  1055. style={{
  1056. paddingVertical: 10,
  1057. paddingLeft: 10,
  1058. paddingRight:
  1059. data[i].iconName == 'icon-icon-jianjinzhishiqi' ? 3 : 10,
  1060. flexDirection: 'row',
  1061. justifyContent: 'space-between',
  1062. borderBottomColor: '#EEE',
  1063. borderBottomWidth: 1 / PixelRatio.get(),
  1064. }}
  1065. >
  1066. <Text style={styles.text333}>{data[i].viewName}</Text>
  1067. <View style={{ flexDirection: 'row' }}>
  1068. <Text
  1069. style={{
  1070. fontSize: 14,
  1071. lineHeight: 20,
  1072. color: '#666',
  1073. marginRight: 10,
  1074. }}
  1075. >
  1076. {data[i].rightName}
  1077. </Text>
  1078. <Icon name={data[i].iconName} size={size} color={'#ccc'} />
  1079. </View>
  1080. </TouchableOpacity>
  1081. {/* 折叠 */}
  1082. <Collapsible collapsed={i !== this.state.activeMethod}>
  1083. {data[i].dataArr &&
  1084. (data[i].dataArr || []).map((item, key) => (
  1085. <TouchableOpacity
  1086. onPress={() => {
  1087. if (data[i].viewName == '运输方式') {
  1088. this.props.dispatch(
  1089. createAction('mine/TransportSetstate')(item)
  1090. )
  1091. this.setState({ transportSel: item.name })
  1092. // this.setState({ transportVal: item });
  1093. } else if (data[i].viewName == '结算方式') {
  1094. this.props.dispatch(
  1095. createAction('mine/BillwaySetstate')(item)
  1096. )
  1097. this.setState({ billWaySel: item.name })
  1098. // this.setState({ billWay: item });
  1099. } else if (data[i].viewName == '支付方式') {
  1100. this.setState({ payWayDef: item, paySel: item.name })
  1101. }
  1102. // 继续写发票和发货日期的更新值
  1103. // else if(){}
  1104. // 收起折叠板
  1105. this.setState({ activeMethod: 'fjidos' })
  1106. }}
  1107. key={key}
  1108. style={{
  1109. flexDirection: 'row',
  1110. justifyContent: 'space-between',
  1111. padding: 10,
  1112. }}
  1113. >
  1114. <Text
  1115. style={{
  1116. fontSize: 14,
  1117. lineHeight: 20,
  1118. color: '#666',
  1119. }}
  1120. >
  1121. {item.name || ''}
  1122. </Text>
  1123. {data[i].viewName == '支付方式' ? (
  1124. this.state.paySel ==
  1125. (this.state.paySel == 0 ? key : item.name) ? (
  1126. <Icon
  1127. name={'icon-icon-duigou'}
  1128. size={16}
  1129. color={'#E14C46'}
  1130. style={{ marginRight: 30 }}
  1131. />
  1132. ) : null
  1133. ) : data[i].viewName == '运输方式' ? (
  1134. this.state.transportSel ==
  1135. (this.state.transportSel == 0 ? key : item.name) ? (
  1136. <Icon
  1137. name={'icon-icon-duigou'}
  1138. size={16}
  1139. color={'#E14C46'}
  1140. style={{ marginRight: 30 }}
  1141. />
  1142. ) : null
  1143. ) : this.state.billWaySel ==
  1144. (this.state.billWaySel == 0 ? key : item.name) ? (
  1145. <Icon
  1146. name={'icon-icon-duigou'}
  1147. size={16}
  1148. color={'#E14C46'}
  1149. style={{ marginRight: 30 }}
  1150. />
  1151. ) : null}
  1152. </TouchableOpacity>
  1153. ))}
  1154. </Collapsible>
  1155. {!inputTextLOck ? null : (
  1156. <View
  1157. style={{
  1158. paddingHorizontal: 10,
  1159. paddingBottom: 3,
  1160. flexDirection: 'row',
  1161. }}
  1162. >
  1163. <Text style={[styles.text333, { alignSelf: 'center' }]}>
  1164. {data[i].inputName}
  1165. </Text>
  1166. <Input
  1167. style={{
  1168. marginTop: 4,
  1169. width: width / 1.15,
  1170. }}
  1171. isICon={false}
  1172. blurOnSubmit={true}
  1173. textInputBacg={'#FFF'}
  1174. placeholder={data[i].inputDefault}
  1175. placeholderTextColor={'#CCC'}
  1176. onchangeFn={e => {
  1177. this.setState({ remark: e })
  1178. }}
  1179. />
  1180. </View>
  1181. )}
  1182. </View>
  1183. )
  1184. }
  1185. return viewRen
  1186. }
  1187. // 地址回调
  1188. callback(e) {
  1189. this.props.dispatch(createAction('mine/AdressSetstate')(e.item))
  1190. // this.setState({ addressDefault: e.item });
  1191. }
  1192. // 发票回调
  1193. invoiceCallback(e) {
  1194. this.props.dispatch(createAction('mine/InvoiceSetstate')(e))
  1195. }
  1196. async TimeAndroid() {
  1197. const { action, year, month, day } = await DatePickerAndroid.open({
  1198. date: new Date(),
  1199. minDate: new Date(),
  1200. mode: 'spinner',
  1201. })
  1202. if (action !== DatePickerAndroid.dismissedAction) {
  1203. this.setState({
  1204. deliveryTime: moment(
  1205. `${year}-${month + 1}-${day}`,
  1206. 'YYYY-MM-DD'
  1207. ).format('YYYY-MM-DD'),
  1208. })
  1209. // 这里开始可以处理用户选好的年月日三个参数:year, month (0-11), day
  1210. }
  1211. }
  1212. // 清除费用冲抵 输入框
  1213. ClearOffset() {
  1214. //this.AverageRef.setClear()
  1215. this.setState({ giftSelected: [] })
  1216. }
  1217. async combinedFn(init, item, nv) {
  1218. this.ClearOffset()
  1219. if (!init) {
  1220. this.state.EditPromData[item].orderNum = nv
  1221. this.state.EditPromData[item].mainNum = accMul(
  1222. this.state.EditPromData[item].orderNum,
  1223. this.state.EditPromData[item].conversionRate
  1224. )
  1225. this.setState({ Loading: true })
  1226. // await this.promDispatch(this.state.EditPromData);
  1227. await this.props.dispatch(
  1228. createAction('orderedit/getProm')({
  1229. promInfo: {
  1230. customerId: CUSTOMERINFO.id,
  1231. saleOrgId: this.props.navigation.state.params.SaleOrSupplier
  1232. .SaleOrSupplierId,
  1233. isPrimaryChannel: this.props.navigation.state.params.SaleOrSupplier
  1234. .isPrimaryChannel,
  1235. reqOrderItems: this.state.EditPromData,
  1236. },
  1237. })
  1238. )
  1239. // this.creditCheck(
  1240. // this.props.promData.reqOrderItems || this.state.EditPromData
  1241. // )
  1242. // this.creditCheck(this.props.promData.reqOrderItems);
  1243. }
  1244. this.setState({ Loading: false })
  1245. this.CountNumFn(
  1246. init,
  1247. item,
  1248. nv,
  1249. this.props.promData.reqOrderItems || this.state.EditPromData
  1250. )
  1251. // this.CountNumFn(init, item, nv, this.props.promData.reqOrderItems);
  1252. }
  1253. CountNumFn(init, item, nv, EditPromData) {
  1254. // this.ClearOffset();
  1255. init ? null : (EditPromData[item].orderNum = nv)
  1256. // init ? null : (item.orderNum = nv);
  1257. let amount = 0,
  1258. totalnum = 0,
  1259. totoalvolume = 0,
  1260. totalweight = 0,
  1261. totalProm = 0
  1262. ;(EditPromData || []).map(val => {
  1263. val.dealPrice = val.promPrice
  1264. val.offsetAmount = 0
  1265. val.mainNum = accMul(val.orderNum, val.conversionRate)
  1266. // 金额
  1267. amount = accAdd(
  1268. accMul(val.salePrice || val.basePrice, val.mainNum),
  1269. amount
  1270. )
  1271. // 商品行总促销金额 = 促销价格*主数量
  1272. totalProm = accAdd(
  1273. accSub(accMul(val.promPrice, val.mainNum), val.promAmount || 0),
  1274. totalProm
  1275. )
  1276. totalnum = accAdd(val.orderNum, totalnum)
  1277. totoalvolume = accAdd(val.volume, totoalvolume)
  1278. totalweight += accMul(val.weight, val.mainNum)
  1279. val.dealAmount = accMul(val.dealPrice, val.mainNum)
  1280. val.amount = accMul(val.salePrice || val.basePrice, val.mainNum)
  1281. })
  1282. this.setState({
  1283. totalAmount: accSub(amount, accSub(amount, totalProm)),
  1284. totalAmountCopy: accSub(amount, accSub(amount, totalProm)),
  1285. goodsAmount: amount,
  1286. totalNum: totalnum,
  1287. // 促销金额 = 总金额 - 商品行总促销金额
  1288. totalPromAmt: accSub(amount, totalProm),
  1289. totoalVolume: totoalvolume,
  1290. totalWeight: totalweight,
  1291. // 每次增加商品行数量 对冲抵总金额初始化
  1292. offsetAmount: 0,
  1293. EditPromData: EditPromData,
  1294. })
  1295. this.addBoomToData()
  1296. }
  1297. // 当促7销输入数字后对每行商品进行均摊
  1298. AverageBooth(e, MaxOffset) {
  1299. e = parseFloat(e)
  1300. let ToffsetAmount = 0,
  1301. EditPromData = this.state.EditPromData
  1302. // 冲抵输入框的值大于0,则进行--均摊计算---
  1303. if (e > 0 && MaxOffset > 0) {
  1304. // 计算最大可冲抵金额
  1305. if (e >= MaxOffset) {
  1306. ToffsetAmount = MaxOffset
  1307. } else {
  1308. ToffsetAmount = e
  1309. }
  1310. if (ToffsetAmount > this.state.totalAmountCopy) {
  1311. ToffsetAmount = this.state.totalAmountCopy
  1312. }
  1313. // 大于1行的商品,遍历n-1个商品,最后一个商品用总冲抵金额减去除最后一行冲抵金额
  1314. if (EditPromData.length > 1) {
  1315. // 商品除最后一行分摊总金额
  1316. let subOffset = 0,
  1317. rowPromAmt = 0
  1318. for (let i = 0; i < EditPromData.length - 1; i++) {
  1319. // 行促销金额存在rowPromAmt中
  1320. rowPromAmt = accSub(
  1321. accMul(EditPromData[i].promPrice, EditPromData[i].mainNum),
  1322. EditPromData[i].promAmount || 0
  1323. )
  1324. // 行分摊金额
  1325. EditPromData[i].offsetAmount = ScaleUtil(
  1326. accMul(
  1327. accDiv(rowPromAmt, this.state.totalAmountCopy),
  1328. ToffsetAmount
  1329. )
  1330. )
  1331. // 计算除最后一行分摊总金额
  1332. subOffset = accAdd(EditPromData[i].offsetAmount, subOffset)
  1333. // 分摊后成交金额
  1334. EditPromData[i].dealAmount = ScaleUtil(
  1335. accSub(rowPromAmt, EditPromData[i].offsetAmount)
  1336. )
  1337. // 根据分摊后成交金额反算成交价格
  1338. EditPromData[i].dealPrice = ScaleUtil(
  1339. accDiv(EditPromData[i].dealAmount, EditPromData[i].mainNum)
  1340. )
  1341. }
  1342. // 商品最后一行处理
  1343. EditPromData[EditPromData.length - 1].offsetAmount = ScaleUtil(
  1344. accSub(ToffsetAmount, subOffset)
  1345. )
  1346. // 促销金额-冲抵金额 (行)
  1347. EditPromData[EditPromData.length - 1].dealAmount = ScaleUtil(
  1348. accSub(
  1349. accSub(
  1350. accMul(
  1351. EditPromData[EditPromData.length - 1].promPrice,
  1352. EditPromData[EditPromData.length - 1].mainNum
  1353. ),
  1354. EditPromData[EditPromData.length - 1].promAmount || 0
  1355. ),
  1356. EditPromData[EditPromData.length - 1].offsetAmount
  1357. )
  1358. )
  1359. EditPromData[EditPromData.length - 1].dealPrice = ScaleUtil(
  1360. accDiv(
  1361. EditPromData[EditPromData.length - 1].dealAmount,
  1362. EditPromData[EditPromData.length - 1].mainNum
  1363. )
  1364. )
  1365. } else {
  1366. // 如果只有一行数据
  1367. // 则直接进行处理
  1368. EditPromData[0].offsetAmount = ToffsetAmount
  1369. EditPromData[0].dealAmount = ScaleUtil(
  1370. accSub(
  1371. accSub(
  1372. accMul(EditPromData[0].promPrice, EditPromData[0].mainNum),
  1373. EditPromData[0].promAmount || 0
  1374. ),
  1375. EditPromData[0].offsetAmount
  1376. )
  1377. )
  1378. EditPromData[0].dealPrice = ScaleUtil(
  1379. accDiv(EditPromData[0].dealAmount, EditPromData[0].mainNum)
  1380. )
  1381. }
  1382. this.setState({
  1383. totalAmount: accSub(
  1384. accSub(this.state.goodsAmount, this.state.totalPromAmt),
  1385. ToffsetAmount
  1386. ),
  1387. offsetAmount: ToffsetAmount,
  1388. EditPromData: EditPromData,
  1389. })
  1390. } else {
  1391. // 冲抵输入框为0或者输入框为空
  1392. // 则还原各行成交价格/金额 为 销售价格/金额,以及冲抵分摊金额还原为0
  1393. ;(EditPromData || []).forEach(val => {
  1394. val.dealAmount = val.amount
  1395. val.dealPrice = val.promPrice
  1396. val.offsetAmount = 0
  1397. })
  1398. this.setState({
  1399. totalAmount: accSub(this.state.goodsAmount, this.state.totalPromAmt),
  1400. offsetAmount: 0,
  1401. EditPromData: EditPromData,
  1402. })
  1403. }
  1404. this.addBoomToData()
  1405. }
  1406. //控制弹出层隐藏显示
  1407. modalVisible(index) {
  1408. this.setState({
  1409. modalVisible : true,
  1410. index : index,
  1411. num : ""
  1412. })
  1413. }
  1414. //弹出框点击确定
  1415. onModalOk() {
  1416. const {num,index} = this.state;
  1417. if(!(/(^[1-9]\d*$)/.test(num))) {
  1418. Toast.show("请输入正确的数量",{position : toastHeight});
  1419. return;
  1420. }
  1421. this.combinedFn(false,index,num);
  1422. this.setState({
  1423. modalVisible : false
  1424. })
  1425. }
  1426. promInfo(item) {
  1427. let promWay = item.promWay == 1 ? '买赠' : '降价'
  1428. return (
  1429. <View>
  1430. <View style={{ flex: 1, flexDirection: 'row', marginTop: 10 }}>
  1431. <View
  1432. style={{
  1433. paddingHorizontal: 4,
  1434. paddingVertical: 2,
  1435. borderRadius: 100,
  1436. backgroundColor: '#E70013',
  1437. marginRight: 14,
  1438. alignSelf: 'center',
  1439. }}
  1440. >
  1441. <Text style={{ fontSize: 12, lineHeight: 14, color: '#FFF' }}>
  1442. {promWay}
  1443. </Text>
  1444. </View>
  1445. <Text
  1446. numberOfLines={3}
  1447. style={{ flex: 1, fontSize: 12, lineHeight: 17, color: '#333' }}
  1448. >
  1449. {item.description}
  1450. </Text>
  1451. </View>
  1452. </View>
  1453. )
  1454. }
  1455. goodsInfo(item, indexParent) {
  1456. // let optFlag = true,
  1457. let optFlag = false,
  1458. isOptArrs = []
  1459. if (item.baseGoodsOptId) {
  1460. item.isOptional = 1
  1461. }
  1462. item.rowNum = (indexParent + 1) * 10
  1463. if (item.isOptional) {
  1464. isOptArrs.push(item.isOptional)
  1465. } else if (item.reqOrderItemBoms && item.reqOrderItemBoms.length > 0) {
  1466. item.reqOrderItemBoms.forEach(data => {
  1467. isOptArrs.push(data.isOptional)
  1468. })
  1469. }
  1470. if (isOptArrs.some(smdata => smdata == 1)) {
  1471. optFlag = true
  1472. }
  1473. return (
  1474. <View key={item.rowNum}>
  1475. <View style={{ padding: 10, marginTop: 10, backgroundColor: '#FFF' }}>
  1476. {/* 满减/买赠 */}
  1477. <View style={{ paddingBottom: 10 }}>
  1478. <FlatList
  1479. keyExtractor={item => item.ruleId}
  1480. data={item.reqOrderPromRels || []}
  1481. extraData={this.state}
  1482. renderItem={({ item, index }) => this.promInfo(item, index)}
  1483. />
  1484. </View>
  1485. {/* 商品行 */}
  1486. <View style={{ flexDirection: 'row' }}>
  1487. <View style={{ marginLeft: 10}}>
  1488. <Text style={{ fontSize: 13, lineHeight: 18, color: '#333' }}>
  1489. {(indexParent + 1)}
  1490. </Text>
  1491. </View>
  1492. <Image
  1493. source={{ uri: ImageBaseUrl + item.goodsImg } || png}
  1494. style={{ width: 80, height: 80 }}
  1495. />
  1496. <View style={{ marginLeft: 10, flex: 1 }}>
  1497. <View style={{flexDirection:'row'}}>
  1498. <Text style={{ fontSize: 13, lineHeight: 18, color: '#333',width:'90%' }}>
  1499. {item.goodsDisplayName}
  1500. </Text>
  1501. <TouchableOpacity onPress={() =>this.deleteGoodsFn(indexParent)}>
  1502. <Image
  1503. source={deletePng}
  1504. style={{ width: 20, height: 20}}
  1505. />
  1506. </TouchableOpacity>
  1507. </View>
  1508. <View
  1509. style={{
  1510. flexDirection: 'row',
  1511. justifyContent: 'space-between',
  1512. marginTop: 10,
  1513. }}
  1514. >
  1515. <Text style={{ fontSize: 12, lineHeight: 17, color: '#666' }}>
  1516. 型号:{item.model?(item.model.length>10?item.model.substr(0,10):item.model):""}
  1517. </Text>
  1518. </View>
  1519. <View
  1520. style={{
  1521. flexDirection: 'row',
  1522. justifyContent: 'space-between',
  1523. marginTop: 10,
  1524. }}
  1525. >
  1526. <Text style={{ fontSize: 12, lineHeight: 17, color: '#666' }}>
  1527. 规格:{item.specification?(item.specification.split("/")[0]+'/'+item.mainNumUnitName):""}
  1528. </Text>
  1529. </View>
  1530. <View
  1531. style={{
  1532. flexDirection: 'row',
  1533. justifyContent: 'space-between',
  1534. marginTop: 7,
  1535. }}
  1536. >
  1537. {/* <CountNum
  1538. defaultValue={item.orderNum}
  1539. size={25}
  1540. callback={nv => {
  1541. this.combinedFn(false, indexParent, nv)
  1542. }}
  1543. /> */}
  1544. <Text style={{ fontSize: 12, lineHeight: 17, color: '#666' }}>
  1545. 数量:{item.mainNum} {item.mainNumUnitName}
  1546. </Text>
  1547. <Text style={{ fontSize: 12, lineHeight: 17, color: '#666' }}>
  1548. 重量:{item.weight*item.mainNum}{'KG'}
  1549. </Text>
  1550. </View>
  1551. <View style={{
  1552. flexDirection: 'row',
  1553. justifyContent: 'space-between',
  1554. marginTop: 7,
  1555. }}>
  1556. <TouchableOpacity
  1557. style={{
  1558. backgroundColor : '#E70013',
  1559. borderRadius : 100,
  1560. }}
  1561. onPress={() =>this.modalVisible(indexParent)}
  1562. >
  1563. <Text style={{fontSize:12,color:'#fff',padding:5}}>修改数量</Text>
  1564. </TouchableOpacity>
  1565. </View>
  1566. </View>
  1567. </View>
  1568. <View
  1569. style={{
  1570. flexDirection: 'row',
  1571. justifyContent: 'space-between',
  1572. marginTop: 10,
  1573. }}
  1574. >
  1575. <Text style={{ fontSize: 12, lineHeight: 17, color: '#666' }}>
  1576. 成交价:<Text
  1577. style={{ fontSize: 14, lineHeight: 17, color: '#E14C46' }}
  1578. >
  1579. {CURRENCY.currencySign}
  1580. {ScaleUtil(
  1581. item.dealPrice || item.basePrice,
  1582. CURRENCY.currencyPriceScale
  1583. )}
  1584. </Text>
  1585. </Text>
  1586. <Text style={{ fontSize: 12, lineHeight: 17, color: '#666' }}>
  1587. 成交金额:<Text
  1588. style={{ fontSize: 14, lineHeight: 17, color: '#E14C46' }}
  1589. >
  1590. {CURRENCY.currencySign}
  1591. {ScaleUtil(item.dealAmount, CURRENCY.currencyAmountScale)}
  1592. </Text>
  1593. </Text>
  1594. </View>
  1595. </View>
  1596. {/* 选配列表 */}
  1597. {optFlag ? (
  1598. <View
  1599. style={{
  1600. backgroundColor: '#FFF',
  1601. borderTopColor: '#EEE',
  1602. borderTopWidth: 1 / PixelRatio.get(),
  1603. }}
  1604. >
  1605. {this.optView(item, indexParent, true)}
  1606. <FlatList
  1607. keyExtractor={item => item.id}
  1608. data={item.reqOrderItemBoms || []}
  1609. extraData={this.state}
  1610. renderItem={itemSec =>
  1611. this.reqItemBoms(itemSec.item, itemSec.index, item)
  1612. }
  1613. />
  1614. <Collapsible collapsed={this.state.optCollapse != indexParent}>
  1615. <FlatList
  1616. keyExtractor={item => item.id}
  1617. data={item.reqOrderItemBoms || []}
  1618. extraData={this.state}
  1619. renderItem={itemSec =>
  1620. this.reqItemBoms(itemSec.item, itemSec.index, item)
  1621. }
  1622. />
  1623. </Collapsible>
  1624. </View>
  1625. ) : null}
  1626. {/* 重量等信息 */}
  1627. <Collapsible collapsed={this.state.activeAllCollaps}>
  1628. <View style={{ padding: 10, backgroundColor: '#FAFAFA' }}>
  1629. <View
  1630. style={{ flexDirection: 'row', justifyContent: 'space-between' }}
  1631. >
  1632. <Text style={styles.text666}>
  1633. 单价:{CURRENCY.currencySign}
  1634. {item.salePrice}
  1635. </Text>
  1636. <Text style={styles.text666}>
  1637. 金额:{CURRENCY.currencySign}
  1638. {accMul(item.salePrice || item.basePrice, item.mainNum)}
  1639. </Text>
  1640. </View>
  1641. <View
  1642. style={{
  1643. flexDirection: 'row',
  1644. justifyContent: 'space-between',
  1645. marginTop: 3,
  1646. }}
  1647. >
  1648. <Text style={styles.text666}>
  1649. 重量:{item.weight}
  1650. {item.weightUnit}
  1651. </Text>
  1652. <Text style={styles.text666}>
  1653. 体积:{item.volume}
  1654. {item.volumeUnit}
  1655. </Text>
  1656. </View>
  1657. </View>
  1658. </Collapsible>
  1659. </View>
  1660. )
  1661. }
  1662. optView(item, indexParent, collaseFlag, isOptional) {
  1663. const reqBomText = []
  1664. if (item.reqOrderItemBoms && item.reqOrderItemBoms.length > 0) {
  1665. item.reqOrderItemBoms.forEach((data, key) => {
  1666. reqBomText.push(`子件${NumberTranslate(key)}`)
  1667. })
  1668. }
  1669. if (collaseFlag || isOptional) {
  1670. return (
  1671. <View
  1672. style={{
  1673. padding: 10,
  1674. flexDirection: 'row',
  1675. justifyContent: 'space-between',
  1676. }}
  1677. >
  1678. <TouchableOpacity
  1679. activeOpacity={1}
  1680. onPress={() => {
  1681. this.openOptView(item)
  1682. }}
  1683. >
  1684. <View style={{ flexDirection: 'row' }}>
  1685. <Text style={{ fontSize: 12, lineHeight: 17, color: '#333' }}>
  1686. {reqBomText && reqBomText.length > 0 ? '选配项:' : '选 配:'}
  1687. </Text>
  1688. <Text
  1689. numberOfLines={1}
  1690. style={{
  1691. width:
  1692. reqBomText && reqBomText.length > 0
  1693. ? width * 0.4
  1694. : width * 0.75,
  1695. fontSize: 12,
  1696. lineHeight: 17,
  1697. color: '#666',
  1698. }}
  1699. >
  1700. {collaseFlag
  1701. ? reqBomText && reqBomText.length > 0
  1702. ? reqBomText.join()
  1703. : item.baseGoodsOptValue
  1704. : item.baseGoodsOptValue}
  1705. </Text>
  1706. <Image
  1707. resizeMode="contain"
  1708. source={morePng}
  1709. style={{ width: 24, height: 5, alignSelf: 'center' }}
  1710. />
  1711. </View>
  1712. </TouchableOpacity>
  1713. {collaseFlag ? (
  1714. <View style={{ flexDirection: 'row' }}>
  1715. {/* <TouchableOpacity
  1716. onPress={() => {
  1717. item.reqOrderItemBoms && item.reqOrderItemBoms.length > 0
  1718. ? this.state.optCollapse == indexParent
  1719. ? this.setState({ optCollapse: 'shouqi' })
  1720. : this.setState({ optCollapse: indexParent })
  1721. : this.optional._openModal(JSON.parse(JSON.stringify(item)))
  1722. }}
  1723. style={{ alignSelf: 'center' }}
  1724. >
  1725. {item.reqOrderItemBoms && item.reqOrderItemBoms.length > 0 ? (
  1726. this.state.optCollapse == indexParent ? (
  1727. <Text
  1728. style={{ fontSize: 12, lineHeight: 17, color: '#333' }}
  1729. >
  1730. 收起
  1731. </Text>
  1732. ) : (
  1733. <Text
  1734. style={{ fontSize: 12, lineHeight: 17, color: '#333' }}
  1735. >
  1736. 展开
  1737. </Text>
  1738. )
  1739. ) : (
  1740. <Image source={moreDian} style={{ width: 24, height: 5 }} />
  1741. )}
  1742. </TouchableOpacity> */}
  1743. {item.reqOrderItemBoms && item.reqOrderItemBoms.length > 0 ? (
  1744. <View style={{ flexDirection: 'row' }}>
  1745. <Text
  1746. style={{ marginLeft: 8, marginRight: 8, color: '#DDD' }}
  1747. >
  1748. |
  1749. </Text>
  1750. <TouchableOpacity
  1751. onPress={() => {
  1752. this.optional._openModal(
  1753. JSON.parse(JSON.stringify(item)),
  1754. true
  1755. )
  1756. }}
  1757. >
  1758. <Text
  1759. style={{ fontSize: 12, lineHeight: 17, color: '#333' }}
  1760. >
  1761. 选配
  1762. {/* 批量选配 */}
  1763. </Text>
  1764. </TouchableOpacity>
  1765. </View>
  1766. ) : null}
  1767. </View>
  1768. ) : null
  1769. // <TouchableOpacity
  1770. // onPress={() => {
  1771. // this.optional._openModal(JSON.parse(JSON.stringify(item)));
  1772. // }}
  1773. // style={{ alignSelf: "center", paddingRight: 5 }}
  1774. // >
  1775. // <Image source={moreDian} style={{ width: 24, height: 5 }} />
  1776. // </TouchableOpacity>
  1777. }
  1778. </View>
  1779. )
  1780. }
  1781. }
  1782. reqItemBoms(item, index, parentItem) {
  1783. return (
  1784. <View>
  1785. <View
  1786. style={{
  1787. paddingTop: 10,
  1788. paddingHorizontal: 10,
  1789. paddingBottom: item.isOptional ? 0 : 10,
  1790. borderTopColor: '#EEE',
  1791. borderTopWidth: 1 / PixelRatio.get(),
  1792. }}
  1793. >
  1794. <View style={{ flexDirection: 'row' }}>
  1795. <View>
  1796. <Text style={styles.bomTitle}>{`子件${NumberTranslate(
  1797. index
  1798. )}:`}</Text>
  1799. </View>
  1800. <View style={{ flex: 1 }}>
  1801. <Text style={styles.bomTitle}>{item.childGoodsName}</Text>
  1802. <View style={{ flexDirection: 'row', marginTop: 10 }}>
  1803. <Text style={styles.bomText}>编码:{item.childGoodsCode}</Text>
  1804. <Text style={[styles.bomText, { marginLeft: 10 }]}>
  1805. {'v' + item.childGoodsVersion}
  1806. </Text>
  1807. </View>
  1808. <View
  1809. style={{
  1810. flexDirection: 'row',
  1811. justifyContent: 'space-between',
  1812. marginTop: 1,
  1813. }}
  1814. >
  1815. <Text style={styles.bomText}>
  1816. 数量:{accMul(
  1817. accMul(parentItem.conversionRate, parentItem.orderNum),
  1818. item.childGoodsQty
  1819. )}
  1820. {' ' + item.childGoodsUnitName}
  1821. </Text>
  1822. <Text style={styles.bomText}>
  1823. 单价:<Text style={{ color: '#E70013' }}>
  1824. {CURRENCY.currencySign +
  1825. accMul(
  1826. accMul(parentItem.conversionRate, parentItem.orderNum),
  1827. parentItem.basePrice
  1828. )}
  1829. </Text>
  1830. </Text>
  1831. </View>
  1832. </View>
  1833. </View>
  1834. </View>
  1835. <View>{this.optView(item, index, false, item.isOptional)}</View>
  1836. </View>
  1837. )
  1838. }
  1839. promInfoFilter(mutualRelationShip) {
  1840. let result = []
  1841. const basePromInfo = [
  1842. { number: 1, name: '买赠-基于商品' },
  1843. { number: 2, name: '降价-基于商品' },
  1844. { number: 3, name: '买赠-基于订单' },
  1845. { number: 4, name: '降价-基于订单' },
  1846. ]
  1847. for (let i = 0; i < mutualRelationShip.length; i++) {
  1848. let groupArr = []
  1849. ;(mutualRelationShip[i] || []).map(valsec => {
  1850. groupArr = groupArr.concat(
  1851. basePromInfo.filter(item => item.number == valsec)
  1852. )
  1853. })
  1854. result.push(groupArr)
  1855. }
  1856. return result
  1857. }
  1858. baseOnPromTouch(item) {
  1859. let Arr = []
  1860. ;(item || []).map(val => Arr.push(val.number))
  1861. this.props.dispatch(
  1862. createAction('orderedit/getProm')({
  1863. promInfo: {
  1864. customerId: CUSTOMERINFO.id,
  1865. promotionStyle: Arr,
  1866. saleOrgId: this.props.navigation.state.params.SaleOrSupplier
  1867. .SaleOrSupplierId,
  1868. isPrimaryChannel: this.props.navigation.state.params.SaleOrSupplier
  1869. .isPrimaryChannel,
  1870. reqOrderItems: this.state.EditPromData,
  1871. },
  1872. })
  1873. )
  1874. this.combinedFn(true)
  1875. }
  1876. // 赠品回调
  1877. giftCb(e, ids) {
  1878. const {EditPromData} = this.state;
  1879. let totalWeight = 0;
  1880. if(EditPromData && EditPromData.length) {
  1881. EditPromData.map(data => {
  1882. totalWeight += data.mainNum*data.weight;
  1883. })
  1884. }
  1885. if(e && e.length) {
  1886. e.map(data => {
  1887. totalWeight += data.mainNum*data.weight
  1888. })
  1889. }
  1890. this.setState({ giftSelected: e,totalWeight })
  1891. }
  1892. baseOnProm(mutualRelationShip) {
  1893. if (mutualRelationShip) {
  1894. this.RelationShipCopy = mutualRelationShip
  1895. } else {
  1896. mutualRelationShip = this.RelationShipCopy
  1897. }
  1898. let basePromInfo = this.promInfoFilter(mutualRelationShip)
  1899. let basePromData = []
  1900. for (let i = 0; i < basePromInfo.length; i++) {
  1901. ;(basePromInfo[i] || []).map((data, index) =>
  1902. basePromData.push(
  1903. <TouchableOpacity
  1904. key={index + data.name ? data.name : ''}
  1905. style={{ flexDirection: 'row', width: width / 2 - 10 }}
  1906. onPress={() => {
  1907. this.state.baseIndex == i ? {} : this.setState({ baseIndex: i })
  1908. this.baseOnPromTouch(basePromInfo[i])
  1909. }}
  1910. >
  1911. <Icon
  1912. name={
  1913. this.state.baseIndex == i
  1914. ? 'icon-icon-danxuankuang-xuanzhong'
  1915. : 'icon-icon-danxuankuang-weixuanzhong'
  1916. }
  1917. size={26}
  1918. color={this.state.baseIndex == i ? '#E14C46' : '#CCC'}
  1919. />
  1920. <Text
  1921. style={{
  1922. marginLeft: 5,
  1923. fontSize: 13,
  1924. lineHeight: 17,
  1925. color: '#333',
  1926. alignSelf: 'center',
  1927. marginBottom: 1,
  1928. }}
  1929. >
  1930. {data.name || ''}
  1931. </Text>
  1932. </TouchableOpacity>
  1933. )
  1934. )
  1935. }
  1936. return (
  1937. <View
  1938. style={{
  1939. backgroundColor: '#FFF',
  1940. marginTop: 10,
  1941. paddingVertical: 7,
  1942. paddingHorizontal: 10,
  1943. flexDirection: 'row',
  1944. flexWrap: 'wrap',
  1945. }}
  1946. >
  1947. {basePromData}
  1948. </View>
  1949. )
  1950. }
  1951. checkCast(castRateData) {
  1952. let financeOrgIds = [],
  1953. flag = true,
  1954. productLineIds = Array.from(new Set(this.state.productLineIds)),
  1955. returnData = {}
  1956. productLineIds.forEach(lineId => {
  1957. castRateData.forEach(castitem => {
  1958. if (
  1959. castitem.productLineIds.length == 1 &&
  1960. !castitem.productLineIds[0]
  1961. ) {
  1962. flag = false
  1963. returnData = castitem
  1964. } else if (castitem.productLineIds.indexOf(lineId) != -1) {
  1965. financeOrgIds.push(castitem.financeOrgId)
  1966. }
  1967. })
  1968. })
  1969. if (financeOrgIds.length == 1 && flag) {
  1970. castRateData.forEach(item => {
  1971. if (item.financeOrgId == financeOrgIds[0]) {
  1972. returnData = item
  1973. }
  1974. })
  1975. }
  1976. return returnData
  1977. }
  1978. render() {
  1979. const {
  1980. addressDefault,
  1981. transportData,
  1982. transportDefault,
  1983. billwayData,
  1984. billwayDefault,
  1985. invoiceDefault,
  1986. castRateData,
  1987. promData,
  1988. creditData,
  1989. orderPayStatus,
  1990. } = this.props
  1991. const supplierDefault = this.props.navigation.state.params.SaleOrSupplier
  1992. let MaxOffset = 0,
  1993. castRateDataOnly = { costOffsetRatio: 0, supplyMaxOccupyMny: 0 }
  1994. if (
  1995. castRateData &&
  1996. castRateData.length > 0 &&
  1997. this.state.productLineIds &&
  1998. this.state.productLineIds.length > 0
  1999. ) {
  2000. let checkCastReturn = this.checkCast(castRateData)
  2001. if (Object.keys(checkCastReturn).length > 0) {
  2002. castRateDataOnly = checkCastReturn
  2003. }
  2004. if (
  2005. accMul(this.state.goodsAmount, castRateDataOnly.costOffsetRatio) >=
  2006. castRateDataOnly.supplyMaxOccupyMny
  2007. ) {
  2008. MaxOffset = castRateDataOnly.supplyMaxOccupyMny
  2009. } else {
  2010. MaxOffset = accMul(
  2011. this.state.goodsAmount,
  2012. castRateDataOnly.costOffsetRatio
  2013. )
  2014. }
  2015. if (MaxOffset >= this.state.totalAmountCopy) {
  2016. MaxOffset = this.state.totalAmountCopy
  2017. }
  2018. }
  2019. return (
  2020. <View
  2021. style={[
  2022. styles.container,
  2023. { backgroundColor: '#F7F7F7' },
  2024. // { backgroundColor: appTheme.backgroundColor }
  2025. ]}
  2026. >
  2027. <StatusBar
  2028. animated={true}
  2029. // barStyle={appTheme.barStyle}
  2030. barStyle={'dark-content'}
  2031. backgroundColor={'transparent'}
  2032. translucent={true}
  2033. />
  2034. {/* 头部 */}
  2035. {this.header()}
  2036. <ScrollView
  2037. style={{ flex: 1 }}
  2038. // scrollEventThrottle={200}
  2039. // onScroll={() => {
  2040. // // 判断圆形按钮滑动前后是否变化控制刷新
  2041. // if (this.cicleActive == this.state.cicleActive) {
  2042. // this.setState({ cicleActive: false });
  2043. // this.cicleActive = this.state.cicleActive;
  2044. // }
  2045. // }}
  2046. // onScrollEndDrag={() => this.setState({ cicleActive: true })}
  2047. // onMomentumScrollEnd={() => this.setState({ cicleActive: true })}
  2048. >
  2049. {/* 供应商显示 */}
  2050. {this.supplier(supplierDefault)}
  2051. {/*选项行*/}
  2052. <View>
  2053. <View style={{ backgroundColor: '#FFF', marginTop: 10 }}>
  2054. {this.viewRender([
  2055. {
  2056. viewName: '运输方式',
  2057. rightName:
  2058. (transportDefault && transportDefault.name) || '铁路运输',
  2059. iconName: 'icon-icon-xiala',
  2060. onPress: () => {
  2061. this.state.activeMethod == 0
  2062. ? this.setState({ activeMethod: 'nfjdsjf' })
  2063. : this.setState({ activeMethod: 0 })
  2064. },
  2065. dataArr: transportData || [],
  2066. },
  2067. // {
  2068. // viewName: '结算方式',
  2069. // rightName: (billwayDefault && billwayDefault.name) || '现金',
  2070. // iconName: 'icon-icon-xiala',
  2071. // onPress: () => {
  2072. // this.state.activeMethod == 1
  2073. // ? this.setState({ activeMethod: 'nfjdsjf' })
  2074. // : this.setState({ activeMethod: 1 })
  2075. // },
  2076. // dataArr: billwayData || [],
  2077. // },
  2078. // {
  2079. // viewName: '支付方式',
  2080. // rightName: this.state.payWayDef && this.state.payWayDef.name,
  2081. // iconName: 'icon-icon-xiala',
  2082. // onPress: () => {
  2083. // this.state.activeMethod == 2
  2084. // ? this.setState({ activeMethod: 'nfjdsjf' })
  2085. // : this.setState({ activeMethod: 2 })
  2086. // },
  2087. // dataArr: orderPayStatus || [],
  2088. // },
  2089. ])}
  2090. </View>
  2091. <View style={{ backgroundColor: '#FFF', marginTop: 10 }}>
  2092. {this.viewRender([
  2093. {
  2094. viewName: '发票',
  2095. rightName:
  2096. (invoiceDefault && invoiceDefault.invoiceTitle) || '发票',
  2097. iconName: 'icon-icon-jianjinzhishiqi',
  2098. onPress: () =>
  2099. this.props.dispatch(
  2100. NavigationActions.navigate({
  2101. routeName: 'SelectInvoice',
  2102. params: e => this.invoiceCallback(e),
  2103. })
  2104. ),
  2105. },
  2106. ])}
  2107. </View>
  2108. {/* <View style={{ backgroundColor: '#FFF', marginTop: 10 }}>
  2109. {this.viewRender(
  2110. [
  2111. {
  2112. viewName: '期望到货日期',
  2113. rightName: this.state.deliveryTime,
  2114. iconName: 'icon-icon-xiala',
  2115. onPress: () =>
  2116. Platform.OS == 'ios'
  2117. ? this.showTime._openModal()
  2118. : this.TimeAndroid(),
  2119. inputName: '备注',
  2120. inputDefault: this.state.remark || '备注订单内容',
  2121. inputValue: '',
  2122. },
  2123. ],
  2124. true
  2125. )}
  2126. </View> */}
  2127. </View>
  2128. {/* 选地址 */}
  2129. <TouchableOpacity
  2130. activeOpacity={1}
  2131. onPress={() =>
  2132. this.props.dispatch(
  2133. NavigationActions.navigate({
  2134. routeName: 'SelectAdress',
  2135. params: e => this.callback(e),
  2136. })
  2137. )
  2138. }
  2139. style={{
  2140. backgroundColor: '#FFF',
  2141. marginTop: 10,
  2142. flexDirection: 'row',
  2143. paddingTop: 10,
  2144. paddingBottom: 5,
  2145. }}
  2146. >
  2147. <View style={{ flex: 1, justifyContent: 'flex-end' }}>
  2148. <Icon
  2149. name="icon-icon-dizhi"
  2150. size={24}
  2151. color={'#333'}
  2152. style={{ alignSelf: 'center' }}
  2153. />
  2154. </View>
  2155. <View style={{ flex: 8, paddingBottom: 5 }}>
  2156. <View style={{ flexDirection: 'row' }}>
  2157. <Text style={{ fontSize: 15, lineHeight: 21, color: '#333' }}>
  2158. {addressDefault && addressDefault.receiver}
  2159. </Text>
  2160. <Text style={{ marginLeft: 3, alignSelf: 'center' }}>
  2161. {addressDefault && addressDefault.receiverPhone}
  2162. </Text>
  2163. </View>
  2164. <Text
  2165. style={{
  2166. marginTop: 4,
  2167. fontSize: 13,
  2168. lineHeight: 18,
  2169. color: '#333',
  2170. }}
  2171. >
  2172. {((addressDefault && addressDefault.receiverProvince) || '') +
  2173. ((addressDefault && addressDefault.receiverCity) || '') +
  2174. ((addressDefault && addressDefault.receiverDistrict) || '') +
  2175. ((addressDefault && addressDefault.receiverTown) || '') +
  2176. ((addressDefault && addressDefault.receiverAddress) || '')}
  2177. </Text>
  2178. </View>
  2179. <View
  2180. style={{
  2181. flex: 1,
  2182. justifyContent: 'center',
  2183. }}
  2184. >
  2185. <Icon
  2186. name="icon-icon-jianjinzhishiqi"
  2187. size={24}
  2188. color={'#ccc'}
  2189. style={{ alignSelf: 'center' }}
  2190. />
  2191. </View>
  2192. </TouchableOpacity>
  2193. {/* Image地址下边框 */}
  2194. <Image source={redblue} style={{ height: 2, width: width }} />
  2195. {/* 基于原单或基于商品数量选项 */}
  2196. {promData.mutualRelationShip
  2197. ? this.baseOnProm(promData.mutualRelationShip)
  2198. : null}
  2199. {/* 商品信息 */}
  2200. {this.state.Loading ? (
  2201. <View style={{ marginTop: 10 }}>
  2202. <ActivityIndicator />
  2203. </View>
  2204. ) : (
  2205. <FlatList
  2206. keyExtractor={item => item.goodsId}
  2207. data={this.state.EditPromData}
  2208. extraData={this.state}
  2209. renderItem={({ item, index }) => this.goodsInfo(item, index)}
  2210. />
  2211. )}
  2212. {/* 赠品明细 */}
  2213. {promData && promData.giftProms && promData.giftProms.length > 0 ? (
  2214. <View
  2215. style={{
  2216. backgroundColor: '#FFF',
  2217. paddingHorizontal: 10,
  2218. paddingTop: 10,
  2219. marginTop: 10,
  2220. }}
  2221. >
  2222. <TouchableOpacity
  2223. onPress={() => {
  2224. let NavigateGift =
  2225. JSON.parse(JSON.stringify(promData.giftProms)) || []
  2226. ;(NavigateGift || []).map(item => {
  2227. item.data = item.giftDtos
  2228. delete item.giftDtos
  2229. })
  2230. this.props.dispatch(
  2231. NavigationActions.navigate({
  2232. routeName: 'OrderGifts',
  2233. params: {
  2234. giftProms: NavigateGift,
  2235. giftCb: (e, ids) => this.giftCb(e, ids),
  2236. },
  2237. })
  2238. )
  2239. }}
  2240. style={{
  2241. paddingBottom: 6,
  2242. flexDirection: 'row',
  2243. justifyContent: 'space-between',
  2244. }}
  2245. >
  2246. <Text style={{ fontSize: 14, lineHeight: 20, color: '#333' }}>
  2247. 赠品明细
  2248. </Text>
  2249. <View style={{ flexDirection: 'row' }}>
  2250. <Text style={{ fontSize: 14, lineHeight: 20, color: '#666' }}>
  2251. 选择赠品
  2252. </Text>
  2253. <Icon
  2254. name="icon-icon-jianjinzhishiqi"
  2255. color="#666"
  2256. size={24}
  2257. style={{ alignSelf: 'center' }}
  2258. />
  2259. </View>
  2260. </TouchableOpacity>
  2261. {this.state.giftSelected.length > 0 ? (
  2262. <FlatList
  2263. keyExtractor={(item, index) => index}
  2264. data={this.state.giftSelected}
  2265. extraData={this.state}
  2266. style={{
  2267. paddingBottom: 10,
  2268. borderTopColor: '#EEE',
  2269. borderTopWidth: 1 / PixelRatio.get(),
  2270. }}
  2271. renderItem={({ item, index }) => (
  2272. <View
  2273. style={{
  2274. flexDirection: 'row',
  2275. justifyContent: 'space-between',
  2276. paddingTop: 10,
  2277. }}
  2278. >
  2279. <Text
  2280. numberOfLines={1}
  2281. style={{
  2282. flex: 1,
  2283. fontSize: 12,
  2284. lineHeight: 17,
  2285. color: '#333',
  2286. }}
  2287. >
  2288. {item.goodsDisplayName}
  2289. </Text>
  2290. <View style={{ flexDirection: 'row', marginLeft: 30 }}>
  2291. <Icon
  2292. name="icon-icon-guanbianniu"
  2293. size={20}
  2294. color="#666"
  2295. />
  2296. <Text
  2297. style={{
  2298. fontSize: 12,
  2299. lineHeight: 17,
  2300. color: '#333',
  2301. marginLeft: 5,
  2302. }}
  2303. >
  2304. {item.mainNum || 1}
  2305. </Text>
  2306. </View>
  2307. </View>
  2308. )}
  2309. />
  2310. ) : null}
  2311. </View>
  2312. ) : null}
  2313. {/* 增加商品 */}
  2314. <View style={{ marginTop: 10, padding: 10, backgroundColor: '#FFF' }}>
  2315. <View
  2316. style={{
  2317. flexDirection: 'row',
  2318. justifyContent: 'center',
  2319. }}
  2320. >
  2321. <TouchableOpacity onPress={() =>{
  2322. this.setState({
  2323. showGoodsModal: true
  2324. })
  2325. }}>
  2326. <Text style={styles.text666}>增加商品+</Text>
  2327. </TouchableOpacity>
  2328. </View>
  2329. </View>
  2330. {/* 总体积、数量 */}
  2331. <View style={{ marginTop: 10, padding: 10, backgroundColor: '#FFF' }}>
  2332. <View
  2333. style={{
  2334. flexDirection: 'row',
  2335. justifyContent: 'space-between',
  2336. }}
  2337. >
  2338. <Text style={styles.text666}>总重量</Text>
  2339. <Text style={styles.text666}>
  2340. {this.state.totalWeight}{"KG"}
  2341. {/* {this.state.weightUnit} */}
  2342. </Text>
  2343. </View>
  2344. {/* <View
  2345. style={{
  2346. flexDirection: 'row',
  2347. justifyContent: 'space-between',
  2348. }}
  2349. >
  2350. <Text style={styles.text666}>总体积</Text>
  2351. <Text style={styles.text666}>
  2352. {this.state.totoalVolume}
  2353. {this.state.volumeUnit}
  2354. </Text>
  2355. </View> */}
  2356. </View>
  2357. {/* 金额显示 */}
  2358. <View style={{ marginTop: 10, backgroundColor: '#FFF', padding: 10 }}>
  2359. <View
  2360. style={{
  2361. flexDirection: 'row',
  2362. justifyContent: 'space-between',
  2363. }}
  2364. >
  2365. <Text style={styles.text666}>商品金额:</Text>
  2366. <Text style={styles.text666red}>
  2367. {CURRENCY.currencySign}
  2368. {ScaleUtil(
  2369. this.state.goodsAmount,
  2370. CURRENCY.currencyAmountScale
  2371. )}
  2372. </Text>
  2373. </View>
  2374. <View
  2375. style={{
  2376. flexDirection: 'row',
  2377. justifyContent: 'space-between',
  2378. }}
  2379. >
  2380. <Text style={styles.text666}>促销金额:</Text>
  2381. <Text style={styles.text666red}>
  2382. {CURRENCY.currencySign}
  2383. {this.state.totalPromAmt}
  2384. </Text>
  2385. </View>
  2386. {/* <View
  2387. style={{
  2388. flexDirection: 'row',
  2389. justifyContent: 'space-between',
  2390. }}
  2391. >
  2392. <Text style={styles.text666}>费用冲抵:</Text>
  2393. <Input
  2394. style={{
  2395. borderWidth: 1,
  2396. borderColor: '#E6E6E6',
  2397. borderRadius: 2,
  2398. width: width / 2.5,
  2399. height: 24,
  2400. padding: 0,
  2401. alignItems: 'center',
  2402. }}
  2403. ref={AverageRef => (this.AverageRef = AverageRef)}
  2404. keyboardType={'numeric'}
  2405. isICon={false}
  2406. blurOnSubmit={true}
  2407. placeholder={''}
  2408. textInputBacg={'#FFF'}
  2409. placeholderTextColor={'#CCC'}
  2410. onchangeFn={e => this.AverageBooth(e, MaxOffset)}
  2411. maxNum={MaxOffset}
  2412. />
  2413. </View> */}
  2414. {/* <View
  2415. style={{
  2416. flexDirection: 'row',
  2417. justifyContent: 'flex-end',
  2418. marginTop: 5,
  2419. }}
  2420. >
  2421. <Text style={[styles.text999, { marginRight: 10 }]}>
  2422. (本次最高冲抵:<Text style={{ color: '#E14C46' }}>
  2423. {CURRENCY.currencySign}
  2424. {ScaleUtil(MaxOffset, CURRENCY.currencyAmountScale)}
  2425. </Text>
  2426. </Text>
  2427. <Text style={styles.text999}>
  2428. 费用总金额:
  2429. <Text style={{ color: '#E14C46' }}>
  2430. {CURRENCY.currencySign}
  2431. {ScaleUtil(
  2432. castRateDataOnly.supplyMaxOccupyMny || 0,
  2433. CURRENCY.currencyAmountScale
  2434. )}
  2435. </Text>)
  2436. </Text>
  2437. </View> */}
  2438. <View
  2439. style={{
  2440. flexDirection: 'row',
  2441. justifyContent: 'space-between',
  2442. marginTop: 20,
  2443. }}
  2444. >
  2445. {/* <TouchableOpacity
  2446. style={{ flexDirection: 'row' }}
  2447. onPress={() => {
  2448. this.credit._openModal(creditData)
  2449. this.setState({ creditShow: true })
  2450. }}
  2451. >
  2452. <Text style={[styles.text999, { alignSelf: 'center' }]}>
  2453. 信用查询
  2454. </Text>
  2455. <Image
  2456. source={orderCreditPng}
  2457. style={{
  2458. width: 14,
  2459. height: 14,
  2460. alignSelf: 'center',
  2461. marginLeft: 4,
  2462. }}
  2463. />
  2464. </TouchableOpacity> */}
  2465. <Text style={styles.text666}>
  2466. 订单总金额:<Text
  2467. style={{ fontSize: 18, lineHeight: 25, color: '#E14C46' }}
  2468. >
  2469. {CURRENCY.currencySign}{' '}
  2470. {ScaleUtil(
  2471. this.state.totalAmount,
  2472. CURRENCY.currencyAmountScale
  2473. )}
  2474. </Text>
  2475. </Text>
  2476. </View>
  2477. <View style={{ marginTop: 10, backgroundColor: '#FFF' }}>
  2478. <View style={{flexDirection: 'row'}}>
  2479. <Text>备注:</Text>
  2480. <TextInput
  2481. style={{
  2482. fontSize: 12,
  2483. color: '#333333',
  2484. padding: 0,
  2485. backgroundColor: '#FFF',
  2486. height: 25,
  2487. borderWidth: 1,
  2488. borderColor: '#DDDDDD',
  2489. width:'60%'
  2490. }}
  2491. // multiline
  2492. // numberOfLines={4}
  2493. value={this.state.remark}
  2494. onChangeText={text=>this.setState({remark:text})}
  2495. underlineColorAndroid="transparent"
  2496. />
  2497. </View>
  2498. </View>
  2499. </View>
  2500. {/* 增加商品 */}
  2501. <Modal
  2502. animationType="slide"
  2503. presentationStyle="formSheet"
  2504. transparent={true}
  2505. visible={this.state.showGoodsModal}
  2506. onRequestClose={() => {
  2507. this.setState({
  2508. showGoodsModal: false
  2509. })
  2510. }}
  2511. >
  2512. <View
  2513. style={{
  2514. backgroundColor:'#FFF',
  2515. top:'50%',
  2516. paddingBottom: 50,
  2517. width:'100%',
  2518. height:'50%',
  2519. alignItems : 'center',
  2520. elevation : 5,
  2521. }}>
  2522. {this.state.optLoading ? (
  2523. <View style={{marginTop:100}}>
  2524. <ActivityIndicator />
  2525. </View>
  2526. ) : <View>
  2527. <View style={{flexDirection:'row'}}>
  2528. <Text style={{ fontSize: 13, lineHeight: 18, color: '#333',width:'90%',marginTop:10 }}>选择商品</Text>
  2529. <TouchableOpacity onPress={() =>{
  2530. this.setState({
  2531. showGoodsModal: false
  2532. })
  2533. }}>
  2534. <Image
  2535. source={deletePng}
  2536. style={{ width: 20, height: 20}}
  2537. />
  2538. </TouchableOpacity>
  2539. </View>
  2540. <GoodsFlatList addGoods={this.addGoods.bind(this)}/>
  2541. </View>
  2542. }
  2543. </View>
  2544. </Modal>
  2545. {/* 颜色选配 */}
  2546. <Modal
  2547. animationType="slide"
  2548. presentationStyle="formSheet"
  2549. transparent={true}
  2550. visible={this.state.showOptModal}
  2551. onRequestClose={() => {
  2552. this.setState({
  2553. showOptModal: false
  2554. })
  2555. }}
  2556. >
  2557. <View
  2558. style={{
  2559. backgroundColor:'#FFF',
  2560. top:'50%',
  2561. paddingBottom: 50,
  2562. width:'100%',
  2563. height:'50%',
  2564. alignItems : 'center',
  2565. elevation : 5,
  2566. }}>
  2567. {this.state.optLoading ? (
  2568. <View style={{marginTop:100}}>
  2569. <ActivityIndicator />
  2570. </View>
  2571. ) : <View>
  2572. <View style={{flexDirection:'row'}}>
  2573. <Text style={{ fontSize: 13, lineHeight: 18, color: '#333',width:'90%',marginTop:10 }}>选择颜色</Text>
  2574. <TouchableOpacity onPress={() =>{
  2575. this.setState({
  2576. showOptModal: false
  2577. })
  2578. }}>
  2579. <Image
  2580. source={deletePng}
  2581. style={{ width: 20, height: 20}}
  2582. />
  2583. </TouchableOpacity>
  2584. </View>
  2585. <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)}/>
  2586. </View>
  2587. }
  2588. </View>
  2589. </Modal>
  2590. <Modal
  2591. animationType="slide"
  2592. presentationStyle="formSheet"
  2593. transparent={true}
  2594. visible={this.state.modalVisible}
  2595. onRequestClose={() => {
  2596. console.log('close');
  2597. }}
  2598. >
  2599. <View
  2600. style={{
  2601. backgroundColor:'#f8f8f8',
  2602. marginTop:'50%',
  2603. marginLeft:'15%',
  2604. width:'70%',
  2605. height:'24%',
  2606. alignItems : 'center',
  2607. shadowColor : '#000',
  2608. shadowOffset: {width: 0,height: 2},
  2609. shadowOpacity : 0.25,
  2610. shadowRadius : 3.84,
  2611. elevation : 5,
  2612. //borderRadius : 20
  2613. }}>
  2614. <Text style={{marginTop:10}}>请输入商品数量</Text>
  2615. <TextInput
  2616. style={{width:'50%'}}
  2617. onChangeText={text => this.setState({num:text})}
  2618. value={this.state.num}
  2619. />
  2620. <View style={{width:"100%",flexDirection:'row',position:'absolute',bottom:0}}>
  2621. <TouchableOpacity style={{backgroundColor : '#E70013',width:'50%',alignItems:'center',fontSize:20,padding:5}}
  2622. onPress= {() => this.onModalOk()}
  2623. >
  2624. <Text>确定</Text>
  2625. </TouchableOpacity>
  2626. <TouchableOpacity style={{backgroundColor : '#fff',width:'50%',alignItems:'center',fontSize:20,padding:5}}
  2627. onPress= {() => this.setState({modalVisible:false})}
  2628. >
  2629. <Text>取消</Text>
  2630. </TouchableOpacity>
  2631. </View>
  2632. </View>
  2633. </Modal>
  2634. </ScrollView>
  2635. {/* 信用弹窗 */}
  2636. <OrderCredit
  2637. ref={credit => (this.credit = credit)}
  2638. cb={() => this.setState({ creditShow: false })}
  2639. />
  2640. <OrderOptional
  2641. {...this.props}
  2642. ref={optional => (this.optional = optional)}
  2643. onPressBom={() => {
  2644. this.addBoomToData()
  2645. }}
  2646. // 选配回调处理(将选择的选配结果返回 加到商品行上)
  2647. optCb={data => {
  2648. this.state.EditPromData.forEach(item => {
  2649. let allOptIds = '',
  2650. allOptVals = ''
  2651. if (item.reqOrderItemBoms && item.reqOrderItemBoms.length > 0) {
  2652. item.reqOrderItemBoms.forEach(itemSec => {
  2653. data.forEach(itemTh => {
  2654. if (itemSec.childGoodsId == itemTh.goodsId) {
  2655. itemSec.baseGoodsOptId = itemTh.optIds
  2656. itemSec.baseGoodsOptValue = itemTh.optVals
  2657. if (allOptIds && allOptIds.length > 0) {
  2658. allOptIds = allOptIds.concat(
  2659. ',' + itemSec.baseGoodsOptId
  2660. )
  2661. allOptVals = allOptVals.concat(
  2662. ',' + itemSec.baseGoodsOptValue
  2663. )
  2664. } else {
  2665. allOptIds = itemSec.baseGoodsOptId
  2666. allOptVals = itemSec.baseGoodsOptValue
  2667. }
  2668. }
  2669. })
  2670. })
  2671. } else {
  2672. data.forEach(dataFt => {
  2673. if (dataFt.goodsId == item.goodsId) {
  2674. allOptIds = dataFt.optIds
  2675. allOptVals = dataFt.optVals
  2676. }
  2677. })
  2678. }
  2679. item.baseGoodsOptId = allOptIds
  2680. item.baseGoodsOptValue = allOptVals
  2681. })
  2682. this.addBoomToData()
  2683. this.setState({ EditPromData: this.state.EditPromData })
  2684. }}
  2685. />
  2686. {/* 时间弹窗 */}
  2687. <SelectTime
  2688. ref={showTime => (this.showTime = showTime)}
  2689. cb={date => {
  2690. this.setState({
  2691. deliveryTime: moment(date).format('YYYY-MM-DD'),
  2692. })
  2693. }}
  2694. />
  2695. {/* 底部 */}
  2696. <View
  2697. style={{
  2698. height: 45 + HEADERSTYLE.paddingBottom,
  2699. paddingBottom: HEADERSTYLE.paddingBottom,
  2700. backgroundColor: '#FFF',
  2701. flexDirection: 'row',
  2702. borderTopColor: '#EEE',
  2703. borderTopWidth: 1 / PixelRatio.get(),
  2704. }}
  2705. >
  2706. {this.bottomTouch()}
  2707. </View>
  2708. {/* 信用弹窗毛玻璃效果 */}
  2709. {/* {this.state.creditShow ? (
  2710. <View
  2711. style={{
  2712. position: "absolute",
  2713. width: width,
  2714. height: height,
  2715. backgroundColor: "#000",
  2716. opacity: 0.5
  2717. }}
  2718. />
  2719. ) : null} */}
  2720. </View>
  2721. )
  2722. }
  2723. }
  2724. const styles = StyleSheet.create({
  2725. container: {
  2726. flex: 1,
  2727. },
  2728. text333: {
  2729. fontSize: 14,
  2730. lineHeight: 20,
  2731. letterSpacing: 0.17,
  2732. color: '#333',
  2733. },
  2734. text666: {
  2735. fontSize: 13,
  2736. lineHeight: 18,
  2737. color: '#666',
  2738. },
  2739. text666red: {
  2740. fontSize: 14,
  2741. lineHeight: 25,
  2742. color: '#E14C46',
  2743. },
  2744. text999: {
  2745. fontSize: 12,
  2746. lineHeight: 17,
  2747. color: '#999',
  2748. },
  2749. bomTitle: {
  2750. fontSize: 13,
  2751. lineHeight: 18,
  2752. color: '#333',
  2753. },
  2754. bomText: {
  2755. fontSize: 12,
  2756. lineHeight: 17,
  2757. color: '#666',
  2758. },
  2759. modalStyle: {
  2760. }
  2761. })
  2762. export default OrderEdit