Просмотр исходного кода

Merge commit '322d08aa4d06633a77f0e23f7ce3952fdc266951' into gzb

gzb
guozhongbo 1 год назад
Родитель
Сommit
dfca69c2e4

+ 2
- 2
public/config.js Просмотреть файл

@@ -6,7 +6,7 @@ window._config = window.isTest
6 6
       showImageUrl: "//xhwebstatictest.xhkjedu.com/",
7 7
       axiosApiTimeout: 20, // 接口超时时间 单位秒
8 8
       axiosFileTimeout: 30, // 上传文件超时时间 单位秒
9
-      versionname: "测试 v3.8.6",
9
+      versionname: "测试 v1.0.0",
10 10
     }
11 11
   : {
12 12
       // 正式环境
@@ -14,5 +14,5 @@ window._config = window.isTest
14 14
       showImageUrl: "//xhwebstatic.xhkjedu.com/",
15 15
       axiosApiTimeout: 20, // 接口超时时间 单位秒
16 16
       axiosFileTimeout: 30, // 上传文件超时时间 单位秒
17
-      versionname: "测试 v3.8.6",
17
+      versionname: "测试 v1.0.0",
18 18
     };

+ 0
- 167
src/components/MyDatePicker/index.vue Просмотреть файл

@@ -1,167 +0,0 @@
1
-<template>
2
-  <div>
3
-    <DatePicker
4
-      type="date"
5
-      :value="currentDate"
6
-      :options="timeOptions"
7
-      @on-change="timeChange"
8
-      :editable="false"
9
-      :clearable="Boolean(clearable)"
10
-      :placeholder="placeholder"
11
-    ></DatePicker>
12
-  </div>
13
-</template>
14
-
15
-<script>
16
-export default {
17
-  /* 
18
-  range 时间范围
19
-  current 传入时间
20
-  placeholder 占位符
21
-  history 时间范围是否为历史时间 默认false
22
-  clearable 清除
23
-  */
24
-  props: ["range", "current", "placeholder", "history", "clearable"],
25
-  data() {
26
-    return {
27
-      timeOptions: {},
28
-      currentDate: null
29
-    };
30
-  },
31
-  watch: {
32
-    range: {
33
-      handler(rangeArr) {
34
-        // rangeArr[开始日期, 结束日期]
35
-        if (rangeArr.length === 1) {
36
-          if (this.history) {
37
-            let [endDate] = rangeArr;
38
-            if (endDate) {
39
-              if (endDate instanceof String) {
40
-                endDate = this.setStringToDate(endDate);
41
-              } else {
42
-                endDate = new Date(endDate);
43
-              }
44
-              endDate.setHours(0);
45
-              endDate.setMinutes(0);
46
-              endDate.setSeconds(0);
47
-              endDate.setMilliseconds(0);
48
-            }
49
-            this.timeOptions = {
50
-              disabledDate: (date) => {
51
-                return date && endDate && date.valueOf() > endDate.getTime();
52
-              }
53
-            };
54
-          } else {
55
-            let [startDate] = rangeArr;
56
-            if (startDate) {
57
-              if (startDate instanceof String) {
58
-                startDate = this.setStringToDate(startDate);
59
-              } else {
60
-                startDate = new Date(startDate);
61
-              }
62
-              startDate.setHours(0);
63
-              startDate.setMinutes(0);
64
-              startDate.setSeconds(0);
65
-              startDate.setMilliseconds(0);
66
-            }
67
-            this.timeOptions = {
68
-              disabledDate: (date) => {
69
-                return (
70
-                  date && startDate && date.valueOf() < startDate.getTime()
71
-                );
72
-              }
73
-            };
74
-          }
75
-        } else if (rangeArr.length === 2) {
76
-          let [startDate, endDate] = rangeArr;
77
-          if (startDate) {
78
-            if (startDate instanceof String) {
79
-              startDate = this.setStringToDate(startDate);
80
-            } else {
81
-              startDate = new Date(startDate);
82
-            }
83
-            startDate.setHours(0);
84
-            startDate.setMinutes(0);
85
-            startDate.setSeconds(0);
86
-            startDate.setMilliseconds(0);
87
-          }
88
-          if (endDate) {
89
-            if (endDate instanceof String) {
90
-              endDate = this.setStringToDate(endDate);
91
-            } else {
92
-              endDate = new Date(endDate);
93
-            }
94
-            endDate.setHours(0);
95
-            endDate.setMinutes(0);
96
-            endDate.setSeconds(0);
97
-            endDate.setMilliseconds(0);
98
-          }
99
-          this.timeOptions = {
100
-            disabledDate: (date) => {
101
-              if (date) {
102
-                if (startDate && !endDate) {
103
-                  return date.valueOf() < startDate.getTime();
104
-                } else if (!startDate && endDate) {
105
-                  return date.valueOf() > endDate.getTime();
106
-                } else if (startDate && endDate) {
107
-                  return (
108
-                    date.valueOf() < startDate.getTime() ||
109
-                    date.valueOf() > endDate.getTime()
110
-                  );
111
-                }
112
-              }
113
-              return false;
114
-            }
115
-          };
116
-        } else {
117
-          this.timeOptions = {};
118
-        }
119
-      },
120
-      deep: true,
121
-      immediate: true
122
-    },
123
-    current: {
124
-      handler(date, oldDate) {
125
-        let currentDate = null;
126
-        if (date) {
127
-          if (date !== oldDate) {
128
-            if (date instanceof Date) {
129
-              currentDate = date;
130
-            } else if (date instanceof String) {
131
-              currentDate = this.setStringToDate(date);
132
-            }
133
-          }
134
-        }
135
-        this.$nextTick(() => {
136
-          this.currentDate = currentDate;
137
-        });
138
-      },
139
-      deep: true,
140
-      immediate: true
141
-    }
142
-  },
143
-  methods: {
144
-    setStringToDate(timeStr) {
145
-      // IE不能识别字符串日期
146
-      let splitArray = timeStr.split(" ");
147
-      let dateArray = splitArray[0].split("-");
148
-      let d = new Date();
149
-      d.setFullYear(dateArray[0], dateArray[1] - 1, dateArray[2]);
150
-      d.setHours(0);
151
-      d.setMinutes(0);
152
-      d.setSeconds(0);
153
-      d.setMilliseconds(0);
154
-      return d;
155
-    },
156
-    timeChange(date) {
157
-      if (date) {
158
-        this.$emit("change", new Date(date));
159
-      } else {
160
-        this.$emit("change", null);
161
-      }
162
-    }
163
-  }
164
-};
165
-</script>
166
-
167
-<style scoped></style>

