傅行帆 5 years ago
parent
commit
eaaeb447be

+ 7
- 5
foyo-service/src/main/java/com/huiju/foyo/controller/TaCaseController.java View File

20
 import org.springframework.web.bind.annotation.RestController;
20
 import org.springframework.web.bind.annotation.RestController;
21
 
21
 
22
 import java.time.LocalDateTime;
22
 import java.time.LocalDateTime;
23
+import java.util.Arrays;
24
+import java.util.List;
23
 
25
 
24
 /**
26
 /**
25
  * <p>
27
  * <p>
94
 
96
 
95
     /**
97
     /**
96
      * 根据id删除对象
98
      * 根据id删除对象
97
-     * @param id  实体ID
98
      */
99
      */
99
     @ResponseBody
100
     @ResponseBody
100
-    @RequestMapping(value="/taCase/{id}", method= RequestMethod.DELETE)
101
-    public ResponseBean taCaseDelete(@PathVariable Integer id){
101
+    @RequestMapping(value="/admin/case/delete", method= RequestMethod.DELETE)
102
+    public ResponseBean taCaseDelete(@RequestBody String[] ids){
102
         ResponseBean responseBean = new ResponseBean();
103
         ResponseBean responseBean = new ResponseBean();
103
         try {
104
         try {
104
-            if(iTaCaseService.removeById(id)){
105
+            List<String> idList = Arrays.asList(ids);
106
+            if(iTaCaseService.removeByIds(idList)){
105
                 responseBean.addSuccess("success");
107
                 responseBean.addSuccess("success");
106
             }else {
108
             }else {
107
                 responseBean.addError("fail");
109
                 responseBean.addError("fail");
142
      * 根据id查询对象
144
      * 根据id查询对象
143
      * @param id  实体ID
145
      * @param id  实体ID
144
      */
146
      */
145
-    @RequestMapping(value="/taCase/{id}",method= RequestMethod.GET)
147
+    @RequestMapping(value="/admin/case/{id}",method= RequestMethod.GET)
146
     public ResponseBean taCaseGet(@PathVariable Integer id){
148
     public ResponseBean taCaseGet(@PathVariable Integer id){
147
         ResponseBean responseBean = new ResponseBean();
149
         ResponseBean responseBean = new ResponseBean();
148
         try {
150
         try {

+ 5
- 2
foyo-service/src/main/java/com/huiju/foyo/model/TaCase.java View File

96
      * 案例内容
96
      * 案例内容
97
      */
97
      */
98
     private String content;
98
     private String content;
99
-
100
-
99
+    
100
+    /**
101
+     * 发布类型
102
+     */
103
+    private String type;
101
 }
104
 }

+ 17
- 1
vue-element-admin/src/api/case.js View File

42
 export function addCase(data) {
42
 export function addCase(data) {
43
   return request({
43
   return request({
44
     url: '/case/add',
44
     url: '/case/add',
45
-    method: 'post'
45
+    method: 'post',
46
+    data
46
   })
47
   })
47
 }
48
 }
48
 
49
 
69
     data
70
     data
70
   })
71
   })
71
 }
72
 }
73
+
74
+export function deleteCaseBatch(data) {
75
+  return request({
76
+    url: '/case/delete',
77
+    method: 'delete',
78
+    data
79
+  })
80
+}
81
+
82
+export function getCaseDetailById(id) {
83
+  return request({
84
+    url: '/case/' + id,
85
+    method: 'get'
86
+  })
87
+}

+ 19
- 1
vue-element-admin/src/store/modules/case.js View File

1
-import { serviceCaseCover, addCaseCover, getCaseListData, deleteServiceBatch, addCase, getCaseTypeListData, serviceCaseList, addServiceCase, deleteServiceCaseBatch } from '@/api/case'
1
+import { serviceCaseCover, addCaseCover, getCaseListData, deleteServiceBatch, addCase, getCaseTypeListData, serviceCaseList, addServiceCase, deleteServiceCaseBatch, deleteCaseBatch, getCaseDetailById } from '@/api/case'
2
 
2
 
3
 const servicecase = {
3
 const servicecase = {
4
   namespaced: true,
4
   namespaced: true,
84
           reject(error)
84
           reject(error)
85
         })
85
         })
86
       })
