mirror of
https://gitee.com/devlive-community/datacap.git
synced 2024-12-02 03:57:35 +08:00
refactor(page): refactor source --> metadata --> column drop
This commit is contained in:
parent
0de2b04c7d
commit
9e52c41ddf
@ -72,16 +72,17 @@
|
||||
<span>{{ $t('source.common.changeColumn') }}</span>
|
||||
</div>
|
||||
</ShadcnContextMenuItem>
|
||||
|
||||
<ShadcnContextMenuItem v-if="dataInfo?.level === StructureEnum.COLUMN" @click="visibleDropColumn(true)">
|
||||
<div class="flex items-center space-x-1">
|
||||
<ShadcnIcon icon="Delete" size="15"/>
|
||||
<span>{{ $t('source.common.dropColumn') }}</span>
|
||||
</div>
|
||||
</ShadcnContextMenuItem>
|
||||
</ShadcnContextMenu>
|
||||
</div>
|
||||
</ShadcnCard>
|
||||
|
||||
<!-- <DropdownMenuItem v-if="dataInfo?.level === StructureEnum.COLUMN" class="cursor-pointer" @click="handlerDropColumn(true)">-->
|
||||
<!-- <Delete :size="18" class="mr-2"/>-->
|
||||
<!-- {{ $t('source.common.dropColumn') }}-->
|
||||
<!-- </DropdownMenuItem>-->
|
||||
<!-- </DropdownMenuContent>-->
|
||||
<!-- </DropdownMenu>-->
|
||||
<TableCreate v-if="tableCreateVisible"
|
||||
:is-visible="tableCreateVisible"
|
||||
:info="dataInfo"
|
||||
@ -112,7 +113,10 @@
|
||||
:info="dataInfo"
|
||||
@close="visibleChangeColumn(false)"/>
|
||||
|
||||
<!-- <ColumnDrop v-if="columnDropVisible" :isVisible="columnDropVisible" :info="dataInfo" @close="handlerDropColumn(false)"/>-->
|
||||
<ColumnDrop v-if="columnDropVisible"
|
||||
:is-visible="columnDropVisible"
|
||||
:info="dataInfo"
|
||||
@close="visibleDropColumn(false)"/>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
@ -291,7 +295,7 @@ export default defineComponent({
|
||||
{
|
||||
this.columnChangeVisible = opened
|
||||
},
|
||||
handlerDropColumn(opened: boolean)
|
||||
visibleDropColumn(opened: boolean)
|
||||
{
|
||||
this.columnDropVisible = opened
|
||||
},
|
||||
@ -304,21 +308,6 @@ export default defineComponent({
|
||||
this.dataInfo = node
|
||||
this.contextmenu.visible = true
|
||||
},
|
||||
getColumnIcon(type: string)
|
||||
{
|
||||
if (type === 'PRI') {
|
||||
return 'key'
|
||||
}
|
||||
else if (type === 'MUL') {
|
||||
return 'repeat'
|
||||
}
|
||||
else if (type === 'UNI') {
|
||||
return 'circle'
|
||||
}
|
||||
else {
|
||||
return 'columns'
|
||||
}
|
||||
},
|
||||
getColumnTitle(dataType: string, extra: string, isKey: string, defaultValue: string)
|
||||
{
|
||||
let title = dataType
|
||||
|
@ -1,28 +1,37 @@
|
||||
<template>
|
||||
<Dialog :is-visible="visible" :title="title as string" :width="'40%'">
|
||||
<div class="grid w-full gap-2 pt-1 pl-3 pr-3">
|
||||
<Alert type="error" :description="$t('source.tip.dropColumn1')"/>
|
||||
<Alert type="error" :description="$t('source.tip.dropColumn2')"/>
|
||||
<Alert type="error" :description="$t('source.tip.dropColumn3')"/>
|
||||
<Alert type="error" :description="$t('source.tip.dropColumn4')"/>
|
||||
<Alert type="error" :description="$t('source.tip.dropColumn5')"/>
|
||||
</div>
|
||||
<CircularLoading v-if="loading" :show="loading"/>
|
||||
<div v-else>
|
||||
<Divider class="mt-2 mb-4"/>
|
||||
<AceEditor :value="formState.statement" :read-only="true"/>
|
||||
<ShadcnModal v-model="visible"
|
||||
width="40%"
|
||||
:title="title"
|
||||
@on-close="onCancel">
|
||||
<ShadcnSpace wrap>
|
||||
<ShadcnAlert type="error" :title="$t('source.tip.dropColumn1')"/>
|
||||
<ShadcnAlert type="error" :title="$t('source.tip.dropColumn2')"/>
|
||||
<ShadcnAlert type="error" :title="$t('source.tip.dropColumn3')"/>
|
||||
<ShadcnAlert type="error" :title="$t('source.tip.dropColumn4')"/>
|
||||
<ShadcnAlert type="error" :title="$t('source.tip.dropColumn5')"/>
|
||||
</ShadcnSpace>
|
||||
|
||||
<div class="relative mt-2">
|
||||
<ShadcnSpin v-model="loading"/>
|
||||
|
||||
<AceEditor v-if="formState.statement" :value="formState.statement" :read-only="true"/>
|
||||
</div>
|
||||
|
||||
<template #footer>
|
||||
<div class="space-x-5">
|
||||
<Button variant="outline" size="sm" @click="handlerCancel">
|
||||
<ShadcnSpace>
|
||||
<ShadcnButton type="default" @click="onCancel">
|
||||
{{ $t('common.cancel') }}
|
||||
</Button>
|
||||
<Button size="sm" color="#ed4014" :loading="submitting" :disabled="submitting" @click="handlerSubmit(false)">
|
||||
</ShadcnButton>
|
||||
|
||||
<ShadcnButton type="error"
|
||||
:loading="submitting"
|
||||
:disabled="submitting"
|
||||
@click="onSubmit(false)">
|
||||
{{ $t('source.common.dropColumn') }}
|
||||
</Button>
|
||||
</div>
|
||||
</ShadcnButton>
|
||||
</ShadcnSpace>
|
||||
</template>
|
||||
</Dialog>
|
||||
</ShadcnModal>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
@ -30,7 +39,6 @@ import { defineComponent } from 'vue'
|
||||
import { StructureModel } from '@/model/structure.ts'
|
||||
import TableService from '@/services/table'
|
||||
import { SqlType, TableFilter, TableFilterRequest } from '@/model/table'
|
||||
import { toNumber } from 'lodash'
|
||||
|
||||
import AceEditor from '@/views/components/editor/AceEditor.vue'
|
||||
|
||||
@ -71,13 +79,14 @@ export default defineComponent({
|
||||
this.formState = TableFilterRequest.of()
|
||||
this.formState.type = SqlType.DROP
|
||||
if (this.info) {
|
||||
this.formState.columnId = toNumber(this.info.applyId)
|
||||
this.formState.columnId = Number(this.info.applyId)
|
||||
this.title = this.$t('source.common.dropColumnInfo').replace('$VALUE', this.info.title as string)
|
||||
this.handlerSubmit(true)
|
||||
|
||||
this.onSubmit(true)
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
handlerSubmit(preview: boolean)
|
||||
onSubmit(preview: boolean)
|
||||
{
|
||||
if (this.info && this.formState) {
|
||||
if (preview) {
|
||||
@ -87,19 +96,26 @@ export default defineComponent({
|
||||
this.submitting = true
|
||||
}
|
||||
this.formState.preview = preview
|
||||
TableService.getData(this.info.tableId as string, this.formState)
|
||||
TableService.getData(String(this.info.tableId), this.formState)
|
||||
.then(response => {
|
||||
if (response.status) {
|
||||
if (preview) {
|
||||
this.formState.statement = response.data.content
|
||||
}
|
||||
else {
|
||||
ToastUtils.success(this.$t('source.tip.dropColumnSuccess').replace('$VALUE', this.info?.title as string))
|
||||
this.handlerCancel()
|
||||
this.$Message.success({
|
||||
content: this.$t('source.tip.dropColumnSuccess').replace('$VALUE', String(this.info?.title)),
|
||||
showIcon: true
|
||||
})
|
||||
|
||||
this.onCancel()
|
||||
}
|
||||
}
|
||||
else {
|
||||
ToastUtils.success(response.message)
|
||||
this.$Message.error({
|
||||
content: response.message,
|
||||
showIcon: true
|
||||
})
|
||||
}
|
||||
})
|
||||
.finally(() => {
|
||||
@ -112,7 +128,7 @@ export default defineComponent({
|
||||
})
|
||||
}
|
||||
},
|
||||
handlerCancel()
|
||||
onCancel()
|
||||
{
|
||||
this.visible = false
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user