index.js 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. export function getDetail(id, that) {
  2. that.$api.doRequest('get', 'freightReceivingDispatching/getFreightReceivingDispatching', {
  3. "id": id
  4. }).then(res => {
  5. if (res.data.code == 200) {
  6. that.purchaseOrder = res.data.data
  7. makeData(res.data.data,that)
  8. return res.data.data
  9. }else{
  10. }
  11. }).catch(res => {
  12. // uni.showToast({
  13. // title: res.data.message,
  14. // icon: 'none',
  15. // duration: 2000
  16. // })
  17. })
  18. }
  19. export function makeData(val,that) {
  20. //累加净重收发
  21. let _goodsPrice = val.goodsPrice;
  22. let _freightUnitPrice = val.freightUnitPrice
  23. let _data = val.freightReceivingDispatchingCars
  24. for (let i = 0; i < _data.length; i++) {
  25. if (_data[i].reciveNetWeight == null) {
  26. _data[i].reciveNetWeight = 0
  27. }
  28. if (_data[i].dispatchNetWeight == null) {
  29. _data[i].dispatchNetWeight = 0
  30. }
  31. //应付货款
  32. // if(_data[i].reciveNetWeight!=0&&_data[i].dispatchNetWeight!=0){
  33. // if(_data[i].reciveNetWeight-_data[i].dispatchNetWeight>0){
  34. // _data[i].goodsIngPayable = _data[i].reciveNetWeight*_goodsPrice
  35. // }else{
  36. // _data[i].goodsIngPayable = _data[i].dispatchNetWeight*_goodsPrice
  37. // }
  38. // }else{
  39. // _data[i].goodsIngPayable = _data[i].reciveNetWeight*_goodsPrice
  40. // }
  41. // 运费
  42. // _data[i].freightIngPayable =
  43. if (_data[i].reciveNetWeight != 0 && _data[i].dispatchNetWeight != 0) {
  44. if (_data[i].reciveNetWeight - _data[i].dispatchNetWeight > 0) {
  45. _data[i].freightIngPayable = _data[i].reciveNetWeight * _freightUnitPrice - _data[i]
  46. .freightDeductionAmount
  47. } else {
  48. _data[i].freightIngPayable = _data[i].dispatchNetWeight * _freightUnitPrice - _data[i]
  49. .freightDeductionAmount
  50. }
  51. } else {
  52. _data[i].freightIngPayable = _data[i].reciveNetWeight * _freightUnitPrice - _data[i]
  53. .freightDeductionAmount
  54. }
  55. that.radTotal.receipt += parseInt(_data[i].reciveNetWeight)
  56. that.radTotal.delivery += parseInt(_data[i].dispatchNetWeight)
  57. }
  58. }