Browse Source

feat: 新增审核列表打回和通过操作

cuiyalong 10 tháng trước cách đây
mục cha
commit
13972fcf84

+ 12 - 1
frontend/src/components/Breadcrumb.vue

@@ -23,4 +23,15 @@ const emit = defineEmits();
 function goBack() {
   router.go(-1);
 }
-</script>
+</script>
+
+<style lang="scss" scoped>
+::v-deep {
+  .el-page-header__left {
+    .el-page-header__back,
+    .el-divider {
+      display: none;
+    }
+  }
+}
+</style>

+ 25 - 9
frontend/src/components/spider/VerifySpider.vue

@@ -3,13 +3,13 @@
 <template>
     <el-dialog title="爬虫配置验证结果" v-model="dialogVisible" width="50%">
         <el-descriptions title="验证结果" direction="vertical" :column="4" border>
-            <el-descriptions-item label="标题">{{ formData.title ? "通过" : "未通过" }}</el-descriptions-item>
-            <el-descriptions-item label="发布单位">{{ formData.publishUnit ? "通过" : "未通过" }}</el-descriptions-item>
-            <el-descriptions-item label="发布时间">{{ formData.publishTime ? "通过" : "未通过" }}</el-descriptions-item>
-            <el-descriptions-item label="正文">{{ formData.content ? "通过" : "未通过" }}</el-descriptions-item>
-            <el-descriptions-item label="附件">{{ formData.attaches ? "通过" : "未通过" }}</el-descriptions-item>
-            <el-descriptions-item label="列表信息条数">{{ formData.listItems ? "通过" : "未通过" }}</el-descriptions-item>
-            <el-descriptions-item label="列表翻页">{{ formData.listTrunPage ? "通过" : "未通过" }}</el-descriptions-item>
+            <el-descriptions-item :class-name="formData.title ? 'c-success' : 'c-danger'" label="标题">{{ formatText(formData.title) }}</el-descriptions-item>
+            <el-descriptions-item :class-name="formData.publishUnit ? 'c-success' : 'c-danger'" label="发布单位">{{ formatText(formData.publishUnit) }}</el-descriptions-item>
+            <el-descriptions-item :class-name="formData.publishTime ? 'c-success' : 'c-danger'" label="发布时间">{{ formatText(formData.publishTime) }}</el-descriptions-item>
+            <el-descriptions-item :class-name="formData.content ? 'c-success' : 'c-danger'" label="正文">{{ formatText(formData.content) }}</el-descriptions-item>
+            <el-descriptions-item :class-name="formData.attaches ? 'c-success' : 'c-danger'" label="附件">{{ formatText(formData.attaches) }}</el-descriptions-item>
+            <el-descriptions-item :class-name="formData.listItems ? 'c-success' : 'c-danger'" label="列表信息条数">{{ formatText(formData.listItems) }}</el-descriptions-item>
+            <el-descriptions-item :class-name="formData.listTrunPage ? 'c-success' : 'c-danger'" label="列表翻页">{{ formatText(formData.listTrunPage) }}</el-descriptions-item>
         </el-descriptions>
     </el-dialog>
 </template>
@@ -24,10 +24,26 @@ const formData = ref({
     listItems: false,
     listTrunPage: false,
 });
-const dialogVisible = ref(false);
+const dialogVisible = ref(false)
+
+const formatText = (f = false) => {
+    return f ? '通过' : '未通过'
+}
+
+
 //这里是重点
 defineExpose({
     dialogVisible,
     formData
 })
-</script>
+</script>
+<style lang="scss" scoped>
+::v-deep {
+    .c-success {
+        color: var(--el-color-success) !important;
+    }
+    .c-danger {
+        color: var(--el-color-danger) !important;
+    }
+}
+</style>

+ 12 - 12
frontend/src/views/CodeList.vue

@@ -56,13 +56,13 @@
         </el-header>
         <el-main>
             <el-table ref="spiderTable" :data="listState.list" stripe :row-style="getRowStyle" v-loading="listState.loading">
