OrderEdit.js 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. import { createAction, NavigationActions } from '../../utils'
  2. import * as authService from '../../services/auth'
  3. export default {
  4. namespace: 'orderedit',
  5. state: {
  6. castRateData: {},
  7. promData: {},
  8. mutualRelationShip: [],
  9. creditData: [],
  10. },
  11. reducers: {
  12. CastRateReducer(state, { payload }) {
  13. return { ...state, ...payload }
  14. },
  15. PromReducer(state, { payload }) {
  16. return { ...state, ...payload }
  17. },
  18. CreditCheckReducer(state, { payload }) {
  19. return { ...state, ...payload }
  20. },
  21. },
  22. effects: {
  23. // 促销政策
  24. *getProm(action, { call, put }) {
  25. try {
  26. const supConfirm = {}
  27. if (
  28. action.payload.promInfo &&
  29. !action.payload.promInfo.isPrimaryChannel
  30. ) {
  31. const suppilerList = yield call(() =>
  32. authService.getsupplier({ customer: CUSTOMERINFO.id })
  33. )
  34. if (
  35. suppilerList &&
  36. suppilerList.data &&
  37. suppilerList.data.length > 0
  38. ) {
  39. suppilerList = suppilerList.data.filter(
  40. data => data.id == action.payload.promInfo.saleOrgId
  41. )
  42. if (suppilerList && suppilerList.length == 1) {
  43. supConfirm.isPrimaryChannel = suppilerList[0].isPrimaryChannel
  44. }
  45. }
  46. }
  47. // 把互斥关系存在内存里,当返回不为null,将互斥关系覆盖
  48. action.payload.promInfo.orderType = 'reqOrder';
  49. const promdata = yield call(() =>
  50. authService.promServer({ ...action.payload.promInfo, ...supConfirm })
  51. )
  52. if (
  53. promdata &&
  54. promdata.data &&
  55. Object.keys(promdata.data).length > 0 &&
  56. promdata.data.reqOrderItems.length > 0
  57. ) {
  58. yield put(
  59. createAction('PromReducer')({
  60. promData: promdata.data,
  61. })
  62. )
  63. }
  64. } catch (error) {
  65. console.log(error, '下单寻促销政策报错')
  66. }
  67. },
  68. // 检查信用
  69. *getCreditCheck(action, { call, put }) {
  70. try {
  71. // console.log(action);
  72. const creditCheck = yield call(() =>
  73. authService.castCheck(action.payload.searchInfo)
  74. )
  75. // console.log(creditCheck);
  76. if (
  77. creditCheck &&
  78. creditCheck.data &&
  79. creditCheck.data.creditData &&
  80. creditCheck.data.creditData.length > 0
  81. ) {
  82. yield put(
  83. createAction('CreditCheckReducer')({
  84. creditData: creditCheck.data.creditData,
  85. })
  86. )
  87. }
  88. } catch (error) {
  89. console.log(error, '下单检查信用报错')
  90. }
  91. },
  92. // 冲抵比率
  93. *getCastRate(action, { call, put }) {
  94. try {
  95. // console.log(action);
  96. const castdata = yield call(() =>
  97. authService.castRate(action.payload.castInfo)
  98. )
  99. if (castdata && castdata.data) {
  100. yield put(
  101. createAction('CastRateReducer')({
  102. castRateData: castdata.data,
  103. })
  104. )
  105. }
  106. } catch (error) {
  107. console.log(error, '下单获取冲抵比率及最大冲抵值报错')
  108. }
  109. },
  110. },
  111. }