李志伟 3 лет назад
Родитель
Сommit
3e4f65196c

+ 46
- 0
src/api/answer.js Просмотреть файл

@@ -0,0 +1,46 @@
1
+import request from '@/utils/request'
2
+
3
+/**
4
+* 保存答案
5
+* @param {*} data
6
+* @returns
7
+*/
8
+export const saveAnswer = (data) => request({
9
+  url: '/admin/answer',
10
+  method: 'post',
11
+  data
12
+})
13
+
14
+/**
15
+ * 答案列表
16
+ * @param {*} params
17
+ * @returns
18
+ */
19
+export const getAnswerList = (params) => request({
20
+  url: '/admin/answer', params
21
+})
22
+
23
+/**
24
+ * 删除答案
25
+ * @param {*} data
26
+ * @returns
27
+ */
28
+export const deleteAnswer = (id) => request({
29
+  url: `/admin/answer/${id}`, method: 'delete'
30
+})
31
+/**
32
+ * 更新答案
33
+ * @param {*} data
34
+ * @returns
35
+ */
36
+export const UpdateAnswer = (data, id) => request({
37
+  url: `/admin/answer/${id}`, method: 'put', data
38
+})
39
+/**
40
+ * 查询答案详情
41
+ * @param {*} params
42
+ * @returns
43
+ */
44
+export const getAnswerDetail = (id) => request({
45
+  url: `/admin/answer/${id}`
46
+})

+ 11
- 11
src/api/appApi.js Просмотреть файл

@@ -2,8 +2,8 @@ import request from '@/utils/request'
2 2
 
3 3
 /**
4 4
 * 保存应用
5
-* @param {*} data 
6
-* @returns 
5
+* @param {*} data
6
+* @returns
7 7
 */
