许成详 6 years ago
parent
commit
dcb94e3c4d
2 changed files with 104 additions and 2 deletions
  1. 101
    2
      src/pages/system/courseManager/courseList/index.vue
  2. 3
    0
      src/style/main.css

+ 101
- 2
src/pages/system/courseManager/courseList/index.vue View File

@@ -113,7 +113,8 @@
113 113
           <template slot-scope="scope">
114 114
             <el-button
115 115
               size="mini"
116
-              type="success">添加课程详情</el-button>
116
+              type="success"
117
+              @click="addDetail(scope.row)">添加课程详情</el-button>
117 118
             <el-button
118 119
               size="mini"
119 120
               type="warning"
@@ -157,6 +158,76 @@
157 158
       layout="prev, pager, next, jumper"
158 159
       :total="courses.pagenum">
159 160
     </el-pagination>
161
+    <el-dialog
162
+      title="课程详情"
163
+      :visible.sync="centerDialogVisible"
164
+      width="500px"
165
+      center>
166
+      <ul>
167
+        <li class="flex-h" style="align-items: flex-start;">
168
+          <span>课程详情图片:</span>
169
+          <div class="flex-item">
170
+            <div>
171
+              <el-upload
172
+                class="avatar-uploader"
173
+                :action='$api.file.image.url'
174
+                :show-file-list="false"
175
+                :on-success="handleAvatarSuccess">
176
+                <img v-if="editCourseDetail.newImg" :src="editCourseDetail.newImg" class="avatar">
177
+                <i v-else class="el-icon-plus avatar-uploader-icon"></i>
178
+              </el-upload>
179
+            </div>
180
+          </div>
181
+          <el-button
182
+            size="mini"
183
+            type="success"
184
+            v-if="editCourseDetail.newImg"
185
+            @click="addThisImg">确定添加图片</el-button>
186
+        </li>
187
+      </ul>
188
+      <el-table
189
+        :data="currentCourseDetail"
190
+        stripe
191
+        style="width: 100%">
192
+        <el-table-column
193
+          prop="img"
194
+          label="图片">
195
+          <template slot-scope="scope">
196
+            <img :src="scope.row.img" alt="">
197
+          </template>
198
+        </el-table-column>
199
+        <el-table-column
200
+          prop="sort"
201
+          label="排序">
202
+          <template slot-scope="scope">
203
+            <el-input
204
+              placeholder="请输入内容"
205
+              v-model="scope.row.sort"
206
+              :disabled="scope.row.edit ? false : true">
207
+            </el-input>
208
+          </template>
209
+        </el-table-column>
210
+        <el-table-column
211
+          label="操作">
212
+          <template slot-scope="scope">
213
+            <el-button
214
+              size="mini"
215
+              type="success"
216
+              v-if="!scope.row.edit"
217
+              @click="editItem(scope.$index, scope.row)">编辑</el-button>
218
+            <el-button
219
+              size="mini"
220
+              type="success"
221
+              v-if="scope.row.edit"
222
+              @click="sureSort(scope.$index, scope.row)">确认</el-button>
223
+            <el-button
224
+              size="mini"
225
+              type="danger"
226
+              @click="deleteItem(scope.$index, scope.row)">删除</el-button>
227
+          </template>
228
+        </el-table-column>
229
+      </el-table>
230
+    </el-dialog>
160 231
   </div>
161 232
 </template>
162 233
 
@@ -170,6 +241,16 @@ export default {
170 241
   name: '',
171 242
   data () {
172 243
     return {
244
+      currentCourseDetail: [{
245
+        img: '',
246
+        sort: 1,
247
+        edit: false,
248
+      }],
249
+      editCourseDetail: {
250
+        newImg: '',
251
+        list: [],
252
+      },
253
+      centerDialogVisible: false, // 课程详情弹窗显隐
173 254
       total: 0,
174 255
       postData: { // 表格搜索条件
175 256
         caseid: '', // 案场id
@@ -208,6 +289,24 @@ export default {
208 289
     }
209 290
   },
210 291
   methods: {
292
+    deleteItem (index, item) { // 删除图片
293
+
294
+    },
295
+    sureSort (index, item) { // 确认图片排序
296
+      this.currentCourseDetail[index].edit = false
297
+    },
298
+    editItem (index, item) { // 编辑图片排序
299
+      this.currentCourseDetail[index].edit = true
300
+    },
301
+    addThisImg () { // 添加图片到课程详情
302
+
303
+    },
304
+    handleAvatarSuccess (res, file) {
305
+      this.editCourseDetail.newImg = res.result.url
306
+    },
307
+    addDetail (val) { // 添加课程详情
308
+      this.centerDialogVisible = true
309
+    },
211 310
     ...mapCourseActions([
212 311
       'GetCourseList',
213 312
       'Public',
@@ -249,7 +348,7 @@ export default {
249 348
         type: 'warning'
250 349
       })
251 350
         .then(() => {
252
-          this.DelCourse({id: row.CourseId, callback: this.delCallBack})
351
+          this.DelCourse({ id: row.CourseId, callback: this.delCallBack })
253 352
         })
254 353
         .catch(() => {
255 354
           this.$message({

+ 3
- 0
src/style/main.css View File

@@ -384,6 +384,9 @@ select:focus {
384 384
   padding: 0 20px !important;
385 385
 }
386 386
 
387
+.avatar-uploader{
388
+  display: inline-block;
389
+}
387 390
 
388 391
 
389 392