-                <el-table-column prop="code" label="代码" show-overflow-tooltip></el-table-column>
-                <el-table-column prop="site" label="网站" show-overflow-tooltip></el-table-column>
-                <el-table-column prop="channel" label="栏目" show-overflow-tooltip></el-table-column>
-                <el-table-column prop="stateText" label="爬虫状态" show-overflow-tooltip></el-table-column>
-                <el-table-column prop="claimText" label="认领状态" show-overflow-tooltip></el-table-column>
+                <el-table-column prop="code" label="代码" align="center" show-overflow-tooltip></el-table-column>
+                <el-table-column prop="site" label="网站" align="center" show-overflow-tooltip></el-table-column>
+                <el-table-column prop="channel" label="栏目" align="center" show-overflow-tooltip></el-table-column>
+                <el-table-column prop="stateText" label="爬虫状态" width="80" align="center" show-overflow-tooltip></el-table-column>
+                <el-table-column prop="claimText" label="认领状态" width="100" align="center" show-overflow-tooltip></el-table-column>
                 <el-table-column prop="href" label="栏目地址" show-overflow-tooltip></el-table-column>
-                <el-table-column prop="modifyuser" label="维护人" width="80" show-overflow-tooltip></el-table-column>
+                <el-table-column prop="modifyuser" label="维护人" width="120" align="center" show-overflow-tooltip></el-table-column>
                 <el-table-column label="操作" width="160" align="center">
                     <template #default="scope">
                   <!-- <el-tooltip content="标注" placement="top">
@@ -95,8 +95,8 @@
                                 <el-icon><Promotion /></el-icon>
                             </el-button>
                         </el-tooltip>
-                        <el-tooltip content="退" placement="top" v-if="showListRollbackButton">
-                            <!-- 爬虫状态是待完成,才可点击退 -->
+                        <el-tooltip content="退" placement="top" v-if="showListRollbackButton">
+                            <!-- 爬虫状态是待完成,才可点击退 -->
                             <el-button size="small" :disabled="scope.row.state !== 0" :class="{ active: scope.row._action_clicked_rollback }" @click="tableEvents.handleRollback(scope.$index, scope.row)">
                                 <el-icon><DArrowLeft /></el-icon>
                             </el-button>
