李志伟 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
         </template>
27
         </template>
28
       </el-table-column>
28
       </el-table-column>
29
     </el-table>
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
   </div>
40
   </div>
31
 </template>
41
 </template>
32
 <script>
42
 <script>
42
       daterange: '',
52
       daterange: '',
43
       tableData: [],
53
       tableData: [],
44
       endDate: undefined,
54
       endDate: undefined,
45
-      startDate: undefined
55
+      startDate: undefined,
56
+      pageSize: 10,
57
+      currentPage: 1,
58
+      characterTotal: 0
46
     }
59
     }
47
   },
60
   },
48
   watch: {
61
   watch: {
53
     }
66
     }
54
   },
67
   },
55
   methods: {
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
     handleAdd() {
95
     handleAdd() {
57
       this.$emit('handleAddGameCharacter', true)
96
       this.$emit('handleAddGameCharacter', true)
58
     },
97
     },
73
         gameId: this.gameId
112
         gameId: this.gameId
74
       }).then((res) => {
113
       }).then((res) => {
75
         this.tableData = res.data.records
114
         this.tableData = res.data.records
115
+        this.characterTotal = res.data.total
116
+        this.pageSize = res.data.size
76
         // 讲特征列表写入store 供问题答案特征下拉使用
117
         // 讲特征列表写入store 供问题答案特征下拉使用
77
         const list = []
118
         const list = []
78
         this.tableData.map(item => {
119
         this.tableData.map(item => {

+ 34
- 2
src/components/Question/index.vue 查看文件

47
         </template>
47
         </template>
48
       </el-table-column>
48
       </el-table-column>
49
     </el-table>
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
   </div>
60
   </div>
51
 </template>
61
 </template>
52
 <script>
62
 <script>
63
       daterange: '',
73
       daterange: '',
64
       tableData: [],
74
       tableData: [],
65
       endDate: undefined,
75
       endDate: undefined,
66
-      startDate: undefined
76
+      startDate: undefined,
77
+      pageSize: 10,
78
+      currentPage: 1,
79
+      questionTotal: 0// 条目总数
67
     }
80
     }
68
   },
81
   },
69
   watch: {
82
   watch: {
74
     }
87
     }
75
   },
88
   },
76
   methods: {
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
     handleAdd() {
106
     handleAdd() {
79
       this.$emit('handleAddQuestion', true)
107
       this.$emit('handleAddQuestion', true)
91
       })
119
       })
92
     },
120
     },
93
     onSearch() {
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
         (res) => {
123
         (res) => {
96
           this.tableData = res.data.records
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
       this.daterange = ''
132
       this.daterange = ''
103
       this.startDate = ''
133
       this.startDate = ''
104
       this.endDate = ''
134
       this.endDate = ''
135
+      this.pageSize = 10
136
+      this.pageNum = 1
105
       this.onSearch()
137
       this.onSearch()
106
     },
138
     },
107
     dateChange(val) {
139
     dateChange(val) {

+ 9
- 11
src/views/gameManage/index.vue 查看文件

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