소스 검색

Merge branch 'master' of http://git.ycjcjy.com/yz-question/pc-admin

Baozhangchao 3 년 전
부모
커밋
44f7c9c9ae

+ 46
- 0
src/api/answer.js 파일 보기

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
 
2
 
3
 /**
3
 /**
4
 * 保存应用
4
 * 保存应用
5
-* @param {*} data 
6
-* @returns 
5
+* @param {*} data
6
+* @returns
7
 */
7
 */
8
 export const saveApp = (data) => request({
8
 export const saveApp = (data) => request({
9
   url: '/admin/App',
9
   url: '/admin/App',
13
 
13
 
14
 /**
14
 /**
15
  * 应用列表
15
  * 应用列表
16
- * @param {*} params 
17
- * @returns 
16
+ * @param {*} params
17
+ * @returns
18
  */
18
  */
19
 export const getAppList = (params) => request({
19
 export const getAppList = (params) => request({
20
   url: '/admin/App', params
20
   url: '/admin/App', params
22
 
22
 
23
 /**
23
 /**
24
  * 删除应用
24
  * 删除应用
25
- * @param {*} data 
26
- * @returns 
25
+ * @param {*} data
26
+ * @returns
27
  */
27
  */
28
 export const deleteApp = (id) => request({
28
 export const deleteApp = (id) => request({
29
   url: `/admin/App/${id}`, method: 'delete'
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
 export const UpdateApp = (data, id) => request({
36
 export const UpdateApp = (data, id) => request({
37
   url: `/admin/App/${id}`, method: 'put', data
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
 export const getAppDetail = (id) => request({
44
 export const getAppDetail = (id) => request({
45
   url: `/admin/App/${id}`
45
   url: `/admin/App/${id}`
46
-})
46
+})

+ 0
- 111
src/components/AddAnswerMatching/index.vue 파일 보기

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
- 6
src/components/GameCharacter/edit.vue 파일 보기

71
   },
71
   },
72
   methods: {
72
   methods: {
73
     onSubmit() {
73
     onSubmit() {
74
-      this.form.characterId = this.characterId
75
-      if (this.form.name) {
74
+      const data = { ...this.form }
75
+      data.characterId = this.characterId
76
+      if (data.name) {
76
         if (this.characterId) {
77
         if (this.characterId) {
77
-          if (!this.form.thumb) {
78
-            this.form.thumb = ''
78
+          if (!data.thumb) {
79
+            data.thumb = ''
79
           }
80
           }
80
-          UpdateGameCharacter(this.form, this.characterId).then((res) => {
81
+          UpdateGameCharacter(data, this.characterId).then((res) => {
81
             this.$message('修改实例成功')
82
             this.$message('修改实例成功')
82
             // 告诉父页面实例表需要刷新
83
             // 告诉父页面实例表需要刷新
83
             this.$emit('handleRefreshGameCharacter', true)
84
             this.$emit('handleRefreshGameCharacter', true)
84
           })
85
           })
85
         } else {
86
         } else {
86
-          saveGameCharacter(this.form).then((res) => {
87
+          saveGameCharacter(data).then((res) => {
87
             this.$message('添加实例成功')
88
             this.$message('添加实例成功')
88
             // 告诉父页面实例表需要刷新
89
             // 告诉父页面实例表需要刷新
89
             this.$emit('handleRefreshGameCharacter', true)
90
             this.$emit('handleRefreshGameCharacter', true)

+ 7
- 4
src/components/GameCharacter/index.vue 파일 보기

59
     }
59
     }
60
   },
60
   },
61
   watch: {
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
   methods: {
71
   methods: {

+ 70
- 34
src/components/Question/drawer.vue 파일 보기

2
   <div>
2
   <div>
3
     <el-drawer
3
     <el-drawer
4
       ref="drawer"
4
       ref="drawer"
5
-      title="添加答案"
5
+      :title="answerId ?'编辑答案' : '添加答案'"
6
       :before-close="handleClose"
6
       :before-close="handleClose"
7
       :visible.sync="dialog"
7
       :visible.sync="dialog"
8
       direction="ltr"
8
       direction="ltr"
11
       <div class="demo-drawer__content">
11
       <div class="demo-drawer__content">
12
         <el-form :model="form" style="margin:20px">
12
         <el-form :model="form" style="margin:20px">
13
           <el-form-item label="选项:" :label-width="formLabelWidth">
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
           </el-form-item>
24
           </el-form-item>
32
           <el-form-item label="匹配特征:" :label-width="formLabelWidth">
25
           <el-form-item label="匹配特征:" :label-width="formLabelWidth">
33
             <el-select
26
             <el-select
34
               v-model="form.characterList"
27
               v-model="form.characterList"
28
+              size="mini"
35
               multiple
29
               multiple
36
               filterable
30
               filterable
37
               default-first-option
31
               default-first-option
47
             </el-select>
41
             </el-select>
48
           </el-form-item>
42
           </el-form-item>
49
           <el-form-item style="text-align:center">
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
           </el-form-item>
46
           </el-form-item>
53
         </el-form>
47
         </el-form>
54
       </div>
48
       </div>
56
   </div>
50
   </div>
57
 </template>
51
 </template>
58
 <script>
52
 <script>
53
+import { getAnswerDetail, saveAnswer, UpdateAnswer } from '@/api/answer'
59
 export default {
54
 export default {
60
   props: {
55
   props: {
61
-    dialog: Boolean
56
+    dialog: Boolean,
57
+    questionId: String,
58
+    answerId: String,
59
+    gameId: String
62
   },
60
   },
63
   data() {
61
   data() {
64
     return {
62
     return {
101
       return this.$store.state.game.wordList
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
       this.$emit('handleCloseDrawer', true)
156
       this.$emit('handleCloseDrawer', true)
121
       this.form = {
157
       this.form = {
122
         option: undefined,
158
         option: undefined,

+ 103
- 66
src/components/Question/edit.vue 파일 보기

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

+ 45
- 74
src/components/Question/index.vue 파일 보기

1
 <template>
1
 <template>
2
   <div class="body">
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
     </div>
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
     <el-pagination
23
     <el-pagination
51
       v-show="questionTotal!==0"
24
       v-show="questionTotal!==0"
52
       style="float:right; margin:20px 0"
25
       style="float:right; margin:20px 0"
68
   },
41
   },
69
   data() {
42
   data() {
70
     return {
43
     return {
71
-      // 问题名称
72
-      title: undefined,
73
-      daterange: '',
74
       tableData: [],
44
       tableData: [],
75
-      endDate: undefined,
76
-      startDate: undefined,
77
-      pageSize: 10,
45
+      pageSize: 20,
78
       currentPage: 1,
46
       currentPage: 1,
79
       questionTotal: 0// 条目总数
47
       questionTotal: 0// 条目总数
80
     }
48
     }
81
   },
49
   },
82
   watch: {
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
   methods: {
60
   methods: {
96
       this.changePagination()
67
       this.changePagination()
97
     },
68
     },
98
     changePagination() {
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
         (res) => {
71
         (res) => {
101
           this.tableData = res.data.records
72
           this.tableData = res.data.records
102
         }
73
         }
119
       })
90
       })
120
     },
91
     },
121
     onSearch() {
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
         (res) => {
94
         (res) => {
124
           this.tableData = res.data.records
95
           this.tableData = res.data.records
125
           this.questionTotal = res.data.total
96
           this.questionTotal = res.data.total
126
           this.pageSize = res.data.size
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
 </script>
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
 </style>
121
 </style>

+ 10
- 9
src/views/gameManage/edit.vue 파일 보기

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

+ 1
- 0
src/views/gameManage/index.vue 파일 보기

51
       style="float:right; margin:20px 0"
51
       style="float:right; margin:20px 0"
52
       :total="gameTotal"
52
       :total="gameTotal"
53
       :current-page="currentPage"
53
       :current-page="currentPage"
54
+      :page-sizes="[4, 10, 20, 50]"
54
       :page-size="pageSize"
55
       :page-size="pageSize"
55
       layout="total, prev, pager, next, sizes"
56
       layout="total, prev, pager, next, sizes"
56
       @size-change="handleSizeChange"
57
       @size-change="handleSizeChange"