|
|
@@ -1,105 +1,126 @@
|
|
|
<template>
|
|
|
- <ele-modal
|
|
|
- :visible.sync="visible"
|
|
|
- title="作业票管理"
|
|
|
- width="80vw"
|
|
|
- append-to-body
|
|
|
- :close-on-click-modal="false"
|
|
|
- @close="handleClose"
|
|
|
- >
|
|
|
- <div>
|
|
|
- <!-- 搜索区域 -->
|
|
|
- <div class="search-area">
|
|
|
- <seek-page
|
|
|
- ref="seekPage"
|
|
|
- :seekList="seekList"
|
|
|
- @search="handleSearch"
|
|
|
- :formLength="4"
|
|
|
- />
|
|
|
- </div>
|
|
|
+ <div>
|
|
|
+ <ele-modal
|
|
|
+ :visible.sync="visible"
|
|
|
+ title="作业票管理"
|
|
|
+ width="80vw"
|
|
|
+ append-to-body
|
|
|
+ :close-on-click-modal="false"
|
|
|
+ @close="handleClose"
|
|
|
+ >
|
|
|
+ <div>
|
|
|
+ <!-- 搜索区域 -->
|
|
|
+ <div class="search-area">
|
|
|
+ <seek-page
|
|
|
+ ref="seekPage"
|
|
|
+ :seekList="seekList"
|
|
|
+ @search="handleSearch"
|
|
|
+ :formLength="4"
|
|
|
+ />
|
|
|
+ </div>
|
|
|
|
|
|
- <!-- 列表视图 -->
|
|
|
- <div class="list-view">
|
|
|
- <!--
|
|
|
- v-if="work.id":el-dialog 首次打开才会渲染弹窗内容,表格也是此时才挂载。
|
|
|
- 表格挂载后由自身 mounted 触发首次加载,避免首次打开时 $refs.table 还不存在而不发请求。
|
|
|
- -->
|
|
|
- <ele-pro-table
|
|
|
- v-if="work.id"
|
|
|
- ref="table"
|
|
|
- row-key="id"
|
|
|
- :columns="columns"
|
|
|
- :datasource="datasource"
|
|
|
- :cache-key="cacheKeyUrl"
|
|
|
- max-height="500px"
|
|
|
- @columns-change="handleColumnChange"
|
|
|
- @selection-change="handleSelectionChange"
|
|
|
- >
|
|
|
- <template v-slot:toolbar>
|
|
|
- <div class="toolbar-left">
|
|
|
- <el-button
|
|
|
- type="primary"
|
|
|
- size="small"
|
|
|
- icon="el-icon-plus"
|
|
|
- @click="handleAdd"
|
|
|
- >申请作业票</el-button
|
|
|
- >
|
|
|
- <el-button
|
|
|
- type="danger"
|
|
|
- size="small"
|
|
|
- icon="el-icon-delete"
|
|
|
- :disabled="!selectedRows.length"
|
|
|
- @click="handleBatchDelete"
|
|
|
- >批量删除</el-button
|
|
|
- >
|
|
|
- <span class="toolbar-tip"
|
|
|
- >仅草稿(待提交)状态的作业票可编辑、提交、删除</span
|
|
|
- >
|
|
|
- </div>
|
|
|
- </template>
|
|
|
- <template v-slot:workType="{ row }">
|
|
|
- <span>{{ getWorkTypeName(row.workType) }}</span>
|
|
|
- </template>
|
|
|
- <template v-slot:status="{ row }">
|
|
|
- <el-tag :type="getStatusType(row.status)" size="small">
|
|
|
- {{ row.statusName || getStatusName(row.status) }}
|
|
|
- </el-tag>
|
|
|
- </template>
|
|
|
- <template v-slot:action="{ row }">
|
|
|
- <div class="action-links">
|
|
|
- <el-link
|
|
|
- type="primary"
|
|
|
- :underline="false"
|
|
|
- @click="handleView(row)"
|
|
|
- >查看</el-link
|
|
|
- >
|
|
|
- <el-link
|
|
|
- type="primary"
|
|
|
- :underline="false"
|
|
|
- @click="handleEdit(row)"
|
|
|
- >编辑</el-link
|
|
|
- >
|
|
|
- <el-link
|
|
|
- v-if="isDraft(row)"
|
|
|
- type="success"
|
|
|
- :underline="false"
|
|
|
- :disabled="submittingId === row.id"
|
|
|
- @click="handleSubmit(row)"
|
|
|
- >提交</el-link
|
|
|
- >
|
|
|
- <el-link
|
|
|
- type="danger"
|
|
|
- :underline="false"
|
|
|
- @click="handleDelete(row)"
|
|
|
- >删除</el-link
|
|
|
- >
|
|
|
- </div>
|
|
|
- </template>
|
|
|
- </ele-pro-table>
|
|
|
+ <!-- 列表视图 -->
|
|
|
+ <div class="list-view">
|
|
|
+ <!--
|
|
|
+ v-if="work.id":el-dialog 首次打开才会渲染弹窗内容,表格也是此时才挂载。
|
|
|
+ 表格挂载后由自身 mounted 触发首次加载,避免首次打开时 $refs.table 还不存在而不发请求。
|
|
|
+ -->
|
|
|
+ <ele-pro-table
|
|
|
+ v-if="work.id"
|
|
|
+ ref="table"
|
|
|
+ row-key="id"
|
|
|
+ :columns="columns"
|
|
|
+ :datasource="datasource"
|
|
|
+ :cache-key="cacheKeyUrl"
|
|
|
+ max-height="500px"
|
|
|
+ @columns-change="handleColumnChange"
|
|
|
+ @selection-change="handleSelectionChange"
|
|
|
+ >
|
|
|
+ <template v-slot:toolbar>
|
|
|
+ <div class="toolbar-left">
|
|
|
+ <el-button
|
|
|
+ type="primary"
|
|
|
+ size="small"
|
|
|
+ icon="el-icon-plus"
|
|
|
+ @click="handleAdd"
|
|
|
+ >申请作业票</el-button
|
|
|
+ >
|
|
|
+ <el-button
|
|
|
+ type="danger"
|
|
|
+ size="small"
|
|
|
+ icon="el-icon-delete"
|
|
|
+ :disabled="!selectedRows.length"
|
|
|
+ @click="handleBatchDelete"
|
|
|
+ >批量删除</el-button
|
|
|
+ >
|
|
|
+ <span class="toolbar-tip"
|
|
|
+ >仅草稿(待提交)状态的作业票可编辑、提交、删除</span
|
|
|
+ >
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+ <template v-slot:workType="{ row }">
|
|
|
+ <span>{{ getWorkTypeName(row.workType) }}</span>
|
|
|
+ </template>
|
|
|
+ <template v-slot:status="{ row }">
|
|
|
+ <el-tag :type="getStatusType(row.status)" size="small">
|
|
|
+ {{ row.statusName || getStatusName(row.status) }}
|
|
|
+ </el-tag>
|
|
|
+ </template>
|
|
|
+ <template v-slot:action="{ row }">
|
|
|
+ <div class="action-links">
|
|
|
+ <el-link
|
|
|
+ type="primary"
|
|
|
+ :underline="false"
|
|
|
+ @click="handleView(row)"
|
|
|
+ >查看</el-link
|
|
|
+ >
|
|
|
+ <el-link
|
|
|
+ type="primary"
|
|
|
+ :underline="false"
|
|
|
+ @click="handleEdit(row)"
|
|
|
+ >编辑</el-link
|
|
|
+ >
|
|
|
+ <el-link
|
|
|
+ v-if="isDraft(row)"
|
|
|
+ type="success"
|
|
|
+ :underline="false"
|
|
|
+ :disabled="submittingId === row.id"
|
|
|
+ @click="handleSubmit(row)"
|
|
|
+ >提交</el-link
|
|
|
+ >
|
|
|
+ <el-link
|
|
|
+ v-if="!isDraft(row)"
|
|
|
+ type="primary"
|
|
|
+ :underline="false"
|
|
|
+ @click="handleFlow(row)"
|
|
|
+ >流程</el-link
|
|
|
+ >
|
|
|
+ <el-link
|
|
|
+ type="danger"
|
|
|
+ :underline="false"
|
|
|
+ @click="handleDelete(row)"
|
|
|
+ >删除</el-link
|
|
|
+ >
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+ </ele-pro-table>
|
|
|
+ </div>
|
|
|
</div>
|
|
|
- </div>
|
|
|
- <add ref="addRef" @reload="reloadTable"> </add>
|
|
|
- </ele-modal>
|
|
|
+ <add ref="addRef" @reload="reloadTable"> </add>
|
|
|
+ </ele-modal>
|
|
|
+
|
|
|
+ <!-- 审批流程(审批记录 + 高亮流程图) -->
|
|
|
+ <ele-modal
|
|
|
+ title="审批流程"
|
|
|
+ :visible.sync="flowVisible"
|
|
|
+ width="90%"
|
|
|
+ append-to-body
|
|
|
+ :close-on-click-modal="false"
|
|
|
+ :maxable="true"
|
|
|
+ >
|
|
|
+ <flow v-if="flowVisible" :id="currentProcessInstanceId" />
|
|
|
+ </ele-modal>
|
|
|
+ </div>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
@@ -107,11 +128,18 @@
|
|
|
import dictMixins from '@/mixins/dictMixins';
|
|
|
import dictEnum from '@/enum/dict';
|
|
|
import add from './add.vue';
|
|
|
- import { ticketPage, ticketRemove, ticketSubmit } from '@/api/dangerousWork';
|
|
|
+ import flow from '@/views/bpm/processInstance/detail.vue';
|
|
|
+ import {
|
|
|
+ ticketPage,
|
|
|
+ ticketRemove,
|
|
|
+ ticketSubmit,
|
|
|
+ ticketGetById
|
|
|
+ } from '@/api/dangerousWork';
|
|
|
import {
|
|
|
TICKET_STATUS,
|
|
|
DRAFT_STATUS,
|
|
|
- getProcessDefinitionKey
|
|
|
+ getProcessDefinitionKey,
|
|
|
+ getProcessInstanceId
|
|
|
} from './constants';
|
|
|
|
|
|
// 仅草稿(待提交)状态的作业票可以删除
|
|
|
@@ -119,7 +147,7 @@
|
|
|
|
|
|
export default {
|
|
|
mixins: [tabMixins, dictMixins],
|
|
|
- components: { add },
|
|
|
+ components: { add, flow },
|
|
|
data() {
|
|
|
return {
|
|
|
visible: false,
|
|
|
@@ -129,6 +157,10 @@
|
|
|
selectedRows: [],
|
|
|
// 正在提交审批的作业票 id
|
|
|
submittingId: null,
|
|
|
+ // 审批流程弹窗
|
|
|
+ flowVisible: false,
|
|
|
+ // 当前查看的流程实例 id
|
|
|
+ currentProcessInstanceId: '',
|
|
|
columns: [
|
|
|
{
|
|
|
columnKey: 'selection',
|
|
|
@@ -201,7 +233,7 @@
|
|
|
{
|
|
|
columnKey: 'action',
|
|
|
label: '操作',
|
|
|
- width: 200,
|
|
|
+ width: 220,
|
|
|
align: 'center',
|
|
|
slot: 'action'
|
|
|
}
|
|
|
@@ -319,9 +351,16 @@
|
|
|
.then(() => {
|
|
|
this.submittingId = row.id;
|
|
|
return ticketSubmit({ id: row.id, processDefinitionKey })
|
|
|
- .then(() => {
|
|
|
+ .then(async (data) => {
|
|
|
this.$message.success('提交成功,已发起审批');
|
|
|
this.reloadTable();
|
|
|
+ // 提交后自动打开审批流程:优先用响应里的流程实例 id,没有则回查作业票详情
|
|
|
+ const processInstanceId =
|
|
|
+ getProcessInstanceId(data) ||
|
|
|
+ (await this.resolveProcessInstanceId(row));
|
|
|
+ if (processInstanceId) {
|
|
|
+ this.openFlow(processInstanceId);
|
|
|
+ }
|
|
|
})
|
|
|
.finally(() => {
|
|
|
this.submittingId = null;
|
|
|
@@ -329,6 +368,35 @@
|
|
|
})
|
|
|
.catch(() => {});
|
|
|
},
|
|
|
+ // 查看审批流程
|
|
|
+ async handleFlow(row) {
|
|
|
+ const processInstanceId = await this.resolveProcessInstanceId(row);
|
|
|
+ if (!processInstanceId) {
|
|
|
+ this.$message.warning('该作业票暂无审批流程');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ this.openFlow(processInstanceId);
|
|
|
+ },
|
|
|
+ // 打开审批流程弹窗
|
|
|
+ openFlow(processInstanceId) {
|
|
|
+ this.currentProcessInstanceId = processInstanceId;
|
|
|
+ this.flowVisible = true;
|
|
|
+ },
|
|
|
+ // 取作业票的流程实例 id:优先用列表行数据,没有再查作业票详情
|
|
|
+ async resolveProcessInstanceId(row) {
|
|
|
+ const fromRow = getProcessInstanceId(row);
|
|
|
+ if (fromRow) {
|
|
|
+ return fromRow;
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ const detail = await ticketGetById(row.id, {
|
|
|
+ showErrorToast: false
|
|
|
+ });
|
|
|
+ return getProcessInstanceId(detail);
|
|
|
+ } catch (e) {
|
|
|
+ return '';
|
|
|
+ }
|
|
|
+ },
|
|
|
handleClose() {
|
|
|
this.work = {};
|
|
|
this.visible = false;
|