index.vue 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" >
  4. <el-form-item label="流程图名称:">
  5. <el-input
  6. v-model.trim="queryParams.name"
  7. placeholder="请输入流程图名称"
  8. clearable
  9. size="small"
  10. style="width: 160px"
  11. @keyup.enter.native="handleQuery"
  12. />
  13. </el-form-item>
  14. <el-form-item class="right">
  15. <el-button plain size="mini" @click="resetQuery">重置</el-button>
  16. <el-button type="primary" size="mini" @click="handleQuery">搜索</el-button>
  17. </el-form-item>
  18. <br>
  19. <el-button
  20. type="primary"
  21. size="mini"
  22. @click="handleAdd"
  23. >新增</el-button>
  24. </el-form>
  25. <el-table v-loading="loading" :data="adminList" border style="margin-top:20px;">
  26. <el-table-column label="流程id" align="center" prop="id" show-overflow-tooltip />
  27. <el-table-column label="流程图名称" align="center" prop="name" show-overflow-tooltip />
  28. <el-table-column label="描述" align="center" prop="procdefDescribe" show-overflow-tooltip />
  29. <el-table-column label="运行状态" align="center" >
  30. <template slot-scope="scope">
  31. <el-switch
  32. v-model="scope.row.runStatus"
  33. @change="handleStatusChange(scope.row)"
  34. ></el-switch>
  35. </template>
  36. </el-table-column>
  37. <el-table-column label="流程图" align="center" prop="resourceName" show-overflow-tooltip >
  38. <template slot-scope="scope">
  39. <el-button
  40. size="mini"
  41. type="text"
  42. class="lans"
  43. @click="getBpmn(scope.row)"
  44. >查看</el-button>
  45. </template>
  46. </el-table-column>
  47. <el-table-column label="执行记录" align="center" prop="resourceName" show-overflow-tooltip >
  48. <template slot-scope="scope">
  49. <el-button
  50. size="mini"
  51. type="text"
  52. class="lans"
  53. @click="getRecord(scope.row)"
  54. >查看</el-button>
  55. </template>
  56. </el-table-column>
  57. <el-table-column label="创建时间" align="center" prop="createTime" show-overflow-tooltip />
  58. <el-table-column label="操作" align="center" width="400">
  59. <template slot-scope="scope">
  60. <el-button
  61. size="mini"
  62. type="text"
  63. class="lans"
  64. @click="zkReProcdefRun1(scope.row)"
  65. >执行一次</el-button>
  66. <el-button
  67. size="mini"
  68. type="text"
  69. class="lans"
  70. @click="handleUpdate(scope.row)"
  71. >编辑</el-button>
  72. <el-button
  73. size="mini"
  74. type="text"
  75. class="hongs"
  76. @click="handleDelete(scope.row)"
  77. >删除</el-button>
  78. </template>
  79. </el-table-column>
  80. </el-table>
  81. <!-- 查看bpmn对话框 -->
  82. <el-dialog :title="title" :visible.sync="open" width="800px" append-to-body :before-close="cancel" :close-on-click-modal="false">
  83. <div class="canvas" ref="canvas"></div>
  84. </el-dialog>
  85. <pagination
  86. v-show="total>0"
  87. :total="total"
  88. :page.sync="queryParams.current"
  89. :limit.sync="queryParams.size"
  90. @pagination="getList"
  91. />
  92. </div>
  93. </template>
  94. <script>
  95. // 引入相关的依赖
  96. import BpmnViewer from "bpmn-js/lib/Viewer";
  97. import { xmlStr } from "@/mock/xmlStrPreview2";
  98. import { getBpmnZkNodeList, getBpmnZkNodeTreeList, addBpmnZkNode, updataBpmnZkNode,
  99. getBpmnZkReNodeProcdefTreeList, getBpmnZkReNodeProcdefCheckedTreeList,
  100. getBpmnZkReProcdefList, addBpmnZkReProcdef, updataBpmnZkReProcdef, delBpmnZkReProcdef ,zkReProcdefRun,zkReProcdefStatus} from "@/api/business/Middleware/bpmn";
  101. import router from "../../../../router";
  102. export default {
  103. name: "",
  104. created() {},
  105. mounted() {
  106. },
  107. data() {
  108. return {
  109. // 遮罩层
  110. loading: false,
  111. // 导出遮罩层
  112. exportLoading: false,
  113. // 显示搜索条件
  114. showSearch: true,
  115. // 总条数
  116. total: 0,
  117. // 参数表格数据
  118. adminList: [],
  119. // 弹出层标题
  120. title: "查看流程图",
  121. // 是否显示弹出层
  122. open: false,
  123. // 查询参数
  124. queryParams: {
  125. current: 1,
  126. size: 10,
  127. name:undefined
  128. },
  129. // 表单参数
  130. form: {},
  131. bpmnViewer: null,
  132. container: null,
  133. canvas: null,
  134. xml:undefined,
  135. num:0
  136. };
  137. },
  138. created(){
  139. this.getList()
  140. },
  141. mounted:function (){
  142. },
  143. // 方法集合
  144. methods: {
  145. /** 修改按钮操作 */
  146. handleUpdate(row) {
  147. this.$router.push({path:'/Middleware/bpmn/customModeler',query:{name:row.name,id:row.id}})
  148. },
  149. /** 删除按钮操作 */
  150. handleDelete(row) {
  151. const ids = row.id
  152. this.$confirm('是否确认删除', "警告", {
  153. confirmButtonText: "确定",
  154. cancelButtonText: "取消",
  155. type: "warning"
  156. }).then(function() {
  157. return delBpmnZkReProcdef(ids);
  158. }).then(() => {
  159. this.getList();
  160. this.msgSuccess("删除成功");
  161. }).catch(() => {});
  162. },
  163. /** 新增按钮操作 */
  164. handleAdd() {
  165. this.$router.push('/Middleware/bpmn/customModeler')
  166. },
  167. /** 查询参数列表 */
  168. getList() {
  169. this.loading = false;
  170. getBpmnZkReProcdefList(this.queryParams).then(response => {
  171. this.adminList = response.data.records;
  172. this.total = response.data.total;
  173. this.loading = false;
  174. }
  175. );
  176. },
  177. /** 搜索按钮操作 */
  178. handleQuery() {
  179. this.queryParams.current = 1;
  180. this.getList();
  181. },
  182. /** 重置按钮操作 */
  183. resetQuery() {
  184. this.resetForm("queryForm");
  185. this.queryParams.name = undefined
  186. this.handleQuery();
  187. },
  188. // 流程图关闭
  189. cancel() {
  190. this.open = false
  191. },
  192. //流程图查看
  193. getBpmn(row){
  194. this.xml = row.resourceName
  195. if(this.xml){
  196. this.loading = false
  197. this.open = true
  198. setTimeout(()=>{
  199. if(this.num == 0){
  200. const canvas = this.$refs.canvas;
  201. this.bpmnViewer = new BpmnViewer({
  202. container: canvas
  203. });
  204. this.num ++
  205. }
  206. this.createNewDiagram(row.resourceName);
  207. })
  208. }else{
  209. this.msgError("流程图渲染数据不存在");
  210. }
  211. },
  212. async createNewDiagram(xml) {
  213. try {
  214. const result = await this.bpmnViewer.importXML(xml);
  215. const { warnings } = result;
  216. // 屏幕自适应
  217. const canvas = this.bpmnViewer.get("canvas");
  218. canvas.zoom("fit-viewport", true);
  219. } catch (err) {
  220. console.log(err.message, err.warnings);
  221. }
  222. },
  223. //跳转执行记录
  224. getRecord(row){
  225. router.push({path:'/Middleware/bpmn/executionRecord',query:{'procdefId':row.id}})
  226. },
  227. //立即执行
  228. zkReProcdefRun1(row){
  229. this.loading = true
  230. zkReProcdefRun({id:row.id,name:row.name}).then(response => {
  231. if(response.status == "SUCCESS"){
  232. this.msgSuccess("执行成功");
  233. this.loading = false;
  234. }
  235. })
  236. },
  237. //运行状态
  238. handleStatusChange(row){
  239. let text = row.runStatus === true ? "启用" : "停用";
  240. this.$confirm('确认要'+ text + '"' + row.name + '"流程吗?', "警告", {
  241. confirmButtonText: "确定",
  242. cancelButtonText: "取消",
  243. type: "warning"
  244. }).then(function() {
  245. console.log(111)
  246. return zkReProcdefStatus({id:row.id,runStatus:row.runStatus,runCron:row.runCron})
  247. }).then(() => {
  248. this.getList()
  249. this.msgSuccess(row.name + text + "成功");
  250. }).catch(function() {
  251. row.runStatus = row.runStatus === "0" ? "1" : "0";
  252. });
  253. },
  254. },
  255. };
  256. </script>
  257. <style scoped>
  258. .canvas {
  259. width: 100%;
  260. height: 400px;
  261. }
  262. .panel {
  263. position: absolute;
  264. right: 0;
  265. top: 0;
  266. width: 300px;
  267. }
  268. .buttons {
  269. position: absolute;
  270. left: 80px;
  271. bottom: 20px;
  272. }
  273. .buttons li {
  274. display: inline-block;
  275. margin: 5px;
  276. }
  277. .buttons li a {
  278. color: #999;
  279. background: #eee;
  280. cursor: not-allowed;
  281. padding: 8px;
  282. border: 1px solid #ccc;
  283. text-decoration: none;
  284. }
  285. .buttons li a.active {
  286. color: #333;
  287. background: #fff;
  288. cursor: pointer;
  289. }
  290. .demo-drawer-footer {
  291. width: 100%;
  292. position: absolute;
  293. bottom: 0;
  294. left: 0;
  295. border-top: 1px solid #e8e8e8;
  296. padding: 10px 16px;
  297. text-align: right;
  298. background: #fff;
  299. }
  300. .getBpmn{
  301. cursor: pointer !important;
  302. color:#1890ff;
  303. }
  304. </style>