w-web-perm 1.0.0

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 (101) hide show
  1. package/.editorconfig +9 -0
  2. package/.eslintignore +3 -0
  3. package/.eslintrc.js +55 -0
  4. package/.github/workflows/ci-test.yml +24 -0
  5. package/.jsdoc +25 -0
  6. package/.vscode/launch.json +21 -0
  7. package/LICENSE +21 -0
  8. package/README.md +24 -0
  9. package/SECURITY.md +5 -0
  10. package/babel.config.js +15 -0
  11. package/dist/css/app.79b4b59b.css +1 -0
  12. package/dist/css/chunk-vendors.65775501.css +5 -0
  13. package/dist/index.tmp +1 -0
  14. package/dist/js/app-legacy.954e168c.js +2 -0
  15. package/dist/js/app-legacy.954e168c.js.map +1 -0
  16. package/dist/js/app.954e168c.js +2 -0
  17. package/dist/js/app.954e168c.js.map +1 -0
  18. package/dist/js/chunk-vendors-legacy.f5f1a231.js +13 -0
  19. package/dist/js/chunk-vendors-legacy.f5f1a231.js.map +1 -0
  20. package/dist/js/chunk-vendors.f5f1a231.js +13 -0
  21. package/dist/js/chunk-vendors.f5f1a231.js.map +1 -0
  22. package/dist/w-web-perm.umd.js +7 -0
  23. package/dist/w-web-perm.umd.js.map +1 -0
  24. package/docs/WWebPerm.html +826 -0
  25. package/docs/WWebPerm.mjs.html +558 -0
  26. package/docs/fonts/Montserrat/Montserrat-Bold.eot +0 -0
  27. package/docs/fonts/Montserrat/Montserrat-Bold.ttf +0 -0
  28. package/docs/fonts/Montserrat/Montserrat-Bold.woff +0 -0
  29. package/docs/fonts/Montserrat/Montserrat-Bold.woff2 +0 -0
  30. package/docs/fonts/Montserrat/Montserrat-Regular.eot +0 -0
  31. package/docs/fonts/Montserrat/Montserrat-Regular.ttf +0 -0
  32. package/docs/fonts/Montserrat/Montserrat-Regular.woff +0 -0
  33. package/docs/fonts/Montserrat/Montserrat-Regular.woff2 +0 -0
  34. package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.eot +0 -0
  35. package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.svg +978 -0
  36. package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.ttf +0 -0
  37. package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.woff +0 -0
  38. package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.woff2 +0 -0
  39. package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.eot +0 -0
  40. package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.svg +1049 -0
  41. package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.ttf +0 -0
  42. package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.woff +0 -0
  43. package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.woff2 +0 -0
  44. package/docs/index.html +84 -0
  45. package/docs/scripts/collapse.js +39 -0
  46. package/docs/scripts/commonNav.js +28 -0
  47. package/docs/scripts/linenumber.js +25 -0
  48. package/docs/scripts/nav.js +12 -0
  49. package/docs/scripts/polyfill.js +4 -0
  50. package/docs/scripts/prettify/Apache-License-2.0.txt +202 -0
  51. package/docs/scripts/prettify/lang-css.js +2 -0
  52. package/docs/scripts/prettify/prettify.js +28 -0
  53. package/docs/scripts/search.js +99 -0
  54. package/docs/styles/jsdoc.css +776 -0
  55. package/docs/styles/prettify.css +80 -0
  56. package/g.getSettings.mjs +17 -0
  57. package/g.mDb.mjs +10 -0
  58. package/g.mInitialTestData.mjs +20 -0
  59. package/g.mOrm.mjs +24 -0
  60. package/package.json +75 -0
  61. package/public/index.html +23 -0
  62. package/server/WWebPerm.mjs +486 -0
  63. package/src/App.vue +153 -0
  64. package/src/components/Common/CheckYes.vue +85 -0
  65. package/src/components/Common/CheckYesNo.vue +91 -0
  66. package/src/components/Common/LabelItem.vue +106 -0
  67. package/src/components/Common/LoadingWinBar.vue +87 -0
  68. package/src/components/Layout.vue +152 -0
  69. package/src/components/LayoutContent.vue +246 -0
  70. package/src/components/LayoutContentGroups.vue +664 -0
  71. package/src/components/LayoutContentTargets.vue +538 -0
  72. package/src/components/LayoutContentUsers.vue +493 -0
  73. package/src/components/LayoutState.vue +91 -0
  74. package/src/components/VeUser.vue +453 -0
  75. package/src/components/ruleGroup.vue +667 -0
  76. package/src/main.js +103 -0
  77. package/src/perm.mjs +61 -0
  78. package/src/plugins/mDataSelectorSchema.mjs +30 -0
  79. package/src/plugins/mDataSupport.mjs +66 -0
  80. package/src/plugins/mShare.mjs +366 -0
  81. package/src/plugins/mUI.mjs +229 -0
  82. package/src/plugins/mVuetify.mjs +12 -0
  83. package/src/schema/gi.mjs +8 -0
  84. package/src/schema/index.mjs +20 -0
  85. package/src/schema/tables/ruleGroups.mjs +100 -0
  86. package/src/schema/tables/targets.mjs +100 -0
  87. package/src/schema/tables/users.mjs +125 -0
  88. package/src/store/actions.mjs +1 -0
  89. package/src/store/getters.mjs +1 -0
  90. package/src/store/index.mjs +25 -0
  91. package/src/store/mutations.mjs +201 -0
  92. package/src/store/types.mjs +15 -0
  93. package/srv.mjs +52 -0
  94. package/tableTags-web-perm.json +1 -0
  95. package/test/all.test.mjs +10 -0
  96. package/toolg/addVersion.mjs +4 -0
  97. package/toolg/cleanFolder.mjs +4 -0
  98. package/toolg/gDistRollup.mjs +36 -0
  99. package/toolg/genEntry.mjs +23 -0
  100. package/toolg/modifyReadme.mjs +4 -0
  101. package/vue.config.js +15 -0
