123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172 |
- import { createAction, NavigationActions } from '../../utils'
- import * as authService from '../../services/auth'
- export default {
- namespace: 'search',
- state: {
- listDatas: [],
- GoodsList: [],
- Searchval: '',
- // GoodList状态
- GoodsState: true,
- // 分类列表List刷新标识
- GoodsFlag: false,
- // 分页用
- isRefreshing: false,
- totalPages: 2,
- // 0:隐藏footer 1:已加载完成,没有更多数据 2 :显示加载中
- showFoot: 0,
- },
- reducers: {
- commodityList(state, { payload }) {
- return { ...state, ...payload }
- },
- categoryData(state, { payload }) {
- return { ...state, ...payload }
- },
- },
- effects: {
- /**
- * info 1、所有商品查询
- * --------------------------------------
- * isNew 是否新品 - Boolean
- * productLineId 产品线Id - String
- * keyWord 产品编码名称 - String
- * goodsCategoryIds 商品分类IDs - String
- * organizationId 组织 - String
- *
- * ?
- * search_customerId //客户Id (必须)
- * search_customerRankCode=01 //客户档案关系(必须) 01-一级 02-二级
- * --------------------------------------
- * 根据上述条件筛选
- */
- *searchGoodsAll(action, { call, put }) {
- try {
- let foot = 0,
- search = {}
- if (action.payload.forUse !== 'slipOn') {
- yield put(
- createAction('commodityList')({
- isRefreshing: true,
- })
- )
- } else {
- yield put(
- createAction('commodityList')({
- showFoot: 2,
- })
- )
- }
- search = {
- ...action.payload.pageInfo,
- ...action.payload.searchInfo,
- search_EQ_isEnable: 1,
- }
- const listData = yield call(() =>
- authService.searchCommodityList(search)
- )
- if (listData && listData.data && listData.data.content) {
- if (action.payload.pageInfo.page >= listData.data.totalPages) {
- foot = 1
- }
- console.log("listData==============>",listData)
- yield put(
- createAction('commodityList')({
- listDatas: action.payload.actionData.concat(
- listData.data.content
- ),
- totalPages: listData.data.totalPages,
- isRefreshing: false,
- showFoot: foot,
- // Searchval: action.payload.Searchval
- })
- )
- if (
- action.payload.comeFrom !== 'CommodityShowbase' &&
- action.payload.comeFrom !== 'Filter'
- )
- yield put(
- NavigationActions.navigate({
- routeName: 'CommodityShowbase',
- })
- )
- }
- } catch (error) {
- yield put(
- createAction('commodityList')({
- isRefreshing: false,
- showFoot: 1,
- })
- )
- console.log(
- error,
- 'models/commodity/SearchResult-searchGoodsAll-listDatas(1、所有商品查询)'
- )
- }
- },
- // 2、根据商品分类查询商品
- *searchGoodsByCate(action, { call, put }) {
- try {
- yield put(createAction('categoryData')({ GoodsFlag: true }))
- const listData = yield call(() =>
- authService.searchCommodityList({
- ...action.payload.searchVal,
- search_EQ_isEnable: 1,
- })
- )
- if (listData && listData.data && listData.data.content) {
- yield put(
- createAction('categoryData')({
- GoodsList: listData.data.content,
- GoodsState: true,
- GoodsFlag: false,
- })
- )
- }
- } catch (error) {
- yield put(
- createAction('categoryData')({
- GoodsState: false,
- GoodsFlag: false,
- })
- )
- console.log(
- error,
- 'models/commodity/SearchResult-searchGoodsByCate-GoodsList(2、根据商品分类查询商品)'
- )
- }
- },
- // //商品列表
- // *getCommodityList(action, { call, put }) {
- // try {
- // console.log(action, 9991);
- // const listData = yield call(() =>
- // authService.getCommodityList(action.payload.Searchval)
- // );
- // console.log(listData, 888811);
- // if (listData) {
- // yield put(
- // createAction("commodityList")({
- // listDatas: listData.data,
- // Searchval: action.payload.Searchval
- // })
- // );
- // if (action.payload.comeFrom != "CommodityShowbase")
- // yield put(
- // NavigationActions.navigate({
- // routeName: "CommodityShowbase"
- // })
- // );
- // }
- // } catch (error) {
- // console.log(error,'-----error的完整信息'+'\n'+error. response.data.message,'-----相关错误信息');
- // }
- // }
- },
- }
|