processManagement.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521
  1. <template>
  2. <div class="test_page">
  3. <!-- 下拉选择公司 -->
  4. <!-- <div class="company-select" v-if="companys !== '' && companys.length > 1">
  5. <el-dropdown
  6. trigger="click"
  7. @command="selectComPany"
  8. >
  9. <span class="el-dropdown-link">
  10. {{companyName}}<i class="el-icon-arrow-down el-icon--right"></i>
  11. </span>
  12. <el-dropdown-menu slot="dropdown">
  13. <div v-for="item in companys" :key="item.id">
  14. <el-dropdown-item :command="item">{{item.companyName}}</el-dropdown-item>
  15. </div>
  16. </el-dropdown-menu>
  17. </el-dropdown>
  18. </div> -->
  19. <div class="searchArea">
  20. <el-form
  21. v-model="searchForm"
  22. inline
  23. >
  24. <el-form-item prop="type">
  25. <el-select
  26. v-model="searchForm.type"
  27. size="small"
  28. clearable
  29. placeholder="流程类型">
  30. <el-option
  31. v-for="item in typeOptions"
  32. :key="item.index"
  33. :label="item.dictName"
  34. :value="item.dictName">
  35. </el-option>
  36. </el-select>
  37. </el-form-item>
  38. <el-form-item prop="processCnName">
  39. <el-input
  40. v-model="searchForm.name"
  41. size="small"
  42. placeholder="流程名称"
  43. clearable
  44. ></el-input>
  45. </el-form-item>
  46. <el-form-item prop="key">
  47. <el-input
  48. v-model="searchForm.key"
  49. size="small"
  50. placeholder="流程KEY"
  51. clearable
  52. ></el-input>
  53. </el-form-item>
  54. <el-form-item prop="status">
  55. <el-select
  56. v-model="searchForm.status"
  57. placeholder="流程状态"
  58. size="small"
  59. clearable>
  60. <el-option key="0" label="未部署" value="0"></el-option>
  61. <el-option key="1" label="已部署" value="1"></el-option>
  62. </el-select>
  63. </el-form-item>
  64. <el-form-item prop="bigestVersion">
  65. <el-checkbox v-model="searchForm.bigestVersion">查询最高版本</el-checkbox>
  66. </el-form-item>
  67. <el-form-item>
  68. <el-button
  69. type="primary"
  70. @click="searchData"
  71. size="small"
  72. v-privilege="activeMenu + 'QUERY'"
  73. icon="el-icon-search"
  74. >查询</el-button>
  75. <el-button
  76. type="primary"
  77. @click="refresh"
  78. size="small"
  79. v-privilege="activeMenu + 'QUERY'"
  80. icon="el-icon-refresh"
  81. >重置</el-button>
  82. <el-button
  83. type="primary"
  84. @click="goDesign('','add')"
  85. icon="el-icon-plus"
  86. size="small"
  87. v-privilege="activeMenu + 'ADD'"
  88. >新增流程</el-button>
  89. </el-form-item>
  90. </el-form>
  91. </div>
  92. <div class="tableArea">
  93. <el-table
  94. individual-columns="individual-vue-table-columns"
  95. :individual-info="individualInfo"
  96. drag-column="individual-vue-table"
  97. v-loading="tableLoading"
  98. ref="singleTable"
  99. :data="tableData"
  100. :height="tableHeight + 'px'"
  101. border
  102. class="yt-table-no-srcoll"
  103. highlight-current-row
  104. style="width: 100%"
  105. >
  106. <el-table-column
  107. width="80"
  108. type="index"
  109. label="序号"
  110. align="center">
  111. </el-table-column>
  112. <!-- tableKey表示为根据获取的tableData设置的header显示值列表 -->
  113. <el-table-column
  114. v-for ="(item, index) of tableKeys"
  115. :key="index"
  116. :label="item.label"
  117. :prop="item.key"
  118. :fixed="item.fixed"
  119. :width="item.width"
  120. header-align="center"
  121. align="center"
  122. sortable
  123. show-overflow-tooltip>
  124. <template slot-scope="scope">
  125. <span v-for="item in deployStatus" :key="item.value" :class="item.class" v-if="scope.column.property === 'status' && scope.row.status === item.value">
  126. {{item.label}}
  127. </span>
  128. <el-tag v-if="scope.column.property === 'version'" style="min-width: 56px;">v{{scope.row.version}}</el-tag>
  129. <span v-if="scope.column.property !== 'status' && scope.column.property !== 'version'">
  130. {{scope.row[scope.column.property]}}
  131. </span>
  132. </template>
  133. </el-table-column>
  134. <el-table-column
  135. label="操作"
  136. :show-overflow-tooltip="true"
  137. width="180"
  138. align="center"
  139. >
  140. <template slot-scope="scope">
  141. <el-button
  142. size="mini"
  143. @click="editRow(scope.row, 'publish')"
  144. :disabled="scope.row.status === '1'"
  145. v-privilege="activeMenu + 'PUBLISH'"
  146. >发布</el-button>
  147. <el-dropdown
  148. split-button
  149. size="mini"
  150. type="primary"
  151. trigger="click"
  152. @click="handleCommand([scope.row, 'edit'])"
  153. @command="handleCommand"
  154. style="margin-left: 3px;"
  155. v-privilege="activeMenu + 'PUT'"
  156. >
  157. 修改
  158. <el-dropdown-menu slot="dropdown">
  159. <el-dropdown-item
  160. :command="[scope.row, 'show']"
  161. v-privilege="activeMenu + 'LOOK'"
  162. >显示</el-dropdown-item>
  163. <el-dropdown-item
  164. :command="[scope.row, 'del']"
  165. v-privilege="activeMenu + 'DELETE'"
  166. >删除</el-dropdown-item>
  167. </el-dropdown-menu>
  168. </el-dropdown>
  169. <!-- <el-dropdown split-button size="mini" type="primary" trigger="click" @click="handleCommand([scope.row, 'show'])" style="margin-left: 3px;">
  170. 显示
  171. <el-dropdown-menu slot="dropdown">
  172. <el-dropdown-item :command="[scope.row, 'copy']">复制</el-dropdown-item>
  173. <el-dropdown-item :command="[scope.row, 'history']">历史版本</el-dropdown-item>
  174. </el-dropdown-menu>
  175. </el-dropdown> -->
  176. </template>
  177. </el-table-column>
  178. </el-table>
  179. </div>
  180. <div class="foot-style">
  181. <el-pagination
  182. @size-change="handleSizeChange"
  183. @current-change="handleCurrentChange"
  184. :current-page='pageIndex'
  185. :page-sizes="[10, 20, 30, 40, 100, 200]"
  186. :page-size='pageSize'
  187. layout="total, sizes, prev, pager, next, jumper"
  188. :total='total'
  189. >
  190. </el-pagination>
  191. </div>
  192. <icore-individual :uiId="activeMenu" indexClass="individual-index"></icore-individual>
  193. </div>
  194. </template>
  195. <script>
  196. import { checkCharLength, checkCharLength2, checkCharNoChinese, checkChar, checkChinese } from '@/utils/validator.js';
  197. import store from '@/store/index.js';
  198. export default {
  199. name: 'processManagement',
  200. data () {
  201. return {
  202. individualInfo: {},
  203. tableKeys: [],
  204. store,
  205. activeMenu: '',
  206. tableLoading: false, // 表格loading
  207. searchForm: {
  208. type: '',
  209. name: '',
  210. key: '',
  211. bigestVersion: true,
  212. queryType: '0',
  213. status: ''
  214. },
  215. deployStatus: [
  216. {
  217. value: '1',
  218. label: '● 已部署',
  219. class: 'green'
  220. }, {
  221. value: '0',
  222. label: '● 未部署',
  223. class: 'red'
  224. }
  225. ],
  226. tableData: [],
  227. tableHeight: 0,
  228. pageSize: 20,
  229. pageIndex: 1,
  230. total: 0,
  231. companys: [], // 公司数组
  232. companyId: '',
  233. companyName: '',
  234. scroll: 0, // 滚动条位置
  235. typeOptions: []
  236. }
  237. },
  238. watch: {
  239. 'searchForm.bigestVersion': {
  240. immediate: true,
  241. handler (n, o) {
  242. if (n === true) {
  243. this.searchForm.queryType = '0';
  244. } else {
  245. this.searchForm.queryType = '1';
  246. }
  247. }
  248. }
  249. },
  250. mounted: function () {
  251. this.$nextTick(() => {
  252. this.tableHeight = this.getTreeHeight(this.$refs['singleTable'].$el) - 80;
  253. })
  254. // 获取公司信息
  255. this.companys = JSON.parse(window.top.localStorage.getItem('companys'));
  256. this.companyId = window.top.localStorage.getItem('companyId');
  257. if (this.companyId !== '' && this.companyId !== null) {
  258. this.companyName = this.companys.find((x) => x.id === this.companyId).companyName;
  259. }
  260. this.searchData();
  261. this.getDictList();
  262. },
  263. // 操作成功刷新列表
  264. activated () {
  265. // 滚动条保持
  266. this.$nextTick(() => {
  267. setTimeout(() => {
  268. this.$refs.singleTable.bodyWrapper.scrollTop = this.scroll;
  269. }, 13)
  270. })
  271. if (this.$route.params.operate && this.$route.params.operate === 'success') {
  272. this.searchData();
  273. }
  274. },
  275. // 获取菜单页面id
  276. created () {
  277. this.activeMenu = window.top.localStorage.getItem('activeMenu');
  278. },
  279. methods: {
  280. // 计算树区域高度
  281. getTreeHeight (dom) {
  282. return window.innerHeight - dom.offsetTop;
  283. },
  284. editRow: function (row, type) {
  285. switch (type) {
  286. case 'edit':
  287. this.goDesign(row, 'edit');
  288. break;
  289. case 'del':
  290. this.delData(row);
  291. break;
  292. case 'publish':
  293. this.publish(row);
  294. break;
  295. case 'show':
  296. this.goDesign(row, 'show');
  297. // this.showRow(row);
  298. break;
  299. }
  300. },
  301. // 下拉菜单
  302. handleCommand (command) {
  303. this.editRow(command[0], command[1]);
  304. },
  305. // 获取数据字典中-流程类型数据
  306. getDictList () {
  307. this.axios.get('pass/v1/sysdicts/listDict?pDictId=PROCESS_TYPE&status=1&companyId=' + this.companyId).then((res) => {
  308. if (res.code === '0') {
  309. this.typeOptions = res.data.list;
  310. } else {
  311. this.$message.error(res.message)
  312. }
  313. }).catch((err) => {
  314. console.log(err)
  315. })
  316. },
  317. delData (row) {
  318. this.$confirm('确定要删除已选择的记录吗?确定请选是,取消选否。', '提示', {
  319. customClass: 'org-Manage-changeprimaryforbutton',
  320. confirmButtonText: '确定',
  321. cancelButtonText: '取消',
  322. type: 'warning'
  323. }).then(() => {
  324. this.axios.delete('pass/act/v1/actinformations/' + row.id).then(res => {
  325. if (res.code === '0') {
  326. this.$message.success('删除成功');
  327. this.searchData();
  328. } else {
  329. this.$message.error(res.message);
  330. }
  331. });
  332. }).catch(() => {
  333. this.$message.info('已取消操作');
  334. });
  335. },
  336. publish (row) {
  337. this.$confirm('确定要发布已选择的记录吗?确定请选是,取消选否。', '提示', {
  338. customClass: 'org-Manage-changeprimaryforbutton',
  339. confirmButtonText: '确定',
  340. cancelButtonText: '取消',
  341. type: 'warning'
  342. }).then(() => {
  343. this.axios.get('pass/act/v1/actinformations/deployTextProcess?id=' + row.id + '&companyId=' + this.companyId).then((res) => {
  344. let data = [];
  345. if (res.code === '0') {
  346. this.$message.success('部署成功');
  347. this.searchData();
  348. } else {
  349. this.$message.error(res.message);
  350. }
  351. }).catch((err) => {
  352. console.log(err);
  353. })
  354. }).catch(() => {
  355. this.$message.info('已取消操作');
  356. });
  357. },
  358. // 重置搜索
  359. refresh () {
  360. for (let item in this.searchForm) {
  361. this.searchForm[item] = ''
  362. }
  363. this.searchData();
  364. },
  365. // 搜索
  366. searchData () {
  367. let that = this,
  368. searchData = {
  369. type: this.searchForm.type,
  370. name: this.searchForm.name,
  371. key: this.searchForm.key,
  372. queryType: this.searchForm.queryType,
  373. status: this.searchForm.status
  374. };
  375. that.tableLoading = true;
  376. that.getActList(searchData);
  377. },
  378. handleCurrentChange (pageIndex) {
  379. this.pageIndex = pageIndex
  380. this.searchData();
  381. },
  382. handleSizeChange (pageSize) {
  383. // this.pageIndex = 1
  384. this.pageSize = pageSize;
  385. this.searchData()
  386. },
  387. getActList (data) {
  388. this.tableLoading = true;
  389. this.tableKeys = [
  390. {
  391. key: 'type',
  392. label: '流程类型',
  393. width: 'auto'
  394. },
  395. {
  396. key: 'name',
  397. label: '流程名称',
  398. width: 'auto'
  399. },
  400. {
  401. key: 'key',
  402. label: '流程Key',
  403. width: 'auto'
  404. },
  405. {
  406. key: 'version',
  407. label: '流程版本',
  408. width: 'auto'
  409. },
  410. {
  411. key: 'status',
  412. label: '部署状态',
  413. width: 'auto'
  414. },
  415. {
  416. key: 'crtDate',
  417. label: '创建日期',
  418. width: 'auto'
  419. }
  420. ]
  421. let url = data ? '&queryType=' + data.queryType : '';
  422. this.axios.get('pass/act/v1/actinformations/like/?pageNum=' + this.pageIndex + '&pageSize=' + this.pageSize + (data ? '&type=' + data.type + '&name=' + data.name + '&key=' + data.key + '&status=' + data.status : '') + '&companyId=' + this.companyId + url).then((res) => {
  423. let data = [];
  424. if (res.code === '0') {
  425. if (res.data.total >= 1) {
  426. for (let i = 0; i < res.data.list.length; i++) {
  427. let item = {};
  428. item.id = res.data.list[i].id;
  429. item.type = res.data.list[i].type;
  430. item.name = res.data.list[i].name;
  431. item.key = res.data.list[i].key;
  432. item.crtDate = res.data.list[i].crtDate;
  433. item.version = res.data.list[i].version;
  434. item.bpmnText = res.data.list[i].bpmnText;
  435. item.text = res.data.list[i].text;
  436. // item.text = decodeURIComponent(escape(res.data.list[i].text)); //base64解码
  437. item.status = res.data.list[i].status;
  438. // switch (res.data.list[i].status) {
  439. // case '0':
  440. // item.status = '未部署';
  441. // break
  442. // case '1':
  443. // item.status = '已部署';
  444. // break
  445. // }
  446. data.push(item);
  447. }
  448. }
  449. this.tableData = data;
  450. this.total = res.data.total;
  451. this.tableLoading = false;
  452. } else {
  453. this.$message.error(res.message);
  454. this.tableLoading = false;
  455. }
  456. }).catch((err) => {
  457. console.log(err);
  458. })
  459. },
  460. goDesign (item, status) {
  461. // 记住当前页面table滚动条位置
  462. let wrapperScrollTop = this.$refs.singleTable.bodyWrapper.scrollTop;
  463. this.scroll = wrapperScrollTop;
  464. let data = item ? JSON.stringify(item) : '';
  465. this.$router.push({ name: 'processDdesign2', query: { type: status, data: data || '', companyId: this.companyId } })
  466. },
  467. // 下拉选择公司
  468. selectComPany (command) {
  469. this.companyId = command.id;
  470. this.companyName = command.companyName;
  471. // 下拉选择了公司以后需要再重新调用下查询接口,重新获取数据
  472. this.getActList();
  473. }
  474. }
  475. }
  476. </script>
  477. <style lang="less" scoped>
  478. .test_page {
  479. padding: 15px;
  480. min-width: 1000px;
  481. position: relative;;
  482. .foot-style {
  483. margin: 5px 0 0;
  484. text-align: right;
  485. }
  486. .green {
  487. color: #67C23A;
  488. }
  489. .red {
  490. color: #F56C6C;
  491. }
  492. }
  493. .tableButton {
  494. margin-bottom: 10px;
  495. }
  496. .el-form {
  497. .lineFormItem {
  498. width: 20%;
  499. display: inline-block;
  500. margin: 0 1%;
  501. }
  502. .buttonFormItem {
  503. width: 7%;
  504. display: inline-block;
  505. }
  506. .el-select {
  507. width: 100%;
  508. }
  509. }
  510. .company-select {
  511. position: absolute;
  512. right: 20px;
  513. top: 28px;
  514. .el-dropdown {
  515. font-weight: bold;
  516. font-size: 14px;
  517. cursor: pointer;
  518. }
  519. }
  520. </style>