86
       })
87
+    },
88
+    deleteCase({ commit, state }, data) { // 删除
89
+      return new Promise((resolve, reject) => {
90
+        deleteCaseBatch(data).then(response => {
91
+          resolve(response)
92
+        }).catch(error => {
93
+          reject(error)
94
+        })
95
+      })
96
+    },
97
+    getCaseDetail({ commit }, id) {
98
+      return new Promise((resolve, reject) => {
99
+        getCaseDetailById(id).then(response => {
100
+          resolve(response)
101
+        }).catch(error => {
102
+          reject(error)
103
+        })
104
+      })
87
     }
105
     }
88
   }
106
   }
89
 }
107
 }

+ 8
- 1
vue-element-admin/src/views/case/add.vue View File

52
           active-value="1"
52
           active-value="1"
53
           inactive-value="0"/>
53
           inactive-value="0"/>
54
       </el-form-item>
54
       </el-form-item>
55
+      <el-form-item :label-width="formLabelWidth" label="发布类型">
56
+        <el-select v-model="form.type" placeholder="请选择发布类型">
57
+          <el-option key="case" value="case" label="案例"/>
58
+          <el-option key="movement" value="movement" label="动态"/>
59
+        </el-select>
60
+      </el-form-item>
55
     </el-form>
61
     </el-form>
56
     <div slot="footer" class="dialog-footer">
62
     <div slot="footer" class="dialog-footer">
57
       <el-button @click="dialogForm('0')">取 消</el-button>
63
       <el-button @click="dialogForm('0')">取 消</el-button>
122
         caseSummary: '',
128
         caseSummary: '',
123
         caseIndustry: '',
129
         caseIndustry: '',
124
         topping: 0,
130
         topping: 0,
125
-        content: ''
131
+        content: '',
132
+        type: 'case'
126
       },
133
       },
127
       uploadImgUrl: process.env.BASE_API + '/uploadimage',
134
       uploadImgUrl: process.env.BASE_API + '/uploadimage',
128
       dialogStatus: '',
135
       dialogStatus: '',

+ 137
- 32
vue-element-admin/src/views/case/edit.vue View File

1
 <template>
1
 <template>
2
   <div id="app" class="app-container">
2
   <div id="app" class="app-container">
3
     <el-form ref="form" :model="form">
3
     <el-form ref="form" :model="form">
4
-      <el-form-item :label-width="formLabelWidth" label="业务名称">
5
-        <el-input v-model="form.serviceName"/>
4
+      <el-form-item :label-width="formLabelWidth" label="案例标题">
5
+        <el-input v-model="form.caseTitle"/>
6
       </el-form-item>
6
       </el-form-item>
7
-      <el-form-item :label-width="formLabelWidth" label="权重">
8
-        <el-input v-model="form.sort"/>
9
-      </el-form-item>
10
-      <el-form-item :label-width="formLabelWidth" label="banner图">
7
+      <el-form-item :label-width="formLabelWidth" label="案例封面图">
11
         <el-upload
8
         <el-upload
12
           :action= "uploadImgUrl"
9
           :action= "uploadImgUrl"
13
           :show-file-list="false"
10
           :show-file-list="false"
18
           <i v-else class="el-icon-plus avatar-uploader-icon"/>
15
           <i v-else class="el-icon-plus avatar-uploader-icon"/>
19
         </el-upload>
16
         </el-upload>
20
       </el-form-item>
17
       </el-form-item>
18
+      <el-form-item :label-width="formLabelWidth" label="案例简介">
19
+        <el-input v-model="form.caseSummary"/>
20
+      </el-form-item>
21
+      <el-form-item :label-width="formLabelWidth" label="案例类型">
22
+        <el-select v-model="form.taCaseTypeId" placeholder="请选择案例类型">
23
+          <el-option v-for="item in caseTypeList" :key="item.id" :value="item.id" :label="item.typeName"/>
24
+        </el-select>
25
+      </el-form-item>
26
+      <el-form-item :label-width="formLabelWidth" label="案例客户方logo">
27
+        <el-upload
28
+          :action= "uploadImgUrl"
29
+          :show-file-list="false"
30
+          :on-success="handleLogoSuccess"
31
+          class="avatar-uploader"
32
+          name="uploadFiles">
33
+          <img v-if="logoUrl" :src="logoUrl" class="avatar">
34
+          <i v-else class="el-icon-plus avatar-uploader-icon"/>
35
+        </el-upload>
36
+      </el-form-item>
37
+      <el-form-item :label-width="formLabelWidth" label="所属行业">
38
+        <el-input v-model="form.caseIndustry"/>
39
+      </el-form-item>
21
       <el-form-item>
