Browse Source

栏目拖拽

natasha 1 year ago
parent
commit
494c9cbf46

+ 1 - 0
package.json

@@ -36,6 +36,7 @@
         "vue-image-crop-upload": "^3.0.3",
         "vue-router": "3.0.6",
         "vue-slider-component": "^3.2.14",
+        "vuedraggable": "^2.24.3",
         "vuex": "3.1.0",
         "xgplayer": "^3.0.0-next.56"
     },

+ 10 - 0
src/icons/svg/edit.svg

@@ -0,0 +1,10 @@
+<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
+<g clip-path="url(#clip0_1_71759)">
+<path fill-rule="evenodd" clip-rule="evenodd" d="M9.26625 1.62883C9.65677 1.23831 10.2899 1.23831 10.6805 1.62883L12.5424 3.49073C12.9329 3.88125 12.9329 4.51442 12.5424 4.90494L5.72573 11.7216C5.5666 11.8807 5.35844 11.9815 5.13491 12.0077L3.11926 12.2437C2.49464 12.3168 1.95836 11.8021 2.00583 11.175L2.16504 9.07163C2.18309 8.83318 2.28599 8.60909 2.45508 8.44L9.26625 1.62883ZM8.76919 4.01151L10.1597 5.402L11.3638 4.19783L9.97336 2.80734L8.76919 4.01151ZM9.21688 6.34481L7.82638 4.95432L3.48524 9.29545L3.36588 10.8723L4.86483 10.6969L9.21688 6.34481ZM14 14.6654L2 14.6654V13.3321L14 13.3321V14.6654Z" fill="currentColor"/>
+</g>
+<defs>
+<clipPath id="clip0_1_71759">
+<rect width="16" height="16" fill="white"/>
+</clipPath>
+</defs>
+</svg>

+ 10 - 0
src/icons/svg/sort.svg

@@ -0,0 +1,10 @@
+<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
+<g clip-path="url(#clip0_1_71749)">
+<path fill-rule="evenodd" clip-rule="evenodd" d="M5 2H7V4H5V2ZM9 2H11V4H9V2ZM5 7H7V9H5V7ZM9 7H11V9H9V7ZM5 12H7V14H5V12ZM9 12H11V14H9V12Z" fill="currentColor"/>
+</g>
+<defs>
+<clipPath id="clip0_1_71749">
+<rect width="16" height="16" fill="white"/>
+</clipPath>
+</defs>
+</svg>

+ 259 - 4
src/views/content_manage/newspaper_manage/CreateNewspaper.vue

@@ -187,7 +187,66 @@
                     </el-form>
                 </template>
                 <div v-if="stepIndex===1">
