Эх сурвалжийг харах

feat: 批量上线下线多选提交逻辑完善

cuiyalong 9 сар өмнө
parent
commit
fdce1c917d

+ 31 - 8
frontend/src/views/ReviewList.vue

@@ -479,7 +479,7 @@ const tableActionShow = {
         const canOnline = row.state === 3
         return canOnline
     },
-    downCode() {
+    downCode(row) {
         // 下线按钮,只有已上线爬虫展示
         return row.state === 11
     },
@@ -815,31 +815,54 @@ const tableEvents = {
     },
 }
 
+const toggleRow = (rowList = []) => {
+    const ignoreSelectable = false
+    rowList.forEach(row => {
+        spiderTable.value?.toggleRowSelection(
+            row,
+            undefined,
+            ignoreSelectable
+        )
+    })
+}
+
 const tableRowSelectable = (row) => {
-    return row.state === 3
+    // 审核通过或者已上线的才能选
+    return row.state === 3 || row.state === 11
 }
 
 // 执行批量上线
 const doBatchListing = () => {
-    if (listState.selected.length <= 0) {
+    // 过滤一下,找到已通过爬虫,仅提交此类爬虫(因为能选中的只有3和11,所以直接过滤获取2组)
+    const list = listState.selected.filter(v => v.state === 3)
+    const dropList = listState.selected.filter(v => v.state === 11)
+    toggleRow(dropList)
+    if (list.length <= 0) {
         return ElMessage({
-            message: '至少要选中1条数据',
+            message: '至少要选中1条有效数据: 当前未选中已通过爬虫',
             type: 'error',
             duration: 3000,
         })
     }
-    tableEvents.batchListing(listState.selected, 'up')
+    // 判断爬虫中是否有其他类型,如果有,将其他类型爬虫取消选中
+
+
+    tableEvents.batchListing(list, 'up')
 }
 // 执行批量下线操作
 const doUnBatchListing = () => {
-    if (listState.selected.length <= 0) {
+    // 过滤一下,找到已上线爬虫,仅提交此类爬虫(因为能选中的只有3和11,所以直接过滤获取2组)
+    const list = listState.selected.filter(v => v.state === 11)
+    const dropList = listState.selected.filter(v => v.state === 3)
+    toggleRow(dropList)
+    if (list.length <= 0) {
         return ElMessage({
-            message: '至少要选中1条数据',
+            message: '至少要选中1条有效数据: 当前未选中已上线爬虫',
             type: 'error',
             duration: 3000,
         })
     }
-    tableEvents.batchListing(listState.selected, 'down')
+    tableEvents.batchListing(list, 'down')
 }
 
 //Wails事件绑定