浏览代码

锅炉批量认领设备

xy 2 周之前
父节点
当前提交
79adb2758f

+ 4 - 0
yudao-ui-admin-vue3/src/api/pressure2/boilertaskorder/index.ts

@@ -228,6 +228,10 @@ export const BoilerTaskOrderApi = {
   cancelClaim: async (data: any) => {
     return await request.post({ url: `/pressure2/boiler-task-order/order-item/cancelClaim`, data })
   },
+  //批量认领
+  batchClaim: async (data: any) => {
+    return await request.post({ url: `/pressure2/boiler-task-order/order-item/batch-claim`, data })
+  },
   // 查询锅炉任务单详情
   getTaskOrder: async (id: string) => {
     return await request.get({ url: `/pressure2/boiler-task-order/get?id=` + id })

+ 37 - 1
yudao-ui-admin-vue3/src/views/pressure2/boilerchecker/myTask.vue

@@ -210,6 +210,9 @@
       <!-- 按钮区保持不变 -->
       <el-row class="flex justify-end mt-2">
         <el-form-item>
+          <el-button type="primary" @click="handleBatchClaim" :disabled="selectedRows.length === 0">
+            批量认领 ({{ selectedRows.length }})
+          </el-button>
           <el-button @click="handleQuery">
             <Icon icon="ep:search" class="mr-5px" />
             搜索
@@ -265,6 +268,7 @@
       border
       class-name="cursor-pointer"
       @row-dblclick="handleRowDblclick"
+      @selection-change="handleTableSelectionChange"
     >
       <el-table-column type="selection" align="center" width="55" />
       <el-table-column
@@ -498,7 +502,7 @@
             </el-button>
             <el-button
               v-if="
-                scope.row.taskStatus == 400 &&
+                scope.row.taskStatus == 500 &&
                 scope.row.isClaim == true &&
                 scope.row.mainCheckerUser &&
                 userStore.user.id === scope.row.mainCheckerUser.id
@@ -902,6 +906,38 @@ const userColumns = ref<any[]>([
 const printProjectDialogVisible = ref(false)
 const printProjectList = ref([])
 const selectionProject = ref([])
+
+// 批量认领相关
+const selectedRows = ref<any[]>([])
+const handleTableSelectionChange = (selection: any[]) => {
+  selectedRows.value = selection
+}
+
+const handleBatchClaim = () => {
+  if (selectedRows.value.length === 0) {
+    ElMessage.warning('请先选择要认领的设备')
+    return
+  }
+  // 过滤出未认领的
+  const unClaimed = selectedRows.value.filter((row) => !row.isClaim)
+  if (unClaimed.length === 0) {
+    ElMessage.warning('所选设备均已认领')
+    return
+  }
+  ElMessageBox.confirm(`确认批量认领 ${unClaimed.length} 个设备?`, '提示', {
+    confirmButtonText: '确定',
+    cancelButtonText: '取消',
+    type: 'warning'
+  })
+    .then(() => {
+      const orderItemIdList = unClaimed.map((row) => row.id)
+      BoilerTaskOrderApi.batchClaim({ orderItemIdList }).then(() => {
+        ElMessage.success(`成功认领 ${orderItemIdList.length} 个设备`)
+        getList()
+      })
+    })
+    .catch(() => {})
+}
 const printProject = (reportDOList) => {
   printProjectDialogVisible.value = true
   printProjectList.value = reportDOList