manager.vue 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335
  1. <template>
  2. <basic-container>
  3. <avue-crud :option="option"
  4. :table-loading="loading"
  5. :data="data"
  6. ref="crud"
  7. v-model="form"
  8. :page="page"
  9. :permission="permissionList"
  10. @search-change="searchChange"
  11. @search-reset="searchReset"
  12. @selection-change="selectionChange"
  13. @current-change="currentChange"
  14. @size-change="sizeChange"
  15. @on-load="onLoad">
  16. <template slot="menuLeft">
  17. <el-button type="danger"
  18. size="small"
  19. icon="el-icon-delete"
  20. v-if="permission.flow_manager_remove"
  21. plain
  22. @click="handleDelete">删 除
  23. </el-button>
  24. </template>
  25. <template slot-scope="scope" slot="menu">
  26. <el-button type="text"
  27. size="small"
  28. v-if="permission.flow_manager_state"
  29. plain
  30. class="none-border"
  31. @click.stop="handleState(scope.row,scope.index)">变更状态
  32. </el-button>
  33. <el-button type="text"
  34. size="small"
  35. v-if="permission.flow_manager_image"
  36. plain
  37. class="none-border"
  38. @click.stop="handleImage(scope.row,scope.index)">流程图
  39. </el-button>
  40. <el-button type="text"
  41. size="small"
  42. v-if="permission.flow_manager_remove"
  43. plain
  44. class="none-border"
  45. @click.stop="handleSlotDelete(scope.row,scope.index)">删除
  46. </el-button>
  47. </template>
  48. <template slot-scope="{row}"
  49. slot="version">
  50. <el-tag>v{{row.version}}</el-tag>
  51. </template>
  52. <template slot-scope="{row}"
  53. slot="suspensionState">
  54. <el-tag>{{row.suspensionState===1?'激活':'挂起'}}</el-tag>
  55. </template>
  56. <template slot-scope="{row}"
  57. slot="category">
  58. <el-tag>{{row.categoryName}}</el-tag>
  59. </template>
  60. </avue-crud>
  61. <el-dialog title="流程图"
  62. :visible.sync="flowBox"
  63. :fullscreen="true">
  64. <iframe
  65. :src=flowUrl
  66. width="100%"
  67. height="700"
  68. title="流程图"
  69. frameBorder="no"
  70. border="0"
  71. marginWidth="0"
  72. marginHeight="0"
  73. scrolling="no"
  74. allowTransparency="yes">
  75. </iframe>
  76. <span slot="footer"
  77. class="dialog-footer">
  78. <el-button @click="flowBox = false">关 闭</el-button>
  79. </span>
  80. </el-dialog>
  81. <el-dialog title="流程变更"
  82. :visible.sync="stateBox"
  83. width="20%">
  84. <el-form :model="form"
  85. ref="form"
  86. label-width="80px">
  87. <el-form-item label="流程状态">
  88. <el-select v-model="flowState" placeholder="请选择" value="">
  89. <el-option
  90. v-for="item in stateOptions"
  91. :key="item.value"
  92. :label="item.label"
  93. :value="item.value">
  94. </el-option>
  95. </el-select>
  96. </el-form-item>
  97. </el-form>
  98. <span slot="footer"
  99. class="dialog-footer">
  100. <el-button @click="stateBox = false">关 闭</el-button>
  101. <el-button type="primary"
  102. @click="handleDoState">确 定</el-button>
  103. </span>
  104. </el-dialog>
  105. </basic-container>
  106. </template>
  107. <script>
  108. import {mapGetters} from "vuex";
  109. import {managerList, changeState, deleteDeployment} from "@/api/flow/flow";
  110. import {flowCategory} from "@/util/flow";
  111. export default {
  112. data() {
  113. return {
  114. form: {},
  115. selectionId: '',
  116. selectionList: [],
  117. query: {},
  118. loading: true,
  119. page: {
  120. pageSize: 10,
  121. currentPage: 1,
  122. total: 0
  123. },
  124. flowBox: false,
  125. flowUrl: '',
  126. stateBox: false,
  127. flowState: '',
  128. stateOptions: [{
  129. value: 'active',
  130. label: '激活'
  131. }, {
  132. value: 'suspend',
  133. label: '挂起'
  134. }],
  135. option: {
  136. tip: false,
  137. border: true,
  138. index: true,
  139. selection: true,
  140. editBtn: false,
  141. addBtn: false,
  142. viewBtn: false,
  143. delBtn: false,
  144. dialogWidth: 300,
  145. dialogHeight: 400,
  146. menuWidth: 150,
  147. column: [
  148. {
  149. label: '流程主键',
  150. prop: 'id',
  151. },
  152. {
  153. label: '流程标识',
  154. prop: 'key',
  155. width: 150,
  156. },
  157. {
  158. label: '流程名称',
  159. prop: 'name',
  160. width: 150,
  161. },
  162. {
  163. label: "流程分类",
  164. type: "select",
  165. row: true,
  166. dicUrl: "/api/blade-system/dict/dictionary?code=flow",
  167. props: {
  168. label: "dictValue",
  169. value: "dictKey"
  170. },
  171. slot: true,
  172. prop: "category",
  173. search: true,
  174. width: 100,
  175. },
  176. {
  177. label: '流程版本',
  178. prop: 'version',
  179. slot: true,
  180. width: 80,
  181. },
  182. {
  183. label: '状态',
  184. prop: 'suspensionState',
  185. slot: true,
  186. width: 80,
  187. },
  188. {
  189. label: '部署时间',
  190. prop: 'deploymentTime',
  191. width: 165,
  192. },
  193. ]
  194. },
  195. data: []
  196. };
  197. },
  198. computed: {
  199. ...mapGetters(["permission"]),
  200. permissionList() {
  201. return {
  202. delBtn: this.vaildData(this.permission.flow_manager_remove, false),
  203. };
  204. },
  205. ids() {
  206. let ids = [];
  207. this.selectionList.forEach(ele => {
  208. ids.push(ele.id);
  209. });
  210. return ids.join(",");
  211. },
  212. deploymentIds() {
  213. let ids = [];
  214. this.selectionList.forEach(ele => {
  215. ids.push(ele.deploymentId);
  216. });
  217. return ids.join(",");
  218. }
  219. },
  220. methods: {
  221. searchReset() {
  222. this.query = {};
  223. this.onLoad(this.page);
  224. },
  225. searchChange(params) {
  226. this.query = params;
  227. this.onLoad(this.page, params);
  228. },
  229. selectionChange(list) {
  230. this.selectionList = list;
  231. },
  232. handleDelete() {
  233. if (this.selectionList.length === 0) {
  234. this.$message.warning("请选择至少一条数据");
  235. return;
  236. }
  237. this.$confirm("确定将选择数据删除?", {
  238. confirmButtonText: "确定",
  239. cancelButtonText: "取消",
  240. type: "warning"
  241. })
  242. .then(() => {
  243. return deleteDeployment(this.deploymentIds);
  244. })
  245. .then(() => {
  246. this.$message({
  247. type: "success",
  248. message: "操作成功!"
  249. });
  250. this.$refs.crud.toggleSelection();
  251. this.onLoad(this.page);
  252. });
  253. },
  254. handleSlotDelete(row) {
  255. this.$confirm("确定将选择数据删除?", {
  256. confirmButtonText: "确定",
  257. cancelButtonText: "取消",
  258. type: "warning"
  259. })
  260. .then(() => {
  261. return deleteDeployment(row.deploymentId);
  262. })
  263. .then(() => {
  264. this.$message({
  265. type: "success",
  266. message: "操作成功!"
  267. });
  268. this.$refs.crud.toggleSelection();
  269. this.onLoad(this.page);
  270. });
  271. },
  272. handleState(row) {
  273. this.stateBox = true;
  274. this.selectionId = row.id;
  275. },
  276. handleDoState() {
  277. if (!this.flowState) {
  278. this.$message({
  279. type: "warn",
  280. message: "请先选择流程状态!"
  281. });
  282. return;
  283. }
  284. changeState({processId: this.selectionId, state: this.flowState}).then(res => {
  285. const data = res.data;
  286. if (data.success) {
  287. this.$message({
  288. type: "success",
  289. message: data.msg
  290. });
  291. this.stateBox = false;
  292. this.onLoad(this.page);
  293. } else {
  294. this.$message({
  295. type: "warn",
  296. message: data.msg
  297. });
  298. }
  299. })
  300. },
  301. handleImage(row) {
  302. this.flowUrl = `/api/blade-flow/process/resource-view?processDefinitionId=${row.id}`;
  303. this.flowBox = true;
  304. },
  305. currentChange(currentPage){
  306. this.page.currentPage = currentPage;
  307. },
  308. sizeChange(pageSize){
  309. this.page.pageSize = pageSize;
  310. },
  311. onLoad(page, params = {}) {
  312. const values = {
  313. ...params,
  314. category: (params.category) ? flowCategory(params.category) : null
  315. }
  316. this.loading = true;
  317. managerList(page.currentPage, page.pageSize, Object.assign(values, this.query)).then(res => {
  318. const data = res.data.data;
  319. this.page.total = data.total;
  320. this.data = data.records;
  321. this.loading = false;
  322. });
  323. }
  324. }
  325. };
  326. </script>
  327. <style>
  328. .none-border {
  329. border: 0;
  330. background-color: transparent!important;
  331. }
  332. </style>