-                   
+                    <div class="issue-channel">
+                        <div class="issue-top">
+                            <h4 class="issue-top-left">
+                                栏目
+                                <span>共 {{issueChannel.channelNumber}} 个栏目 {{issueChannel.articleNumber}} 篇文章</span>
+                            </h4>
+                            <el-button type="primary" size="small">预览</el-button>
+                        </div>
+                        <div class="channel-item" v-for="(item,index) in issueChannel.channelList" :key="index">
+                            <div class="channel-top">
+                                <i class="el-icon-caret-bottom" v-if="item.show" @click="item.show=!item.show"></i>
+                                <i class="el-icon-caret-top" v-else @click="item.show=!item.show"></i>
+                                <span @click="item.show=!item.show">{{item.channelName}}</span>
+                                <el-button type="text" @click="handleArticle('','en')"><i class="el-icon-plus"></i>新增英文内容</el-button>
+                                <el-button type="text" @click="handleArticle('','cn')"><i class="el-icon-plus"></i>新增中文内容</el-button>
+                            </div>
+                            <el-collapse-transition>
+                                <template v-if="item.show">
+                                    <draggable
+                                        v-model="item.articleList"
+                                        chosenClass="chosen"
+                                        forceFallback="true"
+                                        group="people"
+                                        animation="1000"
+                                        @start="onStart"
+                                        @end="onEnd"
+                                        class="article-list"
+                                    >
+                                        <li v-for="(itema,indexa) in item.articleList" :key="indexa">
+                                            <svg-icon icon-class="sort" draggable="true"></svg-icon>
+                                            <div class="items">
+                                                <h6>{{itema.title}}</h6>
+                                                <span>BY {{itema.author}}</span>
+                                                <span>创建人:{{itema.creator}}</span>
+                                                <span>{{itema.time}}</span>
+                                            </div>
+                                            <svg-icon icon-class="edit" class="edit-article" @click="handleArticle(itema.id,itema.type)"></svg-icon>
+                                            <span class="border"></span>
+                                            <i class="el-icon-delete" @click="handleDeleteArticle(item.articleList,indexa)"></i>
+                                        </li>
+                                    </draggable>
+                                    <!-- <ul class="article-list">
+                                        <li v-for="(itema,indexa) in item.articleList" :key="indexa">
+                                            <svg-icon icon-class="sort" draggable="true"></svg-icon>
+                                            <div class="items">
+                                                <h6>{{itema.title}}</h6>
+                                                <span>BY {{itema.author}}</span>
+                                                <span>创建人:{{itema.creator}}</span>
+                                                <span>{{itema.time}}</span>
+                                            </div>
+                                            <svg-icon icon-class="edit" class="edit-article" @click="handleArticle(itema.id,itema.type)"></svg-icon>
+                                            <span class="border"></span>
+                                            <i class="el-icon-delete" @click="handleDeleteArticle(item.articleList,indexa)"></i>
+                                        </li>
+                                    </ul> -->
+                                </template>
+                            </el-collapse-transition>
+                        </div>
+                        
+                    </div>
                 </div>
                 <div v-if="stepIndex===2">
                     <el-result icon="success" :subTitle="id?'报纸编辑成功':'报纸创建成功'">
@@ -212,10 +271,11 @@ import Breadcrumb from '../../../components/Breadcrumb.vue';
 import Upload from "../../../components/Upload.vue"
 import { getLogin } from "@/api/ajax";
 import { mapState } from 'vuex';
+import draggable from "vuedraggable";
 
 export default {
   //import引入的组件需要注入到对象中才能使用
-  components: { Header, NavMenu, Breadcrumb, Upload },
+  components: { Header, NavMenu, Breadcrumb, Upload, draggable },
   props: {},
   data() {
     const validateIssNo = (rule, value, callback) => {
@@ -365,7 +425,74 @@ export default {
         vlList: [], // 课标词表
         tplList: [], // 栏目列表
         tabsList:['中英双语','少儿必读'],
-        issueId: ''
+        issueId: '',
+        issueChannel:{
+            channelNumber: '12',
+            articleNumber: '4',
+            channelList:[
+                {
+                    channelName: 'FRONT PAGE',
+                    articleList: [
+                        {
+                            title: 'Silly science',
+                            author: 'TEENS',
+                            creator: '张老师',
+                            time: '2012-12-12 12:23'
+                        },
+                        {
+                            title: 'Silly science1',
+                            author: 'TEENS',
+                            creator: '张老师',
+                            time: '2012-12-12 12:23'
+                        },
+                        {
+                            title: 'Silly science2',
+                            author: 'TEENS',
+                            creator: '张老师',
+                            time: '2012-12-12 12:23'
+                        },
+                        {
+                            title: 'Silly science3',
+                            author: 'TEENS',
+                            creator: '张老师',
+                            time: '2012-12-12 12:23'
+                        }
+                    ],
+                    show: true
+                },
+                {
+                    channelName: 'STORY LAND', 
+                    articleList: [],
+                    show: false
+                },
+                {
+                    channelName: 'STORY LAND', 
+                    articleList: [],
+                    show: false
+                },
+                {
+                    channelName: 'STORY LAND', 
+                    articleList: [],
+                    show: false
+                },
+                {
+                    channelName: 'STORY LAND', 
+                    articleList: [],
+                    show: false
+                },
+                {
+                    channelName: 'STORY LAND', 
+                    articleList: [],
+                    show: false
+                },
+                {
+                    channelName: 'STORY LAND', 
+                    articleList: [],
+                    show: false
+                },
+            ]
+        },
+        drag: false,
     }
   },
   //计算属性 类似于data概念
@@ -442,6 +569,15 @@ export default {
         }
       });
     },
