task-detail.vue 32.2 KB
Newer Older
wangdanlei's avatar
wangdanlei committed
1 2 3 4 5 6
/**
* @Description: 任务详情页
* @author wx
* @date 2021/7/5
*/
<template>
wangdanlei's avatar
wangdanlei committed
7
  <div v-if="id && processInstanceId" class="task-detail-page">
wangdanlei's avatar
wangdanlei committed
8 9 10
    <div class="detail-tabs">
      <div class="menu-tab-wrap">
        <div v-for="(item,index) in editableTabs" :key="item.configName" class="menu-tab-item" @click="changeTab(item)">
wangdanlei's avatar
wangdanlei committed
11
          <span :class="currTab && item.configName === currTab.configName ? 'link' : ''">{{ item.name }}</span>
wangdanlei's avatar
wangdanlei committed
12 13 14 15 16 17
          <i v-if="item.closed" class="el-icon-close" @click.stop="closeTab(item,index)" />
        </div>
      </div>
    </div>

    <div class="detail-content">
wangdanlei's avatar
wangdanlei committed
18
      <div v-show="currTab && currTab.configName==='taskDetailBasicInfo'" class="background" style="margin-bottom: 8px">
wangdanlei's avatar
wangdanlei committed
19 20 21 22 23
        <div class="flex-s">
          <div v-if="basicData && basicData.basicInfo" class="task-name">{{ basicData.basicInfo.aliasName || basicData.basicInfo.name }}</div>
          <dee-tools :tools="tools" mode="normal" :collapse="false" />
        </div>
        <task-detail-basicInfo :basic-data="basicData" />
24
        <div v-if="approvalObject.length">
wangdanlei's avatar
wangdanlei committed
25
          <div class="sub-title" style="padding-bottom:12px">审批对象</div>
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
          <div v-for="(name,index) in approvalObject" :key="index">
            <!-- 高级组件: globalComponents -->
            <component :is="name.configName" v-if="name && name.type && name.type === 'globalComponents'" :ref="name.refKey" :com-item="name" :basic-data="basicData" :participant-data="participantData" />
            <!-- 自定义组件: privateComponent -->
            <dee-as-com
              v-else-if="name && name.type && name.type === 'privateComponent'"
              :ref="name.refKey"
              :component-prop="{...name, selfComponentPath: name.selfComponentPath}"
              :lay-config="{
                component: {
                  registrationType: 'custom',
                  codeApp: name.webServerName,
                  codePath: name.selfComponentPath
                }
              }"
              :basic-data="basicData"
              :participant-data="participantData"
              @saveStatusChangeEvent="onSaveStatusChangeEvent"
            />
            <!-- 表单配置: formConfig -->
            <dee-as-com
              v-else-if="name && name.type && name.type === 'formConfig'"
              :ref="name.refKey"
              :lay-config="{
                typeName: name.modelName,
                layKey: name.keyName
              }"
              editor-immediately
              :basic-data="basicData"
              :participant-data="participantData"
            />
wangdanlei's avatar
wangdanlei committed
57
          </div>
58
        </div>
wangdanlei's avatar
wangdanlei committed
59 60 61
        <div v-if="basicData && basicData.basicInfo && !basicData.basicInfo.forwardFlag">
          <div class="sub-title" style="padding-bottom:12px">任务处理</div>
          <div v-for="(name,index) in dynamicComponents" :key="index">
wangdanlei's avatar
wangdanlei committed
62
            <component :is="name.configName" v-if="name && name.comType && name.comType === 'globalComponents'" :key="id + '_' + randomKey" :ref="name.configName" v-bind="name.configParams ? JSON.parse(name.configParams) : {}" :com-item="name" :basic-data="basicData" :participant-data="participantData" />
wangdanlei's avatar
wangdanlei committed
63 64
            <dee-as-com
              v-else-if="name && name.comType && name.comType === 'privateComponent'"
wangdanlei's avatar
wangdanlei committed
65
              :key="id"
wangdanlei's avatar
wangdanlei committed
66 67 68 69 70 71 72 73 74
              :ref="name.configName"
              :component-prop="{...name, selfComponentPath: name.configName}"
              :lay-config="{
                component: {
                  registrationType: 'custom',
                  codeApp: name.webServerName,
                  codePath: name.configName
                }
              }"
wangdanlei's avatar
wangdanlei committed
75
              v-bind="name.configParams ? JSON.parse(name.configParams) : {}"
wangdanlei's avatar
wangdanlei committed
76 77 78 79 80
              :basic-data="basicData"
              :participant-data="participantData"
              @saveStatusChangeEvent="onSaveStatusChangeEvent"
            />
            <!-- <dee-dynamic-com  :ref="name.configName" :com-item="name" :basic-data="basicData" :participant-data="participantData" /> -->
wangdanlei's avatar
wangdanlei committed
81
            <dee-dynamic-com v-else :key="id" :ref="name.configName" :com-item="name" v-bind="name.configParams ? JSON.parse(name.configParams) : {}" :basic-data="basicData" :participant-data="participantData" />
