progressShow.vue 8.6 KB

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