Selaa lähdekoodia

课程增删改查

wangfei 6 vuotta sitten
vanhempi
commit
6be4e2dadf

+ 150
- 56
src/pages/system/courseManager/courseList/add.vue Näytä tiedosto

@@ -11,7 +11,7 @@
11 11
                 :action='$api.file.image.url'
12 12
                 :show-file-list="false"
13 13
                 :on-success="handleAvatarSuccess">
14
-                <img v-if="postData.CourseImg" :src="postData.CourseImg" class="avatar">
14
+                <img v-if="detail.CourseImg" :src="detail.CourseImg" class="avatar">
15 15
                 <i v-else class="el-icon-plus avatar-uploader-icon"></i>
16 16
               </el-upload>
17 17
             </div>
@@ -23,7 +23,7 @@
23 23
             <div style="width: 50%;">
24 24
               <el-input
25 25
                 placeholder="请输入课程名称"
26
-                v-model="postData.CourseName"
26
+                v-model="detail.CourseName"
27 27
                 clearable
28 28
                 >
29 29
               </el-input>
@@ -34,12 +34,12 @@
34 34
           <span>课程类型:</span>
35 35
           <div class="flex-item">
36 36
             <div style="width: 50%;">
37
-              <el-select v-model="postData.LocationId" placeholder="请选择">
37
+              <el-select v-model="detail.LocationId" placeholder="请选择">
38 38
                 <el-option
39
-                  v-for="item in courseTypeList"
40
-                  :key="item.id"
41
-                  :label="item.name"
42
-                  :value="item.id">
39
+                  v-for="item in location"
40
+                  :key="item.LocationId"
41
+                  :label="item.LocationName"
42
+                  :value="item.LocationId">
43 43
                 </el-option>
44 44
               </el-select>
45 45
             </div>
@@ -51,7 +51,7 @@
51 51
             <div style="width: 200px;">
52 52
               <el-input
53 53
                 placeholder="请输入课程价格"
54
-                v-model="postData.Price"
54
+                v-model="detail.Price"
55 55
                 clearable
56 56
                 >
57 57
               </el-input>
@@ -62,7 +62,7 @@
62 62
           <span>案场:</span>
63 63
           <div class="flex-item">
64 64
             <div style="width: 50%;">
65
-              <el-select v-model="postData.CaseId" placeholder="请选择">
65
+              <el-select v-model="CaseId" placeholder="请选择">
66 66
                 <el-option
67 67
                   v-for="item in cases"
68 68
                   :key="item.CaseId"
@@ -79,7 +79,7 @@
79 79
             <div style="width: 200px;">
80 80
               <el-input
81 81
                 placeholder="请输入开课人数"
82
-                v-model="postData.MaxNum"
82
+                v-model="detail.MaxNum"
83 83
                 clearable
84 84
                 >
85 85
               </el-input>
@@ -92,7 +92,7 @@
92 92
             <div style="width: 200px;">
93 93
               <el-input
94 94
                 placeholder="请输入开课人数"
95
-                v-model="postData.MinNum"
95
+                v-model="detail.MinNum"
96 96
                 clearable
97 97
                 >
98 98
               </el-input>
@@ -105,7 +105,7 @@
105 105
             <div style="width: 200px;">
106 106
               <el-input
107 107
                 placeholder="请输入课时数"
108
-                v-model="postData.CourseNum"
108
+                v-model="detail.CourseNum"
109 109
                 clearable
110 110
                 >
111 111
               </el-input>
@@ -117,15 +117,15 @@
117 117
           <div class="flex-item">
118 118
             <div>
119 119
               <el-date-picker
