Aurora Admin v1.2.0: 79 components x 5 ends, doc site, contracts batch 1, playground, regression, deploy ready

This commit is contained in:
aurora-admin
2026-09-10 19:21:56 +08:00
commit 51ce3a28f7
654 changed files with 49082 additions and 0 deletions
+71
View File
@@ -0,0 +1,71 @@
<template>
<div class="aa-formmodal-mask" v-if="visible" @click.self="$emit('cancel')">
<div class="aa-formmodal">
<div class="aa-formmodal-head">
<span>{{ title }}</span>
<button class="aa-formmodal-close" @click="$emit('cancel')">×</button>
</div>
<div class="aa-formmodal-body">
<div class="aa-form-row" v-for="f in fields" :key="f.key">
<label class="aa-form-label"><span class="req" v-if="f.required">*</span>{{ f.label }}</label>
<input
class="aa-form-input"
:class="{ 'is-error': errors[f.key] }"
:value="form[f.key]"
:placeholder="f.placeholder"
@input="onInput(f.key, $event)"
/>
<div class="aa-form-err" v-if="errors[f.key]">{{ errors[f.key] }}</div>
</div>
</div>
<div class="aa-formmodal-foot">
<button class="aa-btn" @click="$emit('cancel')">取消</button>
<button class="aa-btn aa-btn--primary" @click="submit">提交</button>
</div>
</div>
</div>
</template>
<script>
export default {
name: 'AaFormModal',
props: {
visible: { type: Boolean, default: false },
title: { type: String, default: '表单' },
fields: {
type: Array,
default: () => [
{ key: 'name', label: '姓名', required: true, placeholder: '请输入姓名' },
{ key: 'email', label: '邮箱', required: true, placeholder: 'name@example.com' },
{ key: 'role', label: '角色', placeholder: '如:管理员' }
]
},
value: { type: Object, default: () => ({}) }
},
data() {
return { form: Object.assign({}, this.value), errors: {} };
},
watch: {
visible(v) { if (v) { this.form = Object.assign({}, this.value); this.errors = {}; } }
},
methods: {
onInput(key, e) {
this.$set(this.form, key, e.target.value);
if (this.errors[key]) this.$delete(this.errors, key);
},
submit() {
var errors = {};
this.fields.forEach(function (f) {
var v = (this.form[f.key] || '').trim();
if (f.required && !v) errors[f.key] = f.label + '不能为空';
if (f.key === 'email' && v && !/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(v)) errors[f.key] = '邮箱格式不正确';
}, this);
if (Object.keys(errors).length) { this.errors = errors; return; }
this.$emit('submit', Object.assign({}, this.form));
this.$emit('cancel');
}
}
};
</script>
<style src="./FormModal.css"></style>