-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathqzsy.html
More file actions
2802 lines (2597 loc) · 118 KB
/
Copy pathqzsy.html
File metadata and controls
2802 lines (2597 loc) · 118 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>无极天下 - 七政四余</title>
<script src="./js/utils.js"></script>
<script src="./js/timezone.js"></script>
<script src="./js/canvas2image.js"></script>
<script src="./js/html2canvas.min.js"></script>
<script src="./js/xlsx.full.min.js"></script>
<script src="./js/xlxs-style.js"></script>
<link rel="stylesheet" href="./libs/element-plus/2.3.9_dist_index.css" />
<!-- <script src="./libs/3.3.4_dist_vue.global.prod.js"></script> -->
<script src="./libs/3.3.4_dist_vue.global.js"></script>
<script src="./libs/element-plus/2.3.9_dist_index.full.js"></script>
<script src="./libs/element-plus/2.3.9_dist_locale_zh-cn.js"></script>
<script src="./libs/element-plus/icons-vue@2.1.0/index.js"></script>
<script src="./moni.js"></script>
<link rel="stylesheet" href="./css/qzsy.css" />
<script>
const QZSY_XINGS = ['日', '月', '金', '木', '水', '火', '土', '天', '海', '冥', '计', '罗', '炁', '孛', '福', '升', '顶']
const XIU_GONG_LABEL = ['宿1', '宿2', '宫1', '宫2']
const XIU_GONG_CLASS = ['su1', 'su2', 'gong1', 'gong2']
const XIU_GONG_BG_COLORS = ['ec9d8f', 'ecde8f', 'a5ec8f', '8fbfec'] //背景颜色
const XIU_GONG_BG_DOWN_COLORS = ['490707', '997d02', '2eb605', '097ce7'] //运势低背景颜色
const XIU_GONG_BG_UP_COLORS_3 = ['00b050', 'ff0066', '00b050', '0000ff'] //运势高背景颜色样式3
const F_BG_CHANGE_COLORS_2 = ['00b050', 'd16a12', '00b050', 'd16a12'] //运势变化背景颜色样式2(福
const S_BG_CHANGE_COLORS_2 = ['00b050', 'FF0000', '00b050', 'FF0000'] //运势变化背景颜色样式2(升
const D_BG_CHANGE_COLORS_2 = ['00b050', '0000ff', '00b050', '0000ff'] //运势变化背景颜色样式2(顶
const DEFAULT_EXCEL_BORDER_STYLE = {
right: { style: 'thin' },
left: { style: 'thin' },
top: { style: 'thin' },
bottom: { style: 'thin' }
}
const DEFAULT_EXCEL_ALIGN_STYLE = { horizontal: 'center' }
const ASTRO_XINGS = [
'日',
'月',
'金',
'木',
'水',
'火',
'土',
'天',
'海',
'冥',
'计',
'罗',
-1,
'孛',
'福',
'升',
'顶',
'医',
'谷',
'智',
'婚',
'灶'
]
const SYMBOL_MAP = {
日: '⊙',
月: '☽',
金: '♀',
木: '♃',
水: '☿',
火: '♂',
土: '♄',
天: '♅',
海: '♆',
冥: '♇',
升: 'AC',
顶: 'MC',
合: '☌',
冲: '☍',
刑: '◻',
刑: '*'
}
</script>
<script>
const { createApp, ref, getCurrentInstance, reactive } = Vue
const { ElMessageBox, ElMessage, ElNotification } = ElementPlus
window.onload = function () {
const app = createApp({
setup() {
const { ArrowLeftBold, ArrowRightBold, VideoPlay, VideoPause, Refresh } = ElementPlusIconsVue
const { proxy } = getCurrentInstance()
const zoneOptions = ref(timeZoneList)
const user = ref({
account: '请登录...'
})
function loadUserData() {
sendRequest({
url: `api/user/getUserInfo`
}).then(userInfoResp => {
user.value.account = '+' + userInfoResp.data.account
})
}
function onClickLogout() {
ElMessageBox.confirm('确认要退出登录吗?').then(() => {
sendRequest({
method: 'GET',
url: '/api/user/userLogout'
})
.then(res => {
if (res.code == 200) {
window.localStorage.removeItem('token')
window.localStorage.removeItem('username')
window.location.href = 'login.html'
}
})
.catch(() => {
// catch error
})
})
}
const form = ref({
username: '',
sex: '男',
birth: '20020202020202',
now: '20020202020202',
// birth: '',
// now: '',
lat: 39.9,
lng: 116.4,
locationInputType: '0',
zone: 'Asia/Shanghai',
xingZhi: '0',
signDisplay: ['日', '月', '金', '木', '水', '火', '土', '计', '罗', '炁', '孛', '福', '升', '顶', '天', '海', '冥'],
astroSignDisplay: [
'日',
'月',
'金',
'木',
'水',
'火',
'土',
'天',
'海',
'冥',
'计',
'孛',
'福',
'升',
'顶',
'医',
'谷',
'智',
'婚',
'灶',
'罗'
]
})
const qzsyXings = ref(QZSY_XINGS)
let ax = []
Object.assign(ax, ASTRO_XINGS)
ax.splice(12, 1)
const astroXings = ref(ax)
let signDisplay = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1]
let astroSignDisplay = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
const checkTime = (rule, value, callback) => {
if (value === '') {
callback(new Error('请输入时间'))
} else {
if (!/^\s*\d{4}\s*\d{2}\s*\d{2}\s*\d{2}\s*\d{2}\s*\d{2}?$/.test(value)) {
callback(new Error('时间格式不正确'))
}
callback()
}
}
const formRules = ref({
username: [{ required: true, message: '请输入姓名', trigger: 'blur' }],
birth: [
{ required: true, message: '请输入时间', trigger: 'blur' },
{ validator: checkTime, message: '时间格式不正确', trigger: 'change' },
{ validator: checkTime, message: '时间格式不正确', trigger: 'blur' }
],
now: [
{ required: true, message: '请输入时间', trigger: 'blur' },
{ validator: checkTime, message: '时间格式不正确', trigger: 'change' },
{ validator: checkTime, message: '时间格式不正确', trigger: 'blur' }
],
lat: [{ required: true, message: '请输入纬度', trigger: 'blur' }],
lng: [{ required: true, message: '请输入经度', trigger: 'blur' }]
})
function resetForm() {
form.value = {
username: '',
sex: '男',
birth: '',
now: '',
lat: 39.9,
lng: 116.4,
locationInputType: '0',
zone: 'Asia/Shanghai',
xingZhi: '0',
signDisplay: ['日', '月', '金', '木', '水', '火', '土', '计', '罗', '炁', '孛'],
astroSignDisplay: ['日', '月', '金', '木', '水', '火', '土', '天', '海', '冥', '计', '孛', '福', '升', '顶']
}
}
// ******排盘 START
// 弹窗
const dialogPanVisible = ref(false)
const activeTabPan = ref('qzsy')
const qzsyPanData = ref({})
const xingPanData = ref({})
const filtTimeType = ref('year')
const autoPlayIntervalTime = ref(5)
const isAutoPlay = ref(false)
const paiPanBtnLoading = ref(false)
let intervalAutoPlay = null
function onClickPaiPan() {
proxy.$refs['formRef'].validate(valid => {
if (valid) {
paiPanBtnLoading.value = true
loadQzsyPan()
loadXingPan()
getLocationByGoogle()
}
})
}
function loadQzsyPan() {
let fields = form.value
let bt = getDateByStr(fields.birth)
let lt = getDateByStr(fields.now)
sendRequest({
url: `api/moira/getQzsyData?birth=${parseInt(bt.year)},${parseInt(bt.month)},${parseInt(bt.day)},${parseInt(
bt.hour
)},${parseInt(bt.minute)},${parseInt(bt.second)}&now=${parseInt(lt.year)},${parseInt(lt.month)},${parseInt(
lt.day
)},${parseInt(lt.hour)},${parseInt(lt.minute)},${parseInt(lt.second)}&xingZhi=${fields.xingZhi}&zone=${fields.zone}&lat=${
fields.lat
}&lng=${fields.lng}&signDisplay=${signDisplay.join(',')}`
}).then(moriaResp => {
if (moriaResp && moriaResp.data) {
qzsyPanData.value = moriaResp.data
dialogPanVisible.value = true
}
paiPanBtnLoading.value = false
})
}
function loadXingPan() {
let fields = form.value
let bt = getDateByStr(fields.birth)
let lt = getDateByStr(fields.now)
sendRequest({
url: `api/moira/getZhanXingData?birth=${parseInt(bt.year)},${parseInt(bt.month)},${parseInt(bt.day)},${parseInt(
bt.hour
)},${parseInt(bt.minute)},${parseInt(bt.second)}&now=${parseInt(lt.year)},${parseInt(lt.month)},${parseInt(
lt.day
)},${parseInt(lt.hour)},${parseInt(lt.minute)},${parseInt(bt.second)}&xingPan=4&zone=${fields.zone}&lat=${fields.lat}&lng=${
fields.lng
}&astroSignDisplay=${astroSignDisplay.join(',')}`
}).then(moriaResp => {
if (moriaResp.data) {
xingPanData.value = moriaResp.data
let xingDataList = []
// 构建xing
let xingLabel = []
moriaResp.data.benMingHd.map(item => {
xingLabel.push(item.xing)
})
// 构建星盘表格
let tables = [moriaResp.data.benMingTable, moriaResp.data.liuNianTable]
// 构造空数据
for (let index = 0; index < 2; index++) {
let xingData = []
let first = []
Object.assign(first, xingLabel)
first.unshift('')
xingData.push(first)
xingLabel.map(x => {
let data = [x]
xingLabel.map(xx => {
data.push('')
})
xingData.push(data)
})
xingDataList.push(xingData)
}
tables.map((xingTable, index) => {
xingTable.map((b, bIdx) => {
let data = []
let body = ''
if (b.indexOf('\n') != -1) {
let relation = b.split('\n')[1]
let relations = relation.split(' ')
let xingIdx = xingLabel.findIndex(item => {
return item == b.split('\n')[0].split(':')[0].trim()
})
if (xingIdx == -1) return
xingLabel.map((x, xId) => {
relations.map(r => {
if (r.indexOf(':') != -1) {
let rs = r.split(':')
if (rs[1].indexOf(x) != -1) {
xingDataList[index][xingIdx + 1][xId + 1] = rs[0]
}
}
})
})
}
})
})
xingPanData.value.benMingXingRows = xingDataList[0]
xingPanData.value.liuNianXingRows = xingDataList[1]
}
})
}
function getLocationByGoogle() {
const xhr = new XMLHttpRequest()
xhr.open(
'GET',
`https://maps.googleapis.com/maps/api/geocode/json?latlng=${form.value.lat}%2C${form.value.lng}&location_type=ROOFTOP&language=zh-CN&result_type=street_address&key=AIzaSyC2k5kJeKpF6Gs4t9-a-wJg53EyQntj2Gk`
)
xhr.addEventListener('loadend', () => {
if (xhr.status >= 200 && xhr.status < 300) {
try {
let data = JSON.parse(xhr.response)
if (data && data.plus_code && data.plus_code.compound_code) {
if (qzsyPanData.value.headers) qzsyPanData.value.headers.city = data.plus_code.compound_code
if (xingPanData.value.headers) xingPanData.value.headers.city = data.plus_code.compound_code
if (data.plus_code.compound_code.indexOf(' ')) {
if (qzsyPanData.value.headers)
qzsyPanData.value.headers.city = data.plus_code.compound_code.substr(data.plus_code.compound_code.indexOf(' '))
if (xingPanData.value.headers)
xingPanData.value.headers.city = data.plus_code.compound_code.substr(data.plus_code.compound_code.indexOf(' '))
}
}
} catch (e) {}
}
})
xhr.send()
}
function onCheckSignDisplay() {
// 构建signDisplay
if (form.value.signDisplay && form.value.signDisplay.length > 0) {
signDisplay = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1, -1, -1, -1]
form.value.signDisplay.map(x => {
let idx = QZSY_XINGS.findIndex(i => {
return x == i
})
if (-1 != idx) {
signDisplay[idx] = 1
}
})
}
}
function onCheckAstroSignDisplay() {
// 构建signDisplay
if (form.value.astroSignDisplay && form.value.signDisplay.length > 0) {
astroSignDisplay = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0]
form.value.astroSignDisplay.map(x => {
let idx = ASTRO_XINGS.findIndex(i => {
return x == i
})
if (-1 != idx) {
astroSignDisplay[idx] = 1
}
})
}
}
function onChangeNowTime(plus = true) {
let changeType = filtTimeType.value
let now = getDateByStr(form.value.now)
now[changeType] = plus ? parseInt(now[changeType]) + 1 : parseInt(now[changeType]) - 1
form.value.now = dateObjToStr(now)
loadQzsyPan()
loadXingPan()
}
function onPlayAutoPan() {
isAutoPlay.value = true
if (intervalAutoPlay) clearInterval(intervalAutoPlay)
intervalAutoPlay = setInterval(() => {
onChangeNowTime(true)
}, autoPlayIntervalTime.value * 1000)
}
function onPauseAutoPan() {
isAutoPlay.value = false
if (intervalAutoPlay) clearInterval(intervalAutoPlay)
}
function onCloseDialogPan() {
dialogPanVisible.value = false
isAutoPlay.value = false
if (intervalAutoPlay) clearInterval(intervalAutoPlay)
}
// ******排盘 END
// ******排盘历史 START
const panHisData = ref([])
const queryParams = ref({ pageSize: 10, pageNum: 1 })
const total = ref(0)
function loadPanHisData() {
sendRequest({
url: `api/moira/getMoiraRecordList?pageSize=${queryParams.value.pageSize}&pageNum=${queryParams.value.pageNum}`
}).then(res => {
if (!res || !res.rows) return
panHisData.value = res.rows
total.value = res.total
})
}
function onSavePaiHis() {
proxy.$refs['formRef'].validate(valid => {
if (valid) {
sendRequest({
url: `api/moira/addMoiraRecord`,
method: `POST`,
data: form.value
}).then(resp => {
ElMessage({
message: '存档成功',
type: 'success'
})
loadPanHisData()
})
}
})
}
function onDelPanHis(idx, row) {
ElMessageBox.confirm('确认删除该排盘数据吗?').then(() => {
sendRequest({ method: 'POST', url: 'api/moira/deleteById?id=' + row.id }).then(res => {
ElMessage({
message: '删除成功',
type: 'success'
})
loadPanHisData()
})
})
}
function onLoadPanHis(idx, row) {
row.xingZhi = '0'
form.value = row
ElMessage({
message: '载入成功',
type: 'success'
})
}
function addTask(row, days) {
ElMessageBox.prompt('输入要导出的天数', 'Tip', {
confirmButtonText: '提交',
cancelButtonText: '取消',
inputType: 'number',
inputValidator: function (value) {
let intValue = parseInt(value)
if (!/^\d+$/.test(value) || intValue < 1 || intValue > 30) {
return '请输入1-30之间的整数'
}
}
})
.then(({ value }) => {
sendRequest({
method: 'POST',
url: 'api/moiraTask/addMoiraTask',
data: { recordId: row.id, days: parseInt(value) }
}).then(res => {
if (res.code == 200) {
ElMessage({
message: '添加成功',
type: 'success'
})
taskQueryParams.value.pageNum = 1
loadTaskData()
}
})
})
.catch(() => {})
}
// ******排盘历史 END
// ******导出任务 START
const taskData = ref([])
const taskQueryParams = ref({ pageSize: 10, pageNum: 1 })
const taskTotal = ref(0)
const exportTaskDataLoading = ref(false)
const exportPageNum = ref(1)
const exportPageTotal = ref(1)
const exportPageSize = ref(6)
function loadTaskData() {
taskData.value = []
sendRequest({
url: `api/moiraTask/getMoiraTaskVoList?pageSize=${taskQueryParams.value.pageSize}&pageNum=${taskQueryParams.value.pageNum}`
}).then(res => {
if (!res || !res.rows) return
taskData.value = res.rows
taskTotal.value = res.total
})
}
function onDelTask(row) {
ElMessageBox.confirm('确认删除该任务吗?').then(() => {
sendRequest({
url: `api/moiraTask/deleteByTaskId?taskId=${row.taskId}`
}).then(res => {
if ((res.code = 200))
ElMessage({
message: '任务删除成功',
type: 'success'
})
taskQueryParams.value.pageNum = 1
taskData.value = []
loadTaskData()
})
})
}
function reloadTaskData() {
taskData.value = []
sendRequest({
url: `api/moiraTask/getMoiraTaskVoList?pageSize=${taskQueryParams.value.pageSize}&pageNum=${taskQueryParams.value.pageNum}`
}).then(res => {
if (!res || !res.rows) return
taskData.value = res.rows
taskTotal.value = res.total
ElMessage({
message: '导出任务列表刷新成功',
type: 'success'
})
})
}
async function onExportTaskData(idx, row) {
exportTaskDataLoading.value = true
taskData.value[idx].exportLoading = true
taskData.value[idx].exportPageNum = 1
let pageSize = exportPageSize.value
let pageNum = taskData.value[idx].exportPageNum
taskData.value[idx].exportPercentage = 0
while (true) {
let res = await sendRequest({
url: `api/moiraTaskResult/getMoiraTaskResultList?taskId=${row.taskId}&pageSize=${pageSize}&pageNum=${pageNum}`
})
if (!res || !res.rows || res.rows.length <= 0) break
let jjson = []
let pageTotal = Math.ceil(res.total / pageSize)
console.log('pageTotal', pageTotal)
console.log('taskData.value[idx].exportPageNum / pageTotal', taskData.value[idx].exportPageNum / pageTotal)
taskData.value[idx].exportPercentage = parseInt(((taskData.value[idx].exportPageNum / pageTotal) * 100).toFixed(0))
qzsyTableData = []
xingTableData[0] = []
xingTableData[1] = []
res.rows.map(res => {
result = JSON.parse(res.result)
qzsyTableData.push(result.list)
xingTableData[0].push(result.liuNianHd)
xingTableData[1].push(result.liuNianGw)
jjson.push(result)
})
console.log(jjson)
qzsyTableRows.value = []
handleQzsyTableData2Rows()
const wb = XLSX.utils.book_new()
const ws = XLSX.utils.aoa_to_sheet(qzsyTableRows.value)
XLSX.utils.book_append_sheet(wb, ws, '样式' + qzsyTableStyle.value)
let colsWidths = []
colsWidths.push({ wch: 3 })
qzsyTableRows.value[0].map(data => {
colsWidths.push({ wch: 3 })
})
ws['!cols'] = colsWidths
XLSX.writeFile(
wb,
`${row.username ? row.username : ''}_${row.now}_10天推运表_${pageNum}_${parseInt(new Date().getTime() / 1000)}.xlsx`
)
if (pageNum * pageSize >= res.total) {
break
}
pageNum += 1
taskData.value[idx].exportPageNum = pageNum
}
ElMessage({
message: '导出完成',
type: 'success'
})
taskData.value[idx].exportLoading = false
exportTaskDataLoading.value = false
}
loadTaskData()
// ******排盘历史 END
// ******七政四余推运 START
const dialogQzsyTableVisible = ref(false)
const qzsyTableStyle = ref(1)
const qzsyTableStyle2PartHidden = ref(false)
const qzsyTableRows = ref([])
const qzsyTableLoading = ref(false)
const loadMoreQzsyNum = ref(48)
const moreQzsyTotal = ref(0)
const moreQzsyLoaded = ref(0)
let qzsyTableData = []
let currentTuiYunDate = null
function loadQzsyTable() {
return new Promise(async (resolve, reject) => {
let fields = form.value
let bt = getDateByStr(fields.birth)
let birth = `${parseInt(bt.year)},${parseInt(bt.month)},${parseInt(bt.day)},${parseInt(bt.hour)},${parseInt(
bt.minute
)},${parseInt(bt.second)}`
let startNowDate = new Date(currentTuiYunDate.getTime())
startNowDate.setMinutes(startNowDate.getMinutes() - 6)
let startNow = `${startNowDate.getFullYear()},${
startNowDate.getMonth() + 1
},${startNowDate.getDate()},${startNowDate.getHours()},${startNowDate.getMinutes()},0`
let endNowDate = new Date(currentTuiYunDate.getTime())
endNowDate.setMinutes(endNowDate.getMinutes() + 66)
let endNow = `${endNowDate.getFullYear()},${
endNowDate.getMonth() + 1
},${endNowDate.getDate()},${endNowDate.getHours()},${endNowDate.getMinutes()},0`
qzsyTableLoading.value = true
sendRequest({
url: `api/moira/getTableData?birth=${birth}&xingZhi=${fields.xingZhi}&startNow=${startNow}&endNow=${endNow}&zone=${
fields.zone
}&lat=${fields.lat}&lng=${fields.lng}&filterTime=minute&signDisplay=${signDisplay.join(',')}`
}).then(async tableDataResp => {
// tableDataResp = tableData
if (tableDataResp && tableDataResp.data && tableDataResp.data.list) {
qzsyTableData.push(tableDataResp.data.list)
await loadXingTable()
handleQzsyTableData2Rows()
// ElMessage(`${parseTime(currentTuiYunDate, '{y}-{m}-{d} {h}')}数据已加载完毕`)
// currentTuiYunDate.setHours(currentTuiYunDate.getHours() + 1)
moreQzsyLoaded.value = moreQzsyLoaded.value + 1
}
qzsyTableLoading.value = false
resolve()
})
})
}
//将数据转换为行数据,Excel通用
function handleQzsyTableData2Rows() {
let currentTableStyle = qzsyTableStyle.value
let rows = []
qzsyTableData.map(currentTuiYunRow => {
let tuiYunHeader = [
{
v: currentTuiYunRow[7][0].now.substring(0, 13),
s: {
font: {
bold: true
},
fill: { fgColor: { rgb: 'c6f76f' } }
},
style: 'font-weight:bold;color:#000000;background-color:#C6F76F'
}
]
currentTuiYunRow.map(data => {
tuiYunHeader.push({
v: data[0].now.substring(14, 16),
s: {
font: {
bold: true
},
fill: { fgColor: { rgb: 'c6f76f' } }
},
style: 'font-weight:bold;color:#000000;background-color:#C6F76F'
})
})
// tuiYunHeader.splice(tuiYunHeader.length - 1, 1) //去掉最后一列保证60
rows.push(tuiYunHeader)
let xingLabel = []
currentTuiYunRow[0].map(i => {
xingLabel.push(i.xing)
})
let list = []
let su1List = []
let su2List = []
let gong1List = []
let gong2List = []
for (let index = 0; index < currentTuiYunRow[0].length; index++) {
let su1HourList = []
let su2HourList = []
let gong1HourList = []
let gong2HourList = []
currentTuiYunRow.map(data => {
su1HourList.push(parseInt(data[index].su1))
su2HourList.push(parseInt(data[index].su2))
gong1HourList.push(parseInt(data[index].gong1))
gong2HourList.push(parseInt(data[index].gong2))
})
su1List.push(su1HourList)
su2List.push(su2HourList)
gong1List.push(gong1HourList)
gong2List.push(gong2HourList)
}
list.push(su1List, su2List, gong1List, gong2List)
list.map((iData, index) => {
// if (currentTableStyle == 2 && (index == 0 || index == 2)) {
// return iData
// }
iData.map((lData, idx) => {
lData.unshift(xingLabel[idx])
let row = []
let temp = 0
// lData.splice(lData.length - 1, 1) // 去掉最后一行保证只有60分钟数据
lData.map((l, i) => {
let fgColor = XIU_GONG_BG_COLORS[index]
let isBold = false
let isUnderline = false
let fontColor = '000000'
if (temp > l) {
fgColor = XIU_GONG_BG_DOWN_COLORS[index]
fontColor = 'ffffff'
isBold = true
} else if (temp < l) {
fgColor = 'fd0404'
fontColor = 'ffffff'
isBold = true
}
let borderStyle = 'thin'
let broderColor = 'ffffff'
if (i >= 33 && i <= 43) {
isUnderline = true
}
if (i == 32 || i == 43) {
borderStyle = ''
broderColor = '0728e2'
}
// 构造sytle
let style = `background-color:#${fgColor};font-weight:${isBold ? 'bold' : 'normal'};color:#${fontColor}`
row.push({
v: l,
s: {
fill: { fgColor: { rgb: fgColor } },
font: {
bold: isBold,
color: { rgb: fontColor },
underline: isUnderline
},
alignment: { horizontal: 'center' },
border: {
right: { style: borderStyle, color: { rgb: broderColor } },
left: { style: 'thin' },
top: { style: 'thin' },
bottom: { style: 'thin' }
}
},
style: style
})
temp = l
})
rows.push(row)
})
})
})
if (currentTableStyle == 2) {
rows = []
qzsyTableData.map((ctr, currentIdx) => {
let subRows = []
let staticSubRows = []
// 从星盘行列数据里取数据插入
let xingHdTuiYunRow = xingTableData[0][currentIdx]
let xingGwTuiYunRow = xingTableData[1][currentIdx]
let currentTuiYunRow = []
ctr.map((ctrData, cIdx) => {
let ctrD = []
Object.assign(ctrD, ctrData)
let insertIdx = ctrData.findIndex(item => {
return item.xing == '福'
})
let insertData = []
xingHdTuiYunRow[cIdx].map(r => {
r.isXing = true
if (r.xing == '醫' || r.xing == '穀' || r.xing == '智' || r.xing == '婚' || r.xing == '灶') insertData.push(r)
})
xingGwTuiYunRow[cIdx].map((r, i) => {
r.isXing = true
insertData.push(r)
})
if (insertIdx != -1) ctrD.splice(insertIdx, 0, ...insertData)
currentTuiYunRow.push(ctrD)
})
let xingLabel = []
currentTuiYunRow[0].map(i => {
xingLabel.push(i.xing)
})
let tuiYunHeader = [
{
v: currentTuiYunRow[7][0].now.substring(0, 13),
s: {
font: {
bold: true
},
fill: { fgColor: { rgb: 'c6f76f' } }
},
style: 'font-weight:bold;color:#000000;background-color:#C6F76F'
}
]
currentTuiYunRow.map(data => {
tuiYunHeader.push({
v: data[0].now.substring(14, 16),
s: {
font: {
bold: true
},
fill: { fgColor: { rgb: 'c6f76f' } }
},
style: 'font-weight:bold;color:#000000;background-color:#C6F76F'
})
})
// tuiYunHeader.splice(tuiYunHeader.length - 1, 1) //去掉最后一列保证60
subRows.push(tuiYunHeader)
let style3List = []
for (let index = 0; index < currentTuiYunRow[0].length; index++) {
let su1 = []
let su2 = []
let gong1 = []
let gong2 = []
currentTuiYunRow.map(item => {
if (item[index].isXing) {
// 处理占星数据没有宫数据
su1.push(parseInt(item[index].su1))
su2.push(parseInt(item[index].su1))
gong1.push(parseInt(item[index].su2))
gong2.push(parseInt(item[index].su2))
} else {
su1.push(parseInt(item[index].su1))
su2.push(parseInt(item[index].su2))
gong1.push(parseInt(item[index].gong1))
gong2.push(parseInt(item[index].gong2))
}
})
style3List.push([su1, su2, gong1, gong2])
}
style3List.map((iData, index) => {
iData.map((lData, idx) => {
if (idx == 0 || idx == 2) {
if (xingLabel[index] != '福' && xingLabel[index] != '升' && xingLabel[index] != '顶') {
return
}
}
let diffData = []
Object.assign(diffData, lData)
row = []
staticSubRow = [] //变化比较少的行
temp = lData[0]
lData.unshift(xingLabel[index])
// 计算差值list
let diffs = []
diffData.map((l, i) => {
if (i == diffData.length - 1) {
return
}
if (l <= diffData[i + 1]) {
diffs.push(Math.abs(diffData[i + 1] - l))
} else {
diffs.push(Math.abs(diffData[i + 1] + 60 - l))
}
})
diffs.unshift(99)
temp = diffs[0]
let tempL = lData[1]
lData.map((l, i) => {
let fgColor = '8DB4E2'
let isBold = false
let isUnderline = false
let fontColor = '000000'
if (
xingLabel[index] == '福' ||
xingLabel[index] == '升' ||
xingLabel[index] == '顶' ||
xingLabel[index] == '身' ||
xingLabel[index] == '月'
) {
fgColor = '538DD5'
}
if (i > 1 && i < lData.length - 1 && temp > diffs[i]) {
fontColor = 'ffffff'
if (xingLabel[index] == '福') {
fgColor = F_BG_CHANGE_COLORS_2[idx]
} else if (xingLabel[index] == '升') {
fgColor = S_BG_CHANGE_COLORS_2[idx]
} else if (xingLabel[index] == '顶') {
fgColor = D_BG_CHANGE_COLORS_2[idx]
} else {
if (xingLabel[index] == '身' || xingLabel[index] == '月') {
fgColor = 'C5D9F1'
fontColor = '0000ff'
} else {
if (
xingLabel[index] == '命宫' ||
xingLabel[index] == '财帛' ||
xingLabel[index] == '兄弟' ||
xingLabel[index] == '田宅' ||
xingLabel[index] == '男女' ||
xingLabel[index] == '奴仆' ||
xingLabel[index] == '夫妻' ||
xingLabel[index] == '疾厄' ||
xingLabel[index] == '迁移' ||
xingLabel[index] == '官禄' ||
xingLabel[index] == '福德' ||
xingLabel[index] == '相貌'
) {
fgColor = '7030A0'
fontColor = 'ffffff'
} else {
fgColor = 'd16a12'
fontColor = 'ffffff'
}
}
}
isBold = true
}
// if ((l == 0 && tempL != 0) || (l == 60 && tempL != 60)) {
// fgColor = '000000'
// fontColor = 'ffffff'
// isBold = true
// }
temp = diffs[i]
tempL = l
let borderStyle = 'thin'
let broderColor = 'ffffff'
if (i >= 39 && i <= 49) {
isUnderline = true
}
if (i == 38 || i == 49) {
borderStyle = ''
broderColor = '0728e2'
}
// 构造sytle