@yuku123/z-task-component 0.0.0-stage → 0.1.1

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/dist/index.js ADDED
@@ -0,0 +1,855 @@
1
+ import { j as e } from "./jsx-runtime-z6PQ6F3d.js";
2
+ import { Card as C, Space as w, Tag as v, Button as T, Table as Z, Select as M, Form as f, Empty as X, Spin as de, Descriptions as k, List as N, Drawer as xe, Input as A, message as b, Popconfirm as ue, Typography as je, Modal as he, DatePicker as be, Row as se, Col as U, Statistic as G, Progress as Ie } from "antd";
3
+ import { CheckCircleOutlined as Y, EditOutlined as J, DeleteOutlined as ee, PlusOutlined as pe, InboxOutlined as Te, CheckOutlined as te, UnorderedListOutlined as ke, EyeOutlined as ve, ProjectOutlined as we, ReloadOutlined as Pe, ClockCircleOutlined as me, RocketOutlined as ye } from "@ant-design/icons";
4
+ import { useState as h, useEffect as E } from "react";
5
+ import { createRequest as De, authRequest as Se } from "@yuku123/z-frontend-common";
6
+ import { PageHeader as ze, TableToolbar as Oe, ErrorState as le, EmptyState as Le } from "@yuku123/z-frontend-common/ui";
7
+ import { Routes as Ce, Route as q, Navigate as Me } from "react-router-dom";
8
+ const Re = {
9
+ high: { color: "red", text: "高" },
10
+ medium: { color: "orange", text: "中" },
11
+ low: { color: "green", text: "低" }
12
+ }, Be = {
13
+ pending: { color: "default", text: "待处理" },
14
+ in_progress: { color: "blue", text: "进行中" },
15
+ completed: { color: "green", text: "已完成" }
16
+ };
17
+ function Ye({ task: s, onEdit: l, onComplete: o }) {
18
+ const i = Re[s.priority] || { color: "default", text: s.priority }, n = Be[s.status] || { color: "default", text: s.status };
19
+ return /* @__PURE__ */ e.jsx(C, { size: "small", title: s.title, extra: /* @__PURE__ */ e.jsxs(w, { children: [
20
+ s.status !== "completed" && /* @__PURE__ */ e.jsx(T, { size: "small", icon: /* @__PURE__ */ e.jsx(Y, {}), onClick: () => o == null ? void 0 : o(s), children: "完成" }),
21
+ /* @__PURE__ */ e.jsx(T, { size: "small", icon: /* @__PURE__ */ e.jsx(J, {}), onClick: () => l == null ? void 0 : l(s), children: "编辑" })
22
+ ] }), children: /* @__PURE__ */ e.jsxs(w, { orientation: "vertical", style: { width: "100%" }, children: [
23
+ /* @__PURE__ */ e.jsxs("div", { children: [
24
+ "项目:",
25
+ s.projectName
26
+ ] }),
27
+ /* @__PURE__ */ e.jsxs(w, { children: [
28
+ /* @__PURE__ */ e.jsx(v, { color: i.color, children: i.text }),
29
+ /* @__PURE__ */ e.jsx(v, { color: n.color, children: n.text })
30
+ ] }),
31
+ s.dueDate && /* @__PURE__ */ e.jsxs("div", { children: [
32
+ "截止:",
33
+ s.dueDate
34
+ ] })
35
+ ] }) });
36
+ }
37
+ const Fe = { high: "red", medium: "orange", low: "green" }, Ae = {
38
+ pending: "default",
39
+ in_progress: "blue",
40
+ completed: "green"
41
+ };
42
+ function Je({ dataSource: s, loading: l, onEdit: o, onDelete: i, onComplete: n }) {
43
+ const r = [
44
+ { title: "任务名称", dataIndex: "title", key: "title" },
45
+ { title: "项目", dataIndex: "projectName", key: "projectName" },
46
+ {
47
+ title: "优先级",
48
+ dataIndex: "priority",
49
+ key: "priority",
50
+ render: (d) => /* @__PURE__ */ e.jsx(v, { color: Fe[d], children: d === "high" ? "高" : d === "medium" ? "中" : "低" })
51
+ },
52
+ {
53
+ title: "状态",
54
+ dataIndex: "status",
55
+ key: "status",
56
+ render: (d) => {
57
+ const y = { pending: "待处理", in_progress: "进行中", completed: "已完成" };
58
+ return /* @__PURE__ */ e.jsx(v, { color: Ae[d], children: y[d] || d });
59
+ }
60
+ },
61
+ { title: "截止日期", dataIndex: "dueDate", key: "dueDate" },
62
+ {
63
+ title: "操作",
64
+ key: "action",
65
+ render: (d, y) => /* @__PURE__ */ e.jsxs(w, { children: [
66
+ y.status !== "completed" && /* @__PURE__ */ e.jsx(T, { size: "small", icon: /* @__PURE__ */ e.jsx(Y, {}), onClick: () => n == null ? void 0 : n(y), children: "完成" }),
67
+ /* @__PURE__ */ e.jsx(T, { size: "small", icon: /* @__PURE__ */ e.jsx(J, {}), onClick: () => o == null ? void 0 : o(y), children: "编辑" }),
68
+ /* @__PURE__ */ e.jsx(T, { size: "small", danger: !0, icon: /* @__PURE__ */ e.jsx(ee, {}), onClick: () => i == null ? void 0 : i(y), children: "删除" })
69
+ ] })
70
+ }
71
+ ];
72
+ return /* @__PURE__ */ e.jsx(
73
+ Z,
74
+ {
75
+ columns: r,
76
+ dataSource: s,
77
+ loading: l,
78
+ rowKey: "id",
79
+ pagination: { pageSize: 10 }
80
+ }
81
+ );
82
+ }
83
+ function Qe({ value: s, onChange: l, projects: o = [] }) {
84
+ return /* @__PURE__ */ e.jsx(
85
+ M,
86
+ {
87
+ value: s,
88
+ onChange: l,
89
+ placeholder: "请选择项目",
90
+ style: { width: 200 },
91
+ allowClear: !0,
92
+ children: o.map((i) => /* @__PURE__ */ e.jsx(M.Option, { value: i.id, children: i.name }, i.id))
93
+ }
94
+ );
95
+ }
96
+ const L = De("task"), I = {
97
+ // === 项目 ===
98
+ listMyProjects: () => Se.get("/project/user/list"),
99
+ createProject: (s) => L.post("/project", s),
100
+ updateProject: (s, l) => L.put(`/project/${s}`, l),
101
+ archiveProject: (s) => L.put(`/project/${s}/archive`),
102
+ // === 任务 ===
103
+ listTasksByProject: (s) => L.get("/task/project/list", { params: { projectId: s } }),
104
+ listTasksByList: (s) => L.get("/task/list", { params: { listId: s } }),
105
+ createTask: (s) => L.post("/task", s),
106
+ completeTask: (s) => L.post("/task/complete", null, { params: { taskId: s } }),
107
+ moveTask: (s, l, o) => L.put("/task/move", null, { params: { taskId: s, targetListId: l, position: o } }),
108
+ // === 任务详情 ===
109
+ getTaskDetail: (s) => L.get(`/task/${s}`),
110
+ updateTask: (s, l) => L.put(`/task/${s}`, l),
111
+ deleteTask: (s) => L.delete(`/task/${s}`)
112
+ }, Q = (s) => {
113
+ if (!s) return "-";
114
+ const l = String(s), o = l.match(/^(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2})/);
115
+ return o ? o[1] : l;
116
+ };
117
+ function re({ apiBaseURL: s }) {
118
+ const [l, o] = h([]), [i, n] = h(!1), [r, d] = h(!1), [y, j] = h(null), [u, D] = h(null), [S, z] = h([]), [g, F] = h(!1), [O] = f.useForm(), c = async () => {
119
+ n(!0);
120
+ try {
121
+ const t = await I.listMyProjects();
122
+ o((t == null ? void 0 : t.data) || t || []);
123
+ } catch (t) {
124
+ b.error("加载项目失败: " + ((t == null ? void 0 : t.message) || t));
125
+ } finally {
126
+ n(!1);
127
+ }
128
+ };
129
+ E(() => {
130
+ c();
131
+ }, []);
132
+ const p = async (t) => {
133
+ D(t), F(!0);
134
+ try {
135
+ const x = await I.listTasksByProject(t.id);
136
+ z((x == null ? void 0 : x.data) || x || []);
137
+ } catch (x) {
138
+ b.error("加载任务失败: " + ((x == null ? void 0 : x.message) || x));
139
+ } finally {
140
+ F(!1);
141
+ }
142
+ }, P = async () => {
143
+ if (u)
144
+ try {
145
+ const t = await I.listTasksByProject(u.id);
146
+ z((t == null ? void 0 : t.data) || t || []);
147
+ } catch (t) {
148
+ b.error("刷新任务失败: " + ((t == null ? void 0 : t.message) || t));
149
+ }
150
+ }, R = () => {
151
+ j(null), O.resetFields(), O.setFieldsValue({ status: 1 }), d(!0);
152
+ }, _ = (t) => {
153
+ j(t), O.setFieldsValue({ name: t.name, description: t.description, status: t.status ?? 1 }), d(!0);
154
+ }, V = async () => {
155
+ try {
156
+ const t = await O.validateFields();
157
+ y ? (await I.updateProject(y.id, t), b.success("项目已更新")) : (await I.createProject(t), b.success("项目已创建")), d(!1), c();
158
+ } catch (t) {
159
+ if (t != null && t.errorFields) return;
160
+ b.error("保存失败: " + ((t == null ? void 0 : t.message) || t));
161
+ }
162
+ }, $ = async (t) => {
163
+ try {
164
+ await I.archiveProject(t), b.success("项目已归档"), c(), (u == null ? void 0 : u.id) === t && (D(null), z([]));
165
+ } catch (x) {
166
+ b.error("归档失败: " + ((x == null ? void 0 : x.message) || x));
167
+ }
168
+ }, H = async (t) => {
169
+ try {
170
+ await I.completeTask(t), b.success("任务已完成"), P();
171
+ } catch (x) {
172
+ b.error("操作失败: " + ((x == null ? void 0 : x.message) || x));
173
+ }
174
+ }, B = [
175
+ {
176
+ title: "项目名称",
177
+ dataIndex: "name",
178
+ render: (t, x) => /* @__PURE__ */ e.jsx(
179
+ "a",
180
+ {
181
+ onClick: () => p(x),
182
+ style: { fontWeight: (u == null ? void 0 : u.id) === x.id ? 600 : 400 },
183
+ children: t
184
+ }
185
+ )
186
+ },
187
+ {
188
+ title: "状态",
189
+ dataIndex: "status",
190
+ width: 80,
191
+ render: (t) => t === 1 ? /* @__PURE__ */ e.jsx(v, { color: "green", children: "进行中" }) : /* @__PURE__ */ e.jsx(v, { children: "已归档" })
192
+ },
193
+ { title: "创建时间", dataIndex: "createdAt", width: 170, render: Q },
194
+ {
195
+ title: "操作",
196
+ width: 160,
197
+ fixed: "right",
198
+ render: (t, x) => /* @__PURE__ */ e.jsxs(w, { children: [
199
+ /* @__PURE__ */ e.jsx(T, { size: "small", icon: /* @__PURE__ */ e.jsx(J, {}), onClick: () => _(x), children: "编辑" }),
200
+ /* @__PURE__ */ e.jsx(ue, { title: "确定归档该项目?", onConfirm: () => $(x.id), children: /* @__PURE__ */ e.jsx(T, { size: "small", danger: !0, icon: /* @__PURE__ */ e.jsx(ee, {}), children: "归档" }) })
201
+ ] })
202
+ }
203
+ ], K = (t) => {
204
+ const W = {
205
+ 0: { text: "待办", color: "default" },
206
+ 1: { text: "进行中", color: "blue" },
207
+ 2: { text: "已完成", color: "green" }
208
+ }[t] || { text: String(t), color: "default" };
209
+ return /* @__PURE__ */ e.jsx(v, { color: W.color, children: W.text });
210
+ };
211
+ return /* @__PURE__ */ e.jsxs("div", { children: [
212
+ /* @__PURE__ */ e.jsx("div", { style: { display: "flex", justifyContent: "flex-end", marginBottom: 12 }, children: /* @__PURE__ */ e.jsx(T, { type: "primary", icon: /* @__PURE__ */ e.jsx(pe, {}), onClick: R, children: "新建项目" }) }),
213
+ /* @__PURE__ */ e.jsxs("div", { style: { display: "flex", gap: 16, height: "calc(100vh - 220px)" }, children: [
214
+ /* @__PURE__ */ e.jsx(
215
+ C,
216
+ {
217
+ size: "small",
218
+ title: /* @__PURE__ */ e.jsxs(w, { children: [
219
+ /* @__PURE__ */ e.jsx(Te, {}),
220
+ "项目管理"
221
+ ] }),
222
+ style: { width: 520, flexShrink: 0 },
223
+ styles: { body: { padding: 8, overflow: "auto", height: "calc(100% - 40px)" } },
224
+ children: /* @__PURE__ */ e.jsx(
225
+ Z,
226
+ {
227
+ rowKey: "id",
228
+ columns: B,
229
+ dataSource: l,
230
+ loading: i,
231
+ pagination: { pageSize: 10, size: "small" },
232
+ size: "small",
233
+ rowClassName: (t) => (u == null ? void 0 : u.id) === t.id ? "ant-table-row-selected" : "",
234
+ onRow: (t) => ({ onClick: () => p(t), style: { cursor: "pointer" } }),
235
+ locale: { emptyText: "暂无项目" }
236
+ }
237
+ )
238
+ }
239
+ ),
240
+ /* @__PURE__ */ e.jsx(
241
+ C,
242
+ {
243
+ size: "small",
244
+ style: { flex: 1, overflow: "auto" },
245
+ styles: { body: { padding: 16 } },
246
+ title: u ? /* @__PURE__ */ e.jsxs(w, { children: [
247
+ /* @__PURE__ */ e.jsx(ke, {}),
248
+ u.name,
249
+ " · 任务列表"
250
+ ] }) : "项目详情",
251
+ children: u ? /* @__PURE__ */ e.jsxs(de, { spinning: g, children: [
252
+ /* @__PURE__ */ e.jsxs(k, { size: "small", bordered: !0, column: 2, style: { marginBottom: 16 }, children: [
253
+ /* @__PURE__ */ e.jsx(k.Item, { label: "项目名称", span: 2, children: u.name }),
254
+ /* @__PURE__ */ e.jsx(k.Item, { label: "描述", span: 2, children: u.description || "无" }),
255
+ /* @__PURE__ */ e.jsx(k.Item, { label: "负责人", children: u.ownerId || "未指定" }),
256
+ /* @__PURE__ */ e.jsx(k.Item, { label: "状态", children: u.status === 1 ? /* @__PURE__ */ e.jsx(v, { color: "green", children: "进行中" }) : /* @__PURE__ */ e.jsx(v, { children: "已归档" }) }),
257
+ /* @__PURE__ */ e.jsx(
258
+ k.Item,
259
+ {
260
+ label: "创建时间",
261
+ children: Q(u.createdAt)
262
+ }
263
+ ),
264
+ /* @__PURE__ */ e.jsx(k.Item, { label: "项目ID", children: u.id })
265
+ ] }),
266
+ /* @__PURE__ */ e.jsx(
267
+ N,
268
+ {
269
+ size: "small",
270
+ header: /* @__PURE__ */ e.jsxs("b", { children: [
271
+ "任务项 (",
272
+ S.length,
273
+ ")"
274
+ ] }),
275
+ bordered: !0,
276
+ dataSource: S,
277
+ locale: { emptyText: "该项目下暂无任务" },
278
+ renderItem: (t) => /* @__PURE__ */ e.jsx(
279
+ N.Item,
280
+ {
281
+ actions: [
282
+ /* @__PURE__ */ e.jsx(
283
+ T,
284
+ {
285
+ size: "small",
286
+ type: "primary",
287
+ icon: /* @__PURE__ */ e.jsx(te, {}),
288
+ disabled: t.status === 2,
289
+ onClick: () => H(t.id),
290
+ children: "完成"
291
+ },
292
+ "complete"
293
+ )
294
+ ],
295
+ children: /* @__PURE__ */ e.jsx(
296
+ N.Item.Meta,
297
+ {
298
+ title: /* @__PURE__ */ e.jsxs(w, { children: [
299
+ t.title,
300
+ K(t.status),
301
+ /* @__PURE__ */ e.jsxs(v, { children: [
302
+ "优先级 ",
303
+ t.priority ?? "-"
304
+ ] })
305
+ ] }),
306
+ description: /* @__PURE__ */ e.jsxs("span", { style: { color: "#888", fontSize: 12 }, children: [
307
+ "截止: ",
308
+ Q(t.dueDate),
309
+ " · ID: ",
310
+ t.id
311
+ ] })
312
+ }
313
+ )
314
+ }
315
+ )
316
+ }
317
+ )
318
+ ] }) : /* @__PURE__ */ e.jsx(X, { description: "请从左侧选择一个项目", style: { marginTop: 80 } })
319
+ }
320
+ )
321
+ ] }),
322
+ /* @__PURE__ */ e.jsx(
323
+ xe,
324
+ {
325
+ title: y ? `编辑项目 - ${y.name}` : "新建项目",
326
+ size: "large",
327
+ open: r,
328
+ onClose: () => d(!1),
329
+ destroyOnHidden: !0,
330
+ extra: /* @__PURE__ */ e.jsxs(w, { children: [
331
+ /* @__PURE__ */ e.jsx(T, { onClick: () => d(!1), children: "取消" }),
332
+ /* @__PURE__ */ e.jsx(T, { type: "primary", onClick: V, children: "保存" })
333
+ ] }),
334
+ children: /* @__PURE__ */ e.jsxs(f, { form: O, layout: "vertical", preserve: !1, children: [
335
+ /* @__PURE__ */ e.jsx(f.Item, { name: "name", label: "项目名称", rules: [{ required: !0, message: "请输入项目名称" }], children: /* @__PURE__ */ e.jsx(A, { placeholder: "例如: 一人公司" }) }),
336
+ /* @__PURE__ */ e.jsx(f.Item, { name: "description", label: "项目描述", children: /* @__PURE__ */ e.jsx(A.TextArea, { rows: 3, placeholder: "可选" }) }),
337
+ /* @__PURE__ */ e.jsx(f.Item, { name: "status", label: "状态", initialValue: 1, children: /* @__PURE__ */ e.jsx(
338
+ M,
339
+ {
340
+ options: [
341
+ { label: "进行中", value: 1 },
342
+ { label: "已归档", value: 0 }
343
+ ]
344
+ }
345
+ ) })
346
+ ] })
347
+ }
348
+ )
349
+ ] });
350
+ }
351
+ const { Paragraph: Ee } = je, ae = {
352
+ 0: { label: "待办", color: "default" },
353
+ 1: { label: "进行中", color: "blue" },
354
+ 2: { label: "已完成", color: "green" }
355
+ }, ie = {
356
+ 1: { label: "低", color: "default" },
357
+ 2: { label: "中", color: "orange" },
358
+ 3: { label: "高", color: "red" }
359
+ };
360
+ function _e({ taskId: s, open: l, onClose: o, onChanged: i, onEdit: n }) {
361
+ const [r, d] = h(null), [y, j] = h(!1);
362
+ E(() => {
363
+ !l || !s || (j(!0), I.getTaskDetail(s).then((g) => d((g == null ? void 0 : g.data) || g)).catch(() => d(null)).finally(() => j(!1)));
364
+ }, [l, s]);
365
+ const u = async () => {
366
+ try {
367
+ await I.completeTask(s), d((g) => ({ ...g, status: 2 })), i == null || i();
368
+ } catch {
369
+ }
370
+ }, D = async () => {
371
+ try {
372
+ await I.deleteTask(s), i == null || i(), o == null || o();
373
+ } catch {
374
+ }
375
+ }, S = ae[r == null ? void 0 : r.status] || ae[0], z = ie[r == null ? void 0 : r.priority] || ie[1];
376
+ return /* @__PURE__ */ e.jsx(
377
+ xe,
378
+ {
379
+ title: (r == null ? void 0 : r.title) || "任务详情",
380
+ size: "large",
381
+ open: l,
382
+ onClose: o,
383
+ loading: y,
384
+ footer: /* @__PURE__ */ e.jsxs("div", { style: { display: "flex", justifyContent: "space-between" }, children: [
385
+ /* @__PURE__ */ e.jsx(
386
+ ue,
387
+ {
388
+ title: "确认删除此任务?",
389
+ onConfirm: D,
390
+ okText: "删除",
391
+ cancelText: "取消",
392
+ okButtonProps: { danger: !0 },
393
+ children: /* @__PURE__ */ e.jsx(T, { danger: !0, icon: /* @__PURE__ */ e.jsx(ee, {}), children: "删除" })
394
+ }
395
+ ),
396
+ /* @__PURE__ */ e.jsxs(w, { children: [
397
+ (r == null ? void 0 : r.status) !== 2 && /* @__PURE__ */ e.jsx(T, { type: "primary", icon: /* @__PURE__ */ e.jsx(te, {}), onClick: u, children: "完成任务" }),
398
+ /* @__PURE__ */ e.jsx(T, { icon: /* @__PURE__ */ e.jsx(J, {}), onClick: () => n == null ? void 0 : n(r), children: "编辑" })
399
+ ] })
400
+ ] }),
401
+ children: r && /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
402
+ /* @__PURE__ */ e.jsxs(k, { column: 2, bordered: !0, size: "small", style: { marginBottom: 24 }, children: [
403
+ /* @__PURE__ */ e.jsx(k.Item, { label: "状态", children: /* @__PURE__ */ e.jsx(v, { color: S.color, children: S.label }) }),
404
+ /* @__PURE__ */ e.jsx(k.Item, { label: "优先级", children: /* @__PURE__ */ e.jsx(v, { color: z.color, children: z.label }) }),
405
+ /* @__PURE__ */ e.jsx(k.Item, { label: "项目 ID", children: r.projectId }),
406
+ /* @__PURE__ */ e.jsx(k.Item, { label: "列表 ID", children: r.listId }),
407
+ /* @__PURE__ */ e.jsx(k.Item, { label: "截止时间", span: 2, children: r.dueDate || "未设置" }),
408
+ /* @__PURE__ */ e.jsx(k.Item, { label: "创建时间", children: r.createdAt || "-" }),
409
+ /* @__PURE__ */ e.jsx(k.Item, { label: "更新时间", children: r.updatedAt || "-" })
410
+ ] }),
411
+ r.description && /* @__PURE__ */ e.jsxs("div", { style: { marginBottom: 24 }, children: [
412
+ /* @__PURE__ */ e.jsx("div", { style: { fontWeight: 600, marginBottom: 8 }, children: "描述" }),
413
+ /* @__PURE__ */ e.jsx(Ee, { style: { whiteSpace: "pre-wrap", color: "#595959" }, children: r.description })
414
+ ] })
415
+ ] })
416
+ }
417
+ );
418
+ }
419
+ function Ve({ open: s, task: l, projects: o, onClose: i, onSaved: n }) {
420
+ const [r] = f.useForm(), d = !!(l != null && l.id);
421
+ E(() => {
422
+ s && l ? r.setFieldsValue({
423
+ title: l.title,
424
+ description: l.description,
425
+ projectId: l.projectId,
426
+ listId: l.listId,
427
+ status: l.status,
428
+ priority: l.priority,
429
+ dueDate: l.dueDate
430
+ }) : s && r.resetFields();
431
+ }, [s, l, r]);
432
+ const y = async () => {
433
+ try {
434
+ const j = await r.validateFields();
435
+ d ? (await I.updateTask(l.id, j), b.success("任务已更新")) : (await I.createTask(j), b.success("任务已创建")), n == null || n(), i == null || i();
436
+ } catch (j) {
437
+ if (j != null && j.errorFields) return;
438
+ b.error("保存失败: " + ((j == null ? void 0 : j.message) || j));
439
+ }
440
+ };
441
+ return /* @__PURE__ */ e.jsx(
442
+ he,
443
+ {
444
+ title: d ? "编辑任务" : "新建任务",
445
+ open: s,
446
+ onCancel: i,
447
+ onOk: y,
448
+ destroyOnHidden: !0,
449
+ size: "large",
450
+ children: /* @__PURE__ */ e.jsxs(f, { form: r, layout: "vertical", preserve: !1, children: [
451
+ /* @__PURE__ */ e.jsx(
452
+ f.Item,
453
+ {
454
+ name: "title",
455
+ label: "任务标题",
456
+ rules: [{ required: !0, message: "请输入任务标题" }],
457
+ children: /* @__PURE__ */ e.jsx(A, { placeholder: "例如: 实现 xx 功能" })
458
+ }
459
+ ),
460
+ /* @__PURE__ */ e.jsx(f.Item, { name: "description", label: "描述", children: /* @__PURE__ */ e.jsx(A.TextArea, { rows: 3, placeholder: "任务描述 (可选)" }) }),
461
+ /* @__PURE__ */ e.jsxs("div", { style: { display: "flex", gap: 16 }, children: [
462
+ /* @__PURE__ */ e.jsx(
463
+ f.Item,
464
+ {
465
+ name: "projectId",
466
+ label: "所属项目",
467
+ rules: [{ required: !0 }],
468
+ style: { flex: 1 },
469
+ children: /* @__PURE__ */ e.jsx(
470
+ M,
471
+ {
472
+ options: o.map((j) => ({ label: j.name, value: j.id })),
473
+ placeholder: "选择项目"
474
+ }
475
+ )
476
+ }
477
+ ),
478
+ /* @__PURE__ */ e.jsx(f.Item, { name: "listId", label: "列表 ID", style: { flex: 1 }, children: /* @__PURE__ */ e.jsx(A, { type: "number", placeholder: "默认 1" }) })
479
+ ] }),
480
+ /* @__PURE__ */ e.jsxs("div", { style: { display: "flex", gap: 16 }, children: [
481
+ /* @__PURE__ */ e.jsx(f.Item, { name: "status", label: "状态", initialValue: 0, style: { flex: 1 }, children: /* @__PURE__ */ e.jsx(
482
+ M,
483
+ {
484
+ options: [
485
+ { label: "待办", value: 0 },
486
+ { label: "进行中", value: 1 },
487
+ { label: "已完成", value: 2 }
488
+ ]
489
+ }
490
+ ) }),
491
+ /* @__PURE__ */ e.jsx(f.Item, { name: "priority", label: "优先级", initialValue: 1, style: { flex: 1 }, children: /* @__PURE__ */ e.jsx(
492
+ M,
493
+ {
494
+ options: [
495
+ { label: "低", value: 1 },
496
+ { label: "中", value: 2 },
497
+ { label: "高", value: 3 }
498
+ ]
499
+ }
500
+ ) })
501
+ ] }),
502
+ /* @__PURE__ */ e.jsx(f.Item, { name: "dueDate", label: "截止时间", children: /* @__PURE__ */ e.jsx(be, { style: { width: "100%" }, placeholder: "选择截止日期" }) })
503
+ ] })
504
+ }
505
+ );
506
+ }
507
+ function ne({ apiBaseURL: s, back: l }) {
508
+ const [o, i] = h([]), [n, r] = h(null), [d, y] = h([]), [j, u] = h(!1), [D, S] = h(null), [z, g] = h(null), [F, O] = h(!1), [c, p] = h(!1), [P, R] = h(!1), [_, V] = h(null), [$] = f.useForm(), H = async () => {
509
+ try {
510
+ const a = await I.listMyProjects(), m = (a == null ? void 0 : a.data) || a || [];
511
+ i(m), g(null), m.length > 0 && !n && r(m[0].id);
512
+ } catch (a) {
513
+ g((a == null ? void 0 : a.message) || "加载项目失败");
514
+ }
515
+ }, B = async (a) => {
516
+ if (!a) {
517
+ y([]);
518
+ return;
519
+ }
520
+ u(!0), S(null);
521
+ try {
522
+ const m = await I.listTasksByProject(a);
523
+ y((m == null ? void 0 : m.data) || m || []);
524
+ } catch (m) {
525
+ S((m == null ? void 0 : m.message) || "加载任务失败");
526
+ } finally {
527
+ u(!1);
528
+ }
529
+ };
530
+ E(() => {
531
+ H();
532
+ }, []), E(() => {
533
+ B(n);
534
+ }, [n]);
535
+ const K = () => {
536
+ if (!n) {
537
+ b.warning("请先选择项目");
538
+ return;
539
+ }
540
+ $.resetFields(), $.setFieldsValue({ projectId: n, listId: 1, status: 1, priority: 1 }), O(!0);
541
+ }, t = async () => {
542
+ try {
543
+ const a = await $.validateFields();
544
+ await I.createTask(a), b.success("任务已创建"), O(!1), B(n);
545
+ } catch (a) {
546
+ if (a != null && a.errorFields) return;
547
+ b.error("创建失败: " + ((a == null ? void 0 : a.message) || a));
548
+ }
549
+ }, x = async (a) => {
550
+ try {
551
+ await I.completeTask(a), b.success("任务已完成"), B(n);
552
+ } catch (m) {
553
+ b.error("操作失败: " + ((m == null ? void 0 : m.message) || m));
554
+ }
555
+ }, W = [
556
+ { title: "ID", dataIndex: "id", width: 60 },
557
+ { title: "标题", dataIndex: "title" },
558
+ { title: "项目ID", dataIndex: "projectId", width: 80 },
559
+ {
560
+ title: "状态",
561
+ dataIndex: "status",
562
+ width: 100,
563
+ render: (a) => {
564
+ const m = { 0: "待办", 1: "进行中", 2: "已完成" }, ge = { 0: "default", 1: "blue", 2: "green" }[a] || "default";
565
+ return /* @__PURE__ */ e.jsx(v, { color: ge, children: m[a] || a });
566
+ }
567
+ },
568
+ { title: "优先级", dataIndex: "priority", width: 80 },
569
+ { title: "截止时间", dataIndex: "dueDate", width: 180 },
570
+ {
571
+ title: "操作",
572
+ width: 200,
573
+ fixed: "right",
574
+ render: (a, m) => /* @__PURE__ */ e.jsxs(w, { children: [
575
+ /* @__PURE__ */ e.jsx(
576
+ T,
577
+ {
578
+ size: "small",
579
+ icon: /* @__PURE__ */ e.jsx(ve, {}),
580
+ onClick: () => {
581
+ V(m), p(!0);
582
+ },
583
+ children: "查看"
584
+ }
585
+ ),
586
+ /* @__PURE__ */ e.jsx(
587
+ T,
588
+ {
589
+ size: "small",
590
+ type: "primary",
591
+ icon: /* @__PURE__ */ e.jsx(te, {}),
592
+ onClick: () => x(m.id),
593
+ disabled: m.status === 2,
594
+ children: "完成"
595
+ }
596
+ )
597
+ ] })
598
+ }
599
+ ], fe = !j && !D && d.length === 0 && n;
600
+ return /* @__PURE__ */ e.jsxs("div", { children: [
601
+ /* @__PURE__ */ e.jsx(
602
+ ze,
603
+ {
604
+ title: "任务管理",
605
+ subtitle: "按项目维度组织任务, 支持新建、完成等操作",
606
+ breadcrumb: [{ label: "任务中心" }, { label: "任务列表" }],
607
+ back: !!l
608
+ }
609
+ ),
610
+ /* @__PURE__ */ e.jsx(
611
+ Oe,
612
+ {
613
+ left: /* @__PURE__ */ e.jsx(
614
+ M,
615
+ {
616
+ value: n,
617
+ onChange: r,
618
+ style: { width: 240 },
619
+ placeholder: "选择项目",
620
+ options: o.map((a) => ({ label: a.name, value: a.id }))
621
+ }
622
+ ),
623
+ right: /* @__PURE__ */ e.jsx(T, { type: "primary", icon: /* @__PURE__ */ e.jsx(pe, {}), onClick: K, children: "新建任务" })
624
+ }
625
+ ),
626
+ z && /* @__PURE__ */ e.jsx("div", { style: { marginBottom: 16 }, children: /* @__PURE__ */ e.jsx(
627
+ le,
628
+ {
629
+ error: z,
630
+ onRetry: H,
631
+ title: "加载项目列表失败"
632
+ }
633
+ ) }),
634
+ D && /* @__PURE__ */ e.jsx("div", { style: { marginBottom: 16 }, children: /* @__PURE__ */ e.jsx(le, { error: D, onRetry: () => B(n) }) }),
635
+ /* @__PURE__ */ e.jsx("div", { style: {
636
+ background: "#ffffff",
637
+ borderRadius: 16,
638
+ padding: 20,
639
+ boxShadow: "0 1px 3px rgba(15, 23, 42, 0.04), 0 1px 2px rgba(15, 23, 42, 0.06)"
640
+ }, children: fe ? /* @__PURE__ */ e.jsx(
641
+ Le,
642
+ {
643
+ title: "该项目下还没有任务",
644
+ description: "把目标拆解成可执行的任务, 一项项推进",
645
+ actionText: "新建第一个任务",
646
+ onAction: K
647
+ }
648
+ ) : /* @__PURE__ */ e.jsx(
649
+ Z,
650
+ {
651
+ rowKey: "id",
652
+ columns: W,
653
+ dataSource: d,
654
+ loading: j,
655
+ pagination: { pageSize: 10 }
656
+ }
657
+ ) }),
658
+ /* @__PURE__ */ e.jsx(
659
+ he,
660
+ {
661
+ title: "新建任务",
662
+ open: F,
663
+ onCancel: () => O(!1),
664
+ onOk: t,
665
+ destroyOnHidden: !0,
666
+ children: /* @__PURE__ */ e.jsxs(f, { form: $, layout: "vertical", preserve: !1, children: [
667
+ /* @__PURE__ */ e.jsx(f.Item, { name: "title", label: "任务标题", rules: [{ required: !0, message: "请输入任务标题" }], children: /* @__PURE__ */ e.jsx(A, { placeholder: "例如: 实现 xx 功能" }) }),
668
+ /* @__PURE__ */ e.jsx(f.Item, { name: "projectId", label: "所属项目", rules: [{ required: !0 }], children: /* @__PURE__ */ e.jsx(
669
+ M,
670
+ {
671
+ options: o.map((a) => ({ label: a.name, value: a.id })),
672
+ placeholder: "从数据库捞出的项目列表"
673
+ }
674
+ ) }),
675
+ /* @__PURE__ */ e.jsx(f.Item, { name: "listId", label: "列表ID", rules: [{ required: !0 }], children: /* @__PURE__ */ e.jsx(A, { type: "number", placeholder: "默认 1" }) }),
676
+ /* @__PURE__ */ e.jsx(f.Item, { name: "priority", label: "优先级", initialValue: 1, children: /* @__PURE__ */ e.jsx(M, { options: [{ label: "低", value: 1 }, { label: "中", value: 2 }, { label: "高", value: 3 }] }) })
677
+ ] })
678
+ }
679
+ ),
680
+ /* @__PURE__ */ e.jsx(
681
+ _e,
682
+ {
683
+ taskId: _ == null ? void 0 : _.id,
684
+ open: c,
685
+ onClose: () => {
686
+ p(!1), V(null);
687
+ },
688
+ onChanged: B,
689
+ onEdit: (a) => {
690
+ V(a), p(!1), R(!0);
691
+ }
692
+ }
693
+ ),
694
+ /* @__PURE__ */ e.jsx(
695
+ Ve,
696
+ {
697
+ open: P,
698
+ task: _,
699
+ projects: o,
700
+ onClose: () => {
701
+ R(!1), V(null);
702
+ },
703
+ onSaved: B
704
+ }
705
+ )
706
+ ] });
707
+ }
708
+ const { Text: ce, Title: Xe } = je, oe = {
709
+ 0: { text: "待办", color: "default", icon: /* @__PURE__ */ e.jsx(me, {}) },
710
+ 1: { text: "进行中", color: "blue", icon: /* @__PURE__ */ e.jsx(ye, {}) },
711
+ 2: { text: "已完成", color: "green", icon: /* @__PURE__ */ e.jsx(Y, {}) }
712
+ };
713
+ function $e({ apiBaseURL: s }) {
714
+ const [l, o] = h([]), [i, n] = h(null), [r, d] = h([]), [y, j] = h(!1), [u, D] = h(!1), S = async () => {
715
+ D(!0);
716
+ try {
717
+ const c = await I.listMyProjects(), p = (c == null ? void 0 : c.data) || c || [];
718
+ o(p), p.length > 0 && !i && n(p[0].id);
719
+ } catch {
720
+ o([]);
721
+ } finally {
722
+ D(!1);
723
+ }
724
+ }, z = async (c) => {
725
+ if (!c) {
726
+ d([]);
727
+ return;
728
+ }
729
+ j(!0);
730
+ try {
731
+ const p = await I.listTasksByProject(c);
732
+ d((p == null ? void 0 : p.data) || p || []);
733
+ } catch {
734
+ d([]);
735
+ } finally {
736
+ j(!1);
737
+ }
738
+ };
739
+ E(() => {
740
+ S();
741
+ }, []), E(() => {
742
+ z(i);
743
+ }, [i]);
744
+ const g = r.reduce((c, p) => {
745
+ c.total += 1;
746
+ const P = p.status ?? 0;
747
+ return P === 0 ? c.todo += 1 : P === 1 ? c.doing += 1 : P === 2 && (c.done += 1), c;
748
+ }, { total: 0, todo: 0, doing: 0, done: 0 }), F = g.total > 0 ? Math.round(g.done / g.total * 100) : 0, O = [1, 2, 3].map((c) => ({
749
+ priority: c,
750
+ list: r.filter((p) => (p.priority ?? 1) === c)
751
+ }));
752
+ return /* @__PURE__ */ e.jsxs("div", { style: { display: "flex", flexDirection: "column", gap: 16 }, children: [
753
+ /* @__PURE__ */ e.jsx(C, { children: /* @__PURE__ */ e.jsxs(w, { wrap: !0, children: [
754
+ /* @__PURE__ */ e.jsx(we, { style: { fontSize: 18, color: "#1677ff" } }),
755
+ /* @__PURE__ */ e.jsx(ce, { strong: !0, children: "选择项目:" }),
756
+ /* @__PURE__ */ e.jsx(
757
+ M,
758
+ {
759
+ value: i,
760
+ onChange: n,
761
+ style: { width: 280 },
762
+ loading: u,
763
+ placeholder: "选择项目",
764
+ options: l.map((c) => ({ label: c.name, value: c.id }))
765
+ }
766
+ ),
767
+ /* @__PURE__ */ e.jsxs("a", { onClick: () => S(), children: [
768
+ /* @__PURE__ */ e.jsx(Pe, {}),
769
+ " 刷新项目"
770
+ ] })
771
+ ] }) }),
772
+ /* @__PURE__ */ e.jsxs(de, { spinning: y, children: [
773
+ /* @__PURE__ */ e.jsxs(se, { gutter: 16, children: [
774
+ /* @__PURE__ */ e.jsx(U, { span: 6, children: /* @__PURE__ */ e.jsx(C, { children: /* @__PURE__ */ e.jsx(G, { title: "总任务数", value: g.total }) }) }),
775
+ /* @__PURE__ */ e.jsx(U, { span: 6, children: /* @__PURE__ */ e.jsx(C, { children: /* @__PURE__ */ e.jsx(
776
+ G,
777
+ {
778
+ title: "待办",
779
+ value: g.todo,
780
+ styles: { content: { color: "#8c8c8c" } },
781
+ prefix: /* @__PURE__ */ e.jsx(me, {})
782
+ }
783
+ ) }) }),
784
+ /* @__PURE__ */ e.jsx(U, { span: 6, children: /* @__PURE__ */ e.jsx(C, { children: /* @__PURE__ */ e.jsx(
785
+ G,
786
+ {
787
+ title: "进行中",
788
+ value: g.doing,
789
+ styles: { content: { color: "#1677ff" } },
790
+ prefix: /* @__PURE__ */ e.jsx(ye, {})
791
+ }
792
+ ) }) }),
793
+ /* @__PURE__ */ e.jsx(U, { span: 6, children: /* @__PURE__ */ e.jsx(C, { children: /* @__PURE__ */ e.jsx(
794
+ G,
795
+ {
796
+ title: "已完成",
797
+ value: g.done,
798
+ styles: { content: { color: "#52c41a" } },
799
+ prefix: /* @__PURE__ */ e.jsx(Y, {})
800
+ }
801
+ ) }) })
802
+ ] }),
803
+ /* @__PURE__ */ e.jsx(C, { style: { marginTop: 16 }, title: "完成率", children: /* @__PURE__ */ e.jsx(Ie, { percent: F, status: F === 100 ? "success" : "active" }) }),
804
+ /* @__PURE__ */ e.jsx(se, { gutter: 16, style: { marginTop: 16 }, children: O.map(({ priority: c, list: p }) => /* @__PURE__ */ e.jsx(U, { span: 8, children: /* @__PURE__ */ e.jsx(C, { size: "small", title: /* @__PURE__ */ e.jsxs(w, { children: [
805
+ /* @__PURE__ */ e.jsx(v, { color: c === 3 ? "red" : c === 2 ? "orange" : "default", children: c === 3 ? "高" : c === 2 ? "中" : "低" }),
806
+ /* @__PURE__ */ e.jsxs("span", { children: [
807
+ "优先级 (",
808
+ p.length,
809
+ ")"
810
+ ] })
811
+ ] }), children: p.length === 0 ? /* @__PURE__ */ e.jsx(X, { image: X.PRESENTED_IMAGE_SIMPLE, description: "无任务" }) : /* @__PURE__ */ e.jsx(
812
+ N,
813
+ {
814
+ size: "small",
815
+ dataSource: p.slice(0, 8),
816
+ renderItem: (P) => {
817
+ const R = oe[P.status ?? 0] || oe[0];
818
+ return /* @__PURE__ */ e.jsx(N.Item, { children: /* @__PURE__ */ e.jsx(
819
+ N.Item.Meta,
820
+ {
821
+ avatar: R.icon,
822
+ title: /* @__PURE__ */ e.jsxs(w, { children: [
823
+ /* @__PURE__ */ e.jsx(ce, { children: P.title }),
824
+ /* @__PURE__ */ e.jsx(v, { color: R.color, style: { margin: 0 }, children: R.text })
825
+ ] }),
826
+ description: P.dueDate ? `截止: ${P.dueDate}` : "无截止时间"
827
+ }
828
+ ) });
829
+ }
830
+ }
831
+ ) }) }, c)) })
832
+ ] })
833
+ ] });
834
+ }
835
+ function Ze() {
836
+ return /* @__PURE__ */ e.jsxs(Ce, { children: [
837
+ /* @__PURE__ */ e.jsx(q, { index: !0, element: /* @__PURE__ */ e.jsx(Me, { to: "dashboard", replace: !0 }) }),
838
+ /* @__PURE__ */ e.jsx(q, { path: "dashboard", element: /* @__PURE__ */ e.jsx($e, {}) }),
839
+ /* @__PURE__ */ e.jsx(q, { path: "project", element: /* @__PURE__ */ e.jsx(re, {}) }),
840
+ /* @__PURE__ */ e.jsx(q, { path: "project/*", element: /* @__PURE__ */ e.jsx(re, {}) }),
841
+ /* @__PURE__ */ e.jsx(q, { path: "task", element: /* @__PURE__ */ e.jsx(ne, {}) }),
842
+ /* @__PURE__ */ e.jsx(q, { path: "task/*", element: /* @__PURE__ */ e.jsx(ne, {}) })
843
+ ] });
844
+ }
845
+ export {
846
+ re as ProjectList,
847
+ Qe as ProjectSelect,
848
+ Ze as TaskApp,
849
+ Ye as TaskCard,
850
+ $e as TaskDashboard,
851
+ ne as TaskList,
852
+ Je as TaskTable,
853
+ I as api,
854
+ I as taskApi
855
+ };