feat 对接数据
This commit is contained in:
@@ -1,4 +1,13 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
import storage from '@/utils/storage'
|
||||||
|
|
||||||
|
const project = ref(storage.get('current_project'))
|
||||||
|
|
||||||
|
// 页面显示时刷新数据(从设置页返回时)
|
||||||
|
onShow(() => {
|
||||||
|
project.value = storage.get('current_project')
|
||||||
|
})
|
||||||
|
|
||||||
function onIconClick(name: string) {
|
function onIconClick(name: string) {
|
||||||
if (name === '通知') {
|
if (name === '通知') {
|
||||||
uni.navigateTo({
|
uni.navigateTo({
|
||||||
@@ -27,10 +36,10 @@ function onIconClick(name: string) {
|
|||||||
<image class="nav-logo" src="/static/logo.png" mode="aspectFit" @tap="onIconClick('logo')" />
|
<image class="nav-logo" src="/static/logo.png" mode="aspectFit" @tap="onIconClick('logo')" />
|
||||||
<view class="nav-info">
|
<view class="nav-info">
|
||||||
<text class="nav-title">
|
<text class="nav-title">
|
||||||
G6高速改扩建测试测试项目
|
{{ project?.project_name || '未设置项目' }}
|
||||||
</text>
|
</text>
|
||||||
<text class="nav-subtitle">
|
<text class="nav-subtitle">
|
||||||
K1+200-K1+800
|
{{ project?.stake_range || '--' }}
|
||||||
</text>
|
</text>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|||||||
@@ -1,3 +1,8 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
const now = new Date()
|
||||||
|
const dateStr = `${now.getFullYear()}年${now.getMonth() + 1}月${now.getDate()}日`
|
||||||
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<view class="card overview-card">
|
<view class="card overview-card">
|
||||||
<view class="card-header">
|
<view class="card-header">
|
||||||
@@ -5,7 +10,7 @@
|
|||||||
今日作业概览
|
今日作业概览
|
||||||
</text>
|
</text>
|
||||||
<text class="card-date">
|
<text class="card-date">
|
||||||
2025年8月11日
|
{{ dateStr }}
|
||||||
</text>
|
</text>
|
||||||
</view>
|
</view>
|
||||||
<view class="overview-stats">
|
<view class="overview-stats">
|
||||||
@@ -14,7 +19,7 @@
|
|||||||
实时作业状态(台)
|
实时作业状态(台)
|
||||||
</text>
|
</text>
|
||||||
<text class="stat-value">
|
<text class="stat-value">
|
||||||
22
|
1
|
||||||
</text>
|
</text>
|
||||||
</view>
|
</view>
|
||||||
<view class="stat-item">
|
<view class="stat-item">
|
||||||
|
|||||||
@@ -1,10 +1,43 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
const projectName = ref('')
|
import { projectService } from '@/service'
|
||||||
const startEndStation = ref('k12+300-k125+800')
|
import storage from '@/utils/storage'
|
||||||
const totalArea = ref('')
|
|
||||||
|
|
||||||
function handleSave() {
|
const PROJECT_KEY = 'current_project'
|
||||||
console.log('保存项目设置')
|
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>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ export const projectTableSql = `CREATE TABLE IF NOT EXISTS project (
|
|||||||
)`
|
)`
|
||||||
|
|
||||||
export interface Project {
|
export interface Project {
|
||||||
id?: number // 主键,自增
|
id: number // 主键,自增
|
||||||
project_name: string // 项目名称,必填
|
project_name: string // 项目名称,必填
|
||||||
stake_range: string // 项目范围,可选
|
stake_range: string // 项目范围,可选
|
||||||
total_area: number // 项目总面积,可选
|
total_area: number // 项目总面积,可选
|
||||||
@@ -38,8 +38,10 @@ export async function selectByStatus(status: 0 | 1): Promise<Project[]> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** 新增项目 */
|
/** 新增项目 */
|
||||||
export async function insert(data: Omit<Project, 'id'>): Promise<any> {
|
export async function insert(data: Omit<Project, 'id'>): Promise<number> {
|
||||||
return DB.insert(TABLE, data)
|
await DB.insert(TABLE, data)
|
||||||
|
const result = await DB.selectSql('SELECT last_insert_rowid() as id')
|
||||||
|
return result?.[0]?.id || 0
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 更新项目 */
|
/** 更新项目 */
|
||||||
|
|||||||
Reference in New Issue
Block a user