detail.vue 25.7 KB
Newer Older
sunhongwei's avatar
sunhongwei committed
1 2 3 4 5
<template>
  <div class="app-container">
    <!-- 审批信息 -->
    <el-card class="box-card" v-loading="processInstanceLoading" v-for="(item, index) in runningTasks" :key="index">
      <div slot="header" class="clearfix">
dragondean@qq.com's avatar
dragondean@qq.com committed
6
        <span class="el-icon-picture-outline">{{$t('审批任务')}}{{ item.name }}</span>
sunhongwei's avatar
sunhongwei committed
7
      </div>
chenjiuping's avatar
chenjiuping committed
8
      <el-col :span="16" :offset="6">
sunhongwei's avatar
sunhongwei committed
9
        <el-form :ref="'form' + index" :model="auditForms[index]" :rules="auditRule" label-width="100px">
dragondean@qq.com's avatar
dragondean@qq.com committed
10
          <el-form-item :label="$t('流程名')" v-if="processInstance && processInstance.name">
sunhongwei's avatar
sunhongwei committed
11 12
            {{ processInstance.name }}
          </el-form-item>
dragondean@qq.com's avatar
dragondean@qq.com committed
13
          <el-form-item :label="$t('流程发起人')" v-if="processInstance && processInstance.startUser">
sunhongwei's avatar
sunhongwei committed
14 15 16
            {{ processInstance.startUser.nickname }}
            <el-tag type="info" size="mini">{{ processInstance.startUser.deptName }}</el-tag>
          </el-form-item>
dragondean@qq.com's avatar
dragondean@qq.com committed
17
          <el-form-item :label="$t('抄送人')" prop="copyUserIds">
sunhongwei's avatar
sunhongwei committed
18
            <el-select v-model="auditForms[index].copyUserIds" clearable multiple filterable style="width: 100%">
chenjiuping's avatar
chenjiuping committed
19 20
              <el-option v-for="item in userOptions" :key="parseInt(item.id)" :label="item.nickname"
                         :value="parseInt(item.id)"/>
sunhongwei's avatar
sunhongwei committed
21 22
            </el-select>
          </el-form-item>
dragondean@qq.com's avatar
dragondean@qq.com committed
23 24
          <el-form-item :label="$t('审批建议')" prop="comment">
            <el-input type="textarea" v-model="auditForms[index].comment" :placeholder="$t('请输入审批建议')"/>
sunhongwei's avatar
sunhongwei committed
25 26 27
          </el-form-item>
        </el-form>
        <div style="margin-left: 10%; margin-bottom: 20px; font-size: 14px;">
dragondean@qq.com's avatar
dragondean@qq.com committed
28
          <el-button icon="el-icon-edit-outline" type="success" size="mini" @click="handleAudit(item, true)">{{$t('通过')}}
chenjiuping's avatar
chenjiuping committed
29
          </el-button>
dragondean@qq.com's avatar
dragondean@qq.com committed
30
          <el-button icon="el-icon-circle-close" type="danger" size="mini" @click="handleAudit(item, false)">{{$t('不通过')}}
chenjiuping's avatar
chenjiuping committed
31
          </el-button>
dragondean@qq.com's avatar
dragondean@qq.com committed
32
          <el-button icon="el-icon-edit-outline" type="primary" size="mini" @click="handleUpdateAssignee(item)">{{$t('转办')}}
chenjiuping's avatar
chenjiuping committed
33
          </el-button>
Marcus's avatar
Marcus committed
34 35
<!--          <el-button icon="el-icon-edit-outline" type="primary" size="mini" @click="handleDelegate(item)">{{ $t('委派') }}</el-button>-->
<!--          <el-button icon="el-icon-refresh-left" type="warning" size="mini" @click="handleBack(item)">{{ $t('退回') }}</el-button>-->
sunhongwei's avatar
sunhongwei committed
36 37 38 39
        </div>
      </el-col>
    </el-card>
    <!-- 申请信息 -->
dragondean@qq.com's avatar
dragondean@qq.com committed
40
    <el-card class="box-card mt-10" v-loading="processInstanceLoading">
