object1.ts 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. import { statusObj } from "@/utils/dataChange";
  2. import http from "@/utils/http";
  3. import { message } from "antd";
  4. import store, { AppDispatch } from "..";
  5. /**
  6. * 藏品登记页面点击新增
  7. */
  8. export const object1AddAPI = (data?: any) => {
  9. return http.post("cms/register/save", { ...data });
  10. };
  11. /**
  12. * 藏品登记页面上传封面图和附件
  13. */
  14. export const object1AddUpFileAPI = (data: any) => {
  15. return http.post("cms/register/goods/file/upload", data);
  16. };
  17. /**
  18. * 里面的一条藏品添加
  19. */
  20. export const goodsSonAddAPI = (data: any, id: any) => {
  21. return async (dispatch: AppDispatch) => {
  22. const res: any = await http.post("cms/register/goods/save", data);
  23. if (res.code === 0) {
  24. const oldData = store.getState().loginStore.goodsTableList;
  25. message.success("操作成功!");
  26. let newData;
  27. if (id) {
  28. // 是编辑 覆盖之前的数据
  29. newData = oldData.map((v: any) => {
  30. if (v.id === id) return res.data;
  31. else return v;
  32. });
  33. } else newData = [res.data, ...oldData]; // 是新增,在前面添加一条数据
  34. dispatch({ type: "login/setGoodsSonList", payload: newData });
  35. }
  36. };
  37. };
  38. /**
  39. * 获取藏品登记列表信息
  40. */
  41. export const getObject1List = (data: any) => {
  42. return async (dispatch: AppDispatch) => {
  43. // 获取列表数据
  44. const res: any = await http.post("cms/register/pageList", data);
  45. const list = res.data.records;
  46. list.forEach((v: any) => {
  47. v.statusTxt = statusObj[v.status];
  48. });
  49. const obj = {
  50. list,
  51. total: res.data.total,
  52. };
  53. dispatch({ type: "object1/getList", payload: obj });
  54. };
  55. };
  56. /**
  57. * 获取藏品登记列表顶部数字信息
  58. */
  59. export const getObject1ListNum = () => {
  60. return async (dispatch: AppDispatch) => {
  61. // 获取统计数据
  62. const res: any = await http.get("cms/register/countByStatus");
  63. const data = [
  64. { id: null, name: "全部", num: res.data.all ? res.data.all : 0 },
  65. { id: 0, name: "待办理", num: res.data[0] ? res.data[0] : 0 },
  66. { id: 1, name: "待审核", num: res.data[1] ? res.data[1] : 0 },
  67. { id: 2, name: "审核不通过", num: res.data[2] ? res.data[2] : 0 },
  68. { id: 3, name: "已完成", num: res.data[3] ? res.data[3] : 0 },
  69. ];
  70. dispatch({ type: "object1/getListNum", payload: data });
  71. };
  72. };
  73. /**
  74. * 删除外层表格数据
  75. */
  76. export const object1DelAPI = (id: number) => {
  77. return http.get(`cms/register/remove/${id}`);
  78. };
  79. /**
  80. * 通过id获取信息
  81. */
  82. export const object1infoOutAPI = (id: number) => {
  83. return http.get(`cms/register/detail/${id}`);
  84. };
  85. /**
  86. * 通过id获取表格信息
  87. */
  88. export const getObj1InfoTableAPI2 = (id: number) => {
  89. return http.get(`cms/register/goods/list/${id}`);
  90. };
  91. /**
  92. * 通过id获取表格信息
  93. */
  94. export const getObj1InfoTableAPI = (id: number) => {
  95. return async (dispatch: AppDispatch) => {
  96. // 获取统计数据
  97. const res: any = await http.get(`cms/register/goods/list/${id}`);
  98. dispatch({ type: "login/setGoodsSonList", payload: res.data });
  99. };
  100. };
  101. /**
  102. * 删除里面的表格藏品 s
  103. */
  104. export const delInTablesAPI = (ids: string) => {
  105. return http.get(`cms/register/goods/removes/${ids}`);
  106. };
  107. /**
  108. * 删除最里面的附件或者封面图 s
  109. */
  110. export const delInfileAPI = (ids: string) => {
  111. return http.get(`cms/register/goods/file/dels/${ids}`);
  112. };
  113. /**
  114. * 通过id获取里面的藏品详情
  115. */
  116. export const getInfoInAPI = (id: number) => {
  117. return http.get(`cms/register/goods/detail/${id}`);
  118. };
  119. /**
  120. * 审核藏品信息
  121. */
  122. export const auditObject1API = (data: any) => {
  123. return http.post("cms/register/audit", data);
  124. };