boom.js 12 KB

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