ProcessSimulationInst.vue 16.4 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 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 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 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 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 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 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 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 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 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 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 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 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577
<template>
  <el-dialog
    :visible="instDialogVisible"
    destroy-on-close
    append-to-body
    fullscreen
    v-if="instDialogVisible"
    :close-on-click-modal="false"
    :show-close="false"
    :before-close="handleInstDialogClose"
  >
    <div class="fullheight">
      <ht-table
        @load="loadData"
        :data="data"
        :pageResult="pageResult"
        :selection="true"
        :show-export="false"
        :quick-search-props="[
          {prop: 'subject', label: '流程标题'},
          {prop: 'procDefName', label: '流程名称'},
          {prop: 'ID_', label: '流程编号'}
        ]"
        ref="htTable"
        :header-cell-class-name="headerCellClassName"
      >
        <template v-slot:toolbar>
          <div style="width: 35%">
            <el-button-group>
              <ht-delete-button
                :url="deleteUrl"
                :htTable="$refs.htTable"
                @after-delete="afterDelete"
                >删除</ht-delete-button
              >
              <el-button icon="el-icon-document-add" @click="batchRestore()"
                >恢复</el-button
              >
            </el-button-group>
          </div>
          <div style="width: 65%">
            <div style="text-align: right">
              <el-button
                size="small"
                type="danger"
                @click="instDialogVisible = false"
                >关闭</el-button
              >
            </div>
          </div>
        </template>
        <template v-slot:search>
          <ht-table-search-panel :divide="3">
            <ht-table-search-field label="流程编号" prop="ID_" />
            <ht-table-search-field label="流程标题" prop="subject" />
            <ht-table-search-field label="流程名称" prop="procDefName" />
            <ht-table-search-field
              type="daterange"
              label="创建时间"
              prop="createTime"
              operation="BETWEEN"
            />
          </ht-table-search-panel>
        </template>

        <template>
          <ht-table-column
            type="index"
            width="50"
            align="center"
            label="序号"
          />
          <ht-table-column
            prop="id"
            label="流程编号"
            :hiden="true"
            width="160"
            show-overflow-tooltip
            :sortable="true"
          />
          <ht-table-column
            prop="subject"
            label="流程标题"
            :show-overflow-tooltip="true"
          ></ht-table-column>
          <ht-table-column
            prop="procDefName"
            label="流程名称"
            hidden
            width="150"
            :sortable="true"
          />
          <ht-table-column
            prop="status"
            label="实例状态"
            width="110"
            :filters="statusArray"
          >
            <template v-slot="{row}">
              <el-tag
                v-show="row.status == s.value"
                :type="s.type"
                v-for="s in statusArray"
                :key="s.value"
                >{{ s.text }}</el-tag
              >
            </template>
          </ht-table-column>
          <ht-table-column
            prop="createTime"
            label="创建时间"
            width="160"
            :sortable="true"
          />
        </template>

        <template>
          <ht-table-column
            type="index"
            width="50"
            align="center"
            label="序号"
          />
          <ht-table-column
            prop="id"
            label="流程编号"
            :hiden="true"
            width="160"
            show-overflow-tooltip
            :sortable="true"
          />
          <ht-table-column
            prop="subject"
            label="流程标题"
            :show-overflow-tooltip="true"
          ></ht-table-column>
          <ht-table-column
            prop="procDefName"
            label="流程名称"
            hidden
            width="150"
            :sortable="true"
          />
          <ht-table-column
            prop="status"
            label="实例状态"
            width="110"
            :render-header="renderHeaderMethod"
            :filters="statusArray"
          >
            <template v-slot="{row}">
              <el-tag
                v-show="row.status == s.value"
                :type="s.type"
                v-for="s in statusArray"
                :key="s.value"
                >{{ s.text }}</el-tag
              >
            </template>
          </ht-table-column>
          <ht-table-column
            prop="createTime"
            label="创建时间"
            width="140"
            :sortable="true"
          />
          <ht-table-column
            prop="endTime"
            label="结束时间"
            hidden
            width="140"
            :sortable="true"
          />
          <ht-table-column
            prop="isForbidden"
            label="是否挂起"
            width="100"
            :render-header="renderHeaderMethod"
            :filters="isForbidden"
          >
            <template v-slot="{row}">
              <el-tag
                v-show="row.isForbidden == s.value"
                :type="s.type"
                v-for="s in isForbidden"
                :key="s.value"
                >{{ s.text }}</el-tag
              >
            </template>
          </ht-table-column>
          <ht-table-column prop="creator" label="发起人" width="120" />
          <ht-table-column
            prop="isDele"
            label="是否删除"
            width="100"
            :render-header="renderHeaderMethod"
            :filters="[
              {text: '未删除', value: '0'},
              {text: '已删除', value: '1'}
            ]"
          >
            <template v-slot="{row}">
              <el-tag type="danger" v-if="row.isDele == '1'">已删除</el-tag>
              <el-tag type="info" v-if="row.isDele == '0'">未删除</el-tag>
            </template>
          </ht-table-column>
          <ht-table-column align="left" label="操作" width="130">
            <template v-slot="{row}">
              <el-dropdown
                size="mini"
                split-button
                @command="handleCommand"
                @click="handleCommand({row: row, command: 'detail'})"
              >
                <span> <i class="el-icon-tickets"></i>查看 </span>
                <el-dropdown-menu slot="dropdown">
                  <el-dropdown-item
                    icon="el-icon-menu"
                    :command="{row: row, command: 'restore'}"
                    v-if="row.isDele == '1'"
                    >恢复</el-dropdown-item
                  >

                  <el-dropdown-item
                    icon="el-icon-menu"
                    v-if="
                      row.isDele != '1' &&
                        row.status != 'end' &&
                        row.status != 'draft' &&
                        row.status != 'manualend' &&
                        row.status != 'adminmanualend'
                    "
                    :command="{row: row, command: 'resume'}"
                    >继续</el-dropdown-item
                  >
                  <!-- <el-dropdown-item
                  icon="el-icon-menu"
                  v-if="row.status !='end' && row.status !='manualend' && row.status !='adminmanualend'"
                  :command="{row:row,command:'exceptionlog'}"
                >查看错误日志</el-dropdown-item> -->
                </el-dropdown-menu>
              </el-dropdown>
            </template>
          </ht-table-column>
        </template>
      </ht-table>

      <ht-sidebar-dialog
        width="100%"
        :close-on-click-modal="false"
        :visible="dialogVisible"
        :before-close="handleClose"
        :append-to-body="true"
        title="查看明细"
      >
        <el-button
          style="float: right;z-index: 15000;position: relative;"
          @click="dialogVisible = false"
          type="danger"
          icon="el-icon-refresh-left"
          >返回</el-button
        >
        <InstanceDetail v-if="dialogVisible" :instance="curInstance" />
      </ht-sidebar-dialog>

      <ht-sidebar-dialog
        width="100%"
        :close-on-click-modal="false"
        :visible="logDialogVisible"
        :before-close="handleLogClose"
        :append-to-body="true"
        title="异常日志"
        class="log"
      >
        <el-button
          style="float: right;z-index: 15000;position: relative;"
          @click="logDialogVisible = false"
          type="danger"
          icon="el-icon-refresh-left"
          >返回</el-button
        >
        <el-form>
          <el-form-item label="名称">
            {{ log.opeName }}
          </el-form-item>
          <el-form-item label="内容">
            {{ log.opeContent }}
          </el-form-item>
        </el-form>
      </ht-sidebar-dialog>
      <!-- 流程催办 -->
      <InstanceUrgent ref="instanceUrgent" />
    </div>
  </el-dialog>
