综合办公系统
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

index.vue 20KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536
  1. <template>
  2. <div class="app-container">
  3. <el-card class="box-card">
  4. <div slot="header" class="clearfix">
  5. <span class="el-icon-document">待办任务</span>
  6. <el-tag style="margin-left:10px">发起人:{{ startUser }}</el-tag>
  7. <el-tag>任务节点:{{ taskName }}</el-tag>
  8. <el-button style="float: right;" size="mini" type="danger" @click="goBack">关闭</el-button>
  9. </div>
  10. <el-tabs tab-position="top" v-model="activeName" @tab-click="handleClick">
  11. <!--表单信息-->
  12. <!-- <el-tab-pane label="表单信息" name="1">
  13. <el-col :span="16" :offset="4">
  14. <div class="test-form">
  15. <parser :key="new Date().getTime()" :form-conf="variablesData"/>
  16. <parser :key="new Date().getTime()" :form-conf="variablesData" @submit="submitForm" ref="parser" />
  17. </div>
  18. <div style="margin-left:15%;margin-bottom: 20px;font-size: 14px;">
  19. <el-button v-if="!formKeyExist" icon="el-icon-edit-outline" type="success" size="mini"
  20. @click="handleComplete">审批
  21. </el-button>
  22. <el-button icon="el-icon-edit-outline" type="primary" size="mini" @click="handleDelegate">委派</el-button>
  23. <el-button icon="el-icon-edit-outline" type="primary" size="mini" @click="handleAssign">转办</el-button>
  24. <el-button icon="el-icon-edit-outline" type="primary" size="mini" @click="handleDelegate">签收</el-button>
  25. <el-button icon="el-icon-refresh-left" type="warning" size="mini" @click="handleReturn">退回</el-button>
  26. <el-button icon="el-icon-circle-close" type="danger" size="mini" @click="handleReject">驳回</el-button>
  27. </div>
  28. </el-col>
  29. </el-tab-pane> -->
  30. <el-tab-pane label="表单信息" name="1">
  31. <ScTable :tableForm="tableForm"></ScTable>
  32. <el-button v-if="!formKeyExist" icon="el-icon-edit-outline" type="success" size="mini"
  33. @click="handleComplete">审批
  34. </el-button>
  35. <el-button icon="el-icon-refresh-left" type="warning" size="mini" @click="handleReturn">退回</el-button>
  36. <el-button icon="el-icon-circle-close" type="danger" size="mini" @click="handleReject">驳回</el-button>
  37. </el-tab-pane>
  38. <!--流程流转记录-->
  39. <el-tab-pane label="流转记录" name="2">
  40. <!--flowRecordList-->
  41. <el-col :span="16" :offset="4">
  42. <div class="block">
  43. <el-timeline>
  44. <el-timeline-item v-for="(item, index ) in flowRecordList" :key="index" :icon="setIcon(item.finishTime)"
  45. :color="setColor(item.finishTime)">
  46. <p style="font-weight: 700">{{ item.taskName }}</p>
  47. <el-card :body-style="{ padding: '10px' }">
  48. <el-descriptions class="margin-top" :column="1" size="small" border>
  49. <el-descriptions-item v-if="item.assigneeName" label-class-name="my-label">
  50. <template slot="label"><i class="el-icon-user"></i>办理人</template>
  51. {{ item.assigneeName }}
  52. <el-tag type="info" size="mini">{{ item.deptName }}</el-tag>
  53. </el-descriptions-item>
  54. <el-descriptions-item v-if="item.candidate" label-class-name="my-label">
  55. <template slot="label"><i class="el-icon-user"></i>候选办理</template>
  56. {{ item.candidate }}
  57. </el-descriptions-item>
  58. <el-descriptions-item label-class-name="my-label">
  59. <template slot="label"><i class="el-icon-date"></i>接收时间</template>
  60. {{ item.createTime }}
  61. </el-descriptions-item>
  62. <el-descriptions-item v-if="item.finishTime" label-class-name="my-label">
  63. <template slot="label"><i class="el-icon-date"></i>处理时间</template>
  64. {{ item.finishTime }}
  65. </el-descriptions-item>
  66. <el-descriptions-item v-if="item.duration" label-class-name="my-label">
  67. <template slot="label"><i class="el-icon-time"></i>耗时</template>
  68. {{ item.duration }}
  69. </el-descriptions-item>
  70. <el-descriptions-item v-if="item.comment" label-class-name="my-label">
  71. <template slot="label"><i class="el-icon-tickets"></i>处理意见</template>
  72. {{ item.comment }}
  73. </el-descriptions-item>
  74. </el-descriptions>
  75. </el-card>
  76. </el-timeline-item>
  77. </el-timeline>
  78. </div>
  79. </el-col>
  80. </el-tab-pane>
  81. <!--流程图-->
  82. <el-tab-pane label="流程图" name="3">
  83. <flow :flowData="flowData" />
  84. </el-tab-pane>
  85. </el-tabs>
  86. <!--审批任务-->
  87. <el-dialog :title="completeTitle" :visible.sync="completeOpen" width="60%" append-to-body>
  88. <el-form ref="taskForm" :model="taskForm">
  89. <el-form-item prop="targetKey">
  90. <flow-user v-if="checkSendUser" :checkType="checkType" @handleUserSelect="handleUserSelect"></flow-user>
  91. <flow-role v-if="checkSendRole" @handleRoleSelect="handleRoleSelect"></flow-role>
  92. </el-form-item>
  93. <el-form-item label="熟练程度" label-width="80px" prop="comment">
  94. <el-checkbox v-model="taskForm.check">备选项</el-checkbox>
  95. </el-form-item>
  96. <el-form-item label="处理意见" label-width="80px" prop="comment"
  97. :rules="[{ required: true, message: '请输入处理意见', trigger: 'blur' }]">
  98. <el-input type="textarea" v-model="taskForm.comment" placeholder="请输入处理意见" />
  99. </el-form-item>
  100. </el-form>
  101. <span slot="footer" class="dialog-footer">
  102. <el-button @click="completeOpen = false">取 消</el-button>
  103. <el-button type="primary" @click="taskComplete">确 定</el-button>
  104. </span>
  105. </el-dialog>
  106. <!--退回流程-->
  107. <el-dialog :title="returnTitle" :visible.sync="returnOpen" width="40%" append-to-body>
  108. <el-form ref="taskForm" :model="taskForm" label-width="80px">
  109. <el-form-item label="退回节点" prop="targetKey">
  110. <el-radio-group v-model="taskForm.targetKey">
  111. <el-radio-button v-for="item in returnTaskList" :key="item.id" :label="item.id">{{ item.name }}
  112. </el-radio-button>
  113. </el-radio-group>
  114. </el-form-item>
  115. <el-form-item label="退回意见" prop="comment" :rules="[{ required: true, message: '请输入意见', trigger: 'blur' }]">
  116. <el-input style="width: 50%" type="textarea" v-model="taskForm.comment" placeholder="请输入意见" />
  117. </el-form-item>
  118. </el-form>
  119. <span slot="footer" class="dialog-footer">
  120. <el-button @click="returnOpen = false">取 消</el-button>
  121. <el-button type="primary" @click="taskReturn">确 定</el-button>
  122. </span>
  123. </el-dialog>
  124. <!--驳回流程-->
  125. <el-dialog :title="rejectTitle" :visible.sync="rejectOpen" width="40%" append-to-body>
  126. <el-form ref="taskForm" :model="taskForm" label-width="80px">
  127. <el-form-item label="驳回意见" prop="comment" :rules="[{ required: true, message: '请输入意见', trigger: 'blur' }]">
  128. <el-input style="width: 50%" type="textarea" v-model="taskForm.comment" placeholder="请输入意见" />
  129. </el-form-item>
  130. </el-form>
  131. <span slot="footer" class="dialog-footer">
  132. <el-button @click="rejectOpen = false">取 消</el-button>
  133. <el-button type="primary" @click="taskReject">确 定</el-button>
  134. </span>
  135. </el-dialog>
  136. </el-card>
  137. </div>
  138. </template>
  139. <script>
  140. import { flowRecord } from "@/api/flowable/finished";
  141. import FlowUser from '@/components/flow/User'
  142. import FlowRole from '@/components/flow/Role'
  143. import Parser from '@/components/parser/Parser'
  144. import { getProcessVariables, flowXmlAndNode, definitionStart } from "@/api/flowable/definition";
  145. import {
  146. complete,
  147. rejectTask,
  148. returnList,
  149. returnTask,
  150. getNextFlowNode,
  151. delegate,
  152. flowTaskForm,
  153. checkIsStartUserNode
  154. } from "@/api/flowable/todo";
  155. import { getAssess } from '@/api/oa/assess/assess'
  156. import flow from '@/views/flowable/task/todo/detail/flow'
  157. import "@riophae/vue-treeselect/dist/vue-treeselect.css";
  158. import { listUser } from "@/api/system/user";
  159. import ScTable from "../../../form/scTable.vue";
  160. export default {
  161. name: "Record",
  162. components: {
  163. Parser,
  164. flow,
  165. FlowUser,
  166. FlowRole,
  167. ScTable
  168. },
  169. props: {},
  170. data() {
  171. return {
  172. // 模型xml数据
  173. xmlData: "",
  174. flowData: {},
  175. activeName: '1',
  176. // 部门名称
  177. deptName: undefined,
  178. // 部门树选项
  179. // 用户表格数据
  180. userList: null,
  181. defaultProps: {
  182. children: "children",
  183. label: "label"
  184. },
  185. // 查询参数
  186. queryParams: {
  187. deptId: undefined
  188. },
  189. // 遮罩层
  190. loading: true,
  191. flowRecordList: [], // 流程流转数据
  192. formConfCopy: {},
  193. src: null,
  194. rules: {}, // 表单校验
  195. variablesForm: {}, // 流程变量数据
  196. taskForm: {
  197. returnTaskShow: false, // 是否展示回退表单
  198. delegateTaskShow: false, // 是否展示回退表单
  199. defaultTaskShow: true, // 默认处理
  200. comment: "", // 意见内容
  201. procInsId: "", // 流程实例编号
  202. instanceId: "", // 流程实例编号
  203. deployId: "", // 流程定义编号
  204. taskId: "",// 流程任务编号
  205. procDefId: "", // 流程编号
  206. targetKey: "",
  207. variables: {
  208. variables: {}
  209. },
  210. check: true
  211. },
  212. assignee: null,
  213. formConf: {}, // 默认表单数据
  214. variables: [], // 流程变量数据
  215. variablesData: {}, // 流程变量数据
  216. returnTaskList: [], // 回退列表数据
  217. completeTitle: null,
  218. completeOpen: false,
  219. returnTitle: null,
  220. returnOpen: false,
  221. rejectOpen: false,
  222. rejectTitle: null,
  223. userData: [],
  224. checkSendUser: false, // 是否展示人员选择模块
  225. checkSendRole: false,// 是否展示角色选择模块
  226. checkType: 'single', // 选择类型
  227. taskName: null, // 任务节点
  228. startUser: null, // 发起人信息,
  229. multiInstanceVars: '', // 会签节点
  230. formKeyExist: false, // 当前节点是否存在表单
  231. // 表单信息
  232. tableForm: {}
  233. };
  234. },
  235. created() {
  236. if (this.$route.query) {
  237. this.taskName = this.$route.query.taskName;
  238. this.startUser = this.$route.query.startUser;
  239. this.taskForm.deployId = this.$route.query.deployId;
  240. this.taskForm.taskId = this.$route.query.taskId;
  241. this.taskForm.procInsId = this.$route.query.procInsId;
  242. this.taskForm.executionId = this.$route.query.executionId;
  243. this.taskForm.instanceId = this.$route.query.procInsId;
  244. this.taskForm.formId = this.$route.query.formId;
  245. // 流程任务获取变量信息
  246. if (this.taskForm.taskId) {
  247. this.processVariables(this.taskForm.taskId)
  248. this.getFlowTaskForm(this.taskForm.taskId)
  249. this.getAssessByAssessId(this.taskForm.formId)
  250. }
  251. this.getFlowRecordList(this.taskForm.procInsId, this.taskForm.deployId);
  252. }
  253. },
  254. methods: {
  255. handleClick(tab, event) {
  256. if (tab.name === '3') {
  257. flowXmlAndNode({ procInsId: this.taskForm.procInsId, deployId: this.taskForm.deployId }).then(res => {
  258. this.flowData = res.data;
  259. })
  260. }
  261. },
  262. setIcon(val) {
  263. if (val) {
  264. return "el-icon-check";
  265. } else {
  266. return "el-icon-time";
  267. }
  268. },
  269. setColor(val) {
  270. if (val) {
  271. return "#2bc418";
  272. } else {
  273. return "#b3bdbb";
  274. }
  275. },
  276. // 用户信息选中数据
  277. handleUserSelect(selection) {
  278. if (selection) {
  279. if (selection instanceof Array) {
  280. const selectVal = selection.map(item => item.userId);
  281. if (this.multiInstanceVars) {
  282. this.$set(this.taskForm.variables, this.multiInstanceVars, selectVal);
  283. } else {
  284. this.$set(this.taskForm.variables, "approval", selectVal.join(','));
  285. }
  286. } else {
  287. this.$set(this.taskForm.variables, "approval", selection.userId.toString());
  288. }
  289. }
  290. },
  291. // 角色信息选中数据
  292. handleRoleSelect(selection) {
  293. if (selection) {
  294. if (selection instanceof Array) {
  295. const selectVal = selection.map(item => item.roleId);
  296. this.$set(this.taskForm.variables, "approval", selectVal.join(','));
  297. } else {
  298. this.$set(this.taskForm.variables, "approval", selection);
  299. }
  300. }
  301. },
  302. /** 流程流转记录 */
  303. getFlowRecordList(procInsId, deployId) {
  304. const that = this
  305. const params = { procInsId: procInsId, deployId: deployId }
  306. flowRecord(params).then(res => {
  307. that.flowRecordList = res.data.flowList;
  308. }).catch(res => {
  309. this.goBack();
  310. })
  311. },
  312. fillFormData(form, data) {
  313. form.fields.forEach(item => {
  314. const val = data[item.__vModel__]
  315. if (val) {
  316. item.__config__.defaultValue = val
  317. }
  318. })
  319. },
  320. /** 获取流程变量内容 */
  321. processVariables(taskId) {
  322. if (taskId) {
  323. // 提交流程申请时填写的表单存入了流程变量中后续任务处理时需要展示
  324. getProcessVariables(taskId).then(res => {
  325. // this.variablesData = res.data.variables;
  326. });
  327. }
  328. },
  329. /** 流程节点表单 */
  330. getFlowTaskForm(taskId) {
  331. if (taskId) {
  332. // 提交流程申请时填写的表单存入了流程变量中后续任务处理时需要展示
  333. flowTaskForm({ taskId: taskId }).then(res => {
  334. this.variablesData = res.data.formData;
  335. this.taskForm.variables = res.data.formData;
  336. this.formKeyExist = res.data.formKeyExist;
  337. });
  338. }
  339. },
  340. // 获取需要处理的表单表格信息
  341. getAssessByAssessId(formId) {
  342. getAssess(formId ).then(res => {
  343. let data = res.data;
  344. for(let d in data){
  345. if(d.includes('role') || d.includes('familiar')){
  346. data[d] = data[d].split(',')
  347. }
  348. }
  349. this.tableForm = data;
  350. console.log(data);
  351. })
  352. },
  353. /** 加载审批任务弹框 */
  354. handleComplete() {
  355. // this.completeOpen = true;
  356. // this.completeTitle = "流程审批";
  357. this.submitForm(null);
  358. },
  359. /** 用户审批任务 */
  360. taskComplete() {
  361. this.$set(this.taskForm.variables, "pass", "通过");
  362. if (!this.taskForm.variables && this.checkSendUser) {
  363. this.$modal.msgError("请选择流程接收人员!");
  364. return;
  365. }
  366. if (!this.taskForm.variables && this.checkSendRole) {
  367. this.$modal.msgError("请选择流程接收角色组!");
  368. return;
  369. }
  370. if (!this.taskForm.comment) {
  371. this.$modal.msgError("请输入审批意见!");
  372. return;
  373. }
  374. if (this.taskForm && this.formKeyExist) {
  375. // 表单是否禁用
  376. this.taskForm.formData.formData.disabled = true;
  377. // 是否显示按钮
  378. this.taskForm.formData.formData.formBtns = false;
  379. this.taskForm.variables = Object.assign({}, this.taskForm.variables, this.taskForm.formData.valData);
  380. this.taskForm.variables.variables = this.taskForm.formData.formData;
  381. complete(this.taskForm).then(response => {
  382. this.$modal.msgSuccess(response.msg);
  383. this.goBack();
  384. });
  385. } else {
  386. // 流程设计人员类型配置为固定人员接收任务时,直接提交任务到下一步
  387. complete(this.taskForm).then(response => {
  388. this.$modal.msgSuccess(response.msg);
  389. this.goBack();
  390. });
  391. }
  392. },
  393. /** 委派任务 */
  394. handleDelegate() {
  395. this.taskForm.delegateTaskShow = true;
  396. this.taskForm.defaultTaskShow = false;
  397. },
  398. handleAssign() {
  399. },
  400. /** 返回页面 */
  401. goBack() {
  402. // 关闭当前标签页并返回上个页面
  403. const obj = { path: "/task/todo", query: { t: Date.now() } };
  404. this.$tab.closeOpenPage(obj);
  405. },
  406. /** 驳回任务 */
  407. handleReject() {
  408. this.rejectOpen = true;
  409. this.rejectTitle = "驳回流程";
  410. },
  411. /** 驳回任务 */
  412. taskReject() {
  413. this.$set(this.taskForm.variables, "pass", "驳回");
  414. complete(this.taskForm).then(response => {
  415. this.$modal.msgSuccess(response.msg);
  416. this.goBack();
  417. });
  418. // this.$refs["taskForm"].validate(valid => {
  419. // if (valid) {
  420. // rejectTask(this.taskForm).then(res => {
  421. // this.$modal.msgSuccess(res.msg);
  422. // this.goBack();
  423. // });
  424. // }
  425. // });
  426. },
  427. /** 可退回任务列表 */
  428. handleReturn() {
  429. this.returnOpen = true;
  430. this.returnTitle = "退回流程";
  431. returnList(this.taskForm).then(res => {
  432. this.returnTaskList = res.data;
  433. this.taskForm.variables = null;
  434. })
  435. },
  436. /** 提交退回任务 */
  437. taskReturn() {
  438. this.$refs["taskForm"].validate(valid => {
  439. if (valid) {
  440. returnTask(this.taskForm).then(res => {
  441. this.$modal.msgSuccess(res.msg);
  442. this.goBack()
  443. });
  444. }
  445. });
  446. },
  447. /** 取消回退任务按钮 */
  448. cancelTask() {
  449. this.taskForm.returnTaskShow = false;
  450. this.taskForm.defaultTaskShow = true;
  451. this.returnTaskList = [];
  452. },
  453. /** 委派任务 */
  454. submitDeleteTask() {
  455. this.$refs["taskForm"].validate(valid => {
  456. if (valid) {
  457. delegate(this.taskForm).then(response => {
  458. this.$modal.msgSuccess(response.msg);
  459. this.goBack();
  460. });
  461. }
  462. });
  463. },
  464. /** 取消回退任务按钮 */
  465. cancelDelegateTask() {
  466. this.taskForm.delegateTaskShow = false;
  467. this.taskForm.defaultTaskShow = true;
  468. this.returnTaskList = [];
  469. },
  470. /** 申请流程表单数据提交 */
  471. submitForm(formData) {
  472. // 根据当前任务或者流程设计配置的下一步节点 todo 暂时未涉及到考虑网关、表达式和多节点情况
  473. const params = { taskId: this.taskForm.taskId }
  474. getNextFlowNode(params).then(res => {
  475. const data = res.data;
  476. this.taskForm.formData = formData;
  477. if (data) {
  478. if (data.dataType === 'dynamic') {
  479. if (data.type === 'assignee') { // 指定人员
  480. this.checkSendUser = true;
  481. this.checkType = "single";
  482. } else if (data.type === 'candidateUsers') { // 候选人员(多个)
  483. this.checkSendUser = true;
  484. this.checkType = "multiple";
  485. } else if (data.type === 'candidateGroups') { // 指定组(所属角色接收任务)
  486. this.checkSendRole = true;
  487. } else { // 会签
  488. // 流程设计指定的 elementVariable 作为会签人员列表
  489. this.multiInstanceVars = data.vars;
  490. this.checkSendUser = true;
  491. this.checkType = "multiple";
  492. }
  493. }
  494. }
  495. this.completeOpen = true;
  496. this.completeTitle = "流程审批";
  497. })
  498. },
  499. },
  500. };
  501. </script>
  502. <style lang="scss" scoped>
  503. .test-form {
  504. margin: 15px auto;
  505. // width: 800px;
  506. padding: 20px;
  507. }
  508. .clearfix:before,
  509. .clearfix:after {
  510. display: table;
  511. content: "";
  512. }
  513. .clearfix:after {
  514. clear: both
  515. }
  516. .box-card {
  517. width: 100%;
  518. margin-bottom: 20px;
  519. }
  520. .el-tag+.el-tag {
  521. margin-left: 10px;
  522. }
  523. .my-label {
  524. background: #E1F3D8;
  525. }
  526. </style>