123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116 |
- import { createAction, NavigationActions } from '../../utils'
- import * as authService from '../../services/auth'
- export default {
- namespace: 'orderedit',
- state: {
- castRateData: {},
- promData: {},
- mutualRelationShip: [],
- creditData: [],
- },
- reducers: {
- CastRateReducer(state, { payload }) {
- return { ...state, ...payload }
- },
- PromReducer(state, { payload }) {
- return { ...state, ...payload }
- },
- CreditCheckReducer(state, { payload }) {
- return { ...state, ...payload }
- },
- },
- effects: {
- // 促销政策
- *getProm(action, { call, put }) {
- try {
- const supConfirm = {}
- if (
- action.payload.promInfo &&
- !action.payload.promInfo.isPrimaryChannel
- ) {
- const suppilerList = yield call(() =>
- authService.getsupplier({ customer: CUSTOMERINFO.id })
- )
- if (
- suppilerList &&
- suppilerList.data &&
- suppilerList.data.length > 0
- ) {
- suppilerList = suppilerList.data.filter(
- data => data.id == action.payload.promInfo.saleOrgId
- )
- if (suppilerList && suppilerList.length == 1) {
- supConfirm.isPrimaryChannel = suppilerList[0].isPrimaryChannel
- }
- }
- }
- // 把互斥关系存在内存里,当返回不为null,将互斥关系覆盖
- action.payload.promInfo.orderType = 'reqOrder';
- const promdata = yield call(() =>
- authService.promServer({ ...action.payload.promInfo, ...supConfirm })
- )
- if (
- promdata &&
- promdata.data &&
- Object.keys(promdata.data).length > 0 &&
- promdata.data.reqOrderItems.length > 0
- ) {
- yield put(
- createAction('PromReducer')({
- promData: promdata.data,
- })
- )
- }
- } catch (error) {
- console.log(error, '下单寻促销政策报错')
- }
- },
- // 检查信用
- *getCreditCheck(action, { call, put }) {
- try {
- // console.log(action);
- const creditCheck = yield call(() =>
- authService.castCheck(action.payload.searchInfo)
- )
- // console.log(creditCheck);
- if (
- creditCheck &&
- creditCheck.data &&
- creditCheck.data.creditData &&
- creditCheck.data.creditData.length > 0
- ) {
- yield put(
- createAction('CreditCheckReducer')({
- creditData: creditCheck.data.creditData,
- })
- )
- }
- } catch (error) {
- console.log(error, '下单检查信用报错')
- }
- },
- // 冲抵比率
- *getCastRate(action, { call, put }) {
- try {
- // console.log(action);
- const castdata = yield call(() =>
- authService.castRate(action.payload.castInfo)
- )
- if (castdata && castdata.data) {
- yield put(
- createAction('CastRateReducer')({
- castRateData: castdata.data,
- })
- )
- }
- } catch (error) {
- console.log(error, '下单获取冲抵比率及最大冲抵值报错')
- }
- },
- },
- }
|