WaitTab.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675
  1. <template>
  2. <div class="WaitTab">
  3. <!-- 无待办显示 -->
  4. <div class="waitTab_null" v-if="todoList.length == 0">
  5. <a-empty />
  6. </div>
  7. <!-- 待办列表 -->
  8. <div class="waitTabList">
  9. <a-card class="cardTask" v-for="item in todoList" :key="item.id">
  10. <p class="pTitle">
  11. <span>
  12. <img src="@assets/title.png" />
  13. </span>
  14. {{ item.processName }}
  15. </p>
  16. <p>
  17. 任务名称:
  18. <span style="color:black;">
  19. {{ item.name }}
  20. </span>
  21. </p>
  22. <p>
  23. 创建时间: <span style="color:black;">{{ item.createTime }}</span>
  24. </p>
  25. <!-- 优先级 -->
  26. <p>
  27. 优先级:
  28. <span class="priorityComm" v-if="item.priority == 0" style="background:rgba(252, 96, 10,.6);color:#092834;">
  29. 普通
  30. </span>
  31. <span class="priorityComm" v-else-if="item.priority == 1" style="background:rgba(255, 0, 0,.6);color:white;">
  32. 重要
  33. </span>
  34. <span class="priorityComm" v-else-if="item.priority == 2" style="background:rgba(255, 0, 0,.8);color:white;">
  35. 紧急
  36. </span>
  37. <span class="priorityComm" v-else style="background:#999;">
  38. </span>
  39. </p>
  40. <!-- 状态 -->
  41. <p style="float:left;marginBottom:30px;">
  42. 状态:
  43. <span v-if="item.isSuspended == false" style="background:rgba(252, 96, 10,.6)" class="resultComm">
  44. 已激活
  45. </span>
  46. <span v-if="item.isSuspended == true" style="background:rgba(20, 137, 184,.6)" class="resultComm">
  47. 已挂起
  48. </span>
  49. {{ item.status }}
  50. </p>
  51. <!-- 发起人 -->
  52. <p style="float:right;marginBottom:30px;">
  53. 发起人:
  54. <span style="color:black;">
  55. {{ item.applyer }}
  56. </span>
  57. </p>
  58. <a-divider style="background:rgba(70, 130, 180,.2);"></a-divider>
  59. <!-- 操作 -->
  60. <div class="operation">
  61. <!-- <p>
  62. <span class="operationImg"><img src="@assets/set.png"/></span>
  63. 操作
  64. </p> -->
  65. <div class="btns">
  66. <i class="itemBtn">
  67. <a-button ghost @click="detail(item)" style="box-shadow: 8px 8px 8px rgba(128, 128, 128);color:#4e73b9;">
  68. 申请详情
  69. </a-button>
  70. </i>
  71. <!-- 挂起 状态 按钮不可用 -->
  72. <span
  73. v-if="item.isSuspended == true"
  74. style="cursor: no-drop;color: #999999;"
  75. title="流程已被挂起,无法操作!"
  76. >
  77. <a-button class="itemBtn" disabled>通过</a-button>
  78. <a-button class="itemBtn" disabled>驳回</a-button>
  79. <a-button class="itemBtn" disabled>委托</a-button>
  80. </span>
  81. <!-- 激活 状态 -->
  82. <span v-else>
  83. <i class="itemBtn mid">
  84. <a-button
  85. ghost
  86. @click="passTask(item)"
  87. style="box-shadow: 8px 8px 8px rgba(128, 128, 128);color:#4e73b9;"
  88. >
  89. 通过
  90. </a-button>
  91. </i>
  92. <i class="itemBtn mid">
  93. <a-button
  94. ghost
  95. @click="backTask(item)"
  96. style="color:gray;box-shadow: 5px 5px 5px rgba(128, 128, 128,.8);color:#ea472c;"
  97. >
  98. 驳回
  99. </a-button>
  100. </i>
  101. <i class="itemBtn mid">
  102. <a-button
  103. ghost
  104. @click="delegateTask(item)"
  105. style="box-shadow:6px 6px 6px rgba(128, 128, 128,.7);color:orange;marginRight:0;"
  106. >
  107. 委托
  108. </a-button>
  109. </i>
  110. </span>
  111. <i class="itemBtn">
  112. <a-button ghost @click="history(item)" style="color:gray;box-shadow: 4px 4px 4px rgba(128, 128, 128);">
  113. 历史
  114. </a-button>
  115. </i>
  116. </div>
  117. </div>
  118. </a-card>
  119. <!--审批历史 -->
  120. <a-modal
  121. title="审批历史"
  122. v-model="modalLsVisible"
  123. :mask-closable="false"
  124. :width="'100%'"
  125. :footer="null"
  126. wrapClassName="hisModal"
  127. >
  128. <div v-if="modalLsVisible">
  129. <historyModal :procInstId="procInstId"></historyModal>
  130. </div>
  131. </a-modal>
  132. <!--流程表单-->
  133. <a-modal :title="lcModa.title" v-model="lcModa.visible" :footer="null" :maskClosable="false" width="100%">
  134. <component
  135. :disabled="lcModa.disabled"
  136. v-if="lcModa.visible"
  137. :is="lcModa.formComponent"
  138. :processData="lcModa.processData"
  139. :isNew="lcModa.isNew"
  140. @close=";(lcModa.visible = false), (lcModa.disabled = false)"
  141. @getDataList="getDataList"
  142. ></component>
  143. </a-modal>
  144. <!-- 通过、驳回、委托 弹框 -->
  145. <a-modal :title="modalTaskTitle" v-model="modalTaskVisible" :mask-closable="false" :width="500">
  146. <div v-if="modalTaskVisible">
  147. <a-form ref="form" :model="form" :label-width="85" :rules="formValidate">
  148. <a-form-item label="审批意见" prop="reason">
  149. <a-input type="textarea" v-model="form.comment" :rows="4" />
  150. </a-form-item>
  151. <a-form-item label="下一审批人" prop="assignees" v-show="showAssign" :error="error">
  152. <a-select v-model="form.assignees" placeholder="请选择" allowClear mode="multiple" :loading="userLoading">
  153. <a-select-option v-for="(item, i) in assigneeList" :key="i" :value="item.username">{{
  154. item.realname
  155. }}</a-select-option>
  156. </a-select>
  157. </a-form-item>
  158. <!-- 下一审批人 -->
  159. <a-form-item label="下一审批人" v-show="isGateway">
  160. <span>分支网关处暂不支持自定义选择下一审批人,将发送给下一节点所有人</span>
  161. </a-form-item>
  162. <!-- 驳回至 -->
  163. <div v-show="form.type == 1">
  164. <a-form-item label="驳回至">
  165. <a-select v-model="form.backTaskKey" :loading="backLoading" @change="changeBackTask">
  166. <a-select-option v-for="(item, i) in backList" :key="i" :value="item.key">{{
  167. item.name
  168. }}</a-select-option>
  169. </a-select>
  170. </a-form-item>
  171. <a-form-item label="指定原节点审批人" prop="assignees" v-show="form.backTaskKey != -1" :error="error">
  172. <a-select
  173. v-model="form.assignees"
  174. placeholder="请选择"
  175. allowClear
  176. mode="multiple"
  177. :loading="userLoading"
  178. >
  179. <a-select-option v-for="(item, i) in assigneeList" :key="i" :value="item.id">{{
  180. item.username
  181. }}</a-select-option>
  182. </a-select>
  183. </a-form-item>
  184. </div>
  185. <!-- 选择委托人 -->
  186. <a-form-item label="选择委托人" prop="userId" :error="error" v-show="form.type == 2">
  187. <selectPerson v-model="form.userId" :multi="false"></selectPerson>
  188. </a-form-item>
  189. <a-form-item label="消息通知">
  190. <a-checkbox v-model="form.sendMessage">站内消息通知</a-checkbox>
  191. <a-checkbox v-model="form.sendSms" disabled>短信通知</a-checkbox>
  192. <a-checkbox v-model="form.sendEmail" disabled>邮件通知</a-checkbox>
  193. </a-form-item>
  194. </a-form>
  195. </div>
  196. <!-- 弹框提交 -->
  197. <div slot="footer">
  198. <a-button type="text" @click="modalTaskVisible = false">取消</a-button>
  199. <a-button type="primary" :loading="submitLoading" @click="handelSubmit">提交</a-button>
  200. </div>
  201. </a-modal>
  202. </div>
  203. </div>
  204. </template>
  205. <script>
  206. import HistoryModal from '@views/user/tabs/HistoryModal'
  207. import SelectPerson from '@views/user/tabs/SelectPerson'
  208. import { deleteAction, getAction, down01File } from '@/api/manage'
  209. import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  210. import { activitiMixin } from '@/views/activiti/mixins/activitiMixin'
  211. import JSelectUserByDep from '@/components/jeecgbiz/JSelectUserByDep'
  212. export default {
  213. name: 'WaitTab',
  214. mixins: [activitiMixin, JeecgListMixin],
  215. components: { JSelectUserByDep, HistoryModal, SelectPerson },
  216. data() {
  217. return {
  218. todoList: [], // 待办列表
  219. openSearch: true,
  220. openTip: true,
  221. loading: true, // 表单加载状态
  222. modalTaskVisible: false,
  223. userLoading: false,
  224. backLoading: false,
  225. selectCount: 0, // 多选计数
  226. selectList: [], // 多选数据
  227. assigneeList: [],
  228. backList: [
  229. {
  230. key: '-1',
  231. name: '发起人'
  232. }
  233. ],
  234. error: '',
  235. showAssign: false,
  236. searchForm: {
  237. // 搜索框对应data对象
  238. name: ''
  239. },
  240. modalTaskTitle: '',
  241. modalTitle: '', // 添加或编辑标题
  242. form: {
  243. id: '',
  244. userId: '',
  245. procInstId: '',
  246. comment: '',
  247. type: 0,
  248. assignees: [],
  249. backTaskKey: '-1',
  250. sendMessage: true,
  251. sendSms: false,
  252. sendEmail: false
  253. },
  254. formValidate: {
  255. // 表单验证规则
  256. },
  257. submitLoading: false, // 添加或编辑提交状态
  258. data: [], // 表单数据
  259. total: 0, // 表单数据总数
  260. dictPriority: [],
  261. isGateway: false,
  262. lcModa: {
  263. title: '',
  264. disabled: false,
  265. visible: false,
  266. formComponent: null,
  267. isNew: false
  268. },
  269. url: {
  270. todoList: '/actTask/todoList',
  271. pass: '/actTask/pass',
  272. back: '/actTask/back',
  273. backToTask: '/actTask/backToTask',
  274. delegate: '/actTask/delegate',
  275. getNextNode: '/activiti_process/getNextNode',
  276. getNode: '/activiti_process/getNode/',
  277. getBackList: '/actTask/getBackList/',
  278. passAll: '/actTask/passAll/',
  279. backAll: '/actTask/backAll/'
  280. },
  281. /*历史*/
  282. modalLsVisible: false,
  283. procInstId: '' //点击历史的该项
  284. }
  285. },
  286. mounted() {
  287. this.init()
  288. },
  289. methods: {
  290. //初始化表单
  291. forminitial() {
  292. this.form = {
  293. id: '',
  294. userId: '',
  295. procInstId: '',
  296. comment: '',
  297. type: 0,
  298. assignees: [],
  299. backTaskKey: '-1',
  300. sendMessage: true,
  301. sendSms: false,
  302. sendEmail: false
  303. }
  304. },
  305. //
  306. init() {
  307. this.getDataList()
  308. },
  309. loadData() {},
  310. //发请求拿到 todoList
  311. getDataList() {
  312. this.loading = true
  313. getAction(this.url.todoList, {}).then(res => {
  314. if (res.success) {
  315. this.todoList = res.result || []
  316. // this.total = this.data.leading
  317. console.log('2次 waitTab 待办列表', this.todoList)
  318. }
  319. })
  320. },
  321. //分页、排序、筛选变化时触发
  322. handleTableChange(pagination, filters, sorter) {
  323. if (Object.keys(sorter).length > 0) {
  324. this.isorter.column = sorter.field
  325. this.isorter.order = 'ascend' == sorter.order ? 'asc' : 'desc'
  326. }
  327. this.ipagination = pagination
  328. this.loadData()
  329. },
  330. //
  331. handleSearch() {
  332. this.getDataList()
  333. },
  334. //
  335. handleReset() {
  336. this.searchForm = {}
  337. // 重新加载数据
  338. this.getDataList()
  339. },
  340. //
  341. showSelect(e) {
  342. this.selectList = e
  343. this.selectCount = e.length
  344. },
  345. //
  346. clearSelectAll() {
  347. this.$refs.table.selectAll(false)
  348. },
  349. // 提交
  350. handelSubmit() {
  351. console.log('提交')
  352. this.submitLoading = true
  353. var formData = Object.assign({}, this.form)
  354. formData.assignees = formData.assignees.join(',')
  355. if (formData.type == 0) {
  356. // 通过
  357. if (this.showAssign && formData.assignees.length < 1) {
  358. this.$message.error('请至少选择一个审批人')
  359. this.submitLoading = false
  360. return
  361. } else {
  362. this.error = ''
  363. }
  364. this.postFormAction(this.url.pass, formData).then(res => {
  365. this.submitLoading = false
  366. if (res.success) {
  367. this.$message.success('操作成功')
  368. this.modalTaskVisible = false
  369. this.getDataList()
  370. }
  371. })
  372. } else if (formData.type == 1) {
  373. // 驳回
  374. if (formData.backTaskKey == '-1') {
  375. // 驳回至发起人
  376. this.postFormAction(this.url.back, formData).then(res => {
  377. this.submitLoading = false
  378. if (res.success) {
  379. this.$message.success('操作成功')
  380. this.modalTaskVisible = false
  381. this.getDataList()
  382. }
  383. })
  384. } else {
  385. // 自定义驳回
  386. if (formData.backTaskKey != '-1' && formData.assignees.length < 1) {
  387. this.$message.error('请至少选择一个审批人')
  388. this.submitLoading = false
  389. return
  390. } else {
  391. this.error = ''
  392. }
  393. this.postFormAction(this.url.backToTask, formData).then(res => {
  394. this.submitLoading = false
  395. if (res.success) {
  396. this.$message.success('操作成功')
  397. this.modalTaskVisible = false
  398. this.getDataList()
  399. }
  400. })
  401. }
  402. } else if (formData.type == 2) {
  403. // 委托
  404. if (!formData.userId) {
  405. this.$message.error('请选择一委托人')
  406. this.submitLoading = false
  407. return
  408. } else {
  409. this.error = ''
  410. }
  411. this.postFormAction(this.url.delegate, formData).then(res => {
  412. this.submitLoading = false
  413. if (res.success) {
  414. this.$message.success('操作成功')
  415. this.modalTaskVisible = false
  416. this.getDataList()
  417. }
  418. })
  419. }
  420. },
  421. // 详情
  422. detail(r) {
  423. if (!r.routeName) {
  424. this.$message.warning('该流程信息未配置表单,请联系开发人员!')
  425. return
  426. }
  427. r.operationType = '1' //代办
  428. if (r.routeName.indexOf('外部表单') != -1) {
  429. //其他项目的表单流程
  430. alert('调用其他项目页面')
  431. } else if (r.routeName.indexOf('自定义') != -1) {
  432. //自定义的表单流程
  433. this.lcModa.disabled = true
  434. this.lcModa.title = '查看流程业务信息:' + r.processName
  435. let com = { component: () => import(`@/views/activiti/form/demoForm2`) }
  436. this.lcModa.formComponent = com.component
  437. this.lcModa.isNew = false
  438. this.lcModa.processData = r
  439. this.lcModa.visible = true
  440. } else {
  441. //固定的表单流程
  442. this.lcModa.disabled = true
  443. this.lcModa.title = '查看流程业务信息:' + r.processName
  444. this.lcModa.formComponent = this.getFormComponent(r.routeName).component
  445. this.lcModa.processData = r
  446. this.lcModa.isNew = false
  447. this.lcModa.visible = true
  448. }
  449. },
  450. // 通过
  451. passTask(v) {
  452. this.forminitial()
  453. this.modalTaskTitle = '审批通过'
  454. this.form.id = v.id
  455. this.form.procInstId = v.procInstId
  456. this.form.priority = v.priority
  457. this.form.type = 0
  458. this.modalTaskVisible = true
  459. this.userLoading = true
  460. this.getAction(this.url.getNextNode, { procDefId: v.procDefId, currActId: v.key, procInstId: v.procInstId }).then(
  461. res => {
  462. this.userLoading = false
  463. if (res.success) {
  464. if (res.result.type == 3 || res.result.type == 4) {
  465. this.isGateway = true
  466. this.showAssign = false
  467. this.error = ''
  468. return
  469. }
  470. this.isGateway = false
  471. if (res.result.users && res.result.users.length > 0) {
  472. this.error = ''
  473. this.assigneeList = res.result.users
  474. // 默认勾选
  475. let ids = []
  476. res.result.users.forEach(e => {
  477. ids.push(e.username)
  478. })
  479. this.form.assignees = ids
  480. this.showAssign = true
  481. } else {
  482. this.form.assignees = []
  483. this.showAssign = false
  484. }
  485. }
  486. }
  487. )
  488. },
  489. //
  490. changeBackTask(v) {
  491. if (v == '-1') {
  492. return
  493. }
  494. this.userLoading = true
  495. this.getAction(this.url.getNode + v + '&' + this.form.procInstId).then(res => {
  496. this.userLoading = false
  497. if (res.success) {
  498. if (res.result.users && res.result.users.length > 0) {
  499. this.assigneeList = res.result.users
  500. // 默认勾选
  501. let ids = []
  502. res.result.users.forEach(e => {
  503. ids.push(e.username)
  504. })
  505. this.form.assignees = ids
  506. }
  507. }
  508. })
  509. },
  510. // 驳回
  511. backTask(v) {
  512. this.forminitial()
  513. this.modalTaskTitle = '审批驳回'
  514. this.form.id = v.id
  515. this.form.procInstId = v.procInstId
  516. this.form.procDefId = v.procDefId
  517. this.form.priority = v.priority
  518. this.form.type = 1
  519. this.showAssign = false
  520. this.modalTaskVisible = true
  521. // 获取可驳回节点
  522. this.backList = [
  523. {
  524. key: '-1',
  525. name: '发起人'
  526. }
  527. ]
  528. this.form.backTaskKey = '-1'
  529. this.backLoading = true
  530. this.getAction(this.url.getBackList + v.procInstId).then(res => {
  531. this.backLoading = false
  532. if (res.success) {
  533. res.result.forEach(e => {
  534. this.backList.push(e)
  535. })
  536. }
  537. })
  538. },
  539. // 委托
  540. delegateTask(v) {
  541. this.forminitial()
  542. this.modalTaskTitle = '委托他人代办'
  543. this.form.id = v.id
  544. this.form.procInstId = v.procInstId
  545. this.form.type = 2
  546. this.showAssign = false
  547. this.modalTaskVisible = true
  548. },
  549. // 历史
  550. history(v) {
  551. if (v.procInstId) {
  552. this.procInstId = v.procInstId
  553. this.modalLsVisible = true
  554. console.log('开开心心走到这,拿到该项procInstId:', v.procInstId)
  555. } else {
  556. this.$message.error('流程实例ID不存在')
  557. return
  558. }
  559. },
  560. //
  561. passAll() {
  562. if (this.selectCount <= 0) {
  563. this.$message.warning('您还未选择要通过的数据')
  564. return
  565. }
  566. // 批量通过
  567. this.modalVisible = true
  568. this.$confirm({
  569. title: '确认通过',
  570. content: '您确认要通过所选的 ' + this.selectCount + ' 条数据? 注意:将默认分配给节点设定的所有可审批用户',
  571. loading: true,
  572. onOk: () => {
  573. let ids = ''
  574. this.selectList.forEach(function(e) {
  575. ids += e.id + ','
  576. })
  577. ids = ids.substring(0, ids.length - 1)
  578. this.postFormAction(this.url.passAll, { ids: ids }).then(res => {
  579. if (res.success) {
  580. this.$message.success('操作成功')
  581. this.modalVisible = false
  582. this.clearSelectAll()
  583. this.getDataList()
  584. }
  585. })
  586. }
  587. })
  588. },
  589. //
  590. backAll() {
  591. if (this.selectCount <= 0) {
  592. this.$message.warning('您还未选择要驳回的数据')
  593. return
  594. }
  595. // 批量驳回
  596. this.modalVisible = true
  597. this.$confirm({
  598. title: '确认驳回',
  599. content: '您确认要驳回所选的 ' + this.selectCount + ' 条数据? 注意:所有流程将驳回至发起人',
  600. loading: true,
  601. onOk: () => {
  602. let procInstIds = ''
  603. this.selectList.forEach(function(e) {
  604. procInstIds += e.procInstId + ','
  605. })
  606. procInstIds = procInstIds.substring(0, procInstIds.length - 1)
  607. this.postFormAction(this.url.backAll, { procInstIds: procInstIds }).then(res => {
  608. if (res.success) {
  609. this.$message.success('操作成功')
  610. this.modalVisible = false
  611. this.clearSelectAll()
  612. this.getDataList()
  613. }
  614. })
  615. }
  616. })
  617. }
  618. }
  619. }
  620. </script>
  621. <style src="@assets/less/overwrite.less" lang="less" scoped></style>
  622. <style lang="less">
  623. @import '~@assets/less/common.less';
  624. </style>
  625. <style lang="less" scoped>
  626. .btns {
  627. // 两行按钮样式
  628. .itemBtn {
  629. display: inline-block;
  630. padding: 0 12px;
  631. font-weight: 700 !important;
  632. margin-bottom: 30px;
  633. }
  634. }
  635. </style>