index.vue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641
  1. <template>
  2. <div class="hello">
  3. <div class="box">
  4. <el-container>
  5. <el-aside width="180px" >
  6. <div class="title">流程分类</div>
  7. <div class="left">
  8. <ul>
  9. <li style="cursor:pointer" @click="changeCategroy(item.id)" v-for="item in processList"><i class="el-icon-s-order"></i>{{item.categoryName}}</li>
  10. </ul>
  11. </div>
  12. </el-aside>
  13. <el-main class="right">
  14. <div class="bgfff">
  15. <el-form :model="queryParams" ref="queryForm" :inline="true">
  16. <el-form-item label="流程名称:" prop="activitiName">
  17. <el-input
  18. v-model="queryParams.activitiName"
  19. placeholder="请输入要查询的关键字"
  20. clearable
  21. size="small"
  22. @keyup.enter.native="handleQuery"
  23. />
  24. </el-form-item>
  25. <el-form-item>
  26. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  27. <el-button type="primary" icon="el-icon-plus" @click="handleAdd()">新建流程</el-button>
  28. <el-button type="primary" icon="el-icon-plus" @click="handleUpload()">导入模型</el-button>
  29. </el-form-item>
  30. </el-form>
  31. <!-- <el-row class="der">
  32. <el-button @click="handleQuery()">刷新</el-button>
  33. <el-button type="primary" @click="handleAdd()">添加模型</el-button>
  34. <el-button type="primary" @click="handleUpload()">导入模型(BPMN)</el-button>
  35. &lt;!&ndash; <el-button>查看流程图</el-button>&ndash;&gt;
  36. &lt;!&ndash; <el-button>查看流程(XML)</el-button>&ndash;&gt;
  37. &lt;!&ndash; <el-button>查看流程(JSON)</el-button>&ndash;&gt;
  38. &lt;!&ndash; <el-button>导出流程(BPMN)</el-button>&ndash;&gt;
  39. &lt;!&ndash; <el-button>导入流程(BPMN)</el-button>&ndash;&gt;
  40. </el-row>-->
  41. <el-table
  42. border
  43. v-loading="loading"
  44. :data="modelerList"
  45. style="width: 100%;"
  46. >
  47. <el-table-column label="序号" type="index" align="center">
  48. <template slot-scope="scope">
  49. <span>{{(queryParams.pageNum - 1) * queryParams.pageSize + scope.$index + 1}}</span>
  50. </template>
  51. </el-table-column>
  52. <el-table-column label="部署版本" align="center" prop="activitiDeployStatus" width="180">
  53. <template slot-scope="scope">
  54. <span v-if="scope.row.processDefinition!=null">
  55. {{ scope.row.processDefinition.id}}
  56. </span>
  57. </template>
  58. </el-table-column>
  59. <el-table-column label="流程名称" align="center" prop="activitiName"/>
  60. <el-table-column label="流程分类" align="center" prop="activitiDeployId"/>
  61. <!-- <el-table-column label="流程定义" align="center" prop="resourceName" width="180">
  62. <template slot-scope="scope">
  63. <el-link target="_blank" type="success" @click="viewFlowXML(scope.row)">
  64. 查看流程(XML)
  65. </el-link>
  66. </template>
  67. </el-table-column>
  68. <el-table-column label="流程图" align="center" prop="diagramResourceName" width="180">
  69. <template slot-scope="scope">
  70. <el-link target="_blank" type="primary" @click="viewFlowChat(scope.row)">
  71. 查看流程图
  72. </el-link>
  73. </template>
  74. </el-table-column>-->
  75. <el-table-column label="部署状态" align="center" prop="activitiDeployStatus" width="180">
  76. <template slot-scope="scope">
  77. <el-tag
  78. :type="formatStatus(scope.row.activitiDeployStatus)"
  79. effect="dark">
  80. {{ scope.row.activitiDeployStatus==='0'?'未部署':'已部署' }}
  81. </el-tag>
  82. </template>
  83. </el-table-column>
  84. <el-table-column label="运行状态" align="center" prop="activitiDeployStatus" width="180">
  85. <template slot-scope="scope" v-if="scope.row.processDefinition!=null">
  86. <el-tag
  87. :type="scope.row.processDefinition.suspendState ==='2'?'warning':''"
  88. effect="dark">
  89. {{scope.row.processDefinition.suspendStateName}}
  90. </el-tag>
  91. </template>
  92. </el-table-column>
  93. <el-table-column label="创建时间" align="center" prop="activitiCreateTime" width="180">
  94. <template slot-scope="scope">
  95. <span>{{ parseTimeT(scope.row.activitiCreateTime) }}</span>
  96. </template>
  97. </el-table-column>
  98. <!-- <el-table-column label="最后更新时间" align="center" prop="activitiUpdateTime" width="180">
  99. <template slot-scope="scope">
  100. <span>{{ parseTimeT(scope.row.activitiUpdateTime) }}</span>
  101. </template>
  102. </el-table-column>-->
  103. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  104. <template slot-scope="scope">
  105. <el-button
  106. size="mini"
  107. type="text"
  108. icon="el-icon-edit"
  109. @click="handleUpdate(scope.row)"
  110. v-hasPermi="['system:menu:edit']"
  111. >修改
  112. </el-button>
  113. <el-button
  114. size="mini"
  115. type="text"
  116. icon="el-icon-upload"
  117. @click="handleDeploy(scope.row)"
  118. v-hasPermi="['system:menu:add']"
  119. >{{scope.row.activitiDeployStatus==='0'?'部署':'重新部署'}}
  120. </el-button>
  121. <el-button
  122. v-if="scope.row.processDefinition!=null"
  123. size="mini"
  124. type="text"
  125. icon="el-icon-switch-button"
  126. @click="handleSuspendOrActiveApply(scope.row)"
  127. v-hasPermi="['system:menu:add']"
  128. >{{scope.row.processDefinition.suspendState === '2' ? '激活' : '挂起'}}
  129. </el-button>
  130. <el-button
  131. size="mini"
  132. type="text"
  133. icon="el-icon-delete"
  134. @click="handleDelete(scope.row,scope.$index)"
  135. v-hasPermi="['system:menu:remove']"
  136. >删除
  137. </el-button>
  138. <el-button
  139. size="mini"
  140. type="text"
  141. icon="el-icon-delete"
  142. @click="data_association(scope.row.activitiKey)"
  143. >业务关联
  144. </el-button>
  145. </template>
  146. </el-table-column>
  147. </el-table>
  148. <pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNum"
  149. :limit.sync="queryParams.pageSize"
  150. @pagination="getList"/>
  151. </div>
  152. </el-main>
  153. </el-container>
  154. </div>
  155. <el-dialog id="editModeler" title="修改流程" :visible.sync="editOpen" width="90%" top="10"
  156. @close="handleEditModelerDialogClose" fullscreen>
  157. <iframe :src="src" id="activiti_main" frameborder="no" :style="'width: 100%;height:'+ iframe.height"
  158. scrolling="auto"/>
  159. </el-dialog>
  160. <!-- 用户导入对话框 -->
  161. <el-dialog :title="upload.title" :visible.sync="upload.open" width="400px" append-to-body>
  162. <el-upload
  163. ref="upload"
  164. :limit="1"
  165. accept=".bpmn"
  166. :headers="upload.headers"
  167. :action="upload.url"
  168. :disabled="upload.isUploading"
  169. :on-progress="handleFileUploadProgress"
  170. :on-success="handleFileSuccess"
  171. :auto-upload="false"
  172. drag
  173. >
  174. <i class="el-icon-upload"></i>
  175. <div class="el-upload__text">
  176. 将文件拖到此处,或
  177. <em>点击上传</em>
  178. </div>
  179. <div class="el-upload__tip" style="color:red" slot="tip">提示:仅允许导入“*.bpmn”格式文件!</div>
  180. </el-upload>
  181. <div slot="footer" class="dialog-footer">
  182. <el-button type="primary" @click="submitFileForm">确 定</el-button>
  183. <el-button @click="upload.open = false">取 消</el-button>
  184. </div>
  185. </el-dialog>
  186. <!-- 第一个业务关联 -->
  187. <el-dialog title="业务关联" :visible.sync="dialogVisible" width="1200px">
  188. <el-tabs :tab-position="tabPosition" style="min-height: 300px;">
  189. <el-tab-pane>
  190. <span slot="label"><i class="el-icon-date"></i> 业务关联</span>
  191. <el-button type="primary" icon="el-icon-plus" @click="addDatAassociation">新增</el-button>
  192. <br/>
  193. <el-table border :data="DataAssociation" >
  194. <el-table-column label="序号" type="index" width="130" align="center">
  195. </el-table-column>
  196. <el-table-column label="表名/自定义表单编号" width="180" align="center" prop="tablename"/>
  197. <el-table-column label="业务标题表达式" align="center" prop="titleexp"/>
  198. <el-table-column label="操作" width="180" align="center" >
  199. <template slot-scope="scope">
  200. <!-- <el-button
  201. size="mini"
  202. type="text"
  203. icon="el-icon-edit"
  204. @click="data_association(scope.row.activitiKey)"
  205. >编辑
  206. </el-button>-->
  207. <el-button
  208. size="mini"
  209. type="text"
  210. icon="el-icon-delete"
  211. @click="handleDeleteAss(scope.row.id)"
  212. v-hasPermi="['system:menu:remove']"
  213. >删除
  214. </el-button>
  215. </template>
  216. </el-table-column>
  217. </el-table>
  218. </el-tab-pane>
  219. </el-tabs>
  220. <span slot="footer" class="dialog-footer">
  221. <el-button @click="cancel">关 闭</el-button>
  222. </span>
  223. </el-dialog>
  224. <!-- 第二个增加业务关联 -->
  225. <el-dialog title="新增" :visible.sync="dialogaddVisible" width="800px" height="500px">
  226. <el-form ref="formadd" :model="formadd" :rules="rules" label-width="120px">
  227. <el-form-item label="流程key:" prop="actkey" read>
  228. <el-input v-model="formadd.actkey" :disabled="true"></el-input>
  229. </el-form-item>
  230. <el-form-item label="表名:" prop="tablename">
  231. <el-input v-model="formadd.tablename"></el-input>
  232. </el-form-item>
  233. <el-form-item label="标题表达式:" prop="titleexp">
  234. <el-input v-model="formadd.titleexp"></el-input>
  235. </el-form-item>
  236. <el-form-item >
  237. <p style="color: red;">参考:XXXX【${busname}】-XXXX【${name}】;其中${}表达式取流程变量的值</p>
  238. </el-form-item>
  239. <el-form-item>
  240. <el-button type="primary" @click="SubmitAcc('formadd')">确 定</el-button>
  241. <el-button @click="closeAddform" >关 闭</el-button>
  242. </el-form-item>
  243. </el-form>
  244. </el-dialog>
  245. </div>
  246. </template>
  247. <script>
  248. import {
  249. listModeler,
  250. deployModeler,
  251. suspendOrActiveApply,
  252. delModeler,
  253. getActCategroy,
  254. addDataAssociation,
  255. getListDataAssociation,
  256. removeDataAssociation
  257. } from '@/api/activiti/modeler/activiti_list'
  258. import { getToken } from '@/utils/auth'
  259. export default {
  260. created() {
  261. getActCategroy().then(response => {
  262. this.processList = response.rows
  263. })
  264. this.getList()
  265. },
  266. data() {
  267. return {
  268. formadd: {
  269. actkey:'',
  270. tablename:'',
  271. titleexp:''
  272. },
  273. rules: {
  274. tablename: [
  275. { required: true, message: '请输入表名', trigger: 'blur' }
  276. ],
  277. titleexp: [
  278. { required: true, message: '请输入标题表达式', trigger: 'blur' }
  279. ],
  280. },
  281. baseUrl: process.env.VUE_APP_BASE_API,
  282. processList: [],
  283. dialogVisible: false,
  284. dialogaddVisible:false,
  285. // 遮罩层
  286. loading: true,
  287. // 总条数
  288. total: 0,
  289. // 表格数据
  290. modelerList: [],
  291. // 查询参数
  292. queryParams: {
  293. activitiName: undefined,
  294. activitiCategory: 0,
  295. pageNum: 1,
  296. pageSize: 10
  297. },
  298. // 是否显示弹出层
  299. editOpen: false,
  300. iframe: {
  301. height: document.documentElement.clientHeight - 126.5 + 'px;'
  302. },
  303. // 用户导入参数
  304. upload: {
  305. // 是否显示弹出层(用户导入)
  306. open: false,
  307. // 弹出层标题(用户导入)
  308. title: '',
  309. // 是否禁用上传
  310. isUploading: false,
  311. // 设置上传的请求头部
  312. headers: { Authorization: 'Bearer ' + getToken() },
  313. // 上传的地址
  314. url: undefined,
  315. actkey:'',
  316. //业务关联数据
  317. DataAssociation:[]
  318. }
  319. }
  320. },
  321. methods: {
  322. changeCategroy(item) {
  323. this.queryParams.activitiCategory = item
  324. this.handleQuery()
  325. },
  326. /** 查询列表 */
  327. getList() {
  328. this.loading = true
  329. listModeler(this.queryParams).then(response => {
  330. this.modelerList = response.rows
  331. //console.log(response.rows)
  332. this.total = response.total
  333. this.loading = false
  334. })
  335. },
  336. formatStatus(status) {
  337. return status === '0' ? 'danger' : 'success'
  338. },
  339. /** 搜索按钮操作 */
  340. handleQuery() {
  341. this.pageNum = 1
  342. this.getList()
  343. },
  344. /** 重置按钮操作 */
  345. resetQuery() {
  346. this.resetForm('queryForm')
  347. this.handleQuery()
  348. },
  349. /** 新增按钮操作 */
  350. handleAdd() {
  351. this.src = process.env.VUE_APP_BASE_API + '/modeler/create?f=' + this.queryParams.activitiCategory + '&r=' + Math.random()
  352. this.editOpen = true
  353. },
  354. /** 编辑按钮操作 */
  355. handleUpdate(row) {
  356. this.src = process.env.VUE_APP_BASE_API + '/modeler/activiti/index?modelId=' + row.activitiId
  357. this.editOpen = true
  358. },
  359. /** 部署按钮操作 */
  360. handleDeploy(row) {
  361. const name = row.activitiName
  362. this.$confirm('是否确认部署名称为"' + name + '"的流程模型?', '提示', {
  363. confirmButtonText: '确定',
  364. cancelButtonText: '取消',
  365. type: 'warning'
  366. }).then(function() {
  367. return deployModeler(row.id)
  368. }).then(() => {
  369. this.getList()
  370. this.msgSuccess('部署成功')
  371. }).catch(function() {
  372. })
  373. },
  374. handleSuspendOrActiveApply(row) {
  375. let suspendOrActive = row.processDefinition.suspendState === '2' ? '激活' : '挂起'
  376. this.$confirm('是否挂起"' + suspendOrActive + '"流程定义?', '警告', {
  377. confirmButtonText: '确定',
  378. cancelButtonText: '取消',
  379. type: 'warning'
  380. }).then(function() {
  381. return suspendOrActiveApply(row.processDefinition.id, row.processDefinition.suspendState)
  382. }).then(() => {
  383. this.getList()
  384. this.msgSuccess(suspendOrActive + '成功')
  385. }).catch(function() {
  386. })
  387. },
  388. /** 删除按钮操作 */
  389. handleDelete(row, index) {
  390. const name = row.activitiName
  391. this.$confirm('是否确认删除名称为"' + name + '"的流程模型?', '警告', {
  392. confirmButtonText: '确定',
  393. cancelButtonText: '取消',
  394. type: 'warning'
  395. }).then(function() {
  396. return delModeler(row.id)
  397. }).then(() => {
  398. if (this.modelerList.length - 1 === 0) {
  399. this.queryParams.pageNum = this.queryParams.pageNum - 1 === 0 ? 1 : this.queryParams.pageNum - 1
  400. }
  401. this.getList()
  402. this.msgSuccess('删除成功')
  403. }).catch(function() {
  404. })
  405. },
  406. /**
  407. * 查看流程图
  408. * 2020年7月24日09:06:14
  409. * 吕瑞涵
  410. */
  411. viewFlowChat(row) {
  412. if (row.activitiDeployStatus === '1') {
  413. window.open(this.baseUrl + '/activiti/definition/readResource?id=' + row.id + '&type=png')
  414. } else {
  415. this.msgError('暂未部署,无法查看')
  416. }
  417. },
  418. /**
  419. * 查看流程XML
  420. * 2020年7月24日09:06:59
  421. * 吕瑞涵
  422. */
  423. viewFlowXML(row) {
  424. if (row.activitiDeployStatus === '1') {
  425. window.open(this.baseUrl + '/activiti/definition/readResource?id=' + row.id + '&type=xml')
  426. } else {
  427. this.msgError('暂未部署,无法查看')
  428. }
  429. },
  430. handleUpload() {
  431. this.upload.title = '部署自定义流程'
  432. this.upload.open = true
  433. this.upload.url = process.env.VUE_APP_BASE_API + '/activiti/definition/upload/' + this.queryParams.activitiCategory
  434. },
  435. // 提交上传文件
  436. submitFileForm() {
  437. this.$refs.upload.submit()
  438. },
  439. // 文件上传中处理
  440. handleFileUploadProgress(event, file, fileList) {
  441. this.upload.isUploading = true
  442. },
  443. // 文件上传成功处理
  444. handleFileSuccess(response, file, fileList) {
  445. this.upload.open = false
  446. this.upload.isUploading = false
  447. this.$refs.upload.clearFiles()
  448. this.$alert(response.msg, '导入结果', { dangerouslyUseHTMLString: true })
  449. this.getList()
  450. },
  451. //监听修改流程对话框的关闭事件
  452. handleEditModelerDialogClose() {
  453. this.getList()
  454. },
  455. //单击业务关联
  456. data_association(actkeyvalue){
  457. this.dialogVisible = false;
  458. getListDataAssociation(actkeyvalue).then(response => {
  459. this.DataAssociation=response.rows;
  460. this.dialogVisible = true;
  461. });
  462. this.actkey=actkeyvalue;
  463. },
  464. // 取消按钮
  465. cancel() {
  466. this.dialogVisible = false
  467. },
  468. //弹出新增关联按钮
  469. addDatAassociation(){
  470. this.formadd.actkey=this.actkey;
  471. this.dialogaddVisible=true;
  472. },
  473. //提交数据
  474. SubmitAcc(formName) {
  475. this.$refs[formName].validate((valid) => {
  476. if (valid) {
  477. addDataAssociation(this.formadd).then(response => {
  478. this.msgSuccess('新增成功')
  479. this.dialogaddVisible=false;
  480. this.data_association(this.actkey);
  481. });
  482. } else {
  483. console.log('error submit!!');
  484. return false;
  485. }
  486. });
  487. },
  488. handleDeleteAss(id){
  489. this.$confirm('此操作将永久删除该文件, 是否继续?', '提示', {
  490. confirmButtonText: '确定',
  491. cancelButtonText: '取消',
  492. type: 'warning'
  493. }).then(() => {
  494. return removeDataAssociation(id);
  495. }).then(() => {
  496. this.data_association(this.actkey)
  497. this.msgSuccess('删除成功')
  498. }).catch(() => {
  499. this.$message({
  500. type: 'info',
  501. message: '已取消删除'
  502. });
  503. });
  504. /* removeDataAssociation(id).then(response => {
  505. this.msgSuccess('删除成功');
  506. })*/
  507. },
  508. closeAddform(){
  509. this.dialogaddVisible=false;
  510. }
  511. }
  512. }
  513. </script>
  514. <!-- Add "scoped" attribute to limit CSS to this component only -->
  515. <style scoped>
  516. .el-aside{background: #fff;}
  517. h3 {
  518. margin: 40px 0 0;
  519. }
  520. ul {
  521. list-style-type: none;
  522. padding: 0;
  523. }
  524. li {
  525. display: inline-block;
  526. margin: 0 10px;
  527. }
  528. a {
  529. color: inherit;
  530. text-decoration: none;
  531. }
  532. body {
  533. background: #ffffff;
  534. padding: 10px;
  535. }
  536. .box {
  537. margin: 10px;
  538. }
  539. .el-aside {
  540. /*background-color: #D3DCE6;*/
  541. color: #333;
  542. border: 1px solid #e9e9e9;
  543. border-radius: 10px;
  544. }
  545. .title {
  546. line-height: 40px;
  547. border-bottom: 2px solid #e9e9e9;
  548. text-align: left;
  549. padding-left: 30px;
  550. }
  551. .left {
  552. width: 100%;
  553. /*height: 100%;*/
  554. }
  555. .left ul {
  556. min-height: 800px;
  557. height: 100%;
  558. }
  559. .left ul li {
  560. width: 80%;
  561. height: 50px;
  562. line-height: 50px;
  563. color: #2f4050;
  564. text-align: left;
  565. padding-left: 30px;
  566. }
  567. .left ul li:hover {
  568. color: #02a7f0;
  569. }
  570. .right {
  571. border: 1px solid #e9e9e9;
  572. margin-left: 20px;
  573. padding-top: 0;
  574. padding-left: 0;
  575. border-radius: 10px;
  576. padding-right: 0;
  577. }
  578. .dad {
  579. height: 75px;
  580. border-top: 1px solid #e9e9e9;
  581. border-bottom: 1px solid #e9e9e9;
  582. border-top: none;
  583. }
  584. .bgfff{background:#fff;padding:10px;}
  585. .dead {
  586. width: 100%;
  587. height: 500px;
  588. margin-top: 20px;
  589. border-top: 1px solid #e9e9e9;
  590. border-bottom: 1px solid #e9e9e9;
  591. }
  592. .left ul li[data-v-74afc76c]{
  593. padding-left: 20px;
  594. }
  595. .der {
  596. float: left;
  597. margin-bottom: 10px;
  598. }
  599. .der .el-button {
  600. margin-bottom: 10px;
  601. }
  602. .right{margin-left:10px;}
  603. .ddt {
  604. margin: 0 20px;
  605. }
  606. .el-icon-s-order{
  607. color:#bbbbbb;
  608. font-size: 22px;
  609. line-height: 1.2;
  610. }
  611. </style>