index.js 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. debugger
  21. //累加净重收发
  22. let _goodsPrice = val.goodsPrice;
  23. let _freightUnitPrice = val.freightUnitPrice
  24. let _data = val.freightReceivingDispatchingCars
  25. for (let i = 0; i < _data.length; i++) {
  26. if (_data[i].reciveNetWeight == null) {
  27. _data[i].reciveNetWeight = 0
  28. }
  29. if (_data[i].dispatchNetWeight == null) {
  30. _data[i].dispatchNetWeight = 0
  31. }
  32. //应付货款
  33. // if(_data[i].reciveNetWeight!=0&&_data[i].dispatchNetWeight!=0){
  34. // if(_data[i].reciveNetWeight-_data[i].dispatchNetWeight>0){
  35. // _data[i].goodsIngPayable = _data[i].reciveNetWeight*_goodsPrice
  36. // }else{
  37. // _data[i].goodsIngPayable = _data[i].dispatchNetWeight*_goodsPrice
  38. // }
  39. // }else{
  40. // _data[i].goodsIngPayable = _data[i].reciveNetWeight*_goodsPrice
  41. // }
  42. // 运费
  43. // _data[i].freightIngPayable =
  44. if (_data[i].reciveNetWeight != 0 && _data[i].dispatchNetWeight != 0) {
  45. if (_data[i].reciveNetWeight - _data[i].dispatchNetWeight > 0) {
  46. _data[i].freightIngPayable = _data[i].reciveNetWeight * _freightUnitPrice - _data[i]
  47. .freightDeductionAmount
  48. } else {
  49. _data[i].freightIngPayable = _data[i].dispatchNetWeight * _freightUnitPrice - _data[i]
  50. .freightDeductionAmount
  51. }
  52. } else {
  53. _data[i].freightIngPayable = _data[i].reciveNetWeight * _freightUnitPrice - _data[i]
  54. .freightDeductionAmount
  55. }
  56. that.radTotal.receipt += parseInt(_data[i].reciveNetWeight)
  57. that.radTotal.delivery += parseInt(_data[i].dispatchNetWeight)
  58. }
  59. }