|
@@ -4,17 +4,30 @@ import {
|
4
|
4
|
ProForm,
|
5
|
5
|
ProFormText,
|
6
|
6
|
ProFormSelect,
|
7
|
|
- ProFormList
|
|
7
|
+ ProFormList,
|
|
8
|
+ PageContainer
|
8
|
9
|
} from '@ant-design/pro-components';
|
9
|
|
-import { postTaCheckItemQu, getTaCheckItemQu } from '@/service/tdlocquestion';
|
|
10
|
+import { postTdLocQuestion, getTdLocQuestion, deleteTdLocQuestion, getTdLocQuestionById } from '@/service/tdlocquestion';
|
10
|
11
|
|
11
|
12
|
const QuItem = (props) => {
|
12
|
|
- const { qu, onEdit } = props;
|
|
13
|
+ const { qu, onEdit, onDelete } = props;
|
13
|
14
|
|
14
|
|
- const quTitle = `${qu?.sortNo}. [${qu?.quType == 'fill' ? '填空' : '选择'}] ${qu?.title}`
|
|
15
|
+ const quTitle = `${qu?.quType == 'fill' ? '填空' : '选择'} ${qu?.title}`
|
15
|
16
|
|
16
|
17
|
return (
|
17
|
|
- <Card title={quTitle} extra={<Button type='link' onClick={onEdit}>修改</Button>} style={{ marginTop: '24px' }}>
|
|
18
|
+ <Card title={quTitle}
|
|
19
|
+ extra={(
|
|
20
|
+ <>
|
|
21
|
+ <Button type='link' onClick={onEdit}>修改</Button>
|
|
22
|
+ <Popconfirm
|
|
23
|
+ title="确认进行删除操作?"
|
|
24
|
+ onConfirm={onDelete}
|
|
25
|
+ >
|
|
26
|
+ <Button type='link' danger >删除</Button>
|
|
27
|
+ </Popconfirm>
|
|
28
|
+ </>
|
|
29
|
+ )}
|
|
30
|
+ style={{ marginTop: '24px' }}>
|
18
|
31
|
<Card.Meta
|
19
|
32
|
title={
|
20
|
33
|
qu?.quType != 'fill' ?
|
|
@@ -25,7 +38,7 @@ const QuItem = (props) => {
|
25
|
38
|
const anStr = `${item.answerCode} ${item.answer}`;
|
26
|
39
|
|
27
|
40
|
return (
|
28
|
|
- <Col span={12} key={item.answerId} style={{ height: '32px', lineHeight: '32px', fontWeight: 400 }}>
|
|
41
|
+ <Col span={12} key={item.quId} style={{ height: '32px', lineHeight: '32px', fontWeight: 400 }}>
|
29
|
42
|
{anStr}
|
30
|
43
|
</Col>
|
31
|
44
|
);
|
|
@@ -52,15 +65,12 @@ export default React.forwardRef((props, ref) => {
|
52
|
65
|
const [open, setOpen] = React.useState(false);
|
53
|
66
|
const [quInfo, setQuInfo] = React.useState(false);
|
54
|
67
|
const [list, setList] = React.useState([]);
|
55
|
|
- // const [anList, setAnList] = React.useState([]);
|
|
68
|
+ // const [and, setAnd] = React.useState([]);
|
56
|
69
|
const [form] = Form.useForm();
|
57
|
70
|
|
58
|
71
|
const onFinish = async (values) => {
|
59
|
|
- const data = { ...(quInfo || {}), ...values, itemId }
|
60
|
|
- const res = await postTaCheckItemQu(data);
|
61
|
|
-
|
62
|
|
- console.log('方方data', data);
|
63
|
|
- console.log('方方res', res);
|
|
72
|
+ const data = { ...(quInfo || {}), ...values, itemId };
|
|
73
|
+ const res = await postTdLocQuestion(data).then(x => x);
|
64
|
74
|
let found = false;
|
65
|
75
|
const newList = list.map(item => {
|
66
|
76
|
if (item.quId === res.quId) {
|
|
@@ -86,15 +96,33 @@ export default React.forwardRef((props, ref) => {
|
86
|
96
|
setOpen(true);
|
87
|
97
|
}
|
88
|
98
|
|
|
99
|
+ const onDeleteQu = (qu) => {
|
|
100
|
+ if (qu?.quId) {
|
|
101
|
+ deleteTdLocQuestion(qu.quId).then(() => {
|
|
102
|
+ setList(list.filter(x => x.quId !== qu.quId));
|
|
103
|
+ })
|
|
104
|
+ } else {
|
|
105
|
+ setList(list.filter(x => x.quId !== qu.quId));
|
|
106
|
+ }
|
|
107
|
+ }
|
|
108
|
+
|
89
|
109
|
React.useEffect(() => {
|
90
|
110
|
if (quInfo) {
|
91
|
111
|
form.setFieldsValue(quInfo);
|
92
|
112
|
}
|
93
|
113
|
}, [quInfo]);
|
94
|
114
|
|
|
115
|
+ // React.useEffect(() => {
|
|
116
|
+ // if (itemId) {
|
|
117
|
+ // getTdLocQuestion({ pageSize: 500, itemId }).then((res) => {
|
|
118
|
+ // setList(res.records);
|
|
119
|
+ // });
|
|
120
|
+ // }
|
|
121
|
+ // }, [itemId]);
|
|
122
|
+
|
95
|
123
|
React.useEffect(() => {
|
96
|
124
|
if (itemId) {
|
97
|
|
- getTaCheckItemQu({ pageSize: 500, itemId }).then((res) => {
|
|
125
|
+ getTdLocQuestionById({ pageSize: 500, itemId }).then((res) => {
|
98
|
126
|
setList(res.records);
|
99
|
127
|
});
|
100
|
128
|
}
|
|
@@ -106,62 +134,69 @@ export default React.forwardRef((props, ref) => {
|
106
|
134
|
|
107
|
135
|
return (
|
108
|
136
|
<div>
|
109
|
|
- <ProForm title="问题维护" style={{ width: '800px' }} form={form} onFinish={onFinish}>
|
110
|
|
- <ProFormText
|
111
|
|
- name="title"
|
112
|
|
- label="问题描述"
|
113
|
|
- placeholder="请填写"
|
114
|
|
- rules={[
|
115
|
|
- {
|
116
|
|
- required: true,
|
117
|
|
- message: '请填写题干',
|
118
|
|
- },
|
119
|
|
- ]}
|
120
|
|
- />
|
121
|
|
- <ProFormSelect
|
122
|
|
- name="quType"
|
123
|
|
- label="问题类型"
|
124
|
|
- fieldProps={{
|
125
|
|
- style: { width: '100%' }
|
126
|
|
- }}
|
127
|
|
- valueEnum={{
|
128
|
|
- radio: '单选',
|
129
|
|
- fill: '填空'
|
130
|
|
- }}
|
131
|
|
- rules={[
|
132
|
|
- {
|
133
|
|
- required: true,
|
134
|
|
- message: '请选择问题类型',
|
135
|
|
- },
|
136
|
|
- ]}
|
137
|
|
- />
|
138
|
|
- <ProFormList
|
139
|
|
- label="选项列表"
|
140
|
|
- copyIconProps={false}
|
141
|
|
- >
|
142
|
|
- <Row gutter={24} style={{ width: '730px' }}>
|
143
|
|
- <Col span={6}>
|
144
|
|
- <ProFormText
|
145
|
|
- name="answerCode"
|
146
|
|
- label="选项"
|
147
|
|
- help="类似 A, B, C, D"
|
148
|
|
- />
|
149
|
|
- </Col>
|
150
|
|
- <Col span={6}>
|
151
|
|
- <ProFormText
|
152
|
|
- name="answer"
|
153
|
|
- label="答案"
|
154
|
|
- placeholder="具体选项内容"
|
155
|
|
- />
|
156
|
|
- </Col>
|
157
|
|
- </Row>
|
158
|
|
- </ProFormList>
|
159
|
|
- </ProForm>
|
|
137
|
+ <Card>
|
|
138
|
+ <ProForm style={{ width: '800px' }} form={form} onFinish={onFinish} itemId={itemId} quInfo={quInfo} open={open}>
|
|
139
|
+ <ProFormText
|
|
140
|
+ name="title"
|
|
141
|
+ label="问题描述"
|
|
142
|
+ placeholder="请填写"
|
|
143
|
+ rules={[
|
|
144
|
+ {
|
|
145
|
+ required: true,
|
|
146
|
+ message: '请填写题干',
|
|
147
|
+ },
|
|
148
|
+ ]}
|
|
149
|
+ />
|
|
150
|
+ <ProFormSelect
|
|
151
|
+ name="quType"
|
|
152
|
+ label="问题类型"
|
|
153
|
+ fieldProps={{
|
|
154
|
+ style: { width: '100%' }
|
|
155
|
+ }}
|
|
156
|
+ valueEnum={{
|
|
157
|
+ radio: '单选',
|
|
158
|
+ fill: '填空'
|
|
159
|
+ }}
|
|
160
|
+ rules={[
|
|
161
|
+ {
|
|
162
|
+ required: true,
|
|
163
|
+ message: '请选择问题类型',
|
|
164
|
+ },
|
|
165
|
+ ]}
|
|
166
|
+ />
|
|
167
|
+ <ProFormList
|
|
168
|
+ label="选项列表"
|
|
169
|
+ copyIconProps={false}
|
|
170
|
+ name="quAnswerList"
|
|
171
|
+ >
|
|
172
|
+ <Row gutter={24} style={{ width: '730px' }}>
|
|
173
|
+ <Col span={6}>
|
|
174
|
+ <ProFormText
|
|
175
|
+ name="answerCode"
|
|
176
|
+ label="答案选项"
|
|
177
|
+ help="类似 A, B, C, D"
|
|
178
|
+ />
|
|
179
|
+ </Col>
|
|
180
|
+ <Col span={6}>
|
|
181
|
+ <ProFormText
|
|
182
|
+ name="answer"
|
|
183
|
+ label="答案"
|
|
184
|
+ placeholder="具体选项内容"
|
|
185
|
+ />
|
|
186
|
+ </Col>
|
|
187
|
+ </Row>
|
|
188
|
+ </ProFormList>
|
|
189
|
+ </ProForm>
|
|
190
|
+
|
|
191
|
+ </Card>
|
160
|
192
|
<List
|
161
|
193
|
itemLayout="horizontal"
|
|
194
|
+ itemId={itemId}
|
|
195
|
+ quInfo={quInfo}
|
162
|
196
|
dataSource={list}
|
163
|
|
- renderItem={(item) => <QuItem qu={item} onEdit={() => onEditQu(item)} />}
|
|
197
|
+ renderItem={(item) => <QuItem qu={item} onEdit={() => onEditQu(item)} onDelete={() => onDeleteQu(item)} />}
|
164
|
198
|
/>
|
|
199
|
+
|
165
|
200
|
</div>
|
166
|
201
|
)
|
167
|
202
|
});
|