120
-                v-model="postData.BeginDate"
121
-                type="date"
122
-                placeholder="选择开始日期">
123
-              </el-date-picker>
124
-              <span style="line-height:40px;display:inline-block;">-</span>
125
-              <el-date-picker
126
-                v-model="postData.EndDate"
127
-                type="date"
128
-                placeholder="选择结束日期">
120
+                v-model="courseDate"
121
+                type="daterange"
122
+                align="right"
123
+                unlink-panels
124
+                range-separator="至"
125
+                start-placeholder="开始日期"
126
+                end-placeholder="结束日期"
127
+                value-format="yyyy-MM-ddTHH:mm:ss"
128
+                :picker-options="pickerOptions">
129 129
               </el-date-picker>
130 130
             </div>
131 131
           </div>
@@ -138,7 +138,7 @@
138 138
                 type="textarea"
139 139
                 autosize
140 140
                 placeholder="请输入备注"
141
-                v-model="postData.Remark"
141
+                v-model="detail.Remark"
142 142
                 clearable
143 143
                 >
144 144
               </el-input>
@@ -150,17 +150,20 @@
150 150
           <div class="flex-item">
151 151
             <div style="width: 50%;">
152 152
               <el-select
153
-                v-model="postData.tagids"
153
+              style="width:100%"
154
+                v-model="tags"
154 155
                 multiple
155 156
                 filterable
156 157
                 allow-create
157 158
                 default-first-option
158 159
                 placeholder="请选择课程标签">
159 160
                 <el-option
160
-                  v-for="item in tagList"
161
-                  :key="item.value"
162
-                  :label="item.id"
163
-                  :value="item.value">
161
+                  v-for="item in tagList.list"
162
+                  :key="item.TagId"
163
+                  :label="item.TagName"
164
+                  :value="item.TagId"
165
+                  :value-key="item.TagId"
166
+                  >
164 167
                 </el-option>
165 168
               </el-select>
166 169
             </div>
@@ -174,7 +177,7 @@
174 177
                 type="textarea"
175 178
                 autosize
176 179
                 placeholder="请输入课程简介"
177
-                v-model="postData.CourseDesc"
180
+                v-model="detail.CourseDesc"
178 181
                 clearable
179 182
                 >
180 183
               </el-input>
@@ -185,8 +188,8 @@
185 188
           <span>是否精选课程:</span>
186 189
           <div class="flex-item">
187 190
             <div>
188
-              <el-radio v-model="postData.IsSelect" label="1">是</el-radio>
189
-              <el-radio v-model="postData.IsSelect" label="0">否</el-radio>
191
+              <el-radio v-model="detail.IsSelect" :label="1">是</el-radio>
192
+              <el-radio v-model="detail.IsSelect" :label="0">否</el-radio>
190 193
             </div>
191 194
           </div>
192 195
         </li>
@@ -200,59 +203,150 @@
200 203
 </template>
201 204
 
202 205
 <script>
