boom.js 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301
  1. import request from '@/utils/request';
  2. import { async } from '@antv/x6/lib/registry/marker/async';
  3. import { stringify } from 'qs';
  4. /**
  5. project_id
  6. version_id 大版本id
  7. template_id
  8. template_node_id 查询某流程和某节点下最新版本的数据记录
  9. node_id 查询某审批流程和某审批节点下最新版本的数据记录
  10. */
  11. export async function queryRecord(params) {
  12. return request(`/purchase/record?${stringify(params)}`);
  13. }
  14. // 查询全部工作流
  15. export async function queryFlowList(params) {
  16. return request(`/purchase/bom/flows?${stringify(params)}`);
  17. }
  18. // 根据节点id查询所有version
  19. export async function queryVserionByNode(params) {
  20. return request(`/purchase/bom/flow/node?${stringify(params)}`);
  21. }
  22. export async function commitSheet(params) {
  23. return request(`/purchase/record`, {
  24. method: 'POST',
  25. body: params,
  26. });
  27. }
  28. export async function approve(params) {
  29. return request(`/purchase/audit/status`, {
  30. method: 'POST',
  31. body: params,
  32. });
  33. }
  34. export async function queryAuthority(params) {
  35. const depId = localStorage.depId;
  36. return request(`/purchase/bom/user/excel/col?depId=${depId}`, {
  37. method: 'POST',
  38. body: params,
  39. });
  40. }
  41. export async function addBomComment(params) {
  42. return request(`/purchase/comment`, {
  43. method: 'POST',
  44. body: params,
  45. });
  46. }
  47. export async function queryBomComment(params) {
  48. return request(`/purchase/comment?${stringify(params)}`);
  49. }
  50. /**
  51. * 提交流转
  52. "id":3, 当前流转文档id,必填
  53. "project_id":46, 所属项目id
  54. "template_id":1, 所属模板id ,必填
  55. "template_node_id":34,所属节点id,必填
  56. "next_template_id":1,跳转的下级业务模板id,必填
  57. "next_template_node_id":2,跳转的下级业务节点id,必填
  58. "flow_id":1, 跳转的下级审核流程id , 如果不为空,则说明流转的是审核节点,下级业务节点为审核通过后进入的业务节点
  59. "node_id":1,跳转的下级审核节点id
  60. "desc":"流转描述"
  61. */
  62. export async function submitNextNode(params) {
  63. return request(`/purchase/next/node/submit`, {
  64. method: 'POST',
  65. body: params,
  66. });
  67. }
  68. export async function queryDetail(params) {
  69. let response = await request(`/purchase/record?${stringify(params)}`);
  70. let sheet = response.data;
  71. sheet.data = JSON.parse(sheet.data || '[]');
  72. sheet.data.forEach(item => {
  73. item.config = JSON.parse(item.config || '{}');
  74. item.celldata = JSON.parse(item.cell_data || '[]');
  75. delete item.cell_data;
  76. });
  77. return sheet;
  78. }
  79. export async function queryHistoryDetail(params) {
  80. return request(`/purchase/record/history/detail?${stringify(params)}`);
  81. }
  82. export async function queryHistoryList(params) {
  83. return request(`/purchase/record/history?${stringify(params)}`);
  84. }
  85. export async function queryBoomFlowList(params) {
  86. return request(`/purchase/bom/flows?${stringify(params)}`);
  87. }
  88. //请求历史版本
  89. export async function queryVersionsTree(params) {
  90. return request(`/api/v1/purchase/record/version/tree?${stringify(params)}`);
  91. }
  92. //查询业务节点的审核记录
  93. export async function queryAuditExcel(params) {
  94. return request(`/api/v1/purchase/audit/excel?${stringify(params)}`);
  95. }
  96. //查询审批节点的审核记录
  97. export async function queryAuditRecord(params) {
  98. return request(`/api/v1/purchase/audit/record?${stringify(params)}`);
  99. }
  100. //查询表单数据接口
  101. export async function queryDingSchema(params) {
  102. return request(`/api/v1/purchase/bom/ding/schema?${stringify(params)}`);
  103. }
  104. /**
  105. * 查看项目流程列表
  106. * project_id
  107. */
  108. export async function queryProjectRecord(params) {
  109. return request(`/purchase/bom/project/record?${stringify(params)}`);
  110. }
  111. /** 查看版本列表
  112. * project_id
  113. template_id 流程id
  114. template_node_id 流程节点id
  115. */
  116. export async function queryVersionsList(params) {
  117. return request(`/purchase/record/versions?${stringify(params)}`);
  118. }
  119. export async function queryBoomFlowDetail(params) {
  120. let { data } = await request(`/purchase/bom/flow/info?${stringify(params)}`);
  121. const groups = {
  122. top: {
  123. position: { name: 'top' },
  124. attrs: {
  125. circle: {
  126. r: 4,
  127. magnet: true,
  128. stroke: '#31d0c6',
  129. strokeWidth: 2,
  130. fill: '#fff',
  131. style: { visibility: 'hidden' },
  132. },
  133. },
  134. zIndex: 10,
  135. },
  136. right: {
  137. position: { name: 'right' },
  138. attrs: {
  139. circle: {
  140. r: 4,
  141. magnet: true,
  142. stroke: '#31d0c6',
  143. strokeWidth: 2,
  144. fill: '#fff',
  145. style: { visibility: 'hidden' },
  146. },
  147. },
  148. zIndex: 10,
  149. },
  150. bottom: {
  151. position: { name: 'bottom' },
  152. attrs: {
  153. circle: {
  154. r: 4,
  155. magnet: true,
  156. stroke: '#31d0c6',
  157. strokeWidth: 2,
  158. fill: '#fff',
  159. style: { visibility: 'hidden' },
  160. },
  161. },
  162. zIndex: 10,
  163. },
  164. left: {
  165. position: { name: 'left' },
  166. attrs: {
  167. circle: {
  168. r: 4,
  169. magnet: true,
  170. stroke: '#31d0c6',
  171. strokeWidth: 2,
  172. fill: '#fff',
  173. style: { visibility: 'hidden' },
  174. },
  175. },
  176. zIndex: 10,
  177. },
  178. };
  179. const attrs = {
  180. line: {
  181. stroke: '#A2B1C3',
  182. targetMarker: { name: 'block', width: 12, height: 8 },
  183. strokeDasharray: '5 5',
  184. strokeWidth: 1,
  185. },
  186. };
  187. let nodes = data.Nodes.map(item => {
  188. let node = {
  189. ...item,
  190. id: item.node_id,
  191. renderKey: item.render_key,
  192. zIndex: item.z_index,
  193. isCustom: !!item.is_custom,
  194. ports: JSON.parse(item.ports || '{}'),
  195. };
  196. node.ports.groups = groups;
  197. node.parentKey = '1';
  198. return node;
  199. });
  200. let edges = data.Edges.map(item => {
  201. let edge = {
  202. id: item.edge_id,
  203. source: {
  204. cell: item.source_cell,
  205. port: item.source_port,
  206. },
  207. target: {
  208. cell: item.target_cell,
  209. port: item.target_port,
  210. },
  211. };
  212. try {
  213. edge.attrs = item.attr ? JSON.parse(item.attr) : attrs;
  214. } catch (error) {
  215. edge.attrs = attrs;
  216. }
  217. return edge;
  218. });
  219. return {
  220. ...data,
  221. nodes,
  222. edges,
  223. };
  224. }
  225. export async function updateNode(data) {
  226. return request(`/purchase/bom/flow/${data.templateId}/${data.nodeId}`, {
  227. method: 'PUT',
  228. body: data.body,
  229. });
  230. }
  231. export async function addBoomFlow(data) {
  232. return request(`/purchase/bom/flow/info`, {
  233. method: 'POST',
  234. body: data,
  235. });
  236. }
  237. export async function queryAuditList(params) {
  238. return request(`/purchase/flow/info?${stringify(params)}`);
  239. }
  240. export async function addAudit(data) {
  241. return request(`/purchase/flow/info`, {
  242. method: 'POST',
  243. body: data,
  244. });
  245. }
  246. export async function addFlow(data) {
  247. return request(`/purchase/bom/flow/info`, {
  248. method: 'POST',
  249. body: data,
  250. });
  251. }
  252. /**
  253. * [
  254. {
  255. "flow_id": 23,
  256. "node": "主管",
  257. "desc": "desc",
  258. "auditor": 2,
  259. "seq": 1,
  260. "seq_relate": 0
  261. }
  262. ]
  263. */
  264. export async function addAuditNode(data) {
  265. return request(`/purchase/flow/info/${data.flowId}`, {
  266. method: 'POST',
  267. body: data.nodes,
  268. });
  269. }
  270. export async function queryOSSData() {
  271. return request(`/config/chart-template-img?destDir=public/bom`);
  272. }
  273. export async function queryRecordSheet(data) {
  274. return request(`/purchase/record/sheet?${stringify(data)}`, {
  275. method: 'POST',
  276. body: data,
  277. });
  278. }
  279. export async function queryDingTemplateList() {
  280. return request(`/purchase/bom/ding/template/list`);
  281. }
  282. export async function queryDDdepList(data) {
  283. let res = await request(`/api/v1/purchase/bom/ding/department-list`, {
  284. method: 'POST',
  285. body: data,
  286. });
  287. return res.data.result
  288. }