mirror of
https://github.com/1Panel-dev/MaxKB.git
synced 2025-12-26 10:12:51 +00:00
88 lines
1.9 KiB
Vue
88 lines
1.9 KiB
Vue
<template>
|
|
<el-dialog
|
|
:title="$t('views.functionLib.functionForm.form.functionName.placeholder')"
|
|
v-model="dialogVisible"
|
|
:close-on-click-modal="false"
|
|
:close-on-press-escape="false"
|
|
:destroy-on-close="true"
|
|
append-to-body
|
|
width="450"
|
|
>
|
|
<el-form
|
|
label-position="top"
|
|
ref="fieldFormRef"
|
|
:rules="rules"
|
|
:model="form"
|
|
require-asterisk-position="right"
|
|
>
|
|
<el-form-item prop="name">
|
|
<el-input v-model="form.name" maxlength="64" show-word-limit></el-input>
|
|
</el-form-item>
|
|
</el-form>
|
|
<template #footer>
|
|
<span class="dialog-footer">
|
|
<el-button @click.prevent="dialogVisible = false"> {{ $t('common.cancel') }} </el-button>
|
|
<el-button type="primary" @click="submit(fieldFormRef)" :loading="loading">
|
|
{{ $t('common.add') }}
|
|
</el-button>
|
|
</span>
|
|
</template>
|
|
</el-dialog>
|
|
</template>
|
|
<script setup lang="ts">
|
|
import { reactive, ref, watch } from 'vue'
|
|
import type { FormInstance } from 'element-plus'
|
|
import { cloneDeep } from 'lodash'
|
|
import { t } from '@/locales'
|
|
|
|
const emit = defineEmits(['refresh'])
|
|
|
|
const fieldFormRef = ref()
|
|
const loading = ref<boolean>(false)
|
|
|
|
const form = ref<any>({
|
|
name: ''
|
|
})
|
|
|
|
const rules = reactive({
|
|
name: [
|
|
{
|
|
required: true,
|
|
message: t('views.functionLib.functionForm.form.functionName.placeholder'),
|
|
trigger: 'blur'
|
|
}
|
|
]
|
|
})
|
|
|
|
const dialogVisible = ref<boolean>(false)
|
|
|
|
watch(dialogVisible, (bool) => {
|
|
if (!bool) {
|
|
form.value = {
|
|
name: ''
|
|
}
|
|
}
|
|
})
|
|
|
|
const open = (row: any) => {
|
|
if (row) {
|
|
form.value = cloneDeep(row)
|
|
}
|
|
|
|
dialogVisible.value = true
|
|
}
|
|
|
|
const submit = async (formEl: FormInstance | undefined) => {
|
|
if (!formEl) return
|
|
await formEl.validate((valid) => {
|
|
if (valid) {
|
|
emit('refresh', form.value)
|
|
dialogVisible.value = false
|
|
}
|
|
})
|
|
}
|
|
|
|
defineExpose({ open })
|
|
</script>
|
|
<style lang="scss" scoped></style>
|