model.vue 9.2 KB

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