+    handleDeleteArticle(item,i){
+        this.$confirm("确定删除吗?", "提示", {
+            confirmButtonText: "确定",
+            cancelButtonText: "取消",
+            type: "warning",
+        }).then(() => {
+            item.splice(i, 1);
+        });
+    },
     // 去掉前后空格
     handleTrim(form,fild){
         this[form][fild] = this[form][fild].trim()
@@ -573,7 +709,19 @@ export default {
         })
         .catch(() => {
         });
-    }
+    },
+    // 跳转文章
+    handleArticle(id,type){
+
+    },
+    //开始拖拽事件
+    onStart() {
+      this.drag = true;
+    },
+    //拖拽结束事件
+    onEnd() {
+      this.drag = false;
+    },
   },
   //生命周期 - 创建完成(可以访问当前this实例)
   async created() {
@@ -695,6 +843,113 @@ export default {
         margin: 0;
     }
 }
+.issue-channel{
+    .issue-top{
+        display: flex;
+        justify-content: space-between;
+        margin-bottom: 8px;
+        &-left{
+            margin: 0;
+            color: #1D2129;
+            font-size: 20px;
+            font-weight: 500;
+            line-height: 28px;
+            span{
+                margin-left: 4px;
+                color: #86909C;
+                font-size: 14px;
+                font-weight: 400;
+                line-height: 22px;
+            }
+        }
+    }
+    .channel-item{
+        border: 1px solid #E5E6EB;
+        margin: 12px 0;
+        .channel-top{
+            display: flex;
+            padding: 9px 12px;
+            align-items: center;
+            .el-icon-caret-bottom,.el-icon-caret-top{
+                color: #4E5969;
+                width: 14px;
+                height: 14px;
+                cursor: pointer;
+            }
+            span{
+                margin-left: 6px;
+                flex: 1;
+                cursor: pointer;
+                word-break: break-word;
+                color: #1D2129;
+                font-size: 14px;
+                font-weight: 400;
+                line-height: 22px;
+            }
+            .el-button--text{
+                padding: 2px 12px;
+                color: #165DFF;
+                .el-icon-plus{
+                    width: 12px;
+                    height: 12px;
+                    margin-right: 8px;
+                    font-weight: bold;
+                }
+            }
+        }
+        .article-list{
+            margin: 0;
+            padding: 8px;
+            list-style: none;
+            background: #F7F8FA;
+            min-height: 44px;
+            border-top: 1px solid #E5E6EB;
+            li{
+                padding: 13px 20px;
+                border-bottom: 1px solid #E5E6EB;
+                display: flex;
+                align-items: center;
+                .svg-icon{
+                    width: 16px;
+                    height: 16px;
+                    cursor: move;
+                }
+                .edit-article{
+                    cursor: pointer;
+                }
+                .items{
+                    flex: 1;
+                    margin: 0 16px;
+                    h6{
+                        font-size: 16px;
+                        font-weight: 500;
+                        line-height: 24px;
+                        margin-bottom: 2px;
+                        word-break: break-word;
+                    }
+                    span{
+                        color: #1D2129;
+                        font-size: 14px;
+                        font-weight: 400;
+                        line-height: 22px;
+                        margin-right: 8px;
+                    }
+                }
+                .border{
+                    height: 12px;
+                    width: 1px;
+                    display: block;
+                    background: #E5E6EB;
+                    margin: 0 8px;
+                }
+                .el-icon-delete{
+                    font-weight: bold;
+                    cursor: pointer;
+                }
+            }
+        }
+    }
+}
 </style>
 <style lang="scss">
 .newspaper-create{