Files
2026-08-11 09:39:41 +08:00

58 lines
1.6 KiB
Vue

<script setup lang="ts">
/**
* 模板名称新建/编辑全屏表单(替代底部抽屉)
*/
import { computed, ref } from 'vue'
import { onLoad } from '@dcloudio/uni-app'
import { createupperCamelCase, getupperCamelCaseInfo, updateupperCamelCase } from '../api'
import AppPageForm from '@/components/AppPageForm.vue'
const id = ref(0)
const submitting = ref(false)
const form = ref<Record<string, any>>({
// UNI_FORM_DEFAULTS
})
const isEdit = computed(() => !!id.value)
onLoad(async (q) => {
id.value = Number(q?.id || 0)
if (id.value) {
const info = await getupperCamelCaseInfo(id.value)
form.value = {
// UNI_FORM_ASSIGN
}
// 回填兜底
Object.assign(form.value, info || {})
}
})
async function onSubmit() {
submitting.value = true
try {
if (isEdit.value) await updateupperCamelCase({ id: id.value, ...form.value })
else await createupperCamelCase({ ...form.value })
uni.showToast({ title: '保存成功', icon: 'success' })
setTimeout(() => uni.navigateBack(), 400)
} finally {
submitting.value = false
}
}
</script>
<template>
<AppPageForm tip="请填写模板名称信息后保存。" :loading="submitting" @submit="onSubmit">
<!-- UNI_FORM_FIELDS -->
</AppPageForm>
</template>
<style scoped lang="scss">
.form-item {
display: flex; align-items: center; justify-content: space-between;
min-height: 100rpx; border-bottom: 1rpx solid $nl-color-border;
}
.label { width: 160rpx; color: $nl-color-text-secondary; font-size: 28rpx; }
.input { flex: 1; text-align: right; font-size: 28rpx; }
</style>