widget.qw 0.0.1

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.
Files changed (115) hide show
  1. package/README.md +73 -0
  2. package/build/favicon.ico +0 -0
  3. package/build/style.css +763 -0
  4. package/build/widget.qw.es.js +20653 -0
  5. package/build/widget.qw.umd.js +20660 -0
  6. package/index.html +17 -0
  7. package/package.json +47 -0
  8. package/public/favicon.ico +0 -0
  9. package/src/App.vue +26 -0
  10. package/src/api/index.js +126 -0
  11. package/src/assets/avatar.png +0 -0
  12. package/src/assets/banner_handle.png +0 -0
  13. package/src/assets/bg_blue.png +0 -0
  14. package/src/assets/bg_white.png +0 -0
  15. package/src/assets/down.png +0 -0
  16. package/src/assets/home.jpg +0 -0
  17. package/src/assets/icon_box.png +0 -0
  18. package/src/assets/icon_dot.png +0 -0
  19. package/src/assets/icon_draw.png +0 -0
  20. package/src/assets/icon_file.png +0 -0
  21. package/src/assets/icon_fold.png +0 -0
  22. package/src/assets/icon_shield.png +0 -0
  23. package/src/assets/logo.png +0 -0
  24. package/src/components/AuditBar.vue +341 -0
  25. package/src/components/BillCard.vue +156 -0
  26. package/src/components/CheckGroup.vue +114 -0
  27. package/src/components/DatetimePicker/DatetimePop.vue +343 -0
  28. package/src/components/DatetimePicker/index.vue +113 -0
  29. package/src/components/DayDropdown.vue +57 -0
  30. package/src/components/FilePicker.vue +114 -0
  31. package/src/components/Input.vue +72 -0
  32. package/src/components/MonthDropdown.vue +52 -0
  33. package/src/components/MultiPicker.vue +124 -0
  34. package/src/components/ProjectDropdown.vue +62 -0
  35. package/src/components/ProjectPicker.vue +111 -0
  36. package/src/components/SecretNotify.js +6 -0
  37. package/src/components/Sheet.vue +93 -0
  38. package/src/components/SinglePicker.vue +103 -0
  39. package/src/components/SingleUserSelector.vue +425 -0
  40. package/src/components/Switch.vue +65 -0
  41. package/src/components/TreePicker.vue +113 -0
  42. package/src/components/UserPicker.vue +107 -0
  43. package/src/components/UserProfile.vue +128 -0
  44. package/src/components/UsersPicker.vue +118 -0
  45. package/src/components/YearDropdown.vue +60 -0
  46. package/src/components/data_selector.vue +281 -0
  47. package/src/components/image_picker.vue +115 -0
  48. package/src/components/images_picker.vue +140 -0
  49. package/src/components/index.js +157 -0
  50. package/src/components/mult_list_selector.vue +156 -0
  51. package/src/components/product_selector.vue +186 -0
  52. package/src/components/subdepartment_selector.vue +481 -0
  53. package/src/components/user_selector.vue +639 -0
  54. package/src/components/widget/DataPop.vue +96 -0
  55. package/src/components/widget/TreePop.vue +89 -0
  56. package/src/components/widget/UserPop.vue +347 -0
  57. package/src/env.d.ts +8 -0
  58. package/src/main.js +111 -0
  59. package/src/router/index.ts +165 -0
  60. package/src/util/array_util.js +32 -0
  61. package/src/util/auth_util.js +73 -0
  62. package/src/util/bool_util.js +6 -0
  63. package/src/util/bus.js +2 -0
  64. package/src/util/cache_util.js +19 -0
  65. package/src/util/errer_code.js +7 -0
  66. package/src/util/eval_util.js +20 -0
  67. package/src/util/icon_util.js +37 -0
  68. package/src/util/image_util.js +28 -0
  69. package/src/util/index.js +56 -0
  70. package/src/util/num_util.js +71 -0
  71. package/src/util/obj_util.js +29 -0
  72. package/src/util/request.js +74 -0
  73. package/src/util/request_json.js +72 -0
  74. package/src/util/request_json_mute.js +66 -0
  75. package/src/util/request_upload.js +79 -0
  76. package/src/util/route_util.js +32 -0
  77. package/src/util/str_util.js +144 -0
  78. package/src/util/time_util.js +407 -0
  79. package/src/util/toast_util.js +25 -0
  80. package/src/util/tree_util.js +120 -0
  81. package/src/util/validate.js +183 -0
  82. package/src/util/vue_filter.js +223 -0
  83. package/src/views/auditbar/index.vue +66 -0
  84. package/src/views/billcard/index.vue +46 -0
  85. package/src/views/checkgroup/index.vue +36 -0
  86. package/src/views/dataSelector/index.vue +49 -0
  87. package/src/views/datetimepicker/index.vue +35 -0
  88. package/src/views/daydropdown/index.vue +31 -0
  89. package/src/views/filepicker/index.vue +32 -0
  90. package/src/views/home/index.vue +64 -0
  91. package/src/views/imagepicker/index.vue +32 -0
  92. package/src/views/imagespicker/index.vue +32 -0
  93. package/src/views/input/index.vue +35 -0
  94. package/src/views/monthdropdown/index.vue +31 -0
  95. package/src/views/multListSelector/index.vue +61 -0
  96. package/src/views/multipicker/index.vue +37 -0
  97. package/src/views/productSelector/index.vue +35 -0
  98. package/src/views/projectdropdown/index.vue +31 -0
  99. package/src/views/projectpicker/index.vue +42 -0
  100. package/src/views/secretnotify/index.vue +28 -0
  101. package/src/views/sheet/index.vue +46 -0
  102. package/src/views/singlepicker/index.vue +36 -0
  103. package/src/views/subdepartmentSelector/index.vue +41 -0
  104. package/src/views/switch/index.vue +35 -0
  105. package/src/views/treepicker/index.vue +42 -0
  106. package/src/views/userSelector/index.vue +54 -0
  107. package/src/views/userSelectorNew/index.vue +45 -0
  108. package/src/views/userpicker/index.vue +43 -0
  109. package/src/views/userprofile/index.vue +30 -0
  110. package/src/views/userspicker/index.vue +43 -0
  111. package/src/views/yeardropdown/index.vue +32 -0
  112. package/src/vm/index.js +6 -0
  113. package/tsconfig.json +19 -0
  114. package/tsconfig.node.json +8 -0
  115. package/vite.config.ts +73 -0