wangdanlei's avatar
wangdanlei committed
82
          </div>
wangdanlei's avatar
wangdanlei committed
83 84 85
          <route-dealing :basic-data="basicData" :is-save-before-submit="isSaveBeforeSubmit" :show-title="showTitle" :routes="routes" :participant-data="participantData" @finishTask="finishTask" @routeSelect="routeSelect" />
          <dee-as-com
            v-if="layoutId"
wangdanlei's avatar
wangdanlei committed
86
            :key="typeName + layoutId"
wangdanlei's avatar
wangdanlei committed
87 88 89 90 91 92 93
            editor-immediately
            :lay-config="{
              typeName: typeName,
              layKey: layoutId
            }"
            :basic-data="basicData.businessObject"
          />
wangdanlei's avatar
wangdanlei committed
94 95
        </div>
      </div>
wangdanlei's avatar
wangdanlei committed
96
      <div v-show="currTab && currTab.configName==='defaultInfo'" class="background" style="height: 100%;margin-bottom: 8px">
wangdanlei's avatar
wangdanlei committed
97 98 99 100 101
        <dee-as-com
          editor-immediately
          :lay-config="{
            typeName: typeName,
            layKey: 'defaultInfo'
wangdanlei's avatar
wangdanlei committed
102
          }"
wangdanlei's avatar
wangdanlei committed
103
          :basic-data="basicData.businessObject"
wangdanlei's avatar
wangdanlei committed
104 105
        />
      </div>
wangdanlei's avatar
wangdanlei committed
106 107
      <div v-show="!(currTab && ['taskDetailBasicInfo','defaultInfo'].includes(currTab.configName))" class="background" style="height: 100%;margin-bottom: 8px">
        <component :is="currTab.configName" v-if="currTab && currTab.comType && currTab.comType === 'globalComponents'" :ref="currTab.name" v-bind="currTab.configParams ? JSON.parse(currTab.configParams) : {}" :process-instance-id="processInstanceId" :basic-data="basicData" />
wangdanlei's avatar
wangdanlei committed
108 109
        <dee-as-com
          v-else-if="currTab && currTab.comType && currTab.comType === 'privateComponent'"
wangdanlei's avatar
wangdanlei committed
110
          :key="id"
wangdanlei's avatar
wangdanlei committed
111
          :ref="currTab.configName"
wangdanlei's avatar
wangdanlei committed
112
          v-bind="currTab.configParams ? JSON.parse(currTab.configParams) : {}"
wangdanlei's avatar
wangdanlei committed
113 114 115 116 117 118 119
          :component-prop="{...currTab, selfComponentPath: currTab.configName}"
          :lay-config="{
            component: {
              registrationType: 'custom',
              codeApp: currTab.webServerName,
              codePath: currTab.configName
            }
wangdanlei's avatar
wangdanlei committed
120
          }"
wangdanlei's avatar
wangdanlei committed
121 122
          :process-instance-id="processInstanceId"
          :basic-data="basicData"
wangdanlei's avatar
wangdanlei committed
123
        />
wangdanlei's avatar
wangdanlei committed
124 125
        <component :is="currTab.comName" v-else-if="currTab && currTab.comName" :ref="currTab.name" v-bind="currTab.configParams ? JSON.parse(currTab.configParams) : {}" :process-instance-id="processInstanceId" :basic-data="basicData" />
        <component :is="currTab.configName" v-else-if="currTab && currTab.configName" :ref="currTab.name" v-bind="currTab.configParams ? JSON.parse(currTab.configParams) : {}" :process-instance-id="processInstanceId" :basic-data="basicData" />
wangdanlei's avatar
wangdanlei committed
126
      </div>
wangdanlei's avatar
wangdanlei committed
127
      <re-designate-person :dialog-visible="showReDesignateDia" :basic-data="basicData" @handleClose="handleClose" @delegateTask="delegateTask" />
wangdanlei's avatar
wangdanlei committed
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145

      <dee-dialog :title="examinationTitle" :dialog-visible="addExaminationVisible" width="660px" @handleClose="handleClose">
        <dee-form :form="addExaminationForm" :form-data="addExaminationFormData" :rules="ExaminationFormRules" />
        <div class="dialogBtn">
          <el-button type="primary" @click="addExamination">确定</el-button>
          <el-button type="default" @click="handleClose">取消</el-button>
        </div>
      </dee-dialog>

      <dee-dialog :title="examinationTitle" :dialog-visible="subExaminationVisible" width="660px" @handleClose="handleClose">
        <dee-form :form="subExaminationForm" :form-data="subExaminationFormData" :rules="ExaminationFormRules" />
        <div class="dialogBtn">
          <el-button type="primary" @click="subExamination">确定</el-button>
          <el-button type="default" @click="handleClose">取消</el-button>
        </div>
      </dee-dialog>
    </div>
  </div>
