vue2-client 1.0.0 → 1.2.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 (134) hide show
  1. package/.eslintrc.js +81 -81
  2. package/README.md +65 -55
  3. package/babel.config.js +15 -14
  4. package/docs/index.md +29 -29
  5. package/docs/notice.md +24 -0
  6. package/index.js +28 -0
  7. package/jest.config.js +3 -3
  8. package/package.json +1 -1
  9. package/public/index.html +27 -27
  10. package/src/App.vue +2 -2
  11. package/src/base-client/all.js +57 -57
  12. package/src/base-client/components/common/CreateQuery/CreateQuery.vue +1159 -1159
  13. package/src/base-client/components/common/CreateQuery/index.md +1 -1
  14. package/src/base-client/components/common/CreateSimpleFormQuery/CreateSimpleFormQuery.vue +540 -540
  15. package/src/base-client/components/common/CreateSimpleFormQuery/index.md +1 -1
  16. package/src/base-client/components/common/CustomColumnsDrawer/index.md +1 -1
  17. package/src/base-client/components/common/FormGroupEdit/FormGroupEdit.vue +150 -150
  18. package/src/base-client/components/common/FormGroupEdit/index.md +1 -1
  19. package/src/base-client/components/common/FormGroupQuery/index.md +1 -1
  20. package/src/base-client/components/common/XAddForm/XAddForm.vue +323 -323
  21. package/src/base-client/components/common/XAddForm/index.md +1 -1
  22. package/src/base-client/components/common/XBadge/index.md +1 -1
  23. package/src/base-client/components/common/XCard/index.md +1 -1
  24. package/src/base-client/components/common/XForm/XForm.vue +275 -275
  25. package/src/base-client/components/common/XForm/XFormItem.vue +217 -217
  26. package/src/base-client/components/common/XForm/index.md +196 -196
  27. package/src/base-client/components/common/XFormCol/index.md +1 -1
  28. package/src/base-client/components/common/XFormTable/XFormTable.vue +405 -405
  29. package/src/base-client/components/common/XFormTable/index.md +2 -2
  30. package/src/base-client/components/common/XTable/XTable.vue +262 -262
  31. package/src/base-client/components/common/XTable/index.md +255 -255
  32. package/src/base-client/components/common/XTreeOne/XTreeOne.vue +1 -1
  33. package/src/base-client/components/iot/CustomerDetailsView/CustomerDetailsView.vue +226 -226
  34. package/src/base-client/components/iot/CustomerDetailsView/index.md +2 -2
  35. package/src/base-client/components/iot/DataAnalysisUser/DataAnalysisUser.vue +1 -1
  36. package/src/base-client/components/iot/DataAnalysisViewGD/DataAnalysisViewGD.vue +548 -548
  37. package/src/base-client/components/iot/DeviceBrandDetailsView/DeviceBrandDetailsView.vue +453 -453
  38. package/src/base-client/components/iot/DeviceDetailsView/DeviceDetailsView.vue +231 -231
  39. package/src/base-client/components/iot/DeviceDetailsView/index.md +1 -1
  40. package/src/base-client/components/iot/DeviceDetailsView/part/DeviceDetailsCount.vue +330 -330
  41. package/src/base-client/components/iot/DeviceDetailsView/part/DeviceDetailsException.vue +1 -1
  42. package/src/base-client/components/iot/DeviceDetailsView/part/DeviceDetailsInstruct.vue +3 -3
  43. package/src/base-client/components/iot/DeviceDetailsView/part/DeviceDetailsInstructOperate.vue +122 -122
  44. package/src/base-client/components/iot/DeviceDetailsView/part/DeviceDetailsMain.vue +1 -1
  45. package/src/base-client/components/iot/DeviceDetailsView/part/DeviceDetailsRead.vue +3 -3
  46. package/src/base-client/components/iot/DeviceTypeDetailsView/DeviceTypeDetailsView.vue +277 -277
  47. package/src/base-client/components/iot/InstructDetailsView/InstructDetailsView.vue +472 -472
  48. package/src/base-client/components/iot/InstructDetailsView/index.md +1 -1
  49. package/src/base-client/components/iot/LogDetailsView/LogDetailsView.vue +380 -380
  50. package/src/base-client/components/iot/LogDetailsView/index.md +1 -1
  51. package/src/base-client/components/iot/MeterDetailsView/MeterDetailsView.vue +360 -360
  52. package/src/base-client/components/iot/MeterDetailsView/index.md +1 -1
  53. package/src/base-client/components/iot/MeterDetailsView/part/MeterDetailsCount.vue +335 -335
  54. package/src/base-client/components/iot/MeterDetailsView/part/MeterDetailsException.vue +185 -185
  55. package/src/base-client/components/iot/MeterDetailsView/part/MeterDetailsHandPlan.vue +292 -292
  56. package/src/base-client/components/iot/MeterDetailsView/part/MeterDetailsInstruct.vue +237 -237
  57. package/src/base-client/components/iot/MeterDetailsView/part/MeterDetailsMain.vue +257 -257
  58. package/src/base-client/components/iot/MeterDetailsView/part/MeterDetailsSellGas.vue +190 -190
  59. package/src/base-client/components/iot/WebmeterAnalysisView/WebmeterAnalysisView.vue +723 -723
  60. package/src/base-client/components/iot/WebmeterAnalysisView/index.md +1 -1
  61. package/src/base-client/components/system/DictionaryDetailsView/DictionaryDetailsView.vue +232 -232
  62. package/src/base-client/components/system/DictionaryDetailsView/index.md +1 -1
  63. package/src/base-client/components/system/QueryParamsDetailsView/QueryParamsDetailsView.vue +248 -248
  64. package/src/base-client/components/ticket/EmployeeDetailsView/EmployeeDetailsView.vue +406 -406
  65. package/src/base-client/components/ticket/TicketDetailsView/TicketDetailsView.vue +486 -486
  66. package/src/base-client/components/ticket/TicketDetailsView/part/TicketDetailsFlow.vue +184 -184
  67. package/src/base-client/components/ticket/TicketSubmitSuccessView/TicketSubmitSuccessView.vue +303 -303
  68. package/src/base-client/plugins/AppData.js +69 -69
  69. package/src/base-client/plugins/GetLoginInfoService.js +221 -222
  70. package/src/base-client/plugins/index.js +21 -21
  71. package/src/bootstrap.js +6 -4
  72. package/src/components/Ellipsis/Ellipsis.vue +1 -1
  73. package/src/components/Ellipsis/index.md +2 -2
  74. package/src/components/NumberInfo/index.md +1 -1
  75. package/src/components/STable/README.md +3 -3
  76. package/src/components/Trend/index.md +1 -1
  77. package/src/components/cache/AKeepAlive.js +1 -1
  78. package/src/components/checkbox/index.js +2 -2
  79. package/src/components/index.js +15 -15
  80. package/src/components/menu/menu.js +1 -1
  81. package/src/components/setting/Setting.vue +4 -4
  82. package/src/components/table/advance/AdvanceTable.vue +3 -3
  83. package/src/components/transition/PageToggleTransition.vue +1 -1
  84. package/src/config/default/setting.config.js +33 -33
  85. package/src/layouts/CommonLayout.vue +1 -1
  86. package/src/layouts/ComponentLayoutOne.vue +47 -47
  87. package/src/layouts/PageLayout.vue +2 -2
  88. package/src/layouts/SinglePageView.vue +1 -1
  89. package/src/layouts/header/AdminHeader.vue +2 -2
  90. package/src/layouts/header/HeaderAvatar.vue +1 -1
  91. package/src/layouts/header/HeaderNotice.vue +97 -97
  92. package/src/layouts/tabs/TabsHead.vue +1 -1
  93. package/src/layouts/tabs/TabsView.vue +6 -6
  94. package/src/main.js +20 -12
  95. package/src/mock/common/reportData.js +20 -20
  96. package/src/mock/goods/index.js +2 -2
  97. package/src/mock/index.js +6 -6
  98. package/src/mock/project/index.js +1 -1
  99. package/src/mock/user/current.js +1 -1
  100. package/src/mock/user/login.js +1 -1
  101. package/src/mock/user/routes.js +61 -61
  102. package/src/mock/workplace/index.js +1 -1
  103. package/src/pages/exception/403.vue +25 -25
  104. package/src/pages/exception/404.vue +25 -25
  105. package/src/pages/exception/500.vue +25 -25
  106. package/src/pages/login/Login.vue +194 -194
  107. package/src/pages/report/ReportTable.js +125 -125
  108. package/src/pages/report/ReportTableHome.vue +28 -28
  109. package/src/pages/resourceManage/resourceManageMain.vue +55 -55
  110. package/src/pages/system/applyInstallView/Core.vue +1 -1
  111. package/src/pages/system/applyInstallView/index.vue +1 -1
  112. package/src/pages/system/dictionary/index.vue +1 -1
  113. package/src/pages/system/queryParams/index.vue +1 -1
  114. package/src/router/async/config.async.js +1 -1
  115. package/src/router/async/router.map.js +59 -59
  116. package/src/router/guards.js +3 -3
  117. package/src/router/index.js +4 -8
  118. package/src/services/api/common.js +39 -39
  119. package/src/services/api/restTools.js +23 -23
  120. package/src/services/dataSource.js +1 -1
  121. package/src/services/user.js +2 -2
  122. package/src/store/index.js +3 -6
  123. package/src/store/modules/setting.js +5 -5
  124. package/src/theme/index.less +5 -5
  125. package/src/theme/reportTable.less +58 -58
  126. package/src/utils/i18n.js +2 -2
  127. package/src/utils/indexedDB.js +146 -146
  128. package/src/utils/request.js +3 -3
  129. package/src/utils/routerUtil.js +18 -5
  130. package/tests/unit/ReportTable.spec.js +15 -15
  131. package/vue.config.js +153 -152
  132. package/webpack.config.js +12 -0
  133. package/src/index.js +0 -29
  134. package/src/router/config.js +0 -23
