star7th 6 سال پیش
والد
کامیت
04b3a85da4

+ 14 - 0
server/Application/Api/Controller/CatalogController.class.php

@@ -213,4 +213,18 @@ class CatalogController extends BaseController {
     }
 
 
+    //获取某个目录下所有页面的标题
+    public function getPagesBycat(){
+        $cat_id = I("cat_id/d")? I("cat_id/d") : 0;
+        $item_id =  I("item_id/d");
+        $login_user = $this->checkLogin();
+        if (!$this->checkItemPermn($login_user['uid'] , $item_id)) {
+            $this->sendError(10103);
+            return ;
+        }
+        $return = D("Page")->where("cat_id = '$cat_id' and  item_id = '$item_id' and is_del = 0  ")->field("page_id , page_title,s_number")->order("`s_number` asc , `page_id` asc")->select();
+        $this->sendResult($return);
+
+    }
+
 }

+ 22 - 0
server/Application/Api/Controller/PageController.class.php

@@ -413,5 +413,27 @@ class PageController extends BaseController {
         $this->sendResult($page);
     }
 
+    //同一个目录下的页面排序
+    public function sort(){
+        $pages = I("pages");
+        $item_id = I("item_id/d");
+        $login_user = $this->checkLogin();
+        if (!$this->checkItemPermn($login_user['uid'] , $item_id)) {
+            $this->sendError(10103);
+            return ;
+        }
+        $ret = '';
+        $data_array = json_decode(htmlspecialchars_decode($pages) , true) ;
+        if ($data_array) {
+            foreach ($data_array as $key => $value) {
+                $ret = D("Page")->where(" page_id = '$key' and item_id = '$item_id' ")->save(array(
+                    "s_number" => $value ,
+                    ));
+            }
+        }
+
+        $this->sendResult(array());
+    }
+
 
 }

+ 13 - 7
web_src/src/components/page/edit/Index.vue

@@ -16,8 +16,8 @@
             </el-select>
           </el-form-item>
 
-          <el-form-item :label="$t('s_number')+' : '">
-            <el-input  :placeholder="$t('optional')" class="num" v-model="s_number"></el-input>
+          <el-form-item label="" >
+            <el-button type="text" @click="ShowSortPage">{{$t('sort_pages')}}</el-button>
           </el-form-item>
           <el-form-item label="" >
             <el-button type="text" @click="ShowHistoryVersion">{{$t('history_version')}}</el-button>
@@ -80,8 +80,9 @@
         <!-- 粘贴插入表格 -->
         <PasteTable :callback="insertValue" :item_id="item_id" :manage="true" :page_id="page_id" ref="PasteTable"></PasteTable>
         
-
-
+        <!-- 页面排序 -->
+        <SortPage :callback="insertValue" :belong_to_catalogs="belong_to_catalogs" :item_id="item_id" :page_id="page_id" :cat_id="cat_id" ref="SortPage"></SortPage>
+        
       </el-container>
     <Footer> </Footer>
     <div class=""></div>
@@ -259,7 +260,7 @@ import TemplateList from '@/components/page/edit/TemplateList'
 import HistoryVersion from '@/components/page/edit/HistoryVersion'
 import AttachmentList from '@/components/page/edit/AttachmentList'
 import PasteTable from '@/components/page/edit/PasteTable'
