boom.js 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304
  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. export async function queryDingInstanceDetail(params) {
  105. return request(`/api/v1/purchase/bom/ding/instance-detail?${stringify(params)}`);
  106. }
  107. /**
  108. * 查看项目流程列表
  109. * project_id
  110. */
  111. export async function queryProjectRecord(params) {
  112. return request(`/purchase/bom/project/record?${stringify(params)}`);
  113. }
  114. /** 查看版本列表
  115. * project_id
  116. template_id 流程id
  117. template_node_id 流程节点id
  118. */
  119. export async function queryVersionsList(params) {
  120. return request(`/purchase/record/versions?${stringify(params)}`);
  121. }
  122. export async function queryBoomFlowDetail(params) {
  123. let { data } = await request(`/purchase/bom/flow/info?${stringify(params)}`);
  124. const groups = {
  125. top: {
  126. position: { name: 'top' },
  127. attrs: {
  128. circle: {
  129. r: 4,
  130. magnet: true,
  131. stroke: '#31d0c6',
  132. strokeWidth: 2,
  133. fill: '#fff',
  134. style: { visibility: 'hidden' },
  135. },
  136. },
  137. zIndex: 10,
  138. },
  139. right: {
  140. position: { name: 'right' },
  141. attrs: {
  142. circle: {
  143. r: 4,
  144. magnet: true,
  145. stroke: '#31d0c6',
  146. strokeWidth: 2,
  147. fill: '#fff',
  148. style: { visibility: 'hidden' },
  149. },
  150. },
  151. zIndex: 10,
  152. },
  153. bottom: {
  154. position: { name: 'bottom' },
  155. attrs: {
  156. circle: {
  157. r: 4,
  158. magnet: true,
  159. stroke: '#31d0c6',
  160. strokeWidth: 2,
  161. fill: '#fff',
  162. style: { visibility: 'hidden' },
  163. },
  164. },
  165. zIndex: 10,
  166. },
  167. left: {
  168. position: { name: 'left' },
  169. attrs: {
  170. circle: {
  171. r: 4,
  172. magnet: true,
  173. stroke: '#31d0c6',
  174. strokeWidth: 2,
  175. fill: '#fff',
  176. style: { visibility: 'hidden' },
  177. },
  178. },
  179. zIndex: 10,
  180. },
  181. };
  182. const attrs = {
  183. line: {
  184. stroke: '#A2B1C3',
  185. targetMarker: { name: 'block', width: 12, height: 8 },
  186. strokeDasharray: '5 5',
  187. strokeWidth: 1,
  188. },
  189. };
  190. let nodes = data.Nodes.map(item => {
  191. let node = {
  192. ...item,
  193. id: item.node_id,
  194. renderKey: item.render_key,
  195. zIndex: item.z_index,
  196. isCustom: !!item.is_custom,
  197. ports: JSON.parse(item.ports || '{}'),
  198. };
  199. node.ports.groups = groups;
  200. node.parentKey = '1';
  201. return node;
  202. });
  203. let edges = data.Edges.map(item => {
  204. let edge = {
  205. id: item.edge_id,
  206. source: {
  207. cell: item.source_cell,
  208. port: item.source_port,
  209. },
  210. target: {
  211. cell: item.target_cell,
  212. port: item.target_port,
  213. },
  214. };
  215. try {
  216. edge.attrs = item.attr ? JSON.parse(item.attr) : attrs;
  217. } catch (error) {
  218. edge.attrs = attrs;
  219. }
  220. return edge;
  221. });
  222. return {
  223. ...data,
  224. nodes,
  225. edges,
  226. };
  227. }
  228. export async function updateNode(data) {
  229. return request(`/purchase/bom/flow/${data.templateId}/${data.nodeId}`, {
  230. method: 'PUT',
  231. body: data.body,
  232. });
  233. }
  234. export async function addBoomFlow(data) {
  235. return request(`/purchase/bom/flow/info`, {
  236. method: 'POST',
  237. body: data,
  238. });
  239. }
  240. export async function queryAuditList(params) {
  241. return request(`/purchase/flow/info?${stringify(params)}`);
  242. }
  243. export async function addAudit(data) {
  244. return request(`/purchase/flow/info`, {
  245. method: 'POST',
  246. body: data,
  247. });
  248. }
  249. export async function addFlow(data) {
  250. return request(`/purchase/bom/flow/info`, {
  251. method: 'POST',
  252. body: data,
  253. });
  254. }
  255. /**
  256. * [
  257. {
  258. "flow_id": 23,
  259. "node": "主管",
  260. "desc": "desc",
  261. "auditor": 2,
  262. "seq": 1,
  263. "seq_relate": 0
  264. }
  265. ]
  266. */
  267. export async function addAuditNode(data) {
  268. return request(`/purchase/flow/info/${data.flowId}`, {
  269. method: 'POST',
  270. body: data.nodes,
  271. });
  272. }
  273. export async function queryOSSData() {
  274. return request(`/config/chart-template-img?destDir=public/bom`);
  275. }
  276. export async function queryRecordSheet(data) {
  277. return request(`/purchase/record/sheet?${stringify(data)}`, {
  278. method: 'POST',
  279. body: data,
  280. });
  281. }
  282. export async function queryDingTemplateList() {
  283. return request(`/purchase/bom/ding/template/list`);
  284. }
  285. export async function queryDDdepList(data) {
  286. let res = await request(`/api/v1/purchase/bom/ding/department-list`, {
  287. method: 'POST',
  288. body: data,
  289. });
  290. return res.data.result;
  291. }