Pārlūkot izejas kodu

feat: 编辑爬虫提交校验

cuiyalong 9 mēneši atpakaļ
vecāks
revīzija
ebc666640f
1 mainītis faili ar 28 papildinājumiem un 2 dzēšanām
  1. 28 2
      frontend/src/components/spider/EditSpider.vue

+ 28 - 2
frontend/src/components/spider/EditSpider.vue

@@ -203,6 +203,7 @@
 </template>
 <script setup>
 import { ref, defineEmits, computed, watchEffect } from 'vue';
+import { ElMessage, ElMessageBox } from 'element-plus'
 import { TemplateJsCode } from './jscodetpl.js'
 import { Link } from '@element-plus/icons-vue'
 import { useStore } from 'vuex'
@@ -450,12 +451,37 @@ const getPageData = () => {
     }
 }
 
-const handleSave = () => {
-    // dialogVisible.value = false;
+const emitSaveEvent = () => {
     const payload = getPageData()
     emit("custom-event", payload)
     // formData.value = {}
 }
+const handleSave = () => {
+    if (!formData.value.listBodyCss) {
+        return ElMessage({
+            message: '条目区域块不能为空',
+            type: 'error',
+            duration: 3000,
+        })
+    }
+
+    // 如果有js,则需要二次确认
+    if (formData.value.contentJs || formData.value.listJs) {
+        ElMessageBox.confirm('是否保存列表页JS代码或详情页JS代码?', '提示',
+            {
+                customClass: 'j-confirm-message-box',
+                type: 'warning',
+                confirmButtonText: '确定',
+                cancelButtonText: '取消',
+                showCancelButton: false,
+            }
+        ).then(() => {
+            emitSaveEvent()
+        })
+    } else {
+        emitSaveEvent()
+    }
+}
 
 const handleDataTag = () => {
     emit('data-tag', originData)