Browse Source

feat: 批量通过 驳回

main
buaixuexideshitongxue 1 month ago
parent
commit
3871b14718
  1. 55
      src/components/reportAudit/finishDistrbute.vue
  2. 74
      src/views/warning/index.vue

55
src/components/reportAudit/finishDistrbute.vue

@ -8,7 +8,7 @@ import {getList,save,delCommon} from '@/api/commonOpinions';
import useCatchStore from "@/stores/modules/catch";
import useUserStore from "@/stores/modules/user";
const userStore = useUserStore();
const props = defineProps(['dialog','reportId','nextNode','message',"isWarning","flowId"])
const props = defineProps(['dialog','reportId','nextNode','message',"isWarning","flowId","batchItems"])
const emits = defineEmits(['submitFeedback',"closeFun"])
const catchStore = useCatchStore();
@ -19,6 +19,7 @@ const formData = ref({
data:{}
})
const auditForm= ref()
const submitLoading = ref(false)
const dict = catchStore.getDicts([
"businessType",
"suspectProblem",
@ -99,23 +100,43 @@ const closeAdd=()=>{
}
const submitFun = async ()=>{
await auditForm.value.validate();
await feedback.confirm("是否确认通过?");
formData.value.reportId = props.reportId;
formData.value.flowId = props.flowId;
//nextNode
if(props.nextNode){
formData.value.nextNode = props.nextNode;
}
if(props.isWarning){
const res = await auditPassWarningDistribute(formData.value);
// const res = await auditWarning(formData.value);
}else{
const res = await auditReport(formData.value);
const isBatch = Array.isArray(props.batchItems) && props.batchItems.length > 0
const targets = isBatch ? props.batchItems : [{
reportId: props.reportId,
flowId: props.flowId
}]
await feedback.confirm(isBatch ? `是否确认批量通过选中的 ${targets.length} 个项目?` : "是否确认通过?");
submitLoading.value = true
try {
const createSubmitData = (target) => ({
...formData.value,
data: {...formData.value.data},
reportId: target.reportId,
flowId: target.flowId,
nextNode: props.nextNode || formData.value.nextNode
})
if (isBatch) {
const results = await Promise.allSettled(targets.map(target =>
auditPassWarningDistribute(createSubmitData(target))
))
const successCount = results.filter(item => item.status === 'fulfilled').length
const failCount = results.length - successCount
if (failCount > 0) {
feedback.msgError(`批量通过完成:成功 ${successCount} 个,失败 ${failCount}`)
} else {
feedback.msgSuccess(`已批量通过 ${successCount} 个项目`)
}
} else if(props.isWarning){
await auditPassWarningDistribute(createSubmitData(targets[0]));
}else{
await auditReport(createSubmitData(targets[0]));
}
emits('submitFeedback',true)
closeAdd()
} finally {
submitLoading.value = false
}
emits('submitFeedback',true)
closeAdd()
}
@ -295,7 +316,7 @@ watch(()=>formData.value.approverId,(val)=>{
</el-form>
<div class="flex end">
<el-button @click="closeAdd">关闭</el-button>
<el-button type="primary" @click="submitFun">提交</el-button>
<el-button type="primary" :loading="submitLoading" @click="submitFun">提交</el-button>
</div>
</el-dialog>
</template>

74
src/views/warning/index.vue

@ -2,11 +2,17 @@
<script setup>
import {warningPage, excelWarningList} from "@/api/warning/index";
import {auditRejectWarning} from "@/api/warning/business";
import {timeFormat} from "@/utils/util";
import {useRoute} from "vue-router";
import feedback from "@/utils/feedback";
import finishDistrbute from '@/components/reportAudit/finishDistrbute.vue';
const route = useRoute()
const loading =ref(false)
const exportLoading = ref(false)
const batchRejectLoading = ref(false)
const finishDialog = ref(false)
const selectedRows = ref([])
const total =ref(10)
const tableData =ref([])
const activeTab = ref(route.query.specialArea === 'cwlnt' ? 'cwlnt' : route.query.warningState === '1' ? '1' : '0')
@ -44,6 +50,44 @@ const reset =()=>{
getList();
}
const warningStateDisabled = computed(() => activeTab.value !== 'cwlnt' && activeTab.value !== 'all')
const batchItems = computed(() => selectedRows.value.map(row => ({
reportId: row.id,
flowId: row.flowId
})))
const handleSelectionChange = (rows) => {
selectedRows.value = rows
}
const selectable = (row) => Boolean(row.flowId)
const handleBatchPass = () => {
finishDialog.value = true
}
const handleBatchPassSuccess = () => {
finishDialog.value = false
selectedRows.value = []
getList()
}
const handleBatchReject = async () => {
await feedback.confirm(`确定批量驳回选中的 ${selectedRows.value.length} 个项目吗?`)
batchRejectLoading.value = true
try {
const results = await Promise.allSettled(selectedRows.value.map(row => auditRejectWarning({
flowId: row.flowId,
reportId: row.id,
approverMessage: ''
})))
const successCount = results.filter(item => item.status === 'fulfilled').length
const failCount = results.length - successCount
if (failCount > 0) {
feedback.msgError(`批量驳回完成:成功 ${successCount} 个,失败 ${failCount}`)
} else {
feedback.msgSuccess(`已批量驳回 ${successCount} 个项目`)
}
selectedRows.value = []
getList()
} finally {
batchRejectLoading.value = false
}
}
const getList = async ()=>{
loading.value=true
const res = await warningPage(query.value)
@ -146,6 +190,19 @@ watch(()=>route.query.load,(val)=>{
</el-form>
<div class="flex end">
<div>
<template v-if="activeTab === '2'">
<el-button
type="success"
:disabled="selectedRows.length === 0"
@click="handleBatchPass"
>批量通过</el-button>
<el-button
type="danger"
:disabled="selectedRows.length === 0"
:loading="batchRejectLoading"
@click="handleBatchReject"
>批量驳回</el-button>
</template>
<el-button type="primary" :loading="exportLoading" @click="handleExcel">导出</el-button>
<el-button type="primary" @click="getList">
<template #icon>
@ -166,7 +223,13 @@ watch(()=>route.query.load,(val)=>{
<el-tab-pane label="已预警" name="1"></el-tab-pane>
<el-tab-pane label="长望浏宁" name="cwlnt"></el-tab-pane>
</el-tabs>
<el-table :data="tableData">
<el-table :data="tableData" @selection-change="handleSelectionChange">
<el-table-column
v-if="activeTab === '2'"
type="selection"
width="50"
:selectable="selectable"
/>
<el-table-column label="项目名称" prop="reportName" width="200" />
<el-table-column
label="报审类型"
@ -294,6 +357,15 @@ watch(()=>route.query.load,(val)=>{
<p>
列表根据权限范围展示涉及的可预警项目针对项目进行问题预警报审单位签收
</p>
<finish-distrbute
v-if="finishDialog"
@submitFeedback="handleBatchPassSuccess"
@closeFun="finishDialog = false"
:isWarning="true"
:batchItems="batchItems"
:dialog="finishDialog"
:nextNode="'end'"
/>
</el-main>
</div>
</template>

Loading…
Cancel
Save