瀏覽代碼

update 页面修正

15724580513 5 年之前
父節點
當前提交
355ac5d181

+ 3 - 0
src/views/management/HangYeZiXun/HangYeZiXunConfig/index.vue

@@ -269,6 +269,9 @@
                 this.initPage();
             }
         },
+        beforeDestroy() {
+            Object.assign(selectServiceData, selectData);
+        },
     };
 </script>
 

+ 18 - 6
src/views/management/HangYeZiXun/components/Pagination.vue

@@ -18,6 +18,18 @@
                 type:    Array,
                 default: () => [],
             },
+            codePage: {
+                type: String,
+                default: 'page'
+            },
+            codeSize: {
+                type: String,
+                default: 'size'
+            },
+            codeTotal: {
+                type: String,
+                default: 'total'
+            }
         },
         inject:   {
             paginationServiceData: {
@@ -34,26 +46,26 @@
         computed: {
             page:  {
                 get() {
-                    return this.paginationServiceData.page;
+                    return this.paginationServiceData[this.codePage];
                 },
                 set(val) {
-                    this.paginationServiceData.page = val;
+                    this.paginationServiceData[this.codePage] = val;
                 },
             },
             size:  {
                 get() {
-                    return this.paginationServiceData.size;
+                    return this.paginationServiceData[this.codeSize];
                 },
                 set(val) {
-                    this.paginationServiceData.size = val;
+                    this.paginationServiceData[this.codeSize] = val;
                 },
             },
             total: {
                 get() {
-                    return this.paginationServiceData.total;
+                    return this.paginationServiceData[this.codeTotal];
                 },
                 set(val) {
-                    this.this.paginationServiceData.total = val;
+                    this.this.paginationServiceData[this.codeTotal] = val;
                 },
             },
         },

+ 5 - 6
src/views/management/HangYeZiXun/components/Select.vue

@@ -25,6 +25,10 @@
             label: {
                 type: String,
                 default: 'name'
+            },
+            codeOptions: {
+                type: String,
+                default: 'options'
             }
         },
 
@@ -38,7 +42,7 @@
 
         computed: {
             options() {
-                return this.selectServiceData.options;
+                return this.selectServiceData[this.codeOptions];
             },
             value:   {
                 get() {
@@ -53,14 +57,9 @@
 
         methods: {
             selectChange(val) {
-                console.log(val)
                 this.$emit('select-change', val)
             }
         },
-
-        destroyed() {
-            this.selectServiceData[this.id] = null;
-        }
     };
 </script>
 

+ 13 - 9
src/views/management/HangYeZiXun/index.vue

@@ -32,12 +32,12 @@
 </template>
 
 <script>
-    import myPagination              from './components/Pagination';
-    import myTable                   from './components/Table';
-    import * as HYZXApi              from '@/api/hangyezixun';
-    import * as NewsClassifyApi      from '@/api/newsClassify';
-    import mySelect                  from './components/Select';
-    import Vue                       from 'vue';
+    import myPagination         from './components/Pagination';
+    import myTable              from './components/Table';
+    import * as HYZXApi         from '@/api/hangyezixun';
+    import * as NewsClassifyApi from '@/api/newsClassify';
+    import mySelect             from './components/Select';
+    import Vue                  from 'vue';
 
     const CHANGEPAGECODE = {
         add:    'add',
@@ -49,8 +49,8 @@
         placeholder:    '请选择新闻资讯分类',
     };
     const tableData = {
-        myData: []
-    }
+        myData: [],
+    };
 
     const pagination = {
         page:  1,
@@ -220,7 +220,6 @@
                     // 新闻资讯列表
                     const opt = this.getOption();
                     const { code, data } = await HYZXApi.getNewsList(opt);
-                    console.log(code, data);
                     if (code === 0) {
                         // 渲染页面
                         this.initPageData(data);
@@ -235,6 +234,11 @@
         created() {
             this.initPageService();
         },
+        beforeDestroy() {
+            Object.assign(tableServiceData, tableData);
+            Object.assign(paginationServiceData, pagination);
+            Object.assign(selectServiceData, selectData);
+        },
     };
 </script>
 

+ 24 - 9
src/views/management/XinWenFenLei/components/Pagination.vue

@@ -11,15 +11,25 @@
 </template>
 
 <script>
-    import { paginationServiceData, defaultPageSizes } from './paginationData';
-
     export default {
         name:     'Pagination',
         props:    {
             pageSizes: {
                 type:    Array,
-                default: () => defaultPageSizes,
+                default: () => [],
+            },
+            codePage: {
+                type: String,
+                default: 'page'
             },
+            codeSize: {
+                type: String,
+                default: 'size'
+            },
+            codeTotal: {
+                type: String,
+                default: 'total'
+            }
         },
         inject:   {
             tableServiceData: {
@@ -27,30 +37,35 @@
                 default: () => {
                 },
             },
+            paginationServiceData: {
+                type:    Object,
+                default: () => {
+                },
+            },
         },
         computed: {
             page:  {
                 get() {
-                    return paginationServiceData.page;
+                    return this.paginationServiceData[this.codePage];
                 },
                 set(val) {
-                    paginationServiceData.page = val;
+                    this.paginationServiceData[this.codePage] = val;
                 },
             },
             size:  {
                 get() {
-                    return paginationServiceData.size;
+                    return this.paginationServiceData[this.codeSize];
                 },
                 set(val) {
-                    paginationServiceData.size = val;
+                    this.paginationServiceData[this.codeSize] = val;
                 },
             },
             total: {
                 get() {
-                    return paginationServiceData.total;
+                    return this.paginationServiceData[this.codeTotal];
                 },
                 set(val) {
-                    this.paginationServiceData.total = val;
+                    this.this.paginationServiceData[this.codeTotal] = val;
                 },
             },
         },

+ 0 - 14
src/views/management/XinWenFenLei/components/paginationData.js

@@ -1,14 +0,0 @@
-import Vue from 'vue';
-
-const pagination = {
-    page: 1,
-    size: 10,
-    total: 0
-}
-const defaultPageSizes = [10, 20, 30, 40];
-const paginationServiceData = Vue.observable(pagination);
-
-export {
-    paginationServiceData,
-    defaultPageSizes
-}

+ 0 - 11
src/views/management/XinWenFenLei/components/tableData.js

@@ -1,11 +0,0 @@
-import Vue from 'vue';
-
-const tableData = {
-    myData: []
-}
-
-const tableServiceData = Vue.observable(tableData);
-
-export {
-    tableServiceData
-}

+ 43 - 23
src/views/management/XinWenFenLei/index.vue

@@ -26,6 +26,7 @@
         <!--    分页    -->
         <myPagination
                 class="yqlj-pagination"
+                :pageSizes="defaultPageSizes"
                 @size-change="handleSizeChange"
                 @current-page="handleCurrentPage" />
 
@@ -79,13 +80,24 @@
 </template>
 
 <script>
-    import { tableServiceData }      from './components/tableData';
-    import { paginationServiceData } from './components/paginationData';
-    import myPagination              from './components/Pagination';
-    import myTable                   from './components/Table';
-    import * as NewsClassifyService  from '@/api/newsClassify';
-    import * as comminUtil           from '@/utils/admin/tools';
+    import myPagination             from './components/Pagination';
+    import myTable                  from './components/Table';
+    import * as NewsClassifyService from '@/api/newsClassify';
+    import * as comminUtil          from '@/utils/admin/tools';
+    import Vue                      from 'vue';
 
+    const tableData = {
+        myData: [],
+    };
+    const pagination = {
+        page:  1,
+        size:  10,
+        total: 0,
+    };
+    const defaultPageSizes = [10, 20, 30, 40];
+
+    const paginationServiceData = Vue.observable(pagination);
+    const tableServiceData = Vue.observable(tableData);
     export default {
         name:       'YouQingLianJie',
         provide:    {
@@ -98,6 +110,7 @@
         },
         data() {
             return {
+                defaultPageSizes:  defaultPageSizes,
                 addDialogVisit:    false,
                 editorDialogVisit: false,
                 searchData:        '',
@@ -176,15 +189,15 @@
                 const opt = { newsClassifyId: this.selectRow.newsClassifyId };
                 const loading = this.$loading({ background: 'rgba(0, 0, 0, 0.7)' });
                 NewsClassifyService.getNewsClassifyInfo(opt)
-                           .then(res => {
-                               const { name, number } = res.data;
-                               this.editorForm.name = name;
-                               this.editorForm.number = number;
-                               loading.close();
-                           })
-                           .catch(err => {
-                               loading.close();
-                           });
+                                   .then(res => {
+                                       const { name, number } = res.data;
+                                       this.editorForm.name = name;
+                                       this.editorForm.number = number;
+                                       loading.close();
+                                   })
+                                   .catch(err => {
+                                       loading.close();
+                                   });
             },
             handleEditorReset(formName) {
                 this.$refs[formName].resetFields();
@@ -202,7 +215,10 @@
             async editorLinksFun() {
                 const loading = this.$loading({ background: 'rgba(0, 0, 0, 0.7)' });
                 try {
-                    const opt = Object.assign({}, this.editorForm, { userId: this.userId, newsClassifyId: this.selectRow.newsClassifyId });
+                    const opt = Object.assign({}, this.editorForm, {
+                        userId:         this.userId,
+                        newsClassifyId: this.selectRow.newsClassifyId,
+                    });
                     const res = await NewsClassifyService.getNewsClassifyUpdate(opt);
                     if (res.code === 0) {
                         this.editorDialogVisit = false;
@@ -268,13 +284,13 @@
                 const opt = this.getOption();
                 const loading = this.$loading({ background: 'rgba(0, 0, 0, 0.7)' });
                 NewsClassifyService.getNewsClassifyList(opt)
-                           .then(res => {
-                               this.initPageData(res.data);
-                               loading.close();
-                           })
-                           .catch(err => {
-                               loading.close();
-                           });
+                                   .then(res => {
+                                       this.initPageData(res.data);
+                                       loading.close();
+                                   })
+                                   .catch(err => {
+                                       loading.close();
+                                   });
             },
             handleSizeChange(size) {
                 paginationServiceData.size = size;
@@ -299,6 +315,10 @@
         mounted() {
             this.searchYouQingData();
         },
+        beforeDestroy() {
+            Object.assign(tableServiceData, tableData);
+            Object.assign(paginationServiceData, pagination);
+        },
     };
 </script>
 

+ 19 - 10
src/views/management/YouQingLianJie/components/Pagination.vue

@@ -18,6 +18,18 @@
                 type:    Array,
                 default: () => [],
             },
+            codePage:  {
+                type:    String,
+                default: 'page',
+            },
+            codeSize:  {
+                type:    String,
+                default: 'size',
+            },
+            codeTotal: {
+                type:    String,
+                default: 'total',
+            },
         },
         inject:   {
             paginationServiceData: {
@@ -25,7 +37,7 @@
                 default: () => {
                 },
             },
-            tableServiceData: {
+            tableServiceData:      {
                 type:    Object,
                 default: () => {
                 },
@@ -34,26 +46,26 @@
         computed: {
             page:  {
                 get() {
-                    return this.paginationServiceData.page;
+                    return this.paginationServiceData[this.codePage];
                 },
                 set(val) {
-                    this.paginationServiceData.page = val;
+                    this.paginationServiceData[this.codePage] = val;
                 },
             },
             size:  {
                 get() {
-                    return this.paginationServiceData.size;
+                    return this.paginationServiceData[this.codeSize];
                 },
                 set(val) {
-                    this.paginationServiceData.size = val;
+                    this.paginationServiceData[this.codeSize] = val;
                 },
             },
             total: {
                 get() {
-                    return this.paginationServiceData.total;
+                    return this.paginationServiceData[this.codeTotal];
                 },
                 set(val) {
-                    this.paginationServiceData.total = val;
+                    this.paginationServiceData[this.codeTotal] = val;
                 },
             },
         },
@@ -73,9 +85,6 @@
                 this.$emit('current-page', val);
             },
         },
-        beforeDestroy() {
-            // this.paginationServiceData.clearData();
-        }
     };
 </script>
 

+ 5 - 2
src/views/management/YouQingLianJie/index.vue

@@ -89,17 +89,16 @@
     const tableData = {
         myData: [],
     };
-
     const pagination = {
         page:  1,
         size:  10,
         total: 0,
     };
-
     const defaultPageSizes = [10, 20, 30, 40];
 
     const paginationServiceData = Vue.observable(pagination);
     const tableServiceData = Vue.observable(tableData);
+
     export default {
         name:       'YouQingLianJie',
         provide:    {
@@ -315,6 +314,10 @@
         mounted() {
             this.searchYouQingData();
         },
+        beforeDestroy() {
+            Object.assign(tableServiceData, tableData);
+            Object.assign(paginationServiceData, pagination);
+        },
     };
 </script>