mirror of
https://github.com/0xJacky/nginx-ui.git
synced 2025-05-11 02:15:48 +02:00
refactor: refactor app and api
This commit is contained in:
parent
5ab50b8a93
commit
287ef7527d
157 changed files with 8116 additions and 3587 deletions
77
app/src/components/StdDesign/StdDataDisplay/StdBatchEdit.vue
Normal file
77
app/src/components/StdDesign/StdDataDisplay/StdBatchEdit.vue
Normal file
|
@ -0,0 +1,77 @@
|
|||
<script setup lang="ts">
|
||||
import { message } from 'ant-design-vue'
|
||||
import gettext from '@/gettext'
|
||||
import StdDataEntry from '@/components/StdDesign/StdDataEntry'
|
||||
|
||||
const props = defineProps<{
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
api: (ids: number[], data: any) => Promise<void>
|
||||
beforeSave?: () => Promise<void>
|
||||
}>()
|
||||
|
||||
const emit = defineEmits(['onSave'])
|
||||
|
||||
const { $gettext } = gettext
|
||||
|
||||
const batchColumns = ref([])
|
||||
|
||||
const visible = ref(false)
|
||||
|
||||
const selectedRowKeys = ref([])
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
function showModal(c: any, rowKeys: any) {
|
||||
visible.value = true
|
||||
selectedRowKeys.value = rowKeys
|
||||
batchColumns.value = c
|
||||
}
|
||||
|
||||
defineExpose({
|
||||
showModal,
|
||||
})
|
||||
|
||||
const data = reactive({})
|
||||
const error = reactive({})
|
||||
const loading = ref(false)
|
||||
|
||||
async function ok() {
|
||||
loading.value = true
|
||||
|
||||
await props.beforeSave?.()
|
||||
|
||||
await props.api(selectedRowKeys.value, data).then(async () => {
|
||||
message.success($gettext('Save successfully'))
|
||||
emit('onSave')
|
||||
}).catch(e => {
|
||||
message.error($gettext(e?.message) ?? $gettext('Server error'))
|
||||
}).finally(() => {
|
||||
loading.value = false
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<AModal
|
||||
v-model:open="visible"
|
||||
class="std-curd-edit-modal"
|
||||
:mask="false"
|
||||
:title="$gettext('Batch Modify')"
|
||||
:cancel-text="$gettext('Cancel')"
|
||||
:ok-text="$gettext('OK')"
|
||||
:confirm-loading="loading"
|
||||
:width="600"
|
||||
destroy-on-close
|
||||
@ok="ok"
|
||||
>
|
||||
<StdDataEntry
|
||||
:data-list="batchColumns"
|
||||
:data-source="data"
|
||||
:error="error"
|
||||
/>
|
||||
|
||||
<slot name="extra" />
|
||||
</AModal>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
Loading…
Add table
Add a link
Reference in a new issue