index.vue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-position="top">
  4. <el-row :gutter="20">
  5. <el-col :span="6">
  6. <el-form-item label="名称" prop="name">
  7. <el-input v-model="queryParams.name" placeholder="请输入名称" clearable size="small"
  8. @keyup.enter.native="handleQuery" />
  9. </el-form-item>
  10. </el-col>
  11. <el-col :span="6">
  12. <el-form-item label="开始时间" prop="deployTime">
  13. <el-date-picker clearable size="small" v-model="queryParams.deployTime" type="date"
  14. value-format="yyyy-MM-dd" placeholder="选择时间" style="width: 100%;">
  15. </el-date-picker>
  16. </el-form-item>
  17. </el-col>
  18. <el-col :span="6"></el-col>
  19. <el-col :span="6"></el-col>
  20. </el-row>
  21. <el-row :gutter="20">
  22. <el-col :span="6">
  23. <el-form-item label="搜索">
  24. <el-button style="width: 100%;" type="primary" icon="el-icon-search" @click="handleQuery">搜索</el-button>
  25. </el-form-item>
  26. </el-col>
  27. <el-col :span="6">
  28. <el-form-item label="重置">
  29. <el-button style="width: 100%;" icon="el-icon-refresh" @click="resetQuery">重置</el-button>
  30. </el-form-item>
  31. </el-col>
  32. </el-row>
  33. </el-form>
  34. <el-row :gutter="10" class="mb8">
  35. <!-- <el-col :span="1.5">-->
  36. <!-- <el-button-->
  37. <!-- type="primary"-->
  38. <!-- icon="el-icon-upload"-->
  39. <!-- size="small"-->
  40. <!-- @click="handleImport"-->
  41. <!-- >导入</el-button>-->
  42. <!-- </el-col>-->
  43. <el-col :span="1.5">
  44. <el-button type="success" class="editButton" icon="el-icon-plus" size="small" @click="handleLoadXml">新增</el-button>
  45. </el-col>
  46. <el-col :span="1.5">
  47. <el-button type="danger" icon="el-icon-delete" size="small" :disabled="multiple" @click="handleDelete"
  48. v-hasPermi="['system:deployment:remove']">删除</el-button>
  49. </el-col>
  50. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  51. </el-row>
  52. <el-alert title="流程设计说明" type="success" class="editButton">
  53. <template slot='title'>
  54. <p>流程设计说明:</p>
  55. <div>1、XML文件中的流程定义id属性用作流程定义的key参数。</div>
  56. <div>2、XML文件中的流程定义name属性用作流程定义的name参数。如果未给定name属性,会使用id作为name。</div>
  57. <div>3、当每个唯一key的流程第一次部署时,指定版本为1。对其后所有使用相同key的流程定义,部署时版本会在该key当前已部署的最高版本号基础上加1。key参数用于区分流程定义。</div>
  58. <div>
  59. 4、id参数设置为{processDefinitionKey}:{processDefinitionVersion}:{generated-id},其中generated-id是一个唯一数字,用以保证在集群环境下,流程定义缓存中,流程id的唯一性。
  60. </div>
  61. </template>
  62. </el-alert>
  63. <div class="border-card">
  64. <el-table height="450" v-loading="loading" fit :data="definitionList" border
  65. @selection-change="handleSelectionChange">
  66. <el-table-column type="selection" width="55" align="center" />
  67. <el-table-column label="流程编号" align="center" prop="deploymentId" :show-overflow-tooltip="true" />
  68. <el-table-column label="流程标识" align="center" prop="flowKey" :show-overflow-tooltip="true" />
  69. <el-table-column label="流程分类" align="center" prop="category" />
  70. <el-table-column label="流程名称" align="center" width="120" :show-overflow-tooltip="true">
  71. <template slot-scope="scope">
  72. <el-button type="text" @click="handleReadImage(scope.row.deploymentId)">
  73. <span>{{ scope.row.name }}</span>
  74. </el-button>
  75. </template>
  76. </el-table-column>
  77. <el-table-column label="业务表单" align="center" :show-overflow-tooltip="true">
  78. <template slot-scope="scope">
  79. <el-button v-if="scope.row.formId" type="text" @click="handleForm(scope.row.formId)">
  80. <span>{{ scope.row.formName }}</span>
  81. </el-button>
  82. <label v-else>暂无表单</label>
  83. </template>
  84. </el-table-column>
  85. <el-table-column label="流程版本" align="center">
  86. <template slot-scope="scope">
  87. <el-tag size="medium">v{{ scope.row.version }}</el-tag>
  88. </template>
  89. </el-table-column>
  90. <el-table-column label="状态" align="center">
  91. <template slot-scope="scope">
  92. <el-tag type="success" class="editButton" v-if="scope.row.suspensionState === 1">激活</el-tag>
  93. <el-tag type="warning" v-if="scope.row.suspensionState === 2">挂起</el-tag>
  94. </template>
  95. </el-table-column>
  96. <el-table-column label="部署时间" align="center" prop="deploymentTime" width="180" />
  97. <el-table-column label="操作" width="250" class-name="small-padding fixed-width">
  98. <template slot-scope="scope">
  99. <el-button @click="handleLoadXml(scope.row)" icon="el-icon-edit-outline" type="text"
  100. size="small">设计</el-button>
  101. <el-button @click="handleAddForm(scope.row)" icon="el-icon-edit-el-icon-s-promotion" type="text"
  102. size="small" v-if="scope.row.formId == null">配置主表单</el-button>
  103. <el-button @click="handleUpdateSuspensionState(scope.row)" icon="el-icon-video-pause" type="text"
  104. size="small" v-if="scope.row.suspensionState === 1">挂起</el-button>
  105. <el-button @click="handleUpdateSuspensionState(scope.row)" icon="el-icon-video-play" type="text"
  106. size="small" v-if="scope.row.suspensionState === 2">激活</el-button>
  107. <el-button class="custom-red-color" @click="handleDelete(scope.row)" icon="el-icon-delete" type="text"
  108. size="small" v-hasPermi="['system:deployment:remove']">删除</el-button>
  109. </template>
  110. </el-table-column>
  111. </el-table>
  112. <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
  113. @pagination="getList" />
  114. </div>
  115. <!-- 添加或修改流程定义对话框 -->
  116. <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
  117. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  118. <el-form-item label="看看" prop="name">
  119. <el-input v-model="form.name" placeholder="请输入看看" />
  120. </el-form-item>
  121. </el-form>
  122. <div slot="footer" class="dialog-footer">
  123. <el-button type="primary" @click="submitForm">确 定</el-button>
  124. <el-button @click="cancel">取 消</el-button>
  125. </div>
  126. </el-dialog>
  127. <!-- bpmn20.xml导入对话框 -->
  128. <el-dialog :title="upload.title" :visible.sync="upload.open" width="400px" append-to-body>
  129. <el-upload ref="upload" :limit="1" accept=".xml" :headers="upload.headers"
  130. :action="upload.url + '?name=' + upload.name + '&category=' + upload.category" :disabled="upload.isUploading"
  131. :on-progress="handleFileUploadProgress" :on-success="handleFileSuccess" :auto-upload="false" drag>
  132. <i class="el-icon-upload"></i>
  133. <div class="el-upload__text">
  134. 将文件拖到此处,或
  135. <em>点击上传</em>
  136. </div>
  137. <div class="el-upload__tip" slot="tip">
  138. 流程名称:<el-input v-model="upload.name" />
  139. 流程分类:
  140. <div>
  141. <!-- <el-input v-model="upload.category"/>-->
  142. <el-select v-model="upload.category" placeholder="请选择流程分类">
  143. <el-option v-for="dict in dict.type.sys_process_category" :key="dict.value" :label="dict.label"
  144. :value="dict.value"></el-option>
  145. </el-select>
  146. </div>
  147. </div>
  148. <div class="el-upload__tip" style="color:red" slot="tip">提示:仅允许导入“bpmn20.xml”格式文件!</div>
  149. </el-upload>
  150. <div slot="footer" class="dialog-footer">
  151. <el-button type="primary" @click="submitFileForm">确 定</el-button>
  152. <el-button @click="upload.open = false">取 消</el-button>
  153. </div>
  154. </el-dialog>
  155. <!-- 流程图 -->
  156. <el-dialog :title="readImage.title" :visible.sync="readImage.open" width="70%" append-to-body>
  157. <!-- <el-image :src="readImage.src"></el-image> -->
  158. <flow :flowData="flowData" />
  159. </el-dialog>
  160. <!--表单配置详情-->
  161. <!-- <el-dialog :title="formTitle" :visible.sync="formConfOpen" width="50%" append-to-body>
  162. <div class="test-form">
  163. <parser :key="new Date().getTime()" :form-conf="formConf" />
  164. </div>
  165. </el-dialog>-->
  166. <el-dialog :title="formTitle" :visible.sync="formConfOpen" width="50%" append-to-body>
  167. <div class="test-form">
  168. <v-form-render :form-data="formData" ref="vFormRef" />
  169. </div>
  170. </el-dialog>
  171. <!--挂载表单-->
  172. <el-dialog :title="formDeployTitle" :visible.sync="formDeployOpen" width="60%" append-to-body>
  173. <el-row :gutter="24">
  174. <el-col :span="10" :xs="24">
  175. <el-table ref="singleTable" :data="formList" border highlight-current-row
  176. @current-change="handleCurrentChange" style="width: 100%">
  177. <el-table-column label="表单编号" align="center" prop="formId" />
  178. <el-table-column label="表单名称" align="center" prop="formName" />
  179. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  180. <template slot-scope="scope">
  181. <el-button size="small" type="text" @click="submitFormDeploy(scope.row)">确定</el-button>
  182. </template>
  183. </el-table-column>
  184. </el-table>
  185. <pagination small layout="prev, pager, next" v-show="formTotal > 0" :total="formTotal"
  186. :page.sync="formQueryParams.pageNum" :limit.sync="formQueryParams.pageSize" @pagination="ListFormDeploy" />
  187. </el-col>
  188. <!-- <el-col :span="14" :xs="24">
  189. <div v-if="currentRow">
  190. <parser :key="new Date().getTime()" :form-conf="currentRow" />
  191. </div>
  192. </el-col>-->
  193. <el-col :span="14" :xs="24">
  194. <div class="test-form">
  195. <v-form-render :form-data="formData" ref="vFormCurrentRowRef" />
  196. </div>
  197. </el-col>
  198. </el-row>
  199. </el-dialog>
  200. <!-- &lt;!&ndash;流程设计器&ndash;&gt;-->
  201. <!-- <el-dialog-->
  202. <!-- title="流程配置"-->
  203. <!-- :visible.sync="dialogVisible"-->
  204. <!-- :close-on-press-escape="false"-->
  205. <!-- :fullscreen=true-->
  206. <!-- :before-close="handleClose"-->
  207. <!-- append-to-body>-->
  208. <!-- <Model :deployId="deployId"/>-->
  209. <!-- </el-dialog>-->
  210. </div>
  211. </template>
  212. <script>
  213. import {
  214. listDefinition,
  215. updateState,
  216. delDeployment,
  217. addDeployment,
  218. updateDeployment,
  219. exportDeployment,
  220. definitionStart,
  221. flowXmlAndNode
  222. } from "@/api/flowable/definition";
  223. import { getToken } from "@/utils/auth";
  224. import { getForm, addDeployForm, listForm } from "@/api/flowable/form";
  225. import Parser from '@/components/parser/Parser'
  226. import flow from '@/views/flowable/task/myProcess/send/flow'
  227. import Model from './model';
  228. export default {
  229. name: "Definition",
  230. dicts: ['sys_process_category'],
  231. components: {
  232. Parser,
  233. flow,
  234. Model
  235. },
  236. data() {
  237. return {
  238. // 遮罩层
  239. loading: true,
  240. dialogVisible: false,
  241. // 选中数组
  242. ids: [],
  243. // 非单个禁用
  244. single: true,
  245. // 非多个禁用
  246. multiple: true,
  247. // 显示搜索条件
  248. showSearch: true,
  249. // 总条数
  250. total: 0,
  251. // 流程定义表格数据
  252. definitionList: [],
  253. // 弹出层标题
  254. title: "",
  255. // 是否显示弹出层
  256. open: false,
  257. formConfOpen: false,
  258. formTitle: "",
  259. formDeployOpen: false,
  260. formDeployTitle: "",
  261. formList: [],
  262. formTotal: 0,
  263. formConf: {}, // 默认表单数据
  264. formData: {}, // 默认表单数据
  265. readImage: {
  266. open: false,
  267. src: "",
  268. },
  269. // bpmn.xml 导入
  270. upload: {
  271. // 是否显示弹出层(xml导入)
  272. open: false,
  273. // 弹出层标题(xml导入)
  274. title: "",
  275. // 是否禁用上传
  276. isUploading: false,
  277. name: null,
  278. category: null,
  279. // 设置上传的请求头部
  280. headers: { Authorization: "Bearer " + getToken() },
  281. // 上传的地址
  282. url: process.env.VUE_APP_BASE_API + "/flowable/definition/import"
  283. },
  284. // 查询参数
  285. queryParams: {
  286. pageNum: 1,
  287. pageSize: 10,
  288. name: null,
  289. category: null,
  290. key: null,
  291. tenantId: null,
  292. deployTime: null,
  293. derivedFrom: null,
  294. derivedFromRoot: null,
  295. parentDeploymentId: null,
  296. engineVersion: null
  297. },
  298. formQueryParams: {
  299. pageNum: 1,
  300. pageSize: 10,
  301. },
  302. // 挂载表单到流程实例
  303. formDeployParam: {
  304. formId: null,
  305. deployId: null
  306. },
  307. deployId: '',
  308. currentRow: null,
  309. // xml
  310. flowData: {},
  311. // 表单参数
  312. form: {},
  313. // 表单校验
  314. rules: {
  315. }
  316. };
  317. },
  318. created() {
  319. this.getList();
  320. },
  321. activated() {
  322. const time = this.$route.query.t;
  323. if (time != null) {
  324. this.getList();
  325. }
  326. },
  327. methods: {
  328. /** 查询流程定义列表 */
  329. getList() {
  330. this.loading = true;
  331. listDefinition(this.queryParams).then(response => {
  332. this.definitionList = response.data.records;
  333. this.total = response.data.total;
  334. this.loading = false;
  335. });
  336. },
  337. handleClose(done) {
  338. this.$confirm('确定要关闭吗?关闭未保存的修改都会丢失?', '提示', {
  339. confirmButtonText: '确定',
  340. cancelButtonText: '取消',
  341. type: 'warning'
  342. }).then(() => {
  343. done();
  344. }).catch(() => { });
  345. },
  346. // 取消按钮
  347. cancel() {
  348. this.open = false;
  349. this.reset();
  350. },
  351. // 表单重置
  352. reset() {
  353. this.form = {
  354. id: null,
  355. name: null,
  356. category: null,
  357. key: null,
  358. tenantId: null,
  359. deployTime: null,
  360. derivedFrom: null,
  361. derivedFromRoot: null,
  362. parentDeploymentId: null,
  363. engineVersion: null
  364. };
  365. this.resetForm("form");
  366. },
  367. /** 搜索按钮操作 */
  368. handleQuery() {
  369. this.queryParams.pageNum = 1;
  370. this.getList();
  371. },
  372. /** 重置按钮操作 */
  373. resetQuery() {
  374. this.resetForm("queryForm");
  375. this.handleQuery();
  376. },
  377. // 多选框选中数据
  378. handleSelectionChange(selection) {
  379. this.ids = selection.map(item => item.deploymentId)
  380. this.single = selection.length !== 1
  381. this.multiple = !selection.length
  382. },
  383. /** 新增按钮操作 */
  384. handleAdd() {
  385. this.reset();
  386. this.open = true;
  387. this.title = "添加流程定义";
  388. },
  389. /** 跳转到流程设计页面 */
  390. handleLoadXml(row) {
  391. // this.dialogVisible = true;
  392. // this.deployId = row.deploymentId;
  393. this.$router.push({ path: '/flowable/definition/model', query: { deployId: row.deploymentId } })
  394. },
  395. /** 流程图查看 */
  396. handleReadImage(deployId) {
  397. this.readImage.title = "流程图";
  398. this.readImage.open = true;
  399. // this.readImage.src = process.env.VUE_APP_BASE_API + "/flowable/definition/readImage/" + deploymentId;
  400. flowXmlAndNode({ deployId: deployId }).then(res => {
  401. this.flowData = res.data;
  402. })
  403. },
  404. /** 表单查看 */
  405. /*handleForm(formId){
  406. getForm(formId).then(res =>{
  407. this.formTitle = "表单详情";
  408. this.formConfOpen = true;
  409. this.formConf = JSON.parse(res.data.formContent)
  410. })
  411. },*/
  412. handleForm(formId) {
  413. getForm(formId).then(res => {
  414. this.formTitle = "表单详情";
  415. this.formConfOpen = true;
  416. this.$nextTick(() => {
  417. // 回显数据
  418. this.$refs.vFormRef.setFormJson(JSON.parse(res.data.formContent))
  419. this.$nextTick(() => {
  420. // 表单禁用
  421. this.$refs.vFormRef.disableForm();
  422. })
  423. })
  424. })
  425. },
  426. /** 启动流程 */
  427. handleDefinitionStart(row) {
  428. definitionStart(row.id).then(res => {
  429. this.$modal.msgSuccess(res.msg);
  430. })
  431. },
  432. /** 挂载表单弹框 */
  433. handleAddForm(row) {
  434. this.formDeployParam.deployId = row.deploymentId
  435. this.ListFormDeploy()
  436. },
  437. /** 挂载表单列表 */
  438. ListFormDeploy() {
  439. listForm(this.formQueryParams).then(res => {
  440. this.formList = res.rows;
  441. this.formTotal = res.total;
  442. this.formDeployOpen = true;
  443. this.formDeployTitle = "挂载表单";
  444. })
  445. },
  446. // /** 更改挂载表单弹框 */
  447. // handleEditForm(row){
  448. // this.formDeployParam.deployId = row.deploymentId
  449. // const queryParams = {
  450. // pageNum: 1,
  451. // pageSize: 10
  452. // }
  453. // listForm(queryParams).then(res =>{
  454. // this.formList = res.rows;
  455. // this.formDeployOpen = true;
  456. // this.formDeployTitle = "挂载表单";
  457. // })
  458. // },
  459. /** 挂载表单 */
  460. submitFormDeploy(row) {
  461. this.formDeployParam.formId = row.formId;
  462. addDeployForm(this.formDeployParam).then(res => {
  463. this.$modal.msgSuccess(res.msg);
  464. this.formDeployOpen = false;
  465. this.getList();
  466. })
  467. },
  468. /* handleCurrentChange(data) {
  469. if (data) {
  470. this.currentRow = JSON.parse(data.formContent);
  471. }
  472. },*/
  473. handleCurrentChange(data) {
  474. if (data) {
  475. this.$nextTick(() => {
  476. // 回显数据
  477. this.$refs.vFormCurrentRowRef.setFormJson(JSON.parse(data.formContent))
  478. this.$nextTick(() => {
  479. // 表单禁用
  480. this.$refs.vFormCurrentRowRef.disableForm();
  481. })
  482. })
  483. }
  484. },
  485. /** 挂起/激活流程 */
  486. handleUpdateSuspensionState(row) {
  487. let state = 1;
  488. if (row.suspensionState === 1) {
  489. state = 2
  490. }
  491. const params = {
  492. deployId: row.deploymentId,
  493. state: state
  494. }
  495. updateState(params).then(res => {
  496. this.$modal.msgSuccess(res.msg);
  497. this.getList();
  498. });
  499. },
  500. /** 修改按钮操作 */
  501. handleUpdate(row) {
  502. this.reset();
  503. const id = row.deploymentId || this.ids
  504. getDeployment(id).then(response => {
  505. this.form = response.data;
  506. this.open = true;
  507. this.title = "修改流程定义";
  508. });
  509. },
  510. /** 提交按钮 */
  511. submitForm() {
  512. this.$refs["form"].validate(valid => {
  513. if (valid) {
  514. if (this.form.id != null) {
  515. updateDeployment(this.form).then(response => {
  516. this.$modal.msgSuccess("修改成功");
  517. this.open = false;
  518. this.getList();
  519. });
  520. } else {
  521. addDeployment(this.form).then(response => {
  522. this.$modal.msgSuccess("新增成功");
  523. this.open = false;
  524. this.getList();
  525. });
  526. }
  527. }
  528. });
  529. },
  530. /** 删除按钮操作 */
  531. handleDelete(row) {
  532. const deploymentIds = row.deploymentId || this.ids;
  533. this.$confirm('是否确认删除流程定义编号为"' + deploymentIds + '"的数据项?', "警告", {
  534. confirmButtonText: "确定",
  535. cancelButtonText: "取消",
  536. type: "warning"
  537. }).then(function () {
  538. return delDeployment(deploymentIds);
  539. }).then(() => {
  540. this.getList();
  541. this.$modal.msgSuccess("删除成功");
  542. })
  543. },
  544. /** 导出按钮操作 */
  545. handleExport() {
  546. const queryParams = this.queryParams;
  547. this.$confirm('是否确认导出所有流程定义数据项?', "警告", {
  548. confirmButtonText: "确定",
  549. cancelButtonText: "取消",
  550. type: "warning"
  551. }).then(function () {
  552. return exportDeployment(queryParams);
  553. }).then(response => {
  554. this.download(response.msg);
  555. })
  556. },
  557. /** 导入bpmn.xml文件 */
  558. handleImport() {
  559. this.upload.title = "bpmn20.xml文件导入";
  560. this.upload.open = true;
  561. },
  562. // 文件上传中处理
  563. handleFileUploadProgress(event, file, fileList) {
  564. this.upload.isUploading = true;
  565. },
  566. // 文件上传成功处理
  567. handleFileSuccess(response, file, fileList) {
  568. this.upload.open = false;
  569. this.upload.isUploading = false;
  570. this.$refs.upload.clearFiles();
  571. this.$message(response.msg);
  572. this.getList();
  573. },
  574. // 提交上传文件
  575. submitFileForm() {
  576. this.$refs.upload.submit();
  577. }
  578. }
  579. };
  580. </script>