+ 2
- 90
src/utils/fileConfig.js Просмотреть файл

@@ -1,90 +1,2 @@
1
-//文件上传格式
2
-export const ACCEPT_CONFIG = {
3
-  image: [".png", ".jpg", ".jpeg"], // ".gif", ".bmp"
4
-  client: [".exe"],
5
-  app: [".apk"],
6
-  audio: [".mp3", ".wav"],
7
-  video: [".mp4", ".flv"],
8
-  document: [".doc", ".docx", ".ppt", ".pptx", ".pdf"],
9
-  // ".class", ".dsc",
10
-  documentClass: [".doc", ".docx", ".ppt", ".pptx", ".pdf"],
11
-  zipFile: [".zip", ".rar"],
12
-  getPreview() {
13
-    return [...this.document, ...this.image, ...this.audio, ...this.video];
14
-  },
15
-  getAll() {
16
-    return [
17
-      ...this.image,
18
-      ...this.video,
19
-      ...this.document,
20
-      ...this.audio,
21
-      ...this.documentClass,
22
-      ...this.zipFile
23
-    ];
24
-  },
25
-  getClient() {
26
-    return [...this.client];
27
-  },
28
-  getApp() {
29
-    return [...this.app];
30
-  },
31
-  getImg() {
32
-    return [...this.image];
33
-  },
34
-  getAudio() {
35
-    return [...this.audio];
36
-  },
37
-  getVideo() {
38
-    return [...this.video];
39
-  },
40
-  getDocument() {
41
-    return [...this.document];
42
-  },
43
-  getDocumentClass() {
44
-    return [...this.documentClass];
45
-  },
46
-  getZipFile() {
47
-    return [...this.zipFile];
48
-  }
49
-};
50
-//定义分片大小
51
-export const CHUNK_SIZE = {
52
-  chunkSize: 5 * 1024 * 1024,
53
-  getSize() {
54
-    return this.chunkSize;
55
-  }
56
-};
57
-export const CONFIG_SUFFIX = {
58
-  image: ["png", "jpg", "jpeg"], // "gif", "bmp"
59
-  audio: ["mp3", "wav"],
60
-  video: ["mp4", "flv"],
61
-  document: ["doc", "docx", "ppt", "pptx", "pdf"],
62
-  documentClass: ["class", "dsc", "doc", "docx", "ppt", "pptx", "pdf"],
63
-  zipFile: ["zip", "rar"],
64
-
65
-  getImg() {
66
-    return [...this.image];
67
-  },
68
-  getAudio() {
69
-    return [...this.audio];
70
-  },
71
-  getVideo() {
72
-    return [...this.video];
73
-  },
74
-  getDocument() {
75
-    return [...this.document];
76
-  },
77
-  getDocumentClass() {
78
-    return [...this.documentClass];
79
-  },
80
-  getZipFile() {
81
-    return [...this.zipFile];
82
-  }
83
-};
84
-//教材上传封面格式
85
-export const MATERIAL_IMG_SUFFIX = {
86
-  image: ["png", "jpg", "jpeg"],
87
-  getImg() {
88
-    return [...this.image];
89
-  }
90
-};
1
+//图片上传格式
2
+export const pictureFormat = ["jpg", "jpeg", "png", "bmp", "jfif", "webp"];