@@ -215,7 +215,7 @@ const showModifyUserFilter = computed(() => [USER_ROLE_ADMIN, USER_ROLE_REVIEWER
 const showRenLingButton = computed(() => [USER_ROLE_DEVELOPER].includes(userRole.value))
 // 是否展示提交按钮(仅开发人员展示)
 const showListDevelopeButton = computed(() => [USER_ROLE_DEVELOPER].includes(userRole.value))
-// 是否展示退按钮(仅开发人员展示)
+// 是否展示退按钮(仅开发人员展示)
 const showListRollbackButton = computed(() => [USER_ROLE_DEVELOPER].includes(userRole.value))
 
 // 实现待认领不能和维护人同时筛选
@@ -610,7 +610,7 @@ const tableEvents = {
     },
     handleRollback(_, row) {
         onlyClickHighlight(row, '_action_clicked_rollback')
-        ElMessageBox.alert('确定退?', '提示', {
+        ElMessageBox.alert('确定退?', '提示', {
             customClass: 'j-confirm-message-box',
             confirmButtonText: '确定',
             callback: (action) => {
@@ -626,14 +626,14 @@ const tableEvents = {
         ServerActionUpdateCodeState({ lua: lua }).then(r => {
             if (r.err === 1) {
                 ElMessage({
-                    message: '退成功',
+                    message: '退成功',
                     type: 'success',
                     duration: 3000,
                 })
                 getTableList()
             } else {
                 return ElMessage({
-                    message: r.msg || '退失败',
+                    message: r.msg || '退失败',
                     type: 'error',
                     duration: 3000,
                 })

+ 132 - 88
frontend/src/views/ReviewList.vue

@@ -55,13 +55,13 @@
         </el-header>
         <el-main>
             <el-table ref="spiderTable" :data="listState.list" stripe :row-style="getRowStyle" v-loading="listState.loading">
-                <el-table-column prop="code" label="代码" show-overflow-tooltip></el-table-column>
-                <el-table-column prop="site" label="网站" show-overflow-tooltip></el-table-column>
-                <el-table-column prop="channel" label="栏目" show-overflow-tooltip></el-table-column>
-                <el-table-column prop="stateText" label="爬虫状态" show-overflow-tooltip></el-table-column>
-                <el-table-column prop="claimText" label="认领状态" show-overflow-tooltip></el-table-column>
+                <el-table-column prop="code" label="代码" align="center" show-overflow-tooltip></el-table-column>
+                <el-table-column prop="site" label="网站" align="center" show-overflow-tooltip></el-table-column>
+                <el-table-column prop="channel" label="栏目" align="center" show-overflow-tooltip></el-table-column>
+                <el-table-column prop="stateText" label="爬虫状态" width="80" align="center" show-overflow-tooltip></el-table-column>
+                <el-table-column prop="claimText" label="认领状态" width="100" align="center" show-overflow-tooltip></el-table-column>
                 <el-table-column prop="href" label="栏目地址" show-overflow-tooltip></el-table-column>
-                <el-table-column prop="modifyuser" label="维护人" width="80" show-overflow-tooltip></el-table-column>
+                <el-table-column prop="modifyuser" label="维护人" width="120" align="center" show-overflow-tooltip></el-table-column>
                 <el-table-column label="操作" width="160" align="center">
                     <template #default="scope">
                   <!-- <el-tooltip content="标注" placement="top">
@@ -88,18 +88,33 @@
                 </el-table-column>
                 <el-table-column label="功能" width="120" align="center">
                     <template #default="scope">
-                        <el-tooltip content="提交" placement="top" v-if="showListDevelopeButton">
-                            <!-- 爬虫状态是待完成,才可点击提交 -->
-                            <el-button size="small" :disabled="scope.row.state !== 0" :class="{ active: scope.row._action_clicked_submit }" @click="tableEvents.handleSubmit(scope.$index, scope.row)">
-                                <el-icon><Promotion /></el-icon>
-                            </el-button>
-                        </el-tooltip>
-                        <el-tooltip content="回退" placement="top" v-if="showListRollbackButton">
-                            <!-- 爬虫状态是待完成,才可点击回退 -->
-                            <el-button size="small" :disabled="scope.row.state !== 0" :class="{ active: scope.row._action_clicked_rollback }" @click="tableEvents.handleRollback(scope.$index, scope.row)">
-                                <el-icon><DArrowLeft /></el-icon>
-                            </el-button>
-                        </el-tooltip>
+                        <!-- 审核人员:打回和通过 -->
+                        <div v-if="isReviewer">
+                            <el-tooltip content="通过" placement="top">
+                                <el-button size="small" :class="{ active: scope.row._action_clicked_submit }" @click="tableEvents.reviewerSubmit(scope.$index, scope.row)">
+                                    <el-icon><CircleCheck /></el-icon>
+                                </el-button>
+                            </el-tooltip>
+                            <el-tooltip content="打回" placement="top">
+                                <el-button size="small" :class="{ active: scope.row._action_clicked_rollback }" @click="tableEvents.reviewerRollback(scope.$index, scope.row)">
+                                    <el-icon><CircleClose /></el-icon>
+                                </el-button>
+                            </el-tooltip>
+                            
+                        </div>
+                        <!-- 管理员:上线和退回 -->
+                        <div v-if="isAdmin">
+                            <el-tooltip content="上线" placement="top">
+                                <el-button size="small" :class="{ active: scope.row._action_clicked_submit }" @click="tableEvents.adminSubmit(scope.$index, scope.row)">
+                                    <el-icon><UploadFilled /></el-icon>
+                                </el-button>
+                            </el-tooltip>
+                            <el-tooltip content="退回" placement="top">
+                                <el-button size="small" :class="{ active: scope.row._action_clicked_rollback }" @click="tableEvents.adminRollback(scope.$index, scope.row)">
+                                    <el-icon><DArrowLeft /></el-icon>
+                                </el-button>
+                            </el-tooltip>
+                        </div>
                     </template>
                 </el-table-column>
             </el-table>
@@ -215,29 +230,27 @@ const prevClickedRow = ref({})
 const userRole = computed(() => store.getters.userRole)
 // 是否展示维护人模块(管理员和审核员展示)
 const showModifyUserFilter = computed(() => [USER_ROLE_ADMIN, USER_ROLE_REVIEWER].includes(userRole.value))
-// 是否展示提交按钮(仅开发人员展示)
-const showListDevelopeButton = computed(() => [USER_ROLE_DEVELOPER].includes(userRole.value))
-// 是否展示回退按钮(仅开发人员展示)
-const showListRollbackButton = computed(() => [USER_ROLE_DEVELOPER].includes(userRole.value))
 
 // 实现待认领不能和维护人同时筛选
 // 是否禁用维护人模块(待认领筛选下,禁用维护人筛选模块)
 const modifyUserSelectDisabled = computed(() => filters.claimtype === 0)
 // 是否禁用待认领筛选(维护人不为全部,则禁用待认领的选中)
-const stopWatch = watch(() => filters.modifyuser, (n) => {
-    const target = filterConfig.claimOptions.find(i => i.value === 0)
-    if (target) {
-        if (n === defaultFilters.modifyuser) {
-            // 解除禁用待认领
-            target.disabled = false
-        } else {
-            // 禁用待认领
-            target.disabled = true
-        }
-    } else {
-        stopWatch()
-    }
-})
+// const stopWatch = watch(() => filters.modifyuser, (n) => {
+//     const target = filterConfig.claimOptions.find(i => i.value === 0)
+//     if (target) {
+//         if (n === defaultFilters.modifyuser) {
+//             // 解除禁用待认领
+//             target.disabled = false
+//         } else {
+//             // 禁用待认领
+//             target.disabled = true
+//         }
+//     } else {
+//         stopWatch()
+//     }
+// })
+const isReviewer = computed(() => [USER_ROLE_REVIEWER].includes(userRole.value))
+const isAdmin = computed(() => [USER_ROLE_ADMIN].includes(userRole.value))
 
 const changeFilterDefaultValue = () => {
     // 根据用户身份
@@ -572,83 +585,114 @@ const tableEvents = {
             loading.value = false
         })
     },
-    handleSubmit(index, row) {
-        onlyClickHighlight(row, '_action_clicked_submit')
+    // 操作按钮-----
+    updateCodeStateAction(row, info) {
         const lua = getLuaParams(row)
-        lua.state = 1
+        lua.state = info.state
+        lua.reason = info.reason
         ServerActionUpdateCodeState({ lua: lua }).then(r => {
             if (r.err === 1) {
                 ElMessage({
-                    message: '提交成功',
+                    message: r.msg || info.successTip,
                     type: 'success',
                     duration: 3000,
                 })
                 getTableList()
             } else {
                 return ElMessage({
-                    message: r.msg || '提交失败',
+                    message: r.msg || info.errorTip,
                     type: 'error',
                     duration: 3000,
                 })
             }
         })
     },
-    handleRollback(_, row) {
+    // 审核打回
+    reviewerRollback(_, row) {
+        console.log('审核打回', row)
         onlyClickHighlight(row, '_action_clicked_rollback')
-        ElMessageBox.alert('确定回退?', '提示', {
-            customClass: 'j-confirm-message-box',
-            confirmButtonText: '确定',
-            callback: (action) => {
-                if (action === 'confirm') {
-                    this.confirmRollback(row)
-                }
-            },
+        ElMessageBox.prompt('请输入打回原因', '审核打回', {
+            confirmButtonText: '确认打回',
+            cancelButtonText: '取消',
+            inputPattern: /^.+$/, // 非空
+            inputErrorMessage: '不能为空',
+        })
+        .then(({ value }) => {
+            this.updateCodeStateAction(row, {
+                reason: value,
+                state: 2,
+                successTip: '打回成功',
+                errorTip: '打回失败',
+            })
         })
     },
-    confirmRollback(row) {
-        const lua = getLuaParams(row)
-        lua.state = 12
-        ServerActionUpdateCodeState({ lua: lua }).then(r => {
-            if (r.err === 1) {
-                ElMessage({
-                    message: '回退成功',
-                    type: 'success',
-                    duration: 3000,
-                })
-                getTableList()
-            } else {
-                return ElMessage({
-                    message: r.msg || '回退失败',
-                    type: 'error',
-                    duration: 3000,
-                })
+    // 审核提交
+    reviewerSubmit(_, row) {
+        console.log('审核提交', row)
+        onlyClickHighlight(row, '_action_clicked_submit')
+        ElMessageBox.confirm('确认提交?', '提示',
+            {
+                confirmButtonText: '确认',
+                cancelButtonText: '取消',
+                type: 'warning',
+            }
+        ).then(() => {
+            this.updateCodeStateAction(row, {
+                state: 3,
+                successTip: '提交成功',
+                errorTip: '提交失败',
+            })
+        })
+    },
+    // 管理上线
+    adminSubmit(_, row) {
+        console.log('管理上线', row)
+        onlyClickHighlight(row, '_action_clicked_submit')
+        ElMessageBox.confirm('确认上线?', '提示',
+            {
+                confirmButtonText: '确认',
+                cancelButtonText: '取消',
+                type: 'warning',
             }
+        ).then(() => {
+            this.updateCodeStateAction(row, {
+                state: 11,
+                successTip: '上线成功',
+                errorTip: '上线失败',
+            })
+        })
+    },
+    // 管理退回
+    adminRollback(_, row) {
+        console.log('管理退回', row)
+        onlyClickHighlight(row, '_action_clicked_rollback')
+        ElMessageBox.confirm('确认退回?', '提示',
+            {
+                confirmButtonText: '确认',
+                cancelButtonText: '取消',
+                type: 'warning',
+            }
+        ).then(() => {
+            this.updateCodeStateAction(row, {
+                state: 12,
+                successTip: '退回成功',
+                errorTip: '退回失败',
+            })
         })
     },
 }
 
 //Wails事件绑定
-EventsOn("spiderConfigChange", data => {
-    console.log(data)
-    const { key, css, url } = data
-    refreshAndAsyncEditDialog(key, css)
-    // 当触发修改时候,同步给客服端一份
-    if (currentEditRow.value && Object.keys(currentEditRow.value).length <= 0) {
-        const mark = getMarkWithRow(currentEditRow.value)
-        ServerActionCurrentOpenTab(mark)
-    }
-    // 判断标注url和编辑url是否相同
-    // const editUrl = currentEditRow.href
-    // if (url === editUrl) {
-    //     refreshAndAsyncEditDialog(key, css[key])
-    // } else {
-    //     ElMessage({
-    //         message: `标注url和编辑url不匹配,此次更新取消。当前标注url: ${url},当前编辑url: ${editUrl}`,
-    //         type: 'warn',
-    //         duration: 4000,
-    //     })
-    // }
-})
+// EventsOn("spiderConfigChange", data => {
+//     console.log(data)
+//     const { key, css, url } = data
+//     refreshAndAsyncEditDialog(key, css)
+//     // 当触发修改时候,同步给客服端一份
+//     if (currentEditRow.value && Object.keys(currentEditRow.value).length <= 0) {
+//         const mark = getMarkWithRow(currentEditRow.value)
+//         ServerActionCurrentOpenTab(mark)
+//     }
+// })
 </script>
 
 <style lang="scss" scoped>