203
-import { mapState } from 'vuex'
206
+import { createNamespacedHelpers, mapState } from 'vuex'
207
+
208
+const { mapState: mapCourseState, mapActions: mapCourseActions } = createNamespacedHelpers('course')
209
+const { mapState: mapLocationState, mapActions: mapLocationActions } = createNamespacedHelpers('cms')
210
+const { mapState: mapTagState, mapActions: mapTagActions } = createNamespacedHelpers('coursetag')
211
+
204 212
 export default {
205 213
   name: '',
206 214
   data () {
207 215
     return {
208
-      postData: {
209
-        CourseImg: '', // 课程主图
210
-        CourseName: '', // 课程名称
211
-        LocationId: '', // 课程类型
212
-        Price: '', // 课程价格
213
-        CaseId: '', // 案场id
214
-        MaxNum: '', // 上课人数
215
-        MinNum: '', // 最小开课人数
216
-        CourseNum: '', // 课时数
217
-        BeginDate: '', // 课程开始时间
218
-        EndDate: '', // 课程结束时间
219
-        Remark: '', // 课程计划备注
220
-        tagids: [], // 课程标签(已有标签数据存入此字段)
221
-        tagnames: [], // 课程标签(新增标签数据存入此字段)
222
-        CourseDesc: '', // 课程描述
223
-        IsSelect: '0', // 是否精选课程
216
+      pickerOptions: {
217
+        shortcuts: [{
218
+          text: '最近一周',
219
+          onClick (picker) {
220
+            const end = new Date()
221
+            const start = new Date()
222
+            start.setTime(start.getTime() - 3600 * 1000 * 24 * 7)
223
+            picker.$emit('pick', [start, end])
224
+          }
225
+        }, {
226
+          text: '最近一个月',
227
+          onClick (picker) {
228
+            const end = new Date()
229
+            const start = new Date()
230
+            start.setTime(start.getTime() - 3600 * 1000 * 24 * 30)
231
+            picker.$emit('pick', [start, end])
232
+          }
233
+        }, {
234
+          text: '最近三个月',
235
+          onClick (picker) {
236
+            const end = new Date()
237
+            const start = new Date()
238
+            start.setTime(start.getTime() - 3600 * 1000 * 24 * 90)
239
+            picker.$emit('pick', [start, end])
240
+          }
241
+        }]
224 242
       },
225
-      courseTypeList: [], // 课程类型列表
226
-      tagList: [], // 标签列表
227 243
     }
228 244
   },
229 245
   computed: {
246
+    ...mapLocationState({
247
+      location: x => x.location
248
+    }),
249
+    ...mapCourseState({
250
+      detail: x => x.courseInfo
251
+    }),
230 252
     ...mapState({
231 253
       cases: x => x.app.cases.list,
232
-      defaultCaseId: x => x.app.cases.default,
233
-      OrgId: x => x.app.user.OrgId,
254
+      caseid: x => x.app.cases.default,
255
+      orgid: x => x.app.user.OrgId,
256
+    }),
257
+    ...mapTagState({
258
+      tagList: x => x.tagList
234 259
     }),
235 260
     CaseId: {
236 261
       get () {
237
-        return this.postData.CaseId === '' ? this.defaultCaseId || '' : this.postData.CaseId
262
+        return this.detail.CaseId || this.caseid
238 263
       },
239 264
       set (val) {
240
-        this.postData.CaseId = val
265
+        this.UpdateInfo({...this.detail, CaseId: val})
241 266
       }
242
-    }
267
+    },
268
+    courseDate: {
269
+      get () {
270
+        return this.detail.BeginDate && this.detail.EndDate ? [this.detail.BeginDate, this.detail.EndDate] : []
271
+      },
272
+      set (val) {
273
+        this.UpdateInfo({...this.detail, BeginDate: val[0], EndDate: val[1]})
274
+      },
275
+    },
276
+    tags: {
277
+      get () {
278
+        return (this.detail.CourseTags || []).map(x => x.TagId)
279
+      },
280
+      set (val) {
281
+        let v = val.map(x => {
282
+          return {
283
+            TagId: x,
284
+          }
285
+        })
286
+        this.UpdateInfo({...this.detail, CourseTags: v})
287
+      }
288
+    },
243 289
   },
244 290
   components: {},
245 291
   methods: {
292
+    ...mapCourseActions([
293
+      'GetCourseByID',
294
+      'AddCourse',
295
+      'UpdateCourse',
296
+      'UpdateInfo',
297
+    ]),
298
+    ...mapLocationActions([
299
+      'updateLocationInfo',
300
+    ]),
301
+    ...mapTagActions([
302
+      'GetCourseTagList',
303
+    ]),
246 304
     handleAvatarSuccess (res, file) {
247
-      this.postData.CourseImg = res.result.url
305
+      this.UpdateInfo({...this.detail, CourseImg: res.result.url})
248 306
     },
249 307
     submit () { // 提交数据
308
+      const { id } = this.$route.query
309
+      if (!id || id === '') {
310
+        this.UpdateInfo({...this.detail, CourseId: ''})
311
+      }
312
+      const _that = this
313
+      this.detail.tagids = this.tags.map(x => {
314
+        let tagfilter = (_that.tagList.list || []).filter(tag => tag.TagId === x)
315
+        if (tagfilter.length > 0) {
316
+          return tagfilter[0].TagName + ':' + tagfilter[0].TagId
317
+        } else {
318
+          return x
319
+        }
320
+      }).join(',')
321
+      if ((this.detail.CourseId || '') === '') {
322
+        this.detail.OrgId = this.orgid
323
+        if (!this.detail.CaseId || this.detail.CaseId === '') {
324
+          this.detail.CaseId = this.caseid
325
+        }
326
+        this.AddCourse(this.detail)
327
+      } else {
328
+        this.UpdateCourse(this.detail)
329
+      }
330
+      this.$message({
331
+        type: 'success',
332
+        message: '操作成功'
333
+      })
334
+      this.$router.push({ name: 'courseList' })
250 335
     },
251 336
     cancel () {
252 337
       this.$router.push({ name: 'courseList' })
253 338
     }
254 339
   },
255
-  mounted () { }
340
+  mounted () {
341
+    this.updateLocationInfo()
342
+    this.GetCourseTagList({ pagesize: 100 })
343
+    const { id } = this.$route.query
344
+    if (id && id !== '') {
345
+      this.GetCourseByID({ id: id })
346
+    } else {
347
+      // this.SetNull()
348
+    }
349
+  }
256 350
 }
