123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288 |
- <template>
- <div class="app-container">
- <div class="main-area">
- <div class="show-header">
- <div class="tag-list">
- <div class="tag-item">
- <!-- <div class="circle"></div> -->
- <i class="el-icon-circle-check icon"></i>
- <span>已完成</span>
- </div>
- <div class="tag-item">
- <i class="el-icon-warning icon"></i>
- <span>触发异常</span>
- </div>
- <div class="tag-item">
- <i class="el-icon-warning-outline icon"></i>
- <span>新插入</span>
- </div>
- <div class="tag-item">
- <span class="current-node">当前节点</span>
- </div>
- </div>
- <div class="search-list">
- <div class="search-tab">
- <el-radio-group v-model="processType">
- <el-radio-button :label="1">进行</el-radio-button>
- <el-radio-button :label="2">完成</el-radio-button>
- </el-radio-group>
- </div>
- <div class="search-input">
- <el-input placeholder="请输入..." v-model="queryString">
- <el-button
- slot="append"
- @click="getList"
- icon="el-icon-search"
- ></el-button>
- </el-input>
- </div>
- </div>
- </div>
- <div class="show-body">
- <TaskList
- v-for="(item, index) of tableData"
- :key="index + 1"
- :num="index + 1"
- :cardData="item"
- ></TaskList>
- <pagination
- v-show="total > 0"
- :total="total"
- :page.sync="queryParams.pageNum"
- :limit.sync="queryParams.pageSize"
- @pagination="getList"
- />
- </div>
- </div>
- </div>
- </template>
- <script>
- import TaskList from "./components/taskList.vue";
- import { processList, getListLog } from "@/api/bpmprocess/run/executeProcess";
- import getNodeSequence from "@/utils/bpmn/getNodeSequence";
- import { xmlStr2XmlObj } from "@/utils/bpmn/xml";
- export default {
- name: "ProgressShow",
- props: [],
- components: { TaskList },
- data() {
- return {
- processType: 1,
- queryString: "",
- total: 0,
- queryParams: {
- pageNum: 1,
- pageSize: 10,
- },
- tableData: [], //列表数据
- };
- },
- computed: {},
- methods: {
- // 获取列表数据
- getList() {
- getListLog(this.queryParams).then((res) => {
- if (res.code == 200) {
- this.tableData = this.getTableData(
- res.rows.map((item) => item.resultMap)
- );
- console.log(this.tableData);
- this.total = res.total;
- } else {
- this.$message.error("网络异常,请稍后再试");
- }
- return;
- if (res.code == 200) {
- this.tableData = this.getTableData(
- res.rows.map((item) => item.resultMap)
- );
- this.total = res.total;
- } else {
- this.$message.error("网络异常,请稍后再试");
- }
- });
- },
- // 获取表格展示数据
- getTableData(dataList) {
- let res = [];
- res = dataList.map((item) => {
- let baseObj = {
- benTaskProcessKey: item.taskKey, //任务编号
- bepTaskName: item.taskName, //任务名称
- benCreateTime: item.nodeLogList[0].taskNodeType
- ? item.nodeLogList[0].createTime
- : "", //开始或结束时间 需要根据bepTaskProcessState状态 来判定
- currentNodeKey: item.taskNodeNextKey, //当前节点key
- cardList: [],
- doneNodeList: item.nodeLogList,
- };
- let xmlObj = xmlStr2XmlObj(item.taskProcessXmlContent);
- baseObj.cardList = getNodeSequence(xmlObj);
- return baseObj;
- });
- res = this.nodeHandler(res); //合并两个节点数组
- res = this.sortHandler(res); //排序
- // res = this.setNodeState(res);
- return res;
- },
- // 设置节点完成情况
- setNodeState(res) {
- res.forEach((re) => {
- let nowKey = re.currentNodeKey;
- let isDone = true;
- re.cardList.forEach((item) => {
- if (item.nodeId == nowKey) {
- isDone = false;
- item.isDone = isDone;
- item.isNow = true;
- } else {
- item.isDone = isDone;
- item.isNow = false;
- }
- });
- // 当最后一个节点就是当前节点时置为完成状态
- let lastNode = re.cardList[re.cardList.length - 1];
- if (re.currentNodeKey == lastNode.nodeId) {
- lastNode.isDone = true;
- lastNode.isNow = false;
- }
- });
- return res;
- },
- // 合并两个节点数组
- nodeHandler(processList) {
- let res = processList.map((item, index) => {
- console.log(
- JSON.parse(JSON.stringify(item.cardList)),
- JSON.parse(JSON.stringify(item.doneNodeList)),
- item.currentNodeKey
- );
- item.doneNodeList.forEach((node) => {
- Object.assign(node, {
- isDone: true,
- isNow: false,
- nodeId: node.taskNodeKey,
- nodeInfo: {
- localName: node.taskNodeType,
- id: "",
- name: node.taskNodeName,
- nodeDescription: "",
- industryType: "",
- normalScriptKey: "",
- normalScriptTriggerType: node.taskNodeExecuteType,
- executeUserType: "",
- executeUser: "",
- virtuallyRole: "",
- },
- });
- });
- let currentIndex = item.cardList.findIndex(
- (node) => node.nodeId == item.currentNodeKey
- );
- console.log(currentIndex, item.cardList.length);
- // while(currentIndex<item.cardList.length){}
- for (let i = currentIndex; i < item.cardList.length; i++) {
- if (i == currentIndex) {
- item.cardList[i].isNow = true;
- if (i == item.cardList.length - 1) {
- item.cardList[i].isDone = true;
- } else {
- item.cardList[i].isDone = false;
- }
- } else {
- item.cardList[i].isDone = false;
- item.cardList[i].isNow = false;
- }
- }
- if (currentIndex == item.cardList.length - 1) {
- item.cardList.splice(0, currentIndex + 1);
- } else {
- item.cardList.splice(0, currentIndex);
- }
- item.cardList.unshift(...item.doneNodeList);
- console.log(item.cardList);
- item.cardList.forEach((node, index) => {
- node.num = index + 1;
- });
- return item;
- });
- return res;
- },
- // 任务排序
- sortHandler(processList) {
- processList.sort((a, b) => {
- let time_a = new Date(a.doneNodeList[0].createTime)?.getTime();
- let time_b = new Date(b.doneNodeList[0].createTime)?.getTime();
- return time_b - time_a;
- });
- return processList;
- },
- },
- mounted() {
- this.getList();
- },
- activated() {
- this.getList();
- },
- };
- </script>
- <style scoped lang="scss">
- .app-container {
- padding: 15px 15px;
- box-sizing: border-box;
- .main-area {
- box-shadow: 0 1px 15px 1px rgb(69 65 78 / 8%);
- background-color: #fff;
- .show-header {
- border-bottom: 1px solid #ebedf2;
- display: flex;
- align-items: center;
- justify-content: space-between;
- padding: 0px 20px 0px 20px;
- height: 50px;
- .tag-list {
- display: flex;
- align-items: center;
- .tag-item {
- display: flex;
- align-items: center;
- margin-right: 15px;
- font-size: 16px;
- .circle {
- width: 15px;
- height: 15px;
- background-color: rgb(104, 221, 104);
- border-radius: 50%;
- margin-right: 5px;
- }
- .icon {
- margin-right: 5px;
- }
- .current-node {
- display: inline-block;
- border: 2px solid #34bfa3;
- padding: 2px 5px;
- margin: 2px 40px 2px 10px;
- }
- }
- }
- .search-list {
- display: flex;
- .search-tab {
- margin-right: 20px;
- }
- }
- }
- .show-body {
- padding: 25px;
- }
- }
- }
- </style>
|