OrderEdit.js 88 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659
  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. if (item.isOptional) {
  1364. isOptArrs.push(item.isOptional)
  1365. } else if (item.reqOrderItemBoms && item.reqOrderItemBoms.length > 0) {
  1366. item.reqOrderItemBoms.forEach(data => {
  1367. isOptArrs.push(data.isOptional)
  1368. })
  1369. }
  1370. if (isOptArrs.some(smdata => smdata == 1)) {
  1371. optFlag = true
  1372. }
  1373. return (
  1374. <View>
  1375. <View style={{ padding: 10, marginTop: 10, backgroundColor: '#FFF' }}>
  1376. {/* 满减/买赠 */}
  1377. <View style={{ paddingBottom: 10 }}>
  1378. <FlatList
  1379. keyExtractor={item => item.ruleId}
  1380. data={item.reqOrderPromRels || []}
  1381. extraData={this.state}
  1382. renderItem={({ item, index }) => this.promInfo(item, index)}
  1383. />
  1384. </View>
  1385. {/* 商品行 */}
  1386. <View style={{ flexDirection: 'row' }}>
  1387. <Image
  1388. source={{ uri: ImageBaseUrl + item.goodsImg } || png}
  1389. style={{ width: 80, height: 80 }}
  1390. />
  1391. <View style={{ marginLeft: 10, flex: 1 }}>
  1392. <View style={{flexDirection:'row'}}>
  1393. <Text style={{ fontSize: 13, lineHeight: 18, color: '#333',width:'90%' }}>
  1394. {item.goodsDisplayName}
  1395. </Text>
  1396. <TouchableOpacity onPress={() =>this.deleteGoodsFn(indexParent)}>
  1397. <Image
  1398. source={deletePng}
  1399. style={{ width: 20, height: 20}}
  1400. />
  1401. </TouchableOpacity>
  1402. </View>
  1403. <View
  1404. style={{
  1405. flexDirection: 'row',
  1406. justifyContent: 'space-between',
  1407. marginTop: 10,
  1408. }}
  1409. >
  1410. <Text style={{ fontSize: 12, lineHeight: 17, color: '#666' }}>
  1411. 型号:{item.model?(item.model.length>10?item.model.substr(0,10):item.model):""}
  1412. </Text>
  1413. </View>
  1414. <View
  1415. style={{
  1416. flexDirection: 'row',
  1417. justifyContent: 'space-between',
  1418. marginTop: 10,
  1419. }}
  1420. >
  1421. <Text style={{ fontSize: 12, lineHeight: 17, color: '#666' }}>
  1422. 规格:{item.specification?(item.specification.split("/")[0]+'/'+item.mainNumUnitName):""}
  1423. </Text>
  1424. </View>
  1425. <View
  1426. style={{
  1427. flexDirection: 'row',
  1428. justifyContent: 'space-between',
  1429. marginTop: 7,
  1430. }}
  1431. >
  1432. {/* <CountNum
  1433. defaultValue={item.orderNum}
  1434. size={25}
  1435. callback={nv => {
  1436. this.combinedFn(false, indexParent, nv)
  1437. }}
  1438. /> */}
  1439. <Text style={{ fontSize: 12, lineHeight: 17, color: '#666' }}>
  1440. 数量:{item.mainNum} {item.mainNumUnitName}
  1441. </Text>
  1442. <Text style={{ fontSize: 12, lineHeight: 17, color: '#666' }}>
  1443. 重量:{item.weight*item.mainNum}{'KG'}
  1444. </Text>
  1445. </View>
  1446. <View style={{
  1447. flexDirection: 'row',
  1448. justifyContent: 'space-between',
  1449. marginTop: 7,
  1450. }}>
  1451. <TouchableOpacity
  1452. style={{
  1453. backgroundColor : '#E70013',
  1454. borderRadius : 100,
  1455. }}
  1456. onPress={() =>this.modalVisible(indexParent)}
  1457. >
  1458. <Text style={{fontSize:12,color:'#fff',padding:5}}>修改数量</Text>
  1459. </TouchableOpacity>
  1460. </View>
  1461. </View>
  1462. </View>
  1463. <View
  1464. style={{
  1465. flexDirection: 'row',
  1466. justifyContent: 'space-between',
  1467. marginTop: 10,
  1468. }}
  1469. >
  1470. <Text style={{ fontSize: 12, lineHeight: 17, color: '#666' }}>
  1471. 成交价:<Text
  1472. style={{ fontSize: 14, lineHeight: 17, color: '#E14C46' }}
  1473. >
  1474. {CURRENCY.currencySign}
  1475. {ScaleUtil(
  1476. item.dealPrice || item.basePrice,
  1477. CURRENCY.currencyPriceScale
  1478. )}
  1479. </Text>
  1480. </Text>
  1481. <Text style={{ fontSize: 12, lineHeight: 17, color: '#666' }}>
  1482. 成交金额:<Text
  1483. style={{ fontSize: 14, lineHeight: 17, color: '#E14C46' }}
  1484. >
  1485. {CURRENCY.currencySign}
  1486. {ScaleUtil(item.dealAmount, CURRENCY.currencyAmountScale)}
  1487. </Text>
  1488. </Text>
  1489. </View>
  1490. </View>
  1491. {/* 选配列表 */}
  1492. {optFlag ? (
  1493. <View
  1494. style={{
  1495. backgroundColor: '#FFF',
  1496. borderTopColor: '#EEE',
  1497. borderTopWidth: 1 / PixelRatio.get(),
  1498. }}
  1499. >
  1500. {this.optView(item, indexParent, true)}
  1501. <FlatList
  1502. keyExtractor={item => item.id}
  1503. data={item.reqOrderItemBoms || []}
  1504. extraData={this.state}
  1505. renderItem={itemSec =>
  1506. this.reqItemBoms(itemSec.item, itemSec.index, item)
  1507. }
  1508. />
  1509. <Collapsible collapsed={this.state.optCollapse != indexParent}>
  1510. <FlatList
  1511. keyExtractor={item => item.id}
  1512. data={item.reqOrderItemBoms || []}
  1513. extraData={this.state}
  1514. renderItem={itemSec =>
  1515. this.reqItemBoms(itemSec.item, itemSec.index, item)
  1516. }
  1517. />
  1518. </Collapsible>
  1519. </View>
  1520. ) : null}
  1521. {/* 重量等信息 */}
  1522. <Collapsible collapsed={this.state.activeAllCollaps}>
  1523. <View style={{ padding: 10, backgroundColor: '#FAFAFA' }}>
  1524. <View
  1525. style={{ flexDirection: 'row', justifyContent: 'space-between' }}
  1526. >
  1527. <Text style={styles.text666}>
  1528. 单价:{CURRENCY.currencySign}
  1529. {item.salePrice}
  1530. </Text>
  1531. <Text style={styles.text666}>
  1532. 金额:{CURRENCY.currencySign}
  1533. {accMul(item.salePrice || item.basePrice, item.mainNum)}
  1534. </Text>
  1535. </View>
  1536. <View
  1537. style={{
  1538. flexDirection: 'row',
  1539. justifyContent: 'space-between',
  1540. marginTop: 3,
  1541. }}
  1542. >
  1543. <Text style={styles.text666}>
  1544. 重量:{item.weight}
  1545. {item.weightUnit}
  1546. </Text>
  1547. <Text style={styles.text666}>
  1548. 体积:{item.volume}
  1549. {item.volumeUnit}
  1550. </Text>
  1551. </View>
  1552. </View>
  1553. </Collapsible>
  1554. </View>
  1555. )
  1556. }
  1557. optView(item, indexParent, collaseFlag, isOptional) {
  1558. const reqBomText = []
  1559. if (item.reqOrderItemBoms && item.reqOrderItemBoms.length > 0) {
  1560. item.reqOrderItemBoms.forEach((data, key) => {
  1561. reqBomText.push(`子件${NumberTranslate(key)}`)
  1562. })
  1563. }
  1564. if (collaseFlag || isOptional) {
  1565. return (
  1566. <View
  1567. style={{
  1568. padding: 10,
  1569. flexDirection: 'row',
  1570. justifyContent: 'space-between',
  1571. }}
  1572. >
  1573. <TouchableOpacity
  1574. activeOpacity={1}
  1575. onPress={() => {
  1576. this.openOptView(item)
  1577. }}
  1578. >
  1579. <View style={{ flexDirection: 'row' }}>
  1580. <Text style={{ fontSize: 12, lineHeight: 17, color: '#333' }}>
  1581. {reqBomText && reqBomText.length > 0 ? '选配项:' : '选 配:'}
  1582. </Text>
  1583. <Text
  1584. numberOfLines={1}
  1585. style={{
  1586. width:
  1587. reqBomText && reqBomText.length > 0
  1588. ? width * 0.4
  1589. : width * 0.75,
  1590. fontSize: 12,
  1591. lineHeight: 17,
  1592. color: '#666',
  1593. }}
  1594. >
  1595. {collaseFlag
  1596. ? reqBomText && reqBomText.length > 0
  1597. ? reqBomText.join()
  1598. : item.baseGoodsOptValue
  1599. : item.baseGoodsOptValue}
  1600. </Text>
  1601. <Image
  1602. resizeMode="contain"
  1603. source={morePng}
  1604. style={{ width: 24, height: 5, alignSelf: 'center' }}
  1605. />
  1606. </View>
  1607. </TouchableOpacity>
  1608. {collaseFlag ? (
  1609. <View style={{ flexDirection: 'row' }}>
  1610. {/* <TouchableOpacity
  1611. onPress={() => {
  1612. item.reqOrderItemBoms && item.reqOrderItemBoms.length > 0
  1613. ? this.state.optCollapse == indexParent
  1614. ? this.setState({ optCollapse: 'shouqi' })
  1615. : this.setState({ optCollapse: indexParent })
  1616. : this.optional._openModal(JSON.parse(JSON.stringify(item)))
  1617. }}
  1618. style={{ alignSelf: 'center' }}
  1619. >
  1620. {item.reqOrderItemBoms && item.reqOrderItemBoms.length > 0 ? (
  1621. this.state.optCollapse == indexParent ? (
  1622. <Text
  1623. style={{ fontSize: 12, lineHeight: 17, color: '#333' }}
  1624. >
  1625. 收起
  1626. </Text>
  1627. ) : (
  1628. <Text
  1629. style={{ fontSize: 12, lineHeight: 17, color: '#333' }}
  1630. >
  1631. 展开
  1632. </Text>
  1633. )
  1634. ) : (
  1635. <Image source={moreDian} style={{ width: 24, height: 5 }} />
  1636. )}
  1637. </TouchableOpacity> */}
  1638. {item.reqOrderItemBoms && item.reqOrderItemBoms.length > 0 ? (
  1639. <View style={{ flexDirection: 'row' }}>
  1640. <Text
  1641. style={{ marginLeft: 8, marginRight: 8, color: '#DDD' }}
  1642. >
  1643. |
  1644. </Text>
  1645. <TouchableOpacity
  1646. onPress={() => {
  1647. this.optional._openModal(
  1648. JSON.parse(JSON.stringify(item)),
  1649. true
  1650. )
  1651. }}
  1652. >
  1653. <Text
  1654. style={{ fontSize: 12, lineHeight: 17, color: '#333' }}
  1655. >
  1656. 选配
  1657. {/* 批量选配 */}
  1658. </Text>
  1659. </TouchableOpacity>
  1660. </View>
  1661. ) : null}
  1662. </View>
  1663. ) : null
  1664. // <TouchableOpacity
  1665. // onPress={() => {
  1666. // this.optional._openModal(JSON.parse(JSON.stringify(item)));
  1667. // }}
  1668. // style={{ alignSelf: "center", paddingRight: 5 }}
  1669. // >
  1670. // <Image source={moreDian} style={{ width: 24, height: 5 }} />
  1671. // </TouchableOpacity>
  1672. }
  1673. </View>
  1674. )
  1675. }
  1676. }
  1677. reqItemBoms(item, index, parentItem) {
  1678. return (
  1679. <View>
  1680. <View
  1681. style={{
  1682. paddingTop: 10,
  1683. paddingHorizontal: 10,
  1684. paddingBottom: item.isOptional ? 0 : 10,
  1685. borderTopColor: '#EEE',
  1686. borderTopWidth: 1 / PixelRatio.get(),
  1687. }}
  1688. >
  1689. <View style={{ flexDirection: 'row' }}>
  1690. <View>
  1691. <Text style={styles.bomTitle}>{`子件${NumberTranslate(
  1692. index
  1693. )}:`}</Text>
  1694. </View>
  1695. <View style={{ flex: 1 }}>
  1696. <Text style={styles.bomTitle}>{item.childGoodsName}</Text>
  1697. <View style={{ flexDirection: 'row', marginTop: 10 }}>
  1698. <Text style={styles.bomText}>编码:{item.childGoodsCode}</Text>
  1699. <Text style={[styles.bomText, { marginLeft: 10 }]}>
  1700. {'v' + item.childGoodsVersion}
  1701. </Text>
  1702. </View>
  1703. <View
  1704. style={{
  1705. flexDirection: 'row',
  1706. justifyContent: 'space-between',
  1707. marginTop: 1,
  1708. }}
  1709. >
  1710. <Text style={styles.bomText}>
  1711. 数量:{accMul(
  1712. accMul(parentItem.conversionRate, parentItem.orderNum),
  1713. item.childGoodsQty
  1714. )}
  1715. {' ' + item.childGoodsUnitName}
  1716. </Text>
  1717. <Text style={styles.bomText}>
  1718. 单价:<Text style={{ color: '#E70013' }}>
  1719. {CURRENCY.currencySign +
  1720. accMul(
  1721. accMul(parentItem.conversionRate, parentItem.orderNum),
  1722. parentItem.basePrice
  1723. )}
  1724. </Text>
  1725. </Text>
  1726. </View>
  1727. </View>
  1728. </View>
  1729. </View>
  1730. <View>{this.optView(item, index, false, item.isOptional)}</View>
  1731. </View>
  1732. )
  1733. }
  1734. promInfoFilter(mutualRelationShip) {
  1735. let result = []
  1736. const basePromInfo = [
  1737. { number: 1, name: '买赠-基于商品' },
  1738. { number: 2, name: '降价-基于商品' },
  1739. { number: 3, name: '买赠-基于订单' },
  1740. { number: 4, name: '降价-基于订单' },
  1741. ]
  1742. for (let i = 0; i < mutualRelationShip.length; i++) {
  1743. let groupArr = []
  1744. ;(mutualRelationShip[i] || []).map(valsec => {
  1745. groupArr = groupArr.concat(
  1746. basePromInfo.filter(item => item.number == valsec)
  1747. )
  1748. })
  1749. result.push(groupArr)
  1750. }
  1751. return result
  1752. }
  1753. baseOnPromTouch(item) {
  1754. let Arr = []
  1755. ;(item || []).map(val => Arr.push(val.number))
  1756. this.props.dispatch(
  1757. createAction('orderedit/getProm')({
  1758. promInfo: {
  1759. customerId: CUSTOMERINFO.id,
  1760. promotionStyle: Arr,
  1761. saleOrgId: this.props.navigation.state.params.SaleOrSupplier
  1762. .SaleOrSupplierId,
  1763. isPrimaryChannel: this.props.navigation.state.params.SaleOrSupplier
  1764. .isPrimaryChannel,
  1765. reqOrderItems: this.state.EditPromData,
  1766. },
  1767. })
  1768. )
  1769. this.combinedFn(true)
  1770. }
  1771. // 赠品回调
  1772. giftCb(e, ids) {
  1773. const {EditPromData} = this.state;
  1774. let totalWeight = 0;
  1775. if(EditPromData && EditPromData.length) {
  1776. EditPromData.map(data => {
  1777. totalWeight += data.mainNum*data.weight;
  1778. })
  1779. }
  1780. if(e && e.length) {
  1781. e.map(data => {
  1782. totalWeight += data.mainNum*data.weight
  1783. })
  1784. }
  1785. this.setState({ giftSelected: e,totalWeight })
  1786. }
  1787. baseOnProm(mutualRelationShip) {
  1788. if (mutualRelationShip) {
  1789. this.RelationShipCopy = mutualRelationShip
  1790. } else {
  1791. mutualRelationShip = this.RelationShipCopy
  1792. }
  1793. let basePromInfo = this.promInfoFilter(mutualRelationShip)
  1794. let basePromData = []
  1795. for (let i = 0; i < basePromInfo.length; i++) {
  1796. ;(basePromInfo[i] || []).map((data, index) =>
  1797. basePromData.push(
  1798. <TouchableOpacity
  1799. key={index + data.name ? data.name : ''}
  1800. style={{ flexDirection: 'row', width: width / 2 - 10 }}
  1801. onPress={() => {
  1802. this.state.baseIndex == i ? {} : this.setState({ baseIndex: i })
  1803. this.baseOnPromTouch(basePromInfo[i])
  1804. }}
  1805. >
  1806. <Icon
  1807. name={
  1808. this.state.baseIndex == i
  1809. ? 'icon-icon-danxuankuang-xuanzhong'
  1810. : 'icon-icon-danxuankuang-weixuanzhong'
  1811. }
  1812. size={26}
  1813. color={this.state.baseIndex == i ? '#E14C46' : '#CCC'}
  1814. />
  1815. <Text
  1816. style={{
  1817. marginLeft: 5,
  1818. fontSize: 13,
  1819. lineHeight: 17,
  1820. color: '#333',
  1821. alignSelf: 'center',
  1822. marginBottom: 1,
  1823. }}
  1824. >
  1825. {data.name || ''}
  1826. </Text>
  1827. </TouchableOpacity>
  1828. )
  1829. )
  1830. }
  1831. return (
  1832. <View
  1833. style={{
  1834. backgroundColor: '#FFF',
  1835. marginTop: 10,
  1836. paddingVertical: 7,
  1837. paddingHorizontal: 10,
  1838. flexDirection: 'row',
  1839. flexWrap: 'wrap',
  1840. }}
  1841. >
  1842. {basePromData}
  1843. </View>
  1844. )
  1845. }
  1846. checkCast(castRateData) {
  1847. let financeOrgIds = [],
  1848. flag = true,
  1849. productLineIds = Array.from(new Set(this.state.productLineIds)),
  1850. returnData = {}
  1851. productLineIds.forEach(lineId => {
  1852. castRateData.forEach(castitem => {
  1853. if (
  1854. castitem.productLineIds.length == 1 &&
  1855. !castitem.productLineIds[0]
  1856. ) {
  1857. flag = false
  1858. returnData = castitem
  1859. } else if (castitem.productLineIds.indexOf(lineId) != -1) {
  1860. financeOrgIds.push(castitem.financeOrgId)
  1861. }
  1862. })
  1863. })
  1864. if (financeOrgIds.length == 1 && flag) {
  1865. castRateData.forEach(item => {
  1866. if (item.financeOrgId == financeOrgIds[0]) {
  1867. returnData = item
  1868. }
  1869. })
  1870. }
  1871. return returnData
  1872. }
  1873. render() {
  1874. const {
  1875. addressDefault,
  1876. transportData,
  1877. transportDefault,
  1878. billwayData,
  1879. billwayDefault,
  1880. invoiceDefault,
  1881. castRateData,
  1882. promData,
  1883. creditData,
  1884. orderPayStatus,
  1885. } = this.props
  1886. const supplierDefault = this.props.navigation.state.params.SaleOrSupplier
  1887. let MaxOffset = 0,
  1888. castRateDataOnly = { costOffsetRatio: 0, supplyMaxOccupyMny: 0 }
  1889. if (
  1890. castRateData &&
  1891. castRateData.length > 0 &&
  1892. this.state.productLineIds &&
  1893. this.state.productLineIds.length > 0
  1894. ) {
  1895. let checkCastReturn = this.checkCast(castRateData)
  1896. if (Object.keys(checkCastReturn).length > 0) {
  1897. castRateDataOnly = checkCastReturn
  1898. }
  1899. if (
  1900. accMul(this.state.goodsAmount, castRateDataOnly.costOffsetRatio) >=
  1901. castRateDataOnly.supplyMaxOccupyMny
  1902. ) {
  1903. MaxOffset = castRateDataOnly.supplyMaxOccupyMny
  1904. } else {
  1905. MaxOffset = accMul(
  1906. this.state.goodsAmount,
  1907. castRateDataOnly.costOffsetRatio
  1908. )
  1909. }
  1910. if (MaxOffset >= this.state.totalAmountCopy) {
  1911. MaxOffset = this.state.totalAmountCopy
  1912. }
  1913. }
  1914. return (
  1915. <View
  1916. style={[
  1917. styles.container,
  1918. { backgroundColor: '#F7F7F7' },
  1919. // { backgroundColor: appTheme.backgroundColor }
  1920. ]}
  1921. >
  1922. <StatusBar
  1923. animated={true}
  1924. // barStyle={appTheme.barStyle}
  1925. barStyle={'dark-content'}
  1926. backgroundColor={'transparent'}
  1927. translucent={true}
  1928. />
  1929. {/* 头部 */}
  1930. {this.header()}
  1931. <ScrollView
  1932. style={{ flex: 1 }}
  1933. // scrollEventThrottle={200}
  1934. // onScroll={() => {
  1935. // // 判断圆形按钮滑动前后是否变化控制刷新
  1936. // if (this.cicleActive == this.state.cicleActive) {
  1937. // this.setState({ cicleActive: false });
  1938. // this.cicleActive = this.state.cicleActive;
  1939. // }
  1940. // }}
  1941. // onScrollEndDrag={() => this.setState({ cicleActive: true })}
  1942. // onMomentumScrollEnd={() => this.setState({ cicleActive: true })}
  1943. >
  1944. {/* 供应商显示 */}
  1945. {this.supplier(supplierDefault)}
  1946. {/*选项行*/}
  1947. <View>
  1948. <View style={{ backgroundColor: '#FFF', marginTop: 10 }}>
  1949. {this.viewRender([
  1950. {
  1951. viewName: '运输方式',
  1952. rightName:
  1953. (transportDefault && transportDefault.name) || '铁路运输',
  1954. iconName: 'icon-icon-xiala',
  1955. onPress: () => {
  1956. this.state.activeMethod == 0
  1957. ? this.setState({ activeMethod: 'nfjdsjf' })
  1958. : this.setState({ activeMethod: 0 })
  1959. },
  1960. dataArr: transportData || [],
  1961. },
  1962. // {
  1963. // viewName: '结算方式',
  1964. // rightName: (billwayDefault && billwayDefault.name) || '现金',
  1965. // iconName: 'icon-icon-xiala',
  1966. // onPress: () => {
  1967. // this.state.activeMethod == 1
  1968. // ? this.setState({ activeMethod: 'nfjdsjf' })
  1969. // : this.setState({ activeMethod: 1 })
  1970. // },
  1971. // dataArr: billwayData || [],
  1972. // },
  1973. // {
  1974. // viewName: '支付方式',
  1975. // rightName: this.state.payWayDef && this.state.payWayDef.name,
  1976. // iconName: 'icon-icon-xiala',
  1977. // onPress: () => {
  1978. // this.state.activeMethod == 2
  1979. // ? this.setState({ activeMethod: 'nfjdsjf' })
  1980. // : this.setState({ activeMethod: 2 })
  1981. // },
  1982. // dataArr: orderPayStatus || [],
  1983. // },
  1984. ])}
  1985. </View>
  1986. <View style={{ backgroundColor: '#FFF', marginTop: 10 }}>
  1987. {this.viewRender([
  1988. {
  1989. viewName: '发票',
  1990. rightName:
  1991. (invoiceDefault && invoiceDefault.invoiceTitle) || '发票',
  1992. iconName: 'icon-icon-jianjinzhishiqi',
  1993. onPress: () =>
  1994. this.props.dispatch(
  1995. NavigationActions.navigate({
  1996. routeName: 'SelectInvoice',
  1997. params: e => this.invoiceCallback(e),
  1998. })
  1999. ),
  2000. },
  2001. ])}
  2002. </View>
  2003. {/* <View style={{ backgroundColor: '#FFF', marginTop: 10 }}>
  2004. {this.viewRender(
  2005. [
  2006. {
  2007. viewName: '期望到货日期',
  2008. rightName: this.state.deliveryTime,
  2009. iconName: 'icon-icon-xiala',
  2010. onPress: () =>
  2011. Platform.OS == 'ios'
  2012. ? this.showTime._openModal()
  2013. : this.TimeAndroid(),
  2014. inputName: '备注',
  2015. inputDefault: this.state.remark || '备注订单内容',
  2016. inputValue: '',
  2017. },
  2018. ],
  2019. true
  2020. )}
  2021. </View> */}
  2022. </View>
  2023. {/* 选地址 */}
  2024. <TouchableOpacity
  2025. activeOpacity={1}
  2026. onPress={() =>
  2027. this.props.dispatch(
  2028. NavigationActions.navigate({
  2029. routeName: 'SelectAdress',
  2030. params: e => this.callback(e),
  2031. })
  2032. )
  2033. }
  2034. style={{
  2035. backgroundColor: '#FFF',
  2036. marginTop: 10,
  2037. flexDirection: 'row',
  2038. paddingTop: 10,
  2039. paddingBottom: 5,
  2040. }}
  2041. >
  2042. <View style={{ flex: 1, justifyContent: 'flex-end' }}>
  2043. <Icon
  2044. name="icon-icon-dizhi"
  2045. size={24}
  2046. color={'#333'}
  2047. style={{ alignSelf: 'center' }}
  2048. />
  2049. </View>
  2050. <View style={{ flex: 8, paddingBottom: 5 }}>
  2051. <View style={{ flexDirection: 'row' }}>
  2052. <Text style={{ fontSize: 15, lineHeight: 21, color: '#333' }}>
  2053. {addressDefault && addressDefault.receiver}
  2054. </Text>
  2055. <Text style={{ marginLeft: 3, alignSelf: 'center' }}>
  2056. {addressDefault && addressDefault.receiverPhone}
  2057. </Text>
  2058. </View>
  2059. <Text
  2060. style={{
  2061. marginTop: 4,
  2062. fontSize: 13,
  2063. lineHeight: 18,
  2064. color: '#333',
  2065. }}
  2066. >
  2067. {((addressDefault && addressDefault.receiverProvince) || '') +
  2068. ((addressDefault && addressDefault.receiverCity) || '') +
  2069. ((addressDefault && addressDefault.receiverDistrict) || '') +
  2070. ((addressDefault && addressDefault.receiverTown) || '') +
  2071. ((addressDefault && addressDefault.receiverAddress) || '')}
  2072. </Text>
  2073. </View>
  2074. <View
  2075. style={{
  2076. flex: 1,
  2077. justifyContent: 'center',
  2078. }}
  2079. >
  2080. <Icon
  2081. name="icon-icon-jianjinzhishiqi"
  2082. size={24}
  2083. color={'#ccc'}
  2084. style={{ alignSelf: 'center' }}
  2085. />
  2086. </View>
  2087. </TouchableOpacity>
  2088. {/* Image地址下边框 */}
  2089. <Image source={redblue} style={{ height: 2, width: width }} />
  2090. {/* 基于原单或基于商品数量选项 */}
  2091. {promData.mutualRelationShip
  2092. ? this.baseOnProm(promData.mutualRelationShip)
  2093. : null}
  2094. {/* 商品信息 */}
  2095. {this.state.Loading ? (
  2096. <View style={{ marginTop: 10 }}>
  2097. <ActivityIndicator />
  2098. </View>
  2099. ) : (
  2100. <FlatList
  2101. keyExtractor={item => item.goodsId}
  2102. data={this.state.EditPromData}
  2103. extraData={this.state}
  2104. renderItem={({ item, index }) => this.goodsInfo(item, index)}
  2105. />
  2106. )}
  2107. {/* 赠品明细 */}
  2108. {promData && promData.giftProms && promData.giftProms.length > 0 ? (
  2109. <View
  2110. style={{
  2111. backgroundColor: '#FFF',
  2112. paddingHorizontal: 10,
  2113. paddingTop: 10,
  2114. marginTop: 10,
  2115. }}
  2116. >
  2117. <TouchableOpacity
  2118. onPress={() => {
  2119. let NavigateGift =
  2120. JSON.parse(JSON.stringify(promData.giftProms)) || []
  2121. ;(NavigateGift || []).map(item => {
  2122. item.data = item.giftDtos
  2123. delete item.giftDtos
  2124. })
  2125. this.props.dispatch(
  2126. NavigationActions.navigate({
  2127. routeName: 'OrderGifts',
  2128. params: {
  2129. giftProms: NavigateGift,
  2130. giftCb: (e, ids) => this.giftCb(e, ids),
  2131. },
  2132. })
  2133. )
  2134. }}
  2135. style={{
  2136. paddingBottom: 6,
  2137. flexDirection: 'row',
  2138. justifyContent: 'space-between',
  2139. }}
  2140. >
  2141. <Text style={{ fontSize: 14, lineHeight: 20, color: '#333' }}>
  2142. 赠品明细
  2143. </Text>
  2144. <View style={{ flexDirection: 'row' }}>
  2145. <Text style={{ fontSize: 14, lineHeight: 20, color: '#666' }}>
  2146. 选择赠品
  2147. </Text>
  2148. <Icon
  2149. name="icon-icon-jianjinzhishiqi"
  2150. color="#666"
  2151. size={24}
  2152. style={{ alignSelf: 'center' }}
  2153. />
  2154. </View>
  2155. </TouchableOpacity>
  2156. {this.state.giftSelected.length > 0 ? (
  2157. <FlatList
  2158. keyExtractor={(item, index) => index}
  2159. data={this.state.giftSelected}
  2160. extraData={this.state}
  2161. style={{
  2162. paddingBottom: 10,
  2163. borderTopColor: '#EEE',
  2164. borderTopWidth: 1 / PixelRatio.get(),
  2165. }}
  2166. renderItem={({ item, index }) => (
  2167. <View
  2168. style={{
  2169. flexDirection: 'row',
  2170. justifyContent: 'space-between',
  2171. paddingTop: 10,
  2172. }}
  2173. >
  2174. <Text
  2175. numberOfLines={1}
  2176. style={{
  2177. flex: 1,
  2178. fontSize: 12,
  2179. lineHeight: 17,
  2180. color: '#333',
  2181. }}
  2182. >
  2183. {item.goodsDisplayName}
  2184. </Text>
  2185. <View style={{ flexDirection: 'row', marginLeft: 30 }}>
  2186. <Icon
  2187. name="icon-icon-guanbianniu"
  2188. size={20}
  2189. color="#666"
  2190. />
  2191. <Text
  2192. style={{
  2193. fontSize: 12,
  2194. lineHeight: 17,
  2195. color: '#333',
  2196. marginLeft: 5,
  2197. }}
  2198. >
  2199. {item.mainNum || 1}
  2200. </Text>
  2201. </View>
  2202. </View>
  2203. )}
  2204. />
  2205. ) : null}
  2206. </View>
  2207. ) : null}
  2208. {/* 总体积、数量 */}
  2209. <View style={{ marginTop: 10, padding: 10, backgroundColor: '#FFF' }}>
  2210. <View
  2211. style={{
  2212. flexDirection: 'row',
  2213. justifyContent: 'space-between',
  2214. }}
  2215. >
  2216. <Text style={styles.text666}>总重量</Text>
  2217. <Text style={styles.text666}>
  2218. {this.state.totalWeight}{"KG"}
  2219. {/* {this.state.weightUnit} */}
  2220. </Text>
  2221. </View>
  2222. {/* <View
  2223. style={{
  2224. flexDirection: 'row',
  2225. justifyContent: 'space-between',
  2226. }}
  2227. >
  2228. <Text style={styles.text666}>总体积</Text>
  2229. <Text style={styles.text666}>
  2230. {this.state.totoalVolume}
  2231. {this.state.volumeUnit}
  2232. </Text>
  2233. </View> */}
  2234. </View>
  2235. {/* 金额显示 */}
  2236. <View style={{ marginTop: 10, backgroundColor: '#FFF', padding: 10 }}>
  2237. <View
  2238. style={{
  2239. flexDirection: 'row',
  2240. justifyContent: 'space-between',
  2241. }}
  2242. >
  2243. <Text style={styles.text666}>商品金额:</Text>
  2244. <Text style={styles.text666red}>
  2245. {CURRENCY.currencySign}
  2246. {ScaleUtil(
  2247. this.state.goodsAmount,
  2248. CURRENCY.currencyAmountScale
  2249. )}
  2250. </Text>
  2251. </View>
  2252. <View
  2253. style={{
  2254. flexDirection: 'row',
  2255. justifyContent: 'space-between',
  2256. }}
  2257. >
  2258. <Text style={styles.text666}>促销金额:</Text>
  2259. <Text style={styles.text666red}>
  2260. {CURRENCY.currencySign}
  2261. {this.state.totalPromAmt}
  2262. </Text>
  2263. </View>
  2264. {/* <View
  2265. style={{
  2266. flexDirection: 'row',
  2267. justifyContent: 'space-between',
  2268. }}
  2269. >
  2270. <Text style={styles.text666}>费用冲抵:</Text>
  2271. <Input
  2272. style={{
  2273. borderWidth: 1,
  2274. borderColor: '#E6E6E6',
  2275. borderRadius: 2,
  2276. width: width / 2.5,
  2277. height: 24,
  2278. padding: 0,
  2279. alignItems: 'center',
  2280. }}
  2281. ref={AverageRef => (this.AverageRef = AverageRef)}
  2282. keyboardType={'numeric'}
  2283. isICon={false}
  2284. blurOnSubmit={true}
  2285. placeholder={''}
  2286. textInputBacg={'#FFF'}
  2287. placeholderTextColor={'#CCC'}
  2288. onchangeFn={e => this.AverageBooth(e, MaxOffset)}
  2289. maxNum={MaxOffset}
  2290. />
  2291. </View> */}
  2292. {/* <View
  2293. style={{
  2294. flexDirection: 'row',
  2295. justifyContent: 'flex-end',
  2296. marginTop: 5,
  2297. }}
  2298. >
  2299. <Text style={[styles.text999, { marginRight: 10 }]}>
  2300. (本次最高冲抵:<Text style={{ color: '#E14C46' }}>
  2301. {CURRENCY.currencySign}
  2302. {ScaleUtil(MaxOffset, CURRENCY.currencyAmountScale)}
  2303. </Text>
  2304. </Text>
  2305. <Text style={styles.text999}>
  2306. 费用总金额:
  2307. <Text style={{ color: '#E14C46' }}>
  2308. {CURRENCY.currencySign}
  2309. {ScaleUtil(
  2310. castRateDataOnly.supplyMaxOccupyMny || 0,
  2311. CURRENCY.currencyAmountScale
  2312. )}
  2313. </Text>)
  2314. </Text>
  2315. </View> */}
  2316. <View
  2317. style={{
  2318. flexDirection: 'row',
  2319. justifyContent: 'space-between',
  2320. marginTop: 20,
  2321. }}
  2322. >
  2323. {/* <TouchableOpacity
  2324. style={{ flexDirection: 'row' }}
  2325. onPress={() => {
  2326. this.credit._openModal(creditData)
  2327. this.setState({ creditShow: true })
  2328. }}
  2329. >
  2330. <Text style={[styles.text999, { alignSelf: 'center' }]}>
  2331. 信用查询
  2332. </Text>
  2333. <Image
  2334. source={orderCreditPng}
  2335. style={{
  2336. width: 14,
  2337. height: 14,
  2338. alignSelf: 'center',
  2339. marginLeft: 4,
  2340. }}
  2341. />
  2342. </TouchableOpacity> */}
  2343. <Text style={styles.text666}>
  2344. 订单总金额:<Text
  2345. style={{ fontSize: 18, lineHeight: 25, color: '#E14C46' }}
  2346. >
  2347. {CURRENCY.currencySign}{' '}
  2348. {ScaleUtil(
  2349. this.state.totalAmount,
  2350. CURRENCY.currencyAmountScale
  2351. )}
  2352. </Text>
  2353. </Text>
  2354. </View>
  2355. <View style={{ marginTop: 10, backgroundColor: '#FFF' }}>
  2356. <View style={{flexDirection: 'row'}}>
  2357. <Text>备注:</Text>
  2358. <TextInput
  2359. style={{
  2360. fontSize: 12,
  2361. color: '#333333',
  2362. padding: 0,
  2363. backgroundColor: '#FFF',
  2364. height: 25,
  2365. borderWidth: 1,
  2366. borderColor: '#DDDDDD',
  2367. width:'60%'
  2368. }}
  2369. // multiline
  2370. // numberOfLines={4}
  2371. value={this.state.remark}
  2372. onChangeText={text=>this.setState({remark:text})}
  2373. underlineColorAndroid="transparent"
  2374. />
  2375. </View>
  2376. </View>
  2377. </View>
  2378. <Modal
  2379. animationType="slide"
  2380. presentationStyle="formSheet"
  2381. transparent={true}
  2382. visible={this.state.showOptModal}
  2383. onRequestClose={() => {
  2384. this.setState({
  2385. showOptModal: false
  2386. })
  2387. }}
  2388. >
  2389. <View
  2390. style={{
  2391. backgroundColor:'#FFF',
  2392. top:'50%',
  2393. paddingBottom: 50,
  2394. width:'100%',
  2395. height:'50%',
  2396. alignItems : 'center',
  2397. elevation : 5,
  2398. }}>
  2399. {this.state.optLoading ? (
  2400. <View style={{marginTop:100}}>
  2401. <ActivityIndicator />
  2402. </View>
  2403. ) : <View>
  2404. <View style={{flexDirection:'row'}}>
  2405. <Text style={{ fontSize: 13, lineHeight: 18, color: '#333',width:'90%',marginTop:10 }}>选择颜色</Text>
  2406. <TouchableOpacity onPress={() =>{
  2407. this.setState({
  2408. showOptModal: false
  2409. })
  2410. }}>
  2411. <Image
  2412. source={deletePng}
  2413. style={{ width: 20, height: 20}}
  2414. />
  2415. </TouchableOpacity>
  2416. </View>
  2417. <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)}/>
  2418. </View>
  2419. }
  2420. </View>
  2421. </Modal>
  2422. <Modal
  2423. animationType="slide"
  2424. presentationStyle="formSheet"
  2425. transparent={true}
  2426. visible={this.state.modalVisible}
  2427. onRequestClose={() => {
  2428. console.log('close');
  2429. }}
  2430. >
  2431. <View
  2432. style={{
  2433. backgroundColor:'#f8f8f8',
  2434. marginTop:'50%',
  2435. marginLeft:'15%',
  2436. width:'70%',
  2437. height:'24%',
  2438. alignItems : 'center',
  2439. shadowColor : '#000',
  2440. shadowOffset: {width: 0,height: 2},
  2441. shadowOpacity : 0.25,
  2442. shadowRadius : 3.84,
  2443. elevation : 5,
  2444. //borderRadius : 20
  2445. }}>
  2446. <Text style={{marginTop:10}}>请输入商品数量</Text>
  2447. <TextInput
  2448. style={{width:'50%'}}
  2449. onChangeText={text => this.setState({num:text})}
  2450. value={this.state.num}
  2451. />
  2452. <View style={{width:"100%",flexDirection:'row',position:'absolute',bottom:0}}>
  2453. <TouchableOpacity style={{backgroundColor : '#E70013',width:'50%',alignItems:'center',fontSize:20,padding:5}}
  2454. onPress= {() => this.onModalOk()}
  2455. >
  2456. <Text>确定</Text>
  2457. </TouchableOpacity>
  2458. <TouchableOpacity style={{backgroundColor : '#fff',width:'50%',alignItems:'center',fontSize:20,padding:5}}
  2459. onPress= {() => this.setState({modalVisible:false})}
  2460. >
  2461. <Text>取消</Text>
  2462. </TouchableOpacity>
  2463. </View>
  2464. </View>
  2465. </Modal>
  2466. </ScrollView>
  2467. {/* 信用弹窗 */}
  2468. <OrderCredit
  2469. ref={credit => (this.credit = credit)}
  2470. cb={() => this.setState({ creditShow: false })}
  2471. />
  2472. <OrderOptional
  2473. {...this.props}
  2474. ref={optional => (this.optional = optional)}
  2475. onPressBom={() => {
  2476. this.addBoomToData()
  2477. }}
  2478. // 选配回调处理(将选择的选配结果返回 加到商品行上)
  2479. optCb={data => {
  2480. this.state.EditPromData.forEach(item => {
  2481. let allOptIds = '',
  2482. allOptVals = ''
  2483. if (item.reqOrderItemBoms && item.reqOrderItemBoms.length > 0) {
  2484. item.reqOrderItemBoms.forEach(itemSec => {
  2485. data.forEach(itemTh => {
  2486. if (itemSec.childGoodsId == itemTh.goodsId) {
  2487. itemSec.baseGoodsOptId = itemTh.optIds
  2488. itemSec.baseGoodsOptValue = itemTh.optVals
  2489. if (allOptIds && allOptIds.length > 0) {
  2490. allOptIds = allOptIds.concat(
  2491. ',' + itemSec.baseGoodsOptId
  2492. )
  2493. allOptVals = allOptVals.concat(
  2494. ',' + itemSec.baseGoodsOptValue
  2495. )
  2496. } else {
  2497. allOptIds = itemSec.baseGoodsOptId
  2498. allOptVals = itemSec.baseGoodsOptValue
  2499. }
  2500. }
  2501. })
  2502. })
  2503. } else {
  2504. data.forEach(dataFt => {
  2505. if (dataFt.goodsId == item.goodsId) {
  2506. allOptIds = dataFt.optIds
  2507. allOptVals = dataFt.optVals
  2508. }
  2509. })
  2510. }
  2511. item.baseGoodsOptId = allOptIds
  2512. item.baseGoodsOptValue = allOptVals
  2513. })
  2514. this.addBoomToData()
  2515. this.setState({ EditPromData: this.state.EditPromData })
  2516. }}
  2517. />
  2518. {/* 时间弹窗 */}
  2519. <SelectTime
  2520. ref={showTime => (this.showTime = showTime)}
  2521. cb={date => {
  2522. this.setState({
  2523. deliveryTime: moment(date).format('YYYY-MM-DD'),
  2524. })
  2525. }}
  2526. />
  2527. {/* 底部 */}
  2528. <View
  2529. style={{
  2530. height: 45 + HEADERSTYLE.paddingBottom,
  2531. paddingBottom: HEADERSTYLE.paddingBottom,
  2532. backgroundColor: '#FFF',
  2533. flexDirection: 'row',
  2534. borderTopColor: '#EEE',
  2535. borderTopWidth: 1 / PixelRatio.get(),
  2536. }}
  2537. >
  2538. {this.bottomTouch()}
  2539. </View>
  2540. {/* 信用弹窗毛玻璃效果 */}
  2541. {/* {this.state.creditShow ? (
  2542. <View
  2543. style={{
  2544. position: "absolute",
  2545. width: width,
  2546. height: height,
  2547. backgroundColor: "#000",
  2548. opacity: 0.5
  2549. }}
  2550. />
  2551. ) : null} */}
  2552. </View>
  2553. )
  2554. }
  2555. }
  2556. const styles = StyleSheet.create({
  2557. container: {
  2558. flex: 1,
  2559. },
  2560. text333: {
  2561. fontSize: 14,
  2562. lineHeight: 20,
  2563. letterSpacing: 0.17,
  2564. color: '#333',
  2565. },
  2566. text666: {
  2567. fontSize: 13,
  2568. lineHeight: 18,
  2569. color: '#666',
  2570. },
  2571. text666red: {
  2572. fontSize: 14,
  2573. lineHeight: 25,
  2574. color: '#E14C46',
  2575. },
  2576. text999: {
  2577. fontSize: 12,
  2578. lineHeight: 17,
  2579. color: '#999',
  2580. },
  2581. bomTitle: {
  2582. fontSize: 13,
  2583. lineHeight: 18,
  2584. color: '#333',
  2585. },
  2586. bomText: {
  2587. fontSize: 12,
  2588. lineHeight: 17,
  2589. color: '#666',
  2590. },
  2591. modalStyle: {
  2592. }
  2593. })
  2594. export default OrderEdit