257 351
 </script>
258 352
 

+ 136
- 25
src/pages/system/courseManager/courseList/index.vue Näytä tiedosto

@@ -8,7 +8,13 @@
8 8
         <ul>
9 9
           <li>
10 10
             <!-- <span>选择案场:</span> -->
11
-            <el-select v-model="postData.caseid" placeholder="请选择">
11
+            <el-select v-model="postData.caseid" placeholder="请选择案场">
12
+              <el-option
13
+                key=""
14
+                label=""
15
+                value=""
16
+              >
17
+              </el-option>
12 18
               <el-option
13 19
                 v-for="item in cases"
14 20
                 :key="item.CaseId"
@@ -26,10 +32,10 @@
26 32
               >
27 33
               </el-option>
28 34
               <el-option
29
-                v-for="item in courseTypeList"
30
-                :key="item.typeId"
31
-                :label="item.typeName"
32
-                :value="item.typeId">
35
+                v-for="item in location"
36
+                :key="item.LocationId"
37
+                :label="item.LocationName"
38
+                :value="item.LocationId">
33 39
               </el-option>
34 40
             </el-select>
35 41
           </li>
@@ -49,9 +55,17 @@
49 55
     </div>
50 56
     <div class="system-table-box">
51 57
       <el-table
52
-        :data="currentList"
58
+        :data="courses.list"
53 59
         stripe
54 60
         style="width: 100%">
61
+        <el-table-column
62
+          prop="CourseName"
63
+          label="发布状态"
64
+          width="150">
65
+          <template slot-scope="scope">
66
+            <label>{{scope.row.Status===1?'已发布':'未发布'}}</label>
67
+          </template>
68
+        </el-table-column>
55 69
         <el-table-column
56 70
           prop="CourseName"
57 71
           label="课程名称"
@@ -63,24 +77,34 @@
63 77
           width="150">
64 78
         </el-table-column>
65 79
         <el-table-column
66
-          prop="LocationId"
67 80
           label="课程类别"
68 81
           width="150">
82
+          <template slot-scope="scope">
83
+            <label>{{getLocationName(scope.row.LocationId)}}</label>
84
+          </template>
69 85
         </el-table-column>
70 86
         <el-table-column
71
-          prop="CaseId"
72 87
           label="所在案场"
73 88
           width="150">
89
+          <template slot-scope="scope">
90
+            <label>{{getCaseName(scope.row.CaseId)}}</label>
91
+          </template>
74 92
         </el-table-column>
75 93
         <el-table-column
76 94
           prop="BeginDate"
77 95
           label="课程开始时间"
78 96
           width="150">
