Browse Source

1、项目初始化

lqkj@you07.com 1 year ago
parent
commit
858834f0f9

+ 23 - 0
package-lock.json

@@ -2371,6 +2371,29 @@
2371 2371
       "resolved": "https://registry.npmmirror.com/@wangeditor/list-module/-/list-module-1.0.5.tgz",
2372 2372
       "integrity": "sha512-uDuYTP6DVhcYf7mF1pTlmNn5jOb4QtcVhYwSSAkyg09zqxI1qBqsfUnveeDeDqIuptSJhkh81cyxi+MF8sEPOQ=="
2373 2373
     },
2374
+    "@wangeditor/plugin-upload-attachment": {
2375
+      "version": "1.1.0",
2376
+      "resolved": "https://registry.npmmirror.com/@wangeditor/plugin-upload-attachment/-/plugin-upload-attachment-1.1.0.tgz",
2377
+      "integrity": "sha512-K6SsV3Cv1g+Ob1xjRRQ13Sh3lcj3yAa/aXMaKKbaPI76rNZiOpyAGH/iVv5i9enmwbZql01IXpvhK+HtrikVyQ==",
2378
+      "requires": {
2379
+        "dom7": "^4.0.4"
2380
+      },
2381
+      "dependencies": {
2382
+        "dom7": {
2383
+          "version": "4.0.6",
2384
+          "resolved": "https://registry.npmmirror.com/dom7/-/dom7-4.0.6.tgz",
2385
+          "integrity": "sha512-emjdpPLhpNubapLFdjNL9tP06Sr+GZkrIHEXLWvOGsytACUrkbeIdjO5g77m00BrHTznnlcNqgmn7pCN192TBA==",
2386
+          "requires": {
2387
+            "ssr-window": "^4.0.0"
2388
+          }
2389
+        },
2390
+        "ssr-window": {
2391
+          "version": "4.0.2",
2392
+          "resolved": "https://registry.npmmirror.com/ssr-window/-/ssr-window-4.0.2.tgz",
2393
+          "integrity": "sha512-ISv/Ch+ig7SOtw7G2+qkwfVASzazUnvlDTwypdLoPoySv+6MqlOV10VwPSE6EWkGjhW50lUmghPmpYZXMu/+AQ=="
2394
+        }
2395
+      }
2396
+    },
2374 2397
     "@wangeditor/table-module": {
2375 2398
       "version": "1.1.4",
2376 2399
       "resolved": "https://registry.npmmirror.com/@wangeditor/table-module/-/table-module-1.1.4.tgz",

+ 1 - 0
package.json

@@ -39,6 +39,7 @@
39 39
     "@riophae/vue-treeselect": "0.4.0",
40 40
     "@wangeditor/editor": "^5.1.23",
41 41
     "@wangeditor/editor-for-vue": "^1.0.2",
42
+    "@wangeditor/plugin-upload-attachment": "^1.1.0",
42 43
     "axios": "0.21.0",
43 44
     "clipboard": "2.0.6",
44 45
     "core-js": "^3.21.1",

+ 8 - 1
src/api/business/cmsNews.js

@@ -71,7 +71,14 @@ export function updateTopStatus(data) {
71 71
     data: data
72 72
   })
73 73
 }
74
-
74
+//修改轮播状态
75
+export function updateCarouselStatus(data) {
76
+  return request({
77
+    url: '/business/cmsNews/updateCarouselStatus',
78
+    method: 'put',
79
+    data: data
80
+  })
81
+}
75 82
 // 删除信息管理
