From 4c9601b94940ab3bb4e84986cf8d100f1c36c0d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=98Liammcl=E2=80=99?= Date: Sat, 28 Dec 2024 19:23:54 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=BB=E5=8A=A1=E6=A8=A1=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 1 + pnpm-lock.yaml | 3 + src/components/Layout/Header.jsx | 1 - src/components/SectionList/index.jsx | 6 +- src/components/TaskList/index.jsx | 583 ++++++++++++++++++ .../detail/components/TaskTemplate.jsx | 225 ++++++- src/pages/company/service/index.jsx | 448 +++++++++----- src/routes/routes.js | 15 +- src/utils/enum.js | 8 + 9 files changed, 1109 insertions(+), 181 deletions(-) create mode 100644 src/components/TaskList/index.jsx create mode 100644 src/utils/enum.js diff --git a/package.json b/package.json index 888669f..eb48ef7 100644 --- a/package.json +++ b/package.json @@ -19,6 +19,7 @@ "@monaco-editor/react": "^4.6.0", "@supabase/supabase-js": "^2.38.4", "antd": "^5.11.0", + "dayjs": "^1.11.13", "dnd-kit": "^0.0.2", "html2canvas": "^1.4.1", "jspdf": "^2.5.2", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 9765c6a..529d37d 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -35,6 +35,9 @@ importers: antd: specifier: ^5.11.0 version: 5.22.5(react-dom@18.3.1(react@18.3.1))(react@18.3.1) + dayjs: + specifier: ^1.11.13 + version: 1.11.13 dnd-kit: specifier: ^0.0.2 version: 0.0.2 diff --git a/src/components/Layout/Header.jsx b/src/components/Layout/Header.jsx index 00914dd..aaecc5e 100644 --- a/src/components/Layout/Header.jsx +++ b/src/components/Layout/Header.jsx @@ -18,7 +18,6 @@ const Header = ({ collapsed, setCollapsed }) => { console.error("Logout error:", error); } }; -console.log(user); const userMenuItems = [ { diff --git a/src/components/SectionList/index.jsx b/src/components/SectionList/index.jsx index 8e22b03..2629d70 100644 --- a/src/components/SectionList/index.jsx +++ b/src/components/SectionList/index.jsx @@ -572,7 +572,7 @@ const SectionList = ({ ))} -
+
{!isView && (
+
+
+ ) : ( +
+
+ + + +
+

+ 暂无可用模板 +

+

+ 您可以选择创建一个自定义模块开始使用 +

+ +
+ )} +
+ ); + + return ( + <> + + {(fields, { add, remove }) => ( + <> +
+ {fields.map((field, sectionIndex) => ( + +
+ {editingSectionIndex === sectionIndex ? ( +
+ + setEditingSectionName(e.target.value) + } + onPressEnter={handleSectionNameSave} + autoFocus + className="w-48" + /> +
+ ) : ( +
+ + + {form.getFieldValue([ + "sections", + sectionIndex, + "sectionName", + ]) || `任务类型 ${sectionIndex + 1}`} + + {!isView && ( +
+ )} +
+ {!isView && ( +
+ } + > + + {(itemFields, { add: addItem, remove: removeItem }) => ( + <> +
+
任务名称
+
描述/备注
+
开始/结束时间
+
时间范围
+
状态
+
操作
+
+ + {itemFields.map((itemField, itemIndex) => { + const { key, ...restItemField } = itemField; + return ( +
+ + + + + + +
+ { + if (!dates) return null; + return [ + dates[0].format('YYYY-MM-DD HH:mm'), + dates[1].format('YYYY-MM-DD HH:mm') + ]; + }} + getValueProps={(value) => { + if (!value) return {}; + return { + value: [ + dayjs(value[0]), + dayjs(value[1]) + ] + }; + }} + > + { + return current && current < dayjs().startOf('day'); + }} + + /> + + +
+ + + {calculateDuration( + form.getFieldValue([ + "sections", + field.name, + "items", + itemField.name, + "timeRange", + ]) + )} + + + + + + + + { + setEditingItem((prev) => ({ + ...prev || item, + name: e.target.value + })); + }} + /> + ) : ( + {text} + ); + }, + }, + { + title: "状态", + dataIndex: "unit", + key: "unit", + width: "10%", + render: (text, item, index) => { + const isEditing = editingKey === `${record.id}-${section.key}-${index}`; + return isEditing ? ( + { + setEditingItem((prev) => ({ + ...prev || item, + unit: e.target.value + })); + }} + /> + ) : ( + {text} + ); + }, + }, + { + title: "单价", + dataIndex: "price", + key: "price", + width: "10%", + render: (text, item, index) => { + const isEditing = editingKey === `${record.id}-${section.key}-${index}`; + return isEditing ? ( + { + setEditingItem((prev) => ({ + ...prev || item, + price: value + })); + }} + /> + ) : ( + {text} + ); + }, + }, + { + title: "数量", + dataIndex: "quantity", + key: "quantity", + width: "10%", + render: (text, item, index) => { + const isEditing = editingKey === `${record.id}-${section.key}-${index}`; + return isEditing ? ( + { + setEditingItem((prev) => ({ + ...prev || item, + quantity: value + })); + }} + /> + ) : ( + {text} + ); + }, + }, + { + title: "描述", + dataIndex: "description", + key: "description", + render: (text, item, index) => { + const isEditing = editingKey === `${record.id}-${section.key}-${index}`; + return isEditing ? ( + { + setEditingItem((prev) => ({ + ...prev || item, + description: e.target.value + })); + }} + /> + ) : ( + {text} + ); + }, + }, + { + title: "操作", + key: "action", + width: 150, + render: (_, item, index) => { + const isEditing = editingKey === `${record.id}-${section.key}-${index}`; + return ( + + {isEditing ? ( + <> + handleSave(record, section.key, index)} + /> + { + setEditingKey(""); + setEditingItem(null); + }} + /> + + ) : ( + <> + { + setEditingKey(`${record.id}-${section.key}-${index}`); + setEditingItem(item); // 初始化编辑项 + }} + /> + handleDeleteItem(record, section.key, index)} + > + + + + )} + + ); + }, + }, +] +case 'task': + return [ + { + title: "名称", + dataIndex: "name", + key: "name", + width: "15%", + render: (text, item, index) => { + const isEditing = editingKey === `${record.id}-${section.key}-${index}`; + return isEditing ? ( + { + setEditingItem((prev) => ({ + ...prev || item, + name: e.target.value + })); + }} + /> + ) : ( + {text} + ); + }, + }, + { + title: "执行状态", + dataIndex: "unit", + key: "unit", + render: (text, item, index) => { + const isEditing = editingKey === `${record.id}-${section.key}-${index}`; + return isEditing ? ( + { + setEditingItem((prev) => ({ + ...prev || item, + unit: e.target.value + })); + }} + /> + ) : ( + {text} + ); + }, + }, + + { + title: "开始时间", + dataIndex: "timeRange", + key: "startTime", + render: (timeRange) => timeRange?.[0] || '-', + }, + { + title: "结束时间", + dataIndex: "timeRange", + key: "endTime", + render: (timeRange) => timeRange?.[1] || '-', + }, + { + title: "描述", + dataIndex: "description", + key: "description", + render: (text, item, index) => { + const isEditing = editingKey === `${record.id}-${section.key}-${index}`; + return isEditing ? ( + { + setEditingItem((prev) => ({ + ...prev || item, + description: e.target.value + })); + }} + /> + ) : ( + {text} + ); + }, + }, + { + title: "操作", + key: "action", + render: (_, item, index) => { + const isEditing = editingKey === `${record.id}-${section.key}-${index}`; + return ( + + {isEditing ? ( + <> + handleSave(record, section.key, index)} + /> + { + setEditingKey(""); + setEditingItem(null); + }} + /> + + ) : ( + <> + {/* { + setEditingKey(`${record.id}-${section.key}-${index}`); + setEditingItem(item); // 初始化编辑项 + }} + /> */} + handleDeleteItem(record, section.key, index)} + > + + + + )} + + ); + }, + }, + ] + case "project": + default:[] + } + + + + } const expandedRowRender = (record) => { + return (
{record.attributes.sections.map((section) => ( @@ -240,164 +527,12 @@ const ServicePage = () => {
{ - const isEditing = editingKey === `${record.id}-${section.key}-${index}`; - return isEditing ? ( - { - setEditingItem((prev) => ({ - ...prev || item, - name: e.target.value - })); - }} - /> - ) : ( - {text} - ); - }, - }, - { - title: "单位", - dataIndex: "unit", - key: "unit", - width: "10%", - render: (text, item, index) => { - const isEditing = editingKey === `${record.id}-${section.key}-${index}`; - return isEditing ? ( - { - setEditingItem((prev) => ({ - ...prev || item, - unit: e.target.value - })); - }} - /> - ) : ( - {text} - ); - }, - }, - { - title: "单价", - dataIndex: "price", - key: "price", - width: "10%", - render: (text, item, index) => { - const isEditing = editingKey === `${record.id}-${section.key}-${index}`; - return isEditing ? ( - { - setEditingItem((prev) => ({ - ...prev || item, - price: value - })); - }} - /> - ) : ( - {text} - ); - }, - }, - { - title: "数量", - dataIndex: "quantity", - key: "quantity", - width: "10%", - render: (text, item, index) => { - const isEditing = editingKey === `${record.id}-${section.key}-${index}`; - return isEditing ? ( - { - setEditingItem((prev) => ({ - ...prev || item, - quantity: value - })); - }} - /> - ) : ( - {text} - ); - }, - }, - { - title: "描述", - dataIndex: "description", - key: "description", - render: (text, item, index) => { - const isEditing = editingKey === `${record.id}-${section.key}-${index}`; - return isEditing ? ( - { - setEditingItem((prev) => ({ - ...prev || item, - description: e.target.value - })); - }} - /> - ) : ( - {text} - ); - }, - }, - { - title: "操作", - key: "action", - width: 150, - render: (_, item, index) => { - const isEditing = editingKey === `${record.id}-${section.key}-${index}`; - return ( - - {isEditing ? ( - <> - handleSave(record, section.key, index)} - /> - { - setEditingKey(""); - setEditingItem(null); - }} - /> - - ) : ( - <> - { - setEditingKey(`${record.id}-${section.key}-${index}`); - setEditingItem(item); // 初始化编辑项 - }} - /> - handleDeleteItem(record, section.key, index)} - > - - - - )} - - ); - }, - }, - ]} + columns={table_warp(record,section)} /> ))} @@ -411,7 +546,7 @@ const ServicePage = () => { const path = id ? `${basePath}/${id}` : basePath; if (mode === "create") { - navigate(`${basePath}`); + navigate(`${basePath}?type=${type}`); } else { navigate(`${basePath}/${id}?type=${type}&${mode}=true`); } @@ -589,7 +724,6 @@ const ServicePage = () => { className="rounded-lg" /> - {/* 添加模板类型选择弹窗 */} setIsModalOpen(false)} diff --git a/src/routes/routes.js b/src/routes/routes.js index a0edf9c..b16b4c1 100644 --- a/src/routes/routes.js +++ b/src/routes/routes.js @@ -16,13 +16,7 @@ const resourceRoutes = [ icon: "shop", roles: ["OWNER"], }, - { - path: "task", - component: lazy(() => import("@/pages/resource/resourceTask")), - name: "任务管理", - icon: "appstore", - roles: ["OWNER"], - }, + { path: "task/edit/:id?", component: lazy(() => import("@/pages/resource/resourceTask/edit")), @@ -41,6 +35,13 @@ const companyRoutes = [ icon: "file", roles: ["ADMIN", "OWNER"], }, + { + path: "task", + component: lazy(() => import("@/pages/resource/resourceTask")), + name: "任务管理", + icon: "appstore", + roles: ["OWNER"], + }, { path: "quotaInfo/:id?", // 添加可选的 id 参数 hidden: true, diff --git a/src/utils/enum.js b/src/utils/enum.js new file mode 100644 index 0000000..e53f68d --- /dev/null +++ b/src/utils/enum.js @@ -0,0 +1,8 @@ +export const STATUS_OPTIONS = [ + { label: '未开始', value: 'not_started' }, + { label: '进行中', value: 'in_progress' }, + { label: '已完成', value: 'completed' }, + { label: '已暂停', value: 'paused' }, + { label: '延期中', value: 'paused' } + ]; + \ No newline at end of file