97
+          <template slot-scope="scope">
98
+            <label>{{FormatDate(scope.row.BeginDate)}}</label>
99
+          </template>
79 100
         </el-table-column>
80 101
         <el-table-column
81 102
           prop="EndDate"
82 103
           label="课程结束时间"
83 104
           width="150">
105
+          <template slot-scope="scope">
106
+            <label>{{FormatDate(scope.row.EndDate)}}</label>
107
+          </template>
84 108
         </el-table-column>
85 109
         <el-table-column
86 110
           fixed="right"
@@ -92,23 +116,35 @@
92 116
               type="success">添加课程详情</el-button>
93 117
             <el-button
94 118
               size="mini"
95
-              type="warning">排课</el-button>
119
+              type="warning"
120
+              v-if="scope.row.Status===0"
121
+              >排课</el-button>
96 122
             <el-button
97 123
               size="mini"
98
-              type="primary">复制课程</el-button>
124
+              type="primary"
125
+              @click="handleCopy(scope.row)"
126
+              >复制课程</el-button>
99 127
             <el-button
100 128
               size="mini"
101
-              type="warning">发布</el-button>
129
+              type="warning"
130
+              @click="handlePublic(scope.row)"
131
+              v-if="scope.row.Status===0"
132
+              >发布</el-button>
102 133
             <el-button
103 134
               size="mini"
104
-              type="danger">取消发布</el-button>
135
+              type="danger"
136
+              @click="handleUnPublic(scope.row)"
137
+              v-if="scope.row.Status===1"
138
+              >取消发布</el-button>
105 139
             <el-button
106 140
               size="mini"
107 141
               type="warning"
142
+              v-if="scope.row.Status===0"
108 143
               @click="handleEdit(scope.$index, scope.row)">编辑</el-button>
109 144
             <el-button
110 145
               size="mini"
111 146
               type="danger"
147
+              v-if="scope.row.Status===0"
112 148
               @click="handleDelete(scope.$index, scope.row)">删除</el-button>
113 149
           </template>
114 150
         </el-table-column>
@@ -116,16 +152,19 @@
116 152
     </div>
117 153
     <el-pagination
118 154
       @current-change="handleCurrentChange"
119
-      :current-page.sync="postData.page"
120
-      :page-size="postData.pagesize"
155
+      :current-page.sync="courses.page"
156
+      :page-size="courses.pagesize"
121 157
       layout="prev, pager, next, jumper"
122
-      :total="total">
158
+      :total="courses.pagenum">
123 159
     </el-pagination>
124 160
   </div>
125 161
 </template>
126 162
 
127 163
 <script>
128
-import { mapState } from 'vuex'
164
+import { createNamespacedHelpers, mapState } from 'vuex'
165
+
166
+const { mapState: mapCourseState, mapActions: mapCourseActions } = createNamespacedHelpers('course')
167
+const { mapState: mapLocationState, mapActions: mapLocationActions } = createNamespacedHelpers('cms')
129 168
 
130 169
 export default {
131 170
   name: '',
@@ -139,19 +178,11 @@ export default {
139 178
         typeid: '', // 课程类型
140 179
         name: '', // 课程名称
141 180
       },
142
-      currentList: [{
143
-        CourseName: 'xxx',
144
-        Price: 'xxx',
145
-        LocationId: 'xxx',
146
-        CaseId: 'xxx',
147
-        BeginDate: 'xxx',
148
-        EndDate: 'xxx',
149
-        CourseId: 'xxx',
150
-      }],
151 181
       courseTypeList: [],
152 182
     }
153 183
   },
154 184
   mounted () {
185
+    this.updateLocationInfo({ pagesize: 100 })
155 186
     this.$nextTick(function () {
156 187
       this.getList()
157 188
     })
@@ -161,6 +192,12 @@ export default {
161 192
       cases: x => x.app.cases.list,
162 193
       defaultCaseId: x => x.app.cases.default
163 194
     }),