76 83
 export function delCmsNews(newsId) {
77 84
   return request({

+ 39 - 1
src/components/WangEditor/index.vue

@@ -21,15 +21,27 @@
21 21
 </template>
22 22
 <script>
23 23
 import { getToken } from "@/utils/auth";
24
+
24 25
 import { Editor, Toolbar } from '@wangeditor/editor-for-vue'
26
+
25 27
 export default {
26 28
   components: { Editor, Toolbar },
27 29
   data() {
28 30
     return {
29 31
       editor: null,
30 32
       currentValue: '',
31
-      toolbarConfig: { },
33
+      toolbarConfig: {
34
+        insertKeys:{
35
+          index: 0,
36
+          keys:['uploadAttachment']
37
+        }
38
+      },
32 39
       editorConfig: {
40
+        hoverbarKeys: {
41
+          attachment: {
42
+            menuKeys: ['downloadAttachment'], // “下载附件”菜单
43
+          },
44
+        },
33 45
         placeholder: '请输入内容...',
34 46
         MENU_CONF:
35 47
           {
@@ -84,6 +96,32 @@ export default {
84 96
               customInsert(res, insertFn) {
85 97
                 insertFn(BASE_URL + res.url, res.fileName)
86 98
               },
99
+            },
100
+            uploadAttachment:{
101
+              server: BASE_URL + "/v1/common/upload",
102
+              fieldName: 'file',
103
+              maxFileSize: this.fileSize * 1024 * 1024,
104
+              headers:{
105
+                Authorization: "Bearer " + getToken()
106
+              },
107
+              onBeforeUpload(file){
108
+                return file
109
+              },
110
+              onProgress(progress){
111
+                console.log('progress', progress)
112
+              },
113
+              onSuccess(file, res) {
114
+                console.log(file.name + "上传成功")
115
+              },
116
+              onFailed(file, res) {
117
+                console.log(file.name + "上传失败")
118
+              },
119
+              onError(file, err, res){
120
+                console.log(file.name + "上传失败")
121
+              },
122
+              customInsert(res, file, insertFn) {
123
+                insertFn(res.fileName, BASE_URL + res.url)
124
+              },
87 125
             }
88 126
           }
89 127
 

+ 3 - 1
src/main.js

@@ -4,7 +4,9 @@ import Cookies from 'js-cookie'
4 4
 
5 5
 import Element from 'element-ui'
6 6
 import './assets/styles/element-variables.scss'
7
-
7
+import attachmentModule from '@wangeditor/plugin-upload-attachment'
8
+import {Boot} from '@wangeditor/editor'
9
+Boot.registerModule(attachmentModule)
8 10
 import '@/assets/styles/index.scss' // global css
9 11
 import '@/assets/styles/common.scss' // common css
10 12
 import App from './App'

+ 36 - 6
src/views/business/cmsNews/index.vue

@@ -89,7 +89,7 @@
89 89
           </el-table-column>
90 90
           <el-table-column label="所属分类" align="center" prop="cmsCategory.name" width="200"/>
91 91
           <el-table-column label="浏览量" align="center" prop="viewCount" width="140"/>
92
-          <el-table-column label="是否置顶" align="center" prop="isTop" width="140">
92
+          <el-table-column label="置顶" align="center" prop="isTop" width="140">
93 93
             <template slot-scope="scope">
94 94
               <el-switch
95 95
                 v-model="scope.row.isTop"
@@ -97,6 +97,14 @@
97 97
               ></el-switch>
98 98
             </template>
99 99
           </el-table-column>
100
+          <el-table-column label="轮播" align="center" prop="carousel" width="140">
101
+            <template slot-scope="scope">
102
+              <el-switch
103
+                v-model="scope.row.carousel"
104
+                @change="handleCarouselStatusChange(scope.row)"
105
+              ></el-switch>
106
+            </template>
107
+          </el-table-column>
100 108
           <el-table-column label="创建人" align="center" prop="createBy" width="150"/>
101 109
           <el-table-column label="创建时间" align="center" prop="createTime" width="150">
102 110
             <template slot-scope="scope">
@@ -142,7 +150,7 @@
142 150
 
143 151
 
144 152
     <!-- 添加或修改信息管理对话框 -->
145
-    <el-dialog :title="title" :visible.sync="open" width="800px" style="height: 600px; margin-top: 100px" append-to-body>
153
+    <el-dialog :title="title" :visible.sync="open" width="800px" style="height: 600px; margin-top: 100px" append-to-body append-to-body :close-on-click-modal="false">
146 154
       <el-form ref="form" :model="form" :rules="rules" label-width="120px">
147 155
         <el-form-item label="所属分类" prop="categoryId">
148 156
           <el-select v-model="form.categoryId" placeholder="请选择">
@@ -172,6 +180,9 @@
172 180
         <el-form-item label="是否置顶">
173 181
             <el-switch v-model="form.isTop"></el-switch>
174 182
         </el-form-item>
183
+        <el-form-item label="是否轮播">
184
+          <el-switch v-model="form.carousel"></el-switch>
185
+        </el-form-item>
175 186
         <el-form-item label="缩略图">
176 187
           <image-upload :limit="1" :file-size="10" :file-type="['.png', '.jpg', '.jpeg', '.gif']"  v-model="form.thumbnail"></image-upload>
177 188
         </el-form-item>
@@ -188,7 +199,7 @@
188 199
       </div>
189 200
     </el-dialog>
190 201
     <!-- 知识库详情 -->
191
-    <el-dialog title="预览详情" :visible.sync="viewOpen"  width="1000px" append-to-body>
202
+    <el-dialog title="预览详情" :visible.sync="viewOpen"  width="1000px" append-to-body :close-on-click-modal="false">
192 203
       <el-row>
193 204
         <el-col :span="24" align="center">
194 205
           <h2>{{ cmsNewsInfo.title }}</h2>
@@ -221,7 +232,7 @@
221 232
 </template>
222 233
 
223 234
 <script>
224
-import { listCmsNews, getCmsNews, delCmsNews, addCmsNews, updateCmsNews, exportCmsNews, updateTopStatus ,getCmsNewsByCategoryId, frontView} from "@/api/business/cmsNews";
235
+import { listCmsNews, getCmsNews, delCmsNews, addCmsNews, updateCmsNews, exportCmsNews, updateTopStatus ,getCmsNewsByCategoryId, frontView, updateCarouselStatus} from "@/api/business/cmsNews";
225 236
 import { treeselect } from "@/api/business/cmsCategory";
226 237
 import Treeselect from "@riophae/vue-treeselect";
227 238
 import "@riophae/vue-treeselect/dist/vue-treeselect.css";
@@ -305,6 +316,9 @@ export default {
305 316
         isTop: [
306 317
           { required: true, message: "是否置顶不能为空", trigger: "blur" }
307 318
         ],
319
+        carousel: [
320
+          { required: true, message: "是否轮播不能为空", trigger: "blur" }
321
+        ],
308 322
       }
309 323
     };
310 324
   },
@@ -392,6 +406,7 @@ export default {
392 406
         content: null,
393 407
         viewCount: null,
394 408
         isTop: false,
409
+        carousel: false,
395 410
         thumbnail: null,
396 411
         focusImgs:[],
397 412
         focusImgsStr: '',
@@ -426,6 +441,21 @@ export default {
426 441
       this.open = true;
427 442
       this.title = "添加信息";
428 443
     },
444
+    /** 修改轮播状态*/
445
+    handleCarouselStatusChange(row){
446
+      let text = row.carousel ? "轮播" : "取消轮播";
447
+      this.$modal.confirm('确认要' + text + '吗?').then(function() {
448
+        return updateCarouselStatus({
449
+          'newsId': row.newsId,
450
+          'carousel': row.carousel
451
+        });
452
+      }).then(() => {
453
+        this.$modal.msgSuccess(text + "成功");
454
+      }).catch(function() {
455
+        row.carousel = row.carousel ? false : true;
456
+      });
457
+    },
458
+    /**修改置顶状态**/
429 459
     handleStatusChange(row){
430 460
       let text = row.isTop ? "置顶" : "取消置顶";
431 461
       this.$modal.confirm('确认要' + text + '吗?').then(function() {
@@ -500,7 +530,7 @@ export default {
500 530
     /** 删除按钮操作 */
501 531
     handleDelete(row) {
502 532
       const newsIds = row.newsId || this.ids;
503
-      this.$modal.confirm('是否确认删除信息管理编号为"' + newsIds + '"的数据项?').then(function() {
533
+      this.$modal.confirm('是否确认删除?').then(function() {
504 534
         return delCmsNews(newsIds);
505 535
       }).then(() => {
506 536
         this.getList();
@@ -510,7 +540,7 @@ export default {
510 540
     /** 导出按钮操作 */
511 541
     handleExport() {
512 542
       const queryParams = this.queryParams;
513
-      this.$modal.confirm('是否确认导出所有信息管理数据项?').then(() => {
543
+      this.$modal.confirm('是否确认导出所有数据项?').then(() => {
514 544
         this.exportLoading = true;
515 545
         return exportCmsNews(queryParams);
516 546
       }).then(response => {