@@ -1,194 +1,194 @@
1
- <template>
2
- <common-layout>
3
- <div class="top">
4
- <div class="header">
5
- <img alt="logo" class="logo" src="@/assets/img/logo.png" />
6
- <span class="title">{{ systemName }}</span>
7
- </div>
8
- <div class="desc">为物联网设备的兼容、监控和统计提供支持</div>
9
- </div>
10
- <div class="login">
11
- <a-form @submit="onSubmit" :form="form">
12
- <a-tabs size="large" :tabBarStyle="{textAlign: 'center'}" style="padding: 0 2px;">
13
- <a-tab-pane tab="账户密码登录" key="1">
14
- <a-alert
15
- type="error"
16
- :closable="true"
17
- v-show="error"
18
- :message="error"
19
- showIcon
20
- style="margin-bottom: 24px;" />
21
- <a-form-item>
22
- <a-input
23
- autocomplete="autocomplete"
24
- size="large"
25
- placeholder="admin"
26
- v-decorator="['name', {rules: [{ required: true, message: '请输入账户名', whitespace: true}]}]"
27
- >
28
- <a-icon slot="prefix" type="user" />
29
- </a-input>
30
- </a-form-item>
31
- <a-form-item>
32
- <a-input
33
- size="large"
34
- placeholder="888888"
35
- autocomplete="autocomplete"
36
- type="password"
37
- v-decorator="['password', {rules: [{ required: true, message: '请输入密码', whitespace: true}]}]"
38
- >
39
- <a-icon slot="prefix" type="lock" />
40
- </a-input>
41
- </a-form-item>
42
- </a-tab-pane>
43
- </a-tabs>
44
- <div>
45
- <a-checkbox :checked="true" >自动登录</a-checkbox>
46
- </div>
47
- <a-form-item>
48
- <a-button :loading="logging" style="width: 100%;margin-top: 24px" size="large" htmlType="submit" type="primary">登录</a-button>
49
- </a-form-item>
50
- </a-form>
51
- </div>
52
- </common-layout>
53
- </template>
54
-
55
- <script>
56
- import CommonLayout from '@/layouts/CommonLayout'
57
- import { getRoutesConfig, login } from '@/services/user'
58
- import { setAuthorization } from '@/utils/request'
59
- import { loadRoutes, funcToRouter } from '@/utils/routerUtil'
60
- import { mapMutations } from 'vuex'
61
- import JSEncrypt from 'jsencrypt'
62
- import { ACCESS_TOKEN } from '@/store/mutation-types'
63
- import Vue from 'vue'
64
- import Mock from 'mockjs'
65
- import { positions } from '@/mock/common'
66
- const { homePage } = require('@/config')
67
- // import { router } from '@/mock/user/routes'
68
-
69
- export default {
70
- name: 'Login',
71
- components: { CommonLayout },
72
- data () {
73
- return {
74
- logging: false,
75
- error: '',
76
- form: this.$form.createForm(this)
77
- }
78
- },
79
- computed: {
80
- systemName () {
81
- return this.$store.state.setting.systemName
82
- }
83
- },
84
- methods: {
85
- ...mapMutations('account', ['setUser', 'setPermissions', 'setRoles']),
86
- onSubmit (e) {
87
- e.preventDefault()
88
- this.form.validateFields((err) => {
89
- if (!err) {
90
- this.logging = true
91
- const name = this.form.getFieldValue('name')
92
- const password = this.form.getFieldValue('password')
93
- login(name, password).then(this.afterLogin)
94
- }
95
- })
96
- },
97
- afterLogin (res) {
98
- const name = this.form.getFieldValue('name')
99
- const password = this.form.getFieldValue('password')
100
- this.logging = false
101
- const loginRes = res.states
102
- if (loginRes === '登录成功') {
103
- const encrypt = new JSEncrypt()
104
- encrypt.setPublicKey('MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCqPvovSfXcwBbW8cKMCgwqNpsYuzF8RPAPFb7LGsnVo44JhM/xxzDyzoYtdfNmtbIuKVi9PzIsyp6rg+09gbuI6UGwBZ5DWBDBMqv5MPdOF5dCQkB2Bbr5yPfURPENypUz+pBFBg41d+BC+rwRiXELwKy7Y9caD/MtJyHydj8OUwIDAQAB')
105
- const data = encrypt.encrypt(JSON.stringify({ username: name, password: password }))
106
- localStorage.setItem(ACCESS_TOKEN, data)
107
- // 获取路由配置
108
- getRoutesConfig(data).then(result => {
109
- Vue.$login.login(result).then(() => {
110
- const user = Object.assign({
111
- username: result.ename,
112
- name: result.name,
113
- avatar: 'https://gw.alipayobjects.com/zos/rmsportal/jZUIxmJycoymBprLOUbT.png',
114
- address: '西安市',
115
- position: positions[0]
116
- }, result)
117
- this.setUser(user)
118
- this.setPermissions([{ id: 'queryForm', operation: ['add', 'edit'] }])
119
- this.setRoles([{ id: 'admin', operation: ['add', 'edit', 'delete'] }])
120
- let timestamp = new Date().getTime()// 当前的时间戳
121
- timestamp = timestamp + 60 * 60 * 1000
122
- // 格式化时间获取年月日, 登陆过期时间
123
- const dateAfter = new Date(timestamp)
124
- setAuthorization({ token: data, expireAt: dateAfter })
125
- loadRoutes(funcToRouter(user.functions))
126
- this.$router.push(homePage).catch(() => {})
127
- this.$message.success(Mock.mock('@TIMEFIX').CN + ',欢迎回来', 3)
128
- })
129
- })
130
- } else {
131
- this.error = loginRes
132
- }
133
- }
134
- }
135
- }
136
- </script>
137
-
138
- <style lang="less" scoped>
139
- .common-layout{
140
- .top {
141
- text-align: center;
142
- .header {
143
- height: 44px;
144
- line-height: 44px;
145
- a {
146
- text-decoration: none;
147
- }
148
- .logo {
149
- height: 44px;
150
- vertical-align: top;
151
- margin-right: 16px;
152
- }
153
- .title {
154
- font-size: 33px;
155
- color: @title-color;
156
- font-family: 'Myriad Pro', 'Helvetica Neue', Arial, Helvetica, sans-serif;
157
- font-weight: 600;
158
- position: relative;
159
- top: 2px;
160
- }
161
- }
162
- .desc {
163
- font-size: 14px;
164
- color: @text-color-second;
165
- margin-top: 12px;
166
- margin-bottom: 40px;
167
- }
168
- }
169
- .login{
170
- width: 368px;
171
- margin: 0 auto;
172
- @media screen and (max-width: 576px) {
173
- width: 95%;
174
- }
175
- @media screen and (max-width: 320px) {
176
- .captcha-button{
177
- font-size: 14px;
178
- }
179
- }
180
- .icon {
181
- font-size: 24px;
182
- color: @text-color-second;
183
- margin-left: 16px;
184
- vertical-align: middle;
185
- cursor: pointer;
186
- transition: color 0.3s;
187
-
188
- &:hover {
189
- color: @primary-color;
190
- }
191
- }
192
- }
193
- }
194
- </style>
1
+ <template>
2
+ <common-layout>
3
+ <div class="top">
4
+ <div class="header">
5
+ <img alt="logo" class="logo" src="@/assets/img/logo.png" />
6
+ <span class="title">{{ systemName }}</span>
7
+ </div>
8
+ <div class="desc">为物联网设备的兼容、监控和统计提供支持</div>
9
+ </div>
10
+ <div class="login">
11
+ <a-form @submit="onSubmit" :form="form">
12
+ <a-tabs size="large" :tabBarStyle="{textAlign: 'center'}" style="padding: 0 2px;">
13
+ <a-tab-pane tab="账户密码登录" key="1">
14
+ <a-alert
15
+ type="error"
16
+ :closable="true"
17
+ v-show="error"
18
+ :message="error"
19
+ showIcon
20
+ style="margin-bottom: 24px;" />
21
+ <a-form-item>
22
+ <a-input
23
+ autocomplete="autocomplete"
24
+ size="large"
25
+ placeholder="admin"
26
+ v-decorator="['name', {rules: [{ required: true, message: '请输入账户名', whitespace: true}]}]"
27
+ >
28
+ <a-icon slot="prefix" type="user" />
29
+ </a-input>
30
+ </a-form-item>
31
+ <a-form-item>
32
+ <a-input
33
+ size="large"
34
+ placeholder="888888"
35
+ autocomplete="autocomplete"
36
+ type="password"
37
+ v-decorator="['password', {rules: [{ required: true, message: '请输入密码', whitespace: true}]}]"
38
+ >
39
+ <a-icon slot="prefix" type="lock" />
40
+ </a-input>
41
+ </a-form-item>
42
+ </a-tab-pane>
43
+ </a-tabs>
44
+ <div>
45
+ <a-checkbox :checked="true" >自动登录</a-checkbox>
46
+ </div>
47
+ <a-form-item>
48
+ <a-button :loading="logging" style="width: 100%;margin-top: 24px" size="large" htmlType="submit" type="primary">登录</a-button>
49
+ </a-form-item>
50
+ </a-form>
51
+ </div>
52
+ </common-layout>
53
+ </template>
54
+
55
+ <script>
56
+ import CommonLayout from '@vue2-client/layouts/CommonLayout'
57
+ import { getRoutesConfig, login } from '@vue2-client/services/user'
58
+ import { setAuthorization } from '@vue2-client/utils/request'
59
+ import { loadRoutes, funcToRouter } from '@vue2-client/utils/routerUtil'
60
+ import { mapMutations } from 'vuex'
61
+ import JSEncrypt from 'jsencrypt'
62
+ import { ACCESS_TOKEN } from '@vue2-client/store/mutation-types'
63
+ import Vue from 'vue'
64
+ import Mock from 'mockjs'
65
+ import { positions } from '@vue2-client/mock/common'
66
+ const { homePage } = require('@vue2-client/config')
67
+ // import { router } from '@vue2-client/mock/user/routes'
68
+
69
+ export default {
70
+ name: 'Login',
71
+ components: { CommonLayout },
72
+ data () {
73
+ return {
74
+ logging: false,
75
+ error: '',
76
+ form: this.$form.createForm(this)
77
+ }
78
+ },
79
+ computed: {
80
+ systemName () {
81
+ return this.$store.state.setting.systemName
82
+ }
83
+ },
84
+ methods: {
85
+ ...mapMutations('account', ['setUser', 'setPermissions', 'setRoles']),
86
+ onSubmit (e) {
87
+ e.preventDefault()
88
+ this.form.validateFields((err) => {
89
+ if (!err) {
90
+ this.logging = true
91
+ const name = this.form.getFieldValue('name')
92
+ const password = this.form.getFieldValue('password')
93
+ login(name, password).then(this.afterLogin)
94
+ }
95
+ })
96
+ },
97
+ afterLogin (res) {
98
+ const name = this.form.getFieldValue('name')
99
+ const password = this.form.getFieldValue('password')
100
+ this.logging = false
101
+ const loginRes = res.states
102
+ if (loginRes === '登录成功') {
103
+ const encrypt = new JSEncrypt()
104
+ encrypt.setPublicKey('MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCqPvovSfXcwBbW8cKMCgwqNpsYuzF8RPAPFb7LGsnVo44JhM/xxzDyzoYtdfNmtbIuKVi9PzIsyp6rg+09gbuI6UGwBZ5DWBDBMqv5MPdOF5dCQkB2Bbr5yPfURPENypUz+pBFBg41d+BC+rwRiXELwKy7Y9caD/MtJyHydj8OUwIDAQAB')
105
+ const data = encrypt.encrypt(JSON.stringify({ username: name, password: password }))
106
+ localStorage.setItem(ACCESS_TOKEN, data)
107
+ // 获取路由配置
108
+ getRoutesConfig(data).then(result => {
109
+ Vue.$login.login(result).then(() => {
110
+ const user = Object.assign({
111
+ username: result.ename,
112
+ name: result.name,
113
+ avatar: 'https://gw.alipayobjects.com/zos/rmsportal/jZUIxmJycoymBprLOUbT.png',
114
+ address: '西安市',
115
+ position: positions[0]
116
+ }, result)
117
+ this.setUser(user)
118
+ this.setPermissions([{ id: 'queryForm', operation: ['add', 'edit'] }])
119
+ this.setRoles([{ id: 'admin', operation: ['add', 'edit', 'delete'] }])
120
+ let timestamp = new Date().getTime()// 当前的时间戳
121
+ timestamp = timestamp + 60 * 60 * 1000
122
+ // 格式化时间获取年月日, 登陆过期时间
123
+ const dateAfter = new Date(timestamp)
124
+ setAuthorization({ token: data, expireAt: dateAfter })
125
+ loadRoutes(funcToRouter(user.functions))
126
+ this.$router.push(homePage).catch(() => {})
127
+ this.$message.success(Mock.mock('@TIMEFIX').CN + ',欢迎回来', 3)
128
+ })
129
+ })
130
+ } else {
131
+ this.error = loginRes
132
+ }
133
+ }
134
+ }
135
+ }
136
+ </script>
137
+
138
+ <style lang="less" scoped>
139
+ .common-layout{
140
+ .top {
141
+ text-align: center;
142
+ .header {
143
+ height: 44px;
144
+ line-height: 44px;
145
+ a {
146
+ text-decoration: none;
147
+ }
148
+ .logo {
149
+ height: 44px;
150
+ vertical-align: top;
151
+ margin-right: 16px;
152
+ }
153
+ .title {
154
+ font-size: 33px;
155
+ color: @title-color;
156
+ font-family: 'Myriad Pro', 'Helvetica Neue', Arial, Helvetica, sans-serif;
157
+ font-weight: 600;
158
+ position: relative;
159
+ top: 2px;
160
+ }
161
+ }
162
+ .desc {
163
+ font-size: 14px;
164
+ color: @text-color-second;
165
+ margin-top: 12px;
166
+ margin-bottom: 40px;
167
+ }
168
+ }
169
+ .login{
170
+ width: 368px;
171
+ margin: 0 auto;
172
+ @media screen and (max-width: 576px) {
173
+ width: 95%;
174
+ }
175
+ @media screen and (max-width: 320px) {
176
+ .captcha-button{
177
+ font-size: 14px;
178
+ }
179
+ }
180
+ .icon {
181
+ font-size: 24px;
182
+ color: @text-color-second;
183
+ margin-left: 16px;
184
+ vertical-align: middle;
185
+ cursor: pointer;
186
+ transition: color 0.3s;
187
+
188
+ &:hover {
189
+ color: @primary-color;
190
+ }
191
+ }
192
+ }
193
+ }
194
+ </style>
@@ -1,125 +1,125 @@
1
- export default {
2
- name: 'ReportTable',
3
- functional: true,
4
- render (h, content) {
5
- if (!content.props.tableData) {
6
- console.log('没有报表数据')
7
- return
8
- }
9
- console.log('content=>', content)
10
- const html = reportCompute(h, content.props.tableData)
11
- console.log('html=>', html)
12
- // 报表整体高度和宽度
13
- const reportClass = `h-${html.h} w-${html.w}`
14
- const report = (
15
- <div id='ReportTableHome'>
16
- <div id='reportTable' class={reportClass}>
17
- {html.el}
18
- </div>
19
- </div>
20
- )
21
- return report
22
- }
23
- }
24
- /**
25
- * class类生成
26
- * @param w 宽
27
- * @param h 高
28
- * @param l left
29
- * @param t top
30
- * @returns {string}
31
- */
32
- function generClass ({ w = 1, h = 1, l, t }) {
33
- return `w-${w} h-${h} l-${l} t-${t}`
34
- }
35
- /**
36
- * 判断是否是个Number数据
37
- * @param value
38
- * @returns {boolean}
39
- */
40
- function typeNumber (value) {
41
- return Object.prototype.toString.call(value) === '[object Number]'
42
- }
43
- /**
44
- * 判断是否是个object数据
45
- * @param value
46
- * @returns {boolean}
47
- */
48
- function typeObject (value) {
49
- return Object.prototype.toString.call(value) === '[object Object]'
50
- }
51
- /**
52
- * 判断是否是个Array数据
53
- * @param value
54
- * @returns {boolean}
55
- */
56
- function typeArray (value) {
57
- return Object.prototype.toString.call(value) === '[object Array]'
58
- }
59
- /**
60
- * 一行数据转换html函数
61
- * @param h vue的h
62
- * @param row 一行json数据
63
- * @param left 起始left距离
64
- * @param top 起始top距离
65
- * @returns {{el: Array, h: number}}
66
- */
67
- function rowCompute (h, row, left, top) {
68
- if (typeObject(row)) {
69
- const el = []
70
- const keys = Object.keys(row).filter((res) => res != 'span')
71
- let heigth = 0
72
- for (const key of keys.values()) {
73
- const value = row[key]['value'] ? row[key]['value'] : row[key]
74
- const style = { l: left, t: top + heigth }
75
- style.w = row[key]['span'] ? row[key]['span'] : 1
76
- const nextL = left + style.w
77
- const nextT = top + heigth
78
- const divObject = rowCompute(h, value, nextL, nextT)
79
- el.push(divObject.el)
80
- style.h = divObject.h ? divObject.h : 1
81
- heigth += style.h
82
- const attrs = { class: generClass(style) + ' title' }
83
- const div = <div {...attrs}>{key == 'value' ? value : key}</div>
84
- el.push(div)
85
- }
86
- return { h: heigth, el: el }
87
- } else if (typeArray(row)) {
88
- const el = []
89
- for (const [i, value] of row.entries()) {
90
- const style = { l: (left + i), t: top, w: 1, h: 1 }
91
- const extraClass = typeNumber(value) ? 'bold' : 'title'
92
- const attrs = { class: generClass(style) + ` ${extraClass}` }
93
- const div = <div {...attrs}>{value}</div>
94
- el.push(div)
95
- }
96
- return { h: 1, el: el }
97
- }
98
- }
99
- /**
100
- * 完整报表数据转换html函数
101
- * @param h vue的h
102
- * @param jsonArr json数组
103
- * @returns {{el: Array, h: number}}
104
- */
105
- function reportCompute (h, jsonArr) {
106
- const html = []
107
- let heigth = 0
108
- let width = 0
109
- for (const [index, row] of jsonArr.entries()) {
110
- const rowHtml = rowCompute(h, row, 0, index)
111
- // 取第一行的宽度作为整个报表的宽度
112
- if (index == 0) {
113
- const reg = /w-\d\s/
114
- for (const vNode of rowHtml.el) {
115
- if (!vNode.data || !vNode.data.class) continue
116
- const c = vNode.data.class
117
- const w = c.match(reg)[0].split('-')[1]
118
- width += (w - 0)
119
- }
120
- }
121
- heigth += rowHtml.h
122
- html.push(rowHtml.el)
123
- }
124
- return { el: html, h: heigth, w: width }
125
- }
1
+ export default {
2
+ name: 'ReportTable',
3
+ functional: true,
4
+ render (h, content) {
5
+ if (!content.props.tableData) {
6
+ console.log('没有报表数据')
7
+ return
8
+ }
9
+ console.log('content=>', content)
10
+ const html = reportCompute(h, content.props.tableData)
11
+ console.log('html=>', html)
12
+ // 报表整体高度和宽度
13
+ const reportClass = `h-${html.h} w-${html.w}`
14
+ const report = (
15
+ <div id='ReportTableHome'>
16
+ <div id='reportTable' class={reportClass}>
17
+ {html.el}
18
+ </div>
19
+ </div>
20
+ )
21
+ return report
22
+ }
23
+ }
24
+ /**
25
+ * class类生成
26
+ * @param w 宽
27
+ * @param h 高
28
+ * @param l left
29
+ * @param t top
30
+ * @returns {string}
31
+ */
32
+ function generClass ({ w = 1, h = 1, l, t }) {
33
+ return `w-${w} h-${h} l-${l} t-${t}`
34
+ }
35
+ /**
36
+ * 判断是否是个Number数据
37
+ * @param value
38
+ * @returns {boolean}
39
+ */
40
+ function typeNumber (value) {
41
+ return Object.prototype.toString.call(value) === '[object Number]'
42
+ }
43
+ /**
44
+ * 判断是否是个object数据
45
+ * @param value
46
+ * @returns {boolean}
47
+ */
48
+ function typeObject (value) {
49
+ return Object.prototype.toString.call(value) === '[object Object]'
50
+ }
51
+ /**
52
+ * 判断是否是个Array数据
53
+ * @param value
54
+ * @returns {boolean}
55
+ */
56
+ function typeArray (value) {
57
+ return Object.prototype.toString.call(value) === '[object Array]'
58
+ }
59
+ /**
60
+ * 一行数据转换html函数
61
+ * @param h vue的h
62
+ * @param row 一行json数据
63
+ * @param left 起始left距离
64
+ * @param top 起始top距离
65
+ * @returns {{el: Array, h: number}}
66
+ */
67
+ function rowCompute (h, row, left, top) {
68
+ if (typeObject(row)) {
69
+ const el = []
70
+ const keys = Object.keys(row).filter((res) => res != 'span')
71
+ let heigth = 0
72
+ for (const key of keys.values()) {
73
+ const value = row[key]['value'] ? row[key]['value'] : row[key]
74
+ const style = { l: left, t: top + heigth }
75
+ style.w = row[key]['span'] ? row[key]['span'] : 1
76
+ const nextL = left + style.w
77
+ const nextT = top + heigth
78
+ const divObject = rowCompute(h, value, nextL, nextT)
79
+ el.push(divObject.el)
80
+ style.h = divObject.h ? divObject.h : 1
81
+ heigth += style.h
82
+ const attrs = { class: generClass(style) + ' title' }
83
+ const div = <div {...attrs}>{key == 'value' ? value : key}</div>
84
+ el.push(div)
85
+ }
86
+ return { h: heigth, el: el }
87
+ } else if (typeArray(row)) {
88
+ const el = []
89
+ for (const [i, value] of row.entries()) {
90
+ const style = { l: (left + i), t: top, w: 1, h: 1 }
91
+ const extraClass = typeNumber(value) ? 'bold' : 'title'
92
+ const attrs = { class: generClass(style) + ` ${extraClass}` }
93
+ const div = <div {...attrs}>{value}</div>
94
+ el.push(div)
95
+ }
96
+ return { h: 1, el: el }
97
+ }
98
+ }
99
+ /**
100
+ * 完整报表数据转换html函数
101
+ * @param h vue的h
102
+ * @param jsonArr json数组
103
+ * @returns {{el: Array, h: number}}
104
+ */
105
+ function reportCompute (h, jsonArr) {
106
+ const html = []
107
+ let heigth = 0
108
+ let width = 0
109
+ for (const [index, row] of jsonArr.entries()) {
110
+ const rowHtml = rowCompute(h, row, 0, index)
111
+ // 取第一行的宽度作为整个报表的宽度
112
+ if (index == 0) {
113
+ const reg = /w-\d\s/
114
+ for (const vNode of rowHtml.el) {
115
+ if (!vNode.data || !vNode.data.class) continue
116
+ const c = vNode.data.class
117
+ const w = c.match(reg)[0].split('-')[1]
118
+ width += (w - 0)
119
+ }
120
+ }
121
+ heigth += rowHtml.h
122
+ html.push(rowHtml.el)
123
+ }
124
+ return { el: html, h: heigth, w: width }
125
+ }