wangdanlei's avatar
wangdanlei committed
146 147 148 149 150 151 152 153
  <div v-else class="task-detail-page">
    <div
      style="width:100%;display: flex;align-items: center;flex-direction: column;height: 100%;justify-content: center"
    >
      <img src="/images/common/nodata.png" style="width: 190px;height: 132px">
      <div>暂无数据</div>
    </div>
  </div>
wangdanlei's avatar
wangdanlei committed
154 155 156 157 158
</template>
<script>
import TaskDetailBasicInfo from './task-detail-basicInfo'
import RouteDealing from './routeDealing'
import ReDesignatePerson from './redesignatePerson'
wangdanlei's avatar
wangdanlei committed
159 160
import { getTaskDetail, completeTask, receiveTask } from '@/api/workflow/taskCenter.js'
import { getInstancePbo, getInstanceInfo, getBizForm } from '@/api/workflow/userSettings.js'
wangdanlei's avatar
wangdanlei committed
161 162
import { getLayouts } from '@/api/workflow/config.js'
import { changeExamination, getCounterSignDeleteList } from '../../api/workflow/userSettings'
wangdanlei's avatar
wangdanlei committed
163
import addExaminationUserSelect from '@/views/workflow/task-center/task/addExaminationUserSelect'
wangdanlei's avatar
wangdanlei committed
164 165 166 167 168

