Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
提交反馈
为 GitLab 提交贡献
登录
切换导航
P
pica-professional-exam
项目
项目
详情
动态
版本
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
收起侧边栏
Close sidebar
动态
分支图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Culm
pica-professional-exam
提交
b1bb00c8
提交
b1bb00c8
编写于
9月 27, 2020
作者:
guangjun.yang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
对两个数组中的元素进行排序
上级
0e4967b2
变更
8
展开全部
隐藏空白字符变更
内嵌
并排
正在显示
8 个修改的文件
包含
229 行增加
和
97 行删除
+229
-97
question-content.vue
src/components/question/question-content.vue
+39
-12
question-footer.vue
src/components/question/question-footer.vue
+1
-1
question copy.js
src/store/modules/question copy.js
+1
-1
question.js
src/store/modules/question.js
+9
-9
fetch.js
src/utils/fetch.js
+2
-2
index.js
src/utils/index.js
+26
-0
mixins.js
src/utils/mixins.js
+4
-2
question-detail.vue
src/views/question-detail.vue
+147
-70
未找到文件。
src/components/question/question-content.vue
浏览文件 @
b1bb00c8
...
@@ -25,7 +25,7 @@
...
@@ -25,7 +25,7 @@
</article>
</article>
<article
class=
"title-wrapper"
>
<article
class=
"title-wrapper"
>
<span
class=
"type"
:class=
"
{'multi': currentQuestion.typeId == 2}">
<span
class=
"type"
:class=
"
{'multi': currentQuestion.typeId == 2}">
<span>
{{
currentQuestion
.
typeId
==
1
?
"单选题"
:
"多选题"
}}
</span>
<span>
{{
currentQuestion
.
typeId
!=
2
?
"单选题"
:
"多选题"
}}
</span>
</span>
</span>
<span
class=
"content"
v-html=
"currentQuestion.question"
></span>
<span
class=
"content"
v-html=
"currentQuestion.question"
></span>
<!--
<img
src=
"https://files.yunqueyi.com/image/png/protal/project/20200702161856970.png"
/>
-->
<!--
<img
src=
"https://files.yunqueyi.com/image/png/protal/project/20200702161856970.png"
/>
-->
...
@@ -92,6 +92,8 @@ export default {
...
@@ -92,6 +92,8 @@ export default {
...
mapGetters
([
...
mapGetters
([
"questionList"
,
"questionList"
,
"currentQuestion"
,
"currentQuestion"
,
"commonConfig"
,
"titleConfig"
])
])
},
},
data
()
{
data
()
{
...
@@ -124,7 +126,7 @@ export default {
...
@@ -124,7 +126,7 @@ export default {
myAnswer
=
myAnswer
.
split
(
''
).
join
(
','
);
myAnswer
=
myAnswer
.
split
(
''
).
join
(
','
);
this
.
currentQuestion
.
myAnswer
=
myAnswer
;
this
.
currentQuestion
.
myAnswer
=
myAnswer
;
}
else
{
}
else
{
// 单选题直接设置commitFlag
// 单选题
或者判断题
直接设置commitFlag
if
(
this
.
currentQuestion
.
options
[
index
].
isCorrect
)
{
if
(
this
.
currentQuestion
.
options
[
index
].
isCorrect
)
{
this
.
currentQuestion
.
commitFlag
=
1
;
this
.
currentQuestion
.
commitFlag
=
1
;
}
else
{
}
else
{
...
@@ -136,18 +138,43 @@ export default {
...
@@ -136,18 +138,43 @@ export default {
this
.
$forceUpdate
();
this
.
$forceUpdate
();
console
.
log
(
"in commit"
,
this
.
currentQuestion
.
myAnswer
);
console
.
log
(
"in commit"
,
this
.
currentQuestion
.
myAnswer
);
},
},
commitAnswer
()
{
// 提交答案
commitAnswer
(
isMulti
)
{
let
params
=
{
let
params
=
{
commitKind
:
1
,
// 答题来源 1:错题集 2:收藏 3:题库
commitKind
:
this
.
commonConfig
.
commitKind
,
// 答题来源 1:错题集 2:收藏 3:题库
directoryId
:
0
,
// 题库ID
directoryId
:
this
.
currentQuestion
.
directoryId
,
// 题库ID
myAnswer
:
this
.
currentQuestion
.
myAnswer
,
// 我的答案,单选时单个答案,如A;多选答案,按照顺序使用
myAnswer
:
this
.
currentQuestion
.
myAnswer
,
// 我的答案,单选时单个答案,如A;多选答案,按照顺序使用
paperId
:
1
,
// 试卷ID
paperId
:
this
.
currentQuestion
.
paperId
,
// 试卷ID
paperIndex
:
1
,
// 试卷索引(随机试卷的第n套)
paperIndex
:
this
.
currentQuestion
.
paperIndex
,
// 试卷索引(随机试卷的第n套)
resultId
:
1
,
// 刷题库轮次ID,刷收藏和错题集时为0
resultId
:
this
.
titleConfig
.
resultId
,
// 刷题库轮次ID,刷收藏和错题集时为0
rightFlag
:
1
,
// 答题对错:1对 2错
// rightFlag: 1, // 答题对错:1对 2错
titleId
:
1
,
// 题目ID
titleId
:
this
.
currentQuestion
.
titleId
,
// 题目ID
titleNo
:
this
.
currentQuestion
.
titleNo
,
// 题目ID
};
};
this
.
currentQuestion
.
commitFlag
=
1
;
// 计算是否答对了题目(只有多选题,才做相应处理)
if
(
isMulti
)
{
let
cList
=
this
.
currentQuestion
,
option
=
{},
isRight
=
true
;
for
(
let
i
=
0
;
i
<
cList
.
length
;
i
++
)
{
option
=
cList
[
i
];
if
(
option
.
isCorrect
&&
!
option
.
isSelected
)
{
isRight
=
false
;
return
;
}
}
if
(
isRight
)
{
this
.
currentQuestion
.
commitFlag
=
1
;
}
else
{
this
.
currentQuestion
.
commitFlag
=
2
;
}
}
this
.
POST
(
`onlineexam/practise/commit`
,
params
).
then
(({
data
})
=>
{
// this.currentTitleNo = data.currentTitleNo;
// this.handlerQuestionList(data);
// this.handlerPractiseData(data.practiseTitleModelList);
console
.
log
(
"onlineexam/practise/commit"
,
data
);
});
}
}
}
}
};
};
...
...
src/components/question/question-footer.vue
浏览文件 @
b1bb00c8
...
@@ -112,7 +112,7 @@ export default {
...
@@ -112,7 +112,7 @@ export default {
operateType
:
favorFlag
==
1
?
2
:
1
,
// 操作类型:1:收藏 2:取消收藏
operateType
:
favorFlag
==
1
?
2
:
1
,
// 操作类型:1:收藏 2:取消收藏
paperId
:
currentQuestion
.
paperId
,
paperId
:
currentQuestion
.
paperId
,
paperIndex
:
currentQuestion
.
paperIndex
,
paperIndex
:
currentQuestion
.
paperIndex
,
token
:
this
.
userInfo
.
userToken
||
this
.
token
||
'9
98E10CD98ED4BCF91A28223270FE8CE
'
,
token
:
this
.
userInfo
.
userToken
||
this
.
token
||
'9
3521BDB92774134B2CC18633F2B6D3A
'
,
setEntry
:
true
setEntry
:
true
// userId: 0
// userId: 0
};
};
...
...
src/store/modules/question copy.js
浏览文件 @
b1bb00c8
...
@@ -97,7 +97,7 @@ const question = {
...
@@ -97,7 +97,7 @@ const question = {
// async getQuestionList({ commit, state }, params) {
// async getQuestionList({ commit, state }, params) {
// // let param = {
// // let param = {
// // ...params,
// // ...params,
// // token: '9
98E10CD98ED4BCF91A28223270FE8CE
',
// // token: '9
3521BDB92774134B2CC18633F2B6D3A
',
// // setEntry: true
// // setEntry: true
// // };
// // };
// // this.GET(`portal/titleTest/practise/titles`, param).then(({ data }) => {
// // this.GET(`portal/titleTest/practise/titles`, param).then(({ data }) => {
...
...
src/store/modules/question.js
浏览文件 @
b1bb00c8
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
// import { getBaseUrl } from '@/utils/index'
// import { getBaseUrl } from '@/utils/index'
// import { setCookie, getCookie, delCookie } from '@/utils/index';
// import { setCookie, getCookie, delCookie } from '@/utils/index';
// import { envConfig } from '@/utils/env-config';
// import { envConfig } from '@/utils/env-config';
import
{
findQuestionIndexNo
,
getOrderText
}
from
"@/utils"
;
import
{
findQuestionIndexNo
,
getOrderText
,
concatArray
}
from
"@/utils"
;
const
question
=
{
const
question
=
{
state
:
{
state
:
{
...
@@ -59,11 +59,11 @@ const question = {
...
@@ -59,11 +59,11 @@ const question = {
secondSubjectId
:
0
,
secondSubjectId
:
0
,
cardType
:
3
,
cardType
:
3
,
goodsType
:
3
,
goodsType
:
3
,
commitKind
:
1
,
// 答题来源 1:错题集 2:收藏 3:题库
commitKind
:
3
,
// 答题来源 1:错题集 2:收藏 3:题库
},
},
titleConfig
:
{
titleConfig
:
{
bindStatus
:
0
,
// 绑卡状态:0未绑卡 1已绑卡
bindStatus
:
0
,
// 绑卡状态:0未绑卡 1已绑卡
commitKind
:
1
,
// 答题来源 1:错题集 2:收藏 3:题库
commitKind
:
3
,
// 答题来源 1:错题集 2:收藏 3:题库
currentTitleNo
:
0
,
// 定位答题题目id
currentTitleNo
:
0
,
// 定位答题题目id
resultId
:
0
,
// 刷题库轮次ID
resultId
:
0
,
// 刷题库轮次ID
totalCount
:
0
,
// 题目总数
totalCount
:
0
,
// 题目总数
...
@@ -97,7 +97,7 @@ const question = {
...
@@ -97,7 +97,7 @@ const question = {
// 处理返回的数据
// 处理返回的数据
handlerQuestionList
({
commit
,
state
},
rezultData
)
{
handlerQuestionList
({
commit
,
state
},
rezultData
)
{
// debugger
// debugger
let
questionList
=
rezultData
.
practiseTitleModelList
;
let
questionList
=
rezultData
.
practiseTitleModelList
||
[]
;
let
handlerList
=
[],
question
,
option
,
optionList
=
[],
myAnswer
=
""
,
answer
=
""
;
let
handlerList
=
[],
question
,
option
,
optionList
=
[],
myAnswer
=
""
,
answer
=
""
;
questionList
.
forEach
(
(
item
,
index
)
=>
{
questionList
.
forEach
(
(
item
,
index
)
=>
{
...
@@ -123,16 +123,16 @@ const question = {
...
@@ -123,16 +123,16 @@ const question = {
});
});
console
.
log
(
'in handlerList'
,
handlerList
);
console
.
log
(
'in handlerList'
,
handlerList
);
let
cIndex
=
findQuestionIndexNo
(
handlerList
,
'titleNo'
,
rezultData
.
currentTitleNo
||
1
);
let
cIndex
=
findQuestionIndexNo
(
handlerList
,
'titleNo'
,
rezultData
.
currentTitleNo
||
1
);
commit
(
"SET_CURRENT_QUESTION"
,
handlerList
[
cIndex
]);
let
newList
=
concatArray
(
state
.
questionList
,
handlerList
,
'titleNo'
);
commit
(
"SET_QUESTION_LIST"
,
handlerList
);
let
titleConfig
=
{
let
titleConfig
=
{
bindStatus
:
rezultData
.
bindStatus
,
// 绑卡状态:0未绑卡 1已绑卡
bindStatus
:
rezultData
.
bindStatus
,
// 绑卡状态:0未绑卡 1已绑卡
commitKind
:
rezultData
.
commitKind
,
// 答题来源 1:错题集 2:收藏 3:题库
commitKind
:
rezultData
.
commitKind
,
// 答题来源 1:错题集 2:收藏 3:题库
currentTitleNo
:
rezultData
.
currentTitleNo
,
// 定位答题题目id
currentTitleNo
:
rezultData
.
currentTitleNo
,
// 定位答题题目id
resultId
:
rezultData
.
resultId
,
// 刷题库轮次ID
resultId
:
rezultData
.
resultId
,
// 刷题库轮次ID
totalCount
:
rezultData
.
totalCount
,
// 题目总数
totalCount
:
rezultData
.
totalCount
,
// 题目总数
}
}
commit
(
"SET_CURRENT_QUESTION"
,
newList
[
cIndex
]
||
{
titleNo
:
1
});
commit
(
"SET_QUESTION_LIST"
,
newList
);
commit
(
"SET_TITLE_CONIFG"
,
titleConfig
);
commit
(
"SET_TITLE_CONIFG"
,
titleConfig
);
},
},
...
...
src/utils/fetch.js
浏览文件 @
b1bb00c8
...
@@ -14,9 +14,9 @@ service.interceptors.request.use(config => {
...
@@ -14,9 +14,9 @@ service.interceptors.request.use(config => {
if
(
config
.
data
&&
config
.
data
.
setEntry
)
{
if
(
config
.
data
&&
config
.
data
.
setEntry
)
{
config
.
headers
[
'sysCode'
]
=
config
.
data
.
sysCode
||
10
config
.
headers
[
'sysCode'
]
=
config
.
data
.
sysCode
||
10
if
(
config
.
data
.
token
)
{
if
(
config
.
data
.
token
)
{
config
.
headers
[
'token'
]
=
config
.
data
.
token
||
'9
98E10CD98ED4BCF91A28223270FE8CE
'
config
.
headers
[
'token'
]
=
config
.
data
.
token
||
'9
3521BDB92774134B2CC18633F2B6D3A
'
if
(
process
.
env
.
BUILD_ENV
==
"development"
)
{
// 本地开发环境
if
(
process
.
env
.
BUILD_ENV
==
"development"
)
{
// 本地开发环境
config
.
headers
[
'token'
]
=
config
.
data
.
token
||
'9
98E10CD98ED4BCF91A28223270FE8CE
'
;
config
.
headers
[
'token'
]
=
config
.
data
.
token
||
'9
3521BDB92774134B2CC18633F2B6D3A
'
;
}
}
}
}
delete
config
.
data
.
setEntry
;
delete
config
.
data
.
setEntry
;
...
...
src/utils/index.js
浏览文件 @
b1bb00c8
...
@@ -301,6 +301,7 @@ export function getOrderText(index) {
...
@@ -301,6 +301,7 @@ export function getOrderText(index) {
return
orderVac
[
index
];
return
orderVac
[
index
];
}
}
// 从数组中查找某个key对应值所在的位置(序号:0开始的)
export
function
findQuestionIndexNo
(
oList
,
key
,
keyValue
)
{
export
function
findQuestionIndexNo
(
oList
,
key
,
keyValue
)
{
let
index
=
oList
.
findIndex
(
item
=>
{
let
index
=
oList
.
findIndex
(
item
=>
{
return
item
[
key
]
==
keyValue
;
return
item
[
key
]
==
keyValue
;
...
@@ -308,3 +309,28 @@ export function findQuestionIndexNo(oList, key, keyValue) {
...
@@ -308,3 +309,28 @@ export function findQuestionIndexNo(oList, key, keyValue) {
return
index
;
return
index
;
}
}
// 对两个数组中的元素进行排序
export
function
concatArray
(
firstArr
=
[],
secondArr
=
[],
key
)
{
if
(
firstArr
.
length
==
0
)
return
secondArr
;
if
(
secondArr
.
length
==
0
)
return
[];
let
all
=
[],
newArr
=
[],
deleteIndex
;
if
(
firstArr
[
0
][
key
]
==
secondArr
[
0
][
key
])
{
return
firstArr
;
}
else
if
(
firstArr
[
0
][
key
]
<
secondArr
[
0
][
key
])
{
all
=
firstArr
.
concat
(
secondArr
);
}
else
{
all
=
secondArr
.
concat
(
firstArr
);
}
// 从all中去重
for
(
let
i
=
0
;
i
<
all
.
length
;
i
++
)
{
deleteIndex
=
findQuestionIndexNo
(
all
.
slice
(
i
+
1
),
key
,
all
[
i
][
key
]);
if
(
deleteIndex
>=
0
)
{
all
.
splice
(
deleteIndex
,
1
);
i
--
;
}
}
console
.
log
(
"in contactArray"
,
all
);
return
all
;
}
src/utils/mixins.js
浏览文件 @
b1bb00c8
...
@@ -110,7 +110,7 @@ module.exports = {
...
@@ -110,7 +110,7 @@ module.exports = {
// 通用GET请求
// 通用GET请求
GET
(
api
,
para
,
callback
,
str
)
{
GET
(
api
,
para
,
callback
,
str
)
{
// debugger
// debugger
let
token
=
para
.
token
||
this
.
token
||
this
.
$store
.
state
.
user
.
token
||
'9
98E10CD98ED4BCF91A28223270FE8CE
'
;
let
token
=
para
.
token
||
this
.
token
||
this
.
$store
.
state
.
user
.
token
||
'9
3521BDB92774134B2CC18633F2B6D3A
'
;
para
.
token
=
token
;
para
.
token
=
token
;
delete
para
.
token
;
delete
para
.
token
;
delete
para
.
setEntry
;
delete
para
.
setEntry
;
...
@@ -148,8 +148,10 @@ module.exports = {
...
@@ -148,8 +148,10 @@ module.exports = {
// 通用POST请求
// 通用POST请求
POST
(
api
,
para
,
callback
)
{
POST
(
api
,
para
,
callback
)
{
let
token
=
para
.
token
||
this
.
token
||
this
.
$store
.
state
.
user
.
token
||
''
;
let
token
=
para
.
token
||
this
.
token
||
this
.
$store
.
state
.
user
.
token
||
'
93521BDB92774134B2CC18633F2B6D3A
'
;
para
.
token
=
token
;
para
.
token
=
token
;
delete
para
.
token
;
delete
para
.
setEntry
;
return
fetch
({
return
fetch
({
url
:
getBaseUrl
(
api
),
url
:
getBaseUrl
(
api
),
method
:
'post'
,
method
:
'post'
,
...
...
src/views/question-detail.vue
浏览文件 @
b1bb00c8
此差异已折叠。
点击以展开。
写
预览
Markdown
格式
0%
请重试
or
附加一个文件
附加文件
取消
您添加了
0
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录