index.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="100px">
  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>
  15. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  16. <el-button type="primary" icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  17. <el-button
  18. type="primary"
  19. plain
  20. icon="el-icon-plus"
  21. size="mini"
  22. @click="handleAdd"
  23. >新增</el-button>
  24. </el-form-item>
  25. </el-form>
  26. <el-table v-loading="loading" :data="adminList" height="calc(100vh - 30vh)">
  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" prop="resourceName" show-overflow-tooltip >
  30. <template slot-scope="scope"><span class="getBpmn" @click="getBpmn(scope.row)">查看流程图</span></template>
  31. </el-table-column>
  32. <el-table-column label="创建时间" align="center" prop="createTime" show-overflow-tooltip />
  33. <el-table-column label="操作" align="center">
  34. <template slot-scope="scope">
  35. <el-button
  36. size="mini"
  37. type="primary"
  38. icon="el-icon-edit"
  39. @click="handleUpdate(scope.row)"
  40. >编辑</el-button>
  41. <el-button
  42. size="mini"
  43. type="danger"
  44. icon="el-icon-delete"
  45. @click="handleDelete(scope.row)"
  46. >删除</el-button>
  47. </template>
  48. </el-table-column>
  49. </el-table>
  50. <!-- 查看bpmn对话框 -->
  51. <el-dialog :title="title" :visible.sync="open" width="600px" append-to-body :before-close="cancel" :close-on-click-modal="false">
  52. <div class="canvas" ref="canvas"></div>
  53. </el-dialog>
  54. <pagination
  55. v-show="total>0"
  56. :total="total"
  57. :page.sync="queryParams.current"
  58. :limit.sync="queryParams.size"
  59. @pagination="getList"
  60. />
  61. </div>
  62. </template>
  63. <script>
  64. // 引入相关的依赖
  65. import BpmnViewer from "bpmn-js/lib/Viewer";
  66. import { xmlStr } from "@/mock/xmlStrPreview2";
  67. import { getBpmnZkNodeList, getBpmnZkNodeTreeList, addBpmnZkNode, updataBpmnZkNode,
  68. getBpmnZkReNodeProcdefTreeList, getBpmnZkReNodeProcdefCheckedTreeList,
  69. getBpmnZkReProcdefList, addBpmnZkReProcdef, updataBpmnZkReProcdef, delBpmnZkReProcdef} from "@/api/business/Middleware/bpmn";
  70. export default {
  71. name: "",
  72. created() {},
  73. mounted() {
  74. },
  75. data() {
  76. return {
  77. // 遮罩层
  78. loading: false,
  79. // 导出遮罩层
  80. exportLoading: false,
  81. // 显示搜索条件
  82. showSearch: true,
  83. // 总条数
  84. total: 0,
  85. // 参数表格数据
  86. adminList: [],
  87. // 弹出层标题
  88. title: "查看流程图",
  89. // 是否显示弹出层
  90. open: false,
  91. // 查询参数
  92. queryParams: {
  93. current: 1,
  94. size: 20,
  95. name:undefined
  96. },
  97. // 表单参数
  98. form: {},
  99. bpmnViewer: null,
  100. container: null,
  101. canvas: null,
  102. xml:undefined,
  103. };
  104. },
  105. created(){
  106. this.getList()
  107. },
  108. // 方法集合
  109. methods: {
  110. /** 修改按钮操作 */
  111. handleUpdate(row) {
  112. this.$router.push({path:'/business/Middleware/bpmn/customModeler',query:{name:row.name,id:row.id}})
  113. },
  114. /** 删除按钮操作 */
  115. handleDelete(row) {
  116. const ids = row.id
  117. this.$confirm('是否确认删除', "警告", {
  118. confirmButtonText: "确定",
  119. cancelButtonText: "取消",
  120. type: "warning"
  121. }).then(function() {
  122. return delBpmnZkReProcdef(ids);
  123. }).then(() => {
  124. this.getList();
  125. this.msgSuccess("删除成功");
  126. }).catch(() => {});
  127. },
  128. /** 新增按钮操作 */
  129. handleAdd() {
  130. this.$router.push('/business/Middleware/bpmn/customModeler')
  131. },
  132. /** 查询参数列表 */
  133. getList() {
  134. this.loading = false;
  135. getBpmnZkReProcdefList(this.queryParams).then(response => {
  136. this.adminList = response.data.records;
  137. this.total = response.data.total;
  138. this.loading = false;
  139. }
  140. );
  141. },
  142. /** 搜索按钮操作 */
  143. handleQuery() {
  144. this.queryParams.current = 1;
  145. this.getList();
  146. },
  147. /** 重置按钮操作 */
  148. resetQuery() {
  149. this.resetForm("queryForm");
  150. this.queryParams.name = undefined
  151. this.handleQuery();
  152. },
  153. // 流程图关闭
  154. cancel() {
  155. this.open = false
  156. // this.reset();
  157. },
  158. //流程图查看
  159. getBpmn(row){
  160. this.loading = false
  161. this.xml = row.resourceName
  162. this.open = true
  163. const canvas = this.$refs.canvas;
  164. this.bpmnViewer = new BpmnViewer({
  165. container: canvas
  166. });
  167. this.createNewDiagram(row.resourceName);
  168. },
  169. async createNewDiagram(xml) {
  170. let that = this
  171. try {
  172. const result = await this.bpmnViewer.importXML(xml);
  173. const { warnings } = result;
  174. console.log(warnings);
  175. // 屏幕自适应
  176. const canvas = this.bpmnViewer.get("canvas");
  177. canvas.zoom("fit-viewport", true);
  178. } catch (err) {
  179. console.log(err.message, err.warnings);
  180. }
  181. }
  182. },
  183. };
  184. </script>
  185. <style scoped>
  186. .canvas {
  187. width: 100%;
  188. height: 400px;
  189. }
  190. .panel {
  191. position: absolute;
  192. right: 0;
  193. top: 0;
  194. width: 300px;
  195. }
  196. .buttons {
  197. position: absolute;
  198. left: 80px;
  199. bottom: 20px;
  200. }
  201. .buttons li {
  202. display: inline-block;
  203. margin: 5px;
  204. }
  205. .buttons li a {
  206. color: #999;
  207. background: #eee;
  208. cursor: not-allowed;
  209. padding: 8px;
  210. border: 1px solid #ccc;
  211. text-decoration: none;
  212. }
  213. .buttons li a.active {
  214. color: #333;
  215. background: #fff;
  216. cursor: pointer;
  217. }
  218. .demo-drawer-footer {
  219. width: 100%;
  220. position: absolute;
  221. bottom: 0;
  222. left: 0;
  223. border-top: 1px solid #e8e8e8;
  224. padding: 10px 16px;
  225. text-align: right;
  226. background: #fff;
  227. }
  228. </style>