|
@@ -38,7 +38,7 @@
|
|
|
</div>
|
|
|
<div slot="right" class="demo-split-pane">
|
|
|
<Split v-model="split2">
|
|
|
- <div slot="left" class="demo-split-pane">
|
|
|
+ <div slot="left" class="demo-split-pane" ref="voteFormBox">
|
|
|
<!-- 投票基础信息展示 -->
|
|
|
<div class="hw-col hw-info-box">
|
|
|
<div class="hw-box-header">
|
|
@@ -48,7 +48,7 @@
|
|
|
<Icon type="md-create" size="18" :title="$t('vote.edit')" @click="onEditVote" v-if="($access.can('admin.*|schoolAc-upd') || isPrivate)" /></span>
|
|
|
</div>
|
|
|
</div>
|
|
|
- <vuescroll>
|
|
|
+ <vuescroll ref="voteFormScroll">
|
|
|
<div v-show="voteList.length === 0">
|
|
|
<EmptyData :top="50"></EmptyData>
|
|
|
</div>
|
|
@@ -166,6 +166,10 @@
|
|
|
this.hasNewAdd = true
|
|
|
this.$refs.voteForm.voteFormEdit = true
|
|
|
}
|
|
|
+
|
|
|
+ this.$nextTick(() => {
|
|
|
+ this.$refs.voteFormBox.scrollIntoView();
|
|
|
+ })
|
|
|
},
|
|
|
|
|
|
|
|
@@ -204,13 +208,22 @@
|
|
|
* @param index
|
|
|
*/
|
|
|
async onVoteClick(item, index) {
|
|
|
- this.currentVote = item.id ? await this.getVoteDetails(item) : item
|
|
|
+ console.log(item)
|
|
|
+ let fullItem = item.id ? await this.getVoteDetails(item) : item
|
|
|
+ this.currentVote = fullItem
|
|
|
this.activeVoteIndex = index
|
|
|
- // if (item.id) this.getVoteStudents(item.id,item.target)
|
|
|
+ if (item.id) this.getVoteStudents(fullItem,fullItem.classes)
|
|
|
this.$refs.voteForm.voteFormEdit = false
|
|
|
+ this.$refs.voteFormScroll.scrollTo({
|
|
|
+ y: 0,
|
|
|
+ },
|
|
|
+ 200,
|
|
|
+ "easeInQuad"
|
|
|
+ );
|
|
|
this.hasNewAdd = false
|
|
|
},
|
|
|
|
|
|
+ /* 获取投票活动的详细数据 */
|
|
|
getVoteDetails(voteItem){
|
|
|
return new Promise((r,j) => {
|
|
|
this.$api.learnActivity.FindVoteById({
|
|
@@ -225,6 +238,28 @@
|
|
|
})
|
|
|
})
|
|
|
},
|
|
|
+
|
|
|
+ /* 获取正在进行中的投票活动的投票数据 */
|
|
|
+ getVoteRecord(voteItem){
|
|
|
+ return new Promise((r,j) => {
|
|
|
+ this.$api.learnActivity.FindVoteRecord({
|
|
|
+ id: voteItem.id,
|
|
|
+ code: voteItem.code,
|
|
|
+ }).then(res => {
|
|
|
+ if(!res.error){
|
|
|
+ r(res)
|
|
|
+ }
|
|
|
+ }).catch(err => {
|
|
|
+ j(err)
|
|
|
+ })
|
|
|
+ })
|
|
|
+ },
|
|
|
+
|
|
|
+ /* 根据已结束的RecordUrl来获取投票结果数据 */
|
|
|
+ getRecordUrlData(){
|
|
|
+
|
|
|
+ },
|
|
|
+
|
|
|
|
|
|
/* 取消编辑投票(无ID状态) */
|
|
|
onCancelVote() {
|
|
@@ -252,13 +287,16 @@
|
|
|
scope: this.getCurScope
|
|
|
}).then(res => {
|
|
|
if (!res.error && res.flag) {
|
|
|
+ setTimeout(() => {
|
|
|
+ this.isLoading = false
|
|
|
+ this.$Message.success(this.$t('vote.deleteSuc'))
|
|
|
+ this.handleTabClick(this.$route.name === 'manageVote' ? 0 : 1)
|
|
|
+ },1000)
|
|
|
+
|
|
|
+ // this.voteList.splice(this.voteList.indexOf(this.currentVote), 1)
|
|
|
// this.isLoading = false
|
|
|
// this.$Message.success(this.$t('vote.deleteSuc'))
|
|
|
- // this.handleTabClick(this.$route.name === 'manageVote' ? 0 : 1)
|
|
|
- this.voteList.splice(this.voteList.indexOf(this.currentVote), 1)
|
|
|
- this.isLoading = false
|
|
|
- this.$Message.success(this.$t('vote.deleteSuc'))
|
|
|
- if (this.voteList.length) this.onVoteClick(this.voteList[0], 0)
|
|
|
+ // if (this.voteList.length) this.onVoteClick(this.voteList[0], 0)
|
|
|
} else {
|
|
|
this.isLoading = false
|
|
|
this.$Message.error(this.$t('vote.deleteFail'))
|
|
@@ -282,15 +320,17 @@
|
|
|
* 获取投票关联的学生清单
|
|
|
* @param voteId 投票ID
|
|
|
*/
|
|
|
- async getVoteStudents(voteId, target) {
|
|
|
+ async getVoteStudents(voteItem) {
|
|
|
this.isLoading = true
|
|
|
- let records = await this.getVoteRecord(voteId)
|
|
|
+ let records = await this.getVoteRecord(voteItem)
|
|
|
// 先查找 投票发布对象关联的学生清单 然后再去判断学生的作答情况
|
|
|
- this.$api.courseMgmt.getClassroomStudent({
|
|
|
- classroomCode: target.map(i => i.classroomCode),
|
|
|
- school_code: this.$store.state.userInfo.schoolCode
|
|
|
+ console.log(voteItem)
|
|
|
+ this.$api.schoolSetting.getClassroomStudent({
|
|
|
+ school_code: this.$store.state.userInfo.schoolCode,
|
|
|
+ ids: voteItem.classes,
|
|
|
+ scope:voteItem.owner === this.$store.state.userInfo.schoolCode ? 'school' : 'private'
|
|
|
}).then(res => {
|
|
|
- if (!res.error && res.classrooms) {
|
|
|
+ if (!res.error && res.classrooms.length) {
|
|
|
let list = []
|
|
|
res.classrooms.forEach(classroom => {
|
|
|
classroom.students.forEach(i => {
|
|
@@ -302,29 +342,26 @@
|
|
|
})
|
|
|
})
|
|
|
})
|
|
|
- console.log(list)
|
|
|
- // let infoList = res.result.extend.students
|
|
|
- // list.forEach(i => {
|
|
|
- // i.name = infoList.filter(j => j.studentId === i.code)[0].name
|
|
|
- // i.classroomName = target.filter(k => k.classroomCode === i.id)[0].classroomName
|
|
|
- // })
|
|
|
+ console.log(records)
|
|
|
+
|
|
|
// 要根据作答情况 结合两张表 处理表格显示的数据
|
|
|
- if (records.length) {
|
|
|
+ if (records.options.length) {
|
|
|
let arr = []
|
|
|
- this.studentsTable = []
|
|
|
- records.forEach((item, index) => {
|
|
|
+ this.studentsTable = records.records
|
|
|
+ records.options.forEach((item, index) => {
|
|
|
arr.push({
|
|
|
// option: this.getSimpleText(item.optionValue),
|
|
|
- option: item.optionKey ? this.$t('vote.option') + (index + 1) : this.$t('vote.noVote'),
|
|
|
- key: item.optionKey || '',
|
|
|
- result: item.students
|
|
|
+ option: item.code ? this.$t('vote.option') + (index + 1) : this.$t('vote.noVote'),
|
|
|
+ key: item.code || '',
|
|
|
+ result: new Array(item.count).fill('1')
|
|
|
})
|
|
|
- this.studentsTable = this.studentsTable.concat(item.students)
|
|
|
})
|
|
|
console.log(this.studentsTable)
|
|
|
this.studentsTable.forEach(i => {
|
|
|
- let matchList = list.filter(j => j.id === i.code)
|
|
|
+ let matchList = list.filter(j => j.id === i.userid)
|
|
|
i.name = matchList.length ? matchList[0].name : this.$t('vote.noData')
|
|
|
+ i.classroomName = matchList.length ? matchList[0].classroomName : this.$t('vote.noData')
|
|
|
+ i.option = i.opt.join(',')
|
|
|
})
|
|
|
console.log(arr)
|
|
|
this.tableData = arr
|
|
@@ -342,20 +379,6 @@
|
|
|
})
|
|
|
},
|
|
|
|
|
|
- /* 获取投票结果数据 */
|
|
|
- getVoteRecord(voteId) {
|
|
|
- return new Promise((r, j) => {
|
|
|
- this.$api.learnActivity.FindRecordByVoteId({
|
|
|
- id: voteId
|
|
|
- }).then(res => {
|
|
|
- if (!res.error && res.options) {
|
|
|
- r(res.options)
|
|
|
- } else {
|
|
|
- j(500)
|
|
|
- }
|
|
|
- })
|
|
|
- })
|
|
|
- },
|
|
|
|
|
|
// 提取富文本内容中的文本
|
|
|
getSimpleText(html) {
|