</template>
<script>
import flow from '@/api/flow.js'
import utils from '@/hotent-ui-util.js'
import req from '@/request.js'
const InstanceUrgent = () => import('@/views/flow/InstanceUrgent.vue')
import EipUserDialog from '@/components/dialog/EipUserDialog.vue'
const InstanceDetail = () => import('@/views/flow/InstanceDetail.vue')
import tableHeaderFilter from '@/mixins/tableHeaderFilter.js'

export default {
  components: {
    EipUserDialog,
    InstanceDetail,
    InstanceUrgent
  },
  mixins: [tableHeaderFilter],
  data() {
    return {
      data: [],
      instDialogVisible: false,
      logDialogVisible: false,
      pageResult: {
        page: 1,
        pageSize: 50,
        total: 0
      },
      loadDataUrl: '',
      dialogVisible: false,
      statusArray: [
        {text: '运行中', value: 'running', type: 'success'},
        {text: '结束', value: 'end', type: 'info'},
        {text: '草稿', value: 'draft', type: 'info'},
        {text: '驳回', value: 'back', type: 'danger'},
        {text: '驳回到发起人', value: 'backToStart', type: 'danger'},
        {text: '撤回', value: 'revoke', type: 'warning'},
        {text: '撤回到发起人', value: 'revokeToStart', type: 'warning'},
        {text: '人工终止', value: 'manualend', type: 'info'},
        {text: '管理员结束', value: 'adminmanualend', type: 'info'}
      ],
      curInstance: '',
      defKey: null,
      log: {
        opeName: '日志暂未消费请稍后查看',
        opeContent: '日志暂未消费请稍后查看'
      }
    }
  },
  computed: {
    isForbidden: function() {
      return [
        {text: '正常', value: '0', type: 'info'},
        {text: '挂起', value: '1', type: 'danger'}
      ]
    },
    deleteUrl: function() {
      return window.context.bpmRunTime + '/runtime/instance/v1/remove'
    }
  },

  mounted() {
    this.$validator = this.$root.$validator
  },
  methods: {
    handleLogClose() {
      this.logDialogVisible = false
    },
    handleLogShow(id) {
      this.logDialogVisible = true
      this.$http
        .get(
          window.context.bpmRunTime +
            '/runtime/bpmTestCaseLogs/v1/getJson?id=' +
            id
        )
        .then(res => {
          this.log = res.data || {
            opeName: '日志不存在',
            opeContent: '日志已经使用新表存储'
          }
        })
    },

    handleInstDialogClose() {
      this.instDialogVisible = false
    },
    handleInstDialogShow(defKey) {
      this.instDialogVisible = true
      this.defKey = defKey
    },
    batchRestore() {
      let elTable = this.$refs.htTable
      if (this.$refs.htTable.$refs && this.$refs.htTable.$refs.htTable) {
        elTable = this.$refs.htTable.$refs.htTable
      }
      if (elTable && elTable.selection && elTable.selection.length == 0) {
        this.$message.warning('请选择至少一项记录')
        return
      }

      let ids = []

      for (let item of elTable.selection) {
        ids.push(item['id'])
      }

      if (ids.length == 0) {
        this.$message.warning('请选择至少一项记录')
        return
      }
      this.restore(ids.join(','))
    },
    handleClose() {
      this.dialogVisible = false
    },
    handleCloseMenuPerm() {
      this.dialogVisibleMenuPerm = false
    },
    dialogCancle(dialogVisible) {
      this[dialogVisible] = false
    },
    loadData(param, cb) {
      if (!param.querys) {
        param.querys = []
      }
      let defKeyParam = {
        property: 'procDefKey',
        value: this.defKey,
        group: 'custom',
        relation: 'AND',
        operation: 'EQUAL'
      }
      param.querys = param.querys.concat(defKeyParam)

      let sysCodeParam = {
        property: 'sysCode',
        value: 'bpmx_test_',
        group: 'custom',
        relation: 'AND',
        operation: 'RIGHT_LIKE'
      }
      param.querys = param.querys.concat(sysCodeParam)

      flow
        .getInstPage(param)
        .then(response => {
          this.data = response.rows
          this.pageResult = {
            page: response.page,
            pageSize: response.pageSize,
            total: response.total
          }
        })
        .finally(() => cb())
    },
    handleCommand(params) {
      switch (params.command) {
        case 'detail': //查看
          this.curInstance = params.row
          this.dialogVisible = true
          break
        case 'restore': //恢复
          this.restore(params.row.id)
          break
        case 'isForbidden': //挂起/取消挂起
          this.forbiddenOrUnForbiddenInst(params.row)
          break
        case 'instanceUrgent': //实例ID催办
          this.instanceUrgent(params.row)
          break
        case 'end': //终止流程
          this.endProcess(params.row)
          break
        case 'exceptionlog': //日志
          this.handleLogShow(params.row.id)
          break
        case 'resume': //继续
          this.resume(params.row.id)
          break
        default:
          break
      }
    },
    resume(id) {
      this.$http
        .post(
          window.context.bpmRunTime + '/runtime/bpmTestCase/v1/doNext?id=' + id
        )
        .then(res => {
          if (res.data.state) {
            this.$message(res.data.message)
          } else {
            this.$message(res.data.message)
          }
        })
    },
    //终止流程
    endProcess(row) {
      let this_ = this
      this.$prompt('', '请输入终止原因', {
        inputPattern: /^[\s\S]*.*[^\s][\s\S]*$/,
        showCancelButton: false,
        inputErrorMessage: '终止原因不能为空'
      })
        .then(({value}) => {
          this_.$http
            .get(
              '${bpmRunTime}/runtime/instance/v1/doEndProcessById?id=' +
                row.id +
                '&reason=' +
                value
            )
            .then(function(resp) {
              let data = resp.data
              if (data.state) {
                this_.$message.success('操作成功')
                this_.$refs.htTable.load()
              } else {
                this_.$message.error(data.mesage || '操作失败')
              }
            })
        })
        .catch(() => {})
    },
    //流程催办
    instanceUrgent(row) {
      this.$refs.instanceUrgent.handleOpen(row.id, row.procDefId, row.subject) //父组件调用子组件方法
    },
    forbiddenOrUnForbiddenInst(row) {
      let this_ = this
      flow.forbiddenOrUnForbiddenInst(row).then(response => {
        if (response.state) {
          this_.$message.success(response.message)
          row.isForbidden = row.isForbidden == '1' ? '0' : '1'
        }
      })
    },
    restore(id) {
      let this_ = this
      req
        .get(
          window.context.bpmRunTime + '/runtime/instance/v1/restore?id=' + id
        )
        .then(function(response) {
          let data = response.data
          if (data.state) {
            this_.$message.success(data.message)
            this_.$refs.htTable.load(true)
          } else {
            this_.$message.fail(data.message)
          }
        })
    },
    afterDelete() {
      this.$refs.htTable.load()
    }
  }
}
</script>
<style lang="scss" scoped>
::v-deep {
  .cell > .el-table__column-filter-trigger {
    display: none;
  }
}

div[aria-invalid='true'] >>> .el-input__inner,
div[aria-invalid='true'] >>> .el-input__inner:focus {
  border-color: #f56c6c;
}

div >>> .el-dialog__body {
  height: calc(100% - 10px);
  padding: 10px;
}

div >>> .el-tabs__content > .el-tab-pane {
  height: 100%;
}
.log >>> .el-dialog__body {
  padding: 50px;
}
</style>