yuantianjiao 6 yıl önce
ebeveyn
işleme
659b578116

+ 37
- 9
src/pages/system/cmsManager/bannerManager/add.vue Dosyayı Görüntüle

@@ -63,13 +63,18 @@
63 63
           <span>图片:</span>
64 64
           <div class="flex-item">
65 65
             <el-upload
66
-              class="avatar-uploader"
67
-              :action='$api.file.image.url'
68
-              :show-file-list="false"
69
-              :on-success="handleAvatarSuccess">
70
-              <img v-if="postData.ImageUrl" :src="postData.ImageUrl" class="avatar">
71
-              <i v-else class="el-icon-plus avatar-uploader-icon"></i>
66
+              :action="$api.file.image.url"
67
+              :limit='limit'
68
+              list-type="picture-card"
69
+              :file-list='imgsArr'
70
+              :on-success="handlePictureCardPreview"
71
+              :on-remove="handleRemove"
72
+              :on-exceed="exceed">
73
+              <i class="el-icon-plus"></i>
72 74
             </el-upload>
75
+            <el-dialog :visible.sync="dialogVisible">
76
+              <img width="100%" :src="imgs" alt="">
77
+            </el-dialog>
73 78
           </div>
74 79
         </li>
75 80
         <!-- <li class="flex-h">
@@ -113,7 +118,11 @@ export default {
113 118
         Title: '',
114 119
         OrgId: '',
115 120
         CaseId: ''
116
-      }
121
+      },
122
+      dialogVisible: false,
123
+      imgs: '',
124
+      imgsArr: [],
125
+      limit: 1
117 126
     }
118 127
   },
119 128
   components: {},