40
       <el-form-item>
22
-        <el-tag
23
-          v-for="tag in dynamicTags"
24
-          :key="tag"
25
-          :disable-transitions="false"
26
-          closable
27
-          @close="handleClose(tag)">
28
-          {{ tag }}
29
-        </el-tag>
30
-        <el-input
31
-          v-if="inputVisible"
32
-          ref="saveTagInput"
33
-          v-model="inputValue"
34
-          size="small"
35
-          class="input-new-tag"
36
-          @keyup.enter.native="handleInputConfirm"
37
-          @blur="handleInputConfirm"/>
38
-        <el-button v-else class="button-new-tag" closable @click="showInput">+ 添加标签</el-button>
41
+        <p class="title">案例内容</p>
42
+        <div id="websiteEditorElem" style="height: 400px"/>
43
+      </el-form-item>
44
+      <el-form-item :label-width="formLabelWidth" label="权重">
45
+        <el-input v-model="form.sort"/>
46
+      </el-form-item>
47
+      <el-form-item :label-width="formLabelWidth" label="是否置顶">
48
+        <el-switch
49
+          v-model="form.topping"
50
+          :active-value="1"
51
+          :inactive-value="0"
52
+          active-color="#13ce66"
53
+          inactive-color="#ff4949"/>
54
+      </el-form-item>
55
+      <el-form-item :label-width="formLabelWidth" label="发布类型">
56
+        <el-select v-model="form.type" placeholder="请选择发布类型">
57
+          <el-option key="case" value="case" label="案例"/>
58
+          <el-option key="movement" value="movement" label="动态"/>
59
+        </el-select>
39
       </el-form-item>
60
       </el-form-item>
40
     </el-form>
61
     </el-form>
41
     <div slot="footer" class="dialog-footer">
62
     <div slot="footer" class="dialog-footer">
49
 // import { updateArticle, createBanner } from '@/api/banner' // getBanner
70
 // import { updateArticle, createBanner } from '@/api/banner' // getBanner
50
 import waves from '@/directive/waves' // Waves directive
71
 import waves from '@/directive/waves' // Waves directive
51
 import Pagination from '@/components/Pagination' // Secondary package based on el-pagination
72
 import Pagination from '@/components/Pagination' // Secondary package based on el-pagination
