已选列表统计勾选数量的功能追加

main
hujunpeng 4 months ago
parent 0a3825a449
commit 008ca215f0
  1. 32
      packages/examination/src/views/examPaper/examPaperAdd.tsx

@ -366,7 +366,8 @@ class ExamPaperAdd extends Component<any, States> {
questionSelectList, questionSelectList,
selectedRowKeys, selectedRowKeys,
skipValidation, skipValidation,
questionCountSum questionCountSum,
total
} = this.state; } = this.state;
const changePage = (current: number, pageSize: number) => { const changePage = (current: number, pageSize: number) => {
@ -584,7 +585,7 @@ class ExamPaperAdd extends Component<any, States> {
<Form.Item <Form.Item
label="总分值:" label="总分值:"
name="totalScore" name="totalScore"
style={{ width: 240 }} style={{ width: 220 }}
rules={[{ required: true, message: '请输入总分值' }]} rules={[{ required: true, message: '请输入总分值' }]}
> >
<Input type="number" style={{ textAlign: 'right' }} placeholder="请输入总分值" min={1} /> <Input type="number" style={{ textAlign: 'right' }} placeholder="请输入总分值" min={1} />
@ -689,20 +690,23 @@ class ExamPaperAdd extends Component<any, States> {
</Button> </Button>
]} ]}
width={1100} width={1100}
style={{ top: 20 }} style={{top: 20}}
> >
<div> <div>
<h3 style={{ fontWeight: 'bold' }}></h3> <h3 style={{fontWeight: 'bold'}}></h3>
<div style={{textAlign: 'right'}}>
{selectedQuestionList.length}/{total}
</div>
<Table <Table
dataSource={selectedQuestionList} dataSource={selectedQuestionList}
columns={columns} columns={columns}
bordered={true} bordered={true}
scroll={{ y: 200 }} scroll={{y: 200}}
size={'small'} size={'small'}
/> />
</div> </div>
<div style={{ marginTop: '20px' }}> <div style={{marginTop: '20px'}}>
<h3 style={{ fontWeight: 'bold' }}></h3> <h3 style={{fontWeight: 'bold'}}></h3>
<Form <Form
className="filter" className="filter"
layout="inline" layout="inline"
@ -713,10 +717,10 @@ class ExamPaperAdd extends Component<any, States> {
name="serviceTypeId" name="serviceTypeId"
> >
<Select placeholder="请选择AQ服务类型" <Select placeholder="请选择AQ服务类型"
style={{ width: 240 }} style={{width: 240}}
allowClear> allowClear>
{ {
serviceTypeDict && serviceTypeDict.length > 0? serviceTypeDict && serviceTypeDict.length > 0 ?
(() => { (() => {
let rows = []; let rows = [];
for (let i = 0; i < serviceTypeDict.length; i++) { for (let i = 0; i < serviceTypeDict.length; i++) {
@ -736,7 +740,7 @@ class ExamPaperAdd extends Component<any, States> {
label="题干条件:" label="题干条件:"
name="questionContent" name="questionContent"
> >
<Input placeholder="请输入题干条件" style={{ width: 400 }}/> <Input placeholder="请输入题干条件" style={{width: 400}}/>
</Form.Item> </Form.Item>
<Form.Item> <Form.Item>
<Button type="default" onClick={this.handleReset}></Button> <Button type="default" onClick={this.handleReset}></Button>
@ -752,12 +756,12 @@ class ExamPaperAdd extends Component<any, States> {
bordered={true} bordered={true}
size={'small'} size={'small'}
rowKey="id" rowKey="id"
scroll={{ y: 200 }} scroll={{y: 200}}
loading={loading} loading={loading}
rowSelection={{ rowSelection={{
selectedRowKeys: selectedRowKeys, selectedRowKeys: selectedRowKeys,
onChange: (newSelectedRowKeys, selectedRows) => { onChange: (newSelectedRowKeys, selectedRows) => {
const { selectedQuestionList,questionSelectList } = this.state; const {selectedQuestionList, questionSelectList} = this.state;
const newSelectedQuestionList = selectedRows.reduce((acc, row) => { const newSelectedQuestionList = selectedRows.reduce((acc, row) => {
if (!acc.some(item => item.id === row.id)) { if (!acc.some(item => item.id === row.id)) {
acc.push(row); acc.push(row);
@ -766,11 +770,11 @@ class ExamPaperAdd extends Component<any, States> {
}, [...selectedQuestionList]); }, [...selectedQuestionList]);
const deselectedIds = questionSelectList const deselectedIds = questionSelectList
.filter(item =>!newSelectedRowKeys.includes(item.id)) .filter(item => !newSelectedRowKeys.includes(item.id))
.map(item => item.id); .map(item => item.id);
const finalSelectedQuestionList = newSelectedQuestionList.filter( const finalSelectedQuestionList = newSelectedQuestionList.filter(
item =>!deselectedIds.includes(item.id) item => !deselectedIds.includes(item.id)
); );
const selectedRowKeys = finalSelectedQuestionList.map(item => String(item.id)); const selectedRowKeys = finalSelectedQuestionList.map(item => String(item.id));

Loading…
Cancel
Save