@mixd-id/web-scaffold 0.1.230406116 → 0.1.230406118

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.230406118",
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) => {
@@ -708,6 +708,7 @@ export default{
708
708
  })
709
709
  .catch((err) => {
710
710
  this.toast(err)
711
+ this.load()
711
712
  })
712
713
  }, 300),
713
714
 
@@ -780,6 +781,51 @@ export default{
780
781
  this.$refs.iframe.contentWindow.postMessage({ uid, data }, '*')
781
782
  },
782
783
 
784
+ onMessage(event){
785
+
786
+ const { uid, type, value } = event.data ?? {}
787
+
788
+ let comp
789
+ let compType
790
+ if(uid){
791
+ comp = this.findCompByUid(uid, this.page.components)
792
+ if(!comp){
793
+ comp = this.findCompByUid(uid, this.layout.headers)
794
+ if(!comp){
795
+ comp = this.findCompByUid(uid, this.layout.footers)
796
+ if(comp){
797
+ compType = 'footers'
798
+ }
799
+ }
800
+ else{
801
+ compType = 'headers'
802
+ }
803
+ }
804
+ else{
805
+ compType = 'components'
806
+ }
807
+ }
808
+
809
+ switch(type){
810
+
811
+ case 'setProp':
812
+ if(comp){
813
+ Object.assign(comp.props, value)
814
+ compType === 'components' ? this.save(false) : this.saveLayout(false)
815
+ }
816
+ break
817
+
818
+ case 'setSubAction':
819
+ if(this.$refs.settingComponent && this.$refs.settingComponent.setSubAction)
820
+ this.$refs.settingComponent.setSubAction(value)
821
+ break
822
+
823
+ case 'component-click':
824
+ this.store.selectedComponent = [ uid ]
825
+ break
826
+ }
827
+ },
828
+
783
829
  onLayoutItemPaste(items, currentItem, newItem){
784
830
  this.onItemPaste(items, currentItem, newItem, true)
785
831
  },
@@ -823,7 +869,11 @@ export default{
823
869
 
824
870
  getPage(){
825
871
  return this.page
826
- }
872
+ },
873
+
874
+ onResize: throttle(function() {
875
+ this.resize()
876
+ }, 500, { leading:true }),
827
877
 
828
878
  },
829
879
 
@@ -1079,57 +1129,18 @@ export default{
1079
1129
  mounted() {
1080
1130
  this.load()
1081
1131
 
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
- })
1132
+ window.addEventListener('message', this.onMessage)
1133
+ window.addEventListener('resize', this.onResize)
1126
1134
 
1127
1135
  this.listen()
1128
1136
  this.socket.onAny(this.onHooks)
1129
1137
  },
1130
1138
 
1131
1139
  unmounted() {
1140
+ window.removeEventListener('resize', this.onResize)
1141
+ window.removeEventListener('message', this.onMessage)
1132
1142
  this.stopListen()
1143
+ this.socket.offAny(this.onHooks)
1133
1144
  },
1134
1145
 
1135
1146
  provide(){