parent
a5961850fd
commit
1b600c85bd
8 changed files with 478 additions and 8 deletions
@ -0,0 +1,10 @@ |
|||||||
|
import request from '@/utils/request' |
||||||
|
|
||||||
|
let prefix = 'answer' |
||||||
|
|
||||||
|
export function page(data) { |
||||||
|
return request({ |
||||||
|
url: `/${prefix}/page`, |
||||||
|
data |
||||||
|
}) |
||||||
|
} |
@ -0,0 +1,90 @@ |
|||||||
|
<template> |
||||||
|
<el-dialog ref="dialogForm" width="45%" :title="title" :visible.sync="visible" @close="closeDialog"> |
||||||
|
<div class="details"> |
||||||
|
<el-descriptions :column="2" border> |
||||||
|
<el-descriptions-item label="答题者">{{ row.respondent || '无数据' }}</el-descriptions-item> |
||||||
|
<el-descriptions-item label="提交时间">{{ row.submitTime || '无数据' }}</el-descriptions-item> |
||||||
|
</el-descriptions> |
||||||
|
|
||||||
|
<!-- <el-descriptions :column="1" size="small" border>--> |
||||||
|
<!-- <el-descriptions-item v-for="(e,i) in row.details">--> |
||||||
|
<!-- <template slot="label">--> |
||||||
|
<!-- <el-tag v-if="e.type === 0" size="mini">单选</el-tag>--> |
||||||
|
<!-- <el-tag v-if="e.type === 1" size="mini">多选</el-tag>--> |
||||||
|
<!-- <el-tag v-if="e.type === 2" size="mini">文字</el-tag>--> |
||||||
|
<!-- {{ e.title }}--> |
||||||
|
<!-- {{ e.content }}--> |
||||||
|
<!-- </template>--> |
||||||
|
<!-- {{ e.answerContent }}--> |
||||||
|
<!-- </el-descriptions-item>--> |
||||||
|
<!-- </el-descriptions>--> |
||||||
|
<el-card shadow="never" style="margin-top: 3px"> |
||||||
|
<div v-for="(e,i) in row.details"> |
||||||
|
<el-row style="margin-top: 5px"> |
||||||
|
<div style="margin-right: 8px;display:inline-block;"> |
||||||
|
<el-tag v-if="e.type === 0" size="small">单选</el-tag> |
||||||
|
<el-tag v-if="e.type === 1" size="small">多选</el-tag> |
||||||
|
<el-tag v-if="e.type === 2" size="small">文字</el-tag> |
||||||
|
</div> |
||||||
|
<span style="color:#535bf2;margin-right: 15px;display:inline-block;">{{ e.title }}</span> |
||||||
|
{{ e.content }} |
||||||
|
</el-row> |
||||||
|
<el-row style="margin-top: 12px; margin-bottom: 25px;"> |
||||||
|
<el-tag size="small" type="success">答题内容:</el-tag> |
||||||
|
{{ e.answerContent }} |
||||||
|
</el-row> |
||||||
|
</div> |
||||||
|
</el-card> |
||||||
|
</div> |
||||||
|
<div slot="footer" class="dialog-footer"> |
||||||
|
<el-button @click="visible = false">关闭</el-button> |
||||||
|
</div> |
||||||
|
</el-dialog> |
||||||
|
</template> |
||||||
|
|
||||||
|
<script> |
||||||
|
export default { |
||||||
|
name: 'DetailsDialog', |
||||||
|
props: { |
||||||
|
row: { |
||||||
|
type: Object, |
||||||
|
require: true |
||||||
|
}, |
||||||
|
show: { |
||||||
|
type: Boolean, |
||||||
|
default: () => false |
||||||
|
} |
||||||
|
}, |
||||||
|
components: {}, |
||||||
|
data() { |
||||||
|
return { |
||||||
|
visible: this.show |
||||||
|
} |
||||||
|
}, |
||||||
|
computed: { |
||||||
|
title() { |
||||||
|
return this.row.qnName |
||||||
|
} |
||||||
|
}, |
||||||
|
watch: { |
||||||
|
visible() { |
||||||
|
this.$emit('update:show', false) |
||||||
|
} |
||||||
|
}, |
||||||
|
created() { |
||||||
|
|
||||||
|
}, |
||||||
|
mounted() { |
||||||
|
console.log('row -> ', this.row) |
||||||
|
}, |
||||||
|
methods: { |
||||||
|
closeDialog() { |
||||||
|
// 关闭 |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
</script> |
||||||
|
|
||||||
|
<style scoped lang="scss"> |
||||||
|
|
||||||
|
</style> |
@ -0,0 +1,274 @@ |
|||||||
|
<template> |
||||||
|
<div class="app-container full-height"> |
||||||
|
<!-- 查询条件 --> |
||||||
|
<el-card class="filter-container" shadow="never"> |
||||||
|
<el-form label-width="110px" :inline="true" :model="condition" @submit.native.prevent |
||||||
|
@keyup.enter.native="conditionQuery" |
||||||
|
> |
||||||
|
<!--查询条件--> |
||||||
|
<el-form-item label="问卷" prop="name"> |
||||||
|
<el-select v-model="condition.qnId" placeholder="请选择" clearable> |
||||||
|
<el-option |
||||||
|
v-for="item in qnOptions" |
||||||
|
:key="item.code" |
||||||
|
:label="item.label" |
||||||
|
:value="item.code" |
||||||
|
> |
||||||
|
</el-option> |
||||||
|
</el-select> |
||||||
|
</el-form-item> |
||||||
|
<!-- <el-form-item label="" prop="">--> |
||||||
|
<!-- <el-input v-model="condition." placeholder="请输入" />--> |
||||||
|
<!-- </el-form-item>--> |
||||||
|
<!--End--> |
||||||
|
<el-form-item> |
||||||
|
<el-button type="primary" @click="conditionQuery">查询</el-button> |
||||||
|
</el-form-item> |
||||||
|
<el-form-item> |
||||||
|
<el-button @click="handleResetCondition">重置</el-button> |
||||||
|
</el-form-item> |
||||||
|
</el-form> |
||||||
|
</el-card> |
||||||
|
|
||||||
|
<!-- 表格操作 --> |
||||||
|
<el-card class="table-operate-container" shadow="never"> |
||||||
|
<el-button size="mini" icon="el-icon-plus" type="primary" plain @click="addRow">添加</el-button> |
||||||
|
<el-button :disabled="!hasSelection" type="danger" size="mini" @click="removeBatchRows">批量删除 |
||||||
|
</el-button> |
||||||
|
</el-card> |
||||||
|
|
||||||
|
<!-- 表格 --> |
||||||
|
<div ref="tableContainer" class="table-container"> |
||||||
|
<!-- 表格主体 --> |
||||||
|
<el-table ref="listTable" v-loading="selectLoading" :max-height="tableMaxHeight" :data="tableData" border |
||||||
|
style="width: 100%" @row-click="handleRowClick" @selection-change="handleSelectionChange" |
||||||
|
> |
||||||
|
<el-table-column type="selection" width="40" align="center"/> |
||||||
|
<el-table-column type="index" label="序号" width="60" align="center"/> |
||||||
|
<el-table-column property="qnName" label="问卷" min-width="25%" align="center"/> |
||||||
|
<el-table-column property="respondent" label="答题者" min-width="25%" align="center"/> |
||||||
|
<el-table-column property="submitTime" label="提交时间" width="200" align="center"/> |
||||||
|
<!--<el-table-column property="" label="" min-width="25%" align="center" />--> |
||||||
|
<!--<el-table-column property="" label="" width="200" align="center" />--> |
||||||
|
<el-table-column label="操作" width="180" align="center"> |
||||||
|
<template v-slot="scope"> |
||||||
|
<el-button size="mini" @click.stop="handleLookDetails(scope.row)">详细答卷</el-button> |
||||||
|
<!-- <el-button size="mini" @click.stop="handleEdit(scope.row)">编辑</el-button>--> |
||||||
|
<!-- <el-button type="danger" plain size="mini" @click.stop="handleRemove(scope.row)">删除</el-button>--> |
||||||
|
</template> |
||||||
|
</el-table-column> |
||||||
|
</el-table> |
||||||
|
<!-- End 表格主体 --> |
||||||
|
|
||||||
|
<!-- 表格页码控件 --> |
||||||
|
<div class="pagination-container"> |
||||||
|
<el-pagination background layout="total, sizes, prev, pager, next,jumper" |
||||||
|
:current-page.sync="condition.pageNumber" :page-size.sync="condition.pageSize" |
||||||
|
:page-sizes="[10, 20, 30, 50, 100]" :total="total" @size-change="conditionQuery" |
||||||
|
@current-change="conditionQuery" |
||||||
|
/> |
||||||
|
</div> |
||||||
|
<!-- End 表格页码控件 --> |
||||||
|
</div> |
||||||
|
<!-- End 表格 --> |
||||||
|
|
||||||
|
<details-dialog v-if="detailsDialog.show" :row="detailsDialog.row" :show.sync="detailsDialog.show"/> |
||||||
|
|
||||||
|
<!-- 编辑弹窗 --> |
||||||
|
<!-- <edit-dialog v-if="showDialog" :row="editRowData" :show.sync="showDialog" :is-add="isAddDialog" |
||||||
|
@saved="conditionQuery" |
||||||
|
/> --> |
||||||
|
|
||||||
|
</div> |
||||||
|
</template> |
||||||
|
|
||||||
|
<script> |
||||||
|
|
||||||
|
/** |
||||||
|
* @version 2.0 |
||||||
|
*/ |
||||||
|
|
||||||
|
/* Base */ |
||||||
|
import { options } from '@/api/questionnaire' |
||||||
|
import { page } from '@/api/answer' |
||||||
|
import DetailsDialog from '@/views/answer/details' |
||||||
|
|
||||||
|
const default_condition = { |
||||||
|
pageNumber: 1, |
||||||
|
pageSize: 10 |
||||||
|
} |
||||||
|
/* ↑ Base */ |
||||||
|
export default { |
||||||
|
name: 'Answer', |
||||||
|
components: { DetailsDialog }, |
||||||
|
data() { |
||||||
|
return { |
||||||
|
detailsDialog: { |
||||||
|
show: false, |
||||||
|
row: null |
||||||
|
}, |
||||||
|
qnOptionsList: [], |
||||||
|
/* Edit Dialog */ |
||||||
|
editRowData: null, |
||||||
|
showDialog: false, |
||||||
|
isAddDialog: null, |
||||||
|
/* ↑ Edit Dialog */ |
||||||
|
/* Base */ |
||||||
|
condition: JSON.parse(JSON.stringify(default_condition)), |
||||||
|
tableData: [], |
||||||
|
total: null, |
||||||
|
selectLoading: false, |
||||||
|
tableMaxHeight: null, |
||||||
|
multipleSelection: [] |
||||||
|
/* ↑ Base */ |
||||||
|
} |
||||||
|
}, |
||||||
|
computed: { |
||||||
|
hasSelection() { |
||||||
|
return this.multipleSelection.length > 1 |
||||||
|
}, |
||||||
|
qnOptions() { |
||||||
|
return this.qnOptionsList |
||||||
|
} |
||||||
|
}, |
||||||
|
watch: {}, |
||||||
|
created() { |
||||||
|
|
||||||
|
}, |
||||||
|
mounted() { |
||||||
|
/* Base */ |
||||||
|
this.resizeTable() |
||||||
|
window.onresize = () => { |
||||||
|
return (() => { |
||||||
|
this.resizeTable() |
||||||
|
})() |
||||||
|
} |
||||||
|
/* ↑ Base */ |
||||||
|
this.conditionQuery() |
||||||
|
this.queryQnOptions() |
||||||
|
}, |
||||||
|
methods: { |
||||||
|
queryQnOptions() { |
||||||
|
options({ status: -1 }).then(r => { |
||||||
|
this.qnOptionsList = r.data |
||||||
|
}).catch(err => { |
||||||
|
console.log('err -> ', err) |
||||||
|
}) |
||||||
|
}, |
||||||
|
handleLookDetails(row) { |
||||||
|
// open dialog look details |
||||||
|
this.detailsDialog.show = true |
||||||
|
this.detailsDialog.row = row |
||||||
|
}, |
||||||
|
/* Base */ |
||||||
|
addRow() { |
||||||
|
// 表格操作 - 添加 |
||||||
|
this.isAddDialog = true |
||||||
|
this.editRowData = null |
||||||
|
this.showDialog = true |
||||||
|
}, |
||||||
|
handleRemove(row) { |
||||||
|
// 表格 - 操作列 - 删除 |
||||||
|
let title = '确定要删除吗? 该操作可能无法恢复!' |
||||||
|
this.$confirm(title, '提示', { |
||||||
|
type: 'warning' |
||||||
|
}).then(() => { |
||||||
|
const loading = this.$loading({ |
||||||
|
background: this.$elementGlobal.loadingBackground |
||||||
|
}) |
||||||
|
remove([row.id]).then(r => { //todo remove函数未导入 |
||||||
|
loading.close() |
||||||
|
if (r.data) { |
||||||
|
this.$message({ |
||||||
|
type: 'success', |
||||||
|
message: '操作成功!' |
||||||
|
}) |
||||||
|
} else { |
||||||
|
this.$message({ |
||||||
|
type: 'error', |
||||||
|
message: '操作失败!' |
||||||
|
}) |
||||||
|
} |
||||||
|
this.conditionQuery() |
||||||
|
}).catch(e => { |
||||||
|
loading.close() |
||||||
|
console.log(e) |
||||||
|
}) |
||||||
|
}).catch(() => { |
||||||
|
|
||||||
|
}) |
||||||
|
}, |
||||||
|
removeBatchRows() { |
||||||
|
// 表格操作 - 批量删除 |
||||||
|
const h = this.$createElement |
||||||
|
this.$confirm(h('p', null, [ |
||||||
|
h('p', null, '确定要删除 ' + this.multipleSelection.length + ' 个吗?'), |
||||||
|
h('p', { style: 'color: #f80' }, ' 该操作可能无法恢复!') |
||||||
|
]), '提示', { |
||||||
|
type: 'warning' |
||||||
|
}).then(() => { |
||||||
|
const loading = this.$loading({ |
||||||
|
background: this.$elementGlobal.loadingBackground |
||||||
|
}) |
||||||
|
remove(this.multipleSelection.map(e => e.id)).then(r => { //todo remove函数未导入 |
||||||
|
loading.close() |
||||||
|
if (r.data) { |
||||||
|
this.$message({ |
||||||
|
type: 'success', |
||||||
|
message: '操作成功!' |
||||||
|
}) |
||||||
|
} else { |
||||||
|
this.$message({ |
||||||
|
type: 'error', |
||||||
|
message: '操作失败!' |
||||||
|
}) |
||||||
|
} |
||||||
|
this.conditionQuery() |
||||||
|
}).catch(e => { |
||||||
|
loading.close() |
||||||
|
console.log(e) |
||||||
|
}) |
||||||
|
}).catch(() => { |
||||||
|
|
||||||
|
}) |
||||||
|
}, |
||||||
|
// 表格 - 编辑行 |
||||||
|
handleEdit(row) { |
||||||
|
this.isAddDialog = false |
||||||
|
this.showDialog = true |
||||||
|
this.editRowData = row |
||||||
|
}, |
||||||
|
// 表格 - 查询表数据 |
||||||
|
conditionQuery() { |
||||||
|
this.selectLoading = true |
||||||
|
page(this.condition).then(r => { |
||||||
|
this.selectLoading = false |
||||||
|
this.tableData = r.data.rows |
||||||
|
this.total = r.data.total |
||||||
|
}).catch(e => { |
||||||
|
this.selectLoading = false |
||||||
|
console.log('query error -> ', e) |
||||||
|
}) |
||||||
|
}, |
||||||
|
resizeTable() { |
||||||
|
this.tableMaxHeight = window.innerHeight - (this.$refs.tableContainer.offsetTop + 100) |
||||||
|
}, |
||||||
|
// 重置表格查询条件 |
||||||
|
handleResetCondition() { |
||||||
|
this.condition = Object.assign({}, default_condition) |
||||||
|
}, |
||||||
|
// [事件]表格 - 点击行 |
||||||
|
handleRowClick(row) { |
||||||
|
this.$refs.listTable.toggleRowSelection(row) |
||||||
|
}, |
||||||
|
handleSelectionChange(val) { |
||||||
|
this.multipleSelection = val |
||||||
|
} |
||||||
|
/* ↑ Base */ |
||||||
|
} |
||||||
|
} |
||||||
|
</script> |
||||||
|
|
||||||
|
<style scoped lang="scss"> |
||||||
|
|
||||||
|
</style> |
Loading…
Reference in new issue