u
This commit is contained in:
1 parent
00a1cce5ac
commit
c36b274976
9 files changed
+97
-197
No files matched your search
Binary file not shown.
|
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 177 KiB |
@@ -46,7 +46,6 @@ export default function CategorySheet({
|
||||
|
||||
const handleSelect = useCallback(
|
||||
(item: FinanceCategory) => {
|
||||
console.log(item)
|
||||
onSelect?.(item)
|
||||
onClose?.()
|
||||
},
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import type { DateMorePickerMode } from '@/components/common/ao/DateMorePicker'
|
||||
import type { FinanceCategory } from '@/types/finance/category'
|
||||
import { useFocusEffect, useRouter } from 'expo-router'
|
||||
import React, { useCallback, useState } from 'react'
|
||||
import React, { useCallback, useEffect, useState } from 'react'
|
||||
import { Image, Text, TouchableOpacity, View } from 'react-native'
|
||||
import { SafeAreaView, useSafeAreaInsets } from 'react-native-safe-area-context'
|
||||
import { toast } from 'sonner-native'
|
||||
@@ -9,6 +9,7 @@ import { ADateMorePicker, ADrawer, AListItem, LucideIcon } from '@/components/co
|
||||
import { resolveDateRange } from '@/components/common/ao/DateMorePicker'
|
||||
import { Fab, FabIcon } from '@/components/ui/fab'
|
||||
import { AddIcon } from '@/components/ui/icon'
|
||||
import { listFinanceCategoriesApi } from '@/request/api/finance/category'
|
||||
import { deleteFinanceRecordApi, listFinanceRecordsApi } from '@/request/api/finance/record'
|
||||
import { useFinanceStore } from '@/store/finance'
|
||||
import { getCurrentYearMonth } from '@/utils/time'
|
||||
@@ -79,9 +80,22 @@ export default function Money() {
|
||||
})
|
||||
}
|
||||
|
||||
async function fetchFinanceCategories() {
|
||||
if (financeStore.categories.length > 0) {
|
||||
return
|
||||
}
|
||||
const res = await listFinanceCategoriesApi()
|
||||
if (res.isSuccess) {
|
||||
financeStore.setCategories(res.data.categories)
|
||||
}
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
fetchFinanceCategories()
|
||||
}, [])
|
||||
|
||||
useFocusEffect(
|
||||
useCallback(() => {
|
||||
financeStore.ensureCategoriesLoaded()
|
||||
fetchFinanceRecords()
|
||||
}, [searchParams.startTime, searchParams.endTime, searchParams.category]),
|
||||
)
|
||||
@@ -272,7 +286,6 @@ export default function Money() {
|
||||
setShowCategorySheet(false)
|
||||
}}
|
||||
onSelect={(category) => {
|
||||
console.log(category)
|
||||
setSearchParams(prev => ({
|
||||
...prev,
|
||||
category,
|
||||
|
||||
@@ -93,7 +93,6 @@ export default function Auth() {
|
||||
await ExpoQQ.sendGetUserInfoReq()
|
||||
}
|
||||
catch (e) {
|
||||
console.error('QQ 登录未完成', e)
|
||||
setLoading(false)
|
||||
}
|
||||
}
|
||||
@@ -114,8 +113,6 @@ export default function Auth() {
|
||||
avatar: onGetUserInfo.figureurlQq_2 || onGetUserInfo.figureurl_2,
|
||||
})
|
||||
|
||||
console.log(loginRes)
|
||||
|
||||
if (loginRes.isSuccess) {
|
||||
userStore.setUserInfo({
|
||||
token: loginRes.data.token,
|
||||
|
||||
@@ -224,7 +224,6 @@ export default function MoneyCategorySetting() {
|
||||
updateFinanceCategorySortNumberApi({
|
||||
categories: updateData,
|
||||
}).then((res) => {
|
||||
console.log(res)
|
||||
})
|
||||
}
|
||||
}}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { create } from 'zustand'
|
||||
import { enterDefaultSpaceApi } from '@/request/api/space'
|
||||
import { useFinanceStore } from './finance'
|
||||
import { useNavStore } from './navigation'
|
||||
import { useSpaceStore } from './space'
|
||||
import { useUserStore } from './user'
|
||||
@@ -42,5 +43,6 @@ export const useAppStore = create<AppState>((set, get) => ({
|
||||
reset: () => {
|
||||
useUserStore.getState().clear()
|
||||
useSpaceStore.getState().clear()
|
||||
useFinanceStore.getState().clear()
|
||||
},
|
||||
}))
|
||||
@@ -28,6 +28,9 @@ interface FinanceState {
|
||||
getTotalBalance: () => string
|
||||
setRecords: (records: FinanceRecord[]) => void
|
||||
getRecordById: (id: number) => FinanceRecord | null
|
||||
|
||||
// 清空
|
||||
clear: () => void
|
||||
}
|
||||
|
||||
function recomputeGroups(records: FinanceRecord[]) {
|
||||
@@ -260,8 +263,9 @@ export const useFinanceStore = create<FinanceState>()(
|
||||
}),
|
||||
|
||||
ensureCategoriesLoaded: async () => {
|
||||
if (get().categories.length > 0)
|
||||
if (get().categories.length > 0) {
|
||||
return
|
||||
}
|
||||
const res = await listFinanceCategoriesApi()
|
||||
if (res.isSuccess) {
|
||||
set({ categories: res.data.categories })
|
||||
@@ -358,5 +362,12 @@ export const useFinanceStore = create<FinanceState>()(
|
||||
return null
|
||||
},
|
||||
// ================= 记录 =================
|
||||
|
||||
clear: () => {
|
||||
set({
|
||||
categories: [],
|
||||
records: [],
|
||||
})
|
||||
},
|
||||
}),
|
||||
)
|
||||
@@ -22,8 +22,8 @@ const DEFAULT_NAV_MENUS: NavItem[] = [
|
||||
{ label: '记账', path: '/finance', icon: 'CircleDollarSign' },
|
||||
// { label: '恋爱记', path: '/love', icon: 'Heart' },
|
||||
// { label: '聊天', path: '/chat', icon: 'MessageCircle' },
|
||||
{ label: '个人中心', path: '/user', icon: 'CircleUserRound' },
|
||||
{ label: '空间管理', path: '/space', icon: 'Earth' },
|
||||
{ label: '个人中心', path: '/user', icon: 'CircleUserRound' },
|
||||
]
|
||||
|
||||
export const useNavStore = create<NavState>()(
|
||||
|
||||
+66
-187
@@ -1,207 +1,86 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>家庭菜单</title>
|
||||
<style>
|
||||
body{
|
||||
margin:0;
|
||||
font-family: sans-serif;
|
||||
background:#f2f2f2;
|
||||
}
|
||||
.header{
|
||||
background:#4CAF50;
|
||||
color:white;
|
||||
padding:15px;
|
||||
text-align:center;
|
||||
font-size:18px;
|
||||
}
|
||||
.page{
|
||||
display:none;
|
||||
padding:15px;
|
||||
padding-bottom:80px;
|
||||
}
|
||||
.page.active{
|
||||
display:block;
|
||||
}
|
||||
.card{
|
||||
background:white;
|
||||
padding:12px;
|
||||
margin-bottom:10px;
|
||||
border-radius:8px;
|
||||
box-shadow:0 2px 5px rgba(0,0,0,0.1);
|
||||
}
|
||||
button{
|
||||
background:#4CAF50;
|
||||
border:none;
|
||||
color:white;
|
||||
padding:6px 10px;
|
||||
border-radius:6px;
|
||||
margin-top:5px;
|
||||
}
|
||||
.tabs{
|
||||
position:fixed;
|
||||
bottom:0;
|
||||
width:100%;
|
||||
display:flex;
|
||||
background:white;
|
||||
border-top:1px solid #ddd;
|
||||
}
|
||||
.tab{
|
||||
flex:1;
|
||||
padding:12px;
|
||||
text-align:center;
|
||||
}
|
||||
.tab.active{
|
||||
background:#dcedc8;
|
||||
}
|
||||
input,select{
|
||||
width:100%;
|
||||
padding:6px;
|
||||
margin-top:5px;
|
||||
}
|
||||
.small{
|
||||
font-size:12px;
|
||||
color:#666;
|
||||
}
|
||||
</style>
|
||||
<meta charset="UTF-8">
|
||||
<title>EasyUI Grid Demo</title>
|
||||
<!-- 引入 jQuery -->
|
||||
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
|
||||
<!-- 引入 EasyUI 样式和 JS -->
|
||||
<link rel="stylesheet" type="text/css" href="https://www.jeasyui.com/easyui/themes/default/easyui.css">
|
||||
<link rel="stylesheet" type="text/css" href="https://www.jeasyui.com/easyui/themes/icon.css">
|
||||
<script type="text/javascript" src="https://www.jeasyui.com/easyui/jquery.easyui.min.js"></script>
|
||||
<style>
|
||||
body {
|
||||
font-family: Arial, sans-serif;
|
||||
margin: 20px;
|
||||
}
|
||||
.datagrid-cell-btn {
|
||||
text-align: center;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div class="header">家庭做饭助手</div>
|
||||
<h2>EasyUI Grid 简单示例</h2>
|
||||
|
||||
<!-- 菜谱 -->
|
||||
<div class="page active" id="recipePage">
|
||||
<h3>菜谱</h3>
|
||||
<div id="recipeList"></div>
|
||||
</div>
|
||||
<table id="dg" title="用户列表" class="easyui-datagrid" style="width:700px;height:300px"
|
||||
data-options="
|
||||
singleSelect: true,
|
||||
fitColumns: true,
|
||||
toolbar: '#toolbar',
|
||||
rownumbers: true
|
||||
">
|
||||
<thead>
|
||||
<tr>
|
||||
<th data-options="field:'id',width:50">ID</th>
|
||||
<th data-options="field:'name',width:100">姓名</th>
|
||||
<th data-options="field:'age',width:50,align:'right'">年龄</th>
|
||||
<th data-options="field:'email',width:150">邮箱</th>
|
||||
<th data-options="field:'action',width:100,align:'center',
|
||||
formatter: function(value,row,index){
|
||||
return '<a href=\"javascript:void(0)\" onclick=\"editUser('+index+')\">编辑</a> | ' +
|
||||
'<a href=\"javascript:void(0)\" onclick=\"deleteUser('+index+')\">删除</a>';
|
||||
}">操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
</table>
|
||||
|
||||
<!-- 下单 -->
|
||||
<div class="page" id="orderPage">
|
||||
<h3>下单</h3>
|
||||
<div id="orderList"></div>
|
||||
</div>
|
||||
|
||||
<!-- 库存 -->
|
||||
<div class="page" id="inventoryPage">
|
||||
<h3>库存</h3>
|
||||
<input id="name" placeholder="食材名称">
|
||||
<input id="qty" type="number" placeholder="数量">
|
||||
<button onclick="addInventory()">添加主料</button>
|
||||
<div id="inventoryList"></div>
|
||||
</div>
|
||||
|
||||
<div class="tabs">
|
||||
<div class="tab active" onclick="switchTab(0)">菜谱</div>
|
||||
<div class="tab" onclick="switchTab(1)">下单</div>
|
||||
<div class="tab" onclick="switchTab(2)">库存</div>
|
||||
<div id="toolbar">
|
||||
<a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-add" onclick="addUser()">添加用户</a>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
// 模拟数据
|
||||
var users = [
|
||||
{id:1, name:'张三', age:18, email:'zhangsan@example.com'},
|
||||
{id:2, name:'李四', age:22, email:'lisi@example.com'},
|
||||
{id:3, name:'王五', age:30, email:'wangwu@example.com'},
|
||||
{id:4, name:'赵六', age:25, email:'zhaoliu@example.com'}
|
||||
];
|
||||
|
||||
let inventory = [
|
||||
{ id:1, name:"鸡蛋", qty:4 },
|
||||
{ id:2, name:"番茄", qty:2 }
|
||||
];
|
||||
$(function(){
|
||||
$('#dg').datagrid({
|
||||
data: users
|
||||
});
|
||||
});
|
||||
|
||||
let recipes = [
|
||||
{
|
||||
id:1,
|
||||
name:"番茄炒蛋",
|
||||
ingredients:[
|
||||
{ name:"鸡蛋", qty:2, type:"main" },
|
||||
{ name:"番茄", qty:1, type:"main" },
|
||||
{ name:"盐", type:"seasoning" }
|
||||
]
|
||||
}
|
||||
];
|
||||
|
||||
function renderInventory(){
|
||||
let div=document.getElementById("inventoryList");
|
||||
div.innerHTML="";
|
||||
inventory.forEach(i=>{
|
||||
div.innerHTML+=`
|
||||
<div class="card">
|
||||
${i.name} - 剩余 ${i.qty}
|
||||
</div>
|
||||
`;
|
||||
});
|
||||
}
|
||||
|
||||
function renderRecipes(){
|
||||
let div=document.getElementById("recipeList");
|
||||
div.innerHTML="";
|
||||
recipes.forEach(r=>{
|
||||
div.innerHTML+=`
|
||||
<div class="card">
|
||||
<b>${r.name}</b>
|
||||
<div class="small">
|
||||
${r.ingredients.map(i=> i.type==="main" ? i.name+" "+i.qty : i.name+"(调料)").join(", ")}
|
||||
</div>
|
||||
<button onclick="order(${r.id})">做这道菜</button>
|
||||
</div>
|
||||
`;
|
||||
});
|
||||
}
|
||||
|
||||
function order(id){
|
||||
let recipe=recipes.find(r=>r.id===id);
|
||||
let canCook=true;
|
||||
|
||||
recipe.ingredients.forEach(i=>{
|
||||
if(i.type==="main"){
|
||||
let stock=inventory.find(s=>s.name===i.name);
|
||||
if(!stock || stock.qty<i.qty){
|
||||
canCook=false;
|
||||
}
|
||||
function addUser() {
|
||||
alert('这里可以弹出添加用户的表单');
|
||||
}
|
||||
});
|
||||
|
||||
if(!canCook){
|
||||
alert("主料不足,做不了 😢");
|
||||
return;
|
||||
}
|
||||
|
||||
recipe.ingredients.forEach(i=>{
|
||||
if(i.type==="main"){
|
||||
let stock=inventory.find(s=>s.name===i.name);
|
||||
stock.qty-=i.qty;
|
||||
function editUser(index) {
|
||||
var row = $('#dg').datagrid('getRows')[index];
|
||||
alert('编辑用户:' + row.name);
|
||||
}
|
||||
});
|
||||
|
||||
alert("开做!🍳");
|
||||
renderInventory();
|
||||
}
|
||||
|
||||
function addInventory(){
|
||||
let name=document.getElementById("name").value;
|
||||
let qty=parseInt(document.getElementById("qty").value);
|
||||
|
||||
if(!name||!qty) return;
|
||||
|
||||
let existing=inventory.find(i=>i.name===name);
|
||||
if(existing){
|
||||
existing.qty+=qty;
|
||||
}else{
|
||||
inventory.push({id:inventory.length+1,name,qty});
|
||||
}
|
||||
|
||||
renderInventory();
|
||||
}
|
||||
|
||||
function switchTab(i){
|
||||
document.querySelectorAll(".page").forEach((p,index)=>{
|
||||
p.classList.toggle("active",index===i);
|
||||
});
|
||||
document.querySelectorAll(".tab").forEach((t,index)=>{
|
||||
t.classList.toggle("active",index===i);
|
||||
});
|
||||
}
|
||||
|
||||
renderInventory();
|
||||
renderRecipes();
|
||||
|
||||
function deleteUser(index) {
|
||||
var row = $('#dg').datagrid('getRows')[index];
|
||||
if (confirm('确定删除用户:' + row.name + '吗?')) {
|
||||
users.splice(index, 1);
|
||||
$('#dg').datagrid('loadData', users);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
Reference in new issue
Block a user