| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189 |
- <template>
- <view class="havedone-container">
- <uni-nav-bar
- fixed="true"
- statusBar="true"
- left-icon="back"
- :title="uniNavBarTitle"
- background-color="#157A2C"
- color="#fff"
- @clickLeft="back"
- ></uni-nav-bar>
- <view v-if="processInstance.processDefinition">
- <taskForm
- id="async-biz-form-component"
- :taskId="listData.taskId"
- :businessId="listData.businessId"
- :id="listData.id"
- :taskDefinitionKey="listData.taskDefinitionKey"
- ref="bziRef"
- ></taskForm>
- </view>
- <view v-if="listData.type !='view'">
- <view v-for="(item, index) in runningTasks" :key="index">
- <div v-if="processInstance.processDefinition">
- <taskSubmit
- id="async-sub-form-component"
- :taskId="listData.taskId"
- :businessId="listData.businessId"
- :id="listData.id"
- :taskDefinitionKey="listData.taskDefinitionKey"
- @handleAudit="handleAudit"
- @getTableValue="getTableValue"
- ref="subForm"
- >
- </taskSubmit>
- </div>
- </view>
- </view>
- <u-toast ref="uToast"></u-toast>
- </view>
- </template>
- <script>
- import {
- getProcessInstance,
- getTaskListByProcessInstanceId,
- } from "@/api/wt/index.js";
- import taskForm from "./taskForm.vue";
- import taskSubmit from "./taskSubmit.vue";
- export default {
- name: "processTask",
- components: { taskForm, taskSubmit },
- data() {
- return {
- uniNavBarTitle: "",
- processInstanceLoading: false,
- listData: {},
- processInstance: {},
- runningTasks: [],
- auditForms: [],
- };
- },
- onLoad(option) {
- this.listData = option || {};
- this.getDetail();
- },
- methods: {
- async getDetail() {
- this.processInstanceLoading = true;
- this.runningTasks = [];
- this.auditForms = [];
- if (!this.listData.id) {
- this.processInstanceLoading = false;
- return;
- }
- try {
- const response = await getProcessInstance({
- id: this.listData.id,
- });
- if (!response) {
- uni.showToast({
- title: "查询不到流程信息",
- icon: "none",
- duration: 3000,
- });
- this.processInstanceLoading = false;
- return;
- }
- this.processInstance = response;
- this.uniNavBarTitle = `${response.name}`;
- } catch (err) {
- this.processInstanceLoading = false;
- uni.showModal({
- title: "getProcessInstance 失败",
- content: String((err && err.message) || err),
- showCancel: false,
- });
- return;
- }
- this.processInstanceLoading = false;
- try {
- const response = await getTaskListByProcessInstanceId({
- processInstanceId: this.listData.id,
- });
- if (!Array.isArray(response)) {
- uni.showModal({
- title: "任务列表格式异常",
- content: JSON.stringify({ raw: response }).slice(0, 1700),
- showCancel: false,
- });
- return;
- }
- this.tasks = [];
- response.forEach((task) => {
- if (task.result !== 4) {
- this.tasks.push(task);
- }
- });
- this.tasks.sort((a, b) => {
- if (a.endTime && b.endTime) {
- return b.endTime - a.endTime;
- } else if (a.endTime) {
- return 1;
- } else if (b.endTime) {
- return -1;
- } else {
- return b.createTime - a.createTime;
- }
- });
- const userInfo = uni.getStorageSync("userInfo") || {};
- const userId = userInfo.userId;
- this.tasks.forEach((task) => {
- if (task.result !== 1 && task.result !== 6) {
- return;
- }
- if (userId == null) {
- return;
- }
- if (!task.assigneeUser || task.assigneeUser.id !== userId) {
- return;
- }
- if (task.taskDefinitionKey !== this.listData.taskDefinitionKey) {
- return;
- }
- this.runningTasks.push({
- ...task,
- });
- this.auditForms.push({
- reason: "",
- });
- });
- } catch (err) {
- uni.showModal({
- title: "getTaskList 或解析失败",
- content: String((err && err.message) || err),
- showCancel: false,
- });
- }
- },
- handleAudit(data) {
- let text = data.status === 1 ? "通过" : "不通过";
- this.$refs.uToast.show({
- type: "success",
- message: `审批${data.title || text}成功!`,
- iconUrl: "https://cdn.uviewui.com/uview/demo/toast/success.png",
- });
- setTimeout(() => {
- uni.navigateBack();
- }, 1000);
- },
- getTableValue(fn) {
- fn(this.$refs.bziRef.getTableValue());
- },
- },
- };
- </script>
- <style></style>
|