boom.js 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464
  1. import { message } from 'antd';
  2. import request from '@/utils/request';
  3. import { async } from '@antv/x6/lib/registry/marker/async';
  4. import { stringify } from 'qs';
  5. /**
  6. project_id
  7. version_id 大版本id
  8. template_id
  9. template_node_id 查询某流程和某节点下最新版本的数据记录
  10. node_id 查询某审批流程和某审批节点下最新版本的数据记录
  11. */
  12. export async function queryRecord(params) {
  13. return request(`/purchase/record?${stringify(params)}`);
  14. }
  15. //删除excel中单个sheet页
  16. export async function queryDelSheetRecord(params) {
  17. const response = await request(`/purchase/bom/del-purchase-excel-sheet?${stringify(params)}`);
  18. if (response.code == 200) {
  19. // message.success('删除成功');
  20. }
  21. }
  22. // 查询全部工作流
  23. export async function queryFlowList(params) {
  24. return request(`/purchase/bom/flows?${stringify(params)}`);
  25. }
  26. // 根据节点id查询所有version
  27. export async function queryVserionByNode(params) {
  28. return request(`/purchase/bom/flow/node?${stringify(params)}`);
  29. }
  30. export async function commitSheet(params) {
  31. return request(`/purchase/record`, {
  32. method: 'POST',
  33. body: params,
  34. });
  35. }
  36. export async function approve(params) {
  37. return request(`/purchase/audit/status`, {
  38. method: 'POST',
  39. body: params,
  40. });
  41. }
  42. export async function queryAuthority(params) {
  43. const depId = localStorage.depId;
  44. return request(`/purchase/bom/user/excel/col?depId=${depId}`, {
  45. method: 'POST',
  46. body: params,
  47. });
  48. }
  49. export async function addBomComment(params) {
  50. return request(`/purchase/comment`, {
  51. method: 'POST',
  52. body: params,
  53. });
  54. }
  55. export async function queryBomComment(params) {
  56. return request(`/purchase/comment?${stringify(params)}`);
  57. }
  58. /**
  59. * 提交流转
  60. "id":3, 当前流转文档id,必填
  61. "project_id":46, 所属项目id
  62. "template_id":1, 所属模板id ,必填
  63. "template_node_id":34,所属节点id,必填
  64. "next_template_id":1,跳转的下级业务模板id,必填
  65. "next_template_node_id":2,跳转的下级业务节点id,必填
  66. "flow_id":1, 跳转的下级审核流程id , 如果不为空,则说明流转的是审核节点,下级业务节点为审核通过后进入的业务节点
  67. "node_id":1,跳转的下级审核节点id
  68. "desc":"流转描述"
  69. */
  70. export async function submitNextNode(params) {
  71. return request(`/purchase/next/node/submit`, {
  72. method: 'POST',
  73. body: params,
  74. });
  75. }
  76. export async function advanceSubmitNextNode(params) {
  77. return request(`/api/v1/purchase/next/node/advance-submit`, {
  78. method: 'POST',
  79. body: params,
  80. });
  81. }
  82. export async function queryDetail(params) {
  83. let response = await request(`/purchase/record?${stringify(params)}`);
  84. let sheet = response.data;
  85. sheet.data = JSON.parse(sheet.data || '[]');
  86. sheet.data.forEach(item => {
  87. item.config = JSON.parse(item.config || '{}');
  88. item.celldata = JSON.parse(item.cell_data || '[]');
  89. delete item.cell_data;
  90. });
  91. return sheet;
  92. }
  93. export async function queryHistoryDetail(params) {
  94. return request(`/purchase/record/history/detail?${stringify(params)}`);
  95. }
  96. export async function queryHistoryList(params) {
  97. return request(`/purchase/record/history?${stringify(params)}`);
  98. }
  99. export async function queryBoomFlowList(params) {
  100. return request(`/purchase/bom/flows?${stringify(params)}`);
  101. }
  102. //请求历史版本
  103. export async function queryVersionsTree(params) {
  104. return request(`/api/v1/purchase/record/version/tree?${stringify(params)}`);
  105. }
  106. //查询业务节点的审核记录
  107. export async function queryAuditExcel(params) {
  108. return request(`/api/v1/purchase/audit/excel?${stringify(params)}`);
  109. }
  110. //查询审批节点的审核记录
  111. export async function queryAuditRecord(params) {
  112. return request(`/api/v1/purchase/audit/record?${stringify(params)}`);
  113. }
  114. //查询表单数据接口
  115. export async function queryDingSchema(params) {
  116. return request(`/api/v1/purchase/bom/ding/schema?${stringify(params)}`);
  117. }
  118. export async function queryDingInstanceDetail(params) {
  119. let res = await request(`/api/v1/purchase/bom/ding/instance-detail`, {
  120. method: 'POST',
  121. body: params,
  122. });
  123. if (res.data.errcode != 0) {
  124. message.error(res.data.errmsg);
  125. throw new Error(res.data.errmsg);
  126. }
  127. return res;
  128. }
  129. export async function queryDingInstanceExecute(params) {
  130. let res = await request(`/api/v1/purchase/bom/ding/instance-execute`, {
  131. method: 'POST',
  132. body: params,
  133. });
  134. if (res.data.errcode != 0) {
  135. message.error('审批失败,请联系管理员。');
  136. throw new Error(res.data.errmsg);
  137. }
  138. return res;
  139. }
  140. export async function queryListParentByUser(params) {
  141. return request(`/api/v1/purchase/bom/ding/department/list-parent-by-user`, {
  142. method: 'POST',
  143. body: params,
  144. });
  145. }
  146. /**
  147. * 查看项目流程列表
  148. * project_id
  149. */
  150. export async function queryProjectRecord(params) {
  151. return request(`/purchase/bom/project/record?${stringify(params)}`);
  152. }
  153. /** 查看版本列表
  154. * project_id
  155. template_id 流程id
  156. template_node_id 流程节点id
  157. */
  158. export async function queryVersionsList(params) {
  159. return request(`/purchase/record/versions?${stringify(params)}`);
  160. }
  161. export async function queryBoomFlowDetail(params) {
  162. let { data } = await request(`/purchase/bom/flow/info?${stringify(params)}`);
  163. const groups = {
  164. top: {
  165. position: { name: 'top' },
  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. right: {
  179. position: { name: 'right' },
  180. attrs: {
  181. circle: {
  182. r: 4,
  183. magnet: true,
  184. stroke: '#31d0c6',
  185. strokeWidth: 2,
  186. fill: '#fff',
  187. style: { visibility: 'hidden' },
  188. },
  189. },
  190. zIndex: 10,
  191. },
  192. bottom: {
  193. position: { name: 'bottom' },
  194. attrs: {
  195. circle: {
  196. r: 4,
  197. magnet: true,
  198. stroke: '#31d0c6',
  199. strokeWidth: 2,
  200. fill: '#fff',
  201. style: { visibility: 'hidden' },
  202. },
  203. },
  204. zIndex: 10,
  205. },
  206. left: {
  207. position: { name: 'left' },
  208. attrs: {
  209. circle: {
  210. r: 4,
  211. magnet: true,
  212. stroke: '#31d0c6',
  213. strokeWidth: 2,
  214. fill: '#fff',
  215. style: { visibility: 'hidden' },
  216. },
  217. },
  218. zIndex: 10,
  219. },
  220. };
  221. const attrs = {
  222. line: {
  223. stroke: '#A2B1C3',
  224. targetMarker: { name: 'block', width: 12, height: 8 },
  225. strokeDasharray: '5 5',
  226. strokeWidth: 1,
  227. },
  228. };
  229. let nodes = data.Nodes.map(item => {
  230. let node = {
  231. ...item,
  232. id: item.node_id,
  233. renderKey: item.render_key,
  234. zIndex: item.z_index,
  235. isCustom: !!item.is_custom,
  236. ports: JSON.parse(item.ports || '{}'),
  237. };
  238. node.ports.groups = groups;
  239. node.parentKey = '1';
  240. return node;
  241. });
  242. let edges = data.Edges.map(item => {
  243. let edge = {
  244. id: item.edge_id,
  245. source: {
  246. cell: item.source_cell,
  247. port: item.source_port,
  248. },
  249. target: {
  250. cell: item.target_cell,
  251. port: item.target_port,
  252. },
  253. };
  254. try {
  255. edge.attrs = item.attr ? JSON.parse(item.attr) : attrs;
  256. } catch (error) {
  257. edge.attrs = attrs;
  258. }
  259. return edge;
  260. });
  261. return {
  262. ...data,
  263. nodes,
  264. edges,
  265. };
  266. }
  267. export async function updateNode(data) {
  268. return request(`/purchase/bom/flow/${data.templateId}/${data.nodeId}`, {
  269. method: 'PUT',
  270. body: data.body,
  271. });
  272. }
  273. export async function addBoomFlow(data) {
  274. return request(`/purchase/bom/flow/info`, {
  275. method: 'POST',
  276. body: data,
  277. });
  278. }
  279. export async function queryAuditList(params) {
  280. return request(`/purchase/flow/info?${stringify(params)}`);
  281. }
  282. export async function addAudit(data) {
  283. return request(`/purchase/flow/info`, {
  284. method: 'POST',
  285. body: data,
  286. });
  287. }
  288. export async function addFlow(data) {
  289. return request(`/purchase/bom/flow/info`, {
  290. method: 'POST',
  291. body: data,
  292. });
  293. }
  294. /**
  295. * [
  296. {
  297. "flow_id": 23,
  298. "node": "主管",
  299. "desc": "desc",
  300. "auditor": 2,
  301. "seq": 1,
  302. "seq_relate": 0
  303. }
  304. ]
  305. */
  306. export async function addAuditNode(data) {
  307. return request(`/purchase/flow/info/${data.flowId}`, {
  308. method: 'POST',
  309. body: data.nodes,
  310. });
  311. }
  312. export async function queryOSSData() {
  313. return request(`/config/chart-template-img?destDir=public/bom`);
  314. }
  315. export async function queryRecordSheet(data) {
  316. return request(`/purchase/record/sheet?${stringify(data)}`, {
  317. method: 'POST',
  318. body: data,
  319. });
  320. }
  321. export async function queryDingTemplateList() {
  322. return request(`/purchase/bom/ding/template/list`);
  323. }
  324. export async function queryDDdepList(data) {
  325. let res = await request(`/api/v1/purchase/bom/ding/department-list`, {
  326. method: 'POST',
  327. body: data,
  328. });
  329. return res.data.result;
  330. }
  331. export async function queryDDProcessesForecast(data) {
  332. let res = await request(`/api/v1/purchase/bom/ding/processes-forecast`, {
  333. method: 'POST',
  334. body: data,
  335. });
  336. if (res.data.message) {
  337. // message.error(res.data.message);
  338. throw new Error(res.data.message);
  339. }
  340. return res.data.result;
  341. }
  342. export async function uploadFile(data) {
  343. let res = await request(`/api/v1/purchase/bom/ding/upload-file`, {
  344. method: 'POST',
  345. body: data,
  346. headers: {
  347. ContentType: 'application/x-www-form-urlencoded',
  348. },
  349. });
  350. if (!res.data.dentry) {
  351. message.error(res.data.errmsg);
  352. throw new Error(res.data.errmsg);
  353. }
  354. return res.data;
  355. }
  356. export async function bindDDCode(userId, code) {
  357. let res = await request(`/api/v1/purchase/bom/ding/set-ding-user-code?ucode=${userId}:${code}`, {
  358. method: 'GET',
  359. });
  360. return res.data;
  361. }
  362. export async function saveAuditFlowInfo(data) {
  363. return request(`/purchase/flow/info`, {
  364. method: 'POST',
  365. body: data,
  366. });
  367. }
  368. //获取部门结构
  369. export async function queryDepV2(params) {
  370. return request(`/api/v2/dep?${stringify(params)}`);
  371. }
  372. export async function queryProcessFlows(params) {
  373. let res = await request(`/purchase/process/get-flows?${stringify(params)}`, {
  374. method: 'GET',
  375. });
  376. return res.data;
  377. }
  378. export async function queryUserListByRoleID(params) {
  379. let res = await request(`/api/v1/purchase/process/get-role-user?${stringify(params)}`, {
  380. method: 'GET',
  381. });
  382. return res.data;
  383. }
  384. //新增工作流时调用接口 给项目绑定默认分类列表
  385. //purchase/bom/default-bind-classify?project_id=1
  386. export async function queryDefaultBindClassify(params) {
  387. let res = await request(`/purchase/bom/default-bind-classify?${stringify(params)}`, {
  388. method: 'GET',
  389. });
  390. return res.data;
  391. }
  392. //获取分类列表
  393. export async function queryClassify() {
  394. let res = await request(`/purchase/bom/get-classify`, {
  395. method: 'GET',
  396. });
  397. return res.data;
  398. }
  399. export async function queryBindClassify(params) {
  400. let res = await request(`/purchase/bom/get-bind-classify?${stringify(params)}`, {
  401. method: 'GET',
  402. });
  403. return res.data;
  404. }
  405. export async function queryAddBindClassify(data) {
  406. return request(`/purchase/bom/add-bind-classify`, {
  407. method: 'POST',
  408. body: data,
  409. });
  410. }
  411. export async function queryDelPurchaseExcel(params) {
  412. let res = await request(`/purchase/bom/del-purchase-excel?${stringify(params)}`, {
  413. method: 'GET',
  414. });
  415. return res;
  416. }
  417. //提交流转存储表单审批人历史记录
  418. export async function querySaveBomForm(data) {
  419. return request(`/purchase/bom/save-bom-form`, {
  420. method: 'POST',
  421. body: data,
  422. });
  423. }
  424. export async function queryGetBomForm(params) {
  425. let res = await request(`/purchase/bom/get-bom-form?${stringify(params)}`, {
  426. method: 'GET',
  427. });
  428. return res;
  429. }
  430. //章管家失败,重新申请用印
  431. export async function queryTrySeal(params) {
  432. let res = await request(`/purchase/bom/try-seal?${stringify(params)}`, {
  433. method: 'GET',
  434. });
  435. return res;
  436. }