Browse Source

选择审核人

徐展城 6 days ago
parent
commit
3df43a0c7b

+ 59 - 58
yudao-ui-admin-vue3/src/views/pressure2/boilerchecker/components/StatusOperationPanel.vue

@@ -476,26 +476,22 @@
         title="请选择审核人"
       >
         <el-select
-          v-model="reportAuditUser"
+          v-model="reportAuditUserCode"
           filterable
-          remote
-          reserve-keyword
           placeholder="请选择审核人"
-          :remote-method="searchReportAuditUser"
           :loading="reportAuditUserLoading"
           clearable
-          value-key="code"
           style="width: 100%"
         >
           <el-option
             v-for="item in reportAuditUserOptions"
             :key="item.code"
             :label="item.name"
-            :value="item"
+            :value="item.code"
           />
         </el-select>
         <template #footer>
-          <el-button type="primary" @click="handleReportAuditSelectConfirm">确 定</el-button>
+          <el-button type="primary" :loading="reportAuditSubmitting" @click="handleReportAuditSelectConfirm">确 定</el-button>
           <el-button @click="isShowReportAuditDialog = false">取 消</el-button>
         </template>
       </Dialog>
@@ -1786,6 +1782,19 @@ const currentReportConfig = computed(() => {
 
 // 选择报告审核人弹窗的显示和隐藏
 const isShowReportAuditDialog = ref(false)
+
+// 弹窗打开时预加载审核人列表
+watch(isShowReportAuditDialog, (val) => {
+  if (val) {
+    reportAuditUserLoading.value = true
+    getReviewUserList({ pageNo: 1, pageSize: 200, name: '' }).then((res) => {
+      reportAuditUserOptions.value = res || []
+    }).finally(() => {
+      reportAuditUserLoading.value = false
+    })
+  }
+})
+
 // 提交报告审核
 const handleSubmitAudit = async () => {
 
@@ -1858,34 +1867,34 @@ const handleSubmitAudit = async () => {
   } else {
     // 确定审核人:使用当前用户,否则使用默认审核人
     // const approveId = userStore.user.id
-    const approveId = 'b5369aeb73954430eef53a9c8b7586ee'
-    
-    ElMessageBox.confirm('确定提交审核吗?', '提示', {
-      confirmButtonText: '确定',
-      cancelButtonText: '取消',
-      type: 'warning'
-    }).then(async () => {
-      const loadingInstance = ElLoading.service({
-        fullscreen: true,
-        text: '正在提交审核...'
-      })
-      try {
-        const submitResult = await BoilerTaskOrderApi.submitReportAudit({
-          id: templateParams.value?.id,
-          approveId
-        })
-        if (submitResult) {
-          ElMessage.success('提交审核成功!')
-          selectNextItem([props.selectedItem])
-          emit('template-confirm')
-        }
-      } finally {
-        loadingInstance.close()
-      }
-    }).catch(() => {
-      console.log('用户取消提交审核')
-    })
-    // isShowReportAuditDialog.value = true
+    // const approveId = 'b5369aeb73954430eef53a9c8b7586ee'
+    //
+    // ElMessageBox.confirm('确定提交审核吗?', '提示', {
+    //   confirmButtonText: '确定',
+    //   cancelButtonText: '取消',
+    //   type: 'warning'
+    // }).then(async () => {
+    //   const loadingInstance = ElLoading.service({
+    //     fullscreen: true,
+    //     text: '正在提交审核...'
+    //   })
+    //   try {
+    //     const submitResult = await BoilerTaskOrderApi.submitReportAudit({
+    //       id: templateParams.value?.id,
+    //       approveId
+    //     })
+    //     if (submitResult) {
+    //       ElMessage.success('提交审核成功!')
+    //       selectNextItem([props.selectedItem])
+    //       emit('template-confirm')
+    //     }
+    //   } finally {
+    //     loadingInstance.close()
+    //   }
+    // }).catch(() => {
+    //   console.log('用户取消提交审核')
+    // })
+    isShowReportAuditDialog.value = true
   }
 }
 
@@ -2080,38 +2089,30 @@ const checkOtherReportsFinished = (): { canSubmit: boolean; message?: string } =
 }
 
 // 报告审核人选择对话框 - 远程搜索选项
-const reportAuditUser = ref<Recordable | null>(null)
+const reportAuditUserCode = ref<string>('')
 const reportAuditUserOptions = ref<Recordable[]>([])
 const reportAuditUserLoading = ref(false)
-
-// 远程搜索报告审核人
-const searchReportAuditUser = async (query: string) => {
-  reportAuditUserLoading.value = true
-  try {
-    const params: any = { pageNo: 1, pageSize: 50, name: query || '' }
-    const res = await getReviewUserList(params)
-    reportAuditUserOptions.value = res || []
-  } finally {
-    reportAuditUserLoading.value = false
-  }
-}
+const reportAuditSubmitting = ref(false)
 
 // 报告审核人选择确认
 const handleReportAuditSelectConfirm = async () => {
-  if (!reportAuditUser.value?.code) {
+  if (!reportAuditUserCode.value) {
     ElMessage.warning('请选择审核人')
     return
   }
-  const approveCode = reportAuditUser.value.code
-  const submitResult = await PipeTaskOrderApi.submitReportAudit({
-    id: templateParams.value?.id,
-    auditor: approveCode
-  })
-  if (submitResult) {
-    // 这里可以做页面刷新
-    emit('template-confirm')
+  reportAuditSubmitting.value = true
+  try {
+    const submitResult = await PipeTaskOrderApi.submitReportAudit({
+      id: templateParams.value?.id,
+      auditor: reportAuditUserCode.value
+    })
+    if (submitResult) {
+      emit('template-confirm')
+    }
+    isShowReportAuditDialog.value = false
+  } finally {
+    reportAuditSubmitting.value = false
   }
-  isShowReportAuditDialog.value = false
 }
 /**** 葡萄城:报告编制的显示和隐藏 end ****/
 

+ 56 - 61
yudao-ui-admin-vue3/src/views/pressure2/pipechecker/components/StatusOperationPanel.vue

@@ -476,26 +476,21 @@
         title="请选择审核人"
       >
         <el-select
-          v-model="reportAuditUser"
+          v-model="reportAuditUserCode"
           filterable
-          remote
-          reserve-keyword
           placeholder="请选择审核人"
-          :remote-method="searchReportAuditUser"
-          :loading="reportAuditUserLoading"
           clearable
-          value-key="id"
           style="width: 100%"
         >
           <el-option
             v-for="item in reportAuditUserOptions"
             :key="item.id"
             :label="item.name"
-            :value="item"
+            :value="item.code"
           />
         </el-select>
         <template #footer>
-          <el-button type="primary" @click="handleReportAuditSelectConfirm">确 定</el-button>
+          <el-button type="primary" :loading="reportAuditSubmitting" @click="handleReportAuditSelectConfirm">确 定</el-button>
           <el-button @click="isShowReportAuditDialog = false">取 消</el-button>
         </template>
       </Dialog>
@@ -1827,34 +1822,34 @@ const handleSubmitAudit = async () => {
 
     // 确定审核人:使用当前用户,否则使用默认审核人
     // const approveId = userStore.user.id
-    const approveId = 'b5369aeb73954430eef53a9c8b7586ee'
-    
-    ElMessageBox.confirm('确定提交审核吗?', '提示', {
-      confirmButtonText: '确定',
-      cancelButtonText: '取消',
-      type: 'warning'
-    }).then(async () => {
-      const loadingInstance = ElLoading.service({
-        fullscreen: true,
-        text: '正在提交审核...'
-      })
-      try {
-        const submitResult = await PipeTaskOrderApi.submitReportAudit({
-          id: templateParams.value?.id,
-          approveId
-        })
-        if (submitResult) {
-          ElMessage.success('提交审核成功!')
-          selectNextItem([props.selectedItem])
-          emit('template-confirm')
-        }
-      } finally {
-        loadingInstance.close()
-      }
-    }).catch(() => {
-      console.log('用户取消提交审核')
-    })
-    // isShowReportAuditDialog.value = true
+    // const approveId = 'b5369aeb73954430eef53a9c8b7586ee'
+    //
+    // ElMessageBox.confirm('确定提交审核吗?', '提示', {
+    //   confirmButtonText: '确定',
+    //   cancelButtonText: '取消',
+    //   type: 'warning'
+    // }).then(async () => {
+    //   const loadingInstance = ElLoading.service({
+    //     fullscreen: true,
+    //     text: '正在提交审核...'
+    //   })
+    //   try {
+    //     const submitResult = await PipeTaskOrderApi.submitReportAudit({
+    //       id: templateParams.value?.id,
+    //       approveId
+    //     })
+    //     if (submitResult) {
+    //       ElMessage.success('提交审核成功!')
+    //       selectNextItem([props.selectedItem])
+    //       emit('template-confirm')
+    //     }
+    //   } finally {
+    //     loadingInstance.close()
+    //   }
+    // }).catch(() => {
+    //   console.log('用户取消提交审核')
+    // })
+    isShowReportAuditDialog.value = true
   }
 }
 
@@ -1968,40 +1963,40 @@ const checkOtherReportsFinished = (): { canSubmit: boolean; message?: string } =
   return { canSubmit: true }
 }
 
-// 报告审核人选择对话框 - 远程搜索选项
-const reportAuditUser = ref<Recordable | null>(null)
+// 报告审核人选择对话框
+const reportAuditUserCode = ref<string>('')
 const reportAuditUserOptions = ref<Recordable[]>([])
-const reportAuditUserLoading = ref(false)
-
-// 远程搜索报告审核人
-const searchReportAuditUser = async (query: string) => {
-  reportAuditUserLoading.value = true
-  try {
-    const params: any = { pageNo: 1, pageSize: 50, name: query || '' }
-    const res = await getPipeReviewUserList(params)
-    reportAuditUserOptions.value = res || []
-  } finally {
-    reportAuditUserLoading.value = false
-  }
-}
+const reportAuditSubmitting = ref(false)
 
 // 报告审核人选择确认
 const handleReportAuditSelectConfirm = async () => {
-  if (!reportAuditUser.value?.code) {
+  if (!reportAuditUserCode.value) {
     ElMessage.warning('请选择审核人')
     return
   }
-  const approveCode = reportAuditUser.value.code
-  const submitResult = await PipeTaskOrderApi.submitReportAudit({
-    id: templateParams.value?.id,
-    auditor: approveCode
-  })
-  if (submitResult) {
-    // 这里可以做页面刷新
-    emit('template-confirm')
+  reportAuditSubmitting.value = true
+  try {
+    const submitResult = await PipeTaskOrderApi.submitReportAudit({
+      id: templateParams.value?.id,
+      auditor: reportAuditUserCode.value
+    })
+    if (submitResult) {
+      emit('template-confirm')
+    }
+    isShowReportAuditDialog.value = false
+  } finally {
+    reportAuditSubmitting.value = false
   }
-  isShowReportAuditDialog.value = false
 }
+
+// 监听报告审核对话框打开,预加载审核人选项
+watch(isShowReportAuditDialog, (val) => {
+  if (val) {
+    getPipeReviewUserList({ pageNo: 1, pageSize: 200, name: '' }).then((res) => {
+      reportAuditUserOptions.value = res || []
+    })
+  }
+})
 /**** 葡萄城:报告编制的显示和隐藏 end ****/
 
 const handleModifyChecker = () => {