MyRequest.vue 12.7 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
<template>
  <div class="my-request">
    <ht-table
      ref="htTable"
      :data="tableData"
      :page-result="pageResult"
      :selectable="false"
      :quick-search-props="quickSearchProps"
      :quick-search-width="300"
      :show-export="false"
      :row-class-name="rowClassName"
      :header-cell-class-name="headerCellClassName"
      pagination-justify="end"
      :show-custom-column="false"
      :page-sizes="pageSizes"
      @load="loadData"
    >
      <template #search>
        <ht-table-search-panel
          :divide="3"
          :label-width="80"
          display-style="block"
        >
          <ht-table-search-field
            :label="$t('myRequest.SerialNumber')"
            prop="bpm_pro_inst.id_"
            operation="LIKE"
          />
          <ht-table-search-field
            :label="$t('myRequest.flowSubject')"
            prop="subject_"
            operation="LIKE"
          />
          <ht-table-search-field
            :label="$t('myRequest.flowProcDefName')"
            prop="proc_def_name_"
            operation="LIKE"
          />
          <ht-table-search-field
            :label="$t('myRequest.flowCreateTime')"
            prop="create_time_"
            type="daterange"
            operation="BETWEEN"
          />
          <!-- <ht-table-search-field
            label="状态"
            prop="status_"
            type="select"
            :options="statusOptions"
          /> -->
        </ht-table-search-panel>
      </template>
      <template #default>
        <ht-table-column
          type="index"
          width="50"
          align="center"
          :label="$t('myRequest.index')"
          fixed="left"
        />
        <ht-table-column
          prop="id"
          align="left"
          :label="$t('myRequest.SerialNumber')"
          width="180"
          show-overflow-tooltip
          fixed="left"
        >
          <template #default="{ row }">
            <div class="instance-id_wrap">
              {{ row.id }}
              <span
                class="copy-icon"
                @click="(event) => clipboard(row.id, event)"
              >
                <i class="icon-copy"></i>
              </span>
            </div>
          </template>
        </ht-table-column>
        <ht-table-column
          :label="$t('myRequest.flowChart')"
          width="70"
          align="center"
          fixed="left"
        >
          <template #default="{ row }">
            <div class="process-box">
              <ht-icon
                name="process"
                class="process-icon"
                @click="handleShowFlowChart(row)"
              ></ht-icon>
            </div>
          </template>
        </ht-table-column>
        <ht-table-column
          :label="$t('myRequest.flowSubject')"
          align="left"
          min-width="300"
          show-overflow-tooltip
          fixed="left"
        >
          <template #default="{ row }">
            <span class="subject" @click="handleClick(row)">
              {{ row.subject }}
            </span>
          </template>
        </ht-table-column>
        <ht-table-column
          :label="$t('myRequest.flowNodeName')"
          show-overflow-tooltip
          align="left"
          width="120"
        >
          <template #default="{ row }">
            <span v-if="extraField[row.id] && extraField[row.id].nodeName">
              <span
                v-for="(name, index) in extraField[row.id].nodeName"
                :key="`node-name_${row.id}_${index}`"
                class="flowlist-node-name"
              >
                {{ name }}
              </span>
            </span>
          </template>
        </ht-table-column>
        <ht-table-column
          align="left"
          prop="procDefName"
          :label="$t('myRequest.flowProcDefName')"
          width="160"
          show-overflow-tooltip
        />
        <ht-table-column
          align="left"
          prop="createTime"
          :label="$t('myRequest.flowCreateTime')"
          width="160"
          show-overflow-tooltip
        ></ht-table-column>
        <ht-table-column
          align="left"
          :label="$t('myRequest.flowStatus')"
          width="160"
          prop="status_"
          show-overflow-tooltip
          :render-header="renderHeaderMethod"
          :filters="statusArr"
        >
          <template #default="{ row }">
            <span
              :class="{
                'grey-color': ['end', 'manualend'].includes(row.status),
              }"
            >
              <ht-icon
                name="dot"
                :class="statusDotClassName[row.status]"
              ></ht-icon>
              {{ requestStatus[row.status] }}
            </span>
          </template>
        </ht-table-column>
        <ht-table-column
          v-if="isShowOperation"
          :label="$t('myRequest.operation')"
          align="center"
          width="100"
          fixed="right"
        >
          <template #default="{ row }">
            <el-button
              v-if="isTerminationBtn(row)"
              size="mini"
              type="text"
              @click="handleTermination(row.id)"
            >
              终止
            </el-button>
            <el-button
              v-if="isShowDelBtn(row)"
              size="mini"
              type="text"
              class="red-color"
              @click="handleDelete(row.id)"
            >
              删除
            </el-button>
          </template>
        </ht-table-column>
      </template>
    </ht-table>
    <ht-flow-chart
      ref="flowChart"
      :inst-id="instanceId"
      :bpmn-inst-id="bpmnInstId"
    />
        <processForecast
      ref="processForecast"
      :inst-id="instanceId"
      :def-id="defId"
      :node-id="nodeId"
      :bpmn-inst-id="bpmnInstId"
    ></processForecast>
  </div>
</template>

