OrderEdit.js 88 KB

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