From 57c5ceeb8bb4ef1f0d8cd1573929b4605d5ad91b Mon Sep 17 00:00:00 2001 From: zhengpengju Date: Mon, 7 Mar 2022 16:46:55 +0800 Subject: [PATCH] fix bug --- admin/src/pages/questionbank/index.tsx | 62 ++++++++++++++++++----- admin/src/pages/training/option/index.tsx | 3 +- 2 files changed, 51 insertions(+), 14 deletions(-) diff --git a/admin/src/pages/questionbank/index.tsx b/admin/src/pages/questionbank/index.tsx index e741483..ffa49a3 100644 --- a/admin/src/pages/questionbank/index.tsx +++ b/admin/src/pages/questionbank/index.tsx @@ -71,6 +71,7 @@ console.log('first'); * @param selectedRows */ const handleRemove = async (selectedRows: TableListItem[]) => { + console.log('selectedRows--', selectedRows) const hide = message.loading('正在删除'); if (!selectedRows) return true; @@ -118,21 +119,29 @@ const QuestionBank = () => { { title: '标签', valueType: 'select', - dataIndex: 'tags', + dataIndex: 'tag_ids', sorter: false, hideInTable: true, hideInForm: false, - hideInSearch: true, + hideInSearch: false, fieldProps: { mode: "multiple" }, + formItemProps: { + rules: [ + { + required: true, + message: '请填标签', + }, + ] + }, renderText: (val: string) => `${val}`, request: async () => { const { data: Items } = await queryTagList({}); console.log('queryTagList...') const tags = [] for (let i = 0; i < Items.length; i++) { - tags.push({ label: Items[i].tag_name, value: Items[i].tag_id }) + tags.push({ label: Items[i]?.tag_name, value: Items[i]?.tag_id }) } console.log(tags, 'tags:::'); return tags; @@ -145,7 +154,7 @@ const QuestionBank = () => { sorter: false, hideInTable: false, hideInForm: false, - hideInSearch: true, + hideInSearch: false, fieldProps: { //mode: "multiple" }, @@ -158,10 +167,10 @@ const QuestionBank = () => { ] }, renderText: (val: string) => `${val}`, - dependencies: ['tags'], + dependencies: ['tag_ids'], request: async (params) => { - const {tags} = params; - const { data: Items } = await queryCourseListByTag({tag_ids: tags?.toString()}); + const {tag_ids} = params; + const { data: Items } = await queryCourseListByTag({tag_ids: tag_ids?.toString()}); console.log('queryCourseListByTag...') const courses = [] for (let i = 0; i < Items?.length; i++) { @@ -178,7 +187,7 @@ const QuestionBank = () => { hideInTable: false, hideInDescriptions: false, hideInForm: false, - hideInSearch: true, + hideInSearch: false, formItemProps: { rules: [ { @@ -283,6 +292,19 @@ const QuestionBank = () => { /> ), }, + { + title: '创建时间', + dataIndex: 'create_time', + valueType: 'text', + sorter: false, + hideInTable: true, + hideInForm: true, + hideInSearch: false, + // renderText: (val: string) => (
), + renderFormItem: (item, { defaultRender, ...rest }, form) => ( +<> + ), + }, ] @@ -310,6 +332,7 @@ const QuestionBank = () => { return ( + rowKey='id' itemLayout="vertical" actionRef={actionRef} rowClassName='questionbank-list-item' @@ -317,6 +340,7 @@ const QuestionBank = () => { defaultPageSize: 10, showSizeChanger: false, }} + search={{}} toolBarRender={() => { const menuItems = []; console.log('toolBarRender', questionType); @@ -343,10 +367,21 @@ const QuestionBank = () => { 新建 , - /* - */, + , , @@ -656,8 +691,8 @@ const QuestionBank = () => { const answerTrueData = labels?.filter((x, idx, self)=>(`${answertrue[idx]}` === '1')) console.log('$$$', answerTrueData) const trueData = Number(currentRow?.question_type) === 1 ? answerTrueData : answerTrueData[0] // 处理单选和判断 - - return {...currentRow, answers: currentRow?.answers.map((item)=>(item.answer)), answertrue: trueData } + const tag_ids = currentRow?.tag_ids.split(',') + return {...currentRow, answers: currentRow?.answers.map((item)=>(item.answer)), answertrue: trueData, tag_ids: tag_ids.map(item=>Number(item)) } }} onFinish={async (values: any) => { // 表单处理 @@ -675,6 +710,7 @@ const QuestionBank = () => { ...values, type: type, // 必填,0-常规题,1-资质考试题 answers: JSON.stringify(opts), + tag_ids: values?.tag_ids?.toString(), // 标签ids //question_type: currentRow?.question_type, // 题型 // subject_id: params?.id || 0, }); diff --git a/admin/src/pages/training/option/index.tsx b/admin/src/pages/training/option/index.tsx index 2d38a84..b1e62c0 100644 --- a/admin/src/pages/training/option/index.tsx +++ b/admin/src/pages/training/option/index.tsx @@ -190,7 +190,7 @@ const TableList: React.FC = () => { const tree = await queryOrgTree({ org_id: Number(orgId), org_type: 2, - school_type: 1, + //school_type: 1, }) setOrgTree(tree.table_List) console.log('orgId', orgId) @@ -393,6 +393,7 @@ const TableList: React.FC = () => { >