DocManagement.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550
  1. <template>
  2. <div class="container-fluid">
  3. <div class="form-inline">
  4. <div class="page-header">
  5. <h1>
  6. 工作流管理 <small>管理所有工作流</small>
  7. </h1>
  8. </div>
  9. <div class="form-inline">
  10. <div class="form-group">
  11. <label for="documentNo">文件编码</label>
  12. <input
  13. id="documentNo"
  14. v-model="documentNo"
  15. autocomplete="off"
  16. type="text"
  17. class="form-control"
  18. />
  19. </div>
  20. <div class="form-group">
  21. <label for="title">单据主题</label>
  22. <input
  23. id="title"
  24. v-model="title"
  25. autocomplete="off"
  26. type="text"
  27. class="form-control"
  28. />
  29. </div>
  30. <div class="form-group">
  31. <label for="content">审批摘要</label>
  32. <input
  33. id="content"
  34. v-model="content"
  35. autocomplete="off"
  36. type="text"
  37. class="form-control"
  38. />
  39. </div>
  40. <div class="form-group">
  41. <label for="status">单据状态</label>
  42. <select
  43. v-model="status"
  44. class="form-control"
  45. >
  46. <option value="Running">运行中</option>
  47. <option value="Suspended">已暂停</option>
  48. <option value="Finished">已完成</option>
  49. </select>
  50. </div>
  51. <div class="form-group">
  52. <label for="startAfter">开始时间</label>
  53. <input
  54. id="startAfter"
  55. v-model="startAfter"
  56. autocomplete="off"
  57. type="date"
  58. class="form-control"
  59. />
  60. </div>
  61. <div class="form-group">
  62. <label for="startBefore">~</label>
  63. <input
  64. id="startBefore"
  65. v-model="startBefore"
  66. autocomplete="off"
  67. type="date"
  68. class="form-control"
  69. />
  70. </div>
  71. <button
  72. class="btn btn-default"
  73. @click="requery"
  74. >
  75. 查询
  76. </button>
  77. </div>
  78. <table class="table table-bordered table-hover table-condensed">
  79. <thead>
  80. <tr>
  81. <th style="width: 60px;">
  82. 序号
  83. </th>
  84. <th style="width: 100px;">
  85. 文件编码
  86. </th>
  87. <th style="width: 100px;">
  88. 单据主题
  89. </th>
  90. <th>
  91. 审批摘要
  92. </th>
  93. <th style="width: 60px;">
  94. 状态
  95. </th>
  96. <th style="width: 100px;">
  97. 开始时间
  98. </th>
  99. <th style="width: 100px;">
  100. 结束时间
  101. </th>
  102. <th style="width: 100px;">
  103. 流程实例Id
  104. </th>
  105. <th style="width: 100px;">
  106. 操作
  107. </th>
  108. </tr>
  109. </thead>
  110. <tbody>
  111. <template v-for="(data, index) in datas" :key="data.processInstanceId">
  112. <tr>
  113. <td>
  114. {{ index + ((pagination.current_page - 1) * (pagination.per_page)) + 1 }}
  115. </td>
  116. <td>
  117. {{ data.documentNo }}
  118. </td>
  119. <td>
  120. {{ data.title }}
  121. </td>
  122. <td>
  123. <span
  124. v-if="data.content != null && data.content != 'null'"
  125. style="white-space: pre-line"
  126. >{{ data.content }}</span>
  127. </td>
  128. <td>
  129. {{ data.status === 'Running' ? '运行中' : (data.status === 'Suspended' ? '暂停' : (data.status === 'Finished' ? '已完成' : (''))) }}
  130. </td>
  131. <td>
  132. {{ data.startTime }}
  133. </td>
  134. <td>
  135. {{ data.endTime }}
  136. </td>
  137. <td>
  138. {{ data.processInstanceId }}
  139. </td>
  140. <td>
  141. <button
  142. v-if="data.status === 'Running'"
  143. class="td-button"
  144. @click="changeProcessInstance(data, 'suspend', null)"
  145. >
  146. 暂停
  147. </button>
  148. <button
  149. v-if="data.status === 'Suspended'"
  150. class="td-button"
  151. @click="changeProcessInstance(data, 'activate', null)"
  152. >
  153. 激活
  154. </button>
  155. <button
  156. v-if="data.status === 'Running'"
  157. class="td-button"
  158. @click="deleteProcessInstance(data, 'delete', null)"
  159. >
  160. 删除
  161. </button>
  162. <button
  163. class="td-button"
  164. @click="listTaskInfo(data)"
  165. >
  166. 查看任务
  167. </button>
  168. </td>
  169. </tr>
  170. <template v-if="data.taskDocInfos != null && data.taskDocInfos.length > 0">
  171. <tr
  172. :key="'tasks-title' + data.processInstanceId"
  173. class="info"
  174. >
  175. <td colspan="9">进行中的任务</td>
  176. </tr>
  177. <tr
  178. :key="'tasks' + data.processInstanceId"
  179. class="info"
  180. >
  181. <td
  182. colspan="9"
  183. style="padding:0px;"
  184. >
  185. <table class="table table-bordered table-hover table-condensed inner-table">
  186. <thead>
  187. <tr class="warning">
  188. <th style="width: 60px;">
  189. 序号
  190. </th>
  191. <th style="width: 200px;">
  192. 任务名称
  193. </th>
  194. <th style="width: 100px;">
  195. 审批人
  196. </th>
  197. <th style="width: 100px;">
  198. 发起日期
  199. </th>
  200. <th>
  201. 评论信息
  202. </th>
  203. </tr>
  204. </thead>
  205. <tbody>
  206. <template v-for="(taskDocInfo, index1) in data.taskDocInfos" :key="taskDocInfo.id">
  207. <tr
  208. class="warning"
  209. >
  210. <td>
  211. {{ index1 }}
  212. </td>
  213. <td>
  214. {{ taskDocInfo.name }}
  215. </td>
  216. <td>
  217. {{ taskDocInfo.assigneeName }}
  218. </td>
  219. <td>
  220. {{ taskDocInfo.createTime }}
  221. </td>
  222. <td>
  223. {{ taskDocInfo.comments }}
  224. </td>
  225. </tr>
  226. </template>
  227. </tbody>
  228. </table>
  229. </td>
  230. </tr>
  231. </template>
  232. <template v-if="data.historicTaskDocInfos != null && data.historicTaskDocInfos.length > 0">
  233. <tr
  234. :key="'historicTasks-title' + data.processInstanceId"
  235. class="success"
  236. >
  237. <td colspan="9">已完成的任务</td>
  238. </tr>
  239. <tr
  240. :key="'historicTasks' + data.processInstanceId"
  241. class="success"
  242. >
  243. <td
  244. colspan="9"
  245. style="padding:0px;"
  246. >
  247. <table class="table table-bordered table-hover table-condensed inner-table">
  248. <thead>
  249. <tr class="warning">
  250. <th style="width: 60px;">
  251. 序号
  252. </th>
  253. <th style="width: 200px;">
  254. 任务名称
  255. </th>
  256. <th style="width: 100px;">
  257. 审批人
  258. </th>
  259. <th style="width: 100px;">
  260. 发起日期
  261. </th>
  262. <th style="width: 100px;">
  263. 完成日期
  264. </th>
  265. <th>
  266. 评论信息
  267. </th>
  268. </tr>
  269. </thead>
  270. <tbody>
  271. <template v-for="(historicTaskDocInfo, index2) in data.historicTaskDocInfos" :key="historicTaskDocInfo.id">
  272. <tr
  273. class="warning"
  274. >
  275. <td>
  276. {{ index2 }}
  277. </td>
  278. <td>
  279. {{ historicTaskDocInfo.name }}
  280. </td>
  281. <td>
  282. {{ historicTaskDocInfo.assigneeName }}
  283. </td>
  284. <td>
  285. {{ historicTaskDocInfo.createTime }}
  286. </td>
  287. <td>
  288. {{ historicTaskDocInfo.endTime }}
  289. </td>
  290. <td>
  291. {{ historicTaskDocInfo.comments }}
  292. </td>
  293. </tr>
  294. </template>
  295. </tbody>
  296. </table>
  297. </td>
  298. </tr>
  299. </template>
  300. </template>
  301. </tbody>
  302. </table>
  303. </div>
  304. <VueBootstrapPagination
  305. :pagination="pagination"
  306. :callback="listProcessInstanceDoc"
  307. />
  308. </div>
  309. </template>
  310. <script>
  311. import Common from '../common/Common.js';
  312. export default {
  313. components: {
  314. },
  315. data: function () {
  316. return {
  317. 'documentNo': null,
  318. 'title': null,
  319. 'content': null,
  320. 'status': 'Running',
  321. 'startAfter': null,
  322. 'startBefore': null,
  323. 'datas': [],
  324. 'pagination': {
  325. total: 0,
  326. per_page: 20, // required
  327. current_page: 1, // required
  328. last_page: 0, // required
  329. },
  330. };
  331. },
  332. mounted: function () {
  333. this.listProcessInstanceDoc();
  334. },
  335. methods: {
  336. /**
  337. * 重新查询
  338. */
  339. requery: function () {
  340. this.pagination.total = 0;
  341. this.pagination.per_page = 20;
  342. this.pagination.current_page = 1;
  343. this.pagination.last_page = 0;
  344. this.listProcessInstanceDoc();
  345. },
  346. /**
  347. * 查询所有的单据流程实例
  348. */
  349. listProcessInstanceDoc: function () {
  350. let _self = this;
  351. let processInstanceDocRequest = {
  352. 'documentNo': this.documentNo,
  353. 'title': this.title,
  354. 'content': this.content,
  355. 'status': this.status,
  356. 'startAfter': this.startAfter,
  357. 'startBefore': this.startBefore,
  358. 'start': (this.pagination.current_page - 1) * this.pagination.per_page,
  359. 'length': this.pagination.per_page,
  360. };
  361. $.ajax({
  362. url: Common.getApiURL('DocManagmentResource/query'),
  363. type: 'POST',
  364. contentType: 'application/json',
  365. dataType: 'json',
  366. data: JSON.stringify(processInstanceDocRequest),
  367. beforeSend: function (request) {
  368. Common.addTokenToRequest(request);
  369. },
  370. success: function (data) {
  371. data.datas.forEach(item => {
  372. try {
  373. var content = JSON.parse(item.content);
  374. var parentForm = '';
  375. if (content != null && content.parentForm != null) {
  376. content.parentForm.forEach(item => {
  377. parentForm = parentForm + item.title + ':' + item.content + '\n';
  378. });
  379. item.content = parentForm;
  380. }
  381. } catch (error) {
  382. console.error(error);
  383. } finally{
  384. item.taskDocInfos = [];
  385. item.historicTaskDocInfos = [];
  386. }
  387. });
  388. _self.datas = data.datas;
  389. _self.pagination.total = data.total;
  390. _self.pagination.last_page = Math.ceil(data.total / _self.pagination.per_page);
  391. },
  392. error: function (XMLHttpRequest, textStatus, errorThrown) {
  393. Common.processException(XMLHttpRequest, textStatus, errorThrown);
  394. },
  395. });
  396. },
  397. /**
  398. * 查询流程实例的任务信息
  399. */
  400. listTaskInfo(processInstanceInfo) {
  401. $.ajax({
  402. url: Common.getApiURL('DocManagmentResource/listTasks'),
  403. type: 'GET',
  404. dataType: 'json',
  405. data: {
  406. processInstanceId: processInstanceInfo.processInstanceId,
  407. },
  408. beforeSend: function (request) {
  409. Common.addTokenToRequest(request);
  410. },
  411. success: function (datas) {
  412. processInstanceInfo.taskDocInfos = datas;
  413. },
  414. error: function (XMLHttpRequest, textStatus, errorThrown) {
  415. Common.processException(XMLHttpRequest, textStatus, errorThrown);
  416. },
  417. });
  418. $.ajax({
  419. url: Common.getApiURL('DocManagmentResource/listHistoricTasks'),
  420. type: 'GET',
  421. dataType: 'json',
  422. data: {
  423. processInstanceId: processInstanceInfo.processInstanceId,
  424. },
  425. beforeSend: function (request) {
  426. Common.addTokenToRequest(request);
  427. },
  428. success: function (datas) {
  429. processInstanceInfo.historicTaskDocInfos = datas;
  430. },
  431. error: function (XMLHttpRequest, textStatus, errorThrown) {
  432. Common.processException(XMLHttpRequest, textStatus, errorThrown);
  433. },
  434. });
  435. },
  436. /**
  437. * 删除流程实例
  438. */
  439. deleteProcessInstance(processInstanceInfo, changeType, reason) {
  440. let _self = this;
  441. BootstrapDialog.show({
  442. title: '确认',
  443. message: '删除流程实例是不可恢复的操作,您确认要删除流程实例吗?',
  444. buttons: [{
  445. label: '确认',
  446. action: function (dialogItself) {
  447. _self.changeProcessInstance(processInstanceInfo, changeType, reason);
  448. dialogItself.close();
  449. },
  450. },
  451. {
  452. label: '取消',
  453. action: function (dialogItself) {
  454. dialogItself.close();
  455. },
  456. }],
  457. });
  458. },
  459. /**
  460. * 修改流程实例的状态
  461. */
  462. changeProcessInstance(processInstanceInfo, changeType, reason) {
  463. let _self = this;
  464. $.ajax({
  465. url: Common.getApiURL('DocManagmentResource/changeProcessInstance'),
  466. type: 'GET',
  467. dataType: 'json',
  468. data: {
  469. processInstanceId: processInstanceInfo.processInstanceId,
  470. changeType: changeType,
  471. reason: reason,
  472. },
  473. beforeSend: function (request) {
  474. Common.addTokenToRequest(request);
  475. },
  476. success: function (datas) {
  477. _self.listProcessInstanceDoc();
  478. },
  479. error: function (XMLHttpRequest, textStatus, errorThrown) {
  480. Common.processException(XMLHttpRequest, textStatus, errorThrown);
  481. },
  482. });
  483. },
  484. },
  485. };
  486. </script>
  487. <style scoped>
  488. label {
  489. width: 80px;
  490. text-align: left;
  491. padding-left: 10px;
  492. }
  493. button {
  494. margin-bottom: 5px;
  495. }
  496. input,
  497. select {
  498. width: 200px !important;
  499. }
  500. .form-group {
  501. margin-bottom: 5px;
  502. }
  503. table tr {
  504. height: 40px;
  505. }
  506. .td-button {
  507. width: 100px;
  508. }
  509. .inner-table {
  510. margin-bottom: 0px;
  511. }
  512. </style>