@appthen/cli 1.2.10 → 1.2.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.gitignore +1 -0
- package/bin/main.js +92 -0
- package/dist/index.js +7014 -14988
- package/package.json +8 -1
- package/tests/test-app/.appthen/shadow-space-100001-test-app-e99876b1.json +1862 -0
- package/tests/test-app/.appthen/space-config.json +8 -0
- package/tests/test-app/docs/AI-Workflow.flow +112 -0
- package/tests/test-app/docs/Logic-1.flow +16 -0
- package/tests/test-app/docs/Logic.flow +16 -0
- package/tests/test-app/docs/Project-Blueprint-1.flow +119 -0
- package/tests/test-app/docs/Project-Blueprint.flow +119 -0
- package/tests/test-app/docs/README.md +3 -0
- package/tests/test-app/docs/claude.md +194 -0
- package/tests/test-app/docs/page_requirement_analysis.md +149 -0
- package/tests/test-app/docs//345/267/245/345/215/225/347/256/241/347/220/206/347/263/273/347/273/237/350/257/246/347/273/206/350/256/276/350/256/241.md +377 -0
- package/tests/test-app/src/apis/AddTodoPost.api.ts +42 -0
- package/tests/test-app/src/apis/DeleteTodoPost.api.ts +32 -0
- package/tests/test-app/src/apis/GetListPost.api.ts +38 -0
- package/tests/test-app/src/apis/TicketAttachmentUploadPost.api.ts +42 -0
- package/tests/test-app/src/apis/UpdateTodoPost.api.ts +46 -0
- package/tests/test-app/src/app.css +15 -0
- package/tests/test-app/src/cloud_functions/ticket|attachment|upload.node.ts +86 -0
- package/tests/test-app/src/cloud_functions/ticket|comment|add.node.ts +65 -0
- package/tests/test-app/src/cloud_functions/types|entity|Ticket.node.ts +88 -0
- package/tests/test-app/src/cloud_functions/types|entity|TicketAttachment.node.ts +70 -0
- package/tests/test-app/src/cloud_functions/types|entity|TicketCategory.node.ts +56 -0
- package/tests/test-app/src/cloud_functions/types|entity|TicketComment.node.ts +62 -0
- package/tests/test-app/src/cloud_functions/types|entity|TicketHistory.node.ts +74 -0
- package/tests/test-app/src/cloud_functions/types|entity|TicketPriority.node.ts +68 -0
- package/tests/test-app/src/cloud_functions/types|entity|TicketStatus.node.ts +63 -0
- package/tests/test-app/src/cloud_functions/types|models|CreateTicketParams.node.ts +20 -0
- package/tests/test-app/src/cloud_functions/types|models|TicketListParams.node.ts +30 -0
- package/tests/test-app/src/cloud_functions/types|models|UpdateTicketParams.node.ts +22 -0
- package/tests/test-app/src/components/Button.js +11 -0
- package/tests/test-app/src/components/MessageCenter.tsx +506 -0
- package/tests/test-app/src/components/MouduleDemoNzp.tsx +40 -0
- package/tests/test-app/src/components/Timeline.tsx +145 -0
- package/tests/test-app/src/index.ts +2 -0
- package/tests/test-app/src/modules/work_order_module/apis/TicketCommentAddPost.api.ts +48 -0
- package/tests/test-app/src/modules/work_order_module/apis/TicketCreatePost.api.ts +52 -0
- package/tests/test-app/src/modules/work_order_module/apis/TicketDeleteDelete.api.ts +39 -0
- package/tests/test-app/src/modules/work_order_module/apis/TicketDetailGet.api.ts +39 -0
- package/tests/test-app/src/modules/work_order_module/apis/TicketListGet.api.ts +61 -0
- package/tests/test-app/src/modules/work_order_module/apis/TicketUpdatePut.api.ts +57 -0
- package/tests/test-app/src/modules/work_order_module/apis/TrainDoorFaultListGet.ts +76 -0
- package/tests/test-app/src/modules/work_order_module/apis/TrainDoorListGet.ts +76 -0
- package/tests/test-app/src/modules/work_order_module/apis/TrainDoorOperationRecordsGet.ts +284 -0
- package/tests/test-app/src/modules/work_order_module/apis/TrainDoorStatisticsGet.ts +96 -0
- package/tests/test-app/src/modules/work_order_module/cloud_function/category|list.node.ts +40 -0
- package/tests/test-app/src/modules/work_order_module/cloud_function/priority|list.node.ts +26 -0
- package/tests/test-app/src/modules/work_order_module/cloud_function/status|list.node.ts +26 -0
- package/tests/test-app/src/modules/work_order_module/cloud_function/ticket|create.node.ts +54 -0
- package/tests/test-app/src/modules/work_order_module/cloud_function/ticket|delete.node.ts +55 -0
- package/tests/test-app/src/modules/work_order_module/cloud_function/ticket|detail.node.ts +65 -0
- package/tests/test-app/src/modules/work_order_module/cloud_function/ticket|list.node.ts +85 -0
- package/tests/test-app/src/modules/work_order_module/cloud_function/ticket|update.node.ts +73 -0
- package/tests/test-app/src/modules/work_order_module/data_model/Ticket.m.ts +85 -0
- package/tests/test-app/src/modules/work_order_module/data_model/TicketCategory.m.ts +53 -0
- package/tests/test-app/src/modules/work_order_module/data_model/TicketStatus.m.ts +60 -0
- package/tests/test-app/src/modules/work_order_module//345/267/245/345/215/225/347/263/273/347/273/237/344/272/247/345/223/201/350/256/276/350/256/241/346/226/207/346/241/243.md +301 -0
- package/tests/test-app/src/modules/work_order_module//345/267/245/345/215/225/347/263/273/347/273/237/345/274/200/345/217/221/344/273/273/345/212/241/345/210/206/345/267/245/346/226/207/346/241/243.md +345 -0
- package/tests/test-app/src/pages/CustomerManagement.tsx +535 -0
- package/tests/test-app/src/pages/CyberpunkDashboard.tsx +348 -0
- package/tests/test-app/src/pages/CyberpunkProductManagement.tsx +637 -0
- package/tests/test-app/src/pages/CyberpunkUserList.tsx +316 -0
- package/tests/test-app/src/pages/DashboardV2.tsx +334 -0
- package/tests/test-app/src/pages/DataReport.tsx +298 -0
- package/tests/test-app/src/pages/DataStatistics.tsx +317 -0
- package/tests/test-app/src/pages/DepartmentManagement.tsx +503 -0
- package/tests/test-app/src/pages/FileExplorer.tsx +441 -0
- package/tests/test-app/src/pages/OrderDetail.tsx +393 -0
- package/tests/test-app/src/pages/ProductManagement.tsx +521 -0
- package/tests/test-app/src/pages/ProjectTimeline.tsx +395 -0
- package/tests/test-app/src/pages/RoleManagement.tsx +523 -0
- package/tests/test-app/src/pages/SLAManagement.tsx +668 -0
- package/tests/test-app/src/pages/StaticCyberpunkDashboard.tsx +462 -0
- package/tests/test-app/src/pages/StaticCyberpunkUserList.tsx +567 -0
- package/tests/test-app/src/pages/StudentWeaknessList.tsx +547 -0
- package/tests/test-app/src/pages/SystemSettings.tsx +422 -0
- package/tests/test-app/src/pages/TaskManagement.tsx +467 -0
- package/tests/test-app/src/pages/TicketCreate.tsx +27 -0
- package/tests/test-app/src/pages/TicketDetail.tsx +27 -0
- package/tests/test-app/src/pages/TicketList.tsx +27 -0
- package/tests/test-app/src/pages/TicketManagement.tsx +402 -0
- package/tests/test-app/src/pages/TicketManagementPage.tsx +1238 -0
- package/tests/test-app/src/pages/UserProfile.tsx +404 -0
- package/tests/test-app/src/pages/VisualAIIDEUpgrade.tsx +245 -0
- package/tests/test-app/src/pages/WorkflowDesigner.tsx +434 -0
- package/tests/test-app/src/pages/admin/dashboard.tsx +591 -0
- package/tests/test-app/src/pages/appthen_guide/ComponentTreeUnderstanding.tsx +26 -0
- package/tests/test-app/src/pages/appthen_guide/DataBindingLearning.tsx +26 -0
- package/tests/test-app/src/pages/article-list.tsx +222 -0
- package/tests/test-app/src/pages/babyProductRecommendationPage.tsx +168 -0
- package/tests/test-app/src/pages/back-end/adminRootLayout.tsx +155 -0
- package/tests/test-app/src/pages/back-end/adminRootLayout10.tsx +157 -0
- package/tests/test-app/src/pages/back-end/adminRootLayout2.tsx +156 -0
- package/tests/test-app/src/pages/back-end/adminRootLayout3.tsx +156 -0
- package/tests/test-app/src/pages/back-end/adminRootLayout4.tsx +157 -0
- package/tests/test-app/src/pages/back-end/adminRootLayout5.tsx +157 -0
- package/tests/test-app/src/pages/back-end/adminRootLayout6.tsx +157 -0
- package/tests/test-app/src/pages/back-end/adminRootLayout7.tsx +157 -0
- package/tests/test-app/src/pages/back-end/adminRootLayout8.tsx +157 -0
- package/tests/test-app/src/pages/back-end/adminRootLayout9.tsx +157 -0
- package/tests/test-app/src/pages/back-end/backgroundManagementSystem.css +5 -0
- package/tests/test-app/src/pages/back-end/backgroundManagementSystem.tsx +1745 -0
- package/tests/test-app/src/pages/category-list.tsx +179 -0
- package/tests/test-app/src/pages/comment-list.tsx +194 -0
- package/tests/test-app/src/pages/component/WorkOrderCard.tsx +140 -0
- package/tests/test-app/src/pages/cover.tsx +42 -0
- package/tests/test-app/src/pages/cyberpunk/cyberpunkCRMPage.tsx +1299 -0
- package/tests/test-app/src/pages/data-analytics.tsx +1872 -0
- package/tests/test-app/src/pages/data-overview.tsx +600 -0
- package/tests/test-app/src/pages/data_dashboard/blueBrightGreenTechnologyWind.css +181 -0
- package/tests/test-app/src/pages/data_dashboard/blueBrightGreenTechnologyWind.tsx +225 -0
- package/tests/test-app/src/pages/data_dashboard/blueLargeScreen.css +181 -0
- package/tests/test-app/src/pages/data_dashboard/blueLargeScreen.tsx +138 -0
- package/tests/test-app/src/pages/data_dashboard/component_library/BlueBrightGreenBorder.tsx +47 -0
- package/tests/test-app/src/pages/data_dashboard/component_library/FullScreenContainer.tsx +133 -0
- package/tests/test-app/src/pages/demo-error-page.tsx +119 -0
- package/tests/test-app/src/pages/department-list.tsx +183 -0
- package/tests/test-app/src/pages/description_of_mock_interface.md +32 -0
- package/tests/test-app/src/pages/digitalLargeScreen.css +181 -0
- package/tests/test-app/src/pages/digitalLargeScreen.tsx +1417 -0
- package/tests/test-app/src/pages/goods-list.tsx +233 -0
- package/tests/test-app/src/pages/housekeeping/adminDashboardPage.tsx +880 -0
- package/tests/test-app/src/pages/mobile_terminal/PersonalCenter.css +3 -0
- package/tests/test-app/src/pages/mobile_terminal/PersonalCenter.tsx +362 -0
- package/tests/test-app/src/pages/mobile_terminal/WorkOrderHomepage.tsx +337 -0
- package/tests/test-app/src/pages/mobile_terminal/newWorkOrder.tsx +224 -0
- package/tests/test-app/src/pages/mobile_terminal/tabbar.tsx +67 -0
- package/tests/test-app/src/pages/mobile_terminal/uiHandsOnPractice.tsx +638 -0
- package/tests/test-app/src/pages/mobile_terminal/workOrderDetails.tsx +346 -0
- package/tests/test-app/src/pages/mobile_terminal/workOrderPage.tsx +345 -0
- package/tests/test-app/src/pages/notice-list.tsx +217 -0
- package/tests/test-app/src/pages/order-detail.tsx +330 -0
- package/tests/test-app/src/pages/order-list.tsx +195 -0
- package/tests/test-app/src/pages/order-management.tsx +563 -0
- package/tests/test-app/src/pages/page/OrderList.tsx +230 -0
- package/tests/test-app/src/pages/role-list.tsx +184 -0
- package/tests/test-app/src/pages/simple/simplePage.tsx +92 -0
- package/tests/test-app/src/pages/simple-page.tsx +43 -0
- package/tests/test-app/src/pages/test-destructure.tsx +44 -0
- package/tests/test-app/src/pages/test-error-page.tsx +75 -0
- package/tests/test-app/src/pages/test-page-with-errors.tsx +51 -0
- package/tests/test-app/src/pages/test-page.tsx +101 -0
- package/tests/test-app/src/pages/test-render.tsx +52 -0
- package/tests/test-app/src/pages/test-return-type.tsx +41 -0
- package/tests/test-app/src/pages/test-type-assertion.tsx +37 -0
- package/tests/test-app/src/pages/testPage.css +3 -0
- package/tests/test-app/src/pages/testPage.tsx +158 -0
- package/tests/test-app/src/pages/ui/styleSelectorPage.tsx +1554 -0
- package/tests/test-app/src/pages/user-list.tsx +212 -0
- package/tests/test-app/src/pages/web_version/website.css +205 -0
- package/tests/test-app/src/pages/web_version/website.tsx +1066 -0
- package/tests/test-app/src/pages/wrong-page.tsx +50 -0
- package/tests/test-app/src/pages//345/276/205/345/212/236.apidoc.json +336 -0
- package/tests/test-app/src/project.json +1120 -0
- package/tests/test-app/src/store/global.store.ts +10 -0
- package/tests/test-app/src/types/CreateTicketParams.m.ts +20 -0
- package/tests/test-app/src/types/SLAPolicy.ts +50 -0
- package/tests/test-app/src/types/Ticket.ts +68 -0
- package/tests/test-app/src/types/TicketAttachment.m.ts +67 -0
- package/tests/test-app/src/types/TicketComment.m.ts +59 -0
- package/tests/test-app/src/types/TicketEvaluation.ts +44 -0
- package/tests/test-app/src/types/TicketHistory.m.ts +71 -0
- package/tests/test-app/src/types/TicketListParams.m.ts +30 -0
- package/tests/test-app/src/types/TicketPriority.m.ts +65 -0
- package/tests/test-app/src/types/TicketRecord.ts +47 -0
- package/tests/test-app/src/types/TrainDoor.ts +284 -0
- package/tests/test-app/src/types/UpdateTicketParams.m.ts +22 -0
- package/tests/test-app/src/utils/__afterRequest.util.ts +3 -0
- package/tests/test-app/src/utils/__beforeRequest.util.ts +10 -0
- package/tests/test-app/src/utils/testGlobalAction.util.ts +7 -0
|
@@ -0,0 +1,521 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 产品管理
|
|
3
|
+
* 管理所有产品信息
|
|
4
|
+
*
|
|
5
|
+
* @type Page
|
|
6
|
+
* @route /products
|
|
7
|
+
* @screen 1920w
|
|
8
|
+
* @frames web
|
|
9
|
+
*/
|
|
10
|
+
import React from 'react';
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class IProps {
|
|
15
|
+
categoryId?: number;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/*
|
|
19
|
+
* 数据与接口请求定义
|
|
20
|
+
*/
|
|
21
|
+
class IState {
|
|
22
|
+
products?: {
|
|
23
|
+
/* @example 1 */id?: number,
|
|
24
|
+
/* @example iPhone 15 Pro */name?: string,
|
|
25
|
+
/* @example 7999 */price?: number,
|
|
26
|
+
/* @example 手机 */category?: string,
|
|
27
|
+
/* @example 50 */stock?: number,
|
|
28
|
+
/* @example available */status?: string,
|
|
29
|
+
/* @example https://via.placeholder.com/100 */image?: string,
|
|
30
|
+
/* @example 2024-01-15 */createTime?: string,
|
|
31
|
+
}[];
|
|
32
|
+
categories?: string[];
|
|
33
|
+
loading?: boolean;
|
|
34
|
+
searchKeyword?: string;
|
|
35
|
+
selectedProduct?: any;
|
|
36
|
+
showAddModal?: boolean;
|
|
37
|
+
showEditModal?: boolean;
|
|
38
|
+
formData?: {
|
|
39
|
+
name?: string,
|
|
40
|
+
price?: number,
|
|
41
|
+
category?: string,
|
|
42
|
+
stock?: number,
|
|
43
|
+
status?: string,
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
class Document extends React.Component<IProps, IState> {
|
|
48
|
+
state = {
|
|
49
|
+
products: [
|
|
50
|
+
{
|
|
51
|
+
id: 1,
|
|
52
|
+
name: 'iPhone 15 Pro',
|
|
53
|
+
price: 7999,
|
|
54
|
+
category: '手机',
|
|
55
|
+
stock: 50,
|
|
56
|
+
status: 'available',
|
|
57
|
+
image: 'https://via.placeholder.com/100',
|
|
58
|
+
createTime: '2024-01-15',
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
id: 2,
|
|
62
|
+
name: 'MacBook Pro',
|
|
63
|
+
price: 12999,
|
|
64
|
+
category: '电脑',
|
|
65
|
+
stock: 30,
|
|
66
|
+
status: 'available',
|
|
67
|
+
image: 'https://via.placeholder.com/100',
|
|
68
|
+
createTime: '2024-02-20',
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
id: 3,
|
|
72
|
+
name: 'AirPods Pro',
|
|
73
|
+
price: 1999,
|
|
74
|
+
category: '耳机',
|
|
75
|
+
stock: 100,
|
|
76
|
+
status: 'available',
|
|
77
|
+
image: 'https://via.placeholder.com/100',
|
|
78
|
+
createTime: '2024-03-10',
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
id: 4,
|
|
82
|
+
name: 'iPad Air',
|
|
83
|
+
price: 4999,
|
|
84
|
+
category: '平板',
|
|
85
|
+
stock: 0,
|
|
86
|
+
status: 'out_of_stock',
|
|
87
|
+
image: 'https://via.placeholder.com/100',
|
|
88
|
+
createTime: '2024-04-05',
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
id: 5,
|
|
92
|
+
name: 'Apple Watch',
|
|
93
|
+
price: 2999,
|
|
94
|
+
category: '手表',
|
|
95
|
+
stock: 25,
|
|
96
|
+
status: 'available',
|
|
97
|
+
image: 'https://via.placeholder.com/100',
|
|
98
|
+
createTime: '2024-05-12',
|
|
99
|
+
},
|
|
100
|
+
],
|
|
101
|
+
categories: ['手机', '电脑', '耳机', '平板', '手表', '配件'],
|
|
102
|
+
loading: false,
|
|
103
|
+
searchKeyword: '',
|
|
104
|
+
selectedProduct: null,
|
|
105
|
+
showAddModal: false,
|
|
106
|
+
showEditModal: false,
|
|
107
|
+
formData: {
|
|
108
|
+
name: '',
|
|
109
|
+
price: 0,
|
|
110
|
+
category: '',
|
|
111
|
+
stock: 0,
|
|
112
|
+
status: 'available',
|
|
113
|
+
},
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
handleSearch(keyword) {
|
|
117
|
+
this.setState({
|
|
118
|
+
searchKeyword: keyword,
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
getProductById(id) {
|
|
123
|
+
return this.state.products.find(product => product.id === id);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
formatPrice(price) {
|
|
127
|
+
return `¥${price.toFixed(2)}`;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
getStatusTag(status) {
|
|
131
|
+
if (status === 'available') {
|
|
132
|
+
return <Tag color="green">有货</Tag>;
|
|
133
|
+
} else if (status === 'out_of_stock') {
|
|
134
|
+
return <Tag color="red">缺货</Tag>;
|
|
135
|
+
}
|
|
136
|
+
return <Tag color="orange">预定</Tag>;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
handleAddProduct() {
|
|
140
|
+
this.setState({
|
|
141
|
+
showAddModal: true,
|
|
142
|
+
formData: {
|
|
143
|
+
name: '',
|
|
144
|
+
price: 0,
|
|
145
|
+
category: '',
|
|
146
|
+
stock: 0,
|
|
147
|
+
status: 'available',
|
|
148
|
+
},
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
async handleSubmit(type) {
|
|
153
|
+
await new Promise(resolve => setTimeout(resolve, 500));
|
|
154
|
+
if (type === 'add') {
|
|
155
|
+
console.log('添加产品:', this.state.formData);
|
|
156
|
+
} else {
|
|
157
|
+
console.log('编辑产品:', this.state.formData);
|
|
158
|
+
}
|
|
159
|
+
this.setState({
|
|
160
|
+
showAddModal: false,
|
|
161
|
+
showEditModal: false,
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
handleEditProduct(product) {
|
|
166
|
+
this.setState({
|
|
167
|
+
selectedProduct: product,
|
|
168
|
+
formData: {
|
|
169
|
+
...product,
|
|
170
|
+
},
|
|
171
|
+
showEditModal: true,
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
handleDeleteProduct(id) {
|
|
176
|
+
const confirm = window.confirm('确定要删除这个产品吗?');
|
|
177
|
+
if (confirm) {
|
|
178
|
+
console.log('删除产品:', id);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
render() {
|
|
183
|
+
return (
|
|
184
|
+
<Page className="p-[24px] bg-[var(--gray-50)] min-h-screen">
|
|
185
|
+
<View className="mb-[24px]">
|
|
186
|
+
<Text className="text-2xl font-bold text-[#1f2937]">产品管理</Text>
|
|
187
|
+
<Text className="text-[#6b7280] text-sm mt-[4px]">
|
|
188
|
+
管理所有产品信息
|
|
189
|
+
</Text>
|
|
190
|
+
</View>
|
|
191
|
+
{!!this.state.loading && <View className="p-[24px]">加载中...</View>}
|
|
192
|
+
<View className="mb-[24px] flex items-center justify-between">
|
|
193
|
+
<View className="gap-4 flex items-center">
|
|
194
|
+
<Input
|
|
195
|
+
placeholder="搜索产品名称/分类"
|
|
196
|
+
value={this.state.searchKeyword}
|
|
197
|
+
onChange={e => this.handleSearch(e.target.value)}
|
|
198
|
+
prefix="🔍"
|
|
199
|
+
className=""
|
|
200
|
+
/>
|
|
201
|
+
</View>
|
|
202
|
+
<Button type="primary" onClick={() => this.handleAddProduct()}>
|
|
203
|
+
+ 新增产品
|
|
204
|
+
</Button>
|
|
205
|
+
</View>
|
|
206
|
+
<Table
|
|
207
|
+
loading={this.state.loading}
|
|
208
|
+
columns={[
|
|
209
|
+
{
|
|
210
|
+
title: '图片',
|
|
211
|
+
dataIndex: 'image',
|
|
212
|
+
key: 'image',
|
|
213
|
+
render: image => <Image src={image} width={60} height={60} />,
|
|
214
|
+
},
|
|
215
|
+
{ title: '产品名称', dataIndex: 'name', key: 'name' },
|
|
216
|
+
{
|
|
217
|
+
title: '价格',
|
|
218
|
+
dataIndex: 'price',
|
|
219
|
+
key: 'price',
|
|
220
|
+
render: price => <Text>{this.formatPrice(price)}</Text>,
|
|
221
|
+
},
|
|
222
|
+
{
|
|
223
|
+
title: '分类',
|
|
224
|
+
dataIndex: 'category',
|
|
225
|
+
key: 'category',
|
|
226
|
+
render: category => (
|
|
227
|
+
<Tag color="blue">
|
|
228
|
+
<Text>{category}</Text>
|
|
229
|
+
</Tag>
|
|
230
|
+
),
|
|
231
|
+
},
|
|
232
|
+
{ title: '库存', dataIndex: 'stock', key: 'stock' },
|
|
233
|
+
{
|
|
234
|
+
title: '状态',
|
|
235
|
+
dataIndex: 'status',
|
|
236
|
+
key: 'status',
|
|
237
|
+
render: function (status) {
|
|
238
|
+
return this.getStatusTag(status);
|
|
239
|
+
},
|
|
240
|
+
},
|
|
241
|
+
{ title: '创建时间', dataIndex: 'createTime', key: 'createTime' },
|
|
242
|
+
{
|
|
243
|
+
title: '操作',
|
|
244
|
+
key: 'action',
|
|
245
|
+
render: (text, record) => (
|
|
246
|
+
<Space>
|
|
247
|
+
<Button
|
|
248
|
+
type="link"
|
|
249
|
+
onClick={() => this.handleEditProduct(record)}
|
|
250
|
+
>
|
|
251
|
+
编辑
|
|
252
|
+
</Button>
|
|
253
|
+
<Button
|
|
254
|
+
type="link"
|
|
255
|
+
danger={true}
|
|
256
|
+
onClick={() => this.handleDeleteProduct(record.id)}
|
|
257
|
+
>
|
|
258
|
+
删除
|
|
259
|
+
</Button>
|
|
260
|
+
</Space>
|
|
261
|
+
),
|
|
262
|
+
},
|
|
263
|
+
]}
|
|
264
|
+
dataSource={this.state.products?.filter(function (product) {
|
|
265
|
+
return (
|
|
266
|
+
product?.name?.includes(this.state.searchKeyword) ||
|
|
267
|
+
product?.category?.includes(this.state.searchKeyword)
|
|
268
|
+
);
|
|
269
|
+
})}
|
|
270
|
+
rowKey="id"
|
|
271
|
+
pagination={{
|
|
272
|
+
pageSize: 10,
|
|
273
|
+
showTotal: function (total) {
|
|
274
|
+
return `共 ${total} 条`;
|
|
275
|
+
},
|
|
276
|
+
}}
|
|
277
|
+
/>
|
|
278
|
+
<Modal
|
|
279
|
+
animate="pop"
|
|
280
|
+
visible={this.state.showAddModal}
|
|
281
|
+
renderView={() => (
|
|
282
|
+
<View className="bg-[#ffffff] w-[600px] h-[500px] p-[24px]">
|
|
283
|
+
<Text className="text-xl font-bold mb-[16px]">新增产品</Text>
|
|
284
|
+
<View className="space-y-4">
|
|
285
|
+
<View>
|
|
286
|
+
<Text className="block mb-[8px]">产品名称</Text>
|
|
287
|
+
<Input
|
|
288
|
+
value={this.state.formData.name}
|
|
289
|
+
onChange={e =>
|
|
290
|
+
this.setState({
|
|
291
|
+
formData: {
|
|
292
|
+
...this.state.formData,
|
|
293
|
+
name: e.target.value,
|
|
294
|
+
},
|
|
295
|
+
})
|
|
296
|
+
}
|
|
297
|
+
placeholder="请输入产品名称"
|
|
298
|
+
/>
|
|
299
|
+
</View>
|
|
300
|
+
<View>
|
|
301
|
+
<Text className="block mb-[8px]">价格</Text>
|
|
302
|
+
<Input
|
|
303
|
+
type="number"
|
|
304
|
+
value={this.state.formData.price}
|
|
305
|
+
onChange={e =>
|
|
306
|
+
this.setState({
|
|
307
|
+
formData: {
|
|
308
|
+
...this.state.formData,
|
|
309
|
+
price: Number(e.target.value),
|
|
310
|
+
},
|
|
311
|
+
})
|
|
312
|
+
}
|
|
313
|
+
placeholder="请输入价格"
|
|
314
|
+
/>
|
|
315
|
+
</View>
|
|
316
|
+
<View>
|
|
317
|
+
<Text className="block mb-[8px]">分类</Text>
|
|
318
|
+
<Select
|
|
319
|
+
value={this.state.formData.category}
|
|
320
|
+
onChange={value =>
|
|
321
|
+
this.setState({
|
|
322
|
+
formData: {
|
|
323
|
+
...this.state.formData,
|
|
324
|
+
category: value,
|
|
325
|
+
},
|
|
326
|
+
})
|
|
327
|
+
}
|
|
328
|
+
placeholder="请选择分类"
|
|
329
|
+
className="w-full"
|
|
330
|
+
>
|
|
331
|
+
{this.state.categories.map((category, index) => (
|
|
332
|
+
<Select.Option key={category} value={category}>
|
|
333
|
+
<Text>{category}</Text>
|
|
334
|
+
</Select.Option>
|
|
335
|
+
))}
|
|
336
|
+
</Select>
|
|
337
|
+
</View>
|
|
338
|
+
<View>
|
|
339
|
+
<Text className="block mb-[8px]">库存</Text>
|
|
340
|
+
<Input
|
|
341
|
+
type="number"
|
|
342
|
+
value={this.state.formData.stock}
|
|
343
|
+
onChange={e =>
|
|
344
|
+
this.setState({
|
|
345
|
+
formData: {
|
|
346
|
+
...this.state.formData,
|
|
347
|
+
stock: Number(e.target.value),
|
|
348
|
+
},
|
|
349
|
+
})
|
|
350
|
+
}
|
|
351
|
+
placeholder="请输入库存"
|
|
352
|
+
/>
|
|
353
|
+
</View>
|
|
354
|
+
<View>
|
|
355
|
+
<Text className="block mb-[8px]">状态</Text>
|
|
356
|
+
<Select
|
|
357
|
+
value={this.state.formData.status}
|
|
358
|
+
onChange={value =>
|
|
359
|
+
this.setState({
|
|
360
|
+
formData: {
|
|
361
|
+
...this.state.formData,
|
|
362
|
+
status: value,
|
|
363
|
+
},
|
|
364
|
+
})
|
|
365
|
+
}
|
|
366
|
+
placeholder="请选择状态"
|
|
367
|
+
className="w-full"
|
|
368
|
+
>
|
|
369
|
+
<Select.Option value="available">有货</Select.Option>
|
|
370
|
+
<Select.Option value="out_of_stock">缺货</Select.Option>
|
|
371
|
+
<Select.Option value="preorder">预定</Select.Option>
|
|
372
|
+
</Select>
|
|
373
|
+
</View>
|
|
374
|
+
<View className="gap-2 flex justify-end mt-[24px]">
|
|
375
|
+
<Button
|
|
376
|
+
onClick={() =>
|
|
377
|
+
this.setState({
|
|
378
|
+
showAddModal: false,
|
|
379
|
+
})
|
|
380
|
+
}
|
|
381
|
+
>
|
|
382
|
+
取消
|
|
383
|
+
</Button>
|
|
384
|
+
<Button
|
|
385
|
+
type="primary"
|
|
386
|
+
onClick={() => this.handleSubmit('add')}
|
|
387
|
+
>
|
|
388
|
+
确认
|
|
389
|
+
</Button>
|
|
390
|
+
</View>
|
|
391
|
+
</View>
|
|
392
|
+
</View>
|
|
393
|
+
)}
|
|
394
|
+
maskClosable={true}
|
|
395
|
+
/>
|
|
396
|
+
<Modal
|
|
397
|
+
animate="pop"
|
|
398
|
+
visible={this.state.showEditModal}
|
|
399
|
+
renderView={() => (
|
|
400
|
+
<View className="bg-[#ffffff] w-[600px] h-[500px] p-[24px]">
|
|
401
|
+
<Text className="text-xl font-bold mb-[16px]">
|
|
402
|
+
编辑产品:{this.state.selectedProduct?.name}
|
|
403
|
+
</Text>
|
|
404
|
+
<View className="space-y-4">
|
|
405
|
+
<View>
|
|
406
|
+
<Text className="block mb-[8px]">产品名称</Text>
|
|
407
|
+
<Input
|
|
408
|
+
value={this.state.formData.name}
|
|
409
|
+
onChange={e =>
|
|
410
|
+
this.setState({
|
|
411
|
+
formData: {
|
|
412
|
+
...this.state.formData,
|
|
413
|
+
name: e.target.value,
|
|
414
|
+
},
|
|
415
|
+
})
|
|
416
|
+
}
|
|
417
|
+
placeholder="请输入产品名称"
|
|
418
|
+
/>
|
|
419
|
+
</View>
|
|
420
|
+
<View>
|
|
421
|
+
<Text className="block mb-[8px]">价格</Text>
|
|
422
|
+
<Input
|
|
423
|
+
type="number"
|
|
424
|
+
value={this.state.formData.price}
|
|
425
|
+
onChange={e =>
|
|
426
|
+
this.setState({
|
|
427
|
+
formData: {
|
|
428
|
+
...this.state.formData,
|
|
429
|
+
price: Number(e.target.value),
|
|
430
|
+
},
|
|
431
|
+
})
|
|
432
|
+
}
|
|
433
|
+
placeholder="请输入价格"
|
|
434
|
+
/>
|
|
435
|
+
</View>
|
|
436
|
+
<View>
|
|
437
|
+
<Text className="block mb-[8px]">分类</Text>
|
|
438
|
+
<Select
|
|
439
|
+
value={this.state.formData.category}
|
|
440
|
+
onChange={value =>
|
|
441
|
+
this.setState({
|
|
442
|
+
formData: {
|
|
443
|
+
...this.state.formData,
|
|
444
|
+
category: value,
|
|
445
|
+
},
|
|
446
|
+
})
|
|
447
|
+
}
|
|
448
|
+
placeholder="请选择分类"
|
|
449
|
+
className="w-full"
|
|
450
|
+
>
|
|
451
|
+
{this.state.categories.map((category, index) => (
|
|
452
|
+
<Select.Option key={category} value={category}>
|
|
453
|
+
<Text>{category}</Text>
|
|
454
|
+
</Select.Option>
|
|
455
|
+
))}
|
|
456
|
+
</Select>
|
|
457
|
+
</View>
|
|
458
|
+
<View>
|
|
459
|
+
<Text className="block mb-[8px]">库存</Text>
|
|
460
|
+
<Input
|
|
461
|
+
type="number"
|
|
462
|
+
value={this.state.formData.stock}
|
|
463
|
+
onChange={e =>
|
|
464
|
+
this.setState({
|
|
465
|
+
formData: {
|
|
466
|
+
...this.state.formData,
|
|
467
|
+
stock: Number(e.target.value),
|
|
468
|
+
},
|
|
469
|
+
})
|
|
470
|
+
}
|
|
471
|
+
placeholder="请输入库存"
|
|
472
|
+
/>
|
|
473
|
+
</View>
|
|
474
|
+
<View>
|
|
475
|
+
<Text className="block mb-[8px]">状态</Text>
|
|
476
|
+
<Select
|
|
477
|
+
value={this.state.formData.status}
|
|
478
|
+
onChange={value =>
|
|
479
|
+
this.setState({
|
|
480
|
+
formData: {
|
|
481
|
+
...this.state.formData,
|
|
482
|
+
status: value,
|
|
483
|
+
},
|
|
484
|
+
})
|
|
485
|
+
}
|
|
486
|
+
placeholder="请选择状态"
|
|
487
|
+
className="w-full"
|
|
488
|
+
>
|
|
489
|
+
<Select.Option value="available">有货</Select.Option>
|
|
490
|
+
<Select.Option value="out_of_stock">缺货</Select.Option>
|
|
491
|
+
<Select.Option value="preorder">预定</Select.Option>
|
|
492
|
+
</Select>
|
|
493
|
+
</View>
|
|
494
|
+
<View className="gap-2 flex justify-end mt-[24px]">
|
|
495
|
+
<Button
|
|
496
|
+
onClick={() =>
|
|
497
|
+
this.setState({
|
|
498
|
+
showEditModal: false,
|
|
499
|
+
})
|
|
500
|
+
}
|
|
501
|
+
>
|
|
502
|
+
取消
|
|
503
|
+
</Button>
|
|
504
|
+
<Button
|
|
505
|
+
type="primary"
|
|
506
|
+
onClick={() => this.handleSubmit('edit')}
|
|
507
|
+
>
|
|
508
|
+
确认
|
|
509
|
+
</Button>
|
|
510
|
+
</View>
|
|
511
|
+
</View>
|
|
512
|
+
</View>
|
|
513
|
+
)}
|
|
514
|
+
maskClosable={true}
|
|
515
|
+
/>
|
|
516
|
+
</Page>
|
|
517
|
+
);
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
export default Document;
|