-
+import SortPage from '@/components/page/edit/SortPage'
 
 export default {
   data () {
@@ -322,7 +323,8 @@ export default {
     TemplateList,
     HistoryVersion,
     AttachmentList,
-    PasteTable
+    PasteTable,
+    SortPage
   },
   methods:{
     //获取页面内容
@@ -487,7 +489,11 @@ export default {
         let childRef = this.$refs.HistoryVersion ;//获取子组件
         childRef.show() ; 
     },
-
+    //展示页面排序
+    ShowSortPage(){
+        let childRef = this.$refs.SortPage ;//获取子组件
+        childRef.show() ; 
+    },
     save(){
       var that = this ;
       var loading = that.$loading();

+ 148 - 0
web_src/src/components/page/edit/SortPage.vue

@@ -0,0 +1,148 @@
+<!-- 页面排序 -->
+<template>
+  <div class="hello">
+    <Header> </Header>
+
+    <el-container class="container-narrow">
+
+      <el-dialog :title="$t('sort_pages')" :modal="is_modal" :visible.sync="dialogTableVisible" >
+        <div class="dialog-body">
+          <p class="tips" >{{$t('sort_pages_tips')}}</p>
+          <el-select  :placeholder="$t('optional')" class="select-cat" v-model="cat_id">
+            <el-option v-if="belong_to_catalogs" v-for="cat in belong_to_catalogs " :key="cat.cat_name" :label="cat.cat_name" :value="cat.cat_id"></el-option>
+          </el-select>
+          <draggable v-model="pages" tag="div" group="page"  @end="endMove">
+            <div class="page-box" v-for="page in pages">
+              <span class='page-name'>{{page.page_title}}</span>
+            </div>
+
+          </draggable>
+        </div>
+
+
+      </el-dialog>
+
+      </el-container>
+    <Footer> </Footer>
+    <div class=""></div>
+  </div>
+</template>
+
+<style scoped>
+.dialog-body{
+  min-height: 400px;
+  max-height: 90%;
+  overflow-x:hidden;
+  overflow-y:auto;
+}
+.page-box{
+  background-color:rgb(250, 250, 250);
+  width: 98%;
+  height: 40px;
+  margin-top: 10px;
+  border: 1px solid #d9d9d9;
+  border-radius: 2px;
+}
+.page-name{
+  line-height: 40px;
+  margin-left: 20px;
+  color: #262626;
+}
+.tips{
+  margin-left: 10px;
+  color: #9ea1a6;
+  font-size: 11px;
+
+}
+
+</style>
+
+<script>
+import draggable from 'vuedraggable'
+export default {
+  props:{
+    callback:'',
+    page_id:'',
+    item_id:'',
+    is_modal:true,
+    belong_to_catalogs:[],
+    cat_id:''
+  },
+  data () {
+    return {
+      currentDate: new Date(),
+      dialogTableVisible: false,
+      pages:[]
+    };
+  },
+  components:{
+    draggable
+  },
+  methods:{
+
+    show(){
+      this.dialogTableVisible = true ;
+    },
+    //获取某目录下的所有页面
+    get_pages(){
+      var that = this ;
+      var url = DocConfig.server+'/api/catalog/getPagesBycat';
+      var params = new URLSearchParams();
+      params.append('item_id',  this.item_id);
+      params.append('cat_id',  this.cat_id);
+      that.axios.post(url, params)
+        .then(function (response) {
+          if (response.data.error_code === 0 ) {
+            that.pages = response.data.data ;
+          }else{
+            that.$alert(response.data.error_message);
+          }
+          
+        })
+        .catch(function (error) {
+          console.log(error);
+        });
+    },
+    endMove(evt){
+      let data = {} ;
+      for (var i = 0; i < this.pages.length; i++) {
+        let key = this.pages[i]['page_id'] ;
+        data[key] = i + 1  ;
+      };
+      this.sort_page(data);
+    },
+    sort_page(data){
+      var that = this ;
+      var url = DocConfig.server+'/api/page/sort';
+      var params = new URLSearchParams();
+      params.append('pages', JSON.stringify(data));
+      params.append('item_id', this.item_id);
+      that.axios.post(url, params)
+        .then(function (response) {
+          if (response.data.error_code === 0 ) {
+            that.get_pages();
+            //window.location.reload();
+
+          }else{
+            that.$alert(response.data.error_message,'',{
+              callback:function(){
+                window.location.reload();
+              }
+            });
+            
+          }
+          
+        });
+    },
+
+  },
+  watch:{
+    cat_id:function(){
+      this.get_pages();
+    }
+  },
+  mounted () {
+    
+  }
+}
+</script>

+ 2 - 0
web_src/static/lang/en.js

@@ -301,5 +301,7 @@ exports.default = {
     "recover":"recover",
     "recover_tips":"Are you sure to recover? The recovered page will appear in the item root",
 
+    "sort_pages":"Sort Pages",
+    "sort_pages_tips":"After selecting a specific catalog, you can drag and sort the pages in that catalog",
 
 };

+ 3 - 0
web_src/static/lang/zh-CN.js

@@ -308,4 +308,7 @@ exports.default = {
     "recover":"恢复",
     "recover_tips":"确认恢复吗?恢复的页面将出现在项目根目录",
 
+    "sort_pages":"页面排序",
+    "sort_pages_tips":"选择特定的目录后,你可以对该目录下的页面进行拖动排序",
+    
 };