Skip to content

Commit 22f649f

Browse files
committed
fix(user): user manage
1 parent e73ace1 commit 22f649f

File tree

9 files changed

+102
-67
lines changed

9 files changed

+102
-67
lines changed

frontend/src/views/ds/Datasource.vue

Lines changed: 33 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import DatasourceListSide from './DatasourceListSide.vue'
1414
import DatasourceForm from './DatasourceForm.vue'
1515
import { datasourceApi } from '@/api/datasource'
1616
import Card from './Card.vue'
17-
import { dsTypeWithImg } from './js/ds-type'
17+
import { dsTypeWithImgSort } from './js/ds-type'
1818
import { useI18n } from 'vue-i18n'
1919
2020
interface Datasource {
@@ -34,20 +34,24 @@ const datasourceConfigvVisible = ref(false)
3434
const editDatasource = ref(false)
3535
const activeStep = ref(0)
3636
const activeName = ref('')
37+
const activeType = ref('')
3738
const datasourceFormRef = ref()
3839
3940
const datasourceList = shallowRef([] as Datasource[])
40-
const defaultDatasourceList = shallowRef(dsTypeWithImg as (Datasource & { img: string })[])
41+
const defaultDatasourceList = shallowRef(dsTypeWithImgSort as (Datasource & { img: string })[])
4142
4243
const currentDefaultDatasource = ref('')
4344
const datasourceListWithSearch = computed(() => {
44-
if (!keywords.value) return datasourceList.value
45-
return datasourceList.value.filter((ele) =>
46-
ele.name.toLowerCase().includes(keywords.value.toLowerCase())
45+
if (!keywords.value && !currentDatasourceType.value) return datasourceList.value
46+
return datasourceList.value.filter(
47+
(ele) =>
48+
ele.name.toLowerCase().includes(keywords.value.toLowerCase()) &&
49+
(ele.type === currentDatasourceType.value || !currentDatasourceType.value)
4750
)
4851
})
4952
const beforeClose = () => {
5053
datasourceConfigvVisible.value = false
54+
activeStep.value = 0
5155
}
5256
const defaultDatasourceListWithSearch = computed(() => {
5357
if (!defaultDatasourceKeywords.value) return defaultDatasourceList.value
@@ -56,8 +60,16 @@ const defaultDatasourceListWithSearch = computed(() => {
5660
)
5761
})
5862
63+
const currentDatasourceType = ref('')
64+
5965
const handleDefaultDatasourceChange = (item: any) => {
60-
currentDefaultDatasource.value = item.name
66+
if (currentDatasourceType.value === item.type) {
67+
currentDefaultDatasource.value = ''
68+
currentDatasourceType.value = ''
69+
} else {
70+
currentDefaultDatasource.value = item.name
71+
currentDatasourceType.value = item.type
72+
}
6173
}
6274
6375
const formatKeywords = (item: string) => {
@@ -92,6 +104,14 @@ const handleAddDatasource = () => {
92104
datasourceConfigvVisible.value = true
93105
}
94106
107+
const refresh = () => {
108+
activeName.value = ''
109+
activeStep.value = 0
110+
activeType.value = ''
111+
datasourceConfigvVisible.value = false
112+
search()
113+
}
114+
95115
const deleteHandler = (item: any) => {
96116
ElMessageBox.confirm(t('datasource.data_source', { msg: item.name }), {
97117
confirmButtonType: 'danger',
@@ -124,11 +144,12 @@ const deleteHandler = (item: any) => {
124144
const clickDatasource = (ele: any) => {
125145
activeStep.value = 1
126146
activeName.value = ele.name
147+
activeType.value = ele.type
127148
}
128149
129150
const clickDatasourceSide = (ele: any) => {
130151
activeName.value = ele.name
131-
activeStep.value = 1
152+
activeType.value = ele.type
132153
}
133154
134155
const search = () => {
@@ -138,28 +159,6 @@ const search = () => {
138159
}
139160
search()
140161
141-
const submit = (item: any) => {
142-
if (!item.id) {
143-
datasourceApi.add(item).then(() => {
144-
beforeClose()
145-
search()
146-
ElMessage({
147-
type: 'success',
148-
message: 'Add completed',
149-
})
150-
})
151-
return
152-
}
153-
datasourceApi.edit(item).then(() => {
154-
beforeClose()
155-
search()
156-
ElMessage({
157-
type: 'success',
158-
message: 'Edit completed',
159-
})
160-
})
161-
}
162-
163162
const currentDataTable = ref()
164163
const dataTableDetail = (ele: any) => {
165164
currentDataTable.value = ele
@@ -187,7 +186,7 @@ const dataTableDetail = (ele: any) => {
187186
<el-popover popper-class="system-default_datasource" placement="bottom">
188187
<template #reference>
189188
<el-button secondary>
190-
{{ $t('datasource.all_types') }}
189+
{{ currentDefaultDatasource || $t('datasource.all_types') }}
191190
<el-icon style="margin-left: 8px">
192191
<arrow_down></arrow_down>
193192
</el-icon> </el-button
@@ -298,7 +297,8 @@ const dataTableDetail = (ele: any) => {
298297
ref="datasourceFormRef"
299298
:active-step="activeStep"
300299
:active-name="activeName"
301-
@submit="submit"
300+
:active-type="activeType"
301+
@refresh="refresh"
302302
@change-active-step="(val: number) => (activeStep = val)"
303303
></DatasourceForm>
304304
</el-drawer>
@@ -324,6 +324,8 @@ const dataTableDetail = (ele: any) => {
324324
.card-content {
325325
display: flex;
326326
flex-wrap: wrap;
327+
max-height: calc(100% - 40px);
328+
overflow-y: auto;
327329
}
328330
}
329331
</style>

frontend/src/views/ds/DatasourceForm.vue

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,19 @@ import EmptyBackground from '@/views/dashboard/common/EmptyBackground.vue'
1616
const props = withDefaults(
1717
defineProps<{
1818
activeName: string
19+
activeType: string
1920
activeStep: number
2021
}>(),
2122
{
2223
activeName: '',
24+
activeType: '',
2325
activeStep: 0,
2426
}
2527
)
2628
2729
const { wsCache } = useCache()
2830
const dsFormRef = ref<FormInstance>()
29-
const emit = defineEmits(['refresh', 'submit', 'changeActiveStep'])
31+
const emit = defineEmits(['refresh', 'changeActiveStep'])
3032
const isCreate = ref(true)
3133
const isEditTable = ref(false)
3234
const checkList = ref<any>([])
@@ -58,7 +60,7 @@ const dialogVisible = ref<boolean>(false)
5860
const form = ref<any>({
5961
name: '',
6062
description: '',
61-
type: 'mysql',
63+
type: props.activeType,
6264
configuration: '',
6365
driver: '',
6466
host: '',
@@ -326,14 +328,6 @@ onMounted(() => {
326328
}, 100)
327329
})
328330
329-
const submitModle = () => {
330-
dsFormRef.value!.validate((res: any) => {
331-
if (res) {
332-
emit('submit')
333-
}
334-
})
335-
}
336-
337331
const keywords = ref('')
338332
const tableListWithSearch = computed(() => {
339333
if (!keywords.value) return tableList.value
@@ -350,6 +344,13 @@ watch(keywords, () => {
350344
isIndeterminate.value = checkedCount > 0 && checkedCount < tableListWithSearch.value.length
351345
})
352346
347+
watch(
348+
() => props.activeType,
349+
(val) => {
350+
form.value.type = val
351+
}
352+
)
353+
353354
const checkAll = ref(false)
354355
const isIndeterminate = ref(false)
355356
let checkTableList = [] as any[]
@@ -386,7 +387,6 @@ const tableListSave = () => {
386387
387388
defineExpose({
388389
initForm,
389-
submitModle,
390390
tableListSave,
391391
})
392392
</script>

frontend/src/views/ds/DatasourceList.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const handleModelClick = (item: any) => {
2626
</script>
2727

2828
<template>
29-
<div class="model-list">
29+
<div class="datasouce-list">
3030
<div class="title">{{ $t('qa.select_datasource') }}</div>
3131
<el-input
3232
v-model="keywords"
@@ -61,7 +61,7 @@ const handleModelClick = (item: any) => {
6161
</template>
6262

6363
<style lang="less" scoped>
64-
.model-list {
64+
.datasouce-list {
6565
width: 800px;
6666
margin: 0 auto;
6767
max-height: 100%;
@@ -91,7 +91,7 @@ const handleModelClick = (item: any) => {
9191
padding-left: 16px;
9292
margin-bottom: 16px;
9393
border: 1px solid #dee0e3;
94-
border-radius: 4px;
94+
border-radius: 12px;
9595
margin-left: 16px;
9696
cursor: pointer;
9797
&:hover {

frontend/src/views/ds/js/ds-type.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,19 @@ export const dsType = [
1313
]
1414

1515
export const dsTypeWithImg = [
16+
{ name: '本地 Excel/CSV', type: 'excel', img: excel },
1617
{ name: 'MySQL', type: 'mysql', img: mysql_ds },
17-
{ name: 'PostgreSQL', type: 'pg', img: pg },
18-
{ name: 'Microsoft SQL Server', type: 'sqlServer', img: sqlServer },
18+
{ name: 'SQL Server', type: 'sqlServer', img: sqlServer },
1919
{ name: 'Oracle', type: 'oracle', img: oracle },
20+
{ name: 'PostgreSQL', type: 'pg', img: pg },
21+
]
22+
23+
export const dsTypeWithImgSort = [
2024
{ name: '本地 Excel/CSV', type: 'excel', img: excel },
25+
{ name: 'PostgreSQL', type: 'pg', img: pg },
26+
{ name: 'Oracle', type: 'oracle', img: oracle },
27+
{ name: 'MySQL', type: 'mysql', img: mysql_ds },
28+
{ name: 'SQL Server', type: 'sqlServer', img: sqlServer },
2129
]
2230

2331
export const haveSchema = ['sqlServer', 'pg', 'oracle']

frontend/src/views/system/model/Card.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ const current_supplier = computed(() => {
3030
const emits = defineEmits(['edit', 'del'])
3131
3232
const handleEdit = () => {
33-
emits('edit', props.id)
33+
emits('edit')
3434
}
3535
3636
const handleDel = () => {

frontend/src/views/system/model/Model.vue

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ const modelConfigvVisible = ref(false)
3232
const editModel = ref(false)
3333
const activeStep = ref(0)
3434
const activeName = ref('')
35+
const activeType = ref('')
3536
const modelFormRef = ref()
3637
3738
reactive({
@@ -102,9 +103,11 @@ const handleAddModel = () => {
102103
activeStep.value = 0
103104
modelConfigvVisible.value = true
104105
}
105-
const handleEditModel = (id: any) => {
106+
const handleEditModel = (row: any) => {
106107
activeStep.value = 1
107-
modelApi.query(id).then((res: any) => {
108+
activeType.value = row.supplier
109+
activeName.value = row.supplier_item.name
110+
modelApi.query(row.id).then((res: any) => {
108111
modelConfigvVisible.value = true
109112
nextTick(() => {
110113
modelFormRef.value.initForm({ ...res })
@@ -287,7 +290,7 @@ const submit = (item: any) => {
287290
:modle-type="getModelTypeName(ele['model_type'])"
288291
:base-modle="ele['base_model']"
289292
:is-default="ele['default_model']"
290-
@edit="handleEditModel"
293+
@edit="handleEditModel(ele)"
291294
@del="deleteHandler"
292295
></card>
293296
</div>
@@ -320,12 +323,14 @@ const submit = (item: any) => {
320323
<ModelListSide
321324
v-if="activeStep === 1"
322325
:active-name="activeName"
326+
:active-type="activeType"
323327
@click-model="supplierChang"
324328
></ModelListSide>
325329
<ModelForm
326330
v-if="activeStep === 1"
327331
ref="modelFormRef"
328332
:active-name="activeName"
333+
:active-type="activeType"
329334
@submit="submit"
330335
></ModelForm>
331336
<template #footer>

0 commit comments

Comments
 (0)