master
zhengpengju 3 years ago
parent 0c36bf854b
commit 57c5ceeb8b

@ -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) => (<div dangerouslySetInnerHTML={{__html: val}} />),
renderFormItem: (item, { defaultRender, ...rest }, form) => (
<></>
),
},
]
@ -310,6 +332,7 @@ const QuestionBank = () => {
return (
<PageContainer content={false} extraContent={false} className={styles.questionbank}>
<ProList<any>
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 = () => {
<PlusOutlined /> <DownOutlined />
</Button>
</Dropdown>,
/*
<Button key="remove" type="default" danger>
<Button key="remove" type="default" danger onClick={async (value)=>{
console.log('del selectedRowsState', selectedRowsState)
const selectedRows = selectedRowsState?.map((item)=>({key:item?.id}))
console.log('selectedRows', selectedRows)
const success = await handleRemove(selectedRows);
if (success) {
// handleModalVisible(false);
if (actionRef.current) {
setSelectedRows([]);
actionRef.current?.reload();
}
}
}}>
<DeleteOutlined />
</Button>*/,
</Button>,
<Button key="download" onClick={()=>{window.location.href='/dsideal_yy/zygh/training/exportQuestionTemplate'}} >
<DownloadOutlined />
</Button>,
@ -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,
});

@ -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 = () => {
>
<Button
onClick={async () => {
await handleRemove(selectedRowsState);
setSelectedRows([]);
actionRef.current?.reloadAndRest?.();

Loading…
Cancel
Save