sunhongwei's avatar
sunhongwei committed
41
      <div slot="header" class="clearfix">
dragondean@qq.com's avatar
dragondean@qq.com committed
42
        <span class="el-icon-document">{{$t('申请信息')}}{{ processInstance.name }}</span>
sunhongwei's avatar
sunhongwei committed
43 44 45
      </div>
      <el-col v-if="this.processInstance.processDefinition && this.processInstance.processDefinition.formType === 10"
              :span="16" :offset="6">
chenjiuping's avatar
chenjiuping committed
46 47
        <div>
          <parser :key="new Date().getTime()" :form-conf="detailForm" @submit="submitForm"/>
sunhongwei's avatar
sunhongwei committed
48 49 50
        </div>
      </el-col>
      <div v-if="this.processInstance.processDefinition && this.processInstance.processDefinition.formType === 20">
51
        <component v-if="businessKeyToComponent" :is="businessKeyToComponent.component" v-bind="businessKeyToComponent" />
jiuping520's avatar
jiuping520 committed
52

chenjiuping's avatar
chenjiuping committed
53 54
        <div v-else>
          <router-link :to="this.processInstance.processDefinition.formCustomViewPath + '?id='
sunhongwei's avatar
sunhongwei committed
55
                          + this.processInstance.businessKey">
dragondean@qq.com's avatar
dragondean@qq.com committed
56
            <el-button type="primary">{{$t('点击查看')}}</el-button>
chenjiuping's avatar
chenjiuping committed
57 58 59
          </router-link>
        </div>

sunhongwei's avatar
sunhongwei committed
60 61
      </div>
    </el-card>
dragondean@qq.com's avatar
dragondean@qq.com committed
62
    <el-card class="box-card mt-10" v-loading="tasksLoad">
sunhongwei's avatar
sunhongwei committed
63
      <div slot="header" class="clearfix">
dragondean@qq.com's avatar
dragondean@qq.com committed
64
        <span class="el-icon-picture-outline">{{$t('审批记录')}}</span>
sunhongwei's avatar
sunhongwei committed
65
      </div>
chenjiuping's avatar
chenjiuping committed
66
      <el-col :span="16" :offset="4">
sunhongwei's avatar
sunhongwei committed
67 68 69 70
        <div class="block">
          <el-timeline>
            <el-timeline-item v-for="(item, index) in tasks" :key="index"
                              :icon="getTimelineItemIcon(item)" :type="getTimelineItemType(item)">
dragondean@qq.com's avatar
dragondean@qq.com committed
71
              <p style="font-weight: 700">{{$t('任务')}}{{ item.name }}</p>
sunhongwei's avatar
sunhongwei committed
72 73
              <el-card :body-style="{ padding: '10px' }">
                <label v-if="item.assigneeUser" style="font-weight: normal; margin-right: 30px;">
dragondean@qq.com's avatar
dragondean@qq.com committed
74
                  {{$t('审批人')}}{{ item.assigneeUser.nickname }}
sunhongwei's avatar
sunhongwei committed
75 76
                  <el-tag type="info" size="mini">{{ item.assigneeUser.deptName }}</el-tag>
                </label>
dragondean@qq.com's avatar
dragondean@qq.com committed
77
                <label style="font-weight: normal">{{$t('创建时间')}}</label>
sunhongwei's avatar
sunhongwei committed
78
                <label style="color:#8a909c; font-weight: normal">{{ parseTime(item.createTime) }}</label>
dragondean@qq.com's avatar
dragondean@qq.com committed
79
                <label v-if="item.endTime" style="margin-left: 30px;font-weight: normal">{{$t('审批时间')}}</label>
chenjiuping's avatar
chenjiuping committed
80 81 82
                <label v-if="item.endTime" style="color:#8a909c;font-weight: normal"> {{
                    parseTime(item.endTime)
                  }}</label>
dragondean@qq.com's avatar
dragondean@qq.com committed
83
                <label v-if="item.durationInMillis" style="margin-left: 30px;font-weight: normal">{{$t('耗时')}}</label>