<script>
  import matter from '@/mixins/matter'
  import tableHeight from '@/mixins/tableHeight'
  import nodeAndApprover from '@/mixins/nodeAndApprover'
  import tableHeaderFilter from '@/mixins/tableHeaderFilter'
 import processForecast from '@/views/matter/processForecast/processForecast.vue'

  import {
    getMyRequestList,
    deleteInstById,
    terminationProcess,
    getMyRequestTask,
  } from '@/api/process'

  import {
    MY_REQUEST_STATUS,
    REQUEST_DEFAULT_QUERY,
    STATUS_OPTION,
    STATUS_DOT_CLASS_NAME,
  } from './const'

  export default {
    name: 'MyRequest',
    components: {processForecast},
    mixins: [matter, tableHeight, nodeAndApprover, tableHeaderFilter],
    data() {
      return {
        tableData: [],
        isShowOperation: false,
        requestStatus: MY_REQUEST_STATUS,
        quickSearchProps: REQUEST_DEFAULT_QUERY,
        // statusOptions: STATUS_OPTION,
        statusDotClassName: STATUS_DOT_CLASS_NAME,
      }
    },
    computed: {
      isShowDelBtn() {
        return (row) => {
          const { status, backToStart } = row
          const hasStatus = [
            'revokeToStart',
            'manualend',
            'backToStart',
          ].includes(status)
          return hasStatus || (status === 'back' && backToStart)
        }
      },
      isTerminationBtn() {
        return (row) => {
          const { status, backToStart } = row
          const hasStatus = ['revokeToStart', 'backToStart'].includes(status)
          return hasStatus || (status === 'back' && backToStart)
        }
      },
      defaultQueryList() {
        const statusList = ['revoke', 'back', 'running', 'end']
        const list = statusList.map((item) => {
          return {
            property: 'status_',
            value: item,
            group: 'status',
            operation: 'LIKE',
            relation: 'OR',
          }
        })
        if (this.$route.query && this.$route.query.flowKey) {
          list.push({
            property: 'proc_def_key_',
            value: this.$route.query.flowKey,
            operation: 'EQUAL',
            group: 'main',
            relation: 'AND',
          })
        }
        return list
      },
      statusArr() {
        return Object.keys(this.requestStatus)
          .filter((status) => status != 'draft')
          .map((item) => {
            return {
              text: this.requestStatus[item],
              value: item,
            }
          })
      },
    },
    watch: {
      tableData(val) {
        val?.length > 0 && this.loadTaskInfo(val)
      },
    },
    activated() {
      this.$refs.htTable.load(true)
    },
    methods: {
      loadData(param, cb) {
        const data = {
          pageBean: this.pageResult,
          ...param,
          querys: [
            ...this.defaultQueryList,
            ...this.getCurrentQuery(param, 'type_id_'),
          ],
        }
        getMyRequestList(data)
          .then((res) => {
            if (!res) return
            const { rows, page, pageSize, total } = res
            this.tableData = rows || []
            this.handleIsShowOperate(this.tableData)
            this.pageResult = {
              page,
              pageSize,
              total,
            }
            this.$nextTick(() => {
              this.$refs.htTable && this.$refs.htTable.$refs.htTable.doLayout()
            })
          })
          .finally(() => cb?.())
      },
      handleIsShowOperate(data) {
        const statusList = [
          'draft',
          'manualend',
          'revokeToStart',
          'backToStart',
          'revokeToStart',
        ]
        data?.map((item) => {
          if (
            (item.status === 'back' && item.backToStart) ||
            statusList.includes(item.status)
          ) {
            this.isShowOperation = true
          }
        })
      },
      handleClick(row) {
        /*
        //获取我的请求对应实例的任务
        分两种情况:
        1、如果包含退回发起人/驳回发起人,进入我的申请,如果单据退回发起人/驳回发起人状态,直接进入待办
        2、如果情况1不满足,进入只读状态查看我的审批单,可关闭或撤回(根据按钮权限渲染)
        */
        getMyRequestTask(row.id).then((res) => {
          let task = res.value
          if (task && task.id) {
            this.$router.push({
              path: '/matter/approvalForm',
              query: {
                taskId: task.id,
                instId: row.id,
                isGetApprovalBtn: true,
                myApplication: true,
                type: 'request',
              },
            })
          } else {
            this.$router.push({
              path: '/matter/approvalForm',
              query: {
                instId: row.id,
                // 这个参数用于检查是否有撤回流程权限
                type: 'request',
                myApplication: true,
                // TODO:taskId
                // taskId:
                // __isFull__: false,
              },
            })
          }
        })
      },
      handleDelete(id) {
        this.$confirm('确认删除此流程?', '提示', {
          cancelButtonText: '取消',
          confirmButtonText: '确定',
          type: 'warning',
          closeOnClickModal: false,
          beforeClose: (action, instance, done) => {
            if (action === 'confirm') {
              instance.confirmButtonLoading = true
              deleteInstById(id).then((res) => {
                if (!res.state) return this.$message.error(res.message)
                instance.confirmButtonLoading = false
                this.$message.success(res.message)
                this.$refs.htTable.load()
                done()
              })
            } else {
              done()
              instance.confirmButtonLoading = false
            }
          },
        }).then(() => {})
      },
      handleTermination(id) {
        this.$confirm('确认终止此流程?', '提示', {
          cancelButtonText: '取消',
          confirmButtonText: '确定',
          type: 'warning',
          closeOnClickModal: false,
          beforeClose: (action, instance, done) => {
            if (action === 'confirm') {
              instance.confirmButtonLoading = true
              terminationProcess(id, (res) => {
                if (!res.state) return this.$message.error(res.message)
                instance.confirmButtonLoading = false
                this.$message.success(res.message)
                this.$refs.htTable.load()
                done()
              })
            } else {
              done()
              instance.confirmButtonLoading = false
            }
          },
        }).then(() => {})
      },
    },
  }
</script>

<style lang="scss" scoped>
  .my-request {
    height: 100%;
    .subject,
    .process-icon {
      cursor: pointer;
      color: var(--themeColor);
    }
    .red-color {
      color: $base-color-red;
    }
  }
</style>