OrderEdit.js 89 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666
  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. this.editFinish("Temporary")
  728. console.log(
  729. err,
  730. '-----订单编辑-提交订单报错的完整信息' +
  731. '\n' +
  732. '具体错误显示||--->:' +
  733. err.response.data.message
  734. )
  735. })
  736. this.setState({ submitLoading: false })
  737. }
  738. }
  739. // 请求数据报错,则不进行下一步
  740. if (!errReturn) {
  741. if (result.data && Object.keys(result.data).length > 0) {
  742. isReturnTab = true
  743. }
  744. if (isReturnTab) {
  745. if (
  746. this.props.navigation.state.params.cartId &&
  747. this.props.navigation.state.params.cartId.length > 0
  748. ) {
  749. this.props.navigation.state.params.cartId.forEach(item => {
  750. this.props.dispatch(
  751. createAction('shoppingcart/deleteShop')({
  752. params: {
  753. id: item,
  754. customer: CUSTOMERINFO.id,
  755. },
  756. })
  757. )
  758. })
  759. }
  760. // 返回OrderHome
  761. this.props.dispatch(
  762. NavigationActions.navigate({
  763. routeName: 'OrderHome',
  764. action: NavigationActions.navigate({ routeName: 'OrderHome' }),
  765. })
  766. )
  767. }
  768. }
  769. }
  770. // 头部
  771. header() {
  772. return (
  773. <View
  774. style={{
  775. height: HEADERSTYLE.height,
  776. paddingTop: HEADERSTYLE.paddingTop + 5,
  777. backgroundColor: '#fff',
  778. borderBottomColor: '#eee',
  779. borderBottomWidth: 1 / PixelRatio.get(),
  780. }}
  781. >
  782. <View
  783. style={{
  784. flex: 1,
  785. justifyContent: 'center',
  786. }}
  787. >
  788. <TouchableOpacity
  789. style={{ position: 'absolute', left: 10, flexDirection: 'row' }}
  790. onPress={() => this.props.dispatch(NavigationActions.back())}
  791. >
  792. <Icon
  793. name="icon-icon-fanhui"
  794. size={20}
  795. color={'#666'}
  796. style={{ marginTop: 4 }}
  797. />
  798. <Text
  799. style={{
  800. fontSize: 14,
  801. lineHeight: 20,
  802. color: '#666',
  803. alignSelf: 'center',
  804. }}
  805. >
  806. 返回
  807. </Text>
  808. </TouchableOpacity>
  809. <Text
  810. style={{
  811. alignSelf: 'center',
  812. fontSize: 18,
  813. lineHeight: 25,
  814. letterSpacing: 0.19,
  815. color: '#333',
  816. }}
  817. >
  818. 订单编辑
  819. </Text>
  820. <TouchableOpacity
  821. style={{ position: 'absolute', right: 10 }}
  822. onPress={
  823. () =>
  824. this.setState({
  825. activeAllCollaps: !this.state.activeAllCollaps,
  826. })
  827. // this._info.setActive()
  828. }
  829. >
  830. <Text
  831. style={{
  832. fontSize: 14,
  833. lineHeight: 20,
  834. letterSpacing: 0.17,
  835. color: '#666',
  836. }}
  837. >
  838. 折叠
  839. </Text>
  840. </TouchableOpacity>
  841. </View>
  842. </View>
  843. )
  844. }
  845. // 供应商
  846. supplier(supplierDefault) {
  847. return (
  848. <View
  849. style={{
  850. backgroundColor: '#FFF',
  851. padding: 10,
  852. flexDirection: 'row',
  853. borderBottomColor: '#eee',
  854. borderBottomWidth: 1,
  855. }}
  856. >
  857. <Text
  858. style={{
  859. fontSize: 14,
  860. lineHeight: 20,
  861. letterSpacing: 0.17,
  862. color: '#333',
  863. fontWeight: '600',
  864. }}
  865. >
  866. {supplierDefault.SaleOrSupplierName}
  867. </Text>
  868. </View>
  869. )
  870. }
  871. // 底部按钮
  872. bottomTouch() {
  873. let touchArr = [],
  874. touchAtt = [
  875. {
  876. touchName: '暂存',
  877. background: '#FFF',
  878. textColor: '#666',
  879. loading: this.state.temporaryLoading,
  880. itemonpress: () => {
  881. this.editFinish('Temporary')
  882. },
  883. },
  884. {
  885. touchName: '提交',
  886. background: '#E70013',
  887. textColor: '#FFF',
  888. loading: this.state.submitLoading,
  889. itemonpress: () => {
  890. this.editFinish('Submit')
  891. },
  892. },
  893. ]
  894. for (let i = 0; i < touchAtt.length; i++) {
  895. if (touchAtt[i].loading) {
  896. touchArr.push(
  897. <View
  898. onPress={() => touchAtt[i].itemonpress()}
  899. key={i}
  900. style={{
  901. flex: 1,
  902. backgroundColor: touchAtt[i].background,
  903. justifyContent: 'center',
  904. borderRightColor: '#eee',
  905. borderRightWidth: 1 / PixelRatio.get(),
  906. }}
  907. >
  908. <ActivityIndicator />
  909. </View>
  910. )
  911. } else {
  912. touchArr.push(
  913. <TouchableOpacity
  914. disabled={
  915. this.state.temporaryLoading || this.state.submitLoading
  916. ? true
  917. : false
  918. }
  919. onPress={() => touchAtt[i].itemonpress()}
  920. key={i}
  921. style={{
  922. flex: 1,
  923. backgroundColor: touchAtt[i].background,
  924. justifyContent: 'center',
  925. borderRightColor: '#eee',
  926. borderRightWidth: 1 / PixelRatio.get(),
  927. }}
  928. >
  929. <Text
  930. style={{
  931. fontSize: 14,
  932. lineHeight: 20,
  933. color: touchAtt[i].textColor,
  934. alignSelf: 'center',
  935. }}
  936. >
  937. {touchAtt[i].touchName}
  938. </Text>
  939. </TouchableOpacity>
  940. )
  941. }
  942. }
  943. return touchArr
  944. }
  945. // 运输方式、结算方式等
  946. viewRender(data, inputTextLOck) {
  947. let viewRen = [],
  948. size = 16
  949. for (let i = 0; i < data.length; i++) {
  950. if (data[i].iconName == 'icon-icon-jianjinzhishiqi') {
  951. size = 24
  952. }
  953. viewRen.push(
  954. <View key={i}>
  955. <TouchableOpacity
  956. onPress={() => data[i].onPress()}
  957. style={{
  958. paddingVertical: 10,
  959. paddingLeft: 10,
  960. paddingRight:
  961. data[i].iconName == 'icon-icon-jianjinzhishiqi' ? 3 : 10,
  962. flexDirection: 'row',
  963. justifyContent: 'space-between',
  964. borderBottomColor: '#EEE',
  965. borderBottomWidth: 1 / PixelRatio.get(),
  966. }}
  967. >
  968. <Text style={styles.text333}>{data[i].viewName}</Text>
  969. <View style={{ flexDirection: 'row' }}>
  970. <Text
  971. style={{
  972. fontSize: 14,
  973. lineHeight: 20,
  974. color: '#666',
  975. marginRight: 10,
  976. }}
  977. >
  978. {data[i].rightName}
  979. </Text>
  980. <Icon name={data[i].iconName} size={size} color={'#ccc'} />
  981. </View>
  982. </TouchableOpacity>
  983. {/* 折叠 */}
  984. <Collapsible collapsed={i !== this.state.activeMethod}>
  985. {data[i].dataArr &&
  986. (data[i].dataArr || []).map((item, key) => (
  987. <TouchableOpacity
  988. onPress={() => {
  989. if (data[i].viewName == '运输方式') {
  990. this.props.dispatch(
  991. createAction('mine/TransportSetstate')(item)
  992. )
  993. this.setState({ transportSel: item.name })
  994. // this.setState({ transportVal: item });
  995. } else if (data[i].viewName == '结算方式') {
  996. this.props.dispatch(
  997. createAction('mine/BillwaySetstate')(item)
  998. )
  999. this.setState({ billWaySel: item.name })
  1000. // this.setState({ billWay: item });
  1001. } else if (data[i].viewName == '支付方式') {
  1002. this.setState({ payWayDef: item, paySel: item.name })
  1003. }
  1004. // 继续写发票和发货日期的更新值
  1005. // else if(){}
  1006. // 收起折叠板
  1007. this.setState({ activeMethod: 'fjidos' })
  1008. }}
  1009. key={key}
  1010. style={{
  1011. flexDirection: 'row',
  1012. justifyContent: 'space-between',
  1013. padding: 10,
  1014. }}
  1015. >
  1016. <Text
  1017. style={{
  1018. fontSize: 14,
  1019. lineHeight: 20,
  1020. color: '#666',
  1021. }}
  1022. >
  1023. {item.name || ''}
  1024. </Text>
  1025. {data[i].viewName == '支付方式' ? (
  1026. this.state.paySel ==
  1027. (this.state.paySel == 0 ? key : item.name) ? (
  1028. <Icon
  1029. name={'icon-icon-duigou'}
  1030. size={16}
  1031. color={'#E14C46'}
  1032. style={{ marginRight: 30 }}
  1033. />
  1034. ) : null
  1035. ) : data[i].viewName == '运输方式' ? (
  1036. this.state.transportSel ==
  1037. (this.state.transportSel == 0 ? key : item.name) ? (
  1038. <Icon
  1039. name={'icon-icon-duigou'}
  1040. size={16}
  1041. color={'#E14C46'}
  1042. style={{ marginRight: 30 }}
  1043. />
  1044. ) : null
  1045. ) : this.state.billWaySel ==
  1046. (this.state.billWaySel == 0 ? key : item.name) ? (
  1047. <Icon
  1048. name={'icon-icon-duigou'}
  1049. size={16}
  1050. color={'#E14C46'}
  1051. style={{ marginRight: 30 }}
  1052. />
  1053. ) : null}
  1054. </TouchableOpacity>
  1055. ))}
  1056. </Collapsible>
  1057. {!inputTextLOck ? null : (
  1058. <View
  1059. style={{
  1060. paddingHorizontal: 10,
  1061. paddingBottom: 3,
  1062. flexDirection: 'row',
  1063. }}
  1064. >
  1065. <Text style={[styles.text333, { alignSelf: 'center' }]}>
  1066. {data[i].inputName}
  1067. </Text>
  1068. <Input
  1069. style={{
  1070. marginTop: 4,
  1071. width: width / 1.15,
  1072. }}
  1073. isICon={false}
  1074. blurOnSubmit={true}
  1075. textInputBacg={'#FFF'}
  1076. placeholder={data[i].inputDefault}
  1077. placeholderTextColor={'#CCC'}
  1078. onchangeFn={e => {
  1079. this.setState({ remark: e })
  1080. }}
  1081. />
  1082. </View>
  1083. )}
  1084. </View>
  1085. )
  1086. }
  1087. return viewRen
  1088. }
  1089. // 地址回调
  1090. callback(e) {
  1091. this.props.dispatch(createAction('mine/AdressSetstate')(e.item))
  1092. // this.setState({ addressDefault: e.item });
  1093. }
  1094. // 发票回调
  1095. invoiceCallback(e) {
  1096. this.props.dispatch(createAction('mine/InvoiceSetstate')(e))
  1097. }
  1098. async TimeAndroid() {
  1099. const { action, year, month, day } = await DatePickerAndroid.open({
  1100. date: new Date(),
  1101. minDate: new Date(),
  1102. mode: 'spinner',
  1103. })
  1104. if (action !== DatePickerAndroid.dismissedAction) {
  1105. this.setState({
  1106. deliveryTime: moment(
  1107. `${year}-${month + 1}-${day}`,
  1108. 'YYYY-MM-DD'
  1109. ).format('YYYY-MM-DD'),
  1110. })
  1111. // 这里开始可以处理用户选好的年月日三个参数:year, month (0-11), day
  1112. }
  1113. }
  1114. // 清除费用冲抵 输入框
  1115. ClearOffset() {
  1116. //this.AverageRef.setClear()
  1117. this.setState({ giftSelected: [] })
  1118. }
  1119. async combinedFn(init, item, nv) {
  1120. this.ClearOffset()
  1121. if (!init) {
  1122. this.state.EditPromData[item].orderNum = nv
  1123. this.state.EditPromData[item].mainNum = accMul(
  1124. this.state.EditPromData[item].orderNum,
  1125. this.state.EditPromData[item].conversionRate
  1126. )
  1127. this.setState({ Loading: true })
  1128. // await this.promDispatch(this.state.EditPromData);
  1129. await this.props.dispatch(
  1130. createAction('orderedit/getProm')({
  1131. promInfo: {
  1132. customerId: CUSTOMERINFO.id,
  1133. saleOrgId: this.props.navigation.state.params.SaleOrSupplier
  1134. .SaleOrSupplierId,
  1135. isPrimaryChannel: this.props.navigation.state.params.SaleOrSupplier
  1136. .isPrimaryChannel,
  1137. reqOrderItems: this.state.EditPromData,
  1138. },
  1139. })
  1140. )
  1141. // this.creditCheck(
  1142. // this.props.promData.reqOrderItems || this.state.EditPromData
  1143. // )
  1144. // this.creditCheck(this.props.promData.reqOrderItems);
  1145. }
  1146. this.setState({ Loading: false })
  1147. this.CountNumFn(
  1148. init,
  1149. item,
  1150. nv,
  1151. this.props.promData.reqOrderItems || this.state.EditPromData
  1152. )
  1153. // this.CountNumFn(init, item, nv, this.props.promData.reqOrderItems);
  1154. }
  1155. CountNumFn(init, item, nv, EditPromData) {
  1156. // this.ClearOffset();
  1157. init ? null : (EditPromData[item].orderNum = nv)
  1158. // init ? null : (item.orderNum = nv);
  1159. let amount = 0,
  1160. totalnum = 0,
  1161. totoalvolume = 0,
  1162. totalweight = 0,
  1163. totalProm = 0
  1164. ;(EditPromData || []).map(val => {
  1165. val.dealPrice = val.promPrice
  1166. val.offsetAmount = 0
  1167. val.mainNum = accMul(val.orderNum, val.conversionRate)
  1168. // 金额
  1169. amount = accAdd(
  1170. accMul(val.salePrice || val.basePrice, val.mainNum),
  1171. amount
  1172. )
  1173. // 商品行总促销金额 = 促销价格*主数量
  1174. totalProm = accAdd(
  1175. accSub(accMul(val.promPrice, val.mainNum), val.promAmount || 0),
  1176. totalProm
  1177. )
  1178. totalnum = accAdd(val.orderNum, totalnum)
  1179. totoalvolume = accAdd(val.volume, totoalvolume)
  1180. totalweight += accMul(val.weight, val.mainNum)
  1181. val.dealAmount = accMul(val.dealPrice, val.mainNum)
  1182. val.amount = accMul(val.salePrice || val.basePrice, val.mainNum)
  1183. })
  1184. this.setState({
  1185. totalAmount: accSub(amount, accSub(amount, totalProm)),
  1186. totalAmountCopy: accSub(amount, accSub(amount, totalProm)),
  1187. goodsAmount: amount,
  1188. totalNum: totalnum,
  1189. // 促销金额 = 总金额 - 商品行总促销金额
  1190. totalPromAmt: accSub(amount, totalProm),
  1191. totoalVolume: totoalvolume,
  1192. totalWeight: totalweight,
  1193. // 每次增加商品行数量 对冲抵总金额初始化
  1194. offsetAmount: 0,
  1195. EditPromData: EditPromData,
  1196. })
  1197. this.addBoomToData()
  1198. }
  1199. // 当促7销输入数字后对每行商品进行均摊
  1200. AverageBooth(e, MaxOffset) {
  1201. e = parseFloat(e)
  1202. let ToffsetAmount = 0,
  1203. EditPromData = this.state.EditPromData
  1204. // 冲抵输入框的值大于0,则进行--均摊计算---
  1205. if (e > 0 && MaxOffset > 0) {
  1206. // 计算最大可冲抵金额
  1207. if (e >= MaxOffset) {
  1208. ToffsetAmount = MaxOffset
  1209. } else {
  1210. ToffsetAmount = e
  1211. }
  1212. if (ToffsetAmount > this.state.totalAmountCopy) {
  1213. ToffsetAmount = this.state.totalAmountCopy
  1214. }
  1215. // 大于1行的商品,遍历n-1个商品,最后一个商品用总冲抵金额减去除最后一行冲抵金额
  1216. if (EditPromData.length > 1) {
  1217. // 商品除最后一行分摊总金额
  1218. let subOffset = 0,
  1219. rowPromAmt = 0
  1220. for (let i = 0; i < EditPromData.length - 1; i++) {
  1221. // 行促销金额存在rowPromAmt中
  1222. rowPromAmt = accSub(
  1223. accMul(EditPromData[i].promPrice, EditPromData[i].mainNum),
  1224. EditPromData[i].promAmount || 0
  1225. )
  1226. // 行分摊金额
  1227. EditPromData[i].offsetAmount = ScaleUtil(
  1228. accMul(
  1229. accDiv(rowPromAmt, this.state.totalAmountCopy),
  1230. ToffsetAmount
  1231. )
  1232. )
  1233. // 计算除最后一行分摊总金额
  1234. subOffset = accAdd(EditPromData[i].offsetAmount, subOffset)
  1235. // 分摊后成交金额
  1236. EditPromData[i].dealAmount = ScaleUtil(
  1237. accSub(rowPromAmt, EditPromData[i].offsetAmount)
  1238. )
  1239. // 根据分摊后成交金额反算成交价格
  1240. EditPromData[i].dealPrice = ScaleUtil(
  1241. accDiv(EditPromData[i].dealAmount, EditPromData[i].mainNum)
  1242. )
  1243. }
  1244. // 商品最后一行处理
  1245. EditPromData[EditPromData.length - 1].offsetAmount = ScaleUtil(
  1246. accSub(ToffsetAmount, subOffset)
  1247. )
  1248. // 促销金额-冲抵金额 (行)
  1249. EditPromData[EditPromData.length - 1].dealAmount = ScaleUtil(
  1250. accSub(
  1251. accSub(
  1252. accMul(
  1253. EditPromData[EditPromData.length - 1].promPrice,
  1254. EditPromData[EditPromData.length - 1].mainNum
  1255. ),
  1256. EditPromData[EditPromData.length - 1].promAmount || 0
  1257. ),
  1258. EditPromData[EditPromData.length - 1].offsetAmount
  1259. )
  1260. )
  1261. EditPromData[EditPromData.length - 1].dealPrice = ScaleUtil(
  1262. accDiv(
  1263. EditPromData[EditPromData.length - 1].dealAmount,
  1264. EditPromData[EditPromData.length - 1].mainNum
  1265. )
  1266. )
  1267. } else {
  1268. // 如果只有一行数据
  1269. // 则直接进行处理
  1270. EditPromData[0].offsetAmount = ToffsetAmount
  1271. EditPromData[0].dealAmount = ScaleUtil(
  1272. accSub(
  1273. accSub(
  1274. accMul(EditPromData[0].promPrice, EditPromData[0].mainNum),
  1275. EditPromData[0].promAmount || 0
  1276. ),
  1277. EditPromData[0].offsetAmount
  1278. )
  1279. )
  1280. EditPromData[0].dealPrice = ScaleUtil(
  1281. accDiv(EditPromData[0].dealAmount, EditPromData[0].mainNum)
  1282. )
  1283. }
  1284. this.setState({
  1285. totalAmount: accSub(
  1286. accSub(this.state.goodsAmount, this.state.totalPromAmt),
  1287. ToffsetAmount
  1288. ),
  1289. offsetAmount: ToffsetAmount,
  1290. EditPromData: EditPromData,
  1291. })
  1292. } else {
  1293. // 冲抵输入框为0或者输入框为空
  1294. // 则还原各行成交价格/金额 为 销售价格/金额,以及冲抵分摊金额还原为0
  1295. ;(EditPromData || []).forEach(val => {
  1296. val.dealAmount = val.amount
  1297. val.dealPrice = val.promPrice
  1298. val.offsetAmount = 0
  1299. })
  1300. this.setState({
  1301. totalAmount: accSub(this.state.goodsAmount, this.state.totalPromAmt),
  1302. offsetAmount: 0,
  1303. EditPromData: EditPromData,
  1304. })
  1305. }
  1306. this.addBoomToData()
  1307. }
  1308. //控制弹出层隐藏显示
  1309. modalVisible(index) {
  1310. this.setState({
  1311. modalVisible : true,
  1312. index : index,
  1313. num : ""
  1314. })
  1315. }
  1316. //弹出框点击确定
  1317. onModalOk() {
  1318. const {num,index} = this.state;
  1319. if(!(/(^[1-9]\d*$)/.test(num))) {
  1320. Toast.show("请输入正确的数量",{position : toastHeight});
  1321. return;
  1322. }
  1323. this.combinedFn(false,index,num);
  1324. this.setState({
  1325. modalVisible : false
  1326. })
  1327. }
  1328. promInfo(item) {
  1329. let promWay = item.promWay == 1 ? '买赠' : '降价'
  1330. return (
  1331. <View>
  1332. <View style={{ flex: 1, flexDirection: 'row', marginTop: 10 }}>
  1333. <View
  1334. style={{
  1335. paddingHorizontal: 4,
  1336. paddingVertical: 2,
  1337. borderRadius: 100,
  1338. backgroundColor: '#E70013',
  1339. marginRight: 14,
  1340. alignSelf: 'center',
  1341. }}
  1342. >
  1343. <Text style={{ fontSize: 12, lineHeight: 14, color: '#FFF' }}>
  1344. {promWay}
  1345. </Text>
  1346. </View>
  1347. <Text
  1348. numberOfLines={3}
  1349. style={{ flex: 1, fontSize: 12, lineHeight: 17, color: '#333' }}
  1350. >
  1351. {item.description}
  1352. </Text>
  1353. </View>
  1354. </View>
  1355. )
  1356. }
  1357. goodsInfo(item, indexParent) {
  1358. // let optFlag = true,
  1359. let optFlag = false,
  1360. isOptArrs = []
  1361. if (item.baseGoodsOptId) {
  1362. item.isOptional = 1
  1363. }
  1364. item.rowNum = (indexParent + 1) * 10
  1365. if (item.isOptional) {
  1366. isOptArrs.push(item.isOptional)
  1367. } else if (item.reqOrderItemBoms && item.reqOrderItemBoms.length > 0) {
  1368. item.reqOrderItemBoms.forEach(data => {
  1369. isOptArrs.push(data.isOptional)
  1370. })
  1371. }
  1372. if (isOptArrs.some(smdata => smdata == 1)) {
  1373. optFlag = true
  1374. }
  1375. return (
  1376. <View>
  1377. <View style={{ padding: 10, marginTop: 10, backgroundColor: '#FFF' }}>
  1378. {/* 满减/买赠 */}
  1379. <View style={{ paddingBottom: 10 }}>
  1380. <FlatList
  1381. keyExtractor={item => item.ruleId}
  1382. data={item.reqOrderPromRels || []}
  1383. extraData={this.state}
  1384. renderItem={({ item, index }) => this.promInfo(item, index)}
  1385. />
  1386. </View>
  1387. {/* 商品行 */}
  1388. <View style={{ flexDirection: 'row' }}>
  1389. <View style={{ marginLeft: 10}}>
  1390. <Text style={{ fontSize: 13, lineHeight: 18, color: '#333' }}>
  1391. {(indexParent + 1)}
  1392. </Text>
  1393. </View>
  1394. <Image
  1395. source={{ uri: ImageBaseUrl + item.goodsImg } || png}
  1396. style={{ width: 80, height: 80 }}
  1397. />
  1398. <View style={{ marginLeft: 10, flex: 1 }}>
  1399. <View style={{flexDirection:'row'}}>
  1400. <Text style={{ fontSize: 13, lineHeight: 18, color: '#333',width:'90%' }}>
  1401. {item.goodsDisplayName}
  1402. </Text>
  1403. <TouchableOpacity onPress={() =>this.deleteGoodsFn(indexParent)}>
  1404. <Image
  1405. source={deletePng}
  1406. style={{ width: 20, height: 20}}
  1407. />
  1408. </TouchableOpacity>
  1409. </View>
  1410. <View
  1411. style={{
  1412. flexDirection: 'row',
  1413. justifyContent: 'space-between',
  1414. marginTop: 10,
  1415. }}
  1416. >
  1417. <Text style={{ fontSize: 12, lineHeight: 17, color: '#666' }}>
  1418. 型号:{item.model?(item.model.length>10?item.model.substr(0,10):item.model):""}
  1419. </Text>
  1420. </View>
  1421. <View
  1422. style={{
  1423. flexDirection: 'row',
  1424. justifyContent: 'space-between',
  1425. marginTop: 10,
  1426. }}
  1427. >
  1428. <Text style={{ fontSize: 12, lineHeight: 17, color: '#666' }}>
  1429. 规格:{item.specification?(item.specification.split("/")[0]+'/'+item.mainNumUnitName):""}
  1430. </Text>
  1431. </View>
  1432. <View
  1433. style={{
  1434. flexDirection: 'row',
  1435. justifyContent: 'space-between',
  1436. marginTop: 7,
  1437. }}
  1438. >
  1439. {/* <CountNum
  1440. defaultValue={item.orderNum}
  1441. size={25}
  1442. callback={nv => {
  1443. this.combinedFn(false, indexParent, nv)
  1444. }}
  1445. /> */}
  1446. <Text style={{ fontSize: 12, lineHeight: 17, color: '#666' }}>
  1447. 数量:{item.mainNum} {item.mainNumUnitName}
  1448. </Text>
  1449. <Text style={{ fontSize: 12, lineHeight: 17, color: '#666' }}>
  1450. 重量:{item.weight*item.mainNum}{'KG'}
  1451. </Text>
  1452. </View>
  1453. <View style={{
  1454. flexDirection: 'row',
  1455. justifyContent: 'space-between',
  1456. marginTop: 7,
  1457. }}>
  1458. <TouchableOpacity
  1459. style={{
  1460. backgroundColor : '#E70013',
  1461. borderRadius : 100,
  1462. }}
  1463. onPress={() =>this.modalVisible(indexParent)}
  1464. >
  1465. <Text style={{fontSize:12,color:'#fff',padding:5}}>修改数量</Text>
  1466. </TouchableOpacity>
  1467. </View>
  1468. </View>
  1469. </View>
  1470. <View
  1471. style={{
  1472. flexDirection: 'row',
  1473. justifyContent: 'space-between',
  1474. marginTop: 10,
  1475. }}
  1476. >
  1477. <Text style={{ fontSize: 12, lineHeight: 17, color: '#666' }}>
  1478. 成交价:<Text
  1479. style={{ fontSize: 14, lineHeight: 17, color: '#E14C46' }}
  1480. >
  1481. {CURRENCY.currencySign}
  1482. {ScaleUtil(
  1483. item.dealPrice || item.basePrice,
  1484. CURRENCY.currencyPriceScale
  1485. )}
  1486. </Text>
  1487. </Text>
  1488. <Text style={{ fontSize: 12, lineHeight: 17, color: '#666' }}>
  1489. 成交金额:<Text
  1490. style={{ fontSize: 14, lineHeight: 17, color: '#E14C46' }}
  1491. >
  1492. {CURRENCY.currencySign}
  1493. {ScaleUtil(item.dealAmount, CURRENCY.currencyAmountScale)}
  1494. </Text>
  1495. </Text>
  1496. </View>
  1497. </View>
  1498. {/* 选配列表 */}
  1499. {optFlag ? (
  1500. <View
  1501. style={{
  1502. backgroundColor: '#FFF',
  1503. borderTopColor: '#EEE',
  1504. borderTopWidth: 1 / PixelRatio.get(),
  1505. }}
  1506. >
  1507. {this.optView(item, indexParent, true)}
  1508. <FlatList
  1509. keyExtractor={item => item.id}
  1510. data={item.reqOrderItemBoms || []}
  1511. extraData={this.state}
  1512. renderItem={itemSec =>
  1513. this.reqItemBoms(itemSec.item, itemSec.index, item)
  1514. }
  1515. />
  1516. <Collapsible collapsed={this.state.optCollapse != indexParent}>
  1517. <FlatList
  1518. keyExtractor={item => item.id}
  1519. data={item.reqOrderItemBoms || []}
  1520. extraData={this.state}
  1521. renderItem={itemSec =>
  1522. this.reqItemBoms(itemSec.item, itemSec.index, item)
  1523. }
  1524. />
  1525. </Collapsible>
  1526. </View>
  1527. ) : null}
  1528. {/* 重量等信息 */}
  1529. <Collapsible collapsed={this.state.activeAllCollaps}>
  1530. <View style={{ padding: 10, backgroundColor: '#FAFAFA' }}>
  1531. <View
  1532. style={{ flexDirection: 'row', justifyContent: 'space-between' }}
  1533. >
  1534. <Text style={styles.text666}>
  1535. 单价:{CURRENCY.currencySign}
  1536. {item.salePrice}
  1537. </Text>
  1538. <Text style={styles.text666}>
  1539. 金额:{CURRENCY.currencySign}
  1540. {accMul(item.salePrice || item.basePrice, item.mainNum)}
  1541. </Text>
  1542. </View>
  1543. <View
  1544. style={{
  1545. flexDirection: 'row',
  1546. justifyContent: 'space-between',
  1547. marginTop: 3,
  1548. }}
  1549. >
  1550. <Text style={styles.text666}>
  1551. 重量:{item.weight}
  1552. {item.weightUnit}
  1553. </Text>
  1554. <Text style={styles.text666}>
  1555. 体积:{item.volume}
  1556. {item.volumeUnit}
  1557. </Text>
  1558. </View>
  1559. </View>
  1560. </Collapsible>
  1561. </View>
  1562. )
  1563. }
  1564. optView(item, indexParent, collaseFlag, isOptional) {
  1565. const reqBomText = []
  1566. if (item.reqOrderItemBoms && item.reqOrderItemBoms.length > 0) {
  1567. item.reqOrderItemBoms.forEach((data, key) => {
  1568. reqBomText.push(`子件${NumberTranslate(key)}`)
  1569. })
  1570. }
  1571. if (collaseFlag || isOptional) {
  1572. return (
  1573. <View
  1574. style={{
  1575. padding: 10,
  1576. flexDirection: 'row',
  1577. justifyContent: 'space-between',
  1578. }}
  1579. >
  1580. <TouchableOpacity
  1581. activeOpacity={1}
  1582. onPress={() => {
  1583. this.openOptView(item)
  1584. }}
  1585. >
  1586. <View style={{ flexDirection: 'row' }}>
  1587. <Text style={{ fontSize: 12, lineHeight: 17, color: '#333' }}>
  1588. {reqBomText && reqBomText.length > 0 ? '选配项:' : '选 配:'}
  1589. </Text>
  1590. <Text
  1591. numberOfLines={1}
  1592. style={{
  1593. width:
  1594. reqBomText && reqBomText.length > 0
  1595. ? width * 0.4
  1596. : width * 0.75,
  1597. fontSize: 12,
  1598. lineHeight: 17,
  1599. color: '#666',
  1600. }}
  1601. >
  1602. {collaseFlag
  1603. ? reqBomText && reqBomText.length > 0
  1604. ? reqBomText.join()
  1605. : item.baseGoodsOptValue
  1606. : item.baseGoodsOptValue}
  1607. </Text>
  1608. <Image
  1609. resizeMode="contain"
  1610. source={morePng}
  1611. style={{ width: 24, height: 5, alignSelf: 'center' }}
  1612. />
  1613. </View>
  1614. </TouchableOpacity>
  1615. {collaseFlag ? (
  1616. <View style={{ flexDirection: 'row' }}>
  1617. {/* <TouchableOpacity
  1618. onPress={() => {
  1619. item.reqOrderItemBoms && item.reqOrderItemBoms.length > 0
  1620. ? this.state.optCollapse == indexParent
  1621. ? this.setState({ optCollapse: 'shouqi' })
  1622. : this.setState({ optCollapse: indexParent })
  1623. : this.optional._openModal(JSON.parse(JSON.stringify(item)))
  1624. }}
  1625. style={{ alignSelf: 'center' }}
  1626. >
  1627. {item.reqOrderItemBoms && item.reqOrderItemBoms.length > 0 ? (
  1628. this.state.optCollapse == indexParent ? (
  1629. <Text
  1630. style={{ fontSize: 12, lineHeight: 17, color: '#333' }}
  1631. >
  1632. 收起
  1633. </Text>
  1634. ) : (
  1635. <Text
  1636. style={{ fontSize: 12, lineHeight: 17, color: '#333' }}
  1637. >
  1638. 展开
  1639. </Text>
  1640. )
  1641. ) : (
  1642. <Image source={moreDian} style={{ width: 24, height: 5 }} />
  1643. )}
  1644. </TouchableOpacity> */}
  1645. {item.reqOrderItemBoms && item.reqOrderItemBoms.length > 0 ? (
  1646. <View style={{ flexDirection: 'row' }}>
  1647. <Text
  1648. style={{ marginLeft: 8, marginRight: 8, color: '#DDD' }}
  1649. >
  1650. |
  1651. </Text>
  1652. <TouchableOpacity
  1653. onPress={() => {
  1654. this.optional._openModal(
  1655. JSON.parse(JSON.stringify(item)),
  1656. true
  1657. )
  1658. }}
  1659. >
  1660. <Text
  1661. style={{ fontSize: 12, lineHeight: 17, color: '#333' }}
  1662. >
  1663. 选配
  1664. {/* 批量选配 */}
  1665. </Text>
  1666. </TouchableOpacity>
  1667. </View>
  1668. ) : null}
  1669. </View>
  1670. ) : null
  1671. // <TouchableOpacity
  1672. // onPress={() => {
  1673. // this.optional._openModal(JSON.parse(JSON.stringify(item)));
  1674. // }}
  1675. // style={{ alignSelf: "center", paddingRight: 5 }}
  1676. // >
  1677. // <Image source={moreDian} style={{ width: 24, height: 5 }} />
  1678. // </TouchableOpacity>
  1679. }
  1680. </View>
  1681. )
  1682. }
  1683. }
  1684. reqItemBoms(item, index, parentItem) {
  1685. return (
  1686. <View>
  1687. <View
  1688. style={{
  1689. paddingTop: 10,
  1690. paddingHorizontal: 10,
  1691. paddingBottom: item.isOptional ? 0 : 10,
  1692. borderTopColor: '#EEE',
  1693. borderTopWidth: 1 / PixelRatio.get(),
  1694. }}
  1695. >
  1696. <View style={{ flexDirection: 'row' }}>
  1697. <View>
  1698. <Text style={styles.bomTitle}>{`子件${NumberTranslate(
  1699. index
  1700. )}:`}</Text>
  1701. </View>
  1702. <View style={{ flex: 1 }}>
  1703. <Text style={styles.bomTitle}>{item.childGoodsName}</Text>
  1704. <View style={{ flexDirection: 'row', marginTop: 10 }}>
  1705. <Text style={styles.bomText}>编码:{item.childGoodsCode}</Text>
  1706. <Text style={[styles.bomText, { marginLeft: 10 }]}>
  1707. {'v' + item.childGoodsVersion}
  1708. </Text>
  1709. </View>
  1710. <View
  1711. style={{
  1712. flexDirection: 'row',
  1713. justifyContent: 'space-between',
  1714. marginTop: 1,
  1715. }}
  1716. >
  1717. <Text style={styles.bomText}>
  1718. 数量:{accMul(
  1719. accMul(parentItem.conversionRate, parentItem.orderNum),
  1720. item.childGoodsQty
  1721. )}
  1722. {' ' + item.childGoodsUnitName}
  1723. </Text>
  1724. <Text style={styles.bomText}>
  1725. 单价:<Text style={{ color: '#E70013' }}>
  1726. {CURRENCY.currencySign +
  1727. accMul(
  1728. accMul(parentItem.conversionRate, parentItem.orderNum),
  1729. parentItem.basePrice
  1730. )}
  1731. </Text>
  1732. </Text>
  1733. </View>
  1734. </View>
  1735. </View>
  1736. </View>
  1737. <View>{this.optView(item, index, false, item.isOptional)}</View>
  1738. </View>
  1739. )
  1740. }
  1741. promInfoFilter(mutualRelationShip) {
  1742. let result = []
  1743. const basePromInfo = [
  1744. { number: 1, name: '买赠-基于商品' },
  1745. { number: 2, name: '降价-基于商品' },
  1746. { number: 3, name: '买赠-基于订单' },
  1747. { number: 4, name: '降价-基于订单' },
  1748. ]
  1749. for (let i = 0; i < mutualRelationShip.length; i++) {
  1750. let groupArr = []
  1751. ;(mutualRelationShip[i] || []).map(valsec => {
  1752. groupArr = groupArr.concat(
  1753. basePromInfo.filter(item => item.number == valsec)
  1754. )
  1755. })
  1756. result.push(groupArr)
  1757. }
  1758. return result
  1759. }
  1760. baseOnPromTouch(item) {
  1761. let Arr = []
  1762. ;(item || []).map(val => Arr.push(val.number))
  1763. this.props.dispatch(
  1764. createAction('orderedit/getProm')({
  1765. promInfo: {
  1766. customerId: CUSTOMERINFO.id,
  1767. promotionStyle: Arr,
  1768. saleOrgId: this.props.navigation.state.params.SaleOrSupplier
  1769. .SaleOrSupplierId,
  1770. isPrimaryChannel: this.props.navigation.state.params.SaleOrSupplier
  1771. .isPrimaryChannel,
  1772. reqOrderItems: this.state.EditPromData,
  1773. },
  1774. })
  1775. )
  1776. this.combinedFn(true)
  1777. }
  1778. // 赠品回调
  1779. giftCb(e, ids) {
  1780. const {EditPromData} = this.state;
  1781. let totalWeight = 0;
  1782. if(EditPromData && EditPromData.length) {
  1783. EditPromData.map(data => {
  1784. totalWeight += data.mainNum*data.weight;
  1785. })
  1786. }
  1787. if(e && e.length) {
  1788. e.map(data => {
  1789. totalWeight += data.mainNum*data.weight
  1790. })
  1791. }
  1792. this.setState({ giftSelected: e,totalWeight })
  1793. }
  1794. baseOnProm(mutualRelationShip) {
  1795. if (mutualRelationShip) {
  1796. this.RelationShipCopy = mutualRelationShip
  1797. } else {
  1798. mutualRelationShip = this.RelationShipCopy
  1799. }
  1800. let basePromInfo = this.promInfoFilter(mutualRelationShip)
  1801. let basePromData = []
  1802. for (let i = 0; i < basePromInfo.length; i++) {
  1803. ;(basePromInfo[i] || []).map((data, index) =>
  1804. basePromData.push(
  1805. <TouchableOpacity
  1806. key={index + data.name ? data.name : ''}
  1807. style={{ flexDirection: 'row', width: width / 2 - 10 }}
  1808. onPress={() => {
  1809. this.state.baseIndex == i ? {} : this.setState({ baseIndex: i })
  1810. this.baseOnPromTouch(basePromInfo[i])
  1811. }}
  1812. >
  1813. <Icon
  1814. name={
  1815. this.state.baseIndex == i
  1816. ? 'icon-icon-danxuankuang-xuanzhong'
  1817. : 'icon-icon-danxuankuang-weixuanzhong'
  1818. }
  1819. size={26}
  1820. color={this.state.baseIndex == i ? '#E14C46' : '#CCC'}
  1821. />
  1822. <Text
  1823. style={{
  1824. marginLeft: 5,
  1825. fontSize: 13,
  1826. lineHeight: 17,
  1827. color: '#333',
  1828. alignSelf: 'center',
  1829. marginBottom: 1,
  1830. }}
  1831. >
  1832. {data.name || ''}
  1833. </Text>
  1834. </TouchableOpacity>
  1835. )
  1836. )
  1837. }
  1838. return (
  1839. <View
  1840. style={{
  1841. backgroundColor: '#FFF',
  1842. marginTop: 10,
  1843. paddingVertical: 7,
  1844. paddingHorizontal: 10,
  1845. flexDirection: 'row',
  1846. flexWrap: 'wrap',
  1847. }}
  1848. >
  1849. {basePromData}
  1850. </View>
  1851. )
  1852. }
  1853. checkCast(castRateData) {
  1854. let financeOrgIds = [],
  1855. flag = true,
  1856. productLineIds = Array.from(new Set(this.state.productLineIds)),
  1857. returnData = {}
  1858. productLineIds.forEach(lineId => {
  1859. castRateData.forEach(castitem => {
  1860. if (
  1861. castitem.productLineIds.length == 1 &&
  1862. !castitem.productLineIds[0]
  1863. ) {
  1864. flag = false
  1865. returnData = castitem
  1866. } else if (castitem.productLineIds.indexOf(lineId) != -1) {
  1867. financeOrgIds.push(castitem.financeOrgId)
  1868. }
  1869. })
  1870. })
  1871. if (financeOrgIds.length == 1 && flag) {
  1872. castRateData.forEach(item => {
  1873. if (item.financeOrgId == financeOrgIds[0]) {
  1874. returnData = item
  1875. }
  1876. })
  1877. }
  1878. return returnData
  1879. }
  1880. render() {
  1881. const {
  1882. addressDefault,
  1883. transportData,
  1884. transportDefault,
  1885. billwayData,
  1886. billwayDefault,
  1887. invoiceDefault,
  1888. castRateData,
  1889. promData,
  1890. creditData,
  1891. orderPayStatus,
  1892. } = this.props
  1893. const supplierDefault = this.props.navigation.state.params.SaleOrSupplier
  1894. let MaxOffset = 0,
  1895. castRateDataOnly = { costOffsetRatio: 0, supplyMaxOccupyMny: 0 }
  1896. if (
  1897. castRateData &&
  1898. castRateData.length > 0 &&
  1899. this.state.productLineIds &&
  1900. this.state.productLineIds.length > 0
  1901. ) {
  1902. let checkCastReturn = this.checkCast(castRateData)
  1903. if (Object.keys(checkCastReturn).length > 0) {
  1904. castRateDataOnly = checkCastReturn
  1905. }
  1906. if (
  1907. accMul(this.state.goodsAmount, castRateDataOnly.costOffsetRatio) >=
  1908. castRateDataOnly.supplyMaxOccupyMny
  1909. ) {
  1910. MaxOffset = castRateDataOnly.supplyMaxOccupyMny
  1911. } else {
  1912. MaxOffset = accMul(
  1913. this.state.goodsAmount,
  1914. castRateDataOnly.costOffsetRatio
  1915. )
  1916. }
  1917. if (MaxOffset >= this.state.totalAmountCopy) {
  1918. MaxOffset = this.state.totalAmountCopy
  1919. }
  1920. }
  1921. return (
  1922. <View
  1923. style={[
  1924. styles.container,
  1925. { backgroundColor: '#F7F7F7' },
  1926. // { backgroundColor: appTheme.backgroundColor }
  1927. ]}
  1928. >
  1929. <StatusBar
  1930. animated={true}
  1931. // barStyle={appTheme.barStyle}
  1932. barStyle={'dark-content'}
  1933. backgroundColor={'transparent'}
  1934. translucent={true}
  1935. />
  1936. {/* 头部 */}
  1937. {this.header()}
  1938. <ScrollView
  1939. style={{ flex: 1 }}
  1940. // scrollEventThrottle={200}
  1941. // onScroll={() => {
  1942. // // 判断圆形按钮滑动前后是否变化控制刷新
  1943. // if (this.cicleActive == this.state.cicleActive) {
  1944. // this.setState({ cicleActive: false });
  1945. // this.cicleActive = this.state.cicleActive;
  1946. // }
  1947. // }}
  1948. // onScrollEndDrag={() => this.setState({ cicleActive: true })}
  1949. // onMomentumScrollEnd={() => this.setState({ cicleActive: true })}
  1950. >
  1951. {/* 供应商显示 */}
  1952. {this.supplier(supplierDefault)}
  1953. {/*选项行*/}
  1954. <View>
  1955. <View style={{ backgroundColor: '#FFF', marginTop: 10 }}>
  1956. {this.viewRender([
  1957. {
  1958. viewName: '运输方式',
  1959. rightName:
  1960. (transportDefault && transportDefault.name) || '铁路运输',
  1961. iconName: 'icon-icon-xiala',
  1962. onPress: () => {
  1963. this.state.activeMethod == 0
  1964. ? this.setState({ activeMethod: 'nfjdsjf' })
  1965. : this.setState({ activeMethod: 0 })
  1966. },
  1967. dataArr: transportData || [],
  1968. },
  1969. // {
  1970. // viewName: '结算方式',
  1971. // rightName: (billwayDefault && billwayDefault.name) || '现金',
  1972. // iconName: 'icon-icon-xiala',
  1973. // onPress: () => {
  1974. // this.state.activeMethod == 1
  1975. // ? this.setState({ activeMethod: 'nfjdsjf' })
  1976. // : this.setState({ activeMethod: 1 })
  1977. // },
  1978. // dataArr: billwayData || [],
  1979. // },
  1980. // {
  1981. // viewName: '支付方式',
  1982. // rightName: this.state.payWayDef && this.state.payWayDef.name,
  1983. // iconName: 'icon-icon-xiala',
  1984. // onPress: () => {
  1985. // this.state.activeMethod == 2
  1986. // ? this.setState({ activeMethod: 'nfjdsjf' })
  1987. // : this.setState({ activeMethod: 2 })
  1988. // },
  1989. // dataArr: orderPayStatus || [],
  1990. // },
  1991. ])}
  1992. </View>
  1993. <View style={{ backgroundColor: '#FFF', marginTop: 10 }}>
  1994. {this.viewRender([
  1995. {
  1996. viewName: '发票',
  1997. rightName:
  1998. (invoiceDefault && invoiceDefault.invoiceTitle) || '发票',
  1999. iconName: 'icon-icon-jianjinzhishiqi',
  2000. onPress: () =>
  2001. this.props.dispatch(
  2002. NavigationActions.navigate({
  2003. routeName: 'SelectInvoice',
  2004. params: e => this.invoiceCallback(e),
  2005. })
  2006. ),
  2007. },
  2008. ])}
  2009. </View>
  2010. {/* <View style={{ backgroundColor: '#FFF', marginTop: 10 }}>
  2011. {this.viewRender(
  2012. [
  2013. {
  2014. viewName: '期望到货日期',
  2015. rightName: this.state.deliveryTime,
  2016. iconName: 'icon-icon-xiala',
  2017. onPress: () =>
  2018. Platform.OS == 'ios'
  2019. ? this.showTime._openModal()
  2020. : this.TimeAndroid(),
  2021. inputName: '备注',
  2022. inputDefault: this.state.remark || '备注订单内容',
  2023. inputValue: '',
  2024. },
  2025. ],
  2026. true
  2027. )}
  2028. </View> */}
  2029. </View>
  2030. {/* 选地址 */}
  2031. <TouchableOpacity
  2032. activeOpacity={1}
  2033. onPress={() =>
  2034. this.props.dispatch(
  2035. NavigationActions.navigate({
  2036. routeName: 'SelectAdress',
  2037. params: e => this.callback(e),
  2038. })
  2039. )
  2040. }
  2041. style={{
  2042. backgroundColor: '#FFF',
  2043. marginTop: 10,
  2044. flexDirection: 'row',
  2045. paddingTop: 10,
  2046. paddingBottom: 5,
  2047. }}
  2048. >
  2049. <View style={{ flex: 1, justifyContent: 'flex-end' }}>
  2050. <Icon
  2051. name="icon-icon-dizhi"
  2052. size={24}
  2053. color={'#333'}
  2054. style={{ alignSelf: 'center' }}
  2055. />
  2056. </View>
  2057. <View style={{ flex: 8, paddingBottom: 5 }}>
  2058. <View style={{ flexDirection: 'row' }}>
  2059. <Text style={{ fontSize: 15, lineHeight: 21, color: '#333' }}>
  2060. {addressDefault && addressDefault.receiver}
  2061. </Text>
  2062. <Text style={{ marginLeft: 3, alignSelf: 'center' }}>
  2063. {addressDefault && addressDefault.receiverPhone}
  2064. </Text>
  2065. </View>
  2066. <Text
  2067. style={{
  2068. marginTop: 4,
  2069. fontSize: 13,
  2070. lineHeight: 18,
  2071. color: '#333',
  2072. }}
  2073. >
  2074. {((addressDefault && addressDefault.receiverProvince) || '') +
  2075. ((addressDefault && addressDefault.receiverCity) || '') +
  2076. ((addressDefault && addressDefault.receiverDistrict) || '') +
  2077. ((addressDefault && addressDefault.receiverTown) || '') +
  2078. ((addressDefault && addressDefault.receiverAddress) || '')}
  2079. </Text>
  2080. </View>
  2081. <View
  2082. style={{
  2083. flex: 1,
  2084. justifyContent: 'center',
  2085. }}
  2086. >
  2087. <Icon
  2088. name="icon-icon-jianjinzhishiqi"
  2089. size={24}
  2090. color={'#ccc'}
  2091. style={{ alignSelf: 'center' }}
  2092. />
  2093. </View>
  2094. </TouchableOpacity>
  2095. {/* Image地址下边框 */}
  2096. <Image source={redblue} style={{ height: 2, width: width }} />
  2097. {/* 基于原单或基于商品数量选项 */}
  2098. {promData.mutualRelationShip
  2099. ? this.baseOnProm(promData.mutualRelationShip)
  2100. : null}
  2101. {/* 商品信息 */}
  2102. {this.state.Loading ? (
  2103. <View style={{ marginTop: 10 }}>
  2104. <ActivityIndicator />
  2105. </View>
  2106. ) : (
  2107. <FlatList
  2108. keyExtractor={item => item.goodsId}
  2109. data={this.state.EditPromData}
  2110. extraData={this.state}
  2111. renderItem={({ item, index }) => this.goodsInfo(item, index)}
  2112. />
  2113. )}
  2114. {/* 赠品明细 */}
  2115. {promData && promData.giftProms && promData.giftProms.length > 0 ? (
  2116. <View
  2117. style={{
  2118. backgroundColor: '#FFF',
  2119. paddingHorizontal: 10,
  2120. paddingTop: 10,
  2121. marginTop: 10,
  2122. }}
  2123. >
  2124. <TouchableOpacity
  2125. onPress={() => {
  2126. let NavigateGift =
  2127. JSON.parse(JSON.stringify(promData.giftProms)) || []
  2128. ;(NavigateGift || []).map(item => {
  2129. item.data = item.giftDtos
  2130. delete item.giftDtos
  2131. })
  2132. this.props.dispatch(
  2133. NavigationActions.navigate({
  2134. routeName: 'OrderGifts',
  2135. params: {
  2136. giftProms: NavigateGift,
  2137. giftCb: (e, ids) => this.giftCb(e, ids),
  2138. },
  2139. })
  2140. )
  2141. }}
  2142. style={{
  2143. paddingBottom: 6,
  2144. flexDirection: 'row',
  2145. justifyContent: 'space-between',
  2146. }}
  2147. >
  2148. <Text style={{ fontSize: 14, lineHeight: 20, color: '#333' }}>
  2149. 赠品明细
  2150. </Text>
  2151. <View style={{ flexDirection: 'row' }}>
  2152. <Text style={{ fontSize: 14, lineHeight: 20, color: '#666' }}>
  2153. 选择赠品
  2154. </Text>
  2155. <Icon
  2156. name="icon-icon-jianjinzhishiqi"
  2157. color="#666"
  2158. size={24}
  2159. style={{ alignSelf: 'center' }}
  2160. />
  2161. </View>
  2162. </TouchableOpacity>
  2163. {this.state.giftSelected.length > 0 ? (
  2164. <FlatList
  2165. keyExtractor={(item, index) => index}
  2166. data={this.state.giftSelected}
  2167. extraData={this.state}
  2168. style={{
  2169. paddingBottom: 10,
  2170. borderTopColor: '#EEE',
  2171. borderTopWidth: 1 / PixelRatio.get(),
  2172. }}
  2173. renderItem={({ item, index }) => (
  2174. <View
  2175. style={{
  2176. flexDirection: 'row',
  2177. justifyContent: 'space-between',
  2178. paddingTop: 10,
  2179. }}
  2180. >
  2181. <Text
  2182. numberOfLines={1}
  2183. style={{
  2184. flex: 1,
  2185. fontSize: 12,
  2186. lineHeight: 17,
  2187. color: '#333',
  2188. }}
  2189. >
  2190. {item.goodsDisplayName}
  2191. </Text>
  2192. <View style={{ flexDirection: 'row', marginLeft: 30 }}>
  2193. <Icon
  2194. name="icon-icon-guanbianniu"
  2195. size={20}
  2196. color="#666"
  2197. />
  2198. <Text
  2199. style={{
  2200. fontSize: 12,
  2201. lineHeight: 17,
  2202. color: '#333',
  2203. marginLeft: 5,
  2204. }}
  2205. >
  2206. {item.mainNum || 1}
  2207. </Text>
  2208. </View>
  2209. </View>
  2210. )}
  2211. />
  2212. ) : null}
  2213. </View>
  2214. ) : null}
  2215. {/* 总体积、数量 */}
  2216. <View style={{ marginTop: 10, padding: 10, backgroundColor: '#FFF' }}>
  2217. <View
  2218. style={{
  2219. flexDirection: 'row',
  2220. justifyContent: 'space-between',
  2221. }}
  2222. >
  2223. <Text style={styles.text666}>总重量</Text>
  2224. <Text style={styles.text666}>
  2225. {this.state.totalWeight}{"KG"}
  2226. {/* {this.state.weightUnit} */}
  2227. </Text>
  2228. </View>
  2229. {/* <View
  2230. style={{
  2231. flexDirection: 'row',
  2232. justifyContent: 'space-between',
  2233. }}
  2234. >
  2235. <Text style={styles.text666}>总体积</Text>
  2236. <Text style={styles.text666}>
  2237. {this.state.totoalVolume}
  2238. {this.state.volumeUnit}
  2239. </Text>
  2240. </View> */}
  2241. </View>
  2242. {/* 金额显示 */}
  2243. <View style={{ marginTop: 10, backgroundColor: '#FFF', padding: 10 }}>
  2244. <View
  2245. style={{
  2246. flexDirection: 'row',
  2247. justifyContent: 'space-between',
  2248. }}
  2249. >
  2250. <Text style={styles.text666}>商品金额:</Text>
  2251. <Text style={styles.text666red}>
  2252. {CURRENCY.currencySign}
  2253. {ScaleUtil(
  2254. this.state.goodsAmount,
  2255. CURRENCY.currencyAmountScale
  2256. )}
  2257. </Text>
  2258. </View>
  2259. <View
  2260. style={{
  2261. flexDirection: 'row',
  2262. justifyContent: 'space-between',
  2263. }}
  2264. >
  2265. <Text style={styles.text666}>促销金额:</Text>
  2266. <Text style={styles.text666red}>
  2267. {CURRENCY.currencySign}
  2268. {this.state.totalPromAmt}
  2269. </Text>
  2270. </View>
  2271. {/* <View
  2272. style={{
  2273. flexDirection: 'row',
  2274. justifyContent: 'space-between',
  2275. }}
  2276. >
  2277. <Text style={styles.text666}>费用冲抵:</Text>
  2278. <Input
  2279. style={{
  2280. borderWidth: 1,
  2281. borderColor: '#E6E6E6',
  2282. borderRadius: 2,
  2283. width: width / 2.5,
  2284. height: 24,
  2285. padding: 0,
  2286. alignItems: 'center',
  2287. }}
  2288. ref={AverageRef => (this.AverageRef = AverageRef)}
  2289. keyboardType={'numeric'}
  2290. isICon={false}
  2291. blurOnSubmit={true}
  2292. placeholder={''}
  2293. textInputBacg={'#FFF'}
  2294. placeholderTextColor={'#CCC'}
  2295. onchangeFn={e => this.AverageBooth(e, MaxOffset)}
  2296. maxNum={MaxOffset}
  2297. />
  2298. </View> */}
  2299. {/* <View
  2300. style={{
  2301. flexDirection: 'row',
  2302. justifyContent: 'flex-end',
  2303. marginTop: 5,
  2304. }}
  2305. >
  2306. <Text style={[styles.text999, { marginRight: 10 }]}>
  2307. (本次最高冲抵:<Text style={{ color: '#E14C46' }}>
  2308. {CURRENCY.currencySign}
  2309. {ScaleUtil(MaxOffset, CURRENCY.currencyAmountScale)}
  2310. </Text>
  2311. </Text>
  2312. <Text style={styles.text999}>
  2313. 费用总金额:
  2314. <Text style={{ color: '#E14C46' }}>
  2315. {CURRENCY.currencySign}
  2316. {ScaleUtil(
  2317. castRateDataOnly.supplyMaxOccupyMny || 0,
  2318. CURRENCY.currencyAmountScale
  2319. )}
  2320. </Text>)
  2321. </Text>
  2322. </View> */}
  2323. <View
  2324. style={{
  2325. flexDirection: 'row',
  2326. justifyContent: 'space-between',
  2327. marginTop: 20,
  2328. }}
  2329. >
  2330. {/* <TouchableOpacity
  2331. style={{ flexDirection: 'row' }}
  2332. onPress={() => {
  2333. this.credit._openModal(creditData)
  2334. this.setState({ creditShow: true })
  2335. }}
  2336. >
  2337. <Text style={[styles.text999, { alignSelf: 'center' }]}>
  2338. 信用查询
  2339. </Text>
  2340. <Image
  2341. source={orderCreditPng}
  2342. style={{
  2343. width: 14,
  2344. height: 14,
  2345. alignSelf: 'center',
  2346. marginLeft: 4,
  2347. }}
  2348. />
  2349. </TouchableOpacity> */}
  2350. <Text style={styles.text666}>
  2351. 订单总金额:<Text
  2352. style={{ fontSize: 18, lineHeight: 25, color: '#E14C46' }}
  2353. >
  2354. {CURRENCY.currencySign}{' '}
  2355. {ScaleUtil(
  2356. this.state.totalAmount,
  2357. CURRENCY.currencyAmountScale
  2358. )}
  2359. </Text>
  2360. </Text>
  2361. </View>
  2362. <View style={{ marginTop: 10, backgroundColor: '#FFF' }}>
  2363. <View style={{flexDirection: 'row'}}>
  2364. <Text>备注:</Text>
  2365. <TextInput
  2366. style={{
  2367. fontSize: 12,
  2368. color: '#333333',
  2369. padding: 0,
  2370. backgroundColor: '#FFF',
  2371. height: 25,
  2372. borderWidth: 1,
  2373. borderColor: '#DDDDDD',
  2374. width:'60%'
  2375. }}
  2376. // multiline
  2377. // numberOfLines={4}
  2378. value={this.state.remark}
  2379. onChangeText={text=>this.setState({remark:text})}
  2380. underlineColorAndroid="transparent"
  2381. />
  2382. </View>
  2383. </View>
  2384. </View>
  2385. <Modal
  2386. animationType="slide"
  2387. presentationStyle="formSheet"
  2388. transparent={true}
  2389. visible={this.state.showOptModal}
  2390. onRequestClose={() => {
  2391. this.setState({
  2392. showOptModal: false
  2393. })
  2394. }}
  2395. >
  2396. <View
  2397. style={{
  2398. backgroundColor:'#FFF',
  2399. top:'50%',
  2400. paddingBottom: 50,
  2401. width:'100%',
  2402. height:'50%',
  2403. alignItems : 'center',
  2404. elevation : 5,
  2405. }}>
  2406. {this.state.optLoading ? (
  2407. <View style={{marginTop:100}}>
  2408. <ActivityIndicator />
  2409. </View>
  2410. ) : <View>
  2411. <View style={{flexDirection:'row'}}>
  2412. <Text style={{ fontSize: 13, lineHeight: 18, color: '#333',width:'90%',marginTop:10 }}>选择颜色</Text>
  2413. <TouchableOpacity onPress={() =>{
  2414. this.setState({
  2415. showOptModal: false
  2416. })
  2417. }}>
  2418. <Image
  2419. source={deletePng}
  2420. style={{ width: 20, height: 20}}
  2421. />
  2422. </TouchableOpacity>
  2423. </View>
  2424. <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)}/>
  2425. </View>
  2426. }
  2427. </View>
  2428. </Modal>
  2429. <Modal
  2430. animationType="slide"
  2431. presentationStyle="formSheet"
  2432. transparent={true}
  2433. visible={this.state.modalVisible}
  2434. onRequestClose={() => {
  2435. console.log('close');
  2436. }}
  2437. >
  2438. <View
  2439. style={{
  2440. backgroundColor:'#f8f8f8',
  2441. marginTop:'50%',
  2442. marginLeft:'15%',
  2443. width:'70%',
  2444. height:'24%',
  2445. alignItems : 'center',
  2446. shadowColor : '#000',
  2447. shadowOffset: {width: 0,height: 2},
  2448. shadowOpacity : 0.25,
  2449. shadowRadius : 3.84,
  2450. elevation : 5,
  2451. //borderRadius : 20
  2452. }}>
  2453. <Text style={{marginTop:10}}>请输入商品数量</Text>
  2454. <TextInput
  2455. style={{width:'50%'}}
  2456. onChangeText={text => this.setState({num:text})}
  2457. value={this.state.num}
  2458. />
  2459. <View style={{width:"100%",flexDirection:'row',position:'absolute',bottom:0}}>
  2460. <TouchableOpacity style={{backgroundColor : '#E70013',width:'50%',alignItems:'center',fontSize:20,padding:5}}
  2461. onPress= {() => this.onModalOk()}
  2462. >
  2463. <Text>确定</Text>
  2464. </TouchableOpacity>
  2465. <TouchableOpacity style={{backgroundColor : '#fff',width:'50%',alignItems:'center',fontSize:20,padding:5}}
  2466. onPress= {() => this.setState({modalVisible:false})}
  2467. >
  2468. <Text>取消</Text>
  2469. </TouchableOpacity>
  2470. </View>
  2471. </View>
  2472. </Modal>
  2473. </ScrollView>
  2474. {/* 信用弹窗 */}
  2475. <OrderCredit
  2476. ref={credit => (this.credit = credit)}
  2477. cb={() => this.setState({ creditShow: false })}
  2478. />
  2479. <OrderOptional
  2480. {...this.props}
  2481. ref={optional => (this.optional = optional)}
  2482. onPressBom={() => {
  2483. this.addBoomToData()
  2484. }}
  2485. // 选配回调处理(将选择的选配结果返回 加到商品行上)
  2486. optCb={data => {
  2487. this.state.EditPromData.forEach(item => {
  2488. let allOptIds = '',
  2489. allOptVals = ''
  2490. if (item.reqOrderItemBoms && item.reqOrderItemBoms.length > 0) {
  2491. item.reqOrderItemBoms.forEach(itemSec => {
  2492. data.forEach(itemTh => {
  2493. if (itemSec.childGoodsId == itemTh.goodsId) {
  2494. itemSec.baseGoodsOptId = itemTh.optIds
  2495. itemSec.baseGoodsOptValue = itemTh.optVals
  2496. if (allOptIds && allOptIds.length > 0) {
  2497. allOptIds = allOptIds.concat(
  2498. ',' + itemSec.baseGoodsOptId
  2499. )
  2500. allOptVals = allOptVals.concat(
  2501. ',' + itemSec.baseGoodsOptValue
  2502. )
  2503. } else {
  2504. allOptIds = itemSec.baseGoodsOptId
  2505. allOptVals = itemSec.baseGoodsOptValue
  2506. }
  2507. }
  2508. })
  2509. })
  2510. } else {
  2511. data.forEach(dataFt => {
  2512. if (dataFt.goodsId == item.goodsId) {
  2513. allOptIds = dataFt.optIds
  2514. allOptVals = dataFt.optVals
  2515. }
  2516. })
  2517. }
  2518. item.baseGoodsOptId = allOptIds
  2519. item.baseGoodsOptValue = allOptVals
  2520. })
  2521. this.addBoomToData()
  2522. this.setState({ EditPromData: this.state.EditPromData })
  2523. }}
  2524. />
  2525. {/* 时间弹窗 */}
  2526. <SelectTime
  2527. ref={showTime => (this.showTime = showTime)}
  2528. cb={date => {
  2529. this.setState({
  2530. deliveryTime: moment(date).format('YYYY-MM-DD'),
  2531. })
  2532. }}
  2533. />
  2534. {/* 底部 */}
  2535. <View
  2536. style={{
  2537. height: 45 + HEADERSTYLE.paddingBottom,
  2538. paddingBottom: HEADERSTYLE.paddingBottom,
  2539. backgroundColor: '#FFF',
  2540. flexDirection: 'row',
  2541. borderTopColor: '#EEE',
  2542. borderTopWidth: 1 / PixelRatio.get(),
  2543. }}
  2544. >
  2545. {this.bottomTouch()}
  2546. </View>
  2547. {/* 信用弹窗毛玻璃效果 */}
  2548. {/* {this.state.creditShow ? (
  2549. <View
  2550. style={{
  2551. position: "absolute",
  2552. width: width,
  2553. height: height,
  2554. backgroundColor: "#000",
  2555. opacity: 0.5
  2556. }}
  2557. />
  2558. ) : null} */}
  2559. </View>
  2560. )
  2561. }
  2562. }
  2563. const styles = StyleSheet.create({
  2564. container: {
  2565. flex: 1,
  2566. },
  2567. text333: {
  2568. fontSize: 14,
  2569. lineHeight: 20,
  2570. letterSpacing: 0.17,
  2571. color: '#333',
  2572. },
  2573. text666: {
  2574. fontSize: 13,
  2575. lineHeight: 18,
  2576. color: '#666',
  2577. },
  2578. text666red: {
  2579. fontSize: 14,
  2580. lineHeight: 25,
  2581. color: '#E14C46',
  2582. },
  2583. text999: {
  2584. fontSize: 12,
  2585. lineHeight: 17,
  2586. color: '#999',
  2587. },
  2588. bomTitle: {
  2589. fontSize: 13,
  2590. lineHeight: 18,
  2591. color: '#333',
  2592. },
  2593. bomText: {
  2594. fontSize: 12,
  2595. lineHeight: 17,
  2596. color: '#666',
  2597. },
  2598. modalStyle: {
  2599. }
  2600. })
  2601. export default OrderEdit