todoManage.vue 20 KB

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