export default {
  namespace: "replenishmentParameter",

  state: {},

  effects: {
    *getReplenishmentParameterData({ payload }, { call, put }) {
      // const response = yield call()
      const response = {
        content: [
          {
            goodName: {
              img: "",
              title: "21685常规异型反向布艺沙发(转角位)1件2件加包件（附件包含）"
            },
            goodCode: "QDY001-10511802260001",
            amountNum: 30,
            dayNum: 1,
            dayAverageNum: 10,
            safeDay: 10,
            safeNum: 100,
            rare: "台"
          },
          {
            goodName: {
              img: "",
              title: "21685常规异型反向布艺沙发(转角位)1件2件加包件（附件包含）"
            },
            goodCode: "QDY001-10511802260001",
            amountNum: 30,
            dayNum: 1,
            dayAverageNum: 10,
            safeDay: 10,
            safeNum: 100,
            rare: "台"
          },
          {
            goodName: {
              img: "",
              title: "21685常规异型反向布艺沙发(转角位)1件2件加包件（附件包含）"
            },
            goodCode: "QDY001-10511802260001",
            amountNum: 30,
            dayNum: 1,
            dayAverageNum: 10,
            safeDay: 10,
            safeNum: 100,
            rare: "台"
          }
        ],
        totalNumbers: 1,
        size: 10
      };
      const paginationData = {};
      if (payload.page == 0) paginationData.current = 1;
      paginationData.total = response.totalNumbers;
      paginationData.pageSize = response.size;
      yield put({
        type: "replenishmentParameterData",
        replenishmentParameterData: response.content,
        pagination: paginationData
      });
    },
    *saveReplenishmentParameterData({ payload }, { call }) {
      yield call("API", payload);
    },
    *getClassifyData({ payload }, { call, put }) {
      // const response = yield call(API, payload);
      const response = [
        {
          name: "维格生活馆",
          code: "01"
        },
        {
          name: "北欧生活馆",
          code: "02"
        },
        {
          name: "古诺生活馆",
          code: "03"
        },
        {
          name: "自在生活馆",
          code: "04"
        },
        {
          name: "万物生活馆",
          code: "05"
        },
        {
          name: "B8生活馆",
          code: "06"
        },
        {
          name: "艺树生活馆",
          code: "07"
        },
        {
          name: "饰品专区",
          code: "08"
        },
        {
          name: "皮革专区",
          code: "09"
        },
        {
          name: "皮草专区",
          code: "10"
        }
      ];
      yield put({
        type: "classifyData",
        classifyData: response
      });
    }
  },
  reducers: {
    replenishmentParameterData(state, payload) {
      return {
        ...state,
        replenishmentParameterData: payload.replenishmentParameterData,
        pagination: payload.pagination
      };
    },
    classifyData(state, payload) {
      return {
        ...state,
        classifyData: payload.classifyData
      };
    }
  }
};
