progressShow.vue 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288
  1. <template>
  2. <div class="app-container">
  3. <div class="main-area">
  4. <div class="show-header">
  5. <div class="tag-list">
  6. <div class="tag-item">
  7. <!-- <div class="circle"></div> -->
  8. <i class="el-icon-circle-check icon"></i>
  9. <span>已完成</span>
  10. </div>
  11. <div class="tag-item">
  12. <i class="el-icon-warning icon"></i>
  13. <span>触发异常</span>
  14. </div>
  15. <div class="tag-item">
  16. <i class="el-icon-warning-outline icon"></i>
  17. <span>新插入</span>
  18. </div>
  19. <div class="tag-item">
  20. <span class="current-node">当前节点</span>
  21. </div>
  22. </div>
  23. <div class="search-list">
  24. <div class="search-tab">
  25. <el-radio-group v-model="processType">
  26. <el-radio-button :label="1">进行</el-radio-button>
  27. <el-radio-button :label="2">完成</el-radio-button>
  28. </el-radio-group>
  29. </div>
  30. <div class="search-input">
  31. <el-input placeholder="请输入..." v-model="queryString">
  32. <el-button
  33. slot="append"
  34. @click="getList"
  35. icon="el-icon-search"
  36. ></el-button>
  37. </el-input>
  38. </div>
  39. </div>
  40. </div>
  41. <div class="show-body">
  42. <TaskList
  43. v-for="(item, index) of tableData"
  44. :key="index + 1"
  45. :num="index + 1"
  46. :cardData="item"
  47. ></TaskList>
  48. <pagination
  49. v-show="total > 0"
  50. :total="total"
  51. :page.sync="queryParams.pageNum"
  52. :limit.sync="queryParams.pageSize"
  53. @pagination="getList"
  54. />
  55. </div>
  56. </div>
  57. </div>
  58. </template>
  59. <script>
  60. import TaskList from "./components/taskList.vue";
  61. import { processList, getListLog } from "@/api/bpmprocess/run/executeProcess";
  62. import getNodeSequence from "@/utils/bpmn/getNodeSequence";
  63. import { xmlStr2XmlObj } from "@/utils/bpmn/xml";
  64. export default {
  65. name: "ProgressShow",
  66. props: [],
  67. components: { TaskList },
  68. data() {
  69. return {
  70. processType: 1,
  71. queryString: "",
  72. total: 0,
  73. queryParams: {
  74. pageNum: 1,
  75. pageSize: 10,
  76. },
  77. tableData: [], //列表数据
  78. };
  79. },
  80. computed: {},
  81. methods: {
  82. // 获取列表数据
  83. getList() {
  84. getListLog(this.queryParams).then((res) => {
  85. if (res.code == 200) {
  86. this.tableData = this.getTableData(
  87. res.rows.map((item) => item.resultMap)
  88. );
  89. console.log(this.tableData);
  90. this.total = res.total;
  91. } else {
  92. this.$message.error("网络异常,请稍后再试");
  93. }
  94. return;
  95. if (res.code == 200) {
  96. this.tableData = this.getTableData(
  97. res.rows.map((item) => item.resultMap)
  98. );
  99. this.total = res.total;
  100. } else {
  101. this.$message.error("网络异常,请稍后再试");
  102. }
  103. });
  104. },
  105. // 获取表格展示数据
  106. getTableData(dataList) {
  107. let res = [];
  108. res = dataList.map((item) => {
  109. let baseObj = {
  110. benTaskProcessKey: item.taskKey, //任务编号
  111. bepTaskName: item.taskName, //任务名称
  112. benCreateTime: item.nodeLogList[0].taskNodeType
  113. ? item.nodeLogList[0].createTime
  114. : "", //开始或结束时间 需要根据bepTaskProcessState状态 来判定
  115. currentNodeKey: item.taskNodeNextKey, //当前节点key
  116. cardList: [],
  117. doneNodeList: item.nodeLogList,
  118. };
  119. let xmlObj = xmlStr2XmlObj(item.taskProcessXmlContent);
  120. baseObj.cardList = getNodeSequence(xmlObj);
  121. return baseObj;
  122. });
  123. res = this.nodeHandler(res); //合并两个节点数组
  124. res = this.sortHandler(res); //排序
  125. // res = this.setNodeState(res);
  126. return res;
  127. },
  128. // 设置节点完成情况
  129. setNodeState(res) {
  130. res.forEach((re) => {
  131. let nowKey = re.currentNodeKey;
  132. let isDone = true;
  133. re.cardList.forEach((item) => {
  134. if (item.nodeId == nowKey) {
  135. isDone = false;
  136. item.isDone = isDone;
  137. item.isNow = true;
  138. } else {
  139. item.isDone = isDone;
  140. item.isNow = false;
  141. }
  142. });
  143. // 当最后一个节点就是当前节点时置为完成状态
  144. let lastNode = re.cardList[re.cardList.length - 1];
  145. if (re.currentNodeKey == lastNode.nodeId) {
  146. lastNode.isDone = true;
  147. lastNode.isNow = false;
  148. }
  149. });
  150. return res;
  151. },
  152. // 合并两个节点数组
  153. nodeHandler(processList) {
  154. let res = processList.map((item, index) => {
  155. console.log(
  156. JSON.parse(JSON.stringify(item.cardList)),
  157. JSON.parse(JSON.stringify(item.doneNodeList)),
  158. item.currentNodeKey
  159. );
  160. item.doneNodeList.forEach((node) => {
  161. Object.assign(node, {
  162. isDone: true,
  163. isNow: false,
  164. nodeId: node.taskNodeKey,
  165. nodeInfo: {
  166. localName: node.taskNodeType,
  167. id: "",
  168. name: node.taskNodeName,
  169. nodeDescription: "",
  170. industryType: "",
  171. normalScriptKey: "",
  172. normalScriptTriggerType: node.taskNodeExecuteType,
  173. executeUserType: "",
  174. executeUser: "",
  175. virtuallyRole: "",
  176. },
  177. });
  178. });
  179. let currentIndex = item.cardList.findIndex(
  180. (node) => node.nodeId == item.currentNodeKey
  181. );
  182. console.log(currentIndex, item.cardList.length);
  183. // while(currentIndex<item.cardList.length){}
  184. for (let i = currentIndex; i < item.cardList.length; i++) {
  185. if (i == currentIndex) {
  186. item.cardList[i].isNow = true;
  187. if (i == item.cardList.length - 1) {
  188. item.cardList[i].isDone = true;
  189. } else {
  190. item.cardList[i].isDone = false;
  191. }
  192. } else {
  193. item.cardList[i].isDone = false;
  194. item.cardList[i].isNow = false;
  195. }
  196. }
  197. if (currentIndex == item.cardList.length - 1) {
  198. item.cardList.splice(0, currentIndex + 1);
  199. } else {
  200. item.cardList.splice(0, currentIndex);
  201. }
  202. item.cardList.unshift(...item.doneNodeList);
  203. console.log(item.cardList);
  204. item.cardList.forEach((node, index) => {
  205. node.num = index + 1;
  206. });
  207. return item;
  208. });
  209. return res;
  210. },
  211. // 任务排序
  212. sortHandler(processList) {
  213. processList.sort((a, b) => {
  214. let time_a = new Date(a.doneNodeList[0].createTime)?.getTime();
  215. let time_b = new Date(b.doneNodeList[0].createTime)?.getTime();
  216. return time_b - time_a;
  217. });
  218. return processList;
  219. },
  220. },
  221. mounted() {
  222. this.getList();
  223. },
  224. activated() {
  225. this.getList();
  226. },
  227. };
  228. </script>
  229. <style scoped lang="scss">
  230. .app-container {
  231. padding: 15px 15px;
  232. box-sizing: border-box;
  233. .main-area {
  234. box-shadow: 0 1px 15px 1px rgb(69 65 78 / 8%);
  235. background-color: #fff;
  236. .show-header {
  237. border-bottom: 1px solid #ebedf2;
  238. display: flex;
  239. align-items: center;
  240. justify-content: space-between;
  241. padding: 0px 20px 0px 20px;
  242. height: 50px;
  243. .tag-list {
  244. display: flex;
  245. align-items: center;
  246. .tag-item {
  247. display: flex;
  248. align-items: center;
  249. margin-right: 15px;
  250. font-size: 16px;
  251. .circle {
  252. width: 15px;
  253. height: 15px;
  254. background-color: rgb(104, 221, 104);
  255. border-radius: 50%;
  256. margin-right: 5px;
  257. }
  258. .icon {
  259. margin-right: 5px;
  260. }
  261. .current-node {
  262. display: inline-block;
  263. border: 2px solid #34bfa3;
  264. padding: 2px 5px;
  265. margin: 2px 40px 2px 10px;
  266. }
  267. }
  268. }
  269. .search-list {
  270. display: flex;
  271. .search-tab {
  272. margin-right: 20px;
  273. }
  274. }
  275. }
  276. .show-body {
  277. padding: 25px;
  278. }
  279. }
  280. }
  281. </style>