chenjiuping's avatar
chenjiuping committed
84 85
                <label v-if="item.durationInMillis" style="color:#8a909c;font-weight: normal">
                  {{ getDateStar(item.durationInMillis) }} </label>
sunhongwei's avatar
sunhongwei committed
86 87 88 89 90 91 92 93 94 95 96
                <p v-if="item.comment">
                  <el-tag :type="getTimelineItemType(item)">{{ item.comment }}</el-tag>
                </p>
              </el-card>
            </el-timeline-item>
          </el-timeline>
        </div>
      </el-col>
    </el-card>

    <!-- 高亮流程图 -->
dragondean@qq.com's avatar
dragondean@qq.com committed
97
    <el-card class="box-card mt-10" v-loading="processInstanceLoading">
sunhongwei's avatar
sunhongwei committed
98
      <div slot="header" class="clearfix">
dragondean@qq.com's avatar
dragondean@qq.com committed
99
        <span class="el-icon-picture-outline">{{$t('流程图')}}</span>
sunhongwei's avatar
sunhongwei committed
100 101
      </div>
      <my-process-viewer key="designer" v-model="bpmnXML" v-bind="bpmnControlForm" :activityData="activityList"
chenjiuping's avatar
chenjiuping committed
102
                         :processInstanceData="processInstance" :taskData="tasks"/>
sunhongwei's avatar
sunhongwei committed
103 104 105
    </el-card>

    <!-- 对话框(转派审批人) -->
Marcus's avatar
Marcus committed
106
    <el-dialog :title="$t('转派审批人')" :visible.sync="updateAssignee.open" width="500px" append-to-body>
sunhongwei's avatar
sunhongwei committed
107
      <el-form ref="updateAssigneeForm" :model="updateAssignee.form" :rules="updateAssignee.rules" label-width="110px">
dragondean@qq.com's avatar
dragondean@qq.com committed
108
        <el-form-item :label="$t('新审批人')" prop="assigneeUserId">
sunhongwei's avatar
sunhongwei committed
109
          <el-select v-model="updateAssignee.form.assigneeUserId" clearable style="width: 100%">
chenjiuping's avatar
chenjiuping committed
110 111
            <el-option v-for="item in userOptions" :key="parseInt(item.id)" :label="item.nickname"
                       :value="parseInt(item.id)"/>
sunhongwei's avatar
sunhongwei committed
112 113 114 115
          </el-select>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
dragondean@qq.com's avatar
dragondean@qq.com committed
116 117
        <el-button type="primary" @click="submitUpdateAssigneeForm">{{$t('确定')}}</el-button>
        <el-button @click="cancelUpdateAssigneeForm">{{$t('取消')}}</el-button>
sunhongwei's avatar
sunhongwei committed
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133
      </div>
    </el-dialog>
  </div>
</template>

