manager.vue 10 KB

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