@mixd-id/web-scaffold 0.1.230406116 → 0.1.230406117

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@mixd-id/web-scaffold",
3
3
  "private": false,
4
- "version": "0.1.230406116",
4
+ "version": "0.1.230406117",
5
5
  "scripts": {
6
6
  "dev": "vite serve",
7
7
  "build": "vite build",
@@ -170,9 +170,10 @@ import throttle from "lodash/throttle";
170
170
  import { Bar, Line } from 'vue-chartjs'
171
171
  import Chart from 'chart.js/auto'
172
172
  import dayjs from "dayjs";
173
+ import VirtualTable from "./VirtualTable.vue"
173
174
 
174
175
  export default{
175
- components: {Line, Bar},
176
+ components: {Line, Bar, VirtualTable},
176
177
 
177
178
  emits: [ ],
178
179
 
@@ -280,7 +281,7 @@ export default{
280
281
  this.$refs.columnMenu.close()
281
282
  },
282
283
 
283
- load(){
284
+ async load(){
284
285
  if(!this.src) return
285
286
 
286
287
  this.$refs.table1 ? this.$refs.table1.setState(3) : this.$refs.table2.setState(3)
@@ -491,8 +492,6 @@ export default{
491
492
 
492
493
  const items = [ ...this.summary.items ]
493
494
 
494
- //console.log('#1', this.presetSummary.showColumnTotal, this.presetSummary.showRowTotal, items.length)
495
-
496
495
  if(this.presetSummary.mode === 'table' && this.presetSummary.table.showColumnTotal){
497
496
  items.forEach((item) => {
498
497
  let total = 0
@@ -504,7 +503,6 @@ export default{
504
503
  })
505
504
  }
506
505
 
507
-
508
506
  if(this.presetSummary.mode === 'table' && this.presetSummary.table.showRowTotal){
509
507
  const totalItem = { dfDate:"Total" }
510
508
  this.summary.items.forEach((item) => {
@@ -523,6 +521,10 @@ export default{
523
521
  return items
524
522
  },
525
523
 
524
+ onResize: throttle(function() {
525
+ this.calcMediaPrefix()
526
+ }, 100, { leading:true }),
527
+
526
528
  },
527
529
 
528
530
  inject: [ 'socket', 'socketEmit2', 'toast', 'alert' ],
@@ -791,22 +793,22 @@ export default{
791
793
 
792
794
 
793
795
  mounted() {
794
- window.addEventListener('resize', throttle(() => this.calcMediaPrefix(), 100, { leading:true }))
795
- this.calcMediaPrefix()
796
+ window.addEventListener('resize', this.onResize)
796
797
 
797
- this.socket.onAny(this.onHooks)
798
+ this.calcMediaPrefix()
798
799
 
799
- window.setTimeout(() => {
800
- this.loadConfig().then(() => {
801
- window.setTimeout(() => {})
802
- this.load()
803
- }, 1000)
804
- }, 201)
800
+ this.loadConfig().then(() => {
801
+ this.load()
802
+ .then(() => {
803
+ this.subscribe()
804
+ })
805
+ })
805
806
 
806
- this.subscribe()
807
+ this.socket.onAny(this.onHooks)
807
808
  },
808
809
 
809
810
  unmounted() {
811
+ window.removeEventListener('resize', this.onResize)
810
812
  this.socket.offAny(this.onHooks)
811
813
  },
812
814
 
@@ -486,8 +486,8 @@ export default{
486
486
  this.$refs.webPageComponentSelector.close()
487
487
  },
488
488
 
489
- load(){
490
- this.socketEmit2('page.open', { uid:this.$route.params.uid })
489
+ async load(){
490
+ return this.socketEmit2('page.open', { uid:this.$route.params.uid })
491
491
  .then(({ page, layouts }) => {
492
492
 
493
493
  const patchComponents = (items) => {
@@ -780,6 +780,51 @@ export default{
780
780
  this.$refs.iframe.contentWindow.postMessage({ uid, data }, '*')
781
781
  },
782
782
 
783
+ onMessage(event){
784
+
785
+ const { uid, type, value } = event.data ?? {}
786
+
787
+ let comp
788
+ let compType
789
+ if(uid){
790
+ comp = this.findCompByUid(uid, this.page.components)
791
+ if(!comp){
792
+ comp = this.findCompByUid(uid, this.layout.headers)
793
+ if(!comp){
794
+ comp = this.findCompByUid(uid, this.layout.footers)
795
+ if(comp){
796
+ compType = 'footers'
797
+ }
798
+ }
799
+ else{
800
+ compType = 'headers'
801
+ }
802
+ }
803
+ else{
804
+ compType = 'components'
805
+ }
806
+ }
807
+
808
+ switch(type){
809
+
810
+ case 'setProp':
811
+ if(comp){
812
+ Object.assign(comp.props, value)
813
+ compType === 'components' ? this.save(false) : this.saveLayout(false)
814
+ }
815
+ break
816
+
817
+ case 'setSubAction':
818
+ if(this.$refs.settingComponent && this.$refs.settingComponent.setSubAction)
819
+ this.$refs.settingComponent.setSubAction(value)
820
+ break
821
+
822
+ case 'component-click':
823
+ this.store.selectedComponent = [ uid ]
824
+ break
825
+ }
826
+ },
827
+
783
828
  onLayoutItemPaste(items, currentItem, newItem){
784
829
  this.onItemPaste(items, currentItem, newItem, true)
785
830
  },
@@ -823,7 +868,11 @@ export default{
823
868
 
824
869
  getPage(){
825
870
  return this.page
826
- }
871
+ },
872
+
873
+ onResize: throttle(function() {
874
+ this.resize()
875
+ }, 500, { leading:true }),
827
876
 
828
877
  },
829
878
 
@@ -1079,57 +1128,18 @@ export default{
1079
1128
  mounted() {
1080
1129
  this.load()
1081
1130
 
1082
- window.addEventListener('message', (event) => {
1083
-
1084
- const { uid, type, value } = event.data ?? {}
1085
-
1086
- let comp
1087
- let compType
1088
- if(uid){
1089
- comp = this.findCompByUid(uid, this.page.components)
1090
- if(!comp){
1091
- comp = this.findCompByUid(uid, this.layout.headers)
1092
- if(!comp){
1093
- comp = this.findCompByUid(uid, this.layout.footers)
1094
- if(comp){
1095
- compType = 'footers'
1096
- }
1097
- }
1098
- else{
1099
- compType = 'headers'
1100
- }
1101
- }
1102
- else{
1103
- compType = 'components'
1104
- }
1105
- }
1106
-
1107
- switch(type){
1108
-
1109
- case 'setProp':
1110
- if(comp){
1111
- Object.assign(comp.props, value)
1112
- compType === 'components' ? this.save(false) : this.saveLayout(false)
1113
- }
1114
- break
1115
-
1116
- case 'setSubAction':
1117
- if(this.$refs.settingComponent.setSubAction)
1118
- this.$refs.settingComponent.setSubAction(value)
1119
- break
1120
-
1121
- case 'component-click':
1122
- this.store.selectedComponent = [ uid ]
1123
- break
1124
- }
1125
- })
1131
+ window.addEventListener('message', this.onMessage)
1132
+ window.addEventListener('resize', this.onResize)
1126
1133
 
1127
1134
  this.listen()
1128
1135
  this.socket.onAny(this.onHooks)
1129
1136
  },
1130
1137
 
1131
1138
  unmounted() {
1139
+ window.removeEventListener('resize', this.onResize)
1140
+ window.removeEventListener('message', this.onMessage)
1132
1141
  this.stopListen()
1142
+ this.socket.offAny(this.onHooks)
1133
1143
  },
1134
1144
 
1135
1145
  provide(){