李志伟 3 년 전
부모
커밋
777ce62de8
3개의 변경된 파일85개의 추가작업 그리고 14개의 파일을 삭제
  1. 42
    1
      src/components/GameCharacter/index.vue
  2. 34
    2
      src/components/Question/index.vue
  3. 9
    11
      src/views/gameManage/index.vue

+ 42
- 1
src/components/GameCharacter/index.vue 파일 보기

@@ -27,6 +27,16 @@
27 27
         </template>
28 28
       </el-table-column>
29 29
     </el-table>
30
+    <el-pagination
31
+      v-show="characterTotal!==0"
32
+      style="float:right; margin:20px 0"
33
+      :total="characterTotal"
34
+      :current-page="currentPage"
35
+      :page-size="pageSize"
36
+      layout="total, prev, pager, next, sizes"
37
+      @size-change="handleSizeChange"
38
+      @current-change="handleCurrentChange"
39
+    />
30 40
   </div>
31 41
 </template>
32 42
 <script>
@@ -42,7 +52,10 @@ export default {
42 52
       daterange: '',
43 53
       tableData: [],
44 54
       endDate: undefined,
45
-      startDate: undefined
55
+      startDate: undefined,
56
+      pageSize: 10,
57
+      currentPage: 1,
58
+      characterTotal: 0
46 59
     }
47 60
   },
48 61
   watch: {
@@ -53,6 +66,32 @@ export default {
53 66
     }
54 67
   },
55 68
   methods: {
69
+    // 改变每页显示条数
70
+    handleSizeChange(val) {
71
+      this.pageSize = val
72
+      this.changePagination()
73
+    },
74
+    // 改变页码
75
+    handleCurrentChange(val) {
76
+      this.currentPage = val
77
+      this.changePagination()
78
+    },
79
+    // 改变分页组件重新查询数据
80
+    changePagination() {
81
+      getGameCharacterList({
82
+        gameId: this.gameId,
83
+        pageNum: this.currentPage,
84
+        pageSize: this.pageSize
85
+      }).then((res) => {
86
+        this.tableData = res.data.records
87
+        // 讲特征列表写入store 供问题答案特征下拉使用
88
+        const list = []
89
+        this.tableData.map(item => {
90
+          list.push({ characterId: item.characterId, name: item.name })
91
+        })
92
+        this.$store.dispatch('game/setWordListValue', list).then(() => {})
93
+      })
94
+    },
56 95
     handleAdd() {
57 96
       this.$emit('handleAddGameCharacter', true)
58 97
     },
@@ -73,6 +112,8 @@ export default {
73 112
         gameId: this.gameId
74 113
       }).then((res) => {
75 114
         this.tableData = res.data.records
115
+        this.characterTotal = res.data.total
116
+        this.pageSize = res.data.size
76 117
         // 讲特征列表写入store 供问题答案特征下拉使用
77 118
         const list = []
78 119
         this.tableData.map(item => {

+ 34
- 2
src/components/Question/index.vue 파일 보기

@@ -47,6 +47,16 @@
47 47
         </template>
48 48
       </el-table-column>
49 49
     </el-table>
50
+    <el-pagination
51
+      v-if="questionTotal!==0"
52
+      style="float:right; margin:20px 0"
53
+      :total="questionTotal"
54
+      :current-page="currentPage"
55
+      :page-size="pageSize"
56
+      layout="total, prev, pager, next, sizes"
57
+      @size-change="handleSizeChange"
58
+      @current-change="handleCurrentChange"
59
+    />
50 60
   </div>
51 61
 </template>
52 62
 <script>
@@ -63,7 +73,10 @@ export default {
63 73
       daterange: '',
64 74
       tableData: [],
65 75
       endDate: undefined,
66
-      startDate: undefined
76
+      startDate: undefined,
77
+      pageSize: 10,
78
+      currentPage: 1,
79
+      questionTotal: 0// 条目总数
67 80
     }
68 81
   },
69 82
   watch: {
@@ -74,6 +87,21 @@ export default {
74 87
     }
75 88
   },
76 89
   methods: {
90
+    handleSizeChange(val) {
91
+      this.pageSize = val
92
+      this.changePagination()
93
+    },
94
+    handleCurrentChange(val) {
95
+      this.currentPage = val
96
+      this.changePagination()
97
+    },
98
+    changePagination() {
99
+      getQuestionList({ gameId: this.gameId, title: this.title, startDate: this.startDate, endDate: this.endDate, pageSize: this.pageSize, pageNum: this.currentPage }).then(
100
+        (res) => {
101
+          this.tableData = res.data.records
102
+        }
103
+      )
104
+    },
77 105
     // 添加问题
78 106
     handleAdd() {
79 107
       this.$emit('handleAddQuestion', true)
@@ -91,9 +119,11 @@ export default {
91 119
       })
92 120
     },
93 121
     onSearch() {
94
-      getQuestionList({ gameId: this.gameId, title: this.title, startDate: this.startDate, endDate: this.endDate }).then(
122
+      getQuestionList({ gameId: this.gameId, title: this.title, startDate: this.startDate, endDate: this.endDate, pageSize: this.pageSize }).then(
95 123
         (res) => {
96 124
           this.tableData = res.data.records
125
+          this.questionTotal = res.data.total
126
+          this.pageSize = res.data.size
97 127
         }
98 128
       )
99 129
     },
@@ -102,6 +132,8 @@ export default {
102 132
       this.daterange = ''
103 133
       this.startDate = ''
104 134
       this.endDate = ''
135
+      this.pageSize = 10
136
+      this.pageNum = 1
105 137
       this.onSearch()
106 138
     },
107 139
     dateChange(val) {

+ 9
- 11
src/views/gameManage/index.vue 파일 보기

@@ -49,6 +49,7 @@
49 49
       </el-table-column>
50 50
     </el-table>
51 51
     <el-pagination
52
+      v-if="gameTotal!==0"
52 53
       style="float:right; margin:20px 0"
53 54
       :total="gameTotal"
54 55
       :current-page="currentPage"
@@ -81,21 +82,18 @@ export default {
81 82
     this.onSearch()
82 83
   },
83 84
   methods: {
85
+    // 改变每页显示条数
84 86
     handleSizeChange(val) {
85 87
       this.pageSize = val
86
-      getGameList({
87
-        title: this.title,
88
-        startDate: this.startDate,
89
-        endDate: this.endDate,
90
-        pageNum: this.currentPage,
91
-        pageSize: this.pageSize
92
-      }).then((res) => {
93
-        this.tableData = res.data.records
94
-        this.pageSize = res.data.size
95
-      })
88
+      this.changePagination()
96 89
     },
90
+    // 改变页码
97 91
     handleCurrentChange(val) {
98 92
       this.currentPage = val
93
+      this.changePagination()
94
+    },
95
+    // 改变分页组件重新查询数据
96
+    changePagination() {
99 97
       getGameList({
100 98
         title: this.title,
101 99
         startDate: this.startDate,
@@ -106,7 +104,6 @@ export default {
106 104
         this.tableData = res.data.records
107 105
       })
108 106
     },
109
-    //
110 107
     handleAdd() {
111 108
       this.$router.push({ name: 'gameEdit' })
112 109
     },
@@ -139,6 +136,7 @@ export default {
139 136
       this.startDate = undefined
140 137
       this.endDate = undefined
141 138
       this.currentPage = 1
139
+      this.pageSize = 10
142 140
       this.onSearch()
143 141
     },
144 142
     dateChange(val) {