w-web-sso 1.0.13 → 1.0.15
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/db/wsso/ips/data.mdb +0 -0
- package/db/wsso/ips/lock.mdb +0 -0
- package/db/wsso/tokens/data.mdb +0 -0
- package/db/wsso/tokens/lock.mdb +0 -0
- package/db/wsso/users/data.mdb +0 -0
- package/db/wsso/users/lock.mdb +0 -0
- package/dist/css/{app.03a2f95c.css → app.e4367a2b.css} +1 -1
- package/dist/index.tmp +6 -2
- package/dist/js/app-legacy.4ebeee34.js +2 -0
- package/dist/js/app-legacy.4ebeee34.js.map +1 -0
- package/dist/js/app.d1707f92.js +2 -0
- package/dist/js/app.d1707f92.js.map +1 -0
- package/dist/js/chunk-vendors-legacy.7380957a.js +15 -0
- package/dist/js/chunk-vendors-legacy.7380957a.js.map +1 -0
- package/dist/js/chunk-vendors.7380957a.js +15 -0
- package/dist/js/chunk-vendors.7380957a.js.map +1 -0
- package/dist/w-web-sso.umd.js +2 -2
- package/dist/w-web-sso.umd.js.map +1 -1
- package/docs/WWebSso.html +4 -112
- package/docs/WWebSso.mjs.html +460 -111
- package/docs/index.html +1 -1
- package/g.getSettings.mjs +0 -1
- package/g.initialData.mjs +8 -10
- package/g.mjs +0 -0
- package/package.json +7 -6
- package/public/index.html +13 -0
- package/server/WWebSso.mjs +459 -110
- package/server/procCore.mjs +871 -277
- package/server/procProtect.mjs +746 -0
- package/server/procStaInfor.mjs +393 -0
- package/server/provideUsers.mjs +0 -1
- package/server/srlog.mjs +12 -0
- package/server/staLogs/staIp.callWorker.mjs +35 -0
- package/server/staLogs/staIp.mjs +118 -0
- package/server/staLogs/staIp.shellWorker.mjs +18 -0
- package/server/staLogs/staToken.callWorker.mjs +35 -0
- package/server/staLogs/staToken.mjs +118 -0
- package/server/staLogs/staToken.shellWorker.mjs +18 -0
- package/server/staLogs/staUserAccountLogin.callWorker.mjs +35 -0
- package/server/staLogs/staUserAccountLogin.mjs +136 -0
- package/server/staLogs/staUserAccountLogin.shellWorker.mjs +18 -0
- package/server/staLogs/test_staIp.mjs +27 -0
- package/server/staLogs/test_staToken.mjs +27 -0
- package/server/staLogs/test_staUserAccountLogin.mjs +30 -0
- package/settings.json +15 -1
- package/src/components/Layout.vue +70 -15
- package/src/components/LayoutContent.vue +35 -33
- package/src/components/LayoutContentIps.vue +757 -0
- package/src/components/LayoutContentStaInfor.vue +917 -0
- package/src/components/LayoutContentTokens.vue +961 -0
- package/src/components/{LayoutContentInfor.vue → LayoutContentUserInfor.vue} +366 -73
- package/src/components/LayoutContentUsers.vue +21 -34
- package/src/components/PageLogin.vue +1 -1
- package/src/components/VeUser.vue.txt +9 -10
- package/src/components/ruleGroup.vue.txt +5 -6
- package/src/main.js +7 -13
- package/src/plugins/mLang.mjs +853 -520
- package/src/plugins/mShare.mjs +141 -3
- package/src/plugins/mUI.mjs +30 -21
- package/src/schema/index.mjs +2 -0
- package/src/schema/tables/ips.mjs +0 -9
- package/src/schema/tables/tokens.mjs +5 -1
- package/src/schema/tables/users.mjs +2 -14
- package/src/store/mutations.mjs +3 -3
- package/src/store/types.mjs +1 -1
- package/srv.mjs +55 -38
- package/_/350/246/217/345/212/203.md +0 -275
- package/dist/js/app-legacy.d468ef7f.js +0 -2
- package/dist/js/app-legacy.d468ef7f.js.map +0 -1
- package/dist/js/app.d468ef7f.js +0 -2
- package/dist/js/app.d468ef7f.js.map +0 -1
- package/dist/js/chunk-vendors-legacy.f51f58bb.js +0 -13
- package/dist/js/chunk-vendors-legacy.f51f58bb.js.map +0 -1
- package/dist/js/chunk-vendors.f51f58bb.js +0 -13
- package/dist/js/chunk-vendors.f51f58bb.js.map +0 -1
- package/src/components/LayoutContentSettings.vue +0 -1248
|
@@ -0,0 +1,757 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div
|
|
3
|
+
style="height:100%;"
|
|
4
|
+
v-domresize
|
|
5
|
+
@domresize="resizePanel"
|
|
6
|
+
:changeParams="changeParams"
|
|
7
|
+
>
|
|
8
|
+
|
|
9
|
+
<div
|
|
10
|
+
style="background:#fff;"
|
|
11
|
+
v-domresize
|
|
12
|
+
@domresize="resizeHead"
|
|
13
|
+
>
|
|
14
|
+
|
|
15
|
+
<!-- 標題區 -->
|
|
16
|
+
<div style="padding:10px 10px 10px 20px;">
|
|
17
|
+
<div :style="`display:flex; align-items:center; padding:${drawer?'5px':'5px 5px 5px 20px'};`">
|
|
18
|
+
|
|
19
|
+
<WIcon
|
|
20
|
+
:icon="mdiIpNetwork"
|
|
21
|
+
:color="'#000'"
|
|
22
|
+
:size="32"
|
|
23
|
+
></WIcon>
|
|
24
|
+
|
|
25
|
+
<div style="padding-left:12px;">
|
|
26
|
+
|
|
27
|
+
<div style="font-size:1.4rem; color:#000;">
|
|
28
|
+
{{$t('mmIpsList')}}
|
|
29
|
+
</div>
|
|
30
|
+
|
|
31
|
+
<div style="padding-top:2px; font-size:0.8rem; color:#666;">
|
|
32
|
+
{{$t('mmIpsListMsg')}}
|
|
33
|
+
</div>
|
|
34
|
+
|
|
35
|
+
</div>
|
|
36
|
+
|
|
37
|
+
</div>
|
|
38
|
+
</div>
|
|
39
|
+
|
|
40
|
+
<!-- 功能區 -->
|
|
41
|
+
<div
|
|
42
|
+
style="padding:5px; border-top:1px solid #ddd; display:flex; align-items:center;"
|
|
43
|
+
_v-if="showIsEditable || isEditable"
|
|
44
|
+
>
|
|
45
|
+
|
|
46
|
+
<template v-if="showIsEditable">
|
|
47
|
+
|
|
48
|
+
<div style="padding:6px 0px 4px 4px;">
|
|
49
|
+
<WSwitch
|
|
50
|
+
v-model="isEditable"
|
|
51
|
+
:text="$t('modeEdit')"
|
|
52
|
+
></WSwitch>
|
|
53
|
+
</div>
|
|
54
|
+
|
|
55
|
+
<div style="padding-left:10px;"></div>
|
|
56
|
+
|
|
57
|
+
</template>
|
|
58
|
+
|
|
59
|
+
<template v-if="true">
|
|
60
|
+
|
|
61
|
+
<WPopup
|
|
62
|
+
:isolated="true"
|
|
63
|
+
_show=""
|
|
64
|
+
_hide=""
|
|
65
|
+
>
|
|
66
|
+
<template v-slot:trigger>
|
|
67
|
+
<WButtonCircle
|
|
68
|
+
:paddingStyle="{v:6,h:6}"
|
|
69
|
+
:tooltip="$t('showTabCols')"
|
|
70
|
+
:icon="mdiTableHeadersEye"
|
|
71
|
+
:backgroundColor="'#fff'"
|
|
72
|
+
:backgroundColorHover="'#f2f2f2'"
|
|
73
|
+
:iconColor="'#444'"
|
|
74
|
+
:iconColorHover="'#222'"
|
|
75
|
+
:iconColorFocus="'#222'"
|
|
76
|
+
:shadow="false"
|
|
77
|
+
_click=""
|
|
78
|
+
></WButtonCircle>
|
|
79
|
+
</template>
|
|
80
|
+
|
|
81
|
+
<template v-slot:content>
|
|
82
|
+
<div style="padding:10px 0px 10px 0px;">
|
|
83
|
+
|
|
84
|
+
<div style="padding:7px 10px; font-size:0.85rem; color:#222; background:#f2f2f2;">
|
|
85
|
+
{{$t('showTabCols')}}
|
|
86
|
+
</div>
|
|
87
|
+
|
|
88
|
+
<div style="padding:7px 9px 0px 7px;">
|
|
89
|
+
<WInputCheckbox
|
|
90
|
+
:items="tabKeysPick"
|
|
91
|
+
v-model="tabKeysShow"
|
|
92
|
+
@input="toggleTabKeys"
|
|
93
|
+
>
|
|
94
|
+
<template v-slot="props">
|
|
95
|
+
<div style="padding-left:3px; display:flex; align-items:center; font-size:0.85rem; height:24px; cursor:pointer;">
|
|
96
|
+
{{getHead(props.item.data)}}
|
|
97
|
+
</div>
|
|
98
|
+
</template>
|
|
99
|
+
</WInputCheckbox>
|
|
100
|
+
</div>
|
|
101
|
+
|
|
102
|
+
</div>
|
|
103
|
+
</template>
|
|
104
|
+
</WPopup>
|
|
105
|
+
|
|
106
|
+
<div style="padding-left:4px;"></div>
|
|
107
|
+
|
|
108
|
+
</template>
|
|
109
|
+
|
|
110
|
+
<template v-if="isEditable && hasItemsCheck">
|
|
111
|
+
|
|
112
|
+
<WButtonCircle
|
|
113
|
+
:paddingStyle="{v:6,h:6}"
|
|
114
|
+
:tooltip="$t('ipDeleteCheckIps')"
|
|
115
|
+
:icon="mdiTrashCanOutline"
|
|
116
|
+
:backgroundColor="'#fff'"
|
|
117
|
+
:backgroundColorHover="'#f2f2f2'"
|
|
118
|
+
:iconColor="'#444'"
|
|
119
|
+
:iconColorHover="'#222'"
|
|
120
|
+
:iconColorFocus="'#222'"
|
|
121
|
+
:shadow="false"
|
|
122
|
+
@click="deleteItemsCheck"
|
|
123
|
+
></WButtonCircle>
|
|
124
|
+
|
|
125
|
+
<div style="padding-left:4px;"></div>
|
|
126
|
+
|
|
127
|
+
</template>
|
|
128
|
+
|
|
129
|
+
<template v-if="isEditable && isModified">
|
|
130
|
+
|
|
131
|
+
<WButtonCircle
|
|
132
|
+
:paddingStyle="{v:6,h:6}"
|
|
133
|
+
:tooltip="$t('saveChanges')"
|
|
134
|
+
:icon="mdiCloudUploadOutline"
|
|
135
|
+
:backgroundColor="'rgba(255,0,50,0.6)'"
|
|
136
|
+
:backgroundColorHover="'rgba(255,0,50,0.7)'"
|
|
137
|
+
:backgroundColorFocus="'rgba(255,0,50,0.7)'"
|
|
138
|
+
:iconColor="'#eee'"
|
|
139
|
+
:iconColorHover="'#fff'"
|
|
140
|
+
:iconColorFocus="'#fff'"
|
|
141
|
+
:shadow="false"
|
|
142
|
+
@click="saveIps"
|
|
143
|
+
></WButtonCircle>
|
|
144
|
+
|
|
145
|
+
<div style="padding-left:4px;"></div>
|
|
146
|
+
|
|
147
|
+
</template>
|
|
148
|
+
|
|
149
|
+
</div>
|
|
150
|
+
|
|
151
|
+
</div>
|
|
152
|
+
|
|
153
|
+
<template
|
|
154
|
+
v-if="!isLoading"
|
|
155
|
+
>
|
|
156
|
+
|
|
157
|
+
<template v-if="items">
|
|
158
|
+
<WAggridVueDyn
|
|
159
|
+
ref="rftable"
|
|
160
|
+
:style="`width:100%;`"
|
|
161
|
+
:height="contentHeight"
|
|
162
|
+
:opt="opt"
|
|
163
|
+
>
|
|
164
|
+
</WAggridVueDyn>
|
|
165
|
+
</template>
|
|
166
|
+
|
|
167
|
+
</template>
|
|
168
|
+
|
|
169
|
+
<div
|
|
170
|
+
style="padding:10px 15px; font-size:0.8rem;"
|
|
171
|
+
v-else
|
|
172
|
+
>
|
|
173
|
+
{{$t('waitingData')}}
|
|
174
|
+
</div>
|
|
175
|
+
|
|
176
|
+
</div>
|
|
177
|
+
</template>
|
|
178
|
+
|
|
179
|
+
<script>
|
|
180
|
+
import { mdiIpNetwork, mdiCloudUploadOutline, mdiTrashCanOutline, mdiTableHeadersEye } from '@mdi/js/mdi.js'
|
|
181
|
+
import ot from 'dayjs'
|
|
182
|
+
import get from 'lodash-es/get.js'
|
|
183
|
+
import set from 'lodash-es/set.js'
|
|
184
|
+
import each from 'lodash-es/each.js'
|
|
185
|
+
import size from 'lodash-es/size.js'
|
|
186
|
+
import filter from 'lodash-es/filter.js'
|
|
187
|
+
import sortBy from 'lodash-es/sortBy.js'
|
|
188
|
+
import cloneDeep from 'lodash-es/cloneDeep.js'
|
|
189
|
+
import isestr from 'wsemi/src/isestr.mjs'
|
|
190
|
+
import iseobj from 'wsemi/src/iseobj.mjs'
|
|
191
|
+
import istimemsTZ from 'wsemi/src/istimemsTZ.mjs'
|
|
192
|
+
import arrPull from 'wsemi/src/arrPull.mjs'
|
|
193
|
+
import domShowInputDatatime from 'wsemi/src/domShowInputDatatime.mjs'
|
|
194
|
+
import WIcon from 'w-component-vue/src/components/WIcon.vue'
|
|
195
|
+
import WSwitch from 'w-component-vue/src/components/WSwitch.vue'
|
|
196
|
+
import WButtonCircle from 'w-component-vue/src/components/WButtonCircle.vue'
|
|
197
|
+
import WPopup from 'w-component-vue/src/components/WPopup.vue'
|
|
198
|
+
import WInputCheckbox from 'w-component-vue/src/components/WInputCheckbox.vue'
|
|
199
|
+
import WAggridVueDyn from 'w-component-vue/src/components/WAggridVueDyn.vue'
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
export default {
|
|
203
|
+
components: {
|
|
204
|
+
WIcon,
|
|
205
|
+
WSwitch,
|
|
206
|
+
WButtonCircle,
|
|
207
|
+
WPopup,
|
|
208
|
+
WInputCheckbox,
|
|
209
|
+
WAggridVueDyn,
|
|
210
|
+
},
|
|
211
|
+
props: {
|
|
212
|
+
drawer: {
|
|
213
|
+
type: Boolean,
|
|
214
|
+
default: false,
|
|
215
|
+
},
|
|
216
|
+
},
|
|
217
|
+
data: function() {
|
|
218
|
+
return {
|
|
219
|
+
mdiIpNetwork,
|
|
220
|
+
mdiCloudUploadOutline,
|
|
221
|
+
mdiTrashCanOutline,
|
|
222
|
+
mdiTableHeadersEye,
|
|
223
|
+
|
|
224
|
+
panelWidth: 100,
|
|
225
|
+
panelHeight: 100,
|
|
226
|
+
headHeight: 100,
|
|
227
|
+
|
|
228
|
+
isLoading: true,
|
|
229
|
+
firstSetting: true,
|
|
230
|
+
showIsEditable: false,
|
|
231
|
+
isEditable: false,
|
|
232
|
+
isModified: false,
|
|
233
|
+
|
|
234
|
+
tabKeys: [
|
|
235
|
+
'id',
|
|
236
|
+
'ip',
|
|
237
|
+
'timeBlocked',
|
|
238
|
+
],
|
|
239
|
+
tabKeysPick: [
|
|
240
|
+
'ip',
|
|
241
|
+
'timeBlocked',
|
|
242
|
+
],
|
|
243
|
+
tabKeysShow: [
|
|
244
|
+
'ip',
|
|
245
|
+
'timeBlocked',
|
|
246
|
+
],
|
|
247
|
+
|
|
248
|
+
ips: [],
|
|
249
|
+
items: [],
|
|
250
|
+
itemsCheck: [],
|
|
251
|
+
opt: null,
|
|
252
|
+
|
|
253
|
+
}
|
|
254
|
+
},
|
|
255
|
+
mounted: function() {
|
|
256
|
+
// console.log('mounted')
|
|
257
|
+
|
|
258
|
+
let vo = this
|
|
259
|
+
|
|
260
|
+
//註冊至$dg供使用
|
|
261
|
+
vo.$dg.modifyItemTimeBlockedById = vo.modifyItemTimeBlockedById
|
|
262
|
+
|
|
263
|
+
//firstSetting
|
|
264
|
+
if (vo.firstSetting) {
|
|
265
|
+
// console.log('webInfor', vo.webInfor)
|
|
266
|
+
|
|
267
|
+
let showModeEditIps = get(vo, 'webInfor.showModeEditIps', '')
|
|
268
|
+
vo.showIsEditable = showModeEditIps === 'y'
|
|
269
|
+
let modeEditIps = get(vo, 'webInfor.modeEditIps', '')
|
|
270
|
+
vo.isEditable = modeEditIps === 'y'
|
|
271
|
+
|
|
272
|
+
vo.firstSetting = false
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
//token
|
|
276
|
+
let token = vo.userToken
|
|
277
|
+
// console.log('token', token)
|
|
278
|
+
|
|
279
|
+
//getIpsList
|
|
280
|
+
vo.$fapi.getIpsList(token)
|
|
281
|
+
.then((res) => {
|
|
282
|
+
// console.log(res)
|
|
283
|
+
res = sortBy(res, 'ip').reverse()
|
|
284
|
+
vo.ips = res
|
|
285
|
+
})
|
|
286
|
+
.catch((err) => {
|
|
287
|
+
console.log(err)
|
|
288
|
+
vo.errMsg = vo.$t('getDataError')
|
|
289
|
+
})
|
|
290
|
+
.finally(() => {
|
|
291
|
+
vo.isLoading = false
|
|
292
|
+
})
|
|
293
|
+
|
|
294
|
+
},
|
|
295
|
+
computed: {
|
|
296
|
+
|
|
297
|
+
webInfor: function() {
|
|
298
|
+
let wi = get(this, `$store.state.webInfor`)
|
|
299
|
+
return wi
|
|
300
|
+
},
|
|
301
|
+
|
|
302
|
+
userToken: function() {
|
|
303
|
+
let vo = this
|
|
304
|
+
return get(vo, `$store.state.userToken`)
|
|
305
|
+
},
|
|
306
|
+
|
|
307
|
+
changeParams: function() {
|
|
308
|
+
// console.log('computed changeParams')
|
|
309
|
+
|
|
310
|
+
let vo = this
|
|
311
|
+
|
|
312
|
+
//trigger
|
|
313
|
+
let isEditable = vo.isEditable
|
|
314
|
+
|
|
315
|
+
//items
|
|
316
|
+
let items = cloneDeep(vo.ips)
|
|
317
|
+
|
|
318
|
+
//save
|
|
319
|
+
vo.items = items
|
|
320
|
+
|
|
321
|
+
//genOpt
|
|
322
|
+
vo.genOpt({ isEditable })
|
|
323
|
+
|
|
324
|
+
//isLoading
|
|
325
|
+
vo.isLoading = false
|
|
326
|
+
|
|
327
|
+
return ''
|
|
328
|
+
},
|
|
329
|
+
|
|
330
|
+
contentHeight: function() {
|
|
331
|
+
let vo = this
|
|
332
|
+
|
|
333
|
+
//h
|
|
334
|
+
let h = vo.panelHeight - vo.headHeight
|
|
335
|
+
h = Math.max(h, 0)
|
|
336
|
+
|
|
337
|
+
return h
|
|
338
|
+
},
|
|
339
|
+
|
|
340
|
+
hasItemsCheck: function() {
|
|
341
|
+
let vo = this
|
|
342
|
+
|
|
343
|
+
//h
|
|
344
|
+
let b = size(vo.itemsCheck) > 0
|
|
345
|
+
|
|
346
|
+
return b
|
|
347
|
+
},
|
|
348
|
+
|
|
349
|
+
hasItemCheckOne: function() {
|
|
350
|
+
let vo = this
|
|
351
|
+
|
|
352
|
+
//h
|
|
353
|
+
let b = size(vo.itemsCheck) === 1
|
|
354
|
+
|
|
355
|
+
return b
|
|
356
|
+
},
|
|
357
|
+
|
|
358
|
+
isError: function() {
|
|
359
|
+
return ''
|
|
360
|
+
},
|
|
361
|
+
|
|
362
|
+
kpHead: function() {
|
|
363
|
+
let vo = this
|
|
364
|
+
|
|
365
|
+
let kp = {
|
|
366
|
+
'id': vo.$t('id'),
|
|
367
|
+
'ip': vo.$t('ip'),
|
|
368
|
+
'timeBlocked': vo.$t('ipTimeBlocked'),
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
return kp
|
|
372
|
+
},
|
|
373
|
+
|
|
374
|
+
},
|
|
375
|
+
methods: {
|
|
376
|
+
|
|
377
|
+
resizePanel: function(msg) {
|
|
378
|
+
// console.log('methods resizePanel', msg)
|
|
379
|
+
|
|
380
|
+
let vo = this
|
|
381
|
+
|
|
382
|
+
//panelWidth, panelHeight
|
|
383
|
+
vo.panelWidth = msg.snew.offsetWidth
|
|
384
|
+
vo.panelHeight = msg.snew.offsetHeight
|
|
385
|
+
|
|
386
|
+
},
|
|
387
|
+
|
|
388
|
+
resizeHead: function(msg) {
|
|
389
|
+
// console.log('methods resizeHead', msg)
|
|
390
|
+
|
|
391
|
+
let vo = this
|
|
392
|
+
|
|
393
|
+
//headHeight
|
|
394
|
+
vo.headHeight = msg.snew.offsetHeight
|
|
395
|
+
|
|
396
|
+
},
|
|
397
|
+
|
|
398
|
+
getHead: function(key) {
|
|
399
|
+
// console.log('methods getHead', key)
|
|
400
|
+
|
|
401
|
+
let vo = this
|
|
402
|
+
|
|
403
|
+
let head = get(vo, `kpHead.${key}`, '')
|
|
404
|
+
|
|
405
|
+
return head
|
|
406
|
+
},
|
|
407
|
+
|
|
408
|
+
genOpt: function() {
|
|
409
|
+
// console.log('methods genOpt')
|
|
410
|
+
|
|
411
|
+
let vo = this
|
|
412
|
+
|
|
413
|
+
//default
|
|
414
|
+
vo.itemsCheck = []
|
|
415
|
+
|
|
416
|
+
//opt
|
|
417
|
+
let opt = null
|
|
418
|
+
if (size(vo.items) > 0) {
|
|
419
|
+
|
|
420
|
+
//ks
|
|
421
|
+
let ks = vo.tabKeys
|
|
422
|
+
// console.log('ks', ks)
|
|
423
|
+
|
|
424
|
+
//kpHead
|
|
425
|
+
let kpHead = vo.kpHead
|
|
426
|
+
|
|
427
|
+
//kpCellEditable, kpRowDrag, kpHeadCheckBox
|
|
428
|
+
let kpCellEditable = {}
|
|
429
|
+
let kpRowDrag = {}
|
|
430
|
+
let kpHeadCheckBox = {}
|
|
431
|
+
if (vo.isEditable) {
|
|
432
|
+
kpCellEditable = {
|
|
433
|
+
'ip': true,
|
|
434
|
+
}
|
|
435
|
+
kpRowDrag = {
|
|
436
|
+
'ip': true,
|
|
437
|
+
}
|
|
438
|
+
kpHeadCheckBox = {
|
|
439
|
+
'ip': true,
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
//kpHeadHide
|
|
444
|
+
let kpHeadHide = {
|
|
445
|
+
'id': true,
|
|
446
|
+
}
|
|
447
|
+
if (true) {
|
|
448
|
+
let tabKeysHide = arrPull(vo.tabKeysPick, vo.tabKeysShow)
|
|
449
|
+
each(tabKeysHide, (k) => {
|
|
450
|
+
kpHeadHide[k] = true
|
|
451
|
+
})
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
//opt
|
|
455
|
+
opt = {
|
|
456
|
+
language: vo.$t('aggridLanguage'),
|
|
457
|
+
rows: vo.items,
|
|
458
|
+
keys: ks,
|
|
459
|
+
kpHead,
|
|
460
|
+
// autoFitColumn: true,
|
|
461
|
+
defCellEditable: false, //vo.isEditable
|
|
462
|
+
defHeadFilter: true,
|
|
463
|
+
defCellAlignH: 'left',
|
|
464
|
+
kpHeadHide,
|
|
465
|
+
kpHeadFixLeft: {
|
|
466
|
+
'ip': true,
|
|
467
|
+
},
|
|
468
|
+
defHeadMinWidth: 150,
|
|
469
|
+
kpHeadWidth: {
|
|
470
|
+
'ip': 300,
|
|
471
|
+
'timeBlocked': 220,
|
|
472
|
+
},
|
|
473
|
+
kpHeadFilterType: {
|
|
474
|
+
'id': 'text',
|
|
475
|
+
'ip': 'text',
|
|
476
|
+
'timeBlocked': 'text',
|
|
477
|
+
},
|
|
478
|
+
kpCellEditable,
|
|
479
|
+
kpRowDrag,
|
|
480
|
+
kpHeadCheckBox,
|
|
481
|
+
kpHeadFilter: {
|
|
482
|
+
},
|
|
483
|
+
kpHeadSort: {
|
|
484
|
+
},
|
|
485
|
+
kpHeadFocusHighlight: { //雖然效果不完全, 但因按鈕與cell有padding可被點擊, 故還是需要開啟
|
|
486
|
+
'timeBlocked': false,
|
|
487
|
+
},
|
|
488
|
+
kpCellRender: {
|
|
489
|
+
'timeBlocked': (v, k, r) => {
|
|
490
|
+
// console.log('kpCellRender timeBlocked', v, k, r)
|
|
491
|
+
|
|
492
|
+
//id
|
|
493
|
+
let id = get(r, 'id', '')
|
|
494
|
+
// console.log('id', id, k, r)
|
|
495
|
+
|
|
496
|
+
//vv, vm
|
|
497
|
+
let vv = ''
|
|
498
|
+
let vm = vo.$t('ipTimeEmpty')
|
|
499
|
+
if (istimemsTZ(v)) { //原始數據為timemsTZ格式
|
|
500
|
+
let vt = ot(v)
|
|
501
|
+
vv = vt.format('YYYY-MM-DDTHH:mm:ss.SSSZ')
|
|
502
|
+
vm = vt.format('YYYY-MM-DD HH:mm')
|
|
503
|
+
}
|
|
504
|
+
// console.log('vv', vv)
|
|
505
|
+
// console.log('vm', vm)
|
|
506
|
+
|
|
507
|
+
//t
|
|
508
|
+
let t = `
|
|
509
|
+
<div onclick="event.stopPropagation();event.preventDefault();" onmousedown="event.stopPropagation();event.preventDefault();">
|
|
510
|
+
<button style="width:100%; overflow:hidden; text-overflow:ellipsis; white-space:nowrap;" onclick="$vo.$dg.modifyItemTimeBlockedById(this,'${vv}','${id}')" ${vo.isEditable ? '' : 'disabled'}>${vm}</button>
|
|
511
|
+
</div>
|
|
512
|
+
`
|
|
513
|
+
|
|
514
|
+
return t
|
|
515
|
+
},
|
|
516
|
+
},
|
|
517
|
+
rowsChange: (rs) => {
|
|
518
|
+
// console.log('rowsChange', rs)
|
|
519
|
+
// console.log('rowsChange cloneDeep(vo.opt.rows)', cloneDeep(vo.opt.rows))
|
|
520
|
+
|
|
521
|
+
//isModified
|
|
522
|
+
vo.isModified = true
|
|
523
|
+
|
|
524
|
+
},
|
|
525
|
+
rowChecked: (rs) => {
|
|
526
|
+
// console.log('rowChecked', rs)
|
|
527
|
+
// console.log('rowChecked cloneDeep(vo.opt.rows)', cloneDeep(vo.opt.rows))
|
|
528
|
+
|
|
529
|
+
//save itemsCheck
|
|
530
|
+
vo.itemsCheck = cloneDeep(rs)
|
|
531
|
+
|
|
532
|
+
},
|
|
533
|
+
}
|
|
534
|
+
// console.log('opt', opt)
|
|
535
|
+
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
//save
|
|
539
|
+
vo.opt = opt
|
|
540
|
+
|
|
541
|
+
},
|
|
542
|
+
|
|
543
|
+
refresh: function() {
|
|
544
|
+
let vo = this
|
|
545
|
+
|
|
546
|
+
//cmp
|
|
547
|
+
let cmp = get(vo, '$refs.rftable.$refs.$self')
|
|
548
|
+
// console.log('cmp', cmp)
|
|
549
|
+
|
|
550
|
+
//refresh, 因set不會觸發kpCellRender, 故須另外調用組件函數refresh, 進而觸發kpCellRender, 使能更新數據
|
|
551
|
+
cmp.refresh()
|
|
552
|
+
|
|
553
|
+
},
|
|
554
|
+
|
|
555
|
+
toggleTabKeys: function() {
|
|
556
|
+
let vo = this
|
|
557
|
+
|
|
558
|
+
//cmp
|
|
559
|
+
let cmp = get(vo, '$refs.rftable.$refs.$self')
|
|
560
|
+
// console.log('cmp', cmp)
|
|
561
|
+
|
|
562
|
+
//showKeys
|
|
563
|
+
cmp.showKeys(vo.tabKeysShow)
|
|
564
|
+
// console.log('tabKeysShow', vo.tabKeysShow)
|
|
565
|
+
|
|
566
|
+
},
|
|
567
|
+
|
|
568
|
+
modifyItemByKeyAndId: function(key, ele, t, id) {
|
|
569
|
+
// console.log('modifyItemByKeyAndId', ele, t, id)
|
|
570
|
+
|
|
571
|
+
let vo = this
|
|
572
|
+
|
|
573
|
+
//check
|
|
574
|
+
if (!isestr(id)) {
|
|
575
|
+
vo.$alert(`${vo.$t('ipEditNoIpId')}`, { type: 'error' })
|
|
576
|
+
return
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
//timePrev, 須給予秒時間, 要滿足istime才能展示初始值
|
|
580
|
+
let timePrev = ''
|
|
581
|
+
if (istimemsTZ(t)) {
|
|
582
|
+
timePrev = ot(t).format('YYYY-MM-DDTHH:mm:ss')
|
|
583
|
+
}
|
|
584
|
+
// console.log('timePrev', timePrev)
|
|
585
|
+
|
|
586
|
+
//domShowInputDatatime
|
|
587
|
+
let type = 'datetime-local' //'datetime-local', 'date'
|
|
588
|
+
domShowInputDatatime(timePrev, { eleRef: ele, type })
|
|
589
|
+
.then((timeNew) => {
|
|
590
|
+
// console.log(k, 'timeNew', timeNew)
|
|
591
|
+
|
|
592
|
+
//rows
|
|
593
|
+
let rows = get(vo, 'opt.rows', [])
|
|
594
|
+
|
|
595
|
+
//find
|
|
596
|
+
let r = null
|
|
597
|
+
let kr = null
|
|
598
|
+
each(rows, (v, k) => {
|
|
599
|
+
if (get(v, 'id', '') === id) {
|
|
600
|
+
r = v
|
|
601
|
+
kr = k
|
|
602
|
+
return false //跳出
|
|
603
|
+
}
|
|
604
|
+
})
|
|
605
|
+
|
|
606
|
+
//check
|
|
607
|
+
if (!iseobj(r)) {
|
|
608
|
+
vo.$alert(`${vo.$t('ipEditNoIpData')}`, { type: 'error' })
|
|
609
|
+
return
|
|
610
|
+
}
|
|
611
|
+
|
|
612
|
+
//v
|
|
613
|
+
let vt = ot(timeNew, 'YYYY-MM-DDTHH:mm') //domShowInputDatatime數據為年月日時分
|
|
614
|
+
let v = vt.format('YYYY-MM-DDTHH:mm:ss.SSSZ') //轉回原始數據為timemsTZ格式
|
|
615
|
+
// console.log('v', v)
|
|
616
|
+
|
|
617
|
+
//set
|
|
618
|
+
set(vo, `opt.rows[${kr}].${key}`, v)
|
|
619
|
+
// console.log('vo.opt.rows[kr]', cloneDeep(vo.opt.rows[kr]))
|
|
620
|
+
|
|
621
|
+
//refresh
|
|
622
|
+
vo.refresh()
|
|
623
|
+
|
|
624
|
+
//isModified
|
|
625
|
+
vo.isModified = true
|
|
626
|
+
|
|
627
|
+
})
|
|
628
|
+
|
|
629
|
+
},
|
|
630
|
+
|
|
631
|
+
modifyItemTimeBlockedById: function(ele, t, id) {
|
|
632
|
+
// console.log('modifyItemTimeBlockedById', ele, t, id)
|
|
633
|
+
|
|
634
|
+
let vo = this
|
|
635
|
+
|
|
636
|
+
//modifyItemByKeyAndId
|
|
637
|
+
vo.modifyItemByKeyAndId('timeBlocked', ele, t, id)
|
|
638
|
+
|
|
639
|
+
},
|
|
640
|
+
|
|
641
|
+
deleteItemsCheck: function() {
|
|
642
|
+
// console.log('method deleteItemsCheck')
|
|
643
|
+
|
|
644
|
+
let vo = this
|
|
645
|
+
|
|
646
|
+
//check
|
|
647
|
+
if (size(vo.itemsCheck) === 0) {
|
|
648
|
+
console.log(`size(vo.itemsCheck) === 0`, vo.itemsCheck)
|
|
649
|
+
vo.$alert(`${vo.$t('anUnexpectedErrorOccurred')}`, { type: 'error' })
|
|
650
|
+
return
|
|
651
|
+
}
|
|
652
|
+
|
|
653
|
+
//cloneDeep
|
|
654
|
+
let rows = get(vo, 'opt.rows', [])
|
|
655
|
+
|
|
656
|
+
//cloneDeep
|
|
657
|
+
rows = cloneDeep(rows)
|
|
658
|
+
|
|
659
|
+
//filter
|
|
660
|
+
each(vo.itemsCheck, (v) => {
|
|
661
|
+
// console.log('v', v)
|
|
662
|
+
let id = get(v, 'data.id', '')
|
|
663
|
+
if (!isestr(id)) {
|
|
664
|
+
console.log(`invalid id`)
|
|
665
|
+
return true //跳出換下一個
|
|
666
|
+
}
|
|
667
|
+
rows = filter(rows, (vv) => {
|
|
668
|
+
return vv.id !== id
|
|
669
|
+
})
|
|
670
|
+
})
|
|
671
|
+
|
|
672
|
+
//clear
|
|
673
|
+
vo.itemsCheck = []
|
|
674
|
+
|
|
675
|
+
//save
|
|
676
|
+
vo.ips = cloneDeep(rows) //直接更新由getIpsList取得的ips, 連帶驅動computed重算, 故不用另外更新vo.items與vo.opt.rows
|
|
677
|
+
// console.log('cloneDeep(vo.ips)', cloneDeep(vo.ips))
|
|
678
|
+
|
|
679
|
+
//isModified
|
|
680
|
+
vo.isModified = true
|
|
681
|
+
|
|
682
|
+
},
|
|
683
|
+
|
|
684
|
+
saveIps: function() {
|
|
685
|
+
// console.log('method saveIps')
|
|
686
|
+
|
|
687
|
+
let vo = this
|
|
688
|
+
|
|
689
|
+
async function core() {
|
|
690
|
+
let errTemp = null
|
|
691
|
+
|
|
692
|
+
//show loading
|
|
693
|
+
vo.$ui.updateLoading(true)
|
|
694
|
+
|
|
695
|
+
//check
|
|
696
|
+
if (isestr(vo.isError)) {
|
|
697
|
+
vo.$alert(`${vo.isError}`, { type: 'error' })
|
|
698
|
+
return
|
|
699
|
+
}
|
|
700
|
+
|
|
701
|
+
//rows
|
|
702
|
+
let rows = get(vo, 'opt.rows', [])
|
|
703
|
+
|
|
704
|
+
//check
|
|
705
|
+
if (size(rows) === 0) {
|
|
706
|
+
// vo.$alert(`${vo.$t('ipAddEmpty')}`, { type: 'error' })
|
|
707
|
+
// return
|
|
708
|
+
}
|
|
709
|
+
|
|
710
|
+
//token
|
|
711
|
+
let token = vo.userToken
|
|
712
|
+
// console.log('token', token)
|
|
713
|
+
|
|
714
|
+
//updateIpsList
|
|
715
|
+
await vo.$fapi.updateIpsList(token, rows)
|
|
716
|
+
.catch((err) => {
|
|
717
|
+
errTemp = err
|
|
718
|
+
})
|
|
719
|
+
|
|
720
|
+
//check
|
|
721
|
+
if (errTemp !== null) {
|
|
722
|
+
vo.$alert(`${vo.$t('ipSaveIpsFail')}: ${errTemp}`, { type: 'error' })
|
|
723
|
+
return
|
|
724
|
+
}
|
|
725
|
+
|
|
726
|
+
//isModified
|
|
727
|
+
vo.isModified = false
|
|
728
|
+
|
|
729
|
+
//alert
|
|
730
|
+
vo.$alert(vo.$t('ipSaveIpsSuccess'))
|
|
731
|
+
|
|
732
|
+
}
|
|
733
|
+
|
|
734
|
+
//core
|
|
735
|
+
core()
|
|
736
|
+
// .then((res) => {
|
|
737
|
+
// console.log('then', res)
|
|
738
|
+
// })
|
|
739
|
+
.catch((err) => {
|
|
740
|
+
console.log('catch', err)
|
|
741
|
+
vo.$alert(vo.$t('anUnexpectedErrorOccurred'), { type: 'error' })
|
|
742
|
+
})
|
|
743
|
+
.finally(() => {
|
|
744
|
+
|
|
745
|
+
//hide loading
|
|
746
|
+
vo.$ui.updateLoading(false)
|
|
747
|
+
|
|
748
|
+
})
|
|
749
|
+
|
|
750
|
+
},
|
|
751
|
+
|
|
752
|
+
}
|
|
753
|
+
}
|
|
754
|
+
</script>
|
|
755
|
+
<style scoped>
|
|
756
|
+
</style>
|
|
757
|
+
|