<script>
import {getProcessDefinitionBpmnXML} from "@/api/bpm/definition";
import {DICT_TYPE, getDictDatas} from "@/utils/dict";
import store from "@/store";
import {decodeFields} from "@/utils/formGenerator";
import Parser from '@/components/parser/Parser'
import {createProcessInstance, getProcessInstance} from "@/api/bpm/processInstance";
import {approveTask, getTaskListByProcessInstanceId, rejectTask, updateTaskAssignee} from "@/api/bpm/task";
import {getDate} from "@/utils/dateUtils";
import {listSimpleUsers} from "@/api/system/user";
import {getActivityList} from "@/api/bpm/activity";
134
import OfferSpecialDetail from "@/views/ecw/offer/components/SpecialDetail"
135
import warehouseDetails from "@/views/ecw/order/components/warehouseDetails";
136
import shippingDetail from '@/views/ecw/box/shippingDetail'
dragondean@qq.com's avatar
dragondean@qq.com committed
137
import SplitDetail from '@/views/ecw/order/components/SplitDetail'
dragondean@qq.com's avatar
dragondean@qq.com committed
138
import MergeDetail from '@/views/ecw/order/components/MergeDetail'
dragondean@qq.com's avatar
dragondean@qq.com committed
139
import CargoControlDetail from '@/views/ecw/order/components/CargoControlDetail'
140
import BoxSplitDetail from '@/views/ecw/order/components/BoxSplitDetail'
sunhongwei's avatar
sunhongwei committed
141 142 143 144
// 流程实例的详情页,可用于审批
export default {
  name: "ProcessInstanceDetail",
  components: {
chenjiuping's avatar
chenjiuping committed
145
    Parser,
146
    OfferSpecialDetail,
147
    warehouseDetails,
dragondean@qq.com's avatar
dragondean@qq.com committed
148
    shippingDetail,
dragondean@qq.com's avatar
dragondean@qq.com committed
149
    SplitDetail,
dragondean@qq.com's avatar
dragondean@qq.com committed
150
    MergeDetail,
151 152
    CargoControlDetail,
    BoxSplitDetail
sunhongwei's avatar
sunhongwei committed
153
  },
dcy's avatar
dcy committed
154 155 156
  computed:{
    matterNum(){
      return this.$store.state.user.matterNum
157 158 159 160 161 162
    },
    businessKeyToComponent(){
      if(!this.processInstance.processDefinition || !this.processInstance.processDefinition.formCustomViewPath){
        return false
      }
      const map = {
huhaiqing's avatar
huhaiqing committed
163 164 165 166
      "shippingDetail": {
          component: "shippingDetail",
          processId: this.processInstance.businessKey,
        },
dragondean@qq.com's avatar
dragondean@qq.com committed
167
        // 报价单特价审核,原来配置的组件名
168
        "special-discount": {
169
          component: 'OfferSpecialDetail',
170
          id: this.processInstance.businessKey,
dragondean@qq.com's avatar
dragondean@qq.com committed
171 172 173 174
          type: 1
        },
        // 报价单特价审核,符合命名规则的组件名
        offer_special: {
175
          component: 'OfferSpecialDetail',
dragondean@qq.com's avatar
dragondean@qq.com committed
176 177 178 179
          id: this.processInstance.businessKey,
          type: 1
        },
        offer_commission: {
180
          component: 'OfferSpecialDetail',
dragondean@qq.com's avatar
dragondean@qq.com committed
181 182
          id: this.processInstance.businessKey,
          type: 2
183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198
        },
        free_apply: {
          component: "warehouseDetails",
          processId: this.processInstance.businessKey,
          type: 2
        },
        retired_warehouse: {
          component: "warehouseDetails",
          processId: this.processInstance.businessKey,
          type: 3
        },
        warehouse_transfer: {
          component: "warehouseDetails",
          processId: this.processInstance.businessKey,
          type: 1
        },
黄卓's avatar
黄卓 committed
199 200 201 202 203
        warehouse_update: {
          component: "warehouseDetails",
          processId: this.processInstance.businessKey,
          type: 4
        },
204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258
        container_modify: {
          component: "shippingDetail",
          processId: this.processInstance.businessKey,
        },
        trailer_modify: {
          component: "shippingDetail",
          processId: this.processInstance.businessKey,
        },
        ship_modify: {
          component: "shippingDetail",
          processId: this.processInstance.businessKey,
        },
        customs_declare_modify: {
          component: "shippingDetail",
          processId: this.processInstance.businessKey,
        },
        arrival_modify: {
          component: "shippingDetail",
          processId: this.processInstance.businessKey,
        },
        customs_clearance_modify: {
          component: "shippingDetail",
          processId: this.processInstance.businessKey,
        },
        customs_exit_part: {
          component: "shippingDetail",
          processId: this.processInstance.businessKey,
        },
        customs_exit_all: {
          component: "shippingDetail",
          processId: this.processInstance.businessKey,
        },
        start_port_modify: {
          component: "shippingDetail",
          processId: this.processInstance.businessKey,
        },
        book_space_modify: {
          component: "shippingDetail",
          processId: this.processInstance.businessKey,
        },
        sorting_apply_no: {
          component: "shippingDetail",
          processId: this.processInstance.businessKey,
        },
        sorting_apply: {
          component: "shippingDetail",
          processId: this.processInstance.businessKey,
        },
        unload_container_no: {
          component: "shippingDetail",
          processId: this.processInstance.businessKey,
        },
        unload_container: {
          component: "shippingDetail",
          processId: this.processInstance.businessKey,
huhaiqing's avatar
huhaiqing committed
259
          type: "unload_container",
260 261 262 263
        },
        close_container: {
          component: "shippingDetail",
          processId: this.processInstance.businessKey,
huhaiqing's avatar
huhaiqing committed
264
          type: "close_container",
265 266 267 268
        },
        shipment_preassemble: {
          component: "shippingDetail",
          processId: this.processInstance.businessKey,
dragondean@qq.com's avatar
dragondean@qq.com committed
269
        },
270 271 272 273
        close_container_no: {
          component: "shippingDetail",
          processId: this.processInstance.businessKey,
        },
dragondean@qq.com's avatar
dragondean@qq.com committed
274
        // 拆单审核
dragondean@qq.com's avatar
dragondean@qq.com committed
275
        split_detail: {
dragondean@qq.com's avatar
dragondean@qq.com committed
276 277 278
          component: "SplitDetail",
          id: this.processInstance.businessKey,
        },
dragondean@qq.com's avatar
dragondean@qq.com committed
279 280
        // 出货拆单审核
        shipment_split_detail: {
281
          component: "BoxSplitDetail",
dragondean@qq.com's avatar
dragondean@qq.com committed
282 283
          id: this.processInstance.businessKey,
        },
dragondean@qq.com's avatar
dragondean@qq.com committed
284 285
        merge_detail: {
          component: "MergeDetail",
dragondean@qq.com's avatar
dragondean@qq.com committed
286
          id: this.processInstance.businessKey,
dragondean@qq.com's avatar
dragondean@qq.com committed
287 288 289 290 291 292 293 294 295 296 297 298 299 300
        },
        // 放货修改
        order_update_release: {
          component: 'CargoControlDetail',
          id: this.processInstance.businessKey,
          applyType: 7
        },
        // 反复核
        order_fallback: {
          component: 'CargoControlDetail',
          id: this.processInstance.businessKey,
          applyType: 8
        },
        // 调货审核
dragondean@qq.com's avatar
dragondean@qq.com committed
301
        order_transfer: {
dragondean@qq.com's avatar
dragondean@qq.com committed
302 303 304 305
          component: 'CargoControlDetail',
          id: this.processInstance.businessKey,
          applyType: 9
        },
306
        // 取消放货审核
dragondean@qq.com's avatar
dragondean@qq.com committed
307 308 309 310
        order_cancel_release: {
          component: 'CargoControlDetail',
          id: this.processInstance.businessKey,
          applyType: 10
dragondean@qq.com's avatar
dragondean@qq.com committed
311
        },
dragondean@qq.com's avatar
dragondean@qq.com committed
312 313
        // 提单审核
        order_landing_bill:{
dragondean@qq.com's avatar
dragondean@qq.com committed
314
          component: () => import('@/views/ecw/order/components/LandingBillDetail'),
dragondean@qq.com's avatar
dragondean@qq.com committed
315 316
          id: this.processInstance.businessKey,
          path: this.processInstance.processDefinition?.formCustomViewPath
dragondean@qq.com's avatar
dragondean@qq.com committed
317 318 319 320 321 322 323 324 325 326 327 328 329
        },
        // 订单审核详情
        order_approval:{
          component: () => import('@/views/ecw/order/components/ApprovalDetail'),
          id: this.processInstance.businessKey,
          path: this.processInstance.processDefinition?.formCustomViewPath
        },
        // 订单修改审批
        order_update:{
          component: () => import('@/views/ecw/order/components/UpdateDetail'),
          id: this.processInstance.businessKey,
          path: this.processInstance.processDefinition?.formCustomViewPath
        },
330 331 332 333 334 335
        // 预付异常审核
        prepay_excetion:{
          component: () => import('@/views/ecw/order/components/PrepayExceptionDetail'),
          id: this.processInstance.businessKey,
          path: this.processInstance.processDefinition?.formCustomViewPath
        },
dragondean@qq.com's avatar
dragondean@qq.com committed
336 337 338 339 340 341
        // 客户延期
        customer_delay:{
          component: () => import('@/views/ecw/customer/components/Delay'),
          id: this.processInstance.businessKey,
          path: this.processInstance.processDefinition?.formCustomViewPath
        },
邓春圆's avatar
邓春圆 committed
342
        //付款单审核-所有审核流程详情组件
我在何方's avatar
我在何方 committed
343 344 345 346 347 348 349 350 351 352 353
        finance_payment_approve:{
          component: () => import('@/views/ecw/financial/components/PaymentApproval'),
          id: this.processInstance.businessKey,
          path: this.processInstance.processDefinition?.formCustomViewPath
        },
        //收款单审核
        finance_receipt_approve:{
          component: () => import('@/views/ecw/financial/components/CollectionApproval'),
          id: this.processInstance.businessKey,
          path: this.processInstance.processDefinition?.formCustomViewPath
        },
354
        //收款单核销
我在何方's avatar
我在何方 committed
355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383
        finance_receipt_write_off:{
          component: () => import('@/views/ecw/financial/components/CollectionWriteoff'),
          id: this.processInstance.businessKey,
          path: this.processInstance.processDefinition?.formCustomViewPath
        },
        //收款单反核销审核
        finance_receipt_write_off_no:{
          component: () => import('@/views/ecw/financial/components/CollectionApproval'),
          id: this.processInstance.businessKey,
          path: this.processInstance.processDefinition?.formCustomViewPath
        },
        //收款单核销反审核
        finance_receipt_approve_no:{
          component: () => import('@/views/ecw/financial/components/CollectionApproval'),
          id: this.processInstance.businessKey,
          path: this.processInstance.processDefinition?.formCustomViewPath
        },
        //收款单银行实收明细核销
        finance_receipt_item_write_off:{
          component: () => import('@/views/ecw/financial/components/CollectionBankDetail'),
          id: this.processInstance.businessKey,
          path: this.processInstance.processDefinition?.formCustomViewPath
        },
        //收款单银行实收反核销
        finance_receipt_item_write_off_no:{
          component: () => import('@/views/ecw/financial/components/CollectionBankDetail'),
          id: this.processInstance.businessKey,
          path: this.processInstance.processDefinition?.formCustomViewPath
        },
邓春圆's avatar
邓春圆 committed
384
      //佣金付款单审核详情-关于佣金付款单所有审核详情
385 386 387 388
        commissionPaymentDetails:{
         component: ()=>import('@/views/ecw/financial/components/commissionPaymentDetails.vue'),
          id: this.processInstance.businessKey,
          path: this.processInstance.processDefinition?.formCustomViewPath
389 390 391 392 393
        },
        /*撤销拆单*/
        split_revoke:{
          component: () => import("@/views/ecw/order/components/SplitRevokeDetail"),
          id: this.processInstance.businessKey
394
        }
395
      }
396
      console.log('formCustomViewPath', this.processInstance.processDefinition.formCustomViewPath.trim())
dragondean@qq.com's avatar
dragondean@qq.com committed
397
      return map[this.processInstance.processDefinition.formCustomViewPath.trim()]
dcy's avatar
dcy committed
398 399
    }
  },
sunhongwei's avatar
sunhongwei committed
400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427
  data() {
    return {
      // 遮罩层
      processInstanceLoading: true,
      // 流程实例
      id: undefined, // 流程实例的编号
      processInstance: {},

      // 流程表单详情
      detailForm: {
        fields: []
      },

      // BPMN 数据
      bpmnXML: null,
      bpmnControlForm: {
        prefix: "activiti"
      },
      activityList: [],

      // 审批记录
      tasksLoad: true,
      tasks: [],

      // 审批表单
      runningTasks: [],
      auditForms: [],
      auditRule: {
Marcus's avatar
Marcus committed
428
        comment: [{required: true, message: this.$t("审批建议不能为空"), trigger: "blur"}],
sunhongwei's avatar
sunhongwei committed
429 430 431 432 433 434 435 436 437 438
      },

      // 转派审批人
      userOptions: [],
      updateAssignee: {
        open: false,
        form: {
          assigneeUserId: undefined,
        },
        rules: {
Marcus's avatar
Marcus committed
439
          assigneeUserId: [{required: true, message: this.$t("新审批人不能为空"), trigger: "change"}],
sunhongwei's avatar
sunhongwei committed
440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472
        }
      },

      // 数据字典
      categoryDictDatas: getDictDatas(DICT_TYPE.BPM_MODEL_CATEGORY),
    };
  },
  created() {
    this.id = this.$route.query.id;
    if (!this.id) {
      this.$message.error('未传递 id 参数,无法查看流程信息');
      return;
    }
    this.getDetail();

    // 获得用户列表
    this.userOptions = [];
    listSimpleUsers().then(response => {
      this.userOptions.push(...response.data);
    });
  },
  methods: {
    /** 获得流程实例 */
    getDetail() {
      // 获得流程实例相关
      this.processInstanceLoading = true;
      getProcessInstance(this.id).then(response => {
        if (!response.data) {
          this.$message.error('查询不到流程信息!');
          return;
        }
        // 设置流程信息
        this.processInstance = response.data;
473
        console.log(this.processInstance)
sunhongwei's avatar
sunhongwei committed
474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560

        // 设置表单信息
        if (this.processInstance.processDefinition.formType === 10) {
          this.detailForm = {
            ...JSON.parse(this.processInstance.processDefinition.formConf),
            disabled: true, // 表单禁用
            formBtns: false, // 按钮隐藏
            fields: decodeFields(this.processInstance.processDefinition.formFields)
          }
          // 设置表单的值
          this.detailForm.fields.forEach(item => {
            const val = this.processInstance.formVariables[item.__vModel__]
            if (val) {
              item.__config__.defaultValue = val
            }
          });
        }

        // 加载流程图
        getProcessDefinitionBpmnXML(this.processInstance.processDefinition.id).then(response => {
          this.bpmnXML = response.data
        });
        // 加载活动列表
        getActivityList({
          processInstanceId: this.processInstance.id
        }).then(response => {
          this.activityList = response.data;
        });

        // 取消加载中
        this.processInstanceLoading = false;
      });

      // 获得流程任务列表(审批记录)
      this.tasksLoad = true;
      this.runningTasks = [];
      this.auditForms = [];
      getTaskListByProcessInstanceId(this.id).then(response => {
        // 审批记录
        this.tasks = response.data;
        // 排序,将未完成的排在前面,已完成的排在后面;
        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 userId = store.getters.userId;
        this.tasks.forEach(task => {
          if (task.result !== 1) { // 只有待处理才需要
            return;
          }
          if (!task.assigneeUser || task.assigneeUser.id !== userId) { // 自己不是处理人
            return;
          }
          this.runningTasks.push({...task});
          this.auditForms.push({
            comment: ''
          })
        });

        // 取消加载中
        this.tasksLoad = false;
      });
    },
    /** 处理选择流程的按钮操作 **/
    handleSelect(row) {
      // 设置选择的流程
      this.selectProcessInstance = row;

      // 流程表单
      if (row.formId) {
        // 设置对应的表单
        this.detailForm = {
          ...JSON.parse(row.formConf),
          fields: decodeFields(row.formFields)
        }
      } else if (row.formCustomCreatePath) {
chenjiuping's avatar
chenjiuping committed
561
        this.$router.push({path: row.formCustomCreatePath});
sunhongwei's avatar
sunhongwei committed
562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631
        // 这里暂时无需加载流程图,因为跳出到另外个 Tab;
      }
    },
    /** 提交按钮 */
    submitForm(params) {
      if (!params) {
        return;
      }
      // 设置表单禁用
      const conf = params.conf;
      conf.disabled = true; // 表单禁用
      conf.formBtns = false; // 按钮隐藏

      // 提交表单,创建流程
      const variables = params.values;
      createProcessInstance({
        processDefinitionId: this.selectProcessInstance.id,
        variables: variables
      }).then(response => {
        this.$modal.msgSuccess("发起流程成功");
        // 关闭当前窗口
        this.$tab.closeOpenPage();
        this.$router.go(-1);
      }).catch(() => {
        conf.disabled = false; // 表单开启
        conf.formBtns = true; // 按钮展示
      })
    },
    getDateStar(ms) {
      return getDate(ms);
    },
    getTimelineItemIcon(item) {
      if (item.result === 1) {
        return 'el-icon-time';
      }
      if (item.result === 2) {
        return 'el-icon-check';
      }
      if (item.result === 3) {
        return 'el-icon-close';
      }
      if (item.result === 4) {
        return 'el-icon-remove-outline';
      }
      return '';
    },
    getTimelineItemType(item) {
      if (item.result === 1) {
        return 'primary';
      }
      if (item.result === 2) {
        return 'success';
      }
      if (item.result === 3) {
        return 'danger';
      }
      if (item.result === 4) {
        return 'info';
      }
      return '';
    },
    /** 处理审批通过和不通过的操作 */
    handleAudit(task, pass) {
      const index = this.runningTasks.indexOf(task);
      this.$refs['form' + index][0].validate(valid => {
        if (!valid) {
          return;
        }
        const data = {
          id: task.id,
sunhongwei's avatar
sunhongwei committed
632 633
          comment: this.auditForms[index].comment,
          copyUserIds: this.auditForms[index].copyUserIds
sunhongwei's avatar
sunhongwei committed
634 635 636
        }
        if (pass) {
          approveTask(data).then(response => {
dcy's avatar
dcy committed
637
            let p = this.matterNum
638
            //this.$store.commit('GET_MAATER', --p)
sunhongwei's avatar
sunhongwei committed
639 640 641 642 643
            this.$modal.msgSuccess("审批通过成功!");
            this.getDetail(); // 获得最新详情
          });
        } else {
          rejectTask(data).then(response => {
dcy's avatar
dcy committed
644
            let p = this.matterNum
645
            //this.$store.commit('GET_MAATER', --p)
sunhongwei's avatar
sunhongwei committed
646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667
            this.$modal.msgSuccess("审批不通过成功!");
            this.getDetail(); // 获得最新详情
          });
        }
      });
    },
    /** 处理转派审批人 */
    handleUpdateAssignee(task) {
      // 设置表单
      this.resetUpdateAssigneeForm();
      this.updateAssignee.form.id = task.id;
      // 设置为打开
      this.updateAssignee.open = true;
    },
    /** 提交转派审批人 */
    submitUpdateAssigneeForm() {
      this.$refs['updateAssigneeForm'].validate(valid => {
        if (!valid) {
          return;
        }
        updateTaskAssignee(this.updateAssignee.form).then(response => {
          this.$modal.msgSuccess("转派任务成功!");
dcy's avatar
dcy committed
668
          let p = this.matterNum
669
          // this.$store.commit('GET_MAATER', --p)
sunhongwei's avatar
sunhongwei committed
670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699
          this.updateAssignee.open = false;
          this.getDetail(); // 获得最新详情
        });
      });
    },
    /** 取消转派审批人 */
    cancelUpdateAssigneeForm() {
      this.updateAssignee.open = false;
      this.resetUpdateAssigneeForm();
    },
    /** 重置转派审批人 */
    resetUpdateAssigneeForm() {
      this.updateAssignee.form = {
        id: undefined,
        assigneeUserId: undefined,
      };
      this.resetForm("updateAssigneeForm");
    },
    /** 处理审批退回的操作 */
    handleDelegate(task) {
      this.$modal.msgError("暂不支持【委派】功能,可以使用【转派】替代!");
    },
    /** 处理审批退回的操作 */
    handleBack(task) {
      this.$modal.msgError("暂不支持【退回】功能!");
    }
  }
};
</script>

dragondean@qq.com's avatar
dragondean@qq.com committed
700
<style lang="scss" scoped>
sunhongwei's avatar
sunhongwei committed
701 702 703 704 705 706 707 708 709
.my-process-designer {
  height: calc(100vh - 200px);
}

.box-card {
  width: 100%;
  margin-bottom: 20px;
}
</style>