api.ts 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. import request from '@/utils/common/request'
  2. import consts from '@/utils/consts'
  3. /**
  4. * 标段升降、上下移、增删
  5. * @param type - 操作类型
  6. * @param payload - 载荷
  7. */
  8. export async function apiResfulContractTree(type: string, payload: object) {
  9. let url: string = '', method: string = ''
  10. switch (type) {
  11. case 'serial':
  12. url = '/api/contract/section/serial'
  13. method = 'post'
  14. break
  15. case 'depth':
  16. url = '/api/contract/section/depth'
  17. method = 'post'
  18. break
  19. case 'add':
  20. url = '/api/contract/section/add'
  21. method = 'post'
  22. break
  23. case 'del':
  24. url = '/api/contract/section'
  25. method = 'del'
  26. break
  27. default:
  28. break
  29. }
  30. const { data } = await request[method](url, { ...payload, treeType: consts.CONTRACT_TREE.PAID })
  31. return data
  32. }
  33. /**
  34. * 获取单个合同详情和项目节详情
  35. * @param id - 项目节id
  36. * @param bidsectionId - 标段id
  37. */
  38. export async function apiGetExpenditure(id: string, bidsectionId: string) {
  39. const { data } = await request.get('/api/contract/expenditure', { id, bidsectionId })
  40. return data
  41. }
  42. /**
  43. * 修改合同节序号
  44. * @param id 项目节id
  45. * @param bidsectionId 标段id
  46. * @param serial 序号
  47. */
  48. export async function apiUpdateSerial(id: string, bidsectionId: string, serial: string) {
  49. const { data } = await request.post('/api/contract/section/serial/update', { id, bidsectionId, serial: parseInt(serial), treeType: consts.CONTRACT_TREE.PAID })
  50. return data
  51. }
  52. /**
  53. * 修改合同节名称
  54. * @param id 项目节id
  55. * @param bidsectionId 标段id
  56. * @param name 名称
  57. */
  58. export async function apiUpdateName(id: string, bidsectionId: string, name: string) {
  59. const { data } = await request.post('/api/contract/section/save', { id, bidsectionId, name, treeType: consts.CONTRACT_TREE.PAID })
  60. return data
  61. }
  62. /**
  63. * 合同增删改(包括添加已支付)
  64. * @param type - 操作类型
  65. * @param payload - 载荷
  66. */
  67. export async function apiResfulContract(type: string, payload: object) {
  68. let url: string = '', method: string = ''
  69. switch (type) {
  70. case 'create':
  71. url = '/api/contract/expenditure/create'
  72. method = 'post'
  73. break
  74. case 'update':
  75. url = '/api/contract/expenditure/update'
  76. method = 'post'
  77. break
  78. case 'close':
  79. url = '/api/contract/close'
  80. method = 'post'
  81. break
  82. case 'del':
  83. url = '/api/contract/expenditure'
  84. method = 'del'
  85. break
  86. case 'unlock':
  87. url = '/api/contract/unlock'
  88. method = 'post'
  89. break
  90. case 'paid':
  91. url = '/api/contract/paid/create'
  92. method = 'post'
  93. break
  94. default:
  95. break
  96. }
  97. const { data } = await request[method](url, { ...payload, treeType: consts.CONTRACT_TREE.PAID })
  98. return data
  99. }