From 00239519ba9c0561ce7e3490e5cff27b68b5e077 Mon Sep 17 00:00:00 2001
From: guoshilong <123456>
Date: Fri, 17 Mar 2023 11:38:02 +0800
Subject: [PATCH] 添加开始页和结束页判断

---
 src/views/modules/function.vue    |   55 +++++++++++++++++++--------
 src/views/modules/modulesView.vue |   18 ++++++---
 2 files changed, 51 insertions(+), 22 deletions(-)

diff --git a/src/views/modules/function.vue b/src/views/modules/function.vue
index 4ebc722..125ffe7 100644
--- a/src/views/modules/function.vue
+++ b/src/views/modules/function.vue
@@ -24,7 +24,8 @@
         <div class="func">
           <!--列表展示-->
           <div class="list">
-            <el-tree v-if="funList.length >0" :data="funList" :props="defaultProps" node-key="id" @node-click="handleNodeClick">
+            <el-tree v-if="funList.length >0" :data="funList" :props="defaultProps" node-key="id"
+                     @node-click="handleNodeClick">
               <span class="custom-tree-node" slot-scope="{ node, data }">
                 <span>{{ data.name }}</span>
                 <span>
@@ -54,9 +55,9 @@
             </div>
           </div>
           <!--内容页-->
-          <div style="height: 100%;width: 100%"  v-if="content.property == 2">
+          <div style="height: 100%;width: 100%" v-if="content.property == 2">
 
-            <div style="height: 100%;width: 100%"  class="manage" v-if="modelType=='管理'">
+            <div style="height: 100%;width: 100%" class="manage" v-if="modelType=='管理'">
               <!--flash-->
               <div v-if="content.type == 1">
                 <avue-form :option="flashOption" v-model="flashForm" @submit="handleSubmitFile"></avue-form>
@@ -73,23 +74,27 @@
               </div>
             </div>
 
-            <div style="height: 100%;width: 100%"  class="view" v-else>
+            <div style="height: 100%;width: 100%" class="view" v-if="modelType == '预览'">
               <!--flash-->
-              <div  v-if="content.type == 1">
+              <div v-if="content.type == 1">
 
               </div>
 
               <!--图册-->
-              <div style="height: 100%;width: 100%"  v-if="content.type == 2">
-                <Flipbook class="flipbook" :pages="flipConfig.pages" :startPage="flipConfig.pageNum" v-slot="flipbook" ref="flipbook">
+              <div style="height: 100%;width: 100%" v-if="content.type == 2">
+                <flipbook class="flipbook" :pages="flipConfig.pages" :startPage="flipConfig.pageNum" v-slot="flipbook"
+                          ref="flipbook">
                   <div class="action-bar">
-                    <left-icon class="btn left" :class="{ disabled: !flipbook.canFlipLeft }" @click="flipbook.flipLeft"/>
+                    <left-icon class="btn left" :class="{ disabled: !flipbook.canFlipLeft }"
+                               @click="flipbook.flipLeft"/>
                     <plus-icon class="btn plus" :class="{ disabled: !flipbook.canZoomIn }" @click="flipbook.zoomIn"/>
                     <span class="page-num">Page {{ flipbook.page }} of {{ flipbook.numPages }}</span>
-                    <minus-icon class="btn minus" :class="{ disabled: !flipbook.canZoomOut }" @click="flipbook.zoomOut"/>
-                    <right-icon class="btn right" :class="{ disabled: !flipbook.canFlipRight }" @click="flipbook.flipRight"/>
+                    <minus-icon class="btn minus" :class="{ disabled: !flipbook.canZoomOut }"
+                                @click="flipbook.zoomOut"/>
+                    <right-icon class="btn right" :class="{ disabled: !flipbook.canFlipRight }"
+                                @click="flipbook.flipRight"/>
                   </div>
-                </Flipbook>
+                </flipbook>
               </div>
 
               <!--视频-->
