leisure-core 0.6.82 → 0.6.85

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import LeDrag from "./le-libs/js/drag.js";
2
- import leMixins from "./le-libs/mixins/main.js";
2
+ // import leMixins from "./le-libs/mixins/main.js";
3
3
  import {
4
4
  parseTime,
5
5
  formatMoney,
@@ -11,24 +11,20 @@ import LeButton from "./le-button/index.js";
11
11
  import LeButtonQr from "./le-button-qr/index.js";
12
12
  import LeButtonMsg from "./le-button-msg/index.js";
13
13
  import LeDialogContainer from "./le-dialog-container/index.js";
14
- import LeRole from "./le-role/index.js";
15
- import LeMenu from "./le-menu/index.js";
16
- import LeRoleUser from "./le-role-user/index.js";
17
- import LeUser from "./le-user/index.js";
14
+
18
15
  import LeMedia from "./le-media/index.js";
19
16
  import LeMediaUpload from "./le-media-upload/index.js";
20
17
  import LeMediaList from "./le-media-list/index.js";
21
- import LeRichText from "./le-rich-text/index.js";
18
+
22
19
  import LeButtonUpload from "./le-button-upload/index.js";
23
20
  import LeButtonSelectMedia from "./le-button-select-media/index.js";
24
21
  import LeImage from "./le-image/index.js";
25
22
  import LeImageContainer from "./le-image-container/index.js";
26
- import LeBackUp from "./le-backup/index.js";
23
+
27
24
  import LeUpload from "./le-upload/index.js";
28
- import LeMpurl from "./le-mpurl/index.js";
25
+
29
26
  import { LeHelp, LeHelpDetail } from "./le-help/index.js";
30
- import LeSelectUser from "./le-select-user/index.js";
31
- import LeArea from "./le-area/index.js";
27
+
32
28
  import LeSelect from "./le-select/index.js";
33
29
  import LeSelectSearch from "./le-select-search/index.js";
34
30
  import LeInput from "./le-input/index.js";
@@ -53,31 +49,27 @@ import LeUploadTable from "./le-upload-table/index.js";
53
49
  import LeReport from "./le-report/index.js";
54
50
 
55
51
  const components = [
56
- LeArea,
57
52
  LeButton,
58
53
  LeButtonQr,
59
54
  LeButtonMsg,
60
55
  LeDialogContainer,
61
56
  LeLogin,
62
57
  LeHome,
63
- LeMenu,
64
- LeRole,
65
- LeRoleUser,
66
- LeUser,
58
+
67
59
  LeMedia,
68
60
  LeMediaUpload,
69
61
  LeMediaList,
70
- LeRichText,
62
+
71
63
  LeButtonUpload,
72
64
  LeButtonSelectMedia,
73
65
  LeImageContainer,
74
66
  LeImage,
75
- LeBackUp,
67
+
76
68
  LeUpload,
77
- LeMpurl,
69
+
78
70
  LeHelp,
79
71
  LeHelpDetail,
80
- LeSelectUser,
72
+
81
73
  LeSelect,
82
74
  LeSelectSearch,
83
75
  LeInput,
@@ -170,31 +162,24 @@ if (typeof window !== "undefined" && window.Vue) {
170
162
 
171
163
  export default {
172
164
  install,
173
- LeArea,
174
165
  LeButton,
175
166
  LeButtonQr,
176
167
  LeButtonMsg,
177
168
  LeDialogContainer,
178
169
  LeLogin,
179
170
  LeHome,
180
- LeMenu,
181
- LeRole,
182
- LeRoleUser,
183
- LeUser,
171
+
184
172
  LeMedia,
185
173
  LeMediaUpload,
186
174
  LeMediaList,
187
- LeRichText,
175
+
188
176
  LeButtonUpload,
189
177
  LeButtonSelectMedia,
190
178
  LeImageContainer,
191
179
  LeImage,
192
- LeBackUp,
193
180
  LeUpload,
194
- LeMpurl,
195
181
  LeHelp,
196
182
  LeHelpDetail,
197
- LeSelectUser,
198
183
  LeSelect,
199
184
  LeSelectSearch,
200
185
  LeInput,
@@ -210,7 +195,6 @@ export default {
210
195
  LeSpan,
211
196
  LeInputAdvanced,
212
197
  // LeButtonAudit,
213
- leMixins,
214
198
  LeInputValidate,
215
199
  LeDatePickerAuto,
216
200
  LeTableEdit,
@@ -0,0 +1,82 @@
1
+ <template>
2
+ <div>
3
+ <!-- 有子菜单 → 渲染 el-submenu -->
4
+ <el-submenu v-if="hasChildren" :index="getIndex" :key="menuItem.id">
5
+ <template slot="title">
6
+ <i v-if="menuItem.icon" :class="menuItem.icon"></i>
7
+ <span>{{ menuItem.title }}</span>
8
+ </template>
9
+ <!-- 递归渲染子节点 -->
10
+ <menu-node
11
+ v-for="child in menuItem.children"
12
+ :key="child.id"
13
+ :menu-item="child"
14
+ :parent-index="getIndex"
15
+ @menu-click="handleChildClick"
16
+ />
17
+ </el-submenu>
18
+
19
+ <!-- 叶子菜单 → 渲染 el-menu-item -->
20
+ <el-menu-item
21
+ v-else
22
+ :index="getIndex"
23
+ @click="emitClick"
24
+ :title="shouldShowTooltip ? menuItem.title : ''"
25
+ >
26
+ <span class="menu-item-text">{{ menuItem.title }}</span>
27
+ </el-menu-item>
28
+ </div>
29
+ </template>
30
+
31
+ <script>
32
+ export default {
33
+ name: "MenuNode",
34
+ props: {
35
+ // 当前菜单项数据
36
+ menuItem: {
37
+ type: Object,
38
+ required: true,
39
+ },
40
+ // 父级 index,用于构建唯一层级路径
41
+ parentIndex: {
42
+ type: String,
43
+ default: "",
44
+ },
45
+ },
46
+ computed: {
47
+ // 是否有子菜单(且子菜单未被全部过滤掉)
48
+ hasChildren() {
49
+ return this.menuItem.children && this.menuItem.children.length > 0;
50
+ },
51
+ // 构建唯一 index,使用 id 拼接,避免同名冲突
52
+ getIndex() {
53
+ const base = this.parentIndex ? this.parentIndex + "-" : "";
54
+ return base + this.menuItem.id;
55
+ },
56
+ // 是否显示 tooltip(文字超长)
57
+ shouldShowTooltip() {
58
+ return this.menuItem.title && this.menuItem.title.length > 8;
59
+ },
60
+ },
61
+ methods: {
62
+ // 点击叶子菜单
63
+ emitClick() {
64
+ this.$emit("menu-click", this.menuItem);
65
+ },
66
+ // 子节点触发点击,向上冒泡
67
+ handleChildClick(item) {
68
+ this.$emit("menu-click", item);
69
+ },
70
+ },
71
+ };
72
+ </script>
73
+
74
+ <style scoped>
75
+ .menu-item-text {
76
+ display: inline-block;
77
+ max-width: calc(100% + 25px);
78
+ overflow: hidden;
79
+ text-overflow: ellipsis;
80
+ white-space: nowrap;
81
+ }
82
+ </style>
@@ -161,13 +161,13 @@
161
161
  </template>
162
162
 
163
163
  <script>
164
- import debtReportMixins from "@/mixins/debtReportMixins.js";
164
+ import rMixins from "./rmixins.js";
165
165
  import ExcelJS from "exceljs";
166
166
  import FileSaver from "file-saver";
167
167
 
168
168
  export default {
169
169
  name: "le-report",
170
- mixins: [debtReportMixins],
170
+ mixins: [rMixins],
171
171
  props: {
172
172
  showIndex: {
173
173
  type: Boolean,
@@ -0,0 +1,30 @@
1
+ const rMixins = {
2
+ data() {
3
+ return {
4
+ elTableMaxHeight: 200,
5
+ };
6
+ },
7
+
8
+ mounted() {
9
+ window.addEventListener("resize", this.changeHeight);
10
+ this.changeHeight();
11
+ },
12
+
13
+ destroyed() {
14
+ window.removeEventListener("resize", this.changeHeight);
15
+ },
16
+ methods: {
17
+ changeHeight() {
18
+ this.$nextTick(() => {
19
+ if (!this.$refs.eltablemain) return;
20
+ let dyHeight = this.elTableMaxHeight;
21
+ let all = window.innerHeight;
22
+ let top = this.$refs.eltablemain.$el.getBoundingClientRect().top;
23
+ dyHeight = all - top - 30;
24
+ this.elTableMaxHeight = dyHeight - 50;
25
+ });
26
+ },
27
+ },
28
+ };
29
+
30
+ export default rMixins;
@@ -114,14 +114,14 @@
114
114
  </template>
115
115
 
116
116
  <script>
117
- import {
118
- upload,
119
- create,
120
- del,
121
- list,
122
- download,
123
- } from "@/api/attachment/attachment.js";
124
- import { downLoadSimple } from "@/utils/downLoadFile.js";
117
+ // import {
118
+ // upload,
119
+ // create,
120
+ // del,
121
+ // list,
122
+ // download,
123
+ // } from "@/api/attachment/attachment.js";
124
+ // import { downLoadSimple } from "@/utils/downLoadFile.js";
125
125
 
126
126
  export default {
127
127
  name: "le-upload-table",
@@ -183,6 +183,30 @@ export default {
183
183
  type: Boolean,
184
184
  default: true,
185
185
  },
186
+ uploadApi: {
187
+ type: Function,
188
+ required: true, // 强制父组件提供
189
+ },
190
+ // 批量创建附件记录(接收参数数组,返回 Promise<{ data: { data: [...] } }>)
191
+ createApi: {
192
+ type: Function,
193
+ required: true,
194
+ },
195
+ // 删除附件(接收 { id },返回 Promise)
196
+ deleteApi: {
197
+ type: Function,
198
+ required: true,
199
+ },
200
+ // 查询附件列表(接收 { mid, mtype },返回 Promise<{ data: { data: [...] } }>)
201
+ listApi: {
202
+ type: Function,
203
+ required: true,
204
+ },
205
+ // 下载文件(接收参数,通常为 fileName 等,返回 void 或 Promise)
206
+ downloadApi: {
207
+ type: Function,
208
+ required: true,
209
+ },
186
210
  },
187
211
  watch: {
188
212
  showPop: {
@@ -212,7 +236,7 @@ export default {
212
236
  currentTotalSize() {
213
237
  return this.localAttachments.reduce(
214
238
  (total, file) => total + (file.size || 0),
215
- 0
239
+ 0,
216
240
  );
217
241
  },
218
242
  // currentTotalSize() {
@@ -224,24 +248,36 @@ export default {
224
248
  },
225
249
  mounted() {},
226
250
  methods: {
251
+ // getList(callback) {
252
+ // let param = {};
253
+ // param.mid = this.mid;
254
+ // param.mtype = this.mtype;
255
+ // const formData = new URLSearchParams(param);
256
+ // list(formData).then((res) => {
257
+ // this.localAttachments = res.data.data;
258
+ // if (callback) {
259
+ // callback();
260
+ // }
261
+ // });
262
+ // },
227
263
  getList(callback) {
228
- let param = {};
229
- param.mid = this.mid;
230
- param.mtype = this.mtype;
264
+ const param = { mid: this.mid, mtype: this.mtype };
231
265
  const formData = new URLSearchParams(param);
232
- list(formData).then((res) => {
233
- this.localAttachments = res.data.data;
234
- if (callback) {
235
- callback();
236
- }
237
- });
266
+ this.listApi(formData)
267
+ .then((res) => {
268
+ this.localAttachments = res.data.data || [];
269
+ if (callback) callback();
270
+ })
271
+ .catch(() => {
272
+ this.$message.error("获取附件列表失败");
273
+ });
238
274
  },
239
275
  // 上传前校验
240
276
  beforeUpload(file) {
241
277
  // 检查文件大小
242
278
  if (file.size / 1024 / 1024 > this.maxSize) {
243
279
  this.$message.error(
244
- `文件 "${file.name}" 大小不能超过 ${this.maxSize}MB`
280
+ `文件 "${file.name}" 大小不能超过 ${this.maxSize}MB`,
245
281
  );
246
282
  return false;
247
283
  }
@@ -263,58 +299,98 @@ export default {
263
299
  },
264
300
 
265
301
  // 上传文件
302
+ // async uploadFile(param) {
303
+ // if (this.uploading) {
304
+ // this.$message.warning("正在上传中,请稍候...");
305
+ // return;
306
+ // }
307
+
308
+ // this.uploading = true;
309
+
310
+ // try {
311
+ // const formData = new FormData();
312
+ // formData.append("files", param.file);
313
+
314
+ // if (this.dir) {
315
+ // formData.append("dir", this.dir);
316
+ // }
317
+
318
+ // const res = await upload(formData);
319
+
320
+ // if (res.data && res.data.data) {
321
+ // const urlList = res.data.data;
322
+
323
+ // if (urlList && urlList.length > 0) {
324
+ // let newFiles = [];
325
+ // urlList.forEach((ele) => {
326
+ // const newFile = {
327
+ // id: Date.now(),
328
+ // mid: this.mid,
329
+ // mtype: this.mtype,
330
+ // mtype_name: this.mname,
331
+ // attach_name_ori: ele.filesOriginal,
332
+ // attach_name: ele.filesNew,
333
+ // attach_size: ele.fileSize,
334
+ // attach_path: ele.filesUrlPath,
335
+ // create_at: new Date(),
336
+ // };
337
+ // newFiles.push(newFile);
338
+ // });
339
+
340
+ // this._saveData(newFiles, (res) => {
341
+ // const uploadFiles = res.data.data;
342
+ // const localData = [...this.localAttachments, ...uploadFiles];
343
+ // this.localAttachments = localData;
344
+ // this.$message.success(`文件上传成功`);
345
+ // });
346
+ // } else {
347
+ // this.$message.error("上传成功但未返回文件URL");
348
+ // }
349
+ // } else {
350
+ // this.$message.error(res.data?.msg || "上传失败");
351
+ // }
352
+ // } catch (error) {
353
+ // this.$message.error(`文件上传失败`);
354
+ // } finally {
355
+ // this.uploading = false;
356
+ // }
357
+ // },
358
+
266
359
  async uploadFile(param) {
267
360
  if (this.uploading) {
268
361
  this.$message.warning("正在上传中,请稍候...");
269
362
  return;
270
363
  }
271
-
272
364
  this.uploading = true;
273
-
274
365
  try {
275
366
  const formData = new FormData();
276
367
  formData.append("files", param.file);
368
+ if (this.dir) formData.append("dir", this.dir);
277
369
 
278
- if (this.dir) {
279
- formData.append("dir", this.dir);
280
- }
281
-
282
- const res = await upload(formData);
283
-
284
- if (res.data && res.data.data) {
285
- const urlList = res.data.data;
286
-
287
- if (urlList && urlList.length > 0) {
288
- let newFiles = [];
289
- urlList.forEach((ele) => {
290
- const newFile = {
291
- id: Date.now(),
292
- mid: this.mid,
293
- mtype: this.mtype,
294
- mtype_name: this.mname,
295
- attach_name_ori: ele.filesOriginal,
296
- attach_name: ele.filesNew,
297
- attach_size: ele.fileSize,
298
- attach_path: ele.filesUrlPath,
299
- create_at: new Date(),
300
- };
301
- newFiles.push(newFile);
302
- });
303
-
304
- this._saveData(newFiles, (res) => {
305
- const uploadFiles = res.data.data;
306
- const localData = [...this.localAttachments, ...uploadFiles];
307
- this.localAttachments = localData;
308
- this.$message.success(`文件上传成功`);
309
- });
310
- } else {
311
- this.$message.error("上传成功但未返回文件URL");
312
- }
313
- } else {
314
- this.$message.error(res.data?.msg || "上传失败");
370
+ const res = await this.uploadApi(formData);
371
+ const urlList = res?.data?.data;
372
+ if (!urlList || urlList.length === 0) {
373
+ this.$message.error("上传成功但未返回文件URL");
374
+ return;
315
375
  }
376
+ const newFiles = urlList.map((ele) => ({
377
+ id: Date.now(),
378
+ mid: this.mid,
379
+ mtype: this.mtype,
380
+ mtype_name: this.mname,
381
+ attach_name_ori: ele.filesOriginal,
382
+ attach_name: ele.filesNew,
383
+ attach_size: ele.fileSize,
384
+ attach_path: ele.filesUrlPath,
385
+ create_at: new Date(),
386
+ }));
387
+ // 调用创建 API
388
+ await this._createRecords(newFiles);
389
+ // 刷新列表
390
+ await this.getList();
391
+ this.$message.success("文件上传成功");
316
392
  } catch (error) {
317
- this.$message.error(`文件上传失败`);
393
+ this.$message.error(error.message || "文件上传失败");
318
394
  } finally {
319
395
  this.uploading = false;
320
396
  }
@@ -331,7 +407,7 @@ export default {
331
407
  // 直接更新本地数据
332
408
  let param = { id: file.id };
333
409
  const formData = new URLSearchParams(param);
334
- del(formData).then(() => {
410
+ this.deleteApi(formData).then(() => {
335
411
  const updatedAttachments = [...this.localAttachments];
336
412
  updatedAttachments.splice(index, 1);
337
413
  this.localAttachments = updatedAttachments;
@@ -370,12 +446,15 @@ export default {
370
446
  handleDownLoad(row) {
371
447
  let params = {};
372
448
  params.fileName = row.attach_name;
373
- downLoadSimple(
374
- "/system-attachment/download",
375
- row.attach_name_ori,
376
- params
377
- ).catch((error) => {
378
- this.$message.error(error);
449
+ // downLoadSimple(
450
+ // "/system-attachment/download",
451
+ // row.attach_name_ori,
452
+ // params,
453
+ // ).catch((error) => {
454
+ // this.$message.error(error);
455
+ // });
456
+ this.downloadApi(row.attach_name_ori, params).catch((err) => {
457
+ this.$message.error(err.message || "下载失败");
379
458
  });
380
459
  },
381
460
 
@@ -430,29 +509,43 @@ export default {
430
509
  this.closeBtn();
431
510
  },
432
511
 
433
- _saveData(datas, callBack) {
434
- if (datas && datas.length > 0) {
435
- let params = [];
436
- datas.forEach((ele) => {
437
- let param = {};
438
- param.mid = ele.mid;
439
- param.mtype = ele.mtype;
440
- param.mtype_name = ele.mtype_name;
441
- param.attach_name = ele.attach_name;
442
- param.attach_name_ori = ele.attach_name_ori;
443
- param.attach_size = ele.attach_size;
444
- param.attach_path = ele.attach_path;
445
- params.push(param);
446
- });
447
- create(params)
448
- .then((res) => {
449
- if (callBack) callBack(res);
450
- this.$message.success("上传服务器成功");
451
- })
452
- .catch((err) => {
453
- this.$message.error("上传失败");
454
- });
455
- }
512
+ // _saveData(datas, callBack) {
513
+ // if (datas && datas.length > 0) {
514
+ // let params = [];
515
+ // datas.forEach((ele) => {
516
+ // let param = {};
517
+ // param.mid = ele.mid;
518
+ // param.mtype = ele.mtype;
519
+ // param.mtype_name = ele.mtype_name;
520
+ // param.attach_name = ele.attach_name;
521
+ // param.attach_name_ori = ele.attach_name_ori;
522
+ // param.attach_size = ele.attach_size;
523
+ // param.attach_path = ele.attach_path;
524
+ // params.push(param);
525
+ // });
526
+ // create(params)
527
+ // .then((res) => {
528
+ // if (callBack) callBack(res);
529
+ // this.$message.success("上传服务器成功");
530
+ // })
531
+ // .catch((err) => {
532
+ // this.$message.error("上传失败");
533
+ // });
534
+ // }
535
+ // },
536
+
537
+ _createRecords(datas) {
538
+ if (!datas || datas.length === 0) return Promise.resolve();
539
+ const params = datas.map((ele) => ({
540
+ mid: ele.mid,
541
+ mtype: ele.mtype,
542
+ mtype_name: ele.mtype_name,
543
+ attach_name: ele.attach_name,
544
+ attach_name_ori: ele.attach_name_ori,
545
+ attach_size: ele.attach_size,
546
+ attach_path: ele.attach_path,
547
+ }));
548
+ return this.createApi(params);
456
549
  },
457
550
 
458
551
  closeBtn() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "leisure-core",
3
- "version": "0.6.82",
3
+ "version": "0.6.85",
4
4
  "description": "leisure-core是京心数据基于vue2.x开发的一套后台管理系统桌面端组件库,封装了大量实用的UI控件模板,非常方便开发者快速搭建前端应用",
5
5
  "private": false,
6
6
  "author": "北方乐逍遥(zcx7878)",
@@ -21,7 +21,9 @@
21
21
  "vue-router": "^3.5.1",
22
22
  "vuex": "^3.6.2",
23
23
  "vxe-table": "~3.19.28",
24
- "lodash": "^4.17.21"
24
+ "lodash": "^4.17.21",
25
+ "exceljs": "^4.4.0",
26
+ "file-saver": "^2.0.5"
25
27
  },
26
28
  "devDependencies": {}
27
29
  }
package/le-area/index.js DELETED
@@ -1,7 +0,0 @@
1
- import LeArea from "./src/main.vue";
2
-
3
- LeArea.install = function (Vue) {
4
- Vue.component(LeArea.name, LeArea);
5
- };
6
-
7
- export default LeArea;