Browse Source

drag and sort pages

star7th 6 years ago
parent
commit
bb370cfa83

+ 2 - 2
server/Application/Api/Controller/PageController.class.php

@@ -69,7 +69,7 @@ class PageController extends BaseController {
         $page_content = I("page_content");
         $cat_id = I("cat_id/d")? I("cat_id/d") : 0;
         $item_id = I("item_id/d")? I("item_id/d") : 0;
-        $s_number = I("s_number/d")? I("s_number/d") : 99;
+        $s_number = I("s_number/d")? I("s_number/d") : '';
 
         $login_user = $this->checkLogin();
         if (!$this->checkItemPermn($login_user['uid'] , $item_id)) {
@@ -86,7 +86,7 @@ class PageController extends BaseController {
         $data['page_title'] = $page_title ;
         $data['page_content'] = $page_content ;
         $data['page_comments'] = $page_comments ;
-        $data['s_number'] = $s_number ;
+        if($s_number)$data['s_number'] = $s_number ;
         $data['item_id'] = $item_id ;
         $data['cat_id'] = $cat_id ;
         $data['addtime'] = time();

+ 61 - 8
web_src/src/components/catalog/Index.vue

@@ -22,12 +22,18 @@
           <span class="custom-tree-node" slot-scope="{ node, data }">
             <span>{{ node.label }}</span>
             <span class="right-bar">
+
               <el-button
                 type="text"
                 size="mini"
                  class="el-icon-edit"
                 @click.stop="edit(node, data)">
-                
+              </el-button>
+              <el-button
+                type="text"
+                size="mini"
+                 class="el-icon-document"
+                @click.stop="showSortPage(node, data)">
               </el-button>
               <el-button
                 type="text"
@@ -66,17 +72,19 @@
       </el-dialog>
     </el-container>
 
+    <SortPage :callback="insertValue" :belong_to_catalogs="belong_to_catalogs" :item_id="item_id"  :cat_id="curl_cat_id" ref="SortPage"></SortPage>
+
     <Footer> </Footer>
   </div>
 </template>
 
 <script>
 
-
+import SortPage from '@/components/page/edit/SortPage'
 export default {
   name: 'Login',
   components : {
-    
+    SortPage
   },
   data () {
     return {
@@ -89,10 +97,12 @@ export default {
       catalogs:[],
       dialogFormVisible:false,
       treeData: [],
-        defaultProps: {
-          children: 'children',
-          label: 'label'
-        }
+      defaultProps: {
+        children: 'children',
+        label: 'label'
+      },
+      item_id:'',
+      curl_cat_id:''
     }
 
   },
@@ -117,7 +127,43 @@ export default {
         cat_array.push(no_cat);
         return cat_array;
 
+    },
+    //新建/编辑页面时供用户选择的归属目录列表
+    belong_to_catalogs:function(){
+        if (!this.catalogs || this.catalogs.length <=0 ) {
+          return [];
+        };
+        var Info = this.catalogs.slice(0);
+        var cat_array = [] ;
+        for (var i = 0; i < Info.length; i++) {
+          cat_array.push(Info[i]);
+          var sub = Info[i]['sub'] ;
+          if (sub.length > 0 ) {
+            for (var j = 0; j < sub.length; j++) {
+              cat_array.push( {
+                "cat_id":sub[j]['cat_id'] ,
+                "cat_name":Info[i]['cat_name']+' / ' + sub[j]['cat_name']
+              });
+
+              var sub_sub = sub[j]['sub'] ;
+              if (sub_sub.length > 0 ) {
+                for (var k = 0; k < sub_sub.length; k++) {
+                  cat_array.push( {
+                    "cat_id":sub_sub[k]['cat_id'] ,
+                    "cat_name":Info[i]['cat_name']+' / ' + sub[j]['cat_name']+' / ' + sub_sub[k]['cat_name']
+                  });
+                };
+              };
+
+            };
+          };
+        };
+        var no_cat = {"cat_id":'' ,"cat_name":this.$t("none")} ;
+        cat_array.unshift(no_cat);
+        return cat_array;
+
     }
+
   }, 
   methods: {
       get_catalog(){
@@ -324,12 +370,19 @@ export default {
           
         };
         return treeData2 ;
-      }
+      },
+      //展示页面排序
+      showSortPage(node, data){
+          this.curl_cat_id = data.id;
+          let childRef = this.$refs.SortPage ;//获取子组件
+          childRef.show() ; 
+      },
 
   },
 
   mounted(){
     this.get_catalog();
+    this.item_id = this.$route.params.item_id ;
   },
   
   beforeDestroy(){

+ 17 - 9
web_src/src/components/page/edit/Index.vue

@@ -491,10 +491,12 @@ export default {
     },
     //展示页面排序
     ShowSortPage(){
-        let childRef = this.$refs.SortPage ;//获取子组件
-        childRef.show() ; 
+        this.save(()=>{
+          let childRef = this.$refs.SortPage ;//获取子组件
+          childRef.show() ; 
+        });
     },
-    save(){
+    save(callback){
       var that = this ;
       var loading = that.$loading();
       let childRef = this.$refs.Editormd ;
@@ -506,7 +508,6 @@ export default {
       var params = new URLSearchParams();
       params.append('page_id',  page_id);
       params.append('item_id',  item_id);
-      params.append('s_number',  that.s_number);
       params.append('page_title',  that.title);
       params.append('page_content',  encodeURIComponent(content));
       params.append('is_urlencode',  1);
@@ -515,11 +516,18 @@ export default {
         .then(function (response) {
           loading.close();
           if (response.data.error_code === 0 ) {
-            that.$message({
-              showClose: true,
-              message: that.$t("save_success"),
-              type: 'success'
-            });
+
+              if (typeof callback == 'function') {
+                callback();
+              }else{
+                that.$message({
+                  showClose: true,
+                  message: that.$t("save_success"),
+                  type: 'success'
+                });
+              }
+
+
 
             //删除草稿
             that.deleteDraft();

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

@@ -139,6 +139,9 @@ export default {
   watch:{
     cat_id:function(){
       this.get_pages();
+    },
+    dialogTableVisible:function(){
+      this.get_pages();
     }
   },
   mounted () {