export default {
  components: {
    TaskDetailBasicInfo,
    RouteDealing,
wangdanlei's avatar
wangdanlei committed
169 170
    ReDesignatePerson,
    addExaminationUserSelect
wangdanlei's avatar
wangdanlei committed
171 172 173 174 175 176 177 178 179 180 181 182 183
  },
  props: {
    id: {
      type: String,
      default: ''
    },
    processInstanceId: {
      type: String,
      default: ''
    }
  },
  data() {
    return {
wangdanlei's avatar
wangdanlei committed
184 185 186 187 188 189 190
      // 是否已经保持盘点结果
      isSaveBeforeSubmit: true,
      tabProps: {
        // editable: true,
        tabPosition: 'left'
      },
      showTitle: true,
wangdanlei's avatar
wangdanlei committed
191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210
      currTab: null,
      editableTabs: [],
      tabIndex: 2,
      tabPosition: 'left',
      layoutId: '',
      typeName: '',
      modelName: '',
      canDeal: false,
      tools: [],
      routes: [],
      participantData: {},
      basicData: {},
      arrList: [],
      brrList: [],
      requestsName: [],
      taskDetailHandleData: {},
      taskDetailHandleForm: {},
      taskDetailBasicInfoData: {},
      taskDetailInfoData: {},
      dynamicComponents: [],
wangdanlei's avatar
wangdanlei committed
211
      processInstVO: {},
wangdanlei's avatar
wangdanlei committed
212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235
      show: false,
      form: {},
      formData: [{
        split: 3,
        data: []
      }],
      rules: {
        'secretLevel': [{ required: true, message: '请选择', trigger: 'change' }]
      },
      tabs: [],
      config: {
        name: 'detail'
      },
      pageData: {},
      showReDesignateDia: false,
      approvalObject: [],
      // 通用:加签减签弹框title
      examinationTitle: '',
      // 加签弹框是否显示
      addExaminationVisible: false,
      addExaminationForm: {
        name: '',
        userListId: ''
      },
wangdanlei's avatar
wangdanlei committed
236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268
      // 签审表单规则
      ExaminationFormRules: {
        userListId: [
          { required: true, message: '请选择用户', trigger: 'change' }
        ],
        userName: [
          { required: true, message: '请选择用户', trigger: 'change' }
        ]
      },
      // 减签弹框是否显示
      subExaminationVisible: false,
      // 减签人员列表
      subExaminationUserList: [],
      subExaminationForm: {
        name: '',
        userName: ''
      },
      // Tab标签页点击事件
      tabHandler: {
        'tab-click': (tab) => {
          const item = this.editableTabs.find(r => r.name === tab.label)
          this.changeTab(item)
        },
        'edit': (a, actionType) => {
          if (actionType === 'add') {
            this.addApp()
          } else if (actionType === 'remove') {
            const id = this.tabsArr.find(x => {
              return x.id + '' === a + ''
            }).appId
            this.deleteApp(id)
          }
        }
wangdanlei's avatar
wangdanlei committed
269 270
      },
      randomKey: 1
wangdanlei's avatar
wangdanlei committed
271 272 273 274 275
    }
  },
  computed: {
    addExaminationFormData() {
      return [
wangdanlei's avatar
wangdanlei committed
276 277 278 279 280 281 282 283 284 285 286 287 288
        {
          data: [{
            key: 'name',
            title: '任务名称',
            component: {
              name: 'readable',
              disabled: true
            }
          },
          {
            key: 'userListId',
            title: '选择用户',
            component: {
wangdanlei's avatar
wangdanlei committed
289
              name: addExaminationUserSelect,
wangdanlei's avatar
wangdanlei committed
290 291 292 293
              instData: this.participantData,
              props: {
                typeEnum: 'TASK_ASSIGNEE'
              }
wangdanlei's avatar
wangdanlei committed
294 295 296
            },
            handler: {
              getUser: (value) => {
wangdanlei's avatar
wangdanlei committed
297
                this.$set(this.addExaminationForm, 'userListId', value)
wangdanlei's avatar
wangdanlei committed
298 299 300 301
              }
            }
          }]
        }
wangdanlei's avatar
wangdanlei committed
302 303
      ]
    },
wangdanlei's avatar
wangdanlei committed
304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319
    subExaminationFormData() {
      return [
        {
          data: [{
            key: 'name',
            title: '任务名称',
            component: {
              name: 'readable',
              disabled: true
            }
          },
          {
            key: 'userName',
            title: '选择用户',
            component: {
              name: 'el-select',
wangdanlei's avatar
wangdanlei committed
320
              multiple: true,
wangdanlei's avatar
wangdanlei committed
321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354
              // filterable: true,
              // remote: true,
              disabled: false,
              clearable: true,
              options: this.subExaminationUserList
              // options: [
              //   { label: '用户', value: '1' },
              //   { label: '角色', value: '2' }
              // ],
            }
          }]
        }
      ]
    }
  },
  watch: {
    id: {
      handler: function(val) {
        this.$nextTick(function() {
          this.getDetail(val, this.processInstanceId)
        })
      },
      immediate: true
    },
    processInstanceId: {
      handler: function(val) {
        this.processInstanceId = val
      },
      immediate: true
    }
  },
  mounted() {
  },
  methods: {
wangdanlei's avatar
wangdanlei committed
355 356 357
    onSaveStatusChangeEvent(val) {
      this.isSaveBeforeSubmit = val
    },
wangdanlei's avatar
wangdanlei committed
358 359 360 361 362 363 364 365 366 367
    // 获取减签用户列表
    getSubExaminationUserList() {
      getCounterSignDeleteList(this.id).then(x => {
        const userList = x.items.filter(y => {
          return y.userId !== localStorage.getItem('userId')
        })
        this.subExaminationUserList = userList.map(item => {
          return {
            lable: item.userId,
            value: item.userName,
wangdanlei's avatar
wangdanlei committed
368
            data: item,
wangdanlei's avatar
wangdanlei committed
369 370 371 372 373 374 375
            style: { display: 'block' }
          }
        })
      })
    },
    // 加签
    addExamination() {
wangdanlei's avatar
wangdanlei committed
376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393
      const params = {
        operationName: 'signAddTask',
        operator: localStorage.getItem('userId'),
        id: this.id,
        targetUserId: this.addExaminationForm.userListId ? this.addExaminationForm.userListId.join(',') : '',
        processDefinitionId: this.participantData.procDefId,
        processInstId: this.participantData.procInstId,
        taskDefinitionKey: this.participantData.taskKey,
        isBefore: false
      }
      if (params.targetUserId) {
        changeExamination(params).then(res => {
          this.$message.success('加签成功')
          this.addExaminationVisible = false
        })
      } else {
        this.$message.warning('请选择加签人员')
      }
wangdanlei's avatar
wangdanlei committed
394 395 396
    },
    // 减签
    subExamination() {
wangdanlei's avatar
wangdanlei committed
397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413
      const userIdItem = this.subExaminationUserList.filter(item => this.subExaminationForm.userName.includes(item.value))
      const params = {
        operationName: 'signDeleteTask',
        operator: localStorage.getItem('userId'),
        id: this.id,
        targetUserId: userIdItem ? userIdItem.map(item => { return item.data.proxyUserId || userIdItem.data.userId }).join(',') : '',
        processDefinitionId: this.participantData.procDefId,
        processInstId: this.participantData.procInstId,
        taskDefinitionKey: this.participantData.taskKey,
        isBefore: false
      }
      if (params.targetUserId) {
        changeExamination(params).then(res => {
          this.$message.success('减签成功')
          this.subExaminationVisible = false
          this.getSubExaminationUserList()
          this.subExaminationForm.userName = ''
wangdanlei's avatar
wangdanlei committed
414
        })
wangdanlei's avatar
wangdanlei committed
415 416 417
      } else {
        this.$message.warning('请选择减签人员')
      }
wangdanlei's avatar
wangdanlei committed
418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456
    },
    // 重新加载详情页数据
    refreshNodeData(items, type) {
      if (!items.flag) {
        this.typeName = items.subTypeName
        this.modelName = items.dxClassname ? this.$utils.getModelName4dxClassName(items.dxClassname) : ''
      }
      this.outEvent('detail', 'reload', {
        id: items.id,
        subTypeName: items.subTypeName
      })
    },
    outEvent(cmpName, event, params) {
      if (!this.pageData) {
        this.pageData = {}
      }
      this.pageData.eventInfo = {
        model: cmpName,
        event: event
      }
      if (!this.pageData[cmpName]) {
        const cmpEvent = {}
        if (params) {
          cmpEvent[event] = params
        } else {
          cmpEvent[event] = 0
        }
        this.$set(this.pageData, cmpName, cmpEvent)
        return
      }
      if (params) {
        this.$set(this.pageData[cmpName], event, params)
        return
      }
      let key = this.pageData[cmpName][event] || 0
      key++
      this.$set(this.pageData[cmpName], event, key)
    },
    toDetail(data) {
wangdanlei's avatar
wangdanlei committed
457
      const findItem = this.editableTabs.find(r => r.name === data.obj.number)
wangdanlei's avatar
wangdanlei committed
458 459
      if (!findItem && data) {
        this.editableTabs.push({
wangdanlei's avatar
wangdanlei committed
460 461
          id: this.editableTabs.length + 1,
          name: data.obj.number,
wangdanlei's avatar
wangdanlei committed
462 463 464 465 466 467 468 469 470 471 472 473 474
          configName: 'generalDetail',
          displayMode: data.displayMode,
          modelName: this.$utils.getModelName4dxClassName(data.obj.dxClassname),
          subTypeName: data.obj.subTypeName,
          pageData: {
            detail: {
              load: {
                id: data.obj.id,
                subTypeName: data.obj.subTypeName,
                pid: data.obj.id
              }
            }
          },
wangdanlei's avatar
wangdanlei committed
475
          closable: true
wangdanlei's avatar
wangdanlei committed
476 477 478 479 480
        })
      }
    },
    closeTab(val, index) {
      this.editableTabs.splice(index, 1)
wangdanlei's avatar
wangdanlei committed
481 482 483 484 485
      const tabVal = this.editableTabs[0]
      if (tabVal && tabVal.configName && this.$syncComs[tabVal.configName]) {
        tabVal.comName = this.$loadComponentMap[this.$syncComs[tabVal.configName].subProject](this.$syncComs[tabVal.configName].codePath)
      }
      this.currTab = tabVal
wangdanlei's avatar
wangdanlei committed
486 487
    },
    changeTab(val) {
wangdanlei's avatar
wangdanlei committed
488 489 490
      if (val && val.configName && this.$syncComs[val.configName]) {
        val.comName = this.$loadComponentMap[this.$syncComs[val.configName].subProject](this.$syncComs[val.configName].codePath)
      }
wangdanlei's avatar
wangdanlei committed
491 492 493 494 495 496 497 498 499 500 501
      this.currTab = val
      if (val.subTypeName && val.modelName) {
        this.typeTame = val.subTypeName
        this.modelName = val.modelName
      }
    },
    handleClose() {
      this.showReDesignateDia = false
      this.addExaminationVisible = false
      this.subExaminationVisible = false
    },
wangdanlei's avatar
wangdanlei committed
502 503 504 505 506 507 508 509
    // 领取任务
    recTask(id) {
      receiveTask({ 'id': id, 'userId': localStorage.getItem('userId') }).then(res => {
        this.$utils.showMessageSuccess('领取成功')
        this.$emit('reload')
        this.getDetail(this.id, this.processInstanceId)
      })
    },
wangdanlei's avatar
wangdanlei committed
510 511 512 513
    // 获取任务详情
    getDetail(id, instanceId) {
      this.tools = []
      this.currTab = {
wangdanlei's avatar
wangdanlei committed
514
        name: '任务信息',
wangdanlei's avatar
wangdanlei committed
515 516 517 518
        configName: 'taskDetailBasicInfo',
        isInner: true
      }
      this.editableTabs = [{
wangdanlei's avatar
wangdanlei committed
519 520
        id: 1,
        name: '任务信息',
wangdanlei's avatar
wangdanlei committed
521
        configName: 'taskDetailBasicInfo',
wangdanlei's avatar
wangdanlei committed
522 523
        isInner: true,
        closable: false
wangdanlei's avatar
wangdanlei committed
524
      }]
wangdanlei's avatar
wangdanlei committed
525 526 527 528 529 530
      // 获取流程信息
      getInstanceInfo(instanceId).then(res => {
        this.processInstVO = res.items
        this.$set(this.basicData, 'instanceData', res.items)
      })
      // 获取任务信息
wangdanlei's avatar
wangdanlei committed
531
      getTaskDetail(id)
wangdanlei's avatar
wangdanlei committed
532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548
        .then(res => {
          this.addExaminationForm.name = res.items.name
          this.subExaminationForm.name = res.items.name
          const basicInfo = res.items
          if (basicInfo.state === 'BE_RECEIVED' && basicInfo.assignee && basicInfo.assignee.split(',').indexOf(localStorage.getItem('userId')) > -1) {
            this.tools = [
              {
                name: '领取',
                icon: '/icons/c-Receive.png',
                handler: {
                  click: () => {
                    this.recTask(basicInfo.id)
                  }
                }
              }
            ]
          }
wangdanlei's avatar
wangdanlei committed
549
          this.layoutId = res.items.layoutId || ''
wangdanlei's avatar
wangdanlei committed
550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565
          if (res.items.otherFormInfo && res.items.otherFormInfo.length) {
            this.editableTabs = this.editableTabs.concat(res.items.otherFormInfo.filter(r => r.isShow).map((r, index) => {
              r.id = index + 2
              r.name = r.tabName
              r.closable = false
              return r
            }))
          }
          if (res.items.approvalObject && res.items.approvalObject.length) {
            res.items.approvalObject.forEach(el => {
              if (el.type !== 'customComponent' && el.configName && this.$syncComs[el.configName]) {
                el.comName = this.$loadComponentMap[this.$syncComs[el.configName].subProject](this.$syncComs[el.configName].codePath)
              } else {
                el.comName = el.configName
              }
            })
566 567 568 569 570 571 572
            this.approvalObject = res.items.approvalObject.filter(r => r.isShow).map(m => {
              return {
                ...m,
                // 设置组件引用key
                refKey: this.$utils.guid()
              }
            })
wangdanlei's avatar
wangdanlei committed
573
          }
wangdanlei's avatar
wangdanlei committed
574

wangdanlei's avatar
wangdanlei committed
575 576 577 578 579 580 581 582 583 584 585 586 587 588 589
          this.participantData = {
            'procInstId': basicInfo.processInstanceId,
            'procDefId': basicInfo.processDefinitionId,
            'taskKey': basicInfo.taskDefinitionKey
          }
          this.getBizForm()
          // this.dynamicComponents = [
          //   {
          //     'configName': 'test-doc',
          //     'nodeData': [
          //       {
          //         'id': 1,
          //         'label': '一级 1',
          //         'operator': 'AND',
          //         'items': [
wangdanlei's avatar
wangdanlei committed
590

wangdanlei's avatar
wangdanlei committed
591 592
          //         ],
          //         'children': [
wangdanlei's avatar
wangdanlei committed
593

wangdanlei's avatar
wangdanlei committed
594 595 596 597 598 599 600 601 602 603 604
          //         ]
          //       }
          //     ],
          //     'configParams': '{"num":"3","name":"3"}'
          //   }
          // ]

          // 判断加签减签按钮是否显示
          // 定义addExaminationflag,subExaminationFlag,最终值为true时显示按钮,false时不显示按钮
          let addExaminationFlag = false
          let subExaminationFlag = false
wangdanlei's avatar
wangdanlei committed
605
          let delegateTaskFlag = false
wangdanlei's avatar
wangdanlei committed
606 607 608 609 610 611 612 613 614 615
          // 当模板中配置了加签减签时,addExaminationflag,subExaminationFlag的值变为true,显示按钮
          const operationInfo = res.items.operationInfo
          if (operationInfo) {
            operationInfo.forEach(x => {
              if (x.name === 'signAddTask') {
                addExaminationFlag = true
              }
              if (x.name === 'signDeleteTask') {
                subExaminationFlag = true
              }
wangdanlei's avatar
wangdanlei committed
616 617 618
              if (x.name === 'delegateTask') {
                delegateTaskFlag = true
              }
wangdanlei's avatar
wangdanlei committed
619 620 621 622 623
            })
          }
          // 当任务类型为 多人并行百分比,多人并行多少人已处理,多人顺序时,显示按钮
          let flag2 = false
          const nodeType = res.items.nodeType
wangdanlei's avatar
wangdanlei committed
624 625 626 627 628 629
          const nodeTypeList = [
            'MULTI_PARALLEL_OVER_PERCENT',
            'MULTI_PARALLEL_OVER_COUNT',
            'MULTI_SEQUENCE'
          ]
          if (nodeTypeList.includes(nodeType)) {
wangdanlei's avatar
wangdanlei committed
630 631 632 633 634
            flag2 = true
          }
          // addExaminationflag,subExaminationFlag各自同时满足上面两个条件时,显示按钮
          addExaminationFlag = addExaminationFlag && flag2
          subExaminationFlag = subExaminationFlag && flag2
wangdanlei's avatar
wangdanlei committed
635

wangdanlei's avatar
wangdanlei committed
636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658
          // 获取PBO
          getInstancePbo(instanceId).then(res => {
            const businessObject = res.items
            const canDeal = basicInfo.state !== 'BE_RECEIVED' && !basicInfo.endTime && (basicInfo.assignee && basicInfo.assignee.split(',').indexOf(localStorage.getItem('userId')) > -1)
            // 任务详情插入流程信息变量
            basicInfo.processInstVO = this.processInstVO
            this.$set(this.basicData, 'basicInfo', basicInfo)
            this.$set(this.basicData, 'businessObject', businessObject)
            if (businessObject) {
              this.$set(this.basicData, 'dxClassname', businessObject.dxClassname)
              this.$set(this.basicData, 'versionId', businessObject.versionId)
              this.typeName = businessObject.subTypeName
            }
            this.$set(this.basicData, 'canDeal', canDeal)
            this.modelName = businessObject && businessObject.dxClassname ? this.$utils.getModelName4dxClassName(businessObject.dxClassname) : ''
            if (this.layoutId && businessObject && businessObject.subTypeName) {
              this.pageData = {
                detail: {
                  load: {
                    id: businessObject.id,
                    subTypeName: businessObject.subTypeName,
                    number: businessObject.number
                  }
wangdanlei's avatar
wangdanlei committed
659 660 661 662
                }
              }
            // this.initTabs(businessObject.subTypeName, this.layoutId)
            // this.initTabs('3', 'xform')
wangdanlei's avatar
wangdanlei committed
663 664
            }
            if (this.basicData.canDeal) {
wangdanlei's avatar
wangdanlei committed
665 666
              if (delegateTaskFlag) {
                this.tools.push({
wangdanlei's avatar
wangdanlei committed
667 668 669 670 671 672
                  name: '委派',
                  icon: '/icons/b-assign.png',
                  handler: {
                    click: () => {
                      this.showReDesignateDia = true
                    }
wangdanlei's avatar
wangdanlei committed
673
                  }
wangdanlei's avatar
wangdanlei committed
674 675
                })
              }
wangdanlei's avatar
wangdanlei committed
676 677 678 679 680 681 682 683 684 685 686 687
              // 满足减签按钮显示条件时,将减签按钮加入
              if (subExaminationFlag) {
                this.tools.unshift({
                  name: '减签',
                  icon: '/icons/c-batchd.png',
                  hidden: true,
                  handler: {
                    click: () => {
                      this.subExaminationVisible = true
                      this.examinationTitle = '减签'
                      this.getSubExaminationUserList()
                    }
wangdanlei's avatar
wangdanlei committed
688
                  }
wangdanlei's avatar
wangdanlei committed
689 690 691 692 693 694 695 696 697 698 699 700 701
                })
              }
              // 满足加签按钮显示条件时,将加签按钮加入
              if (addExaminationFlag) {
                this.tools.unshift({
                  name: '加签',
                  icon: '/icons/c-batchc.png',
                  hidden: true,
                  handler: {
                    click: () => {
                      this.addExaminationVisible = true
                      this.examinationTitle = '加签'
                    }
wangdanlei's avatar
wangdanlei committed
702
                  }
wangdanlei's avatar
wangdanlei committed
703 704
                })
              }
wangdanlei's avatar
wangdanlei committed
705 706 707 708 709 710 711 712 713 714 715 716 717 718
            // if (basicInfo.operationInfo && basicInfo.operationInfo.length) {
            //   const arr = basicInfo.operationInfo.map(item => {
            //     return {
            //       name: item.pluginInfo.label,
            //       icon: item.pluginInfo.icon,
            //       handler: {
            //         click: () => {
            //         // this.handleComOperata()
            //         }
            //       }
            //     }
            //   })
            //   this.tools = this.tools.concat(arr)
            // }
wangdanlei's avatar
wangdanlei committed
719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738
            }
            let routes = basicInfo.routes || []
            if (basicInfo.result) {
              routes = routes.map(r => {
                if (r.displayName === basicInfo.result) {
                  r.isDefault = true
                } else {
                  r.isDefault = false
                }
                return r
              })
            }
            this.routes = routes
          })
        })
        .catch(res => {
          if (res.code === 'DEX_WFC_SYSTEM_YONDEWF_SERVICE_0046') {
            this.$message.error(res.message)
            this.$store.dispatch('tagsView/delView', this.$route).then(({ visitedViews }) => {
              this.$router.go(-1)
wangdanlei's avatar
wangdanlei committed
739 740 741
            })
          }
        })
wangdanlei's avatar
wangdanlei committed
742 743 744 745
      // // 获取流程历史记录
      // getInstanceHistory(instanceId).then(res => {
      //   this.$set(this.basicData, 'historyInfo', res.items.content || [])
      // })
wangdanlei's avatar
wangdanlei committed
746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761
    },
    // 路由切换
    routeSelect(val) {
      this.getBizForm(val)
    },
    // 获取业务表单
    getBizForm(route) {
      const params = { ...this.participantData, selectRoute: route }
      getBizForm(params).then(res => {
        this.dynamicComponents = res.items || []
      })
    },
    // 完成任务
    finishTask(flag, params, callback, errCallBack) {
      this.$nextTick(function() {
        const validateArray = []
762 763 764 765 766 767 768 769 770 771 772 773 774
        // 审批对象表单
        this.approvalObject.forEach(item => {
          const vm = this.$refs[item.refKey][0]
          if (!vm) return
          if (vm.hasOwnProperty('validate')) {
            validateArray.push(vm.validate())
          } else if (vm.$refs.asCom && vm.$refs.asCom.hasOwnProperty('validate')) {
            validateArray.push(vm.$refs.asCom.validate())
          } else if (vm.$refs.asCom.$refs && vm.$refs.asCom.$refs.deeForm && vm.$refs.asCom.$refs.deeForm.hasOwnProperty('validate')) {
            validateArray.push(vm.$refs.asCom.$refs.deeForm.validate())
          }
        })
        // 任务处理
wangdanlei's avatar
wangdanlei committed
775 776 777 778 779 780 781 782
        this.dynamicComponents.forEach(item => {
          if (this.$refs.hasOwnProperty(item.configName)) {
            if (this.$refs[item.configName][0].hasOwnProperty('validate')) {
              validateArray.push(this.$refs[item.configName][0].validate())
            }
          }
        })
        Promise.all([flag, ...validateArray]).then(asd => {
wangdanlei's avatar
wangdanlei committed
783
          this.randomKey++
wangdanlei's avatar
wangdanlei committed
784 785 786 787 788 789 790 791 792
          if (!asd.includes(false)) {
            this.handleFinish(params, callback, errCallBack)
          }
        })
      })
    },
    handleFinish(params, callback, errCallBack) {
      completeTask(params).then(res => {
        this.$utils.showMessageSuccess(res.message || '操作成功')
wangdanlei's avatar
wangdanlei committed
793
        this.handleClose()
wangdanlei's avatar
wangdanlei committed
794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859
        this.$emit('reload')
        if (callback instanceof Function) callback(res)
      }).catch(res => {
        if (errCallBack instanceof Function) errCallBack(res)
      })
    },
    // 重新指派
    delegateTask(userId) {
      const params = {
        'operationName': 'delegateTask',
        'operator': localStorage.getItem('userId'),
        'id': this.basicData.basicInfo.id,
        'targetUserId': userId,
        'processDefinitionId': this.basicData.basicInfo.processDefinitionId,
        'processInstId': this.basicData.basicInfo.processInstanceId,
        'taskDefinitionKey': this.basicData.basicInfo.taskDefinitionKey
      }
      this.handleFinish(params)
    },
    initTabs(subTypeName, layoutId) {
      this.typeName = subTypeName
      getLayouts(subTypeName, layoutId).then(res => {
        if (res.items && res.items.length) {
          const item = res.items.slice(-1)[0]
          this.tabs = item.configDetails ? JSON.parse(item.configDetails).componentsData : []
        } else {
          this.tabs = []
        }
      })
    },
    finishTaskClick(flag) {
      this.$nextTick(function() {
        if (this.taskDetailHandleForm.radio === '终止流程') {
          this.finishTask()
        } else {
          const validateArray = []
          this.dynamicComponents.forEach(name => {
            if (this.$refs.hasOwnProperty(name)) {
              if (this.$refs[name][0].hasOwnProperty('validate')) {
                validateArray.push(this.$refs[name][0].validate())
              }
            }
          })
          validateArray.push(this.$refs.form.validate())
          Promise.all([flag, ...validateArray]).then(asd => {
            if (!asd.includes(false)) {
              this.finishTask()
            }
          }).catch(e => {
          })
        }
      })
    }
  },
  filter: {}
}
</script>

