object1.ts 4.0 KB

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