import http from "@/utils/http";
import { message } from "antd";
import store, { AppDispatch } from "..";
import { storageStatusObj } from "./object1";

/**
 * 获取藏品登记列表信息
 */
export const getObject2List = (data: any) => {
  return async (dispatch: AppDispatch) => {
    // 获取列表数据
    const res: any = await http.post("cms/ledger/pageList", data);
    const list = res.data.records;
    list.forEach((v: any) => {
      v.storageStatusTxt = storageStatusObj[v.storageStatus];
    });
    const obj = {
      list,
      total: res.data.total,
    };
    dispatch({ type: "object2/getList", payload: obj });
  };
};


/**
 * 通过id获取藏品总账详情
 */
export const getObj2InfoInAPI = (id: number) => {
  return http.get(`cms/ledger/detail/${id}`);
};
