|
@@ -53,9 +53,6 @@
|
|
|
@click="handleBatchDelete"
|
|
@click="handleBatchDelete"
|
|
|
>批量删除</el-button
|
|
>批量删除</el-button
|
|
|
>
|
|
>
|
|
|
- <span class="toolbar-tip"
|
|
|
|
|
- >仅草稿(待提交)状态的作业票可编辑、提交、删除</span
|
|
|
|
|
- >
|
|
|
|
|
</div>
|
|
</div>
|
|
|
</template>
|
|
</template>
|
|
|
<template v-slot:workType="{ row }">
|
|
<template v-slot:workType="{ row }">
|
|
@@ -81,7 +78,7 @@
|
|
|
>编辑</el-link
|
|
>编辑</el-link
|
|
|
>
|
|
>
|
|
|
<el-link
|
|
<el-link
|
|
|
- v-if="isDraft(row)"
|
|
|
|
|
|
|
+ v-if="canSubmit(row)"
|
|
|
type="success"
|
|
type="success"
|
|
|
:underline="false"
|
|
:underline="false"
|
|
|
:disabled="submittingId === row.id"
|
|
:disabled="submittingId === row.id"
|
|
@@ -138,13 +135,16 @@
|
|
|
import {
|
|
import {
|
|
|
TICKET_STATUS,
|
|
TICKET_STATUS,
|
|
|
DRAFT_STATUS,
|
|
DRAFT_STATUS,
|
|
|
|
|
+ REJECTED_STATUS,
|
|
|
|
|
+ canSubmitStatus,
|
|
|
|
|
+ canDeleteStatus,
|
|
|
getProcessDefinitionKey,
|
|
getProcessDefinitionKey,
|
|
|
getProcessInstanceId
|
|
getProcessInstanceId
|
|
|
} from './constants';
|
|
} from './constants';
|
|
|
import { buildWorkTypeOptions, resolveWorkTypeLabel } from './workTypes';
|
|
import { buildWorkTypeOptions, resolveWorkTypeLabel } from './workTypes';
|
|
|
|
|
|
|
|
- // 仅草稿(待提交)状态的作业票可以删除
|
|
|
|
|
- const DELETE_TIP = '仅草稿(待提交)状态的作业票可以删除';
|
|
|
|
|
|
|
+ // 仅待提交(草稿)、已驳回状态的作业票可以删除
|
|
|
|
|
+ const DELETE_TIP = '仅待提交(草稿)或已驳回状态的作业票可以删除';
|
|
|
|
|
|
|
|
export default {
|
|
export default {
|
|
|
mixins: [tabMixins, dictMixins],
|
|
mixins: [tabMixins, dictMixins],
|
|
@@ -169,8 +169,8 @@
|
|
|
width: 50,
|
|
width: 50,
|
|
|
align: 'center',
|
|
align: 'center',
|
|
|
fixed: 'left',
|
|
fixed: 'left',
|
|
|
- // 只有草稿(待提交)状态的作业票允许勾选,避免误删已提交的票
|
|
|
|
|
- selectable: (row) => this.isDraft(row)
|
|
|
|
|
|
|
+ // 只有待提交(草稿)、已驳回状态的作业票允许勾选,避免误删审批中或已通过的票
|
|
|
|
|
+ selectable: (row) => this.canDelete(row)
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
|
columnKey: 'index',
|
|
columnKey: 'index',
|
|
@@ -322,9 +322,10 @@
|
|
|
this.$refs.addRef.openTicket(row, this.work, 'edit');
|
|
this.$refs.addRef.openTicket(row, this.work, 'edit');
|
|
|
},
|
|
},
|
|
|
// 提交作业票并发起审批流:审批流编码按作业类型取
|
|
// 提交作业票并发起审批流:审批流编码按作业类型取
|
|
|
|
|
+ // 待提交(草稿)与已驳回状态都允许提交,已驳回的为重新提交
|
|
|
handleSubmit(row) {
|
|
handleSubmit(row) {
|
|
|
- if (!this.isDraft(row)) {
|
|
|
|
|
- this.$message.warning('仅草稿(待提交)状态的作业票可以提交');
|
|
|
|
|
|
|
+ if (!this.canSubmit(row)) {
|
|
|
|
|
+ this.$message.warning('该作业票当前状态不可提交');
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
const processDefinitionKey = getProcessDefinitionKey(
|
|
const processDefinitionKey = getProcessDefinitionKey(
|
|
@@ -338,7 +339,9 @@
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
this.$confirm(
|
|
this.$confirm(
|
|
|
- '提交后将发起审批流,作业票内容不可再修改,确认提交吗?',
|
|
|
|
|
|
|
+ Number(row?.status) === REJECTED_STATUS
|
|
|
|
|
+ ? '该作业票已被驳回,重新提交后将重新发起审批流,确认提交吗?'
|
|
|
|
|
+ : '提交后将发起审批流,作业票内容不可再修改,确认提交吗?',
|
|
|
'提示',
|
|
'提示',
|
|
|
{
|
|
{
|
|
|
confirmButtonText: '确定',
|
|
confirmButtonText: '确定',
|
|
@@ -353,9 +356,10 @@
|
|
|
this.$message.success('提交成功,已发起审批');
|
|
this.$message.success('提交成功,已发起审批');
|
|
|
this.reloadTable();
|
|
this.reloadTable();
|
|
|
// 提交后自动打开审批流程:优先用响应里的流程实例 id,没有则回查作业票详情
|
|
// 提交后自动打开审批流程:优先用响应里的流程实例 id,没有则回查作业票详情
|
|
|
|
|
+ // 已驳回重新提交时,行数据里是上一轮审批的实例 id,必须回查详情取最新一轮
|
|
|
const processInstanceId =
|
|
const processInstanceId =
|
|
|
getProcessInstanceId(data) ||
|
|
getProcessInstanceId(data) ||
|
|
|
- (await this.resolveProcessInstanceId(row));
|
|
|
|
|
|
|
+ (await this.resolveProcessInstanceId(row, true));
|
|
|
if (processInstanceId) {
|
|
if (processInstanceId) {
|
|
|
this.openFlow(processInstanceId);
|
|
this.openFlow(processInstanceId);
|
|
|
}
|
|
}
|
|
@@ -381,10 +385,13 @@
|
|
|
this.flowVisible = true;
|
|
this.flowVisible = true;
|
|
|
},
|
|
},
|
|
|
// 取作业票的流程实例 id:优先用列表行数据,没有再查作业票详情
|
|
// 取作业票的流程实例 id:优先用列表行数据,没有再查作业票详情
|
|
|
- async resolveProcessInstanceId(row) {
|
|
|
|
|
- const fromRow = getProcessInstanceId(row);
|
|
|
|
|
- if (fromRow) {
|
|
|
|
|
- return fromRow;
|
|
|
|
|
|
|
+ // @param preferDetail 为 true 时直接查详情(行数据里的实例 id 可能是上一轮审批的)
|
|
|
|
|
+ async resolveProcessInstanceId(row, preferDetail = false) {
|
|
|
|
|
+ if (!preferDetail) {
|
|
|
|
|
+ const fromRow = getProcessInstanceId(row);
|
|
|
|
|
+ if (fromRow) {
|
|
|
|
|
+ return fromRow;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
try {
|
|
try {
|
|
|
const detail = await ticketGetById(row.id, {
|
|
const detail = await ticketGetById(row.id, {
|
|
@@ -431,15 +438,21 @@
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
handleDelete(row) {
|
|
handleDelete(row) {
|
|
|
- if (!this.isDraft(row)) {
|
|
|
|
|
|
|
+ if (!this.canDelete(row)) {
|
|
|
this.$message.warning(DELETE_TIP);
|
|
this.$message.warning(DELETE_TIP);
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
- this.$confirm('确认删除该草稿作业票吗?删除后不可恢复。', '提示', {
|
|
|
|
|
- confirmButtonText: '确定',
|
|
|
|
|
- cancelButtonText: '取消',
|
|
|
|
|
- type: 'warning'
|
|
|
|
|
- })
|
|
|
|
|
|
|
+ this.$confirm(
|
|
|
|
|
+ Number(row?.status) === REJECTED_STATUS
|
|
|
|
|
+ ? '确认删除该已驳回的作业票吗?删除后不可恢复。'
|
|
|
|
|
+ : '确认删除该草稿作业票吗?删除后不可恢复。',
|
|
|
|
|
+ '提示',
|
|
|
|
|
+ {
|
|
|
|
|
+ confirmButtonText: '确定',
|
|
|
|
|
+ cancelButtonText: '取消',
|
|
|
|
|
+ type: 'warning'
|
|
|
|
|
+ }
|
|
|
|
|
+ )
|
|
|
.then(() => {
|
|
.then(() => {
|
|
|
ticketRemove([row.id]).then(() => {
|
|
ticketRemove([row.id]).then(() => {
|
|
|
this.$message.success('删除成功');
|
|
this.$message.success('删除成功');
|
|
@@ -450,19 +463,19 @@
|
|
|
.catch(() => {});
|
|
.catch(() => {});
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
- // 批量删除:仅允许删除草稿(待提交)状态的作业票
|
|
|
|
|
|
|
+ // 批量删除:仅允许删除待提交(草稿)、已驳回状态的作业票
|
|
|
handleBatchDelete() {
|
|
handleBatchDelete() {
|
|
|
const rows = this.selectedRows || [];
|
|
const rows = this.selectedRows || [];
|
|
|
if (!rows.length) {
|
|
if (!rows.length) {
|
|
|
this.$message.warning('请至少选择一条数据');
|
|
this.$message.warning('请至少选择一条数据');
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
- if (rows.some((row) => !this.isDraft(row))) {
|
|
|
|
|
|
|
+ if (rows.some((row) => !this.canDelete(row))) {
|
|
|
this.$message.warning(DELETE_TIP);
|
|
this.$message.warning(DELETE_TIP);
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
this.$confirm(
|
|
this.$confirm(
|
|
|
- `确认删除选中的 ${rows.length} 条草稿作业票吗?删除后不可恢复。`,
|
|
|
|
|
|
|
+ `确认删除选中的 ${rows.length} 条作业票吗?删除后不可恢复。`,
|
|
|
'提示',
|
|
'提示',
|
|
|
{
|
|
{
|
|
|
confirmButtonText: '确定',
|
|
confirmButtonText: '确定',
|
|
@@ -480,11 +493,21 @@
|
|
|
.catch(() => {});
|
|
.catch(() => {});
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
- // 是否草稿(待提交)状态,只有该状态允许删除
|
|
|
|
|
|
|
+ // 是否草稿(待提交)状态,只有该状态允许编辑
|
|
|
isDraft(row) {
|
|
isDraft(row) {
|
|
|
return Number(row?.status) === DRAFT_STATUS;
|
|
return Number(row?.status) === DRAFT_STATUS;
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
|
|
+ // 是否允许提交(发起审批):待提交(草稿)与已驳回都允许
|
|
|
|
|
+ canSubmit(row) {
|
|
|
|
|
+ return canSubmitStatus(row?.status);
|
|
|
|
|
+ },
|
|
|
|
|
+
|
|
|
|
|
+ // 是否允许删除:待提交(草稿)与已驳回都允许
|
|
|
|
|
+ canDelete(row) {
|
|
|
|
|
+ return canDeleteStatus(row?.status);
|
|
|
|
|
+ },
|
|
|
|
|
+
|
|
|
// 多选
|
|
// 多选
|
|
|
handleSelectionChange(rows) {
|
|
handleSelectionChange(rows) {
|
|
|
this.selectedRows = rows || [];
|
|
this.selectedRows = rows || [];
|
|
@@ -545,11 +568,4 @@
|
|
|
font-size: 12px;
|
|
font-size: 12px;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- .toolbar-tip {
|
|
|
|
|
- margin-left: 12px;
|
|
|
|
|
- font-size: 12px;
|
|
|
|
|
- color: #909399;
|
|
|
|
|
- line-height: 32px;
|
|
|
|
|
- }
|
|
|
|
|
</style>
|
|
</style>
|