OrderEdit.js 88 KB

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