8 8
 export const saveApp = (data) => request({
9 9
   url: '/admin/App',
@@ -13,8 +13,8 @@ export const saveApp = (data) => request({
13 13
 
14 14
 /**
15 15
  * 应用列表
16
- * @param {*} params 
17
- * @returns 
16
+ * @param {*} params
17
+ * @returns
18 18
  */
19 19
 export const getAppList = (params) => request({
20 20
   url: '/admin/App', params
@@ -22,25 +22,25 @@ export const getAppList = (params) => request({
22 22
 
23 23
 /**
24 24
  * 删除应用
25
- * @param {*} data 
26
- * @returns 
25
+ * @param {*} data
26
+ * @returns
27 27
  */
28 28
 export const deleteApp = (id) => request({
29 29
   url: `/admin/App/${id}`, method: 'delete'
30 30
 })
31 31
 /**
32 32
  * 更新应用
33
- * @param {*} data 
34
- * @returns 
33
+ * @param {*} data
34
+ * @returns
35 35
  */
36 36
 export const UpdateApp = (data, id) => request({
37 37
   url: `/admin/App/${id}`, method: 'put', data
38 38
 })
39 39
 /**
40 40
  * 查询应用详情
41
- * @param {*} params 
42
- * @returns 
41
+ * @param {*} params
42
+ * @returns
43 43
  */
44 44
 export const getAppDetail = (id) => request({
45 45
   url: `/admin/App/${id}`
46
-})
46
+})

+ 0
- 111
src/components/AddAnswerMatching/index.vue Просмотреть файл

@@ -1,111 +0,0 @@
1
-<template>
2
-  <div class="answer">
3
-    <el-row :gutter="20">
4
-      <el-col :span="5">
5
-        <el-select
6
-          v-model="value.option"
7
-          filterable
8
-          allow-create
9
-          default-first-option
10
-          placeholder="请选择"
11
-        >
12
-          <el-option
13
-            v-for="item in options"
14
-            :key="item.value"
15
-            :label="item.label"
16
-            :value="item.value"
17
-          />
18
-        </el-select>
19
-      </el-col>
20
-      <el-col :span="17">
21
-        <el-input v-model="value.content" />
22
-      </el-col>
23
-    </el-row>
24
-    <el-row>
25
-      <el-col :span="20">
26
-        <el-select
27
-          v-model="nowlist"
28
-          filterable
29
-          multiple
30
-          default-first-option
31
-          placeholder="请选择特征词"
32
-        >
33
-          <el-option
34
-            v-for="item in wordList"
35
-            :key="item.wordId"
36
-            :label="item.wordId"
37
-            :value="item.word"
38
-          />
39
-        </el-select>
40
-      </el-col>
41
-      <el-col :span="1">
42
-        <el-button type="danger" @click="handleDelete">X</el-button>
43
-      </el-col>
44
-    </el-row>
45
-  </div>
46
-</template>
47
-<script>
48
-export default {
49
-  name: 'Answer',
50
-  props: {
51
-    characterId: String,
52
-    value: {
53
-      type: Object,
54
-      default: () => ({})
55
-    },
56
-    wordList: Array
57
-  },
58
-  data() {
59
-    return {
60
-      options: [
61
-        {
62
-          value: 'A',
63
-          label: 'A'
64
-        },
65
-        {
66
-          value: 'B',
67
-          label: 'B'
68
-        },
69
-        {
70
-          value: 'C',
71
-          label: 'C'
72
-        },
73
-        {
74
-          value: 'D',
75
-          label: 'D'
76
-        },
77
-        {
78
-          value: '对',
79
-          label: '对'
80
-        },
81
-        {
82
-          value: '错',
83
-          label: '错'
84
-        }
85
-      ],
86
-      nowlist: []
87
-    }
88
-  },
89
-  watch: {
90
-    value() {
91
-      this.value.characterWordList.map(item => {
92
-        this.nowlist.push(item.wordId)
93
-      })
94
-    },
95
-    nowlist() {
96
-      this.$emit('handleWordListChange', this.value, this.nowlist)
97
-    }
98
-  },
99
-  methods: {
100
-    handleDelete() {
101
-      this.$emit('handleDelete', this.value)
102
-    }
103
-  }
104
-}
105
-</script>
106
-<style>
107
-.answer {
108
-  margin: 10px 0;
109
-  width: 500px;
110
-}
111
-</style>

+ 7
- 4
src/components/GameCharacter/index.vue Просмотреть файл

@@ -59,10 +59,13 @@ export default {
59 59
     }
60 60
   },
61 61
   watch: {
62
-    gameId() {
63
-      if (this.gameId) {
64
-        this.onSearch()
65
-      }
62
+    gameId: {
63
+      handler(val) {
64
+        if (this.gameId) {
65
+          this.onSearch()
66
+        }
67
+      },
68
+      immediate: true // 页面加载时就启动
66 69
     }
67 70
   },
68 71
   methods: {

+ 70
- 34
src/components/Question/drawer.vue Просмотреть файл

@@ -2,7 +2,7 @@
2 2
   <div>
3 3
     <el-drawer
4 4
       ref="drawer"
5
-      title="添加答案"
5
+      :title="answerId ?'编辑答案' : '添加答案'"
6 6
       :before-close="handleClose"
7 7
       :visible.sync="dialog"
8 8
       direction="ltr"
@@ -11,27 +11,21 @@
11 11
       <div class="demo-drawer__content">
12 12
         <el-form :model="form" style="margin:20px">
13 13
           <el-form-item label="选项:" :label-width="formLabelWidth">
14
-            <el-select
15
-              v-model="form.option"
16
-              filterable
17
-              allow-create
18
-              default-first-option
19
-              placeholder="请选择选项"
20
-            >
21
-              <el-option
22
-                v-for="item in options"
23
-                :key="item.value"
24
-                :label="item.label"
25
-                :value="item.value"
26
-              />
27
-            </el-select>
28
-          </el-form-item>
29
-          <el-form-item label="内容详情" :label-width="formLabelWidth">
30
-            <el-input v-model="form.content" autocomplete="off" />
14
+            <el-input v-model="form.content" size="mini" placeholder="请输入答案(必填)">
15
+              <el-select slot="prepend" v-model="form.option" filterable allow-create default-first-option size="mini" style="width:100px" placeholder="请选择">
16
+                <el-option
17
+                  v-for="item in options"
18
+                  :key="item.value"
19
+                  :label="item.label"
20
+                  :value="item.value"
21
+                />
22
+              </el-select>
23
+            </el-input>
31 24
           </el-form-item>
32 25
           <el-form-item label="匹配特征:" :label-width="formLabelWidth">
33 26
             <el-select
34 27
               v-model="form.characterList"
28
+              size="mini"
35 29
               multiple
36 30
               filterable
37 31
               default-first-option
@@ -47,8 +41,8 @@
47 41
             </el-select>
48 42
           </el-form-item>
49 43
           <el-form-item style="text-align:center">
50
-            <el-button @click="cancelForm" size="mini">取 消</el-button>
51
-            <el-button type="primary" size="mini" @click="$refs.drawer.closeDrawer()">确 定</el-button>
44
+            <el-button size="mini" @click="handleClose">取 消</el-button>
45
+            <el-button type="primary" size="mini" @click="onSubmit">确 定</el-button>
52 46
           </el-form-item>
53 47
         </el-form>
54 48
       </div>
@@ -56,9 +50,13 @@
56 50
   </div>
57 51
 </template>
58 52
 <script>
53
+import { getAnswerDetail, saveAnswer, UpdateAnswer } from '@/api/answer'
59 54
 export default {
60 55
   props: {
61
-    dialog: Boolean
56
+    dialog: Boolean,
57
+    questionId: String,
58
+    answerId: String,
59
+    gameId: String
62 60
   },
63 61
   data() {
64 62
     return {
@@ -101,22 +99,60 @@ export default {
101 99
       return this.$store.state.game.wordList
102 100
     }
103 101
   },
104
-  methods: {
105
-    handleClose(done) {
106
-      this.$confirm('确定要添加这条答案吗?')
107
-        .then(_ => {
108
-          const list = this.wordList.filter(item => this.form.characterList.includes(item.characterId))
109
-          this.form.characterList = list
110
-          this.$emit('handleEditDrawer', this.form)
111
-          this.form = {
112
-            option: undefined,
113
-            content: undefined,
114
-            characterList: []
102
+  watch: {
103
+    answerId() {
104
+      if (this.answerId) {
105
+        getAnswerDetail(this.answerId).then((res) => {
106
+          this.form = res.data
107
+          if (res.data.characterList) {
108
+            const list = []
109
+            res.data.characterList.map(item => {
110
+              list.push(item.characterId)
111
+            })
112
+            this.form.characterList = list
115 113
           }
116 114
         })
117
-        .catch(_ => {})
115
+      }
116
+    }
117
+  },
118
+  methods: {
119
+    onSubmit() {
120
+      if (this.form.option && this.form.content) {
121
+        const list = this.wordList.filter(item => this.form.characterList.includes(item.characterId))
122
+        const data = { ...this.form }
123
+        if (list) {
124
+          list.map(item => {
125
+            item.gameId = this.gameId
126
+          })
127
+          data.characterList = list
128
+        }
129
+        data.questionId = this.questionId
130
+        if (this.answerId) {
131
+          UpdateAnswer(data, this.answerId).then((res) => {
132
+            this.$message('修改成功')
133
+            this.$emit('handleEditDrawer', true)
134
+            this.form = {
135
+              option: undefined,
136
+              content: undefined,
137
+              characterList: []
138
+            }
139
+          })
140
+        } else {
141
+          saveAnswer(data).then((res) => {
142
+            this.$message('添加成功')
143
+            this.$emit('handleEditDrawer', true)
144
+            this.form = {
145
+              option: undefined,
146
+              content: undefined,
147
+              characterList: []
148
+            }
149
+          })
150
+        }
151
+      } else {
152
+        this.$message('请添加选项和内容')
153
+      }
118 154
     },
119
-    cancelForm() {
155
+    handleClose() {
120 156
       this.$emit('handleCloseDrawer', true)
121 157
       this.form = {
122 158
         option: undefined,

+ 101
- 65
src/components/Question/edit.vue Просмотреть файл

@@ -3,42 +3,17 @@
3 3
     <h2 style="text-align: center">
4 4
       游戏题目{{ questionId ? "编辑" : "添加" }}
5 5
     </h2>
6
-    <el-form ref="form" :model="form" label-width="150px" size="mini">
6
+    <el-form ref="form" :model="form" label-width="90px" size="mini">
7 7
       <el-form-item label="题目:">
8
-        <el-input
9
-          v-model="form.title"
10
-          placeholder="请输入实例名(必填)"
11
-          type="textarea"
12
-        />
8
+        <el-input v-model="form.title" placeholder="请输入实例名(必填)">
9
+          <el-select slot="prepend" v-model="form.optType" style="width:100px" placeholder="请选择">
10
+            <el-option label="单选题" value="1" />
11
+            <el-option label="多选题" value="2" />
12
+            <el-option label="判断题" value="3" />
13
+          </el-select>
14
+        </el-input>
13 15
       </el-form-item>
14
-      <el-form-item label="题目类型:">
15
-        <el-select v-model="form.optType" placeholder="请选择">
16
-          <el-option label="单选题" value="1" />
17
-          <el-option label="多选题" value="2" />
18
-          <el-option label="判断题" value="3" />
19
-        </el-select>
20
-      </el-form-item>
21
-      <el-form-item label="答案:">
22
-        <el-button type="primary" @click="onAddAnswer">添加答案</el-button>
23
-
24
-        <div v-for="(answer, index) in form.answerList" :key="index">
25
-          <el-row :gutter="20" style="padding-top: 20px">
26
-            <el-col :span="1">
27
-              {{ answer.option }}
28
-            </el-col>
29
-            <el-col :span="10">{{ answer.content }}</el-col>
30
-          </el-row>
31
-          <el-row :gutter="20">
32
-            <el-col :span="20">
33
-              {{ handleToString(answer.characterList) }}
34
-            </el-col>
35
-            <el-col :span="1">
36
-              <el-button type="danger" @click="()=>handleDelete(index)">X</el-button>
37
-            </el-col>
38
-          </el-row>
39
-        </div>
40
-      </el-form-item>
41
-      <el-form-item label="正确选项:">
16
+      <el-form-item v-if="questionId!==undefined" label="正确选项:">
42 17
         <!-- <el-input v-model="form.option"></el-input> -->
43 18
         <!-- filterable可搜索 multiple可多选 default-first-option回车可选-->
44 19
         <el-select
@@ -56,17 +31,39 @@
56 31
           />
57 32
         </el-select>
58 33
       </el-form-item>
59
-      <el-form-item>
34
+      <el-form-item style="text-align:center">
60 35
         <el-button type="primary" @click="onSubmit">确定</el-button>
61 36
         <el-button @click="$router.go(-1)">返回</el-button>
62 37
       </el-form-item>
38
+      <el-form-item v-if="questionId!==undefined" label="答案:">
39
+        <el-button type="primary" @click="onAddAnswer">添加答案</el-button>
40
+      </el-form-item>
63 41
     </el-form>
64
-    <QuestionDrawer :dialog="dialog" @handleCloseDrawer="handleCloseDrawer" @handleEditDrawer="handleEditDrawer" />
42
+
43
+    <ul style="list-style-type: none;margin:10px 0 10px -2px">
44
+      <li v-for="answer in answerList" :key="answer.answerId" class="answerli">
45
+        <div style="flex:1;width: 100%;overflow: hidden;display: flex;" @click="handleEdit(answer)">
46
+          <span style="width:45px">{{ answer.option }}</span>
47
+          <span style="flex:1">{{ answer.content }}</span>
48
+        </div>
49
+        <el-popconfirm
50
+          style="width:15px"
51
+          icon="el-icon-info"
52
+          icon-color="red"
53
+          title="确定删除这个答案吗?"
54
+          @onConfirm="handleDelete(answer)"
55
+        >
56
+          <el-button slot="reference" type="text" class="deleteQuestion" style="color:red">×</el-button>
57
+        </el-popconfirm>
58
+      </li>
59
+    </ul>
60
+    <QuestionDrawer :dialog="dialog" :question-id="questionId" :answer-id="answerId" :game-id="gameId" @handleCloseDrawer="handleCloseDrawer" @handleEditDrawer="handleEditDrawer" />
65 61
   </div>
66 62
 </template>
67 63
 <script>
68 64
 
69
-import { saveQuestion, updateQuestion, getQuestionDetail } from '@/api/question'
65
+import { saveQuestion, UpdateQuestion, getQuestionDetail } from '@/api/question'
66
+import { getAnswerList, deleteAnswer } from '@/api/answer'
70 67
 import QuestionDrawer from '@/components/Question/drawer.vue'
71 68
 
72 69
 export default {
@@ -84,69 +81,88 @@ export default {
84 81
         optType: undefined,
85 82
         rightAnswer: undefined,
86 83
         gameId: undefined,
87
-        questionId: undefined,
88
-        // 答案列表(包括选项 内容 特征词列表)
89
-        answerList: []
84
+        questionId: undefined
90 85
       },
86
+      // 答案列表(包括选项 内容 特征词列表)
87
+      answerList: [],
88
+      answerId: undefined,
91 89
       // 正确答案数据源
92 90
       rightList: [],
93
-      dialog: false,
94
-      isChange: 0
91
+      dialog: false
95 92
     }
96 93
   },
97 94
   watch: {
98 95
     // 用于点击左边改变右边的页面
99 96
     questionId: function() {
97
+      if (this.gameId) {
98
+        this.form.gameId = this.gameId
99
+      }
100 100
       if (this.questionId) {
101 101
         this.rightList = []
102 102
         getQuestionDetail(this.questionId).then((res) => {
103 103
           this.form = res.data
104
-          this.form.rightAnswer = res.data.rightAnswer.split(',')
104
+          this.form.rightAnswer = res.data.rightAnswer?.split(',')
105 105
         })
106
+        this.handleAnswerList()
106 107
       } else {
107 108
         this.form = {
108 109
           title: undefined,
109 110
           optType: undefined,
110 111
           gameId: undefined,
111 112
           rightAnswer: undefined,
112
-          questionId: undefined,
113
-          answerList: []
113
+          questionId: undefined
114 114
         }
115
+        this.answerList = []
115 116
         this.rightList = []
116 117
       }
117
-      if (this.gameId) {
118
-        this.form.gameId = this.gameId
119
-      }
120 118
     },
121 119
     gameId() {
122 120
       if (this.gameId) {
123 121
         this.form.gameId = this.gameId
124 122
       }
125
-    },
126
-    isChange() {
127
-      const list = []
128
-      this.form.answerList.map(item => {
129
-        list.push(item.option)
130
-      })
131
-      this.rightList = list
132 123
     }
133 124
   },
134 125
   methods: {
126
+    // 添加答案
135 127
     onAddAnswer() {
136 128
       this.dialog = true
129
+      this.answerId = undefined
130
+    },
131
+    // 编辑答案
132
+    handleEdit(val) {
133
+      this.dialog = true
134
+      this.answerId = val.answerId
135
+    },
136
+    // 删除答案
137
+    handleDelete(val) {
138
+      deleteAnswer(val.answerId).then((res) => {
139
+        this.$message('删除答案成功')
140
+        this.handleAnswerList()
141
+      })
137 142
     },
143
+    // 关闭答案抽屉
138 144
     handleCloseDrawer() {
139 145
       this.dialog = false
146
+      this.answerId = undefined
140 147
     },
148
+    // 编辑答案抽屉成功重新查询列表
141 149
     handleEditDrawer(val) {
142
-      this.isChange++
143
-      this.form.answerList.push(val)
144 150
       this.handleCloseDrawer()
151
+      this.handleAnswerList()
145 152
     },
146
-    handleDelete(index) {
147
-      this.isChange--
148
-      this.form.answerList.splice(index, 1)
153
+    // 查询当前问题答案列表
154
+    handleAnswerList() {
155
+      getAnswerList({ questionId: this.questionId }).then((res) => {
156
+        this.answerList = res.data.records
157
+        // 给正确答按下拉菜单数据源赋值
158
+        const list = []
159
+        this.answerList.map(item => {
160
+          list.push(item.option)
161
+        })
162
+        this.rightList = list
163
+      })
149 164
     },
165
+    // 转换特征数组数据格式
150 166
     handleToString(list) {
151 167
       const nameList = []
152 168
       list?.map(item => {
@@ -155,13 +171,17 @@ export default {
155 171
       return nameList.toString()
156 172
     },
157 173
     onSubmit() {
158
-      if (this.form.title) {
159
-        this.form.rightAnswer = this.form.rightAnswer.toString()
174
+      if (this.form.title && this.form.optType) {
175
+        this.form.gameId = this.gameId
160 176
         if (this.questionId) {
161
-          updateQuestion(this.form, this.questionId).then((res) => {
177
+          if (this.form.rightAnswer) {
178
+            this.form.rightAnswer = this.form.rightAnswer.toString()
179
+          }
180
+          UpdateQuestion(this.form, this.questionId).then((res) => {
162 181
             this.$message('修改问题成功')
163 182
             // 告诉父页面实例表需要刷新并且关闭当前组件
164 183
             this.$emit('handleRefreshQuestion', true)
184
+            this.form.rightAnswer = res.data.rightAnswer?.split(',')
165 185
           })
166 186
         } else {
167 187
           saveQuestion(this.form).then((res) => {
@@ -172,11 +192,27 @@ export default {
172 192
           })
173 193
         }
174 194
       } else {
175
-        this.$message('请输入问题名称')
195
+        this.$message('请输入问题名称和题型')
176 196
       }
177 197
     }
178 198
   }
179 199
 }
180 200
 </script>
181
-<style>
201
+<style lang="scss">
202
+.answerli {
203
+  width: 100%;
204
+  overflow: hidden;
205
+  display: flex;
206
+  line-height:40px;
207
+  background-color: white;
208
+  .deleteQuestion{
209
+    display: none;
210
+  }
211
+}
212
+.answerli:hover {
213
+  background-color: rgb(230, 247, 255);
214
+}
215
+.answerli:hover .deleteQuestion{
216
+    display: block
217
+  }
182 218
 </style>

+ 45
- 74
src/components/Question/index.vue Просмотреть файл

@@ -1,52 +1,25 @@
1 1
 <template>
2 2
   <div class="body">
3
-    <div class="noshadowCard">
4
-      <el-card class="box-card">
5
-        问题名称:<el-input
6
-          v-model="title"
7
-          size="mini"
8
-          style="width: 150px; margin-right: 20px"
9
-        />
10
-        创建时间:
11
-        <el-date-picker
12
-          v-model="daterange"
13
-          size="mini"
14
-          type="daterange"
15
-          range-separator="至"
16
-          start-placeholder="开始日期"
17
-          end-placeholder="结束日期"
18
-          value-format="yyyy-MM-dd"
19
-          style="width:220px; margin-right: 20px"
20
-          @change="dateChange"
21
-        />
22
-
23
-        <el-button type="primary" size="mini" @click="onSearch">查询</el-button>
24
-        <el-button size="mini" @click="onReset">重置</el-button>
25
-        <el-button type="primary" size="mini" @click="handleAdd">添加问题</el-button>
26
-      </el-card>
3
+    <div style="line-height:30px; height:30px">
4
+      题库列表
5
+      <el-button type="primary" size="mini" style="float: right; margin-bottom: 20px;" @click="handleAdd">添加问题</el-button>
27 6
     </div>
28
-    <el-table stripe :data="tableData" border style="width: 100%">
29
-      <el-table-column prop="title" label="问题名称" />
30
-      <el-table-column prop="optType" label="答案类型" />
31
-      <el-table-column prop="createDate" label="创建时间">
32
-        <template slot-scope="scope">{{
33
-          scope.row.createDate.substr(0, 10)
34
-        }}</template>
35
-      </el-table-column>
36
-      <el-table-column fixed="right" label="操作">
37
-        <template slot-scope="scope">
38
-          <el-button type="text" @click="handleEdit(scope.row)">编辑</el-button>
39
-          <el-popconfirm
40
-            icon="el-icon-info"
41
-            icon-color="red"
42
-            title="确定删除这个问题吗?"
43
-            @onConfirm="handleDelete(scope.row)"
44
-          >
45
-            <el-button slot="reference" type="text">删除</el-button>
46
-          </el-popconfirm>
47
-        </template>
48
-      </el-table-column>
49
-    </el-table>
7
+    <ul style="list-style-type: none;margin:10px 0 10px -40px">
8
+      <li v-for="item,index in tableData" :key="index" class="questionli" @click="handleEdit(item)">
9
+        <span style="width:45px">第{{ index+1 }}题</span>
10
+        <span style="width:45px">{{ item.optType === '1'?'单选题':item.optType==='2'?'多选题':'判断题' }}</span>
11
+        <span style="flex:1">{{ item.title }}</span>
12
+        <el-popconfirm
13
+          style="width:15px"
14
+          icon="el-icon-info"
15
+          icon-color="red"
16
+          title="确定删除这个问题吗?"
17
+          @onConfirm="handleDelete(item)"
18
+        >
19
+          <el-button slot="reference" type="text" class="deleteQuestion" style="color:red">×</el-button>
20
+        </el-popconfirm>
21
+      </li>
22
+    </ul>
50 23
     <el-pagination
51 24
       v-show="questionTotal!==0"
52 25
       style="float:right; margin:20px 0"
@@ -68,22 +41,20 @@ export default {
68 41
   },
69 42
   data() {
70 43
     return {
71
-      // 问题名称
72
-      title: undefined,
73
-      daterange: '',
74 44
       tableData: [],
75
-      endDate: undefined,
76
-      startDate: undefined,
77
-      pageSize: 10,
45
+      pageSize: 20,
78 46
       currentPage: 1,
79 47
       questionTotal: 0// 条目总数
80 48
     }
81 49
   },
82 50
   watch: {
83
-    gameId() {
84
-      if (this.gameId) {
85
-        this.onSearch()
86
-      }
51
+    gameId: {
52
+      handler(val) {
53
+        if (this.gameId) {
54
+          this.onSearch()
55
+        }
56
+      },
57
+      immediate: true // 页面加载时就启动
87 58
     }
88 59
   },
89 60
   methods: {
@@ -96,7 +67,7 @@ export default {
96 67
       this.changePagination()
97 68
     },
98 69
     changePagination() {
99
-      getQuestionList({ gameId: this.gameId, title: this.title, startDate: this.startDate, endDate: this.endDate, pageSize: this.pageSize, pageNum: this.currentPage }).then(
70
+      getQuestionList({ gameId: this.gameId, pageSize: this.pageSize, pageNum: this.currentPage }).then(
100 71
         (res) => {
101 72
           this.tableData = res.data.records
102 73
         }
@@ -119,32 +90,32 @@ export default {
119 90
       })
120 91
     },
121 92
     onSearch() {
122
-      getQuestionList({ gameId: this.gameId, title: this.title, startDate: this.startDate, endDate: this.endDate, pageSize: this.pageSize }).then(
93
+      getQuestionList({ gameId: this.gameId, endDate: this.endDate, pageSize: this.pageSize }).then(
123 94
         (res) => {
124 95
           this.tableData = res.data.records
125 96
           this.questionTotal = res.data.total
126 97
           this.pageSize = res.data.size
127 98
         }
128 99
       )
129
-    },
130
-    onReset() {
131
-      this.title = ''
132
-      this.daterange = ''
133
-      this.startDate = ''
134
-      this.endDate = ''
135
-      this.pageSize = 10
136
-      this.pageNum = 1
137
-      this.onSearch()
138
-    },
139
-    dateChange(val) {
140
-      this.startDate = this.daterange[0]
141
-      this.endDate = this.daterange[1]
142 100
     }
143 101
   }
144 102
 }
145 103
 </script>
146
-<style>
147
-.noshadowCard > .box-card {
148
-  box-shadow: none;
104
+<style lang="scss">
105
+.questionli {
106
+  width: 100%;
107
+  overflow: hidden;
108
+  display: flex;
109
+  line-height:40px;
110
+  background-color: white;
111
+  .deleteQuestion{
112
+    display: none;
113
+  }
149 114
 }
115
+.questionli:hover {
116
+  background-color: rgb(230, 247, 255);
117
+}
118
+.questionli:hover .deleteQuestion{
119
+    display: block
120
+  }
150 121
 </style>

+ 6
- 6
src/views/gameManage/edit.vue Просмотреть файл

@@ -38,7 +38,7 @@
38 38
         :disabled="gameId ? false : true"
39 39
       >
40 40
         <el-row :gutter="20" style="padding-top: 20px">
41
-          <el-col :span="13">
41
+          <el-col :span="12">
42 42
             <GameCharacter
43 43
               ref="GameCharacter"
44 44
               :gameId='gameId'
@@ -47,7 +47,7 @@
47 47
               @handleEditGameCharacter='handleEditGameCharacter'
48 48
             />
49 49
           </el-col>
50
-          <el-col :span="11">
50
+          <el-col :span="12">
51 51
             <GameCharacterEdit :characterId='characterId' :gameId='gameId' @handleRefreshGameCharacter='handleRefreshGameCharacter' @handleEditGameCharacter='handleEditGameCharacter' />
52 52
           </el-col>
53 53
         </el-row>
@@ -58,7 +58,7 @@
58 58
         :disabled="gameId ? false : true"
59 59
       >
60 60
         <el-row :gutter="20" style="padding-top: 20px">
61
-          <el-col :span="13">
61
+          <el-col :span="12">
62 62
             <Question
63 63
               ref="Question"
64 64
               :gameId='gameId'
@@ -67,7 +67,7 @@
67 67
               @handleEditQuestion='handleEditQuestion'
68 68
             />
69 69
           </el-col>
70
-          <el-col :span="11">
70
+          <el-col :span="12">
71 71
             <QuestionEdit ref="QuestionEdit" :questionId='questionId' :gameId='gameId' @handleRefreshQuestion='handleRefreshQuestion' @handleEditQuestion='handleEditQuestion' />
72 72
           </el-col>
73 73
         </el-row>
@@ -116,14 +116,14 @@ export default {
116 116
   watch: {
117 117
     '$route.query.id': {
118 118
       handler(val) {
119
-        if (val) {
119
+        if (val) { // 有值代表是编辑状态 查询详情  没有值就是新增
120 120
           this.gameId = val
121 121
           getGameDetail(val).then((res) => {
122 122
             this.gameForm = res.data
123 123
           })
124 124
         }
125 125
       },
126
-      immediate: true
126
+      immediate: true // 页面加载时就启动
127 127
     }
128 128
   },
129 129
   methods: {