195
+    ...mapCourseState({
196
+      courses: x => x.courseList,
197
+    }),
198
+    ...mapLocationState({
199
+      location: x => x.location
200
+    }),
164 201
     CaseId: {
165 202
       get () {
166 203
         return this.postData.caseid || this.defaultCaseId
@@ -171,12 +208,33 @@ export default {
171 208
     }
172 209
   },
173 210
   methods: {
211
+    ...mapCourseActions([
212
+      'GetCourseList',
213
+      'Public',
214
+      'UnPublic',
215
+      'DelCourse',
216
+      'SetNull',
217
+      'GetCourseByID'
218
+    ]),
219
+    ...mapLocationActions([
220
+      'updateLocationInfo',
221
+    ]),
222
+    getLocationName (id) {
223
+      return (this.location.filter(x => x.LocationId === id)[0] || {}).LocationName
224
+    },
225
+    getCaseName (id) {
226
+      return (this.cases.filter(x => x.CaseId === id)[0] || {}).CaseName
227
+    },
228
+    FormatDate (date) {
229
+      return this.toolClass.dateFormat(date, 'yyyy-mm-dd')
230
+    },
174 231
     search () { // 搜索
175 232
       this.postData.page = 1
176 233
       this.currentList = []
177 234
       this.getList()
178 235
     },
179 236
     getList () { // 获取列表
237
+      this.GetCourseList(this.postData)
180 238
     },
181 239
     handleCurrentChange (val) { // 跳转到分页
182 240
       this.getList()
@@ -185,8 +243,61 @@ export default {
185 243
       this.$router.push({ name: 'addCourse', query: { id: row.CourseId } })
186 244
     },
187 245
     handleDelete (index, row) { // 删除
246
+      this.$confirm('确认删除此课程?', '提示', {
247
+        confirmButtonText: '确定',
248
+        cancelButtonText: '取消',
249
+        type: 'warning'
250
+      })
251
+        .then(() => {
252
+          this.DelCourse({id: row.CourseId, callback: this.delCallBack})
253
+        })
254
+        .catch(() => {
255
+          this.$message({
256
+            type: 'info',
257
+            message: '已取消删除'
258
+          })
259
+        })
260
+    },
261
+    actionCallBack () {
262
+      this.$message({
263
+        type: 'success',
264
+        message: '操作成功!'
265
+      })
266
+      this.getList()
267
+    },
268
+    delCallBack () {
269
+      this.$message({
270
+        type: 'success',
271
+        message: '删除成功!'
272
+      })
273
+      this.getList()
188 274
     },
189 275
     addCourse () {
276
+      this.SetNull()
277
+      this.$router.push({ name: 'addCourse' })
278
+    },
279
+    handlePublic (row) {
280
+      this.$confirm('确认发布此课程?', '提示', {
281
+        confirmButtonText: '确定',
282
+        cancelButtonText: '取消',
283
+        type: 'warning'
284
+      })
285
+        .then(() => {
286
+          this.Public({ id: row.CourseId, callback: this.actionCallBack })
287
+        })
288
+    },
289
+    handleUnPublic (row) {
290
+      this.$confirm('确认取消发布此课程?', '提示', {
291
+        confirmButtonText: '确定',
292
+        cancelButtonText: '取消',
293
+        type: 'warning'
294
+      })
295
+        .then(() => {
296
+          this.UnPublic({ id: row.CourseId, callback: this.actionCallBack })
297
+        })
298
+    },
299
+    handleCopy (row) {
300
+      this.GetCourseByID({ id: row.CourseId })
190 301
       this.$router.push({ name: 'addCourse' })
191 302
     }
192 303
   }

+ 2
- 2
src/pages/system/goodsManager/goodManager/edit.vue Näytä tiedosto

@@ -152,7 +152,7 @@ export default {
152 152
       'GetGoodsByID',
153 153
       'AddGoods',
154 154
       'UpdateGoods',
155
-      'SetRoleNull',
155
+      'SetNull',
156 156
       'UpdateInfo',
157 157
       'GetGoodSpecs',
158 158
     ]),
@@ -204,7 +204,7 @@ export default {
204 204
     if (id && id !== '') {
205 205
       this.GetGoodsByID({ id: id })
206 206
     } else {
207
-      this.SetRoleNull()
207
+      this.SetNull()
208 208
     }
209 209
   }
210 210
 }