@@ -0,0 +1,407 @@
1
+ import dayjs from "dayjs"
2
+ import moment from 'moment'
3
+
4
+ export function isValidDatetime(datetimeStr) {
5
+ let dateString = datetimeStr.substring(0, 10)
6
+ let [year, month, day] = dateString.split('-').map(Number);
7
+ month = month - 1; // 因为JavaScript中月份是从0开始计数
8
+ let daysInMonth = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
9
+ if (year % 4 === 0 && (year % 100!== 0 || year % 400 === 0)) {
10
+ daysInMonth[1] = 29; // 闰年2月有29天
11
+ }
12
+ return day <= daysInMonth[month];
13
+ }
14
+
15
+ export function startOfToday() {
16
+ const d = new Date();
17
+ const yyyy = d.getFullYear()
18
+ const MM = pad0(d.getMonth() + 1)
19
+ const dd = pad0(d.getDate())
20
+ const HH = '00'
21
+ const mm = '00'
22
+ const ss = '00'
23
+ return `${yyyy}-${MM}-${dd} ${HH}:${mm}:${ss}`
24
+ }
25
+
26
+ export function endOfToday() {
27
+ const d = new Date();
28
+ const yyyy = d.getFullYear()
29
+ const MM = pad0(d.getMonth() + 1)
30
+ const dd = pad0(d.getDate())
31
+ const HH = '23'
32
+ const mm = '59'
33
+ const ss = '59'
34
+ return `${yyyy}-${MM}-${dd} ${HH}:${mm}:${ss}`
35
+ }
36
+
37
+ export function isToday(str) {
38
+ let t = dayjs(str)
39
+ let s = dayjs(startOfToday())
40
+ let e = dayjs(endOfToday())
41
+ return t >= s && t <= e
42
+ }
43
+
44
+ export function startOfYestoday() {
45
+ const d = new Date();
46
+ d.setTime(d.getTime() - 24 * 60 * 60 * 1000);
47
+ const yyyy = d.getFullYear()
48
+ const MM = pad0(d.getMonth() + 1)
49
+ const dd = pad0(d.getDate())
50
+ const HH = '00'
51
+ const mm = '00'
52
+ const ss = '00'
53
+ return `${yyyy}-${MM}-${dd} ${HH}:${mm}:${ss}`
54
+ }
55
+
56
+ export function endOfYestoday() {
57
+ const d = new Date();
58
+ d.setTime(d.getTime() - 24 * 60 * 60 * 1000);
59
+ const yyyy = d.getFullYear()
60
+ const MM = pad0(d.getMonth() + 1)
61
+ const dd = pad0(d.getDate())
62
+ const HH = '24'
63
+ const mm = '00'
64
+ const ss = '00'
65
+ return `${yyyy}-${MM}-${dd} ${HH}:${mm}:${ss}`
66
+ }
67
+
68
+
69
+ export function startOfWeek() {
70
+ const now = new Date();
71
+ const nowTime = now.getTime();
72
+ const day = now.getDay();
73
+ const oneDayDuration = 24 * 60 * 60 * 1000;
74
+
75
+ //周一
76
+ const d = new Date(nowTime - (day - 1) * oneDayDuration)
77
+ const yyyy = d.getFullYear()
78
+ const MM = pad0(d.getMonth() + 1)
79
+ const dd = pad0(d.getDate())
80
+ const HH = '00'
81
+ const mm = '00'
82
+ const ss = '00'
83
+ return `${yyyy}-${MM}-${dd} ${HH}:${mm}:${ss}`
84
+ }
85
+
86
+ export function endOfWeek() {
87
+ const now = new Date();
88
+ const nowTime = now.getTime();
89
+ const day = now.getDay();
90
+ const oneDayDuration = 24 * 60 * 60 * 1000;
91
+
92
+ //本周日
93
+ const d = new Date(nowTime + (7 - day) * oneDayDuration);
94
+
95
+ const yyyy = d.getFullYear()
96
+ const MM = pad0(d.getMonth() + 1)
97
+ const dd = pad0(d.getDate())
98
+ const HH = '24'
99
+ const mm = '00'
100
+ const ss = '00'
101
+ return `${yyyy}-${MM}-${dd} ${HH}:${mm}:${ss}`
102
+ }
103
+
104
+ export function startOfLastWeek() {
105
+ const now = new Date();
106
+ const nowTime = now.getTime();
107
+ const day = now.getDay();
108
+ const oneDayDuration = 24 * 60 * 60 * 1000;
109
+
110
+ //上周一
111
+ const d = new Date(nowTime - (7 + day - 1) * oneDayDuration);
112
+ const yyyy = d.getFullYear()
113
+ const MM = pad0(d.getMonth() + 1)
114
+ const dd = pad0(d.getDate())
115
+ const HH = '00'
116
+ const mm = '00'
117
+ const ss = '00'
118
+ return `${yyyy}-${MM}-${dd} ${HH}:${mm}:${ss}`
119
+ }
120
+
121
+ export function endOfLastWeek() {
122
+ const now = new Date();
123
+ const nowTime = now.getTime();
124
+ const day = now.getDay();
125
+ const oneDayDuration = 24 * 60 * 60 * 1000;
126
+
127
+ //上周日
128
+ const d = new Date(nowTime - day * oneDayDuration);
129
+
130
+ const yyyy = d.getFullYear()
131
+ const MM = pad0(d.getMonth() + 1)
132
+ const dd = pad0(d.getDate())
133
+ const HH = '24'
134
+ const mm = '00'
135
+ const ss = '00'
136
+ return `${yyyy}-${MM}-${dd} ${HH}:${mm}:${ss}`
137
+ }
138
+
139
+ export function startOfMonth() {
140
+ const date = new Date()
141
+ const y = date.getFullYear()
142
+ const m = date.getMonth();
143
+ //本月1号
144
+ const d = new Date(y, m, 1);
145
+ const yyyy = d.getFullYear()
146
+ const MM = pad0(d.getMonth() + 1)
147
+ const dd = pad0(d.getDate())
148
+ const HH = '00'
149
+ const mm = '00'
150
+ const ss = '00'
151
+ return `${yyyy}-${MM}-${dd} ${HH}:${mm}:${ss}`
152
+ }
153
+
154
+ export function endOfMonth() {
155
+ const date = new Date()
156
+ let y = date.getFullYear()
157
+ let m = date.getMonth();
158
+ if (m == 11) {
159
+ m = 1
160
+ y = y + 1
161
+ } else {
162
+ m = m + 1
163
+ }
164
+ //下个月第0天=本月的最后一天
165
+ const d = new Date(y, m, 0);
166
+
167
+ const yyyy = d.getFullYear()
168
+ const MM = pad0(d.getMonth() + 1)
169
+ const dd = pad0(d.getDate())
170
+ const HH = '24'
171
+ const mm = '00'
172
+ const ss = '00'
173
+ return `${yyyy}-${MM}-${dd} ${HH}:${mm}:${ss}`
174
+ }
175
+
176
+
177
+ export function startOfLastMonth() {
178
+ const now = new Date()
179
+ let y = now.getFullYear()
180
+ let m = now.getMonth();
181
+ if (m == 0) {
182
+ y = y - 1
183
+ m = 11
184
+ } else {
185
+ m = m - 1
186
+ }
187
+
188
+ //上个月1号
189
+ const d = new Date(y, m, 1);
190
+ const yyyy = d.getFullYear()
191
+ const MM = pad0(d.getMonth() + 1)
192
+ const dd = pad0(d.getDate())
193
+ const HH = '00'
194
+ const mm = '00'
195
+ const ss = '00'
196
+ return `${yyyy}-${MM}-${dd} ${HH}:${mm}:${ss}`
197
+ }
198
+
199
+ export function endOfLastMonth() {
200
+ const now = new Date()
201
+ const y = now.getFullYear()
202
+ const m = now.getMonth();
203
+
204
+ //上个月最后一天
205
+ const d = new Date(y, m, 0);
206
+
207
+ const yyyy = d.getFullYear()
208
+ const MM = pad0(d.getMonth() + 1)
209
+ const dd = pad0(d.getDate())
210
+ const HH = '24'
211
+ const mm = '00'
212
+ const ss = '00'
213
+ return `${yyyy}-${MM}-${dd} ${HH}:${mm}:${ss}`
214
+ }
215
+
216
+ // 字符串转时间戳
217
+ export function str2timestamp(time) {
218
+ time = time.substring(0, 19);
219
+ time = time.replace(/-/g, '/');
220
+ return new Date(time).getTime();
221
+ }
222
+
223
+ export function date2timestamp(date) {
224
+ return date.getTime();
225
+ }
226
+
227
+ // 日期转中文
228
+ // 日期转今天、明天、xx月xx日
229
+ export function date2Chinese(date) {
230
+ const today = format(new Date() + "");
231
+ const tomorrow = format(new Date() + "", 1);
232
+ const other = format(date);
233
+ if (today.yyyy === other.yyyy) {
234
+ return other.MM + '月' + other.dd + '日';
235
+ } else return other.yyyy + '年' + other.MM + '月' + other.dd + '日';
236
+ }
237
+
238
+ // 日期转年月日
239
+ // 格式:yyyy-MM-dd
240
+ export function date2yyyyMMdd(date) {
241
+ const formatedDate = format(date);
242
+ return formatedDate.yyyy + '-' + formatedDate.MM + '-' + formatedDate.dd;
243
+ }
244
+
245
+ // 日期转数组
246
+ // 格式:[yyyy,MM,dd]
247
+ export function date2array(date) {
248
+ const formatedDate = format(date);
249
+ return [formatedDate.yyyy, formatedDate.MM, formatedDate.dd];
250
+ }
251
+ // 月份转数组
252
+ // 格式:[yyyy,MM]
253
+ export function month2array(date) {
254
+ const formatedDate = format(date);
255
+ return [formatedDate.yyyy, formatedDate.MM];
256
+ }
257
+
258
+ // 日期转年月日
259
+ // 格式:yyyy-MM-dd hh:mm
260
+ export function date2yyyyMMddhhmm(date) {
261
+ const formatedDate = format(date);
262
+ return formatedDate.yyyy + '-' + formatedDate.MM + '-' + formatedDate.dd + ' ' + formatedDate.hh + ':' + formatedDate.mm;
263
+ }
264
+
265
+ // 日期转年月日
266
+ // 格式:yyyy-MM-dd hh:mm:ss
267
+ export function date2yyyyMMddhhmmss(date) {
268
+ const formatedDate = format(date)
269
+ let str = formatedDate.yyyy + '-' + formatedDate.MM + '-' + formatedDate.dd + ' ' + formatedDate.hh + ':' + formatedDate.mm + ':' + formatedDate.ss
270
+ return str
271
+ }
272
+
273
+ // 时间转小时:分钟
274
+ // 格式:hh:mm
275
+ export function time2hhmm(time) {
276
+ const formatedDate = format(time);
277
+ return formatedDate.hh + ':' + formatedDate.mm;
278
+ }
279
+
280
+ // 时间转小时:分钟:秒
281
+ // 格式:hh:mm:ss
282
+ export function time2hhmmss(time) {
283
+ const formatedDate = format(time);
284
+ return formatedDate.hh + ':' + formatedDate.mm + ':' + formatedDate.ss;
285
+ }
286
+
287
+ // 判断是否为本月
288
+ export function isSameMonth(inDate) {
289
+ var nowDate = new Date();
290
+ return ((nowDate.getFullYear() == inDate.getFullYear()) && (nowDate.getMonth() == inDate.getMonth()))
291
+ }
292
+
293
+ //获取某年某月多少天
294
+ export const YYYYMM2max_day = (YYYY, MM)=> {
295
+ let year = YYYY
296
+ let month = MM
297
+ if(month == 12){
298
+ year = year + 1
299
+ month = 1
300
+ }else{
301
+ month = month + 1
302
+ }
303
+
304
+ // 创建指定年份和月份的下一个月的第一天的日期对象
305
+ // 月份是从0 - 11,所以需要将传入的月份减1
306
+ let nextMonth = new Date(year, month-1, 1, 0, 0, 1)
307
+ // 将日期减去1天,得到指定月份的最后一天
308
+ let lastDayOfMonth = new Date(nextMonth.getTime() - 24*60*60)
309
+
310
+ return lastDayOfMonth.getDate();
311
+ }
312
+
313
+ //日期转星期
314
+ export const date2week_day = (date)=> {
315
+ if(!date)
316
+ return ''
317
+
318
+ let time = date
319
+ if(typeof time === 'string')
320
+ time = new Date(moment(time))
321
+
322
+ let dayOfWeek = time.getDay()
323
+ let weekDays = ["周日", "周一", "周二", "周三", "周四", "周五", "周六"]
324
+ return weekDays[dayOfWeek]
325
+ }
326
+
327
+ export const time_pad0 = (date, types)=>{
328
+ let time = date
329
+ if(typeof time === 'string')
330
+ time = new Date(moment(time))
331
+
332
+ time = date2yyyyMMddhhmmss(time)
333
+
334
+ let res = ''
335
+
336
+ if(types.includes('year'))
337
+ res+=time.slice(0,4)
338
+ else
339
+ res+='0000'
340
+
341
+ if(types.includes('month'))
342
+ res+='-'+time.slice(5,7)
343
+ else
344
+ res+='-'+'0000'
345
+
346
+ if(types.includes('day'))
347
+ res+='-'+time.slice(8,10)
348
+ else
349
+ res+='-'+'00'
350
+
351
+ if(types.includes('hour'))
352
+ res+=' '+time.slice(11,13)
353
+ else
354
+ res+=' '+'00'
355
+
356
+ if(types.includes('minute'))
357
+ res+=':'+time.slice(13,15)
358
+ else
359
+ res+=':'+'00'
360
+
361
+ if(types.includes('second'))
362
+ res+=':'+time.slice(15,17)
363
+ else
364
+ res+=':'+'00'
365
+
366
+ return res
367
+ }
368
+
369
+ //格式化时间
370
+ //输入:
371
+ //val:待格式化时间
372
+ //delayDay:延期天数
373
+ //输出:
374
+ // {
375
+ // mmdd: MM + '月' + dd + '日',
376
+ // day: dd,
377
+ // month: MM,
378
+ // time: hh:mm:ss
379
+ // }
380
+ const format = (val, delayDay = 0) => {
381
+ typeof val === 'string' ? (val = val.replace(/-/g, '/')) : null
382
+ const date = val ? new Date(val) : new Date()
383
+ date.setDate(date.getDate() + delayDay)
384
+ const yyyy = date.getFullYear();
385
+ const MM = pad0(date.getMonth() + 1)
386
+ const dd = pad0(date.getDate())
387
+ // const time = formatTime(date.getTime());
388
+ const hh = pad0(date.getHours());
389
+ const mm = pad0(date.getMinutes());
390
+ const ss = pad0(date.getSeconds());
391
+ return {
392
+ yyyy,
393
+ MM,
394
+ dd,
395
+ hh,
396
+ mm,
397
+ ss,
398
+ }
399
+ }
400
+
401
+ //小于10补0
402
+ export const pad0 = (value) => {
403
+ if(null == value)
404
+ return '00'
405
+
406
+ return value < 10 ? '0' + value : value+''
407
+ }
@@ -0,0 +1,25 @@
1
+ import { showSuccessToast, showFailToast, showLoadingToast, closeToast,setToastDefaultOptions } from 'vant';
2
+
3
+ setToastDefaultOptions({ duration: 5000 })
4
+
5
+ export function warnToast(msg) {
6
+ showFailToast(msg)
7
+ }
8
+
9
+ export function successToast(msg) {
10
+ showSuccessToast(msg)
11
+ }
12
+
13
+ export function showLoading() {
14
+ showLoadingToast({
15
+ message: '加载中...',
16
+ // 禁止背景点击
17
+ forbidClick: true,
18
+ // 一直转圈
19
+ duration:0
20
+ })
21
+ }
22
+
23
+ export function hideLoading(){
24
+ closeToast()
25
+ }
@@ -0,0 +1,120 @@
1
+ // 递归查找叶子节点及父节点
2
+ // 返回存入res数组
3
+ export const findNodes = (id, nodes, res) => {
4
+ if (!nodes || !id) {
5
+ return false
6
+ }
7
+
8
+ for (var i = 0; i < nodes.length; i++) {
9
+ let node = nodes[i]
10
+ res.push(node)
11
+
12
+ if (node.id == id) {
13
+ return true
14
+ }
15
+
16
+ if (node.children) {
17
+ let result = findNodes(id, node.children, res)
18
+ if (result) {
19
+ return true
20
+ }
21
+ }
22
+
23
+ res.pop()
24
+ }
25
+ }
26
+
27
+ // 查找节点
28
+ export const findNode = (id, nodes) => {
29
+ if (!nodes || !id) {
30
+ return null
31
+ }
32
+
33
+
34
+ let res = []
35
+ findNodes(id, nodes, res)
36
+
37
+ if (res.length < 1) {
38
+ return null
39
+ }
40
+
41
+ return res[res.length - 1]
42
+ }
43
+
44
+ // id列表转为节点对象列表
45
+ export const ids2nodes=(ids,totalNodes)=>{
46
+ if(!totalNodes || totalNodes.length<1 || !ids || ids.length<1)
47
+ return []
48
+
49
+ let res = []
50
+ for(var i=0;i<ids.length;i++){
51
+ let node = findNode(ids[i], totalNodes)
52
+ res.push(node)
53
+ }
54
+ return res
55
+ }
56
+
57
+ // 将找到的父子节点数组拼装为树
58
+ export const concatNodes = (nodes) => {
59
+ let res = null
60
+
61
+ for (var i = 0; i < nodes.length; i++) {
62
+ let node = nodes[nodes.length - i - 1]
63
+
64
+ res = {
65
+ text: node.text,
66
+ id: node.id,
67
+ children: res ? [res] : null
68
+ }
69
+ }
70
+
71
+ return res
72
+ }
73
+
74
+ // 递归格式化树结构数据为picker组件数据
75
+ export const data2columns = (nodes) => {
76
+ if (!nodes) {
77
+ return []
78
+ }
79
+
80
+ return nodes.map(e => {
81
+ return {
82
+ text: e.text,
83
+ id: e.id,
84
+ children: e.children ? data2columns(e.children) : null
85
+ }
86
+ })
87
+ }
88
+
89
+ // 树中是否存在值
90
+ export const isFindNode = (id, nodes)=>{
91
+ let res = []
92
+ findNodes(id, nodes, res)
93
+ return res.length > 0
94
+ }
95
+
96
+ // 判断child_id是否等于或属于parent_id
97
+ // nodes:树数据
98
+ export const isChildNode = (child_id, parent_id, nodes)=>{
99
+ if(child_id == parent_id){
100
+ return true
101
+ }
102
+
103
+ let ns = []
104
+ findNodes(child_id, nodes, ns)
105
+
106
+ let one = ns.filter(e=>{
107
+ return e.id == parent_id
108
+ })
109
+ return one.length > 0
110
+ }
111
+
112
+ // 判断child_ids是否属于parent_ids中的任意一个
113
+ // nodes:树数据
114
+ export const isExistChildNode = (child_id, parent_ids, nodes)=>{
115
+ let list = parent_ids.filter(e=>{
116
+ return isChildNode(child_id, e, nodes)
117
+ })
118
+
119
+ return list.length > 0
120
+ }