@@ -0,0 +1,229 @@
1
+ import Vue from 'vue'
2
+ import min from 'lodash/min'
3
+ import size from 'lodash/size'
4
+ import take from 'lodash/take'
5
+ import isEqual from 'lodash/isEqual'
6
+ import uniq from 'lodash/uniq'
7
+ import set from 'lodash/set'
8
+ import get from 'lodash/get'
9
+ import each from 'lodash/each'
10
+ import map from 'lodash/map'
11
+ import filter from 'lodash/filter'
12
+ import last from 'lodash/last'
13
+ import split from 'lodash/split'
14
+ import join from 'lodash/join'
15
+ import drop from 'lodash/drop'
16
+ import dropRight from 'lodash/dropRight'
17
+ import groupBy from 'lodash/groupBy'
18
+ import sortBy from 'lodash/sortBy'
19
+ import cloneDeep from 'lodash/cloneDeep'
20
+ import cint from 'wsemi/src/cint.mjs'
21
+ import delay from 'wsemi/src/delay.mjs'
22
+ import isarr from 'wsemi/src/isarr.mjs'
23
+ import isestr from 'wsemi/src/isestr.mjs'
24
+ import isfun from 'wsemi/src/isfun.mjs'
25
+ import iseobj from 'wsemi/src/iseobj.mjs'
26
+ import isearr from 'wsemi/src/isearr.mjs'
27
+ import isEle from 'wsemi/src/isEle.mjs'
28
+ import strleft from 'wsemi/src/strleft.mjs'
29
+ import strdelleft from 'wsemi/src/strdelleft.mjs'
30
+ import sep from 'wsemi/src/sep.mjs'
31
+ import aes2str from 'wsemi/src/aes2str.mjs'
32
+ import str2aes from 'wsemi/src/str2aes.mjs'
33
+ import haskey from 'wsemi/src/haskey.mjs'
34
+ import genPm from 'wsemi/src/genPm.mjs'
35
+ import pmSeries from 'wsemi/src/pmSeries.mjs'
36
+ import waitFun from 'wsemi/src/waitFun.mjs'
37
+ import browserView from 'wsemi/src/browserView.mjs'
38
+ import arrHas from 'wsemi/src/arrHas.mjs'
39
+ import arrSort from 'wsemi/src/arrSort.mjs'
40
+ import arrInsert from 'wsemi/src/arrInsert.mjs'
41
+ import replace from 'wsemi/src/replace.mjs'
42
+ import timemsTZ2past from 'wsemi/src/timemsTZ2past.mjs'
43
+ import convertToTree from 'wsemi/src/convertToTree.mjs'
44
+ // import WUiDwload from 'w-ui-dwload/src/WUiDwload.mjs'
45
+
46
+
47
+ let vo = Vue.prototype
48
+
49
+
50
+ function setVo(vObj) {
51
+ vo = vObj
52
+ }
53
+
54
+
55
+ function updateConnState(connState) {
56
+ vo.$store.commit(vo.$store.types.UpdateConnState, connState)
57
+ }
58
+
59
+
60
+ function updateLoading(loading) {
61
+ vo.$store.commit(vo.$store.types.UpdateLoading, loading)
62
+ }
63
+
64
+
65
+ function updateViewState(viewState) {
66
+ vo.$store.commit(vo.$store.types.UpdateViewState, viewState)
67
+ }
68
+
69
+
70
+ function updateUserToken(userToken) {
71
+ vo.$store.commit(vo.$store.types.UpdateUserToken, userToken)
72
+ }
73
+
74
+
75
+ function updateUserSelf(userSelf) {
76
+ vo.$store.commit(vo.$store.types.UpdateUserSelf, userSelf)
77
+ }
78
+
79
+
80
+ function forceUpdate() {
81
+ // console.log('call forceUpdate')
82
+
83
+ function broadcast(chs) {
84
+ each(chs, (v) => {
85
+ // console.log(v.$el)
86
+ v.$forceUpdate()
87
+ if (v.$children) {
88
+ broadcast(v.$children)
89
+ }
90
+ })
91
+ }
92
+
93
+ //broadcast, 注意此處需使用更換ui內vo為mounted後的vo, 也就是含元素, 才能使用廣播技術
94
+ broadcast(vo.$children)
95
+
96
+ }
97
+
98
+
99
+ function setLang(lang = null) {
100
+ // console.log('call setLang')
101
+
102
+ //check lang, 若有輸入才commit
103
+ if (isestr(lang)) {
104
+ vo.$store.commit(vo.$store.types.UpdateLang, lang)
105
+ }
106
+
107
+ //getKpLang, 切換lang得調用getKpLang重算kpText
108
+ getKpLang()
109
+
110
+ //forceUpdate
111
+ forceUpdate()
112
+
113
+ }
114
+
115
+
116
+ function getKpLang() {
117
+ // console.log('call getKpLang')
118
+
119
+ //merge keyLangs
120
+ let keyLangs = get(vo, '$store.state.keyLangs')
121
+ let webName = get(vo, '$store.state.webInfor.webName')
122
+ let webDescription = get(vo, '$store.state.webInfor.webDescription')
123
+ let kls = {
124
+ ...keyLangs,
125
+ webName: {
126
+ ...webName,
127
+ },
128
+ webDescription: {
129
+ ...webDescription,
130
+ },
131
+ }
132
+
133
+ //lang
134
+ let lang = get(vo, '$store.state.lang')
135
+
136
+ //kpText
137
+ let kpText = {}
138
+ each(kls, (v, k) => {
139
+ kpText[k] = v[lang]
140
+ })
141
+
142
+ //commit
143
+ vo.$store.commit(vo.$store.types.UpdateKpText, kpText)
144
+
145
+ return kpText
146
+ }
147
+
148
+
149
+ function getKpText(key) {
150
+ // console.log('call getKpText')
151
+ let kpText = get(vo, '$store.state.kpText')
152
+ return get(kpText, key, '')
153
+ }
154
+
155
+
156
+ function gv(o, k, cv = null) {
157
+ let r = get(o, k, '')
158
+ if (!isestr(r)) {
159
+ let def = getKpText('empty')
160
+ return def
161
+ }
162
+ if (isfun(cv)) {
163
+ r = cv(r)
164
+ }
165
+ return r
166
+ }
167
+
168
+
169
+ function syncHeight() {
170
+
171
+ //heightToolbar
172
+ let heightToolbar = get(vo, '$store.state.heightToolbar')
173
+
174
+ //heightAppEff
175
+ let heightAppEff = window.innerHeight - heightToolbar
176
+
177
+ //commit
178
+ // vo.$store.commit(vo.$store.types.UpdateHeightToolbar, heightToolbar)
179
+ vo.$store.commit(vo.$store.types.UpdateHeightApp, window.innerHeight)
180
+ vo.$store.commit(vo.$store.types.UpdateHeightAppEff, heightAppEff)
181
+
182
+ return ''
183
+ }
184
+
185
+
186
+ async function waitData(t = 0) {
187
+
188
+ //delay
189
+ if (t > 0) {
190
+ await delay(t)
191
+ }
192
+
193
+ //waitFun, 等待dsrl模組掛載
194
+ await waitFun(() => {
195
+ return iseobj(get(vo, '$dsrl'))
196
+ })
197
+
198
+ //等待前端第一次同步完畢數據
199
+ await waitFun(() => {
200
+ return get(vo, '$store.state.syncState')
201
+ })
202
+
203
+ }
204
+
205
+
206
+ let mUI = {
207
+
208
+ setVo,
209
+
210
+ updateConnState,
211
+ updateLoading,
212
+ updateViewState,
213
+ updateUserToken,
214
+ updateUserSelf,
215
+ forceUpdate,
216
+
217
+ setLang,
218
+ getKpLang,
219
+ getKpText,
220
+
221
+ gv,
222
+ syncHeight,
223
+
224
+ waitData,
225
+
226
+ }
227
+
228
+
229
+ export default mUI
@@ -0,0 +1,12 @@
1
+ import Vue from 'vue'
2
+ import Vuetify from 'vuetify/lib'
3
+ // import Vuetify from 'vuetify'
4
+ // import 'vuetify/dist/vuetify.min.css'
5
+
6
+ Vue.use(Vuetify)
7
+
8
+ export default new Vuetify({
9
+ icons: {
10
+ iconfont: 'mdiSvg',
11
+ },
12
+ })
@@ -0,0 +1,8 @@
1
+ import genIndex from 'w-data-collector/src/genIndex.mjs'
2
+
3
+
4
+ //genIndex
5
+ genIndex('./src/schema/tables', './src/schema')
6
+
7
+
8
+ //node --experimental-modules --es-module-specifier-resolution=node ./src/schema/gi.mjs
@@ -0,0 +1,20 @@
1
+ import ruleGroups from './tables/ruleGroups.mjs'
2
+ import targets from './tables/targets.mjs'
3
+ import users from './tables/users.mjs'
4
+ import build from 'w-data-collector/src/build.mjs'
5
+
6
+
7
+ let cs = {
8
+ ruleGroups,
9
+ targets,
10
+ users,
11
+ }
12
+
13
+ //ds
14
+ let ds = {}
15
+ for (let k in cs) {
16
+ ds[k] = build(cs[k], { useCreateStorage: false })
17
+ }
18
+
19
+
20
+ export default ds
@@ -0,0 +1,100 @@
1
+ import map from 'lodash/map'
2
+ import keys from 'lodash/keys'
3
+ import genID from 'wsemi/src/genID.mjs'
4
+ import dtmapping from 'wsemi/src/dtmapping.mjs'
5
+ import dtpick from 'wsemi/src/dtpick.mjs'
6
+ import nowms2str from 'wsemi/src/nowms2str.mjs'
7
+ import now2strp from 'wsemi/src/now2strp.mjs'
8
+
9
+
10
+ let keyTable = 'ruleGroups'
11
+ let tableNameCht = '權限群組'
12
+ let tableNameEng = 'Rule groups'
13
+
14
+ let settings = {
15
+ id: {
16
+ pk: true,
17
+ name: '主鍵',
18
+ type: 'STRING',
19
+ },
20
+ name: {
21
+ name: '名稱',
22
+ type: 'STRING',
23
+ },
24
+ order: {
25
+ name: '順序',
26
+ type: 'INTEGER',
27
+ },
28
+ // type: { //可依照type分組
29
+ // name: '類別',
30
+ // type: 'STRING',
31
+ // },
32
+ description: {
33
+ name: '說明',
34
+ type: 'TEXT',
35
+ },
36
+ crules: {
37
+ name: '規則', //為json字串, 例如{ '___all___': {show:'y',active:'n'}, '專案A.頁A': {show:'y',active:'y'}, '專案A.頁B': {show:'n',active:'n'} }
38
+ type: 'TEXT',
39
+ },
40
+ userId: {
41
+ name: '創建使用者主鍵',
42
+ type: 'STRING',
43
+ },
44
+ timeCreate: {
45
+ name: '創建時間',
46
+ type: 'STRING',
47
+ },
48
+ userIdUpdate: {
49
+ name: '最新變更使用者主鍵',
50
+ type: 'STRING',
51
+ },
52
+ timeUpdate: {
53
+ name: '更新時間',
54
+ type: 'STRING',
55
+ },
56
+ }
57
+
58
+ let funNew = (ndata = {}) => {
59
+ let o = dtmapping(ndata, keys(settings))
60
+ o.id = `${now2strp()}-${genID()}`
61
+ o.userIdUpdate = o.userId
62
+ o.timeCreate = nowms2str()
63
+ o.timeUpdate = o.timeCreate
64
+ o.isActive = 'y'
65
+ return o
66
+ }
67
+
68
+ let funTest = () => {
69
+ let rs = [
70
+ ['權限群組1', `{ "___all___": { "show": "y", "active": "n" }, "專案A.頁A": { "show": "y", "active": "y" }, "專案A.頁B": { "show": "n", "active": "n" } }`],
71
+ ['權限群組2', `{ "___all___": { "show": "y", "active": "n" } }`],
72
+ ['權限群組3', `{ "___all___": { "show": "y", "active": "y" } }`],
73
+ // ['L0權限群組', `{ "___all___": { "show": "n", "active": "n" }, "主題列表": { "show": "y", "active": "n" } }`],
74
+ // ['L1權限群組', `{ "___all___": { "show": "y", "active": "y" } }`],
75
+ ]
76
+ rs = map(rs, ([g, crules], k) => {
77
+ let v = funNew({ userId: 'id-for-admin', crules })
78
+ v.id = `id-for-${g}`
79
+ v.name = g
80
+ v.order = k
81
+ v.description = `${g}的說明`
82
+ v = dtpick(v, keys(settings))
83
+ return v
84
+ })
85
+ console.log(`已產生: ${keyTable} 測試資料`, rs)
86
+ return rs
87
+ }
88
+
89
+ let tab = {
90
+ keyTable,
91
+ tableNameCht,
92
+ tableNameEng,
93
+ settings,
94
+ funNew,
95
+ funTest,
96
+ }
97
+
98
+
99
+ export default tab
100
+
@@ -0,0 +1,100 @@
1
+ import map from 'lodash/map'
2
+ import keys from 'lodash/keys'
3
+ import genID from 'wsemi/src/genID.mjs'
4
+ import dtmapping from 'wsemi/src/dtmapping.mjs'
5
+ import dtpick from 'wsemi/src/dtpick.mjs'
6
+ import nowms2str from 'wsemi/src/nowms2str.mjs'
7
+ import now2strp from 'wsemi/src/now2strp.mjs'
8
+
9
+
10
+ let keyTable = 'targets'
11
+ let tableNameCht = '管控對象'
12
+ let tableNameEng = 'Targets'
13
+
14
+ let settings = {
15
+ id: {
16
+ pk: true,
17
+ name: '主鍵', //儲存對象路徑, 不同階層用句點「.」分開, 可用unicode
18
+ type: 'STRING',
19
+ },
20
+ order: {
21
+ name: '順序',
22
+ type: 'INTEGER',
23
+ },
24
+ // key: {
25
+ // name: '所屬區塊識別鍊',
26
+ // type: 'STRING',
27
+ // },
28
+ // name: {
29
+ // name: '區塊名稱',
30
+ // type: 'STRING',
31
+ // },
32
+ description: {
33
+ name: '說明',
34
+ type: 'TEXT',
35
+ },
36
+ }
37
+
38
+ let funNew = (ndata = {}) => {
39
+ let o = dtmapping(ndata, keys(settings))
40
+ o.id = `${now2strp()}-${genID()}`
41
+ o.timeCreate = nowms2str()
42
+ o.timeUpdate = o.timeCreate
43
+ o.isActive = 'y'
44
+ return o
45
+ }
46
+
47
+ let funTest = () => {
48
+ let rs = [
49
+ '專案A',
50
+ '專案A.頁A',
51
+ '專案A.頁A.區塊A',
52
+ '專案A.頁A.區塊A.執行按鈕',
53
+ '專案A.頁A.區塊A.分析按鈕',
54
+ '專案A.頁B',
55
+ '專案A.頁B.區塊A',
56
+ '專案A.頁B.區塊A.執行按鈕',
57
+ '專案A.頁B.區塊A.分析按鈕',
58
+ '專案A.頁B.區塊B',
59
+ '專案A.頁B.區塊B.展開按鈕',
60
+ '專案A.頁B.區塊B.下載按鈕',
61
+ '專案B',
62
+ '專案B.頁A',
63
+ '專案B.頁A.區塊A',
64
+ '專案B.頁A.區塊A.下載報表按鈕',
65
+ '專案B.頁A.區塊A.下載數據按鈕',
66
+ '專案B.頁B.區塊A',
67
+ '專案B.頁B.區塊B',
68
+ '專案B.頁B.區塊B.顯示後台按鈕',
69
+ '專案B.頁B.區塊B.轉跳主站按鈕',
70
+ // '主題列表',
71
+ // '主題列表.隱藏已刪除',
72
+ // '主題列表.新增主題',
73
+ // '主題列表.主題排序',
74
+ // '主題列表.編輯主題',
75
+ // '主題列表.刪除主題',
76
+ // '後台管理',
77
+ // '權限管理',
78
+ ]
79
+ rs = map(rs, (key, k) => {
80
+ let v = funNew({ userId: 'id-for-admin', description: key })
81
+ v.id = `id-for-${key}`
82
+ v = dtpick(v, keys(settings))
83
+ return v
84
+ })
85
+ console.log(`已產生: ${keyTable} 測試資料`, rs)
86
+ return rs
87
+ }
88
+
89
+ let tab = {
90
+ keyTable,
91
+ tableNameCht,
92
+ tableNameEng,
93
+ settings,
94
+ funNew,
95
+ funTest,
96
+ }
97
+
98
+
99
+ export default tab
100
+
@@ -0,0 +1,125 @@
1
+ import map from 'lodash/map'
2
+ import keys from 'lodash/keys'
3
+ import genID from 'wsemi/src/genID.mjs'
4
+ import dtmapping from 'wsemi/src/dtmapping.mjs'
5
+ import dtpick from 'wsemi/src/dtpick.mjs'
6
+ import nowms2str from 'wsemi/src/nowms2str.mjs'
7
+ import now2strp from 'wsemi/src/now2strp.mjs'
8
+
9
+
10
+ let keyTable = 'users'
11
+ let tableNameCht = '使用者'
12
+ let tableNameEng = 'Users'
13
+
14
+
15
+ let settings = {
16
+ id: {
17
+ pk: true,
18
+ name: '主鍵',
19
+ type: 'STRING',
20
+ },
21
+ name: {
22
+ name: '姓名',
23
+ type: 'STRING',
24
+ },
25
+ email: {
26
+ name: '電子郵件',
27
+ type: 'STRING',
28
+ },
29
+ description: {
30
+ name: '描述',
31
+ type: 'TEXT',
32
+ },
33
+ from: {
34
+ name: '來源',
35
+ type: 'STRING',
36
+ },
37
+ ruleGroupsIds: {
38
+ name: '所屬權限群組主鍵', //多主鍵用分號區隔
39
+ type: 'STRING',
40
+ },
41
+ isVirtual: {
42
+ name: '是否為虛擬使用者', //代表由外部系統(如SSO或AD)提供之使用者
43
+ type: 'STRING',
44
+ },
45
+ isAdmin: {
46
+ name: '是否為系統管理員',
47
+ type: 'STRING',
48
+ },
49
+ userId: {
50
+ name: '創建使用者主鍵',
51
+ type: 'STRING',
52
+ },
53
+ timeCreate: {
54
+ name: '創建時間',
55
+ type: 'STRING',
56
+ },
57
+ userIdUpdate: {
58
+ name: '最新變更使用者主鍵',
59
+ type: 'STRING',
60
+ },
61
+ timeUpdate: {
62
+ name: '更新時間',
63
+ type: 'STRING',
64
+ },
65
+ isActive: {
66
+ name: '是否有效',
67
+ type: 'STRING',
68
+ },
69
+ }
70
+
71
+ let funNew = (ndata = {}) => {
72
+ let o = dtmapping(ndata, keys(settings))
73
+ o.id = `${now2strp()}-${genID()}`
74
+ o.isVirtual = 'n'
75
+ o.isAdmin = 'n'
76
+ o.userIdUpdate = o.userId
77
+ o.timeCreate = nowms2str()
78
+ o.timeUpdate = o.timeCreate
79
+ o.isActive = 'y'
80
+ return o
81
+ }
82
+
83
+ let funTest = () => {
84
+ let rs = [
85
+ '王小明',
86
+ 'peter',
87
+ 'mary',
88
+ 'john',
89
+ 'bill',
90
+ 'admin',
91
+ ]
92
+ rs = map(rs, (name, k) => {
93
+ let v = funNew({ userId: 'id-for-admin', name })
94
+ v.id = `id-for-${name}`
95
+ v.email = `${name}@example.com`
96
+ v = dtpick(v, keys(settings))
97
+ return v
98
+ })
99
+ rs[0].ruleGroupsIds = `id-for-權限群組1;id-for-權限群組2`
100
+ rs[1].ruleGroupsIds = `id-for-權限群組1`
101
+ rs[0].from = 'teamA'
102
+ rs[1].from = 'teamA'
103
+ rs[2].from = 'teamA'
104
+ rs[3].from = 'teamB'
105
+ rs[4].from = 'teamB'
106
+ rs[4].isActive = 'n'
107
+ rs[5].ruleGroupsIds = `id-for-L1權限群組`
108
+ rs[5].description = '測試系統管理員描述說明'
109
+ rs[5].isAdmin = 'y' //admin
110
+ console.log(`已產生: ${keyTable} 測試資料`, rs)
111
+ return rs
112
+ }
113
+
114
+ let tab = {
115
+ keyTable,
116
+ tableNameCht,
117
+ tableNameEng,
118
+ settings,
119
+ funNew,
120
+ funTest,
121
+ }
122
+
123
+
124
+ export default tab
125
+
@@ -0,0 +1 @@
1
+ //非同步執行, 不需要
@@ -0,0 +1 @@
1
+ //不需要
@@ -0,0 +1,25 @@
1
+ import Vue from 'vue'
2
+ import Vuex from 'vuex'
3
+ import { state, mutations } from './mutations.mjs'
4
+ import * as getters from './getters.mjs'
5
+ import * as actions from './actions.mjs'
6
+ import * as types from './types.mjs'
7
+
8
+
9
+ //use
10
+ Vue.use(Vuex)
11
+
12
+ let st = new Vuex.Store({
13
+ state,
14
+ mutations,
15
+ getters,
16
+ actions,
17
+ strict: true, //嚴格模式禁止修改state
18
+ })
19
+
20
+ //save to $store
21
+ st.types = types
22
+ Vue.prototype.$store = st
23
+ // console.log('$store', st)
24
+
25
+ export default st