@@ -228,7 +233,7 @@
             type: 'upload',
             limit: 1,
             drag: true,
-            loadText: '模板上传中,请稍等',
+            loadText: '文件上传中,请稍等',
             accept: 'image/png, image/jpeg',
             propsHttp: {
               res: 'data',
@@ -355,7 +360,7 @@
         label: 'name'
       },
       content: {},
-      modelType:'管理',
+      modelType: '管理',
 
       flipConfig: {
         pages: [],
@@ -363,7 +368,7 @@
         hasMouse: true,
         pageNum: null,
       },
-      iframePath:"",
+      iframePath: "",
     }
   },
   watch: {
@@ -410,6 +415,24 @@
     },
     handleSubmit(form, done) {
       form.modulesId = this.modules.id
+      //限制只能有一个开始页和结束页
+      if (form.property == 1 || form.property == 3) {
+        let data = this.funList
+        let filterArray = data.filter(e => {
+          return e.property == form.property
+        })
+        if (filterArray.length > 0) {
+          if (form.property == 1) {
+            this.$message.warning("开始页已存在")
+            done()
+            return
+          } else if (form.property == 3) {
+            this.$message.warning("结束页已存在")
+            done()
+            return
+          }
+        }
+      }
       if (!form.id) {
         add(form).then(() => {
           this.getAllFunc()
@@ -542,7 +565,7 @@
   left: 42%;
 }
 
-.model-type{
+.model-type {
   display: flex;
   justify-content: flex-end;
 }
@@ -558,7 +581,7 @@
   height: 100vh;
 }
 
-.page-num{
+.page-num {
   color: white;
 }
 
diff --git a/src/views/modules/modulesView.vue b/src/views/modules/modulesView.vue
index 981c688..cd03345 100644
--- a/src/views/modules/modulesView.vue
+++ b/src/views/modules/modulesView.vue
@@ -5,9 +5,11 @@
       <!-- 头部左侧按钮模块 -->
       <div class="avue-crud__left">
         <el-button size="small" class="button" icon="el-icon-back" @click="backModules">返回模块列表</el-button>
+        <el-button size="small" class="button" icon="el-icon-back" @click="backStartPage">回到开始页</el-button>
       </div>
     </div>
     <div class="content-view">
+      <!--开始页-->
       <div v-if="currentIndex==1" class="start">
         <img class="start-img" :src="startPage.fileUrl[0].value">
         <div class="start-button-group">
@@ -17,6 +19,7 @@
         </div>
       </div>
 
+      <!--内容页-->
       <div style="height: 100%;width: 100%"  v-if="currentIndex==2" class="content">
 
         <!--flash-->
@@ -69,7 +72,6 @@
 
 <script>
 import {getAll} from "@/api/modules/function";
-// import Flipbook from 'flipbook-vue/vue2'
 import LeftIcon from 'vue-material-design-icons/ChevronLeftCircle'
 import RightIcon from 'vue-material-design-icons/ChevronRightCircle'
 import PlusIcon from 'vue-material-design-icons/PlusCircle'
@@ -98,7 +100,7 @@
       },
     }
   },
-  mounted() {
+  created() {
     this.getAllFunc()
   },
   methods: {
@@ -133,14 +135,18 @@
       if (data.type == 1) {
 
       } else if (data.type == 2) {
-        let fileArray = data.fileUrl
-        fileArray.forEach(e => {
-          this.flipConfig.pages.push(e.value)
-        })
+        // let fileArray = data.fileUrl
+        // fileArray.forEach(e => {
+        //   this.flipConfig.pages.push(e.value)
+        // })
       } else if (data.type == 3) {
         let url = data.fileUrl[0].value
         this.iframePath = 'http://192.168.0.200:8012/onlinePreview?url=' + encodeURIComponent(Base64.encode(url))
       }
+    },
+    backStartPage(){
+      this.currentIndex = 1
+      this.content = this.startPage
     }
   }
 }

--
Gitblit v1.9.3