From 781f1dcace5804d850fd63fe091978a3b2fbff4e Mon Sep 17 00:00:00 2001
From: xialiang <1818147@qq.com>
Date: Wed, 16 Feb 2022 16:57:10 +0800
Subject: [PATCH 1/2] =?UTF-8?q?=E5=9F=B9=E8=AE=AD=E7=AE=A1=E7=90=86?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
admin/src/pages/training/option/index.tsx | 152 +++++++++++++++++----
admin/src/pages/training/option/service.ts | 15 ++
2 files changed, 141 insertions(+), 26 deletions(-)
diff --git a/admin/src/pages/training/option/index.tsx b/admin/src/pages/training/option/index.tsx
index 78549f8..c826f68 100644
--- a/admin/src/pages/training/option/index.tsx
+++ b/admin/src/pages/training/option/index.tsx
@@ -9,7 +9,7 @@ import type { ProDescriptionsItemProps } from '@ant-design/pro-descriptions';
import ProDescriptions from '@ant-design/pro-descriptions';
import type { FormValueType } from './components/UpdateForm';
import UpdateForm from './components/UpdateForm';
-import { queryTrainList, saveTrain, removeTrain, queryOrgTree, queryValueByKey, querySubjectList } from './service';
+import { queryTrainList, saveTrain, removeTrain, queryOrgTree, queryValueByKey, querySubjectList, querySubjectView } from './service';
import type { TableListItem, TableListPagination } from './data';
import { useRequest } from 'umi';
@@ -139,6 +139,7 @@ const TableList: React.FC = () => {
title: '序号',
key: 'index',
valueType: 'indexBorder',
+
render: (text: React.ReactNode, _: any, index: number) => {
if (actionRef && actionRef?.current && actionRef?.current?.pageInfo) {
return `${(actionRef?.current?.pageInfo?.current - 1) * (actionRef.current.pageInfo?.pageSize) + (index + 1)}`;
@@ -148,14 +149,17 @@ const TableList: React.FC = () => {
},
width: 48,
},
+
{
title: '培训名称',
dataIndex: 'train_name',
valueType: 'text',
+ hideInSearch: true,
},
{
title: '培训对象',
valueType: 'select',
+ hideInSearch: true,
fieldProps: {
mode: "multiple"
},
@@ -203,22 +207,25 @@ const TableList: React.FC = () => {
dataIndex: 'start_time',
sorter: false,
hideInForm: true,
+ hideInSearch: true,
renderText: (val: string) => `${val}`,
},
{
title: '结束时间',
dataIndex: 'end_time',
sorter: false,
+ hideInSearch: true,
hideInForm: true,
renderText: (val: string) => `${val}`,
},
{
title: '培训时间',
valueType: 'dateTimeRange',
- dataIndex: 'datetime',
+ dataIndex: 'date_time',
sorter: false,
hideInForm: false,
hideInTable: true,
+ hideInSearch: false,
renderText: (val: string) => `${val}`,
},
{
@@ -227,6 +234,7 @@ const TableList: React.FC = () => {
dataIndex: 'total_course_hours',
valueType: 'text',
hideInForm: true,
+ hideInSearch: true,
renderText: (val: string) => `${val}小时`,
},
{
@@ -234,28 +242,27 @@ const TableList: React.FC = () => {
dataIndex: 'option',
valueType: 'option',
render: (_, record) => [
- {
- handleUpdateModalVisible(true);
- setCurrentRow(record);
- }}
- >
- 查看
- ,
+
{
handleUpdateModalVisible(true);
- const idsArr = record?.org_ids?.split(",")
- const orgName = record?.org_names?.split(",")
- const idsData = []
- idsArr.map((e,i) => {
- idsData.push({
- label: orgName[i], value: Number(e)
- })
- })
- record.org_names = idsData
+ // const _record = JSON.parse(JSON.stringify(record))
+ // const idsArr = _record?.org_ids?.split(",")
+ // const orgName = _record.org_names != "" ? _record.org_names.split(",") : ""
+ // const idsData = []
+ // if (_record?.org_ids != false) {
+ // idsArr.map((e, i) => {
+ // idsData.push({
+ // label: orgName[i], value: Number(e)
+ // })
+ // })
+
+ // }
+ // _record.org_names = idsData
+ // _record.date_time = [_record.start_time, _record.end_time]
+ // console.log("2323", _record);
+
setCurrentRow(record);
}}
>
@@ -303,7 +310,16 @@ const TableList: React.FC = () => {
,
]}
request={async (value) => {
+ if (value.date_time) {
+ value.begin_time = value.date_time[0]
+ value.end_time = value.date_time[1]
+ }
+ // delete value.date_time
+ console.log('search', value);
+
const _data = await queryTrainList(value);
+
+
return {
current: _data?.page_number,
data: _data?.data?.list,
@@ -387,11 +403,11 @@ const TableList: React.FC = () => {
console.log(tree, 'tree');
const _data = {
...values,
- end_time: values.datetime[1],
- start_time: values.datetime[0],
+ end_time: values.date_time[1],
+ start_time: values.date_time[0],
target_list_json: JSON.stringify(tree)
}
- delete _data.datetime
+ delete _data.date_time
delete _data.org_names
// delete params.course_time
// delete params.examination_time
@@ -436,8 +452,92 @@ const TableList: React.FC = () => {
layoutType="Form"
labelCol={{ span: 8 }}
wrapperCol={{ span: 12 }}
- onFinish={async (values) => {
- console.log(values);
+ request={async () => {
+
+ const { data } = await querySubjectView({ train_id: currentRow?.train_id });
+
+
+ data.date_time = [currentRow.start_time, currentRow.end_time]
+ data.org_names = []
+ data.target_list.map((e) => {
+ console.log('1111', e);
+
+ data.org_names.push({
+ value: e.org_id,
+ label: e.org_name
+ })
+ console.log("222", data);
+
+ })
+ console.log("edit", data);
+
+ return data
+ }}
+
+ onFinish={async (values: any) => {
+ // 表单处理
+ //console.log('columns:', columns);
+ console.log('values1:', values, orgTree);
+ //return false;
+ // values.attachment_json.response.file.response.url
+
+ let tree = []
+ if (typeof values.org_names[0] === 'number') {
+ // tree = values.org_names
+ console.log('true values.org_names', tree, orgTree, values)
+ tree = orgTree?.filter((item, idx, self) => {
+ return (values?.org_names?.indexOf(item?.id) !== -1)
+ });
+ console.log("tree,1111", tree);
+
+ tree.map((e, i) => {
+ tree[i].org_id = e.id
+ tree[i].org_name = e.name
+ delete tree[i].id
+ delete tree[i].name
+ delete tree[i].pId
+ })
+ } else {
+ values.org_names.map((e) => {
+ console.log(e, 'e');
+
+ })
+
+ // tree[i].org_id = e.id
+ // tree[i].org_name = e.name
+ console.log(values.org_names, 'false values.org_names')
+ }
+
+
+
+
+ console.log(321);
+ console.log(tree, 'tree');
+
+
+
+ const _data = {
+ ...values,
+
+ end_time: values.date_time[1],
+ start_time: values.date_time[0],
+ target_list_json: JSON.stringify(tree),
+ train_id: currentRow.train_id
+ }
+ delete _data.date_time
+ delete _data.org_names
+ // delete params.course_time
+ // delete params.examination_time
+
+ console.log('_data', _data);
+
+ const res = await saveTrain(_data);
+ // console.log(res, 'ressss');
+ if (res.code === 2000) {
+ handleUpdateModalVisible(false);
+ actionRef.current?.reloadAndRest?.();
+ }
+
}}
submitter={{
render: (props, doms) => (
@@ -450,7 +550,7 @@ const TableList: React.FC = () => {
}}
// action = ''
title="编辑"
- columns={getInitialValues(columns, currentRow)}
+ columns={columns}
/>
)}
diff --git a/admin/src/pages/training/option/service.ts b/admin/src/pages/training/option/service.ts
index 8fa2544..7ccf12c 100644
--- a/admin/src/pages/training/option/service.ts
+++ b/admin/src/pages/training/option/service.ts
@@ -92,3 +92,18 @@ export async function querySubjectList(params: {
});
}
+/**
+ * 获取主题列表
+ * http://10.10.14.252:8080/workspace/myWorkspace.do?projectId=382#6426
+ * @param params
+ * @returns
+ */
+export async function querySubjectView(params: {
+ page_size: number;
+ //count: number;
+}): Promise<{ data: { list: CardListItemDataType[] } }> {
+ return request('/dsideal_yy/ypt/careerTraining/train/view', {
+ params,
+ });
+}
+
From d8493132db77994fe0fbb37dc18bc129f6618fc1 Mon Sep 17 00:00:00 2001
From: xialiang <1818147@qq.com>
Date: Wed, 16 Feb 2022 17:08:23 +0800
Subject: [PATCH 2/2] =?UTF-8?q?=E5=9F=B9=E8=AE=AD=E7=AE=A1=E7=90=86-?=
=?UTF-8?q?=E6=A0=A1=E9=AA=8C=E3=80=81=E9=94=99=E8=AF=AF=E6=8F=90=E9=86=92?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
admin/src/pages/training/option/index.tsx | 36 +++++++++++++++++++++++
1 file changed, 36 insertions(+)
diff --git a/admin/src/pages/training/option/index.tsx b/admin/src/pages/training/option/index.tsx
index c826f68..f38c5fe 100644
--- a/admin/src/pages/training/option/index.tsx
+++ b/admin/src/pages/training/option/index.tsx
@@ -155,6 +155,14 @@ const TableList: React.FC = () => {
dataIndex: 'train_name',
valueType: 'text',
hideInSearch: true,
+ formItemProps: {
+ rules: [
+ {
+ required: true,
+ message: '请输入培训名称',
+ },
+ ]
+ },
},
{
title: '培训对象',
@@ -163,6 +171,14 @@ const TableList: React.FC = () => {
fieldProps: {
mode: "multiple"
},
+ formItemProps: {
+ rules: [
+ {
+ required: true,
+ message: '请选择培训对象',
+ },
+ ]
+ },
dataIndex: 'org_names',
request: async () => {
const Value = await queryValueByKey({});
@@ -188,6 +204,14 @@ const TableList: React.FC = () => {
hideInTable: true,
hideInForm: false,
hideInSearch: false,
+ formItemProps: {
+ rules: [
+ {
+ required: true,
+ message: '请选择主题',
+ },
+ ]
+ },
request: async () => {
const { data: Items } = await querySubjectList({ page_size: 1000 });
// console.log(Items, ')))');
@@ -227,6 +251,14 @@ const TableList: React.FC = () => {
hideInTable: true,
hideInSearch: false,
renderText: (val: string) => `${val}`,
+ formItemProps: {
+ rules: [
+ {
+ required: true,
+ message: '请选择培训时间',
+ },
+ ]
+ },
},
{
title: '学时安排',
@@ -419,6 +451,8 @@ const TableList: React.FC = () => {
if (res.code === 2000) {
handleModalVisible(false);
actionRef.current?.reloadAndRest?.();
+ } else {
+ message.error(res.msg);
}
}}
@@ -536,6 +570,8 @@ const TableList: React.FC = () => {
if (res.code === 2000) {
handleUpdateModalVisible(false);
actionRef.current?.reloadAndRest?.();
+ } else {
+ message.error(res.msg);
}
}}