+ 0
- 1
src/pages/system/goodsManager/goodManager/index.vue Näytä tiedosto

@@ -166,7 +166,6 @@ export default {
166 166
     },
167 167
     handleDelete (index, row) {
168 168
       // 删除
169
-      console.log(index, row)
170 169
       this.$confirm('确认删除此商品?', '提示', {
171 170
         confirmButtonText: '确定',
172 171
         cancelButtonText: '取消',

+ 104
- 0
src/store/course/course.js Näytä tiedosto

@@ -0,0 +1,104 @@
1
+import ajax from '../../util/ajax'
2
+import api from '../../util/api'
3
+
4
+export default {
5
+  namespaced: true,
6
+  state: {
7
+    courseList: [],
8
+    courseInfo: {},
9
+  },
10
+  mutations: {
11
+    updateList (state, payload) {
12
+      state.courseList = payload || []
13
+    },
14
+    updateInfo (state, payload) {
15
+      state.courseInfo = payload || {}
16
+    },
17
+  },
18
+  actions: {
19
+    GetCourseList ({ commit }, payload) {
20
+      ajax(api.course.list.url, {
21
+        method: api.course.list.method,
22
+        queryData: {
23
+          ...payload,
24
+        }
25
+      }).then(res => {
26
+        commit('updateList', res)
27
+      })
28
+    },
29
+    GetCourseByID ({ commit }, { id }) {
30
+      ajax(api.course.info.url, {
31
+        method: api.course.info.method,
32
+        urlData: {
33
+          id: id,
34
+        }
35
+      }).then(res => {
36
+        commit('updateInfo', res)
37
+      })
38
+    },
39
+    AddCourse ({ commit }, payload) {
40
+      ajax(api.course.add.url, {
41
+        method: api.course.add.method,
42
+        data: {
43
+          ...payload
44
+        }
45
+      }).then(res => {
46
+        commit('updateInfo', res)
47
+      })
48
+    },
49
+    UpdateCourse ({ commit }, payload) {
50
+      ajax(api.course.update.url, {
51
+        method: api.course.update.method,
52
+        data: {
53
+          ...payload
54
+        },
55
+        urlData: {
56
+          id: payload.GoodsId,
57
+        }
58
+      }).then(res => {
59
+      })
60
+    },
61
+    DelCourse ({ commit }, { id, callback }) {
62
+      ajax(api.course.delete.url, {
63
+        method: api.course.delete.method,
64
+        urlData: {
65
+          id: id,
66
+        }
67
+      }).then(res => {
68
+        if (callback) {
69
+          callback()
70
+        }
71
+      })
72
+    },
73
+    Public ({ commit }, { id, callback }) {
74
+      ajax(api.course.public.url, {
75
+        method: api.course.public.method,
76
+        urlData: {
77
+          id: id,
78
+        }
79
+      }).then(res => {
80
+        if (callback) {
81
+          callback()
82
+        }
83
+      })
84
+    },
85
+    UnPublic ({ commit }, { id, callback }) {
86
+      ajax(api.course.unpublic.url, {
87
+        method: api.course.unpublic.method,
88
+        urlData: {
89
+          id: id,
90
+        }
91
+      }).then(res => {
92
+        if (callback) {
93
+          callback()
94
+        }
95
+      })
96
+    },
97
+    SetNull ({ commit }) {
98
+      commit('updateInfo', {})
99
+    },
100
+    UpdateInfo ({ commit }, payload) {
101
+      commit('updateInfo', payload)
102
+    }
103
+  }
104
+}

+ 26
- 0
src/store/course/tag.js Näytä tiedosto

@@ -0,0 +1,26 @@
1
+import ajax from '../../util/ajax'
2
+import api from '../../util/api'
3
+
4
+export default {
5
+  namespaced: true,
6
+  state: {
7
+    tagList: [],
8
+  },
9
+  mutations: {
10
+    updateList (state, payload) {
11
+      state.tagList = payload || []
12
+    },
13
+  },
14
+  actions: {
15
+    GetCourseTagList ({ commit }, payload) {
16
+      ajax(api.course.tags.url, {
17
+        method: api.course.tags.method,
18
+        queryData: {
19
+          ...payload,
20
+        }
21
+      }).then(res => {
22
+        commit('updateList', res)
23
+      })
24
+    },
25
+  },
26
+}

+ 1
- 1
src/store/goods/goods.js Näytä tiedosto

@@ -96,7 +96,7 @@ export default {
96 96
         callback()
97 97
       })
98 98
     },
99
-    SetRoleNull ({ commit }) {
99
+    SetNull ({ commit }) {
100 100
       commit('updateInfo', {})
101 101
     },
102 102
     UpdateInfo ({ commit }, payload) {

+ 2
- 0
src/store/index.js Näytä tiedosto

@@ -18,6 +18,8 @@ export const modules = {
18 18
   role: () => require('./system/role').default,
19 19
   device: () => require('./case/device').default,
20 20
   goods: () => require('./goods/goods').default,
21
+  course: () => require('./course/course').default,
22
+  coursetag: () => require('./course/tag').default,
21 23
 }
22 24
 
23 25
 Object.keys(modules).forEach((modKey) => {

+ 51
- 1
src/util/api.js Näytä tiedosto

@@ -82,7 +82,7 @@ const $api = {
82 82
   caseManager: {
83 83
     getRolesList: { // 获取角色列表
84 84
       method: 'get',
85
-      url: `${baseUrl}/common/role`
85
+      url: `${baseUrl}${common}/role`
86 86
     },
87 87
     getCaseList: { // 获取案场列表
88 88
       method: 'get',
@@ -436,6 +436,56 @@ const $api = {
436 436
       method: 'delete',
437 437
       url: `${baseUrl}${common}/case/equipment/:id`
438 438
     },
439
+  },
440
+  course: {
441
+    list: {
442
+      method: 'get',
443
+      url: `${baseUrl}${common}/course`
444
+    },
445
+    info: {
446
+      method: 'get',
447
+      url: `${baseUrl}${common}/course/:id`
448
+    },
449
+    tags: {
450
+      method: 'get',
451
+      url: `${baseUrl}${common}/coursetag`
452
+    },
453
+    add: {
454
+      method: 'post',
455
+      url: `${baseUrl}${common}/course`
456
+    },
457
+    update: {
458
+      method: 'put',
459
+      url: `${baseUrl}${common}/course`
460
+    },
461
+    delete: {
462
+      method: 'delete',
463
+      url: `${baseUrl}${common}/course/:id`
464
+    },
465
+    public: {
466
+      method: 'put',
467
+      url: `${baseUrl}${common}/course/:id/public`
468
+    },
469
+    unpublic: {
470
+      method: 'put',
471
+      url: `${baseUrl}${common}/course/:id/unpublic`
472
+    },
473
+    getimgs: {
474
+      method: 'get',
475
+      url: `${baseUrl}${common}/courseimg/:id`
476
+    },
477
+    addimgs: {
478
+      method: 'post',
479
+      url: `${baseUrl}${common}/courseimg`
480
+    },
481
+    updateimgs: {
482
+      method: 'put',
483
+      url: `${baseUrl}${common}/courseimg`
484
+    },
485
+    deleteimgs: {
486
+      method: 'delete',
487
+      url: `${baseUrl}${common}/courseimg/:id`
488
+    },
439 489
   }
440 490
 }
441 491
 export default $api