model.vue 11 KB

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