许成详 6 年之前
父節點
當前提交
9241e173fe
共有 3 個檔案被更改,包括 18 行新增16 行删除
  1. 13
    13
      src/pages/system/cmsManager/majorProjects/edit.vue
  2. 2
    2
      src/store/cms/case.js
  3. 3
    1
      src/util/ajax.js

+ 13
- 13
src/pages/system/cmsManager/majorProjects/edit.vue 查看文件

@@ -266,7 +266,7 @@ export default {
266 266
     },
267 267
     checkFn (arr) {
268 268
       for (var n = 0; n < arr.length; n++) {
269
-        if (arr[n].type === 'isNull' && arr[n].target === '') {
269
+        if (arr[n].type === 'isNull' && !arr[n].target) {
270 270
           this.$message({
271 271
             message: arr[n].errorMsg,
272 272
             type: 'error'
@@ -278,31 +278,31 @@ export default {
278 278
     },
279 279
     submit () {
280 280
       var checkOff = this.checkFn([{
281
-        target: this.CaseId || '',
281
+        target: Boolean(this.CaseId || ''),
282 282
         errorMsg: '对应案场不能为空',
283 283
         type: 'isNull'
284 284
       }, {
285
-        target: this.detail.Name || '',
285
+        target: Boolean(this.detail.Name || ''),
286 286
         errorMsg: '名称不能为空',
287 287
         type: 'isNull'
288 288
       }, {
289
-        target: this.imgShow || '',
289
+        target: Boolean(this.imgShow || ''),
290 290
         errorMsg: '图片不能为空',
291 291
         type: 'isNull'
292 292
       }, {
293
-        target: (this.detailImgShow || ''),
293
+        target: Boolean(this.detailImgShow || ''),
294 294
         errorMsg: '详细图片不能为空',
295 295
         type: 'isNull'
296 296
       }, {
297
-        target: this.detail.DetailContent || '',
297
+        target: Boolean(this.detail.DetailContent || ''),
298 298
         errorMsg: '专题简介不能为空',
299 299
         type: 'isNull'
300 300
       }, {
301
-        target: this.detail.IsAllCourse || '',
301
+        target: Boolean(this.detail.IsAllCourse || ''),
302 302
         errorMsg: '展示课程不能为空',
303 303
         type: 'isNull'
304 304
       }, {
305
-        target: this.detail.Status === 0 || this.detail.Status || '',
305
+        target: Boolean(String(this.detail.Status) || ''),
306 306
         errorMsg: '是否前台展示不能为空',
307 307
         type: 'isNull'
308 308
       }])
@@ -319,11 +319,13 @@ export default {
319 319
       const courseids = (this.detail.Courses || []).map(x => x.CourseId).join(',')
320 320
       if (this.id === '') {
321 321
         this.detail.OrgId = this.OrgId
322
-        this.AddCaseInfo({ ...this.detail, OrgId: this.OrgId, imgs: this.imgShow, detailimgs: this.detailImgShow, courseids }).then(res => {
322
+        console.log(JSON.stringify({ ...this.detail, OrgId: this.OrgId, imgs: this.imgShow, detailimgs: this.detailImgShow, courseids }))
323
+        this.AddCaseInfo({ ...this.detail, OrgId: this.OrgId, imgs: this.imgShow, detailimgs: this.detailImgShow, courseids }).then((res) => {
323 324
           this.afterSave()
324 325
         })
325 326
       } else {
326
-        this.AddCaseInfo({ ...this.detail, imgs: this.imgShow, detailimgs: this.detailImgShow, courseids }).then(res => {
327
+        console.log(JSON.stringify({ ...this.detail, OrgId: this.OrgId, imgs: this.imgShow, detailimgs: this.detailImgShow, courseids }))
328
+        this.AddCaseInfo({ ...this.detail, imgs: this.imgShow, detailimgs: this.detailImgShow, courseids }).then((res) => {
327 329
           this.afterSave()
328 330
         })
329 331
       }
@@ -334,9 +336,7 @@ export default {
334 336
         type: 'success',
335 337
         duration: 1000
336 338
       })
337
-      setTimeout(() => {
338
-        this.$router.push({ name: 'indexCase' })
339
-      }, 1000)
339
+      this.$router.push({ name: 'indexCase' })
340 340
     },
341 341
     cancel () {
342 342
       this.$router.go(-1)

+ 2
- 2
src/store/cms/case.js 查看文件

@@ -28,8 +28,8 @@ export default {
28 28
         this.$ajax(this.$api.cms.addCase.url, {
29 29
           method: this.$api.cms.addCase.method,
30 30
           data: payload
31
-        }).then(res => {
32
-          resolve()
31
+        }).then((res) => {
32
+          resolve(res)
33 33
         })
34 34
       })
35 35
     },

+ 3
- 1
src/util/ajax.js 查看文件

@@ -47,7 +47,9 @@ Axios.interceptors.request.use((config) => {
47 47
   let fm = new FormData()
48 48
   for (let k in config.data) {
49 49
     if (Array.isArray(config.data[k])) {
50
-      fm.append(k, ...config.data[k].map(v => `${k}=${encodeURIComponent(v)}`))
50
+      config.data[k].forEach((v) => {
51
+        fm.append(k, v)
52
+      })
51 53
     } else {
52 54
       fm.append(k, config.data[k])
53 55
     }