Skip to content

Commit c591cb4

Browse files
committed
Merge remote-tracking branch 'origin/hotfix-configs'
2 parents 324b1b4 + 2ef73ca commit c591cb4

File tree

8 files changed

+62
-25
lines changed

8 files changed

+62
-25
lines changed

src/components/common/PageContainer.vue

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ import constant from '@/types/constant'
121121
import apis from '@/apis/index'
122122
const slots = useSlots()
123123
const toast = useMessage()
124-
const emits = defineEmits(['onSave'])
124+
const emits = defineEmits(['onSave', 'notify'])
125125
let props = defineProps({
126126
config: {
127127
type: Object as PropType<CrudOptions<Object>>,
@@ -131,6 +131,10 @@ let props = defineProps({
131131
type: Array<any>,
132132
default: () => [],
133133
},
134+
callback: {
135+
type: Function,
136+
default: undefined,
137+
},
134138
})
135139
const showDrawer = ref(false)
136140
const height = ref(500)
@@ -242,8 +246,10 @@ const onSave = async (formData: any) => {
242246
if (data.success) {
243247
if (formData.mode === constant.FORM_MODE_CREATE) {
244248
toast.info('添加成功')
249+
emits('notify', 'add')
245250
} else {
246251
toast.info('编辑成功')
252+
emits('notify', 'edit')
247253
}
248254
refreshData()
249255
} else {
@@ -271,6 +277,7 @@ const onUpdate = async (formData: any) => {
271277
if (status === 200 && data && typeof data === 'object') {
272278
if (data.success) {
273279
toast.info('修改成功')
280+
emits('notify', 'edit')
274281
refreshData()
275282
} else {
276283
toast.error(data.message || '修改失败')
@@ -292,6 +299,7 @@ const onDelete = async (params: AnyObj) => {
292299
if (status === 200 && data && typeof data === 'object') {
293300
if (data.success) {
294301
toast.info('删除成功')
302+
emits('notify', 'delete')
295303
refreshData()
296304
} else {
297305
toast.error(data.message || '删除失败')

src/components/config/ConfigFormContainer.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ import { useMessage, NButton } from 'naive-ui'
7878
import constant from '@/types/constant'
7979
import type { AnyObj } from 'encjs/core/base'
8080
import { CloseOutline } from '@vicons/ionicons5'
81-
81+
import { namespaceStore } from '@/data/namespace'
8282
const toast = useMessage()
8383
const configForm = ref<HTMLDivElement>() as any
8484
let props = defineProps({
@@ -134,13 +134,13 @@ const onNext = async () => {
134134
vt.value = 2
135135
}
136136
}
137-
138137
/**
139138
* 保存配置数据
140139
*
141140
* @param formData 配置项
142141
*/
143142
const onSave = async (formData: AnyObj) => {
143+
formData.tenant = namespaceStore.current.value.namespaceId
144144
let url = formData.mode === 'add' || formData.mode === constant.FORM_MODE_CREATE ? `${apis.configAdd || ''}` : `${apis.configUpdate || ''}`
145145
let { status, data } = await apis.postJSON(url, {
146146
data: formData,

src/components/namespace/NamespacePopSelect.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<template>
22
<n-select
33
class="on-select"
4-
v-model:value="value.namespaceId"
4+
v-model:value="namespaceId"
55
:options="optionList"
66
size="medium"
77
@update:value="update"
@@ -18,7 +18,7 @@ import { namespaceStore } from '@/data/namespace'
1818
let value = namespaceStore.current as any
1919
let optionList = namespaceStore.optionList as any
2020
const emits = defineEmits(['change'])
21-
21+
const namespaceId = ref(namespaceStore.current.value.namespaceId || '')
2222
/**
2323
*
2424
* @param v 选中项
@@ -30,7 +30,7 @@ const update = (v: string) => {
3030
namespaceId: item.value,
3131
namespaceName: item.label,
3232
}
33-
value = obj
33+
namespaceId.value = item.value
3434
namespaceStore.setCurrent(obj)
3535
emits('change', obj)
3636
}

src/data/namespace.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,21 @@ function createStore(): INamespaceStore {
5050
}
5151
}
5252

53+
const refresh = async () => {
54+
const { status, data } = await apis.getJSON(apis.namespacesList)
55+
if (status == 200 && data && typeof data === 'object' && Array.isArray(data.data)) {
56+
setLastList(data.data)
57+
}
58+
}
59+
5360
return {
5461
current: currentRef,
5562
listList: listListRef,
5663
optionList: optionListRef,
5764
setCurrent,
5865
setLastList,
5966
initLoad,
67+
refresh,
6068
}
6169
}
6270

src/pages/manage/namespace.vue

Lines changed: 35 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
validator: validator,
1616
pagination: paginationReactive,
1717
}"
18+
@notify="notify"
1819
>
1920
<template #header="{ methods }">
2021
<div>命名空间</div>
@@ -49,7 +50,10 @@
4950
path="namespaceId"
5051
label="命名空间Id"
5152
>
52-
<NInput v-model:value="formData.namespaceId" />
53+
<NInput
54+
v-model:value="formData.namespaceId"
55+
:disabled="formData.mode === 'update'"
56+
/>
5357
</NFormItem>
5458
</NForm>
5559
</template>
@@ -61,9 +65,12 @@ import { NPopconfirm, NTag, NButton, NForm, NFormItem, NInput, type FormItemRule
6165
import apis from '@/apis/index'
6266
import type { INamespace } from '@/types/namespace'
6367
import { useWebResources } from '@/data/resources'
68+
import { namespaceStore } from '@/data/namespace'
69+
6470
let webResources = useWebResources()
6571
const formRef = ref<FormInst | null>(null)
6672
const pageContainer = ref<any>(null)
73+
const columns = ref<any>([])
6774
const paginationReactive = reactive({
6875
page: 1,
6976
pageCount: 1,
@@ -83,18 +90,18 @@ const paginationReactive = reactive({
8390
/**
8491
* 表格表格字段
8592
*/
86-
const columns = [
87-
{
88-
title: '命名空间名称',
89-
key: 'namespaceName',
90-
},
91-
{
92-
title: '命名空间ID',
93-
key: 'namespaceId',
94-
},
95-
]
96-
const optColumn = [
97-
{
93+
const createColumns = () => {
94+
const columns = [
95+
{
96+
title: '命名空间名称',
97+
key: 'namespaceName',
98+
},
99+
{
100+
title: '命名空间ID',
101+
key: 'namespaceId',
102+
},
103+
]
104+
const optColumn = {
98105
title: '操作',
99106
key: 'type',
100107
fixed: 'right',
@@ -141,12 +148,23 @@ const optColumn = [
141148
</div>
142149
)
143150
},
144-
},
145-
]
146-
if (webResources.canUpdateNamespace) {
147-
columns.push(optColumn)
151+
}
152+
153+
if (webResources.canUpdateNamespace) {
154+
columns.push(optColumn)
155+
}
156+
return columns
157+
}
158+
159+
// 通知更新命名空间
160+
const notify = (mark: string = '') => {
161+
namespaceStore.refresh()
148162
}
149163
164+
onMounted(() => {
165+
columns.value = createColumns()
166+
})
167+
150168
/**
151169
* 表单校验
152170
*/

src/pages/manage/service/index.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
type="info"
6363
@click="
6464
methods.createForm({
65+
namespaceId: namespaceStore.current.value.namespaceId || '',
6566
groupName: '',
6667
serviceName: '',
6768
protectThreshold: 0,
@@ -156,7 +157,7 @@ const router = useRouter()
156157
const paramRef = ref({
157158
serviceParam: '',
158159
groupParam: '',
159-
namespaceId: '',
160+
namespaceId: namespaceStore.current.value.namespaceId,
160161
pageNo: 1,
161162
pageSize: 10,
162163
})

src/pages/p/login.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
placeholder="验证码"
4242
v-model:value="modelRef.captcha"
4343
@keydown.enter.prevent
44+
@keyup.enter="submit"
4445
/>
4546
</n-form-item>
4647
</div>

src/types/namespace.d.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,6 @@ export interface INamespaceStore {
1616
optionList: Ref<UnwrapRef<Array<ILabelItem>>>
1717
setCurrent: (arg0: INamespace) => any
1818
setLastList: (list: Array<INamespace>) => any
19-
initLoad: () => any
19+
initLoad: () => void
20+
refresh: () => void
2021
}

0 commit comments

Comments
 (0)