73
+import E from 'wangeditor'
52
 const calendarTypeOptions = [
74
 const calendarTypeOptions = [
53
   { key: 'CN', display_name: 'China' },
75
   { key: 'CN', display_name: 'China' },
54
   { key: 'US', display_name: 'USA' },
76
   { key: 'US', display_name: 'USA' },
84
       total: 0,
106
       total: 0,
85
       listLoading: true,
107
       listLoading: true,
86
       imageUrl: '', // 图片预览
108
       imageUrl: '', // 图片预览
109
+      logoUrl: '', // 图片预览
87
       importanceOptions: [1, 2, 3],
110
       importanceOptions: [1, 2, 3],
88
       calendarTypeOptions,
111
       calendarTypeOptions,
89
       communityQuery: {
112
       communityQuery: {
98
       listQuery: [],
121
       listQuery: [],
99
       form: {
122
       form: {
100
         id: '',
123
         id: '',
101
-        serviceName: '',
124
+        caseTitle: '',
102
         sort: '',
125
         sort: '',
103
-        serviceImageUrl: '',
104
-        labelList: []
126
+        caseCoverImg: '',
127
+        caseLogoImg: '',
128
+        caseSummary: '',
129
+        caseIndustry: '',
130
+        topping: 0,
131
+        content: '',
132
+        type: 'case'
105
       },
133
       },
106
       uploadImgUrl: process.env.BASE_API + '/uploadimage',
134
       uploadImgUrl: process.env.BASE_API + '/uploadimage',
107
       dialogStatus: '',
135
       dialogStatus: '',
109
       formLabelWidth: '120px',
137
       formLabelWidth: '120px',
110
       showContentVisible: false,
138
       showContentVisible: false,
111
       showURLVisible: true,
139
       showURLVisible: true,
140
+      caseTypeList: [],
112
       bannerPositionArr: [
141
       bannerPositionArr: [
113
         { id: 1, value: '首页banner' },
142
         { id: 1, value: '首页banner' },
114
         { id: 2, value: '服务banner' }
143
         { id: 2, value: '服务banner' }
118
       inputValue: ''
147
       inputValue: ''
119
     }
148
     }
120
   },
149
   },
121
-  computed: {
150
+  mounted() {
151
+    const _that = this
152
+    const phoneEditor = new E('#websiteEditorElem')
153
+    phoneEditor.customConfig.zIndex = 1
154
+    phoneEditor.customConfig.onchange = function(html) {
155
+      _that.form.content = html
156
+      console.log('that.dynamic.url', _that.form.content)
157
+    }
158
+    // phoneEditor.customConfig.uploadImgServer = this.upFileUrl
159
+    // phoneEditor.customConfig.uploadFileName = 'uploadFiles'
160
+
161
+    phoneEditor.customConfig.customUploadImg = function(files, insert) {
162
+      _that.uploadImg(files[0]).then(data => {
163
+        insert(data)
164
+      })
165
+    }
166
+    phoneEditor.customConfig.menus = [
167
+      'head', // 标题
168
+      'bold', // 粗体
169
+      'fontSize', // 字号
170
+      'fontName', // 字体
171
+      'italic', // 斜体
172
+      'underline', // 下划线
173
+      'strikeThrough', // 删除线
174
+      'foreColor', // 文字颜色
175
+      'backColor', // 背景颜色
176
+      'justify', // 对齐方式
177
+      'image' // 插入图片
178
+    ]
179
+    phoneEditor.create()
180
+
181
+    this.$store.dispatch('servicecase/getCaseDetail', this.$route.params.id).then((res) => {
182
+      if (res.data.code === '0') {
183
+        console.log(res.data.data)
184
+        this.imageUrl = res.data.data.caseCoverImg
185
+        this.logoUrl = res.data.data.caseLogoImg
186
+        this.form = res.data.data
187
+        phoneEditor.txt.html(res.data.data.content)
188
+      } else {
189
+        this.$message({
190
+          message: res.data.message,
191
+          type: 'warning'
192
+        })
193
+      }
194
+    })
122
   },
195
   },
123
   created() {
196
   created() {
124
-    this.listQuery = this.$route.params.listQuery
197
+    this.getCaseTypeList()
198
+    // this.getCaseDetail(this.$route.params.id)
125
   },
199
   },
126
   updated() {
200
   updated() {
127
   },
201
   },
128
   methods: {
202
   methods: {
129
     handleAvatarSuccess(res, file) { // 上传成功回调
203
     handleAvatarSuccess(res, file) { // 上传成功回调
130
       this.imageUrl = URL.createObjectURL(file.raw)
204
       this.imageUrl = URL.createObjectURL(file.raw)
131
-      this.form.serviceImageUrl = res.data[0]
205
+      this.form.caseCoverImg = res.data[0]
206
+    },
207
+    handleLogoSuccess(res, file) { // 上传成功回调
208
+      this.logoUrl = URL.createObjectURL(file.raw)
209
+      this.form.caseLogoImg = res.data[0]
132
     },
210
     },
133
     dialogAddForm() {
211
     dialogAddForm() {
134
       this.dialogFormVisible = true
212
       this.dialogFormVisible = true
138
     },
216
     },
139
     dialogForm(isVaule) {
217
     dialogForm(isVaule) {
140
       if (isVaule === '0') {
218
       if (isVaule === '0') {
141
-        this.$router.push({ name: 'service-index' })
219
+        this.$router.push({ name: 'case-index' })
142
       } else {
220
       } else {
143
         this.createData()
221
         this.createData()
144
       }
222
       }
156
       this.$refs['form'].validate((valid) => {
234
       this.$refs['form'].validate((valid) => {
157
         if (valid) {
235
         if (valid) {
158
           this.form.labelList = this.dynamicTags
236
           this.form.labelList = this.dynamicTags
159
-          this.$store.dispatch('service/createService', this.form).then((res) => {
237
+          this.$store.dispatch('servicecase/createCase', this.form).then((res) => {
160
             if (res.data.code === '0') {
238
             if (res.data.code === '0') {
161
               this.$message({
239
               this.$message({
162
                 message: res.data.message,
240
                 message: res.data.message,
163
                 type: 'success'
241
                 type: 'success'
164
               })
242
               })
165
-              this.$router.push({ name: 'service-index' })
243
+              this.$router.push({ name: 'case-index' })
166
             } else {
244
             } else {
167
               this.$message({
245
               this.$message({
168
                 message: res.data.message,
246
                 message: res.data.message,
173
         }
251
         }
174
       })
252
       })
175
     },
253
     },
254
+    getCaseDetail(id) {
255
+      this.$store.dispatch('servicecase/getCaseDetail', id).then((res) => {
256
+        if (res.data.code === '0') {
257
+          console.log(res.data.data)
258
+          this.imageUrl = res.data.data.caseCoverImg
259
+          this.logoUrl = res.data.data.caseLogoImg
260
+          this.form = res.data.data
261
+        } else {
262
+          this.$message({
263
+            message: res.data.message,
264
+            type: 'warning'
265
+          })
266
+        }
267
+      })
268
+    },
176
     handleClose(tag) {
269
     handleClose(tag) {
177
       this.dynamicTags.splice(this.dynamicTags.indexOf(tag), 1)
270
       this.dynamicTags.splice(this.dynamicTags.indexOf(tag), 1)
178
     },
271
     },
189
       }
282
       }
190
       this.inputVisible = false
283
       this.inputVisible = false
191
       this.inputValue = ''
284
       this.inputValue = ''
285
+    },
286
+    getCaseTypeList() {
287
+      this.$store.dispatch('servicecase/getCaseTypeList', this.form).then((res) => {
288
+        if (res.data.code === '0') {
289
+          this.caseTypeList = res.data.data
290
+        }
291
+      })
192
     }
292
     }
193
   }
293
   }
194
 }
294
 }
195
 </script>
295
 </script>
196
 
296
 
197
 <style scoped>
297
 <style scoped>
298
+.title{
299
+    font-size: 14px;
300
+    color: #606266;
301
+    font-weight: 600;
302
+}
198
 .app-container {
303
 .app-container {
199
   width: 50%;
304
   width: 50%;
200
   margin: auto;
305
   margin: auto;

+ 9
- 1
vue-element-admin/src/views/case/index.vue View File

59
           <span>{{ formatDate(scope.row.createTime) }}</span>
59
           <span>{{ formatDate(scope.row.createTime) }}</span>
60
         </template>
60
         </template>
61
       </el-table-column>
61
       </el-table-column>
62
+      <el-table-column label="操作" class-name="status-col" align="center">
63
+        <template slot-scope="scope">
64
+          <el-button type="primary" icon="el-icon-edit" @click="updateCase(scope.row.id)">修改</el-button>
65
+        </template>
66
+      </el-table-column>
62
     </el-table>
67
     </el-table>
63
     <div class="block">
68
     <div class="block">
64
       <el-pagination
69
       <el-pagination
144
     addCase() {
149
     addCase() {
145
       this.$router.push({ name: 'case-add' })
150
       this.$router.push({ name: 'case-add' })
146
     },
151
     },
152
+    updateCase(id) {
153
+      this.$router.push({ name: 'case-edit', params: { id }})
154
+    },
147
     handleFilter() {
155
     handleFilter() {
148
       this.listQuery.pageNum = 1
156
       this.listQuery.pageNum = 1
149
       this.getList()
157
       this.getList()
255
         this.$message.error('请至少选择一项')
263
         this.$message.error('请至少选择一项')
256
         return
264
         return
257
       }
265
       }
258
-      this.$store.dispatch('service/deleteService', this.ids).then(res => {
266
+      this.$store.dispatch('servicecase/deleteCase', this.ids).then(res => {
259
         const resCode = res.data.code
267
         const resCode = res.data.code
260
         if (resCode === '0') {
268
         if (resCode === '0') {
261
           this.$message.success('删除成功')
269
           this.$message.success('删除成功')