agentworkshop 0.7.11 → 0.7.12
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/.output/nitro.json +1 -1
- package/.output/public/_nuxt/{BLzCac9K2.js → CcwJ2mrD2.js} +1 -1
- package/.output/public/_nuxt/CvYfzHYz.js +1 -0
- package/.output/public/_nuxt/{B5CYgFAD.js → D2JyEL28.js} +4 -4
- package/.output/public/_nuxt/{CGx-mtWf.js → D8xY-Yjc.js} +1 -1
- package/.output/public/_nuxt/DaE5saZg.js +1 -0
- package/.output/public/_nuxt/Dsdy4Ua-.js +1 -0
- package/.output/public/_nuxt/{B8WV7GzS.js → E88a-JCG.js} +1 -1
- package/.output/public/_nuxt/bAFueD6a.js +1 -0
- package/.output/public/_nuxt/builds/latest.json +1 -1
- package/.output/public/_nuxt/builds/meta/54e22640-4fd0-4fee-9077-31d4d4bb7969.json +1 -0
- package/.output/public/_nuxt/dcw.rpqpOYQ8.css +1 -0
- package/.output/public/_nuxt/entry.Bv_GCmPP.css +1 -0
- package/.output/public/_nuxt/hb_ceMJP.js +1 -0
- package/.output/public/_nuxt/logs.BS1sb41K.css +1 -0
- package/.output/public/_nuxt/pages.BkE-AfIb.css +1 -0
- package/.output/public/_nuxt/permissions.DTRtZeTw.css +1 -0
- package/.output/public/_nuxt/plugins.BcSEwwGb.css +1 -0
- package/.output/public/_nuxt/tokens.rW1xHxRW.css +1 -0
- package/.output/public/_nuxt/workshop.CbymC2LY.css +1 -0
- package/.output/server/chunks/_/nitro.mjs +772 -772
- package/.output/server/chunks/build/{dcw-DqjHrl5Z.mjs → dcw-B0dtiHFG.mjs} +43 -43
- package/.output/server/chunks/build/dcw-B0dtiHFG.mjs.map +1 -0
- package/.output/server/chunks/build/{default-YcUHc1Ev.mjs → default-DdV642BY.mjs} +23 -2
- package/.output/server/chunks/build/{default-YcUHc1Ev.mjs.map → default-DdV642BY.mjs.map} +1 -1
- package/.output/server/chunks/build/{logs-Co854R4y.mjs → logs-Crf6f1IC.mjs} +34 -34
- package/.output/server/chunks/build/{logs-Co854R4y.mjs.map → logs-Crf6f1IC.mjs.map} +1 -1
- package/.output/server/chunks/build/{pages-DPC1Vp6w.mjs → pages-BmRUbGUi.mjs} +28 -18
- package/.output/server/chunks/build/pages-BmRUbGUi.mjs.map +1 -0
- package/.output/server/chunks/build/{permissions-Eu9e6hfZ.mjs → permissions-CxEgXic0.mjs} +12 -12
- package/.output/server/chunks/build/{permissions-Eu9e6hfZ.mjs.map → permissions-CxEgXic0.mjs.map} +1 -1
- package/.output/server/chunks/build/{plugins-D84mvK9G.mjs → plugins-wLIKHcIE.mjs} +17 -17
- package/.output/server/chunks/build/plugins-wLIKHcIE.mjs.map +1 -0
- package/.output/server/chunks/build/{tokens-CZpnEDVf.mjs → tokens-BKLzcdMg.mjs} +44 -75
- package/.output/server/chunks/build/tokens-BKLzcdMg.mjs.map +1 -0
- package/.output/server/chunks/build/{workshop-Crsai2Y9.mjs → workshop-CTcYDq2i.mjs} +21 -16
- package/.output/server/chunks/build/{workshop-Crsai2Y9.mjs.map → workshop-CTcYDq2i.mjs.map} +1 -1
- package/.output/server/chunks/routes/renderer.mjs +1 -1
- package/.output/server/chunks/virtual/entry.mjs +12 -10
- package/.output/server/chunks/virtual/precomputed.mjs +1 -1
- package/.output/server/package.json +1 -1
- package/app/assets/css/main.css +161 -0
- package/app/components/AwChart.vue +12 -2
- package/app/composables/useRouteMeta.ts +8 -1
- package/app/pages/dcw/index.vue +1079 -1079
- package/app/pages/index.vue +7 -2
- package/app/pages/logs/index.vue +621 -621
- package/app/pages/permissions/index.vue +330 -327
- package/app/pages/plugins/index.vue +6 -3
- package/app/pages/tokens.vue +9 -13
- package/app/pages/workshop/index.vue +3 -1
- package/i18n/locales/en.ts +1944 -1943
- package/i18n/locales/zh-CN.ts +1943 -1942
- package/package.json +1 -1
- package/scripts/_dbg-kicker-check.mjs +11 -0
- package/scripts/_dbg-perms-e2e.mjs +3 -3
- package/scripts/_dbg-plugins-e2e.mjs +1 -1
- package/scripts/_dbg-swatch-check.mjs +10 -0
- package/scripts/_dbg-ui-shots.mjs +28 -0
- package/server/data/dcw-rollback.json +6 -6
- package/server/data/dcws.json +345 -345
- package/.output/public/_nuxt/Bckshc9V.js +0 -1
- package/.output/public/_nuxt/D7jiode2.js +0 -1
- package/.output/public/_nuxt/DEaY_uvR.js +0 -1
- package/.output/public/_nuxt/builds/meta/88479a5b-ce6a-400f-9737-1cc9f54b1fe5.json +0 -1
- package/.output/public/_nuxt/d_Sz9KGm.js +0 -1
- package/.output/public/_nuxt/dcw.DcDjwvqv.css +0 -1
- package/.output/public/_nuxt/entry.B03HBJGC.css +0 -1
- package/.output/public/_nuxt/logs.BO-BSyjm.css +0 -1
- package/.output/public/_nuxt/pages.CytEOfUs.css +0 -1
- package/.output/public/_nuxt/permissions.CwZo6t1V.css +0 -1
- package/.output/public/_nuxt/plugins.Clsky_kl.css +0 -1
- package/.output/public/_nuxt/tJuVvBSl.js +0 -1
- package/.output/public/_nuxt/tokens.BPLe9ioQ.css +0 -1
- package/.output/public/_nuxt/workshop.BIdoGfoC.css +0 -1
- package/.output/server/chunks/build/dcw-DqjHrl5Z.mjs.map +0 -1
- package/.output/server/chunks/build/pages-DPC1Vp6w.mjs.map +0 -1
- package/.output/server/chunks/build/plugins-D84mvK9G.mjs.map +0 -1
- package/.output/server/chunks/build/tokens-CZpnEDVf.mjs.map +0 -1
|
@@ -1,327 +1,330 @@
|
|
|
1
|
-
<script setup lang="ts">
|
|
2
|
-
/**
|
|
3
|
-
* 权限管理(admin 专属)—— 用户 × 产线授权矩阵。
|
|
4
|
-
* 三态:无权(none,后端不返回该产线数据)/ 仅查看(readonly,数采只读)/ 可操控(operate,数采+数控全量)。
|
|
5
|
-
* 用户详情抽屉含:基本信息、该用户创建的 Channel、产线授权矩阵(逐线三态选择,批量保存)。
|
|
6
|
-
*/
|
|
7
|
-
import { computed, onMounted, reactive, ref } from 'vue'
|
|
8
|
-
import { message } from 'ant-design-vue'
|
|
9
|
-
import { useUserStore } from '~/stores/workshop/user'
|
|
10
|
-
|
|
11
|
-
const { t } = useI18n()
|
|
12
|
-
const userStore = useUserStore()
|
|
13
|
-
|
|
14
|
-
interface LineView { id: string, name: string }
|
|
15
|
-
interface GrantRow { lineId: string, mode: string, grantedBy: string | null, grantedAt: string }
|
|
16
|
-
interface UserRow {
|
|
17
|
-
id: string
|
|
18
|
-
name: string
|
|
19
|
-
email: string
|
|
20
|
-
role: string
|
|
21
|
-
status: string
|
|
22
|
-
createdAt: string
|
|
23
|
-
channels: Array<{ id: string, name: string, createdAt: string }>
|
|
24
|
-
grants: GrantRow[]
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
const lines = ref<LineView[]>([])
|
|
28
|
-
const users = ref<UserRow[]>([])
|
|
29
|
-
const loading = ref(false)
|
|
30
|
-
const keyword = ref('')
|
|
31
|
-
const drawerOpen = ref(false)
|
|
32
|
-
const current = ref<UserRow | null>(null)
|
|
33
|
-
// lineId → 'none' | 'readonly' | 'operate'
|
|
34
|
-
const draft = reactive<Record<string, string>>({})
|
|
35
|
-
const saving = ref(false)
|
|
36
|
-
|
|
37
|
-
function authHeaders(): Record<string, string> {
|
|
38
|
-
const token = (userStore as { token?: string }).token
|
|
39
|
-
return token ? { authorization: `Bearer ${token}` } : {}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
async function load() {
|
|
43
|
-
loading.value = true
|
|
44
|
-
try {
|
|
45
|
-
const d = await $fetch<{ code: number, data?: { lines: LineView[], users: UserRow[] } }>('/api/workshop/permissions', { headers: authHeaders() })
|
|
46
|
-
if (d.code !== 0 || !d.data) throw new Error('load fail')
|
|
47
|
-
lines.value = d.data.lines ?? []
|
|
48
|
-
users.value = d.data.users ?? []
|
|
49
|
-
}
|
|
50
|
-
catch (err) {
|
|
51
|
-
message.error(apiErrorMessage(err, t('permissions.loadFail')))
|
|
52
|
-
}
|
|
53
|
-
finally {
|
|
54
|
-
loading.value = false
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
const filteredUsers = computed(() => {
|
|
59
|
-
const kw = keyword.value.trim().toLowerCase()
|
|
60
|
-
if (!kw) return users.value
|
|
61
|
-
return users.value.filter(u => `${u.name} ${u.email}`.toLowerCase().includes(kw))
|
|
62
|
-
})
|
|
63
|
-
|
|
64
|
-
function openDetail(u: UserRow) {
|
|
65
|
-
current.value = u
|
|
66
|
-
draftClear(u)
|
|
67
|
-
drawerOpen.value = true
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
function draftClear(u: UserRow) {
|
|
71
|
-
for (const k of Object.keys(draft)) Reflect.deleteProperty(draft, k)
|
|
72
|
-
for (const l of lines.value) {
|
|
73
|
-
const g = u.grants.find(x => x.lineId === l.id)
|
|
74
|
-
draft[l.id] = (g?.mode === 'readonly' || g?.mode === 'operate') ? g.mode : 'none'
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
const dirtyCount = computed(() => {
|
|
79
|
-
if (!current.value) return 0
|
|
80
|
-
let n = 0
|
|
81
|
-
for (const l of lines.value) {
|
|
82
|
-
const g = current.value.grants.find(x => x.lineId === l.id)
|
|
83
|
-
const cur = (g?.mode === 'readonly' || g?.mode === 'operate') ? g.mode : 'none'
|
|
84
|
-
if ((draft[l.id] ?? 'none') !== cur) n++
|
|
85
|
-
}
|
|
86
|
-
return n
|
|
87
|
-
})
|
|
88
|
-
|
|
89
|
-
async function save() {
|
|
90
|
-
if (!current.value) return
|
|
91
|
-
saving.value = true
|
|
92
|
-
try {
|
|
93
|
-
const grants = lines.value
|
|
94
|
-
.filter(l => (draft[l.id] ?? 'none') !== 'none')
|
|
95
|
-
.map(l => ({ lineId: l.id, mode: draft[l.id] }))
|
|
96
|
-
const revoked = lines.value
|
|
97
|
-
.filter(l => (draft[l.id] ?? 'none') === 'none' && current.value!.grants.some(g => g.lineId === l.id))
|
|
98
|
-
.map(l => ({ lineId: l.id, mode: null }))
|
|
99
|
-
const d = await $fetch<{ code: number, data?: { grants: GrantRow[] } }>('/api/workshop/permissions', {
|
|
100
|
-
method: 'PUT',
|
|
101
|
-
headers: authHeaders(),
|
|
102
|
-
body: { userId: current.value.id, grants: [...grants, ...revoked] },
|
|
103
|
-
})
|
|
104
|
-
if (d.code !== 0 || !d.data) throw new Error('save fail')
|
|
105
|
-
current.value.grants = d.data.grants
|
|
106
|
-
const u = users.value.find(x => x.id === current.value?.id)
|
|
107
|
-
if (u) u.grants = d.data.grants
|
|
108
|
-
message.success(t('permissions.saved', { n: grants.length + revoked.length }))
|
|
109
|
-
}
|
|
110
|
-
catch (err) {
|
|
111
|
-
message.error(apiErrorMessage(err, t('permissions.saveFail')))
|
|
112
|
-
}
|
|
113
|
-
finally {
|
|
114
|
-
saving.value = false
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
function modeTag(mode: string): string {
|
|
119
|
-
return mode === 'operate' ? t('permissions.operate') : mode === 'readonly' ? t('permissions.readonly') : t('permissions.none')
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
// admin 专属页:非 admin 直接回仪表盘(后端 API 亦有 admin 拦截)
|
|
123
|
-
watch(() => userStore.isLoggedIn, (ok) => {
|
|
124
|
-
if (ok && !userStore.isAdmin) navigateTo('/')
|
|
125
|
-
}, { immediate: true })
|
|
126
|
-
|
|
127
|
-
onMounted(load)
|
|
128
|
-
</script>
|
|
129
|
-
|
|
130
|
-
<template>
|
|
131
|
-
<div class="perm-page">
|
|
132
|
-
<header class="pg-head">
|
|
133
|
-
<div>
|
|
134
|
-
<
|
|
135
|
-
|
|
136
|
-
</
|
|
137
|
-
<
|
|
138
|
-
{{ $t('permissions.
|
|
139
|
-
</
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
:
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
<
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
<dt>
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
<
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
</
|
|
280
|
-
<
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
<a-radio-button value="
|
|
298
|
-
{{ $t('permissions.
|
|
299
|
-
</a-radio-button>
|
|
300
|
-
<a-radio-button value="
|
|
301
|
-
{{ $t('permissions.
|
|
302
|
-
</a-radio-button>
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
</template>
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
.
|
|
316
|
-
.
|
|
317
|
-
.
|
|
318
|
-
.
|
|
319
|
-
.
|
|
320
|
-
.
|
|
321
|
-
.
|
|
322
|
-
.
|
|
323
|
-
.
|
|
324
|
-
.
|
|
325
|
-
|
|
326
|
-
.
|
|
327
|
-
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
/**
|
|
3
|
+
* 权限管理(admin 专属)—— 用户 × 产线授权矩阵。
|
|
4
|
+
* 三态:无权(none,后端不返回该产线数据)/ 仅查看(readonly,数采只读)/ 可操控(operate,数采+数控全量)。
|
|
5
|
+
* 用户详情抽屉含:基本信息、该用户创建的 Channel、产线授权矩阵(逐线三态选择,批量保存)。
|
|
6
|
+
*/
|
|
7
|
+
import { computed, onMounted, reactive, ref } from 'vue'
|
|
8
|
+
import { message } from 'ant-design-vue'
|
|
9
|
+
import { useUserStore } from '~/stores/workshop/user'
|
|
10
|
+
|
|
11
|
+
const { t } = useI18n()
|
|
12
|
+
const userStore = useUserStore()
|
|
13
|
+
|
|
14
|
+
interface LineView { id: string, name: string }
|
|
15
|
+
interface GrantRow { lineId: string, mode: string, grantedBy: string | null, grantedAt: string }
|
|
16
|
+
interface UserRow {
|
|
17
|
+
id: string
|
|
18
|
+
name: string
|
|
19
|
+
email: string
|
|
20
|
+
role: string
|
|
21
|
+
status: string
|
|
22
|
+
createdAt: string
|
|
23
|
+
channels: Array<{ id: string, name: string, createdAt: string }>
|
|
24
|
+
grants: GrantRow[]
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const lines = ref<LineView[]>([])
|
|
28
|
+
const users = ref<UserRow[]>([])
|
|
29
|
+
const loading = ref(false)
|
|
30
|
+
const keyword = ref('')
|
|
31
|
+
const drawerOpen = ref(false)
|
|
32
|
+
const current = ref<UserRow | null>(null)
|
|
33
|
+
// lineId → 'none' | 'readonly' | 'operate'
|
|
34
|
+
const draft = reactive<Record<string, string>>({})
|
|
35
|
+
const saving = ref(false)
|
|
36
|
+
|
|
37
|
+
function authHeaders(): Record<string, string> {
|
|
38
|
+
const token = (userStore as { token?: string }).token
|
|
39
|
+
return token ? { authorization: `Bearer ${token}` } : {}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
async function load() {
|
|
43
|
+
loading.value = true
|
|
44
|
+
try {
|
|
45
|
+
const d = await $fetch<{ code: number, data?: { lines: LineView[], users: UserRow[] } }>('/api/workshop/permissions', { headers: authHeaders() })
|
|
46
|
+
if (d.code !== 0 || !d.data) throw new Error('load fail')
|
|
47
|
+
lines.value = d.data.lines ?? []
|
|
48
|
+
users.value = d.data.users ?? []
|
|
49
|
+
}
|
|
50
|
+
catch (err) {
|
|
51
|
+
message.error(apiErrorMessage(err, t('permissions.loadFail')))
|
|
52
|
+
}
|
|
53
|
+
finally {
|
|
54
|
+
loading.value = false
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const filteredUsers = computed(() => {
|
|
59
|
+
const kw = keyword.value.trim().toLowerCase()
|
|
60
|
+
if (!kw) return users.value
|
|
61
|
+
return users.value.filter(u => `${u.name} ${u.email}`.toLowerCase().includes(kw))
|
|
62
|
+
})
|
|
63
|
+
|
|
64
|
+
function openDetail(u: UserRow) {
|
|
65
|
+
current.value = u
|
|
66
|
+
draftClear(u)
|
|
67
|
+
drawerOpen.value = true
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function draftClear(u: UserRow) {
|
|
71
|
+
for (const k of Object.keys(draft)) Reflect.deleteProperty(draft, k)
|
|
72
|
+
for (const l of lines.value) {
|
|
73
|
+
const g = u.grants.find(x => x.lineId === l.id)
|
|
74
|
+
draft[l.id] = (g?.mode === 'readonly' || g?.mode === 'operate') ? g.mode : 'none'
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const dirtyCount = computed(() => {
|
|
79
|
+
if (!current.value) return 0
|
|
80
|
+
let n = 0
|
|
81
|
+
for (const l of lines.value) {
|
|
82
|
+
const g = current.value.grants.find(x => x.lineId === l.id)
|
|
83
|
+
const cur = (g?.mode === 'readonly' || g?.mode === 'operate') ? g.mode : 'none'
|
|
84
|
+
if ((draft[l.id] ?? 'none') !== cur) n++
|
|
85
|
+
}
|
|
86
|
+
return n
|
|
87
|
+
})
|
|
88
|
+
|
|
89
|
+
async function save() {
|
|
90
|
+
if (!current.value) return
|
|
91
|
+
saving.value = true
|
|
92
|
+
try {
|
|
93
|
+
const grants = lines.value
|
|
94
|
+
.filter(l => (draft[l.id] ?? 'none') !== 'none')
|
|
95
|
+
.map(l => ({ lineId: l.id, mode: draft[l.id] }))
|
|
96
|
+
const revoked = lines.value
|
|
97
|
+
.filter(l => (draft[l.id] ?? 'none') === 'none' && current.value!.grants.some(g => g.lineId === l.id))
|
|
98
|
+
.map(l => ({ lineId: l.id, mode: null }))
|
|
99
|
+
const d = await $fetch<{ code: number, data?: { grants: GrantRow[] } }>('/api/workshop/permissions', {
|
|
100
|
+
method: 'PUT',
|
|
101
|
+
headers: authHeaders(),
|
|
102
|
+
body: { userId: current.value.id, grants: [...grants, ...revoked] },
|
|
103
|
+
})
|
|
104
|
+
if (d.code !== 0 || !d.data) throw new Error('save fail')
|
|
105
|
+
current.value.grants = d.data.grants
|
|
106
|
+
const u = users.value.find(x => x.id === current.value?.id)
|
|
107
|
+
if (u) u.grants = d.data.grants
|
|
108
|
+
message.success(t('permissions.saved', { n: grants.length + revoked.length }))
|
|
109
|
+
}
|
|
110
|
+
catch (err) {
|
|
111
|
+
message.error(apiErrorMessage(err, t('permissions.saveFail')))
|
|
112
|
+
}
|
|
113
|
+
finally {
|
|
114
|
+
saving.value = false
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
function modeTag(mode: string): string {
|
|
119
|
+
return mode === 'operate' ? t('permissions.operate') : mode === 'readonly' ? t('permissions.readonly') : t('permissions.none')
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// admin 专属页:非 admin 直接回仪表盘(后端 API 亦有 admin 拦截)
|
|
123
|
+
watch(() => userStore.isLoggedIn, (ok) => {
|
|
124
|
+
if (ok && !userStore.isAdmin) navigateTo('/')
|
|
125
|
+
}, { immediate: true })
|
|
126
|
+
|
|
127
|
+
onMounted(load)
|
|
128
|
+
</script>
|
|
129
|
+
|
|
130
|
+
<template>
|
|
131
|
+
<div class="perm-page">
|
|
132
|
+
<header class="pg-head">
|
|
133
|
+
<div>
|
|
134
|
+
<p class="aw-kicker">
|
|
135
|
+
agentworkshop / permissions
|
|
136
|
+
</p>
|
|
137
|
+
<h1 class="pg-title">
|
|
138
|
+
{{ $t('permissions.title') }}
|
|
139
|
+
</h1>
|
|
140
|
+
<p class="pg-sub">
|
|
141
|
+
{{ $t('permissions.subtitle') }}
|
|
142
|
+
</p>
|
|
143
|
+
</div>
|
|
144
|
+
<a-input-search
|
|
145
|
+
v-model:value="keyword"
|
|
146
|
+
:placeholder="$t('permissions.search')"
|
|
147
|
+
style="max-width: 260px"
|
|
148
|
+
allow-clear
|
|
149
|
+
/>
|
|
150
|
+
</header>
|
|
151
|
+
|
|
152
|
+
<a-table
|
|
153
|
+
:data-source="filteredUsers"
|
|
154
|
+
:loading="loading"
|
|
155
|
+
row-key="id"
|
|
156
|
+
size="middle"
|
|
157
|
+
:pagination="{ pageSize: 12, showSizeChanger: false }"
|
|
158
|
+
>
|
|
159
|
+
<a-table-column
|
|
160
|
+
:title="$t('permissions.colUser')"
|
|
161
|
+
data-index="name"
|
|
162
|
+
>
|
|
163
|
+
<template #default="{ record }">
|
|
164
|
+
<a @click.prevent="openDetail(record)">{{ record.name }}</a>
|
|
165
|
+
</template>
|
|
166
|
+
</a-table-column>
|
|
167
|
+
<a-table-column
|
|
168
|
+
:title="$t('permissions.colEmail')"
|
|
169
|
+
data-index="email"
|
|
170
|
+
/>
|
|
171
|
+
<a-table-column
|
|
172
|
+
:title="$t('permissions.colRole')"
|
|
173
|
+
data-index="role"
|
|
174
|
+
>
|
|
175
|
+
<template #default="{ record }">
|
|
176
|
+
<a-tag :color="record.role === 'admin' ? 'green' : record.role === 'editor' ? 'blue' : 'default'">
|
|
177
|
+
{{ record.role }}
|
|
178
|
+
</a-tag>
|
|
179
|
+
</template>
|
|
180
|
+
</a-table-column>
|
|
181
|
+
<a-table-column
|
|
182
|
+
:title="$t('permissions.colStatus')"
|
|
183
|
+
data-index="status"
|
|
184
|
+
>
|
|
185
|
+
<template #default="{ record }">
|
|
186
|
+
<a-tag :color="record.status === 'active' ? 'cyan' : 'red'">
|
|
187
|
+
{{ record.status === 'active' ? $t('permissions.active') : record.status }}
|
|
188
|
+
</a-tag>
|
|
189
|
+
</template>
|
|
190
|
+
</a-table-column>
|
|
191
|
+
<a-table-column
|
|
192
|
+
:title="$t('permissions.colChannels')"
|
|
193
|
+
data-index="channels"
|
|
194
|
+
>
|
|
195
|
+
<template #default="{ record }">
|
|
196
|
+
{{ record.channels.length }}
|
|
197
|
+
</template>
|
|
198
|
+
</a-table-column>
|
|
199
|
+
<a-table-column
|
|
200
|
+
:title="$t('permissions.colGrants')"
|
|
201
|
+
data-index="grants"
|
|
202
|
+
>
|
|
203
|
+
<template #default="{ record }">
|
|
204
|
+
<a-tag
|
|
205
|
+
v-for="g in record.grants"
|
|
206
|
+
:key="g.lineId"
|
|
207
|
+
style="margin-bottom: 2px"
|
|
208
|
+
>
|
|
209
|
+
{{ (lines.find(l => l.id === g.lineId)?.name ?? g.lineId).slice(0, 14) }} · {{ modeTag(g.mode) }}
|
|
210
|
+
</a-tag>
|
|
211
|
+
<span
|
|
212
|
+
v-if="!record.grants.length"
|
|
213
|
+
class="dim"
|
|
214
|
+
>—</span>
|
|
215
|
+
</template>
|
|
216
|
+
</a-table-column>
|
|
217
|
+
<a-table-column
|
|
218
|
+
:title="$t('permissions.colOps')"
|
|
219
|
+
:width="90"
|
|
220
|
+
>
|
|
221
|
+
<template #default="{ record }">
|
|
222
|
+
<a-button
|
|
223
|
+
size="small"
|
|
224
|
+
@click="openDetail(record)"
|
|
225
|
+
>
|
|
226
|
+
{{ $t('permissions.manage') }}
|
|
227
|
+
</a-button>
|
|
228
|
+
</template>
|
|
229
|
+
</a-table-column>
|
|
230
|
+
</a-table>
|
|
231
|
+
|
|
232
|
+
<a-drawer
|
|
233
|
+
v-model:open="drawerOpen"
|
|
234
|
+
:title="current ? `${current.name} · ${$t('permissions.detail')}` : ''"
|
|
235
|
+
width="560"
|
|
236
|
+
>
|
|
237
|
+
<template v-if="current">
|
|
238
|
+
<h4 class="sec">
|
|
239
|
+
{{ $t('permissions.secProfile') }}
|
|
240
|
+
</h4>
|
|
241
|
+
<dl class="detail">
|
|
242
|
+
<dt>email</dt><dd>{{ current.email }}</dd>
|
|
243
|
+
<dt>role</dt><dd>{{ current.role }}</dd>
|
|
244
|
+
<dt>status</dt><dd>{{ current.status }}</dd>
|
|
245
|
+
<dt>created</dt><dd>{{ current.createdAt }}</dd>
|
|
246
|
+
</dl>
|
|
247
|
+
|
|
248
|
+
<h4 class="sec">
|
|
249
|
+
{{ $t('permissions.secChannels') }}({{ current.channels.length }})
|
|
250
|
+
</h4>
|
|
251
|
+
<div
|
|
252
|
+
v-if="current.channels.length"
|
|
253
|
+
class="ch-list"
|
|
254
|
+
>
|
|
255
|
+
<code
|
|
256
|
+
v-for="c in current.channels"
|
|
257
|
+
:key="c.id"
|
|
258
|
+
>{{ c.name || c.id.slice(0, 8) }}</code>
|
|
259
|
+
</div>
|
|
260
|
+
<p
|
|
261
|
+
v-else
|
|
262
|
+
class="dim"
|
|
263
|
+
>
|
|
264
|
+
{{ $t('permissions.noChannels') }}
|
|
265
|
+
</p>
|
|
266
|
+
|
|
267
|
+
<h4 class="sec">
|
|
268
|
+
{{ $t('permissions.secMatrix') }}
|
|
269
|
+
<a-button
|
|
270
|
+
type="primary"
|
|
271
|
+
size="small"
|
|
272
|
+
:loading="saving"
|
|
273
|
+
:disabled="dirtyCount === 0"
|
|
274
|
+
style="margin-left: 12px"
|
|
275
|
+
@click="save"
|
|
276
|
+
>
|
|
277
|
+
{{ $t('permissions.save', { n: dirtyCount }) }}
|
|
278
|
+
</a-button>
|
|
279
|
+
</h4>
|
|
280
|
+
<p class="hint">
|
|
281
|
+
{{ $t('permissions.matrixHint') }}
|
|
282
|
+
</p>
|
|
283
|
+
<div class="matrix">
|
|
284
|
+
<div
|
|
285
|
+
v-for="l in lines"
|
|
286
|
+
:key="l.id"
|
|
287
|
+
class="row"
|
|
288
|
+
>
|
|
289
|
+
<span
|
|
290
|
+
class="line-name"
|
|
291
|
+
:title="l.id"
|
|
292
|
+
>{{ l.name }}</span>
|
|
293
|
+
<a-radio-group
|
|
294
|
+
v-model:value="draft[l.id]"
|
|
295
|
+
size="small"
|
|
296
|
+
>
|
|
297
|
+
<a-radio-button value="none">
|
|
298
|
+
{{ $t('permissions.none') }}
|
|
299
|
+
</a-radio-button>
|
|
300
|
+
<a-radio-button value="readonly">
|
|
301
|
+
{{ $t('permissions.readonly') }}
|
|
302
|
+
</a-radio-button>
|
|
303
|
+
<a-radio-button value="operate">
|
|
304
|
+
{{ $t('permissions.operate') }}
|
|
305
|
+
</a-radio-button>
|
|
306
|
+
</a-radio-group>
|
|
307
|
+
</div>
|
|
308
|
+
</div>
|
|
309
|
+
</template>
|
|
310
|
+
</a-drawer>
|
|
311
|
+
</div>
|
|
312
|
+
</template>
|
|
313
|
+
|
|
314
|
+
<style scoped lang="css">
|
|
315
|
+
.perm-page { max-width: 1180px; margin: 0 auto; padding: 24px 20px 48px; }
|
|
316
|
+
.pg-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
|
|
317
|
+
.pg-title { margin: 0; font-size: 22px; font-weight: 700; letter-spacing: .5px; }
|
|
318
|
+
.pg-sub { margin: 4px 0 0; opacity: .6; font-size: 12px; }
|
|
319
|
+
.dim { opacity: .45; }
|
|
320
|
+
.sec { margin: 20px 0 8px; font-size: 13px; font-weight: 700; }
|
|
321
|
+
.detail dt { margin-top: 8px; font-size: 11px; opacity: .5; }
|
|
322
|
+
.detail dd { margin: 2px 0 0; font-family: ui-monospace, monospace; font-size: 12px; }
|
|
323
|
+
.ch-list { display: flex; flex-wrap: wrap; gap: 6px; }
|
|
324
|
+
.ch-list code { padding: 2px 8px; border: 1px solid rgba(128, 152, 199, .3); border-radius: 6px; font-size: 11px; }
|
|
325
|
+
.hint { font-size: 11px; opacity: .55; margin: 4px 0 10px; }
|
|
326
|
+
.matrix { display: flex; flex-direction: column; gap: 8px; }
|
|
327
|
+
.matrix .row { display: flex; align-items: center; justify-content: space-between; gap: 12px;
|
|
328
|
+
padding: 8px 12px; border: 1px solid var(--aw-border, rgba(128, 152, 199, .25)); border-radius: 10px; }
|
|
329
|
+
.line-name { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
330
|
+
</style>
|