index.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. <!--
  2. - Copyright (c) 2018-2025, lengleng All rights reserved.
  3. -
  4. - Redistribution and use in source and binary forms, with or without
  5. - modification, are permitted provided that the following conditions are met:
  6. -
  7. - Redistributions of source code must retain the above copyright notice,
  8. - this list of conditions and the following disclaimer.
  9. - Redistributions in binary form must reproduce the above copyright
  10. - notice, this list of conditions and the following disclaimer in the
  11. - documentation and/or other materials provided with the distribution.
  12. - Neither the name of the pig4cloud.com developer nor the names of its
  13. - contributors may be used to endorse or promote products derived from
  14. - this software without specific prior written permission.
  15. - Author: lengleng (wangiegie@gmail.com)
  16. -->
  17. <template>
  18. <div class="execution">
  19. <basic-container>
  20. <avue-crud ref="crud"
  21. :page="page"
  22. :data="tableData"
  23. :table-loading="tableLoading"
  24. :option="tableOption"
  25. @on-load="getList"
  26. @search-change="searchChange"
  27. @refresh-change="refreshChange"
  28. @row-save="handleSave"
  29. @row-del="rowDel">
  30. <template slot-scope="scope"
  31. slot="menuBtn">
  32. <el-dropdown-item divided
  33. v-if="permissions.act_model_manage"
  34. @click.native="handleView(scope.row,scope.index)">模型图</el-dropdown-item>
  35. <el-dropdown-item divided
  36. v-if="permissions.act_model_manage"
  37. @click.native="handleDeploy(scope.row,scope.index)">部署</el-dropdown-item>
  38. <el-dropdown-item divided
  39. v-if="permissions.act_model_manage"
  40. @click.native="handleDel(scope.row,scope.index)">删除</el-dropdown-item>
  41. </template>
  42. </avue-crud>
  43. </basic-container>
  44. </div>
  45. </template>
  46. <script>
  47. import { fetchList, delObj, addObj, deploy } from '@/api/activiti/activiti'
  48. import { tableOption } from '@/const/crud/activiti/activiti'
  49. import { mapGetters } from 'vuex'
  50. export default {
  51. name: 'activiti',
  52. data () {
  53. return {
  54. tableData: [],
  55. page: {
  56. total: 0, // 总页数
  57. currentPage: 1, // 当前页数
  58. pageSize: 20 // 每页显示多少条
  59. },
  60. tableLoading: false,
  61. tableOption: tableOption
  62. }
  63. },
  64. created () {
  65. },
  66. mounted: function () { },
  67. computed: {
  68. ...mapGetters(['permissions'])
  69. },
  70. methods: {
  71. getList (page,params) {
  72. this.tableLoading = true
  73. fetchList(Object.assign({
  74. descs: 'create_time',
  75. current: page.currentPage,
  76. size: page.pageSize
  77. }, params)).then(response => {
  78. this.tableData = response.data.data.records
  79. this.page.total = response.data.data.total
  80. this.tableLoading = false
  81. })
  82. },
  83. handleView (row, index) {
  84. const name = `模型id为${row.id}的${row.name}流程图`,
  85. src = `/activti/detail/${row.id}`;
  86. this.$router.push({
  87. path: src,
  88. query: {
  89. name: name
  90. }
  91. })
  92. },
  93. handleDel (row, index) {
  94. this.$refs.crud.rowDel(row, index)
  95. },
  96. handleDeploy: function (row, index) {
  97. var _this = this
  98. this.$confirm('是否确认部署ID为"' + row.id + '"的模型?', '警告', {
  99. confirmButtonText: '确定',
  100. cancelButtonText: '取消',
  101. type: 'warning'
  102. }).then(function () {
  103. return deploy(row.id)
  104. })
  105. .then(data => {
  106. this.getList(this.page)
  107. _this.$message({
  108. showClose: true,
  109. message: '部署成功',
  110. type: 'success'
  111. })
  112. })
  113. .catch(function (err) { })
  114. },
  115. rowDel: function (row, index) {
  116. var _this = this
  117. this.$confirm('是否确认删除ID为"' + row.id + '"的模型?', '警告', {
  118. confirmButtonText: '确定',
  119. cancelButtonText: '取消',
  120. type: 'warning'
  121. })
  122. .then(function () {
  123. return delObj(row.id)
  124. })
  125. .then(data => {
  126. this.getList(this.page)
  127. _this.$message({
  128. showClose: true,
  129. message: '删除成功',
  130. type: 'success'
  131. })
  132. })
  133. .catch(function (err) { })
  134. },
  135. /**
  136. * @title 数据添加
  137. * @param row 为当前的数据
  138. * @param done 为表单关闭函数
  139. *
  140. **/
  141. handleSave: function (row, done) {
  142. addObj(row).then(data => {
  143. this.tableData.push(Object.assign({}, row))
  144. this.$message({
  145. showClose: true,
  146. message: '添加成功',
  147. type: 'success'
  148. })
  149. done()
  150. this.getList(this.page)
  151. })
  152. },
  153. /**
  154. * 搜索回调
  155. */
  156. searchChange (form) {
  157. this.getList(this.page,form)
  158. },
  159. /**
  160. * 刷新回调
  161. */
  162. refreshChange () {
  163. this.getList(this.page)
  164. }
  165. }
  166. }
  167. </script>
  168. <style lang="scss" scoped>
  169. </style>