+ 1
- 1
src/views/history/index.vue Просмотреть файл

@@ -269,7 +269,7 @@ export default {
269 269
         content: "您确定删除选中数据吗?",
270 270
         onOk: () => {
271 271
           dh_remove({ dhid }).then((res) => {
272
-            if (res.code == 0) {
272
+            if (res.code === 0) {
273 273
               this.$Message.success(res.msg);
274 274
               this.searchList();
275 275
             }

+ 105
- 4
src/views/news/index.vue Просмотреть файл

@@ -77,7 +77,24 @@
77 77
             <Radio :label="2">英文</Radio>
78 78
           </RadioGroup>
79 79
         </FormItem>
80
-        <FormItem label="封面" prop="newspic"></FormItem>
80
+        <FormItem label="封面" prop="newspic">
81
+          <Upload
82
+            :format="pictureFormat"
83
+            :max-size="10 * 1024"
84
+            action
85
+            :before-upload="
86
+              (file) => {
87
+                beforeUploadPicture(file, addForm);
88
+                return false;
89
+              }
90
+            "
91
+            :accept="getPictureAccept()"
92
+            :show-upload-list="false"
93
+          >
94
+            <img v-if="addForm.newspic" :src="$api.showImageUrl" />
95
+            <Button v-else icon="ios-cloud-upload-outline">上传封面</Button>
96
+          </Upload>
97
+        </FormItem>
81 98
         <FormItem label="置顶" prop="newsup">
82 99
           <RadioGroup v-model="addForm.newsup">
83 100
             <Radio :label="1">置顶</Radio>
@@ -116,12 +133,15 @@
116 133
 </template>
117 134
 
118 135
 <script>
119
-import { n_list, n_save, n_update, n_remove, n_detail } from "@/api";
136
+import axios from "axios";
137
+import { n_list, n_save, n_update, n_remove } from "@/api";
120 138
 import { dateFormat } from "@/utils";
139
+import { pictureFormat } from "@/utils/fileConfig";
121 140
 export default {
122 141
   data() {
123 142
     return {
124 143
       dateFormat,
144
+      pictureFormat,
125 145
       newsSearch: {
126 146
         ltype: 1,
127 147
         newstitle: "",
@@ -259,6 +279,16 @@ export default {
259 279
         newsup: 2,
260 280
         newsorder: 1,
261 281
         newscontent: ""
282
+      },
283
+      detailInfo: {
284
+        show: false,
285
+        ltype: 1,
286
+        newspic: "",
287
+        newstitle: "",
288
+        newssummary: "",
289
+        newsup: 2,
290
+        newsorder: 1,
291
+        newscontent: ""
262 292
       }
263 293
     };
264 294
   },
@@ -267,6 +297,30 @@ export default {
267 297
     this.getNewsList();
268 298
   },
269 299
   methods: {
300
+    beforeUploadPicture(file, formObj) {
301
+      let formData = new FormData();
302
+      formData.append("files", file);
303
+      formData.append("savefolder", "news");
304
+      axios
305
+        .post(this.$api.baseUrl + "file/upload", formData, {
306
+          timeout: 1000 * window._config.axiosFileTimeout
307
+        })
308
+        .then((res) => {
309
+          if (res.data.code === 0) {
310
+            formObj.newspic = res.data.obj;
311
+          } else {
312
+            this.$Message.error(res.data.msg);
313
+          }
314
+        })
315
+        .catch(() => {});
316
+    },
317
+    getPictureAccept() {
318
+      return this.pictureFormat
319
+        .map((v) => {
320
+          return `.${v}`;
321
+        })
322
+        .join(",");
323
+    },
270 324
     searchList() {
271 325
       this.newsSearch.page = 1;
272 326
       this.getNewsList();
@@ -306,7 +360,25 @@ export default {
306 360
         newscontent: ""
307 361
       };
308 362
     },
309
-    toSaveAdd() {},
363
+    toSaveAdd() {
364
+      n_save({
365
+        newstitle: this.addForm.newstitle,
366
+        newscontent: this.addForm.newscontent,
367
+        newssummary: this.addForm.newssummary,
368
+        newspic: this.addForm.newspic,
369
+        ltype: this.addForm.ltype,
370
+        newsorder: this.addForm.newsorder,
371
+        newsup: this.addForm.newsup,
372
+        createid: this.userInfo.userid
373
+      }).then((res) => {
374
+        if (res.code === 0) {
375
+          this.$Message.success(res.msg);
376
+          this.searchList();
377
+        } else {
378
+          this.$Message.error(res.msg);
379
+        }
380
+      });
381
+    },
310 382
     toModify(row) {
311 383
       this.modifyForm = {
312 384
         show: true,
@@ -319,7 +391,24 @@ export default {
319 391
         newscontent: row.newscontent
320 392
       };
321 393
     },
322
-    toSaveModify() {},
394
+    toSaveModify() {
395
+      n_update({
396
+        newstitle: this.modifyForm.newstitle,
397
+        newscontent: this.modifyForm.newscontent,
398
+        newssummary: this.modifyForm.newssummary,
399
+        newspic: this.modifyForm.newspic,
400
+        newsorder: this.modifyForm.newsorder,
401
+        newsup: this.modifyForm.newsup,
402
+        newsid: this.modifyForm.newsid
403
+      }).then((res) => {
404
+        if (res.code === 0) {
405
+          this.$Message.success(res.msg);
406
+          this.searchList();
407
+        } else {
408
+          this.$Message.error(res.msg);
409
+        }
410
+      });
411
+    },
323 412
     toDel(newsid) {
324 413
       this.$Modal.confirm({
325 414
         title: "提示",
@@ -329,6 +418,8 @@ export default {
329 418
             if (res.code == 0) {
330 419
               this.$Message.success(res.msg);
331 420
               this.searchList();
421
+            } else {
422
+              this.$Message.error(res.msg);
332 423
             }
333 424
           });
334 425
         },
@@ -337,6 +428,16 @@ export default {
337 428
     },
338 429
     toViewDetail(row) {
339 430
       console.log("toViewDetail", row);
431
+      this.detailInfo = {
432
+        show: true,
433
+        ltype: row.ltype,
434
+        newspic: row.newspic,
435
+        newstitle: row.newstitle,
436
+        newssummary: row.newssummary,
437
+        newsup: row.newsup,
438
+        newsorder: row.newsorder,
439
+        newscontent: row.newscontent
440
+      };
340 441
     }
341 442
   }
342 443
 };

+ 1
- 1
src/views/users/index.vue Просмотреть файл

@@ -324,7 +324,7 @@ export default {
324 324
         content: "您确定删除选中数据吗?",
325 325
         onOk: () => {
326 326
           user_del({ userid }).then((res) => {
327
-            if (res.code == 0) {
327
+            if (res.code === 0) {
328 328
               this.$Message.success(res.msg);
329 329
               this.searchList();
330 330
             }

Загрузка…
Отмена
Сохранить