feat 对接数据
This commit is contained in:
@@ -1,10 +1,43 @@
|
||||
<script setup lang="ts">
|
||||
const projectName = ref('')
|
||||
const startEndStation = ref('k12+300-k125+800')
|
||||
const totalArea = ref('')
|
||||
import { projectService } from '@/service'
|
||||
import storage from '@/utils/storage'
|
||||
|
||||
function handleSave() {
|
||||
console.log('保存项目设置')
|
||||
const PROJECT_KEY = 'current_project'
|
||||
const currentProject = storage.get(PROJECT_KEY)
|
||||
|
||||
const projectName = ref(currentProject?.project_name || '')
|
||||
const startEndStation = ref(currentProject?.stake_range || '')
|
||||
const totalArea = ref(currentProject?.total_area ? String(currentProject.total_area) : '')
|
||||
|
||||
async function handleSave() {
|
||||
if (!projectName.value) {
|
||||
uni.showToast({ title: '请输入项目名称', icon: 'none' })
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
const id = await projectService.insert({
|
||||
project_name: projectName.value,
|
||||
stake_range: startEndStation.value,
|
||||
total_area: Number(totalArea.value) || 0,
|
||||
status: 0,
|
||||
})
|
||||
|
||||
// 保存到 storage
|
||||
storage.set(PROJECT_KEY, {
|
||||
id,
|
||||
project_name: projectName.value,
|
||||
stake_range: startEndStation.value,
|
||||
total_area: Number(totalArea.value) || 0,
|
||||
status: 0,
|
||||
})
|
||||
|
||||
uni.showToast({ title: '保存成功', icon: 'success' })
|
||||
}
|
||||
catch (err) {
|
||||
console.error('保存失败:', err)
|
||||
uni.showToast({ title: '保存失败', icon: 'none' })
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user