feat(keys): auto-generate entity keys and remove manual key input from admin create forms
This commit is contained in:
@@ -23,7 +23,6 @@
|
||||
|
||||
<el-dialog v-model="showDialog" title="新增公司" @close="resetForm">
|
||||
<el-form ref="formRef" :model="form" :rules="rules" label-width="100px">
|
||||
<el-form-item label="Company Key" prop="company_key"><el-input v-model="form.company_key" /></el-form-item>
|
||||
<el-form-item label="名稱" prop="name"><el-input v-model="form.name" /></el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
@@ -79,10 +78,9 @@ const showEditDialog = ref(false)
|
||||
const savingEdit = ref(false)
|
||||
const formRef = ref()
|
||||
|
||||
const form = ref({ company_key: '', name: '' })
|
||||
const form = ref({ name: '' })
|
||||
const editForm = ref({ company_key: '', name: '', status: 'active' })
|
||||
const rules = {
|
||||
company_key: [{ required: true, message: '請輸入 Company Key', trigger: 'blur' }],
|
||||
name: [{ required: true, message: '請輸入名稱', trigger: 'blur' }]
|
||||
}
|
||||
|
||||
@@ -108,7 +106,7 @@ async function load() {
|
||||
}
|
||||
|
||||
function resetForm() {
|
||||
form.value = { company_key: '', name: '' }
|
||||
form.value = { name: '' }
|
||||
}
|
||||
|
||||
function openEdit(row) {
|
||||
@@ -125,8 +123,8 @@ async function handleCreate() {
|
||||
if (!valid) return
|
||||
submitting.value = true
|
||||
try {
|
||||
await createCompany(form.value)
|
||||
ElMessage.success('新增成功')
|
||||
const res = await createCompany(form.value)
|
||||
ElMessage.success(`新增成功:${res.data?.company_key || ''}`)
|
||||
showDialog.value = false
|
||||
resetForm()
|
||||
await load()
|
||||
|
||||
@@ -38,9 +38,6 @@
|
||||
<el-option v-for="s in systems" :key="s.system_key" :label="`${s.name} (${s.system_key})`" :value="s.system_key" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="Module Key" prop="module_key">
|
||||
<el-input v-model="form.module_key" placeholder="campaign" />
|
||||
</el-form-item>
|
||||
<el-form-item label="名稱" prop="name">
|
||||
<el-input v-model="form.name" placeholder="行銷活動" />
|
||||
</el-form-item>
|
||||
@@ -119,11 +116,10 @@ const formRef = ref()
|
||||
const showEditDialog = ref(false)
|
||||
const savingEdit = ref(false)
|
||||
|
||||
const form = ref({ system_key: '', module_key: '', name: '' })
|
||||
const form = ref({ system_key: '', name: '' })
|
||||
const editForm = ref({ module_key: '', name: '', status: 'active' })
|
||||
const rules = {
|
||||
system_key: [{ required: true, message: '請輸入 System Key', trigger: 'blur' }],
|
||||
module_key: [{ required: true, message: '請輸入 Module Key', trigger: 'blur' }],
|
||||
name: [{ required: true, message: '請輸入名稱', trigger: 'blur' }]
|
||||
}
|
||||
|
||||
@@ -152,7 +148,7 @@ async function load() {
|
||||
}
|
||||
|
||||
function resetForm() {
|
||||
form.value = { system_key: '', module_key: '', name: '' }
|
||||
form.value = { system_key: '', name: '' }
|
||||
}
|
||||
|
||||
function openEdit(row) {
|
||||
@@ -173,8 +169,8 @@ async function handleCreate() {
|
||||
if (!valid) return
|
||||
submitting.value = true
|
||||
try {
|
||||
await createModule(form.value)
|
||||
ElMessage.success('新增成功')
|
||||
const res = await createModule(form.value)
|
||||
ElMessage.success(`新增成功:${res.data?.module_key || ''}`)
|
||||
showDialog.value = false
|
||||
resetForm()
|
||||
await load()
|
||||
|
||||
@@ -93,9 +93,6 @@
|
||||
|
||||
<el-dialog v-model="showCreateGroup" title="新增群組" @close="resetCreateForm">
|
||||
<el-form :model="createForm" label-width="120px">
|
||||
<el-form-item label="Group Key">
|
||||
<el-input v-model="createForm.group_key" placeholder="group-001" />
|
||||
</el-form-item>
|
||||
<el-form-item label="群組名稱">
|
||||
<el-input v-model="createForm.name" placeholder="群組名稱" />
|
||||
</el-form-item>
|
||||
@@ -157,7 +154,7 @@ const members = ref([])
|
||||
|
||||
const showCreateGroup = ref(false)
|
||||
const creatingGroup = ref(false)
|
||||
const createForm = reactive({ group_key: '', name: '' })
|
||||
const createForm = reactive({ name: '' })
|
||||
|
||||
const showEditGroup = ref(false)
|
||||
const savingGroup = ref(false)
|
||||
@@ -198,7 +195,6 @@ const filteredModuleOptions = computed(() => {
|
||||
})
|
||||
|
||||
function resetCreateForm() {
|
||||
createForm.group_key = ''
|
||||
createForm.name = ''
|
||||
}
|
||||
|
||||
@@ -245,14 +241,14 @@ async function loadCatalogs() {
|
||||
}
|
||||
|
||||
async function handleCreateGroup() {
|
||||
if (!createForm.group_key || !createForm.name) {
|
||||
if (!createForm.name) {
|
||||
ElMessage.warning('請填寫完整資訊')
|
||||
return
|
||||
}
|
||||
creatingGroup.value = true
|
||||
try {
|
||||
await createPermissionGroup(createForm)
|
||||
ElMessage.success('新增成功')
|
||||
const res = await createPermissionGroup(createForm)
|
||||
ElMessage.success(`新增成功:${res.data?.group_key || ''}`)
|
||||
showCreateGroup.value = false
|
||||
resetCreateForm()
|
||||
await loadGroups()
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
|
||||
<el-dialog v-model="showDialog" title="新增站台" @close="resetForm">
|
||||
<el-form ref="formRef" :model="form" :rules="rules" label-width="120px">
|
||||
<el-form-item label="Site Key" prop="site_key"><el-input v-model="form.site_key" /></el-form-item>
|
||||
<el-form-item label="Company" prop="company_key">
|
||||
<el-select v-model="form.company_key" style="width: 100%" filterable>
|
||||
<el-option v-for="c in companies" :key="c.company_key" :label="`${c.name} (${c.company_key})`" :value="c.company_key" />
|
||||
@@ -79,10 +78,9 @@ const showEditDialog = ref(false)
|
||||
const savingEdit = ref(false)
|
||||
const formRef = ref()
|
||||
|
||||
const form = ref({ site_key: '', company_key: '', name: '' })
|
||||
const form = ref({ company_key: '', name: '' })
|
||||
const editForm = ref({ site_key: '', company_key: '', name: '', status: 'active' })
|
||||
const rules = {
|
||||
site_key: [{ required: true, message: '請輸入 Site Key', trigger: 'blur' }],
|
||||
company_key: [{ required: true, message: '請選擇公司', trigger: 'change' }],
|
||||
name: [{ required: true, message: '請輸入名稱', trigger: 'blur' }]
|
||||
}
|
||||
@@ -109,7 +107,7 @@ async function load() {
|
||||
}
|
||||
|
||||
function resetForm() {
|
||||
form.value = { site_key: '', company_key: '', name: '' }
|
||||
form.value = { company_key: '', name: '' }
|
||||
}
|
||||
|
||||
function openEdit(row) {
|
||||
@@ -131,8 +129,8 @@ async function handleCreate() {
|
||||
if (!valid) return
|
||||
submitting.value = true
|
||||
try {
|
||||
await createSite(form.value)
|
||||
ElMessage.success('新增成功')
|
||||
const res = await createSite(form.value)
|
||||
ElMessage.success(`新增成功:${res.data?.site_key || ''}`)
|
||||
showDialog.value = false
|
||||
resetForm()
|
||||
await load()
|
||||
|
||||
@@ -32,9 +32,6 @@
|
||||
|
||||
<el-dialog v-model="showDialog" title="新增系統" @close="resetForm">
|
||||
<el-form ref="formRef" :model="form" :rules="rules" label-width="100px">
|
||||
<el-form-item label="System Key" prop="system_key">
|
||||
<el-input v-model="form.system_key" placeholder="mkt" />
|
||||
</el-form-item>
|
||||
<el-form-item label="名稱" prop="name">
|
||||
<el-input v-model="form.name" placeholder="行銷平台" />
|
||||
</el-form-item>
|
||||
@@ -111,10 +108,9 @@ const formRef = ref()
|
||||
const showEditDialog = ref(false)
|
||||
const savingEdit = ref(false)
|
||||
|
||||
const form = ref({ system_key: '', name: '' })
|
||||
const form = ref({ name: '' })
|
||||
const editForm = ref({ system_key: '', name: '', status: 'active' })
|
||||
const rules = {
|
||||
system_key: [{ required: true, message: '請輸入 System Key', trigger: 'blur' }],
|
||||
name: [{ required: true, message: '請輸入名稱', trigger: 'blur' }]
|
||||
}
|
||||
|
||||
@@ -142,7 +138,7 @@ async function load() {
|
||||
}
|
||||
|
||||
function resetForm() {
|
||||
form.value = { system_key: '', name: '' }
|
||||
form.value = { name: '' }
|
||||
}
|
||||
|
||||
function openEdit(row) {
|
||||
@@ -163,8 +159,8 @@ async function handleCreate() {
|
||||
if (!valid) return
|
||||
submitting.value = true
|
||||
try {
|
||||
await createSystem(form.value)
|
||||
ElMessage.success('新增成功')
|
||||
const res = await createSystem(form.value)
|
||||
ElMessage.success(`新增成功:${res.data?.system_key || ''}`)
|
||||
showDialog.value = false
|
||||
resetForm()
|
||||
await load()
|
||||
|
||||
Reference in New Issue
Block a user