personal-protective-equipment-purchase-apply.ts 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  1. import { http } from '@/utils/http/axios';
  2. import type { QueryPageRequest, QueryPageResponse } from '@/types/basic-query';
  3. /**
  4. * 劳防用品采购申请 - 实体与接口
  5. * 基础路径: /api/ppePurchaseApply
  6. * 状态:0-待审核,1-审核通过,-1-审核不通过
  7. * 申请状态:1-待提交,2-待审批,3-已完成
  8. * 审批状态:1-待审批,2-已审批,3-退回
  9. */
  10. /** 采购申请主表(列表项 / 提交用) */
  11. export interface PpePurchaseApply {
  12. id?: number; // 采购申请主表唯一ID
  13. applyCode?: number; // 申请单号(业务唯一)
  14. applicantCode?: number; // 申请人编码
  15. applicantName?: string; // 申请人名称
  16. deptCode?: number; // 申请部门编码
  17. deptName?: string; // 申请部门名称
  18. status?: number; // 0-待审核/1-审核通过/-1审核不通过
  19. statusName?: string; // 申请状态:1-待提交,2-待审批,3-已完成
  20. nodeDescription?: string; // 当前节点名称
  21. isDeleted?: number;
  22. createdAt?: string;
  23. updatedAt?: string;
  24. templateId?: number; // 审核模板ID
  25. approvalStatus?: number; // 1-待审批,2-已审批,3-退回
  26. approvalOrder?: number; // 审批顺序
  27. rejectReason?: string; // 退回原因
  28. [key: string]: any;
  29. }
  30. /** 采购申请明细(劳防用品项)- 后端 PpePurchaseApplyDetail */
  31. export interface PpePurchaseApplyDetail {
  32. id?: number; // 采购申请物品唯一ID
  33. ppeApplyId?: number; // 关联的劳防采购申请单ID
  34. equipmentId?: number; // 劳防用品ID(关联ppe表的id)
  35. equipmentName?: string; // 劳防用品名称
  36. specSize?: string; // 规格/尺寸/鞋码
  37. applyNum?: number; // 需求数量
  38. model?: string; // 产品型号/品类类型
  39. unitPrice?: number; // 单价(元)
  40. pictureUrl?: string; // 样式照片URL
  41. remark?: string; // 申请备注
  42. isDeleted?: number;
  43. createdAt?: string;
  44. updatedAt?: string;
  45. [key: string]: any;
  46. }
  47. /** 兼容旧组件:明细行(表单用,可同时兼容后端字段名) */
  48. export interface PurchaseApplyItem extends PpePurchaseApplyDetail {
  49. ppeName?: string; // 同 equipmentName
  50. ppeId?: number; // 同 equipmentId
  51. stylePhoto?: string; // 同 pictureUrl 或附件 JSON
  52. sizeOrShoeSize?: string; // 同 specSize
  53. requiredQty?: number; // 同 applyNum
  54. specModelType?: string; // 同 model
  55. productNo?: string;
  56. [key: string]: any;
  57. }
  58. /** 兼容旧组件:列表与表单主表 */
  59. export type PersonalProtectiveEquipmentPurchaseApply = PpePurchaseApply & {
  60. applyNo?: string; // 展示用,可与 applyCode 互转
  61. itemList?: PurchaseApplyItem[];
  62. applicantDeptCode?: string;
  63. applicantDeptName?: string;
  64. currentNodeName?: string;
  65. };
  66. /** 分页查询请求 - 查询条件 QueryPersonalProtectiveEquipmentCommonPageReq */
  67. export interface QueryPurchaseApplyPageReq {
  68. /** 标题/搜索用品名称/申请人 */
  69. name?: string;
  70. /** 状态:0-待审核,1-审核通过,-1-审核不通过 */
  71. status?: number | string;
  72. /** 申请人部门CODE/申请部门编码 */
  73. applyDeptCode?: string;
  74. /** 申请人部门名称 */
  75. applyDeptName?: string;
  76. /** 审批状态:1-待审批,2-已审批,3-退回 */
  77. approvalStatus?: number | string;
  78. }
  79. /** 审批流程参数 */
  80. export interface ApprovalProcessParam {
  81. id: string;
  82. approvalDescription: string;
  83. templateId?: number;
  84. approvalInfoList: {
  85. approvalOrder: number;
  86. approverIdList: number[];
  87. }[];
  88. }
  89. /** 分页查询劳防用品采购申请列表 */
  90. export function queryPurchaseApplyList(
  91. query: QueryPageRequest<QueryPurchaseApplyPageReq>,
  92. ) {
  93. return http.request<QueryPageResponse<PpePurchaseApply>>({
  94. url: '/ppePurchaseApply/queryPpePurchaseApplyList',
  95. method: 'post',
  96. data: query,
  97. });
  98. }
  99. /** 分页查询劳防用品采购申请列表 */
  100. export function queryPurchaseApplyListAdmin(
  101. query: QueryPageRequest<QueryPurchaseApplyPageReq>,
  102. ) {
  103. return http.request<QueryPageResponse<PpePurchaseApply>>({
  104. url: '/ppePurchaseApply/queryPpePurchaseApplyListAdmin',
  105. method: 'post',
  106. data: query,
  107. });
  108. }
  109. /** 查询劳防用品详细内容(返回明细列表) */
  110. export function queryPurchaseApplyDetail(id: number) {
  111. return http.request<PpePurchaseApplyDetail[]>({
  112. url: `/ppePurchaseApply/queryPpePurchaseApplyDetail?id=${id}`,
  113. method: 'post',
  114. });
  115. }
  116. /** 删除劳防用品采购申请 */
  117. export function deletePurchaseApply(id: number) {
  118. return http.request({
  119. url: `/ppePurchaseApply/deletePpePurchaseApply?id=${id}`,
  120. method: 'delete',
  121. });
  122. }
  123. /** 审批信息项 */
  124. export interface ApprovalInfoItem {
  125. approvalOrder?: number;
  126. approverIdList?: number[];
  127. }
  128. /** 编辑/提交请求体 SavePpePurchaseApplyReq */
  129. export interface SavePpePurchaseApplyReq extends PpePurchaseApply {
  130. /** 保存或提交:0-保存 1-提交 */
  131. saveOrSubmit?: number;
  132. /** 审批描述 */
  133. approvalDescription?: string;
  134. /** 审批信息列表 */
  135. approvalInfoList?: ApprovalInfoItem[];
  136. /** 劳防采购申请列表详情 */
  137. ppePurchaseApplyDetails?: PpePurchaseApplyDetail[];
  138. /** 审核模板ID */
  139. templateId?: number;
  140. }
  141. /** 编辑劳防用品采购申请(保存/提交,带审批信息) */
  142. export function updatePurchaseApply(data: SavePpePurchaseApplyReq) {
  143. return http.request({
  144. url: '/ppePurchaseApply/updatePpePurchaseApplyDetail',
  145. method: 'put',
  146. data,
  147. });
  148. }
  149. /** 新增时也可走同一提交接口(无 id 或 saveOrSubmit=1) */
  150. export function savePurchaseApply(data: SavePpePurchaseApplyReq) {
  151. return http.request({
  152. url: '/ppePurchaseApply/updatePpePurchaseApplyDetail',
  153. method: 'put',
  154. data,
  155. });
  156. }
  157. /** 提交审批 - 通过/退回 SaveApprovalReq */
  158. export interface SaveApprovalReq {
  159. id: number;
  160. approvalOrder?: number;
  161. /** 审批状态: 1-待审批,2-已审批,3-退回 */
  162. approvalStatus: number;
  163. /** 退回原因 */
  164. returnReason?: string;
  165. templateId?: string;
  166. }
  167. /** 提交审批(通过/退回) */
  168. export function saveApproval(data: SaveApprovalReq) {
  169. return http.request({
  170. url: '/ppePurchaseApply/saveApproval',
  171. method: 'post',
  172. data,
  173. });
  174. }
  175. /** 审核参数(兼容旧调用:映射到 SaveApprovalReq) */
  176. export interface AuditPurchaseApplyParam {
  177. id: number;
  178. /** 1-审核通过,-1-审核不通过 → 映射 approvalStatus 2/3 */
  179. status: number;
  180. rejectReason?: string; // 同 returnReason
  181. approvalOrder?: number;
  182. templateId?: string;
  183. }
  184. /** 审核劳防用品采购申请(通过/退回)- 兼容旧接口,内部调 saveApproval */
  185. export function auditPurchaseApply(data: AuditPurchaseApplyParam) {
  186. return saveApproval({
  187. id: data.id,
  188. approvalStatus: data.status === 2 ? 2 : 3, // 1 通过→2 已审批,-1 不通过→3 退回
  189. returnReason: data.rejectReason,
  190. approvalOrder: data.approvalOrder,
  191. templateId: data.templateId,
  192. });
  193. }
  194. /** 提交审批流程 */
  195. export const submitApprovalProcess = (data: ApprovalProcessParam) => {
  196. return http.request({
  197. url: '/ppePurchaseApply/submit',
  198. method: 'post',
  199. data,
  200. });
  201. };
  202. /** 新增劳防用品采购申请(保存/提交,带审批信息) */
  203. export function saveThePurchaseRequest(data: SavePpePurchaseApplyReq) {
  204. return http.request({
  205. url: '/ppePurchaseApply/savePpePurchaseApplyList',
  206. method: 'post',
  207. data,
  208. });
  209. }
  210. /** 导出劳防用品采购申请管理 */
  211. export function exportSafetyEquipmentProcurementRequest (queryParams) {
  212. return http.request({
  213. url: '/ppePurchaseApply/exportPpePurchaseApplyList',
  214. method: 'post',
  215. responseType: 'blob',
  216. data: queryParams,
  217. }, {
  218. isTransformResponse: false,
  219. });
  220. }