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(
|
const handleSelect = useCallback(
|
||||||
(item: FinanceCategory) => {
|
(item: FinanceCategory) => {
|
||||||
console.log(item)
|
|
||||||
onSelect?.(item)
|
onSelect?.(item)
|
||||||
onClose?.()
|
onClose?.()
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import type { DateMorePickerMode } from '@/components/common/ao/DateMorePicker'
|
import type { DateMorePickerMode } from '@/components/common/ao/DateMorePicker'
|
||||||
import type { FinanceCategory } from '@/types/finance/category'
|
import type { FinanceCategory } from '@/types/finance/category'
|
||||||
import { useFocusEffect, useRouter } from 'expo-router'
|
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 { Image, Text, TouchableOpacity, View } from 'react-native'
|
||||||
import { SafeAreaView, useSafeAreaInsets } from 'react-native-safe-area-context'
|
import { SafeAreaView, useSafeAreaInsets } from 'react-native-safe-area-context'
|
||||||
import { toast } from 'sonner-native'
|
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 { resolveDateRange } from '@/components/common/ao/DateMorePicker'
|
||||||
import { Fab, FabIcon } from '@/components/ui/fab'
|
import { Fab, FabIcon } from '@/components/ui/fab'
|
||||||
import { AddIcon } from '@/components/ui/icon'
|
import { AddIcon } from '@/components/ui/icon'
|
||||||
|
import { listFinanceCategoriesApi } from '@/request/api/finance/category'
|
||||||
import { deleteFinanceRecordApi, listFinanceRecordsApi } from '@/request/api/finance/record'
|
import { deleteFinanceRecordApi, listFinanceRecordsApi } from '@/request/api/finance/record'
|
||||||
import { useFinanceStore } from '@/store/finance'
|
import { useFinanceStore } from '@/store/finance'
|
||||||
import { getCurrentYearMonth } from '@/utils/time'
|
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(
|
useFocusEffect(
|
||||||
useCallback(() => {
|
useCallback(() => {
|
||||||
financeStore.ensureCategoriesLoaded()
|
|
||||||
fetchFinanceRecords()
|
fetchFinanceRecords()
|
||||||
}, [searchParams.startTime, searchParams.endTime, searchParams.category]),
|
}, [searchParams.startTime, searchParams.endTime, searchParams.category]),
|
||||||
)
|
)
|
||||||
@@ -272,7 +286,6 @@ export default function Money() {
|
|||||||
setShowCategorySheet(false)
|
setShowCategorySheet(false)
|
||||||
}}
|
}}
|
||||||
onSelect={(category) => {
|
onSelect={(category) => {
|
||||||
console.log(category)
|
|
||||||
setSearchParams(prev => ({
|
setSearchParams(prev => ({
|
||||||
...prev,
|
...prev,
|
||||||
category,
|
category,
|
||||||
|
|||||||
@@ -93,7 +93,6 @@ export default function Auth() {
|
|||||||
await ExpoQQ.sendGetUserInfoReq()
|
await ExpoQQ.sendGetUserInfoReq()
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
console.error('QQ 登录未完成', e)
|
|
||||||
setLoading(false)
|
setLoading(false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -114,8 +113,6 @@ export default function Auth() {
|
|||||||
avatar: onGetUserInfo.figureurlQq_2 || onGetUserInfo.figureurl_2,
|
avatar: onGetUserInfo.figureurlQq_2 || onGetUserInfo.figureurl_2,
|
||||||
})
|
})
|
||||||
|
|
||||||
console.log(loginRes)
|
|
||||||
|
|
||||||
if (loginRes.isSuccess) {
|
if (loginRes.isSuccess) {
|
||||||
userStore.setUserInfo({
|
userStore.setUserInfo({
|
||||||
token: loginRes.data.token,
|
token: loginRes.data.token,
|
||||||
|
|||||||
@@ -224,7 +224,6 @@ export default function MoneyCategorySetting() {
|
|||||||
updateFinanceCategorySortNumberApi({
|
updateFinanceCategorySortNumberApi({
|
||||||
categories: updateData,
|
categories: updateData,
|
||||||
}).then((res) => {
|
}).then((res) => {
|
||||||
console.log(res)
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { create } from 'zustand'
|
import { create } from 'zustand'
|
||||||
import { enterDefaultSpaceApi } from '@/request/api/space'
|
import { enterDefaultSpaceApi } from '@/request/api/space'
|
||||||
|
import { useFinanceStore } from './finance'
|
||||||
import { useNavStore } from './navigation'
|
import { useNavStore } from './navigation'
|
||||||
import { useSpaceStore } from './space'
|
import { useSpaceStore } from './space'
|
||||||
import { useUserStore } from './user'
|
import { useUserStore } from './user'
|
||||||
@@ -42,5 +43,6 @@ export const useAppStore = create<AppState>((set, get) => ({
|
|||||||
reset: () => {
|
reset: () => {
|
||||||
useUserStore.getState().clear()
|
useUserStore.getState().clear()
|
||||||
useSpaceStore.getState().clear()
|
useSpaceStore.getState().clear()
|
||||||
|
useFinanceStore.getState().clear()
|
||||||
},
|
},
|
||||||
}))
|
}))
|
||||||
@@ -28,6 +28,9 @@ interface FinanceState {
|
|||||||
getTotalBalance: () => string
|
getTotalBalance: () => string
|
||||||
setRecords: (records: FinanceRecord[]) => void
|
setRecords: (records: FinanceRecord[]) => void
|
||||||
getRecordById: (id: number) => FinanceRecord | null
|
getRecordById: (id: number) => FinanceRecord | null
|
||||||
|
|
||||||
|
// 清空
|
||||||
|
clear: () => void
|
||||||
}
|
}
|
||||||
|
|
||||||
function recomputeGroups(records: FinanceRecord[]) {
|
function recomputeGroups(records: FinanceRecord[]) {
|
||||||
@@ -260,8 +263,9 @@ export const useFinanceStore = create<FinanceState>()(
|
|||||||
}),
|
}),
|
||||||
|
|
||||||
ensureCategoriesLoaded: async () => {
|
ensureCategoriesLoaded: async () => {
|
||||||
if (get().categories.length > 0)
|
if (get().categories.length > 0) {
|
||||||
return
|
return
|
||||||
|
}
|
||||||
const res = await listFinanceCategoriesApi()
|
const res = await listFinanceCategoriesApi()
|
||||||
if (res.isSuccess) {
|
if (res.isSuccess) {
|
||||||
set({ categories: res.data.categories })
|
set({ categories: res.data.categories })
|
||||||
@@ -358,5 +362,12 @@ export const useFinanceStore = create<FinanceState>()(
|
|||||||
return null
|
return null
|
||||||
},
|
},
|
||||||
// ================= 记录 =================
|
// ================= 记录 =================
|
||||||
|
|
||||||
|
clear: () => {
|
||||||
|
set({
|
||||||
|
categories: [],
|
||||||
|
records: [],
|
||||||
|
})
|
||||||
|
},
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
@@ -22,8 +22,8 @@ const DEFAULT_NAV_MENUS: NavItem[] = [
|
|||||||
{ label: '记账', path: '/finance', icon: 'CircleDollarSign' },
|
{ label: '记账', path: '/finance', icon: 'CircleDollarSign' },
|
||||||
// { label: '恋爱记', path: '/love', icon: 'Heart' },
|
// { label: '恋爱记', path: '/love', icon: 'Heart' },
|
||||||
// { label: '聊天', path: '/chat', icon: 'MessageCircle' },
|
// { label: '聊天', path: '/chat', icon: 'MessageCircle' },
|
||||||
{ label: '个人中心', path: '/user', icon: 'CircleUserRound' },
|
|
||||||
{ label: '空间管理', path: '/space', icon: 'Earth' },
|
{ label: '空间管理', path: '/space', icon: 'Earth' },
|
||||||
|
{ label: '个人中心', path: '/user', icon: 'CircleUserRound' },
|
||||||
]
|
]
|
||||||
|
|
||||||
export const useNavStore = create<NavState>()(
|
export const useNavStore = create<NavState>()(
|
||||||
|
|||||||
+66
-187
@@ -1,207 +1,86 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8" />
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
<title>EasyUI Grid Demo</title>
|
||||||
<title>家庭菜单</title>
|
<!-- 引入 jQuery -->
|
||||||
<style>
|
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
|
||||||
body{
|
<!-- 引入 EasyUI 样式和 JS -->
|
||||||
margin:0;
|
<link rel="stylesheet" type="text/css" href="https://www.jeasyui.com/easyui/themes/default/easyui.css">
|
||||||
font-family: sans-serif;
|
<link rel="stylesheet" type="text/css" href="https://www.jeasyui.com/easyui/themes/icon.css">
|
||||||
background:#f2f2f2;
|
<script type="text/javascript" src="https://www.jeasyui.com/easyui/jquery.easyui.min.js"></script>
|
||||||
}
|
<style>
|
||||||
.header{
|
body {
|
||||||
background:#4CAF50;
|
font-family: Arial, sans-serif;
|
||||||
color:white;
|
margin: 20px;
|
||||||
padding:15px;
|
}
|
||||||
text-align:center;
|
.datagrid-cell-btn {
|
||||||
font-size:18px;
|
text-align: center;
|
||||||
}
|
}
|
||||||
.page{
|
</style>
|
||||||
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>
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
<div class="header">家庭做饭助手</div>
|
<h2>EasyUI Grid 简单示例</h2>
|
||||||
|
|
||||||
<!-- 菜谱 -->
|
<table id="dg" title="用户列表" class="easyui-datagrid" style="width:700px;height:300px"
|
||||||
<div class="page active" id="recipePage">
|
data-options="
|
||||||
<h3>菜谱</h3>
|
singleSelect: true,
|
||||||
<div id="recipeList"></div>
|
fitColumns: true,
|
||||||
</div>
|
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 id="toolbar">
|
||||||
<div class="page" id="orderPage">
|
<a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-add" onclick="addUser()">添加用户</a>
|
||||||
<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>
|
</div>
|
||||||
|
|
||||||
<script>
|
<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 = [
|
$(function(){
|
||||||
{ id:1, name:"鸡蛋", qty:4 },
|
$('#dg').datagrid({
|
||||||
{ id:2, name:"番茄", qty:2 }
|
data: users
|
||||||
];
|
});
|
||||||
|
});
|
||||||
|
|
||||||
let recipes = [
|
function addUser() {
|
||||||
{
|
alert('这里可以弹出添加用户的表单');
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
|
||||||
if(!canCook){
|
function editUser(index) {
|
||||||
alert("主料不足,做不了 😢");
|
var row = $('#dg').datagrid('getRows')[index];
|
||||||
return;
|
alert('编辑用户:' + row.name);
|
||||||
}
|
|
||||||
|
|
||||||
recipe.ingredients.forEach(i=>{
|
|
||||||
if(i.type==="main"){
|
|
||||||
let stock=inventory.find(s=>s.name===i.name);
|
|
||||||
stock.qty-=i.qty;
|
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
|
||||||
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>
|
</script>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
Reference in new issue
Block a user