@@ -137,6 +146,13 @@ export default {
137 146
     submit () {
138 147
       this.postData.OrgId = this.OrgId
139 148
       this.postData.ForwardType === '1' ? this.postData.ForwardType = 'url' : this.postData.ForwardType = 'course'
149
+      this.postData.ImageUrl = ''
150
+      for (let i = 0; i < this.imgsArr.length; i++) {
151
+        this.postData.ImageUrl += this.imgsArr[i].response.result.url + ','
152
+      }
153
+      if (this.postData.ImageUrl) {
154
+        this.postData.ImageUrl = this.postData.ImageUrl.substr(0, this.postData.ImageUrl.length - 1)
155
+      }
140 156
       this.$ajax(this.$api.cms.addImage.url, {
141 157
         method: this.$api.cms.addImage.method,
142 158
         data: this.postData
@@ -156,8 +172,20 @@ export default {
156 172
     cancel () {
157 173
       this.$router.go(-1)
158 174
     },
159
-    handleAvatarSuccess (res, file) {
160
-      this.postData.ImageUrl = res.result.url
175
+    handlePictureCardPreview (res, file, fileList) {
176
+      this.imgs = res.result.url
177
+      this.dialogVisible = true
178
+      this.imgsArr = fileList
179
+    },
180
+    handleRemove (file, fileList) {
181
+      this.imgsArr = fileList
182
+    },
183
+    exceed () {
184
+      this.$message({
185
+        message: '超过可传的图片上限',
186
+        type: 'info',
187
+        duration: 1000
188
+      })
161 189
     }
162 190
   }
163 191
 }

+ 49
- 11
src/pages/system/cmsManager/bannerManager/edit.vue Dosyayı Görüntüle

@@ -63,13 +63,18 @@
63 63
           <span>图片:</span>
64 64
           <div class="flex-item">
65 65
             <el-upload
66
-              class="avatar-uploader"
67
-              :action='$api.file.image.url'
68
-              :show-file-list="false"
69
-              :on-success="handleAvatarSuccess">
70
-              <img v-if="postData.ImageUrl" :src="postData.ImageUrl" class="avatar">
71
-              <i v-else class="el-icon-plus avatar-uploader-icon"></i>
66
+              :action="$api.file.image.url"
67
+              :limit='limit'
68
+              list-type="picture-card"
69
+              :file-list='imgsArr'
70
+              :on-success="handlePictureCardPreview"
71
+              :on-remove="handleRemove"
72
+              :on-exceed="exceed">
73
+              <i class="el-icon-plus"></i>
72 74
             </el-upload>
75
+            <el-dialog :visible.sync="dialogVisible">
76
+              <img width="100%" :src="imgs" alt="">
77
+            </el-dialog>
73 78
           </div>
74 79
         </li>
75 80
         <!-- <li class="flex-h">
@@ -113,7 +118,11 @@ export default {
113 118
         Title: '',
114 119
         OrgId: '',
115 120
         CaseId: ''
116
-      }
121
+      },
122
+      dialogVisible: false,
123
+      imgs: '',
124
+      imgsArr: [],
125
+      limit: 1
117 126
     }
118 127
   },
119 128
   components: {},
@@ -134,7 +143,13 @@ export default {
134 143
       this.postData.OrgId = this.OrgId
135 144
       this.postData.CaseId = this.CaseId
136 145
       this.postData.ForwardType === '1' ? this.postData.ForwardType = 'url' : this.postData.ForwardType = 'course'
137
-      console.log(this.postData)
146
+      this.postData.ImageUrl = ''
147
+      for (let i = 0; i < this.imgsArr.length; i++) {
148
+        this.postData.ImageUrl += this.imgsArr[i].response.result.url + ','
149
+      }
150
+      if (this.postData.ImageUrl) {
151
+        this.postData.ImageUrl = this.postData.ImageUrl.substr(0, this.postData.ImageUrl.length - 1)
152
+      }
138 153
       this.$ajax(this.$api.cms.editImage.url, {
139 154
         method: this.$api.cms.editImage.method,
140 155
         data: this.postData,
@@ -157,9 +172,6 @@ export default {
157 172
     cancel () {
158 173
       this.$router.go(-1)
159 174
     },
160
-    handleAvatarSuccess (res, file) {
161
-      this.postData.ImageUrl = res.result.url
162
-    },
163 175
     getDetail () {
164 176
       this.$ajax(this.$api.cms.imageDetail.url, {
165 177
         method: this.$api.cms.imageDetail.method,
@@ -170,10 +182,36 @@ export default {
170 182
         console.log(res)
171 183
         res.Status = res.Status + ''
172 184
         res.ForwardType === 'url' ? res.ForwardType = '1' : res.ForwardType = '0'
185
+        let imgsArr = []
186
+        let item = {
187
+          url: res.ImageUrl,
188
+          response: {
189
+            result: {
190
+              url: res.ImageUrl
191
+            }
192
+          }
193
+        }
194
+        imgsArr.push(item)
195
+        this.imgsArr = imgsArr
173 196
         this.postData = res
174 197
       }).catch(msg => {
175 198
 
176 199
       })
200
+    },
201
+    handlePictureCardPreview (res, file, fileList) {
202
+      this.imgs = res.result.url
203
+      this.dialogVisible = true
204
+      this.imgsArr = fileList
205
+    },
206
+    handleRemove (file, fileList) {
207
+      this.imgsArr = fileList
208
+    },
209
+    exceed () {
210
+      this.$message({
211
+        message: '超过可传的图片上限',
212
+        type: 'info',
213
+        duration: 1000
214
+      })
177 215
     }
178 216
   }
179 217
 }

+ 1
- 0
src/pages/system/cmsManager/bannerManager/index.vue Dosyayı Görüntüle

@@ -116,6 +116,7 @@ export default {
116 116
       this.$router.push({ name: 'addBanner' })
117 117
     },
118 118
     getList () {
119
+      this.tableData = []
119 120
       this.$ajax(this.$api.cms.imageList.url, {
120 121
         method: this.$api.cms.imageList.method,
121 122
         queryData: {

+ 1
- 1
src/pages/system/cmsManager/indexMsg/edit.vue Dosyayı Görüntüle

@@ -106,7 +106,7 @@ export default {
106 106
         data: this.postData
107 107
       }).then(res => {
108 108
         this.$message({
109
-          message: '添加成功',
109
+          message: '编辑成功',
110 110
           type: 'success',
111 111
           duration: 1000
112 112
         })

+ 5
- 15
src/pages/system/cmsManager/indexMsg/index.vue Dosyayı Görüntüle

@@ -104,30 +104,20 @@ export default {
104 104
       })
105 105
     },
106 106
     searchList (key) { // 搜索列表
107
-      this.$ajax(this.$api.cms.info.url, {
108
-        method: this.$api.cms.info.method,
109
-        queryData: {
110
-          page: this.postData.currentPage,
111
-          pagesize: 100,
112
-          title: key
113
-        }
114
-      }).then(res => {
115
-        this.tableData = res.list
116
-        this.postData.total = res.pagenum
117
-        this.postData.currentPage = res.page
118
-      }).catch(msg => {
119
-
120
-      })
107
+      this.tableSearch.key = key
108
+      this.getList()
121 109
     },
122 110
     addIndexMsg () {
123 111
       this.$router.push({ name: 'addIndexMsg' })
124 112
     },
125 113
     getList () {
114
+      this.tableData = []
126 115
       this.$ajax(this.$api.cms.info.url, {
127 116
         method: this.$api.cms.info.method,
128 117
         queryData: {
129 118
           page: this.postData.currentPage,
130
-          pagesize: this.postData.pageSize
119
+          pagesize: this.postData.pageSize,
120
+          title: this.tableSearch.key
131 121
         }
132 122
       }).then(res => {
133 123
         this.tableData = res.list

+ 15
- 19
src/pages/system/cmsManager/majorProjects/add.vue Dosyayı Görüntüle

@@ -48,6 +48,7 @@
48 48
               :action="$api.file.image.url"
49 49
               list-type="picture-card"
50 50
               :on-success="handlePictureCardPreview"
51
+              :file-list='imgsArr'
51 52
               :on-remove="handleRemove">
52 53
               <i class="el-icon-plus"></i>
53 54
             </el-upload>
@@ -62,6 +63,7 @@
62 63
             <el-upload
63 64
               :action='$api.file.image.url'
64 65
               list-type="picture-card"
66
+              :file-list='detailimgsArr'
65 67
               :on-success="handlePictureCardPreviewDetail"
66 68
               :on-remove="handleRemoveDetail">
67 69
               <i class="el-icon-plus"></i>
@@ -89,8 +91,8 @@
89 91
           <span>是否前台展示:</span>
90 92
           <div class="flex-item">
91 93
             <div style="width:50%" class="radio">
92
-              <el-radio v-model="postData.IsAllCourse" label='1' >是</el-radio>
93
-              <el-radio v-model="postData.IsAllCourse" label='0' >否</el-radio>
94
+              <el-radio v-model="postData.Status" label='1' >是</el-radio>
95
+              <el-radio v-model="postData.Status" label='0' >否</el-radio>
94 96
             </div>
95 97
           </div>
96 98
         </li>
@@ -114,7 +116,7 @@ export default {
114 116
         Name: '',
115 117
         Title: '',
116 118
         DetailContent: '',
117
-        IsAllCourse: '1',
119
+        Status: '1',
118 120
         imgs: '',
119 121
         detailimgs: '',
120 122
         courseids: ''
@@ -139,6 +141,8 @@ export default {
139 141
     ...mapActions(['updateSystemInfo']),
140 142
     submit () {
141 143
       this.postData.OrgId = this.OrgId
144
+      this.postData.imgs = ''
145
+      this.postData.detailimgs = ''
142 146
       for (let i = 0; i < this.imgsArr.length; i++) {
143 147
         this.postData.imgs += this.imgsArr[i].response.result.url + ','
144 148
       }
@@ -166,29 +170,21 @@ export default {
166 170
     cancel () {
167 171
       this.$router.go(-1)
168 172
     },
169
-    handlePictureCardPreview (res, file) {
173
+    handlePictureCardPreview (res, file, fileList) {
170 174
       this.imgs = res.result.url
171 175
       this.dialogVisible = true
172
-      this.imgsArr.push(file)
176
+      this.imgsArr = fileList
173 177
     },
174
-    handleRemove (file) {
175
-      for (let i = 0; i < this.imgsArr.length; i++) {
176
-        if (this.imgsArr[i].uid === file.uid) {
177
-          this.imgsArr.splice(i, 1)
178
-        }
179
-      }
178
+    handleRemove (file, fileList) {
179
+      this.imgsArr = fileList
180 180
     },
181
-    handlePictureCardPreviewDetail (res, file) {
181
+    handlePictureCardPreviewDetail (res, file, fileList) {
182 182
       this.detailimgs = res.result.url
183 183
       this.dialogVisibleDetail = true
184
-      this.detailimgsArr.push(file)
184
+      this.detailimgsArr = fileList
185 185
     },
186
-    handleRemoveDetail (file) {
187
-      for (let i = 0; i < this.detailimgsArr.length; i++) {
188
-        if (this.detailimgsArr[i].uid === file.uid) {
189
-          this.detailimgsArr.splice(i, 1)
190
-        }
191
-      }
186
+    handleRemoveDetail (file, fileList) {
187
+      this.detailimgsArr = fileList
192 188
     }
193 189
   },
194 190
   created () {

+ 57
- 25
src/pages/system/cmsManager/majorProjects/edit.vue Dosyayı Görüntüle

@@ -47,6 +47,7 @@
47 47
             <el-upload
48 48
               :action="$api.file.image.url"
49 49
               list-type="picture-card"
50
+              :file-list='imgsArr'
50 51
               :on-success="handlePictureCardPreview"
51 52
               :on-remove="handleRemove">
52 53
               <i class="el-icon-plus"></i>
@@ -62,6 +63,7 @@
62 63
             <el-upload
63 64
               :action='$api.file.image.url'
64 65
               list-type="picture-card"
66
+              :file-list='detailimgsArr'
65 67
               :on-success="handlePictureCardPreviewDetail"
66 68
               :on-remove="handleRemoveDetail">
67 69
               <i class="el-icon-plus"></i>
@@ -89,8 +91,8 @@
89 91
           <span>是否前台展示:</span>
90 92
           <div class="flex-item">
91 93
             <div style="width:50%" class="radio">
92
-              <el-radio v-model="postData.IsAllCourse" label='1' >是</el-radio>
93
-              <el-radio v-model="postData.IsAllCourse" label='0' >否</el-radio>
94
+              <el-radio v-model="postData.Status" label='1' >是</el-radio>
95
+              <el-radio v-model="postData.Status" label='0' >否</el-radio>
94 96
             </div>
95 97
           </div>
96 98
         </li>
@@ -114,7 +116,7 @@ export default {
114 116
         Name: '',
115 117
         Title: '',
116 118
         DetailContent: '',
117
-        IsAllCourse: '1',
119
+        Status: '1',
118 120
         imgs: '',
119 121
         detailimgs: '',
120 122
         courseids: ''
@@ -138,20 +140,30 @@ export default {
138 140
   methods: {
139 141
     submit () {
140 142
       this.postData.OrgId = this.OrgId
143
+      this.postData.imgs = ''
144
+      this.postData.detailimgs = ''
141 145
       for (let i = 0; i < this.imgsArr.length; i++) {
142 146
         this.postData.imgs += this.imgsArr[i].response.result.url + ','
143 147
       }
144
-      this.postData.imgs = this.postData.imgs.substr(0, this.postData.imgs.length - 1)
148
+      if (this.postData.imgs) {
149
+        this.postData.imgs = this.postData.imgs.substr(0, this.postData.imgs.length - 1)
150
+      }
145 151
       for (let i = 0; i < this.detailimgsArr.length; i++) {
146 152
         this.postData.detailimgs += this.detailimgsArr[i].response.result.url + ','
147 153
       }
148
-      this.postData.detailimgs = this.postData.detailimgs.substr(0, this.postData.detailimgs.length - 1)
149
-      this.$ajax(this.$api.cms.addCase.url, {
150
-        method: this.$api.cms.addCase.method,
154
+      if (this.postData.detailimgs) {
155
+        this.postData.detailimgs = this.postData.detailimgs.substr(0, this.postData.detailimgs.length - 1)
156
+      }
157
+      console.log(this.postData)
158
+      this.$ajax(this.$api.cms.editCase.url, {
159
+        method: this.$api.cms.editCase.method,
160
+        urlData: {
161
+          id: this.$route.query.id
162
+        },
151 163
         data: this.postData
152 164
       }).then(res => {
153 165
         this.$message({
154
-          message: '添加成功',
166
+          message: '编辑成功',
155 167
           type: 'success',
156 168
           duration: 1000
157 169
         })
@@ -165,29 +177,22 @@ export default {
165 177
     cancel () {
166 178
       this.$router.go(-1)
167 179
     },
168
-    handlePictureCardPreview (res, file) {
180
+    handlePictureCardPreview (res, file, fileList) {
169 181
       this.imgs = res.result.url
170 182
       this.dialogVisible = true
171
-      this.imgsArr.push(file)
183
+      this.imgsArr = fileList
184
+      console.log(this.imgsArr)
172 185
     },
173
-    handleRemove (file) {
174
-      for (let i = 0; i < this.imgsArr.length; i++) {
175
-        if (this.imgsArr[i].uid === file.uid) {
176
-          this.imgsArr.splice(i, 1)
177
-        }
178
-      }
186
+    handleRemove (file, fileList) {
187
+      this.imgsArr = fileList
179 188
     },
180
-    handlePictureCardPreviewDetail (res, file) {
189
+    handlePictureCardPreviewDetail (res, file, fileList) {
181 190
       this.detailimgs = res.result.url
182 191
       this.dialogVisibleDetail = true
183
-      this.detailimgsArr.push(file)
192
+      this.detailimgsArr = fileList
184 193
     },
185
-    handleRemoveDetail (file) {
186
-      for (let i = 0; i < this.detailimgsArr.length; i++) {
187
-        if (this.detailimgsArr[i].uid === file.uid) {
188
-          this.detailimgsArr.splice(i, 1)
189
-        }
190
-      }
194
+    handleRemoveDetail (file, fileList) {
195
+      this.detailimgsArr = fileList
191 196
     },
192 197
     getDetail () {
193 198
       this.$ajax(this.$api.cms.caseDetail.url, {
@@ -197,7 +202,34 @@ export default {
197 202
         }
198 203
       }).then(res => {
199 204
         console.log(res)
200
-        res.IsAllCourse += ''
205
+        res.Status += ''
206
+        let imgsArr = []
207
+        let detailimgsArr = []
208
+        for (let i = 0; i < res.CmsCaseImgs.length; i++) {
209
+          if (res.CmsCaseImgs[i].ImageType === 'cover') {
210
+            let item = {
211
+              url: res.CmsCaseImgs[i].CaseImageUrl,
212
+              response: {
213
+                result: {
214
+                  url: res.CmsCaseImgs[i].CaseImageUrl
215
+                }
216
+              }
217
+            }
218
+            imgsArr.push(item)
219
+          } else if (res.CmsCaseImgs[i].ImageType === 'detail') {
220
+            let item = {
221
+              url: res.CmsCaseImgs[i].CaseImageUrl,
222
+              response: {
223
+                result: {
224
+                  url: res.CmsCaseImgs[i].CaseImageUrl
225
+                }
226
+              }
227
+            }
228
+            detailimgsArr.push(item)
229
+          }
230
+        }
231
+        this.imgsArr = imgsArr
232
+        this.detailimgsArr = detailimgsArr
201 233
         this.postData = res
202 234
       }).catch(msg => {
203 235
 

+ 34
- 18
src/pages/system/cmsManager/majorProjects/index.vue Dosyayı Görüntüle

@@ -45,21 +45,17 @@
45 45
         </el-table-column>
46 46
         <el-table-column label="操作" width="450">
47 47
           <template slot-scope="scope">
48
-            <el-button v-if="!scope.row.isShow"
48
+            <el-button
49 49
               size="mini"
50 50
               type="primary"
51
-              @click="showItem(scope.$index, scope.row)">前台展示</el-button>
52
-            <el-button v-if="scope.row.isShow"
53
-              size="mini"
54
-              type="danger"
55
-              @click="cancelShowItem(scope.$index, scope.row)">取消前台展示</el-button>
51
+              @click="showItem(scope.$index, scope.row)"><span v-if="scope.row.Status === 1">取消前台展示</span><span v-if="scope.row.Status === 0">前台展示</span></el-button>
56 52
             <el-button
57 53
               size="mini"
58 54
               type="warning"
59 55
               @click="editItem(scope.$index, scope.row)">编辑</el-button>
60
-            <el-button
56
+            <!-- <el-button
61 57
               size="mini"
62
-              @click="copyItemUrl(scope.$index, scope.row)">复制专题链接</el-button>
58
+              @click="copyItemUrl(scope.$index, scope.row)">复制专题链接</el-button> -->
63 59
             <el-button
64 60
               size="mini"
65 61
               type="danger"
@@ -121,18 +117,16 @@ export default {
121 117
       this.getList()
122 118
     },
123 119
     showItem (index, row) { // 前台显示
124
-      console.log(index, row)
125
-    },
126
-    cancelShowItem (index, row) { // 取消前台显示
127
-      console.log(index, row)
120
+      this.editIsAllCourse(row)
128 121
     },
129 122
     editItem (index, row) { // 编辑
130 123
       console.log(index, row)
131 124
       this.$router.push({ name: 'editIndexCase', query: { id: row.CmsCaseId } })
132 125
     },
133
-    copyItemUrl (index, row) { // 复制专题链接
134
-      console.log(index, row)
135
-    },
126
+    // copyItemUrl (index, row) { // 复制专题链接
127
+    //   console.log(index, row)
128
+    //   window.clipboardData.setData('Text', row.Title)
129
+    // },
136 130
     deleteItem (index, row) { // 删除
137 131
       console.log(index, row)
138 132
       this.$confirm('确认删除此项目专题?', '提示', {
@@ -149,18 +143,21 @@ export default {
149 143
       })
150 144
     },
151 145
     searchList (key) { // 搜索列表
152
-      console.log(key)
146
+      this.tableSearch.key = key
147
+      this.getList()
153 148
     },
154 149
     addMajorProjects () {
155 150
       this.$router.push({ name: 'addIndexCase' })
156 151
     },
157 152
     getList () {
153
+      this.tableData = []
158 154
       this.$ajax(this.$api.cms.case.url, {
159 155
         method: this.$api.cms.case.method,
160 156
         queryData: {
161 157
           page: this.postData.currentPage,
162 158
           pagesize: this.postData.pageSize,
163
-          caseid: this.tableSearch.caseId
159
+          caseid: this.tableSearch.caseId,
160
+          name: this.tableSearch.key
164 161
         }
165 162
       }).then(res => {
166 163
         for (let i = 0; i < res.list.length; i++) {
@@ -188,7 +185,26 @@ export default {
188 185
       }).catch(msg => {
189 186
 
190 187
       })
191
-    }
188
+    },
189
+    editIsAllCourse (data) {
190
+      console.log(data)
191
+      let api = data.Status === 1 ? this.$api.cms.caseHide : this.$api.cms.caseShow
192
+      this.$ajax(api.url, {
193
+        method: api.method,
194
+        urlData: {
195
+          id: data.CmsCaseId
196
+        }
197
+      }).then(res => {
198
+        this.$message({
199
+          message: '编辑成功',
200
+          type: 'success',
201
+          duration: 1000
202
+        })
203
+        this.getList()
204
+      }).catch(msg => {
205
+
206
+      })
207
+    },
192 208
   }
193 209
 }
194 210
 </script>

+ 51
- 14
src/pages/system/cmsManager/newsManager/add.vue Dosyayı Görüntüle

@@ -36,7 +36,7 @@
36 36
           <span>图片位置:</span>
37 37
           <div class="flex-item">
38 38
             <div style="width:50%">
39
-              <el-select v-model="postData.LocationId" placeholder="请选择">
39
+              <el-select v-model="postData.LocationIds" multiple placeholder="请选择">
40 40
                 <el-option
41 41
                   v-for="item in positionList"
42 42
                   :key="item.LocationId"
@@ -63,13 +63,18 @@
63 63
           <span>图片:</span>
64 64
           <div class="flex-item">
65 65
             <el-upload
66
-              class="avatar-uploader"
67
-              :action='$api.file.image.url'
68
-              :show-file-list="false"
69
-              :on-success="handleAvatarSuccess">
70
-              <img v-if="postData.ImageUrl" :src="postData.ImageUrl" class="avatar">
71
-              <i v-else class="el-icon-plus avatar-uploader-icon"></i>
66
+              :action="$api.file.image.url"
67
+              :limit='limit'
68
+              list-type="picture-card"
69
+              :file-list='imgsArr'
70
+              :on-success="handlePictureCardPreview"
71
+              :on-remove="handleRemove"
72
+              :on-exceed="exceed">
73
+              <i class="el-icon-plus"></i>
72 74
             </el-upload>
75
+            <el-dialog :visible.sync="dialogVisible">
76
+              <img width="100%" :src="imgs" alt="">
77
+            </el-dialog>
73 78
           </div>
74 79
         </li>
75 80
         <li style="text-align:center">
@@ -82,7 +87,8 @@
82 87
 </template>
83 88
 
84 89
 <script>
85
-import { mapState } from 'vuex'
90
+import { mapState, mapActions, createNamespacedHelpers } from 'vuex'
91
+const { mapActions: mapCmsActions } = createNamespacedHelpers('cms')
86 92
 export default {
87 93
   name: '',
88 94
   data () {
@@ -92,26 +98,46 @@ export default {
92 98
         ForwardUrl: '',
93 99
         ForwardResourceId: '',
94 100
         Status: '1',
95
-        LocationIds: '1',
101
+        LocationIds: [],
96 102
         ImageUrl: '',
97 103
         Title: '',
98 104
         OrgId: '',
99 105
         CaseId: ''
100
-      }
106
+      },
107
+      dialogVisible: false,
108
+      imgs: '',
109
+      imgsArr: [],
110
+      limit: 1
101 111
     }
102 112
   },
103 113
   components: {},
114
+  created () {
115
+    this.updateSystemInfo().then(() => {
116
+      this.postData.OrgId = this.OrgId
117
+      this.postData.CaseId = this.CaseId
118
+    })
119
+  },
104 120
   computed: {
105 121
     ...mapState({
106 122
       positionList: x => x.cms.location,
107 123
       OrgId: x => x.app.user.OrgId,
124
+      CaseId: x => x.app.cases.default,
108 125
     })
109 126
   },
110 127
   methods: {
128
+    ...mapActions(['updateSystemInfo']),
129
+    ...mapCmsActions(['updateLocationInfo']),
111 130
     submit () {
112 131
       console.log(this.postData)
113
-      this.postData.OrgId = this.OrgId
114 132
       this.postData.ForwardType === '1' ? this.postData.ForwardType = 'url' : this.postData.ForwardType = 'course'
133
+      this.postData.locationids = this.postData.LocationIds.join(',')
134
+      this.postData.ImageUrl = ''
135
+      for (let i = 0; i < this.imgsArr.length; i++) {
136
+        this.postData.ImageUrl += this.imgsArr[i].response.result.url + ','
137
+      }
138
+      if (this.postData.ImageUrl) {
139
+        this.postData.ImageUrl = this.postData.ImageUrl.substr(0, this.postData.ImageUrl.length - 1)
140
+      }
115 141
       this.$ajax(this.$api.cms.addNews.url, {
116 142
         method: this.$api.cms.addNews.method,
117 143
         data: this.postData
@@ -131,9 +157,20 @@ export default {
131 157
     cancel () {
132 158
       this.$router.go(-1)
133 159
     },
134
-    handleAvatarSuccess (res, file) {
135
-      console.log(res)
136
-      this.postData.ImageUrl = res.result.url
160
+    handlePictureCardPreview (res, file, fileList) {
161
+      this.imgs = res.result.url
162
+      this.dialogVisible = true
163
+      this.imgsArr = fileList
164
+    },
165
+    handleRemove (file, fileList) {
166
+      this.imgsArr = fileList
167
+    },
168
+    exceed () {
169
+      this.$message({
170
+        message: '超过可传的图片上限',
171
+        type: 'info',
172
+        duration: 1000
173
+      })
137 174
     }
138 175
   }
139 176
 }

+ 124
- 47
src/pages/system/cmsManager/newsManager/edit.vue Dosyayı Görüntüle

@@ -6,8 +6,8 @@
6 6
           <span>跳转类型:</span>
7 7
           <div class="flex-item">
8 8
             <div style="width:50%" class="radio">
9
-                <el-radio v-model="postData.jumpType" label='0' >连接</el-radio>
10
-                <el-radio v-model="postData.jumpType" label='1' >课程</el-radio>
9
+                <el-radio v-model="postData.ForwardType" label='1' >连接</el-radio>
10
+                <el-radio v-model="postData.ForwardType" label='0' >课程</el-radio>
11 11
             </div>
12 12
           </div>
13 13
         </li>
@@ -17,7 +17,7 @@
17 17
             <div style="width:50%">
18 18
               <el-input
19 19
                 placeholder="请输入连接"
20
-                v-model="postData.link"
20
+                v-model="postData.ForwardUrl"
21 21
                 clearable>
22 22
               </el-input>
23 23
             </div>
@@ -27,8 +27,8 @@
27 27
           <span>是否发布:</span>
28 28
           <div class="flex-item">
29 29
             <div style="width:50%" class="radio">
30
-              <el-radio v-model="postData.release" label='0' >是</el-radio>
31
-                <el-radio v-model="postData.release" label='1' >否</el-radio>
30
+              <el-radio v-model="postData.Status" label='1' >是</el-radio>
31
+                <el-radio v-model="postData.Status" label='0' >否</el-radio>
32 32
             </div>
33 33
           </div>
34 34
         </li>
@@ -36,33 +36,24 @@
36 36
           <span>图片位置:</span>
37 37
           <div class="flex-item">
38 38
             <div style="width:50%">
39
-              <el-select v-model="postData.position" placeholder="请选择">
39
+              <el-select v-model="postData.LocationIds" multiple placeholder="请选择">
40 40
                 <el-option
41 41
                   v-for="item in positionList"
42
-                  :key="item.value"
43
-                  :label="item.label"
44
-                  :value="item.value">
42
+                  :key="item.LocationId"
43
+                  :label="item.LocationName"
44
+                  :value="item.LocationId">
45 45
                 </el-option>
46 46
               </el-select>
47 47
             </div>
48 48
           </div>
49 49
         </li>
50
-        <li class="flex-h">
51
-          <span>是否推荐到首页:</span>
52
-          <div class="flex-item">
53
-            <div style="width:50%" class="radio">
54
-              <el-radio v-model="postData.index" label='0' >是</el-radio>
55
-                <el-radio v-model="postData.index" label='1' >否</el-radio>
56
-            </div>
57
-          </div>
58
-        </li>
59 50
         <li class="flex-h">
60 51
           <span>标题:</span>
61 52
           <div class="flex-item">
62 53
             <div style="width:50%">
63 54
               <el-input
64
-                placeholder="请输入真实姓名"
65
-                v-model="postData.realName"
55
+                placeholder="请输入标题"
56
+                v-model="postData.Title"
66 57
                 clearable>
67 58
               </el-input>
68 59
             </div>
@@ -71,13 +62,19 @@
71 62
         <li class="flex-h">
72 63
           <span>图片:</span>
73 64
           <div class="flex-item">
74
-            <div>
75
-              <a class="formImg">
76
-                <img src="" class="centerLabel contain" alt="">
77
-                <i class="iconfont icon-quxiao"></i>
78
-              </a>
79
-              <el-button type="success" size="mini">上传图片</el-button>
80
-            </div>
65
+            <el-upload
66
+              :action="$api.file.image.url"
67
+              :limit='limit'
68
+              list-type="picture-card"
69
+              :file-list='imgsArr'
70
+              :on-success="handlePictureCardPreview"
71
+              :on-remove="handleRemove"
72
+              :on-exceed="exceed">
73
+              <i class="el-icon-plus"></i>
74
+            </el-upload>
75
+            <el-dialog :visible.sync="dialogVisible">
76
+              <img width="100%" :src="imgs" alt="">
77
+            </el-dialog>
81 78
           </div>
82 79
         </li>
83 80
         <li style="text-align:center">
@@ -90,42 +87,122 @@
90 87
 </template>
91 88
 
92 89
 <script>
90
+import { mapState, createNamespacedHelpers } from 'vuex'
91
+const { mapActions: mapCmsActions } = createNamespacedHelpers('cms')
93 92
 export default {
94 93
   name: '',
95 94
   data () {
96 95
     return {
97 96
       postData: {
98
-        jumpType: '0',
99
-        link: '',
100
-        release: '0',
101
-        position: '',
102
-        index: '0'
97
+        ForwardType: '1',
98
+        ForwardUrl: '',
99
+        ForwardResourceId: '',
100
+        Status: '1',
101
+        LocationIds: [],
102
+        ImageUrl: '',
103
+        Title: '',
104
+        OrgId: '',
105
+        CaseId: ''
103 106
       },
104
-      positionList: [{
105
-        value: '0',
106
-        label: '首页'
107
-      }, {
108
-        value: '1',
109
-        label: '精选'
110
-      }, {
111
-        value: '2',
112
-        label: '社交'
113
-      }, {
114
-        value: '3',
115
-        label: '健身'
116
-      }],
107
+      dialogVisible: false,
108
+      imgs: '',
109
+      imgsArr: [],
110
+      limit: 1
117 111
     }
118 112
   },
119 113
   components: {},
114
+  created () {
115
+    this.updateLocationInfo().then(() => {
116
+      this.getDetail()
117
+    })
118
+  },
119
+  computed: {
120
+    ...mapState({
121
+      positionList: x => x.cms.location
122
+    })
123
+  },
120 124
   methods: {
125
+    ...mapCmsActions(['updateLocationInfo']),
121 126
     submit () {
122 127
       console.log(this.postData)
128
+      this.postData.ForwardType === '1' ? this.postData.ForwardType = 'url' : this.postData.ForwardType = 'course'
129
+      this.postData.locationids = this.postData.LocationIds.join(',')
130
+      this.postData.ImageUrl = ''
131
+      for (let i = 0; i < this.imgsArr.length; i++) {
132
+        this.postData.ImageUrl += this.imgsArr[i].response.result.url + ','
133
+      }
134
+      if (this.postData.ImageUrl) {
135
+        this.postData.ImageUrl = this.postData.ImageUrl.substr(0, this.postData.ImageUrl.length - 1)
136
+      }
137
+      this.$ajax(this.$api.cms.editNews.url, {
138
+        method: this.$api.cms.editNews.method,
139
+        urlData: {
140
+          id: this.$route.query.id
141
+        },
142
+        data: this.postData
143
+      }).then(res => {
144
+        this.$message({
145
+          message: '编辑成功',
146
+          type: 'success',
147
+          duration: 1000
148
+        })
149
+        setTimeout(() => {
150
+          this.$router.push({ name: 'newsManager' })
151
+        }, 1000)
152
+      }).catch(msg => {
153
+
154
+      })
123 155
     },
124 156
     cancel () {
125 157
       this.$router.go(-1)
158
+    },
159
+    handlePictureCardPreview (res, file, fileList) {
160
+      this.imgs = res.result.url
161
+      this.dialogVisible = true
162
+      this.imgsArr = fileList
163
+    },
164
+    handleRemove (file, fileList) {
165
+      this.imgsArr = fileList
166
+    },
167
+    exceed () {
168
+      this.$message({
169
+        message: '超过可传的图片上限',
170
+        type: 'info',
171
+        duration: 1000
172
+      })
173
+    },
174
+    getDetail () {
175
+      this.$ajax(this.$api.cms.newsDetail.url, {
176
+        method: this.$api.cms.newsDetail.method,
177
+        urlData: {
178
+          id: this.$route.query.id
179
+        }
180
+      }).then(res => {
181
+        res.ForwardType === 'url' ? res.ForwardType = '1' : res.ForwardType = '0'
182
+        res.Status += ''
183
+        res.LocationIds = res.NewsLocations.reduce((previousValue, currentValue, index, array) => {
184
+          console.log(previousValue)
185
+          previousValue.push(currentValue.LocationId)
186
+          return previousValue
187
+        }, [])
188
+        console.log(res.LocationIds)
189
+        let imgsArr = []
190
+        let item = {
191
+          url: res.ImageUrl,
192
+          response: {
193
+            result: {
194
+              url: res.ImageUrl
195
+            }
196
+          }
197
+        }
198
+        imgsArr.push(item)
199
+        this.imgsArr = imgsArr
200
+        this.postData = res
201
+      }).catch(msg => {
202
+
203
+      })
126 204
     }
127
-  },
128
-  mounted () { }
205
+  }
129 206
 }
130 207
 </script>
131 208
 

+ 26
- 19
src/pages/system/cmsManager/newsManager/index.vue Dosyayı Görüntüle

@@ -41,7 +41,7 @@
41 41
           label="标题">
42 42
         </el-table-column>
43 43
         <el-table-column
44
-          prop="LocationShow"
44
+          prop="LocationNames"
45 45
           label="位置">
46 46
         </el-table-column>
47 47
         <el-table-column
@@ -65,9 +65,9 @@
65 65
     <el-pagination
66 66
       @current-change="handleCurrentChange"
67 67
       :current-page.sync="postData.currentPage"
68
-      :page-size="10"
68
+      :page-size="postData.pageSize"
69 69
       layout="prev, pager, next, jumper"
70
-      :total="100">
70
+      :total="postData.total">
71 71
     </el-pagination>
72 72
   </div>
73 73
 </template>
@@ -112,7 +112,7 @@ export default {
112 112
     },
113 113
     handleEdit (index, row) { // 编辑
114 114
       console.log(index, row)
115
-      this.$router.push({ name: 'editNews' })
115
+      this.$router.push({ name: 'editNews', query: { id: row.NewsId } })
116 116
     },
117 117
     handleDelete (index, row) { // 删除
118 118
       console.log(index, row)
@@ -121,10 +121,7 @@ export default {
121 121
         cancelButtonText: '取消',
122 122
         type: 'warning'
123 123
       }).then(() => {
124
-        this.$message({
125
-          type: 'success',
126
-          message: '删除成功!'
127
-        })
124
+        this.deleteNews(row.NewsId)
128 125
       }).catch(() => {
129 126
         this.$message({
130 127
           type: 'info',
@@ -133,37 +130,47 @@ export default {
133 130
       })
134 131
     },
135 132
     searchList (key) { // 搜索列表
136
-      console.log(key)
133
+      this.tableSearch.key = key
134
+      this.getList()
137 135
     },
138 136
     addNews () {
139 137
       this.$router.push({ name: 'addNews' })
140 138
     },
141 139
     getList () {
140
+      this.tableData = []
142 141
       this.$ajax(this.$api.cms.news.url, {
143 142
         method: this.$api.cms.news.method,
144 143
         queryData: {
145 144
           page: this.postData.currentPage,
146 145
           pagesize: this.postData.pageSize,
147
-          locationid: this.tableSearch.LocationId
146
+          locationid: this.tableSearch.LocationId,
147
+          title: this.tableSearch.key
148 148
         }
149 149
       }).then(res => {
150
-        let that = this
151
-        console.log(that.positionList)
152
-        console.log(res.list)
153 150
         for (let i = 0; i < res.list.length; i++) {
154 151
           res.list[i].Status === 1 ? res.list[i].StatusShow = '是' : res.list[i].StatusShow = '否'
155
-          for (let j = 0; j < that.positionList.length; i++) {
156
-            if (res.list[i].LocationIds === that.positionList[j].LocationId) {
157
-              res.list[i].LocationShow = that.positionList[j].LocationName
158
-            }
159
-          }
160 152
         }
161
-        console.log(res.list)
162 153
         this.tableData = res.list
163 154
         this.postData.total = res.pagenum
164 155
         this.postData.currentPage = res.page
165 156
       }).catch(msg => {
166 157
 
158
+      })
159
+    },
160
+    deleteNews (id) {
161
+      this.$ajax(this.$api.cms.deleteNews.url, {
162
+        method: this.$api.cms.deleteNews.method,
163
+        urlData: {
164
+          id: id
165
+        }
166
+      }).then(res => {
167
+        this.$message({
168
+          type: 'success',
169
+          message: '删除成功!'
170
+        })
171
+        this.getList()
172
+      }).catch(msg => {
173
+
167 174
       })
168 175
     }
169 176
   }

+ 13
- 5
src/util/api.js Dosyayı Görüntüle

@@ -211,25 +211,33 @@ const $api = {
211 211
       method: 'delete',
212 212
       url: `${baseUrl}/common/cms/info/:id`
213 213
     },
214
-    news: { // 咨列表
214
+    news: { // 咨列表
215 215
       method: 'get',
216 216
       url: `${baseUrl}/common/cms/news`
217 217
     },
218
-    newsDetail: { // 咨详情
218
+    newsDetail: { // 咨详情
219 219
       method: 'get',
220 220
       url: `${baseUrl}/common/cms/news/:id`
221 221
     },
222
-    addNews: { // 新增咨
222
+    addNews: { // 新增咨
223 223
       method: 'post',
224 224
       url: `${baseUrl}/common/cms/news`
225 225
     },
226
-    editNews: { // 编辑咨
226
+    editNews: { // 编辑咨
227 227
       method: 'put',
228 228
       url: `${baseUrl}/common/cms/news/:id`
229 229
     },
230
-    deleteNews: { // 删除咨
230
+    deleteNews: { // 删除咨
231 231
       method: 'delete',
232 232
       url: `${baseUrl}/common/cms/news/:id`
233
+    },
234
+    caseShow: { // 前台展示
235
+      method: 'put',
236
+      url: `${baseUrl}/common/cms/caseshow/:id`
237
+    },
238
+    caseHide: { // 取消前台展示
239
+      method: 'put',
240
+      url: `${baseUrl}/common/cms/casehide/:id`
233 241
     }
234 242
   },
235 243
   file: {