<style lang="scss">
  @import '../../styles/variables';
.task-detail-page{
  height: 100%;
  margin: 8px;
  box-sizing: border-box;
  display: flex;
  justify-content: flex-start;
wangdanlei's avatar
wangdanlei committed
860
  background: #f1f4f5;
wangdanlei's avatar
wangdanlei committed
861
  .detail-tabs{
wangdanlei's avatar
wangdanlei committed
862
    height: 100%;
wangdanlei's avatar
wangdanlei committed
863 864 865 866 867 868 869 870
    overflow-y: scroll;
  }
  .menu-tab-wrap{
    width:38px;
    display: flex;
    justify-content: flex-start;
    flex-wrap: wrap;
    text-align: center;
wangdanlei's avatar
wangdanlei committed
871
    margin:8px 4px 0 8px;
wangdanlei's avatar
wangdanlei committed
872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889
    .menu-tab-item{
      background: #fff;
      padding: 8px 10px;
      margin-bottom: 10px;
      border: 1px solid #dedede;
      border-radius: 4px;
      cursor: pointer;
      writing-mode: tb;
      font-size:14px;
      .el-icon-close{
        margin-top:4px;
      }
    }
  }
  .is-active{
    background: #FFF;
  }
  .detail-content {
wangdanlei's avatar
wangdanlei committed
890 891 892
    width: 100%;
    height: 100%;
    background: #fff;
wangdanlei's avatar
wangdanlei committed
893 894 895 896 897 898 899 900 901 902 903 904
    overflow-y: scroll;
    .task-name{
      font-weight: bold;
    }
    .el-scrollbar__wrap {
      height: 100%;
    }
    .el-scrollbar__view{
      height: 100%;
    }
    .background {
      background: rgba(255, 255, 255, 1);
wangdanlei's avatar
wangdanlei committed
905
      padding: 12px 16px;
wangdanlei's avatar
wangdanlei committed
906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937
    }
    .detaile-page {
      background: rgba(255, 255, 255, 1);
    }
    .el-dialog__body {
      padding: 20px 20px 0 20px;
    }
    .el-tabs__content{
      padding:0 8px;
      background: #fff;
    }
    .dee-tools{
      margin-right:20px!important;
      margin-top:0!important;
      // background-color: #ebebeb;
      // border: 1px solid #dedede;
      height: 30px;
      .icon{
        padding-left: 10px;
      }
      .icon-font{
        padding-right: 10px;
      }
    }
    .flex-s{
      display: flex;
      justify-content: space-between;
    }

  }
}
</style>