123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314 |
- <template>
- <div class="pb_content">
- <div class="pb_head">
- <span>问卷调查</span>
- </div>
- <div class="pb_content_body">
- <div class="cd_bread">
- <el-breadcrumb separator-class="el-icon-arrow-right">
- <el-breadcrumb-item :to="{ path: '/ask?userid='+ userid }"
- >问卷调查</el-breadcrumb-item
- >
- <el-breadcrumb-item>查看已经提交的问卷</el-breadcrumb-item>
- </el-breadcrumb>
- </div>
- <div class="student_table">
- <el-table
- ref="table"
- :data="tableData"
- border
- stripe
- :height="tableHeight"
- :fit="true"
- v-loading="isLoading"
- style="width: 100%; height: 60%"
- :header-cell-style="{ background: '#f1f1f1' }"
- >
- <el-table-column
- prop="title"
- label="问卷调查标题"
- min-width="25"
- align="center"
- >
- </el-table-column>
- <el-table-column
- prop="name"
- label="提交者"
- min-width="25"
- align="center"
- >
- </el-table-column>
- <el-table-column
- prop="time"
- label="提交时间"
- min-width="25"
- align="center"
- >
- </el-table-column>
- <el-table-column label="操作" min-width="25">
- <template slot-scope="scope">
- <el-button @click="getAskList(scope.row)" type="text" size="small"
- >查看</el-button
- >
- <el-button
- @click="deleteAsk(scope.row.id)"
- type="text"
- size="small"
- >删除</el-button
- >
- </template>
- </el-table-column>
- </el-table>
- </div>
- <div class="student_page">
- <el-pagination
- background
- layout="prev, pager, next"
- :page-size="10"
- :total="total"
- @current-change="handleCurrentChange"
- >
- </el-pagination>
- </div>
- </div>
- <el-dialog
- title="查看"
- :visible.sync="dialogVisible1"
- :append-to-body="true"
- width="750px"
- :before-close="handleClose"
- class="dialog_diy"
- >
- <div>
- <div class="a_add_title">
- <!-- <el-input
- v-model="askTitle"
- placeholder="请输入问卷标题"
- style="width: 400px"
- ></el-input> -->
- <h1>{{ askTitle }}</h1>
- </div>
- <div class="a_addBox">
- <div
- class="a_add_box"
- v-for="(item, index) in itemCount"
- :key="index"
- >
- <div class="a_add_head">
- <div>
- <!-- {{ index + 1 + "、" }}
- <el-input
- class="a_add_head_input"
- v-model="askJson[index].askstitle"
- placeholder="请输入问卷题目..."
- ></el-input> -->
- <span>{{ index + 1 + "、" + askJson[index].askstitle }}</span>
- </div>
- </div>
- <div class="a_add_body">
- <div class="a_add_input">
- <el-radio-group v-model="radio[index]">
- <el-radio
- :label="checkIndex + 1 + ''"
- v-for="(item, checkIndex) in askJson[index].askItem"
- style="width: 150px; margin: 10px 10px 0 0"
- :key="checkIndex"
- disabled
- >{{ askJson[index].checkList[checkIndex] }}</el-radio
- >
- </el-radio-group>
- </div>
- </div>
- </div>
- </div>
- </div>
- <span slot="footer" class="dialog-footer">
- <el-button @click="dialogVisible1 = false">关 闭</el-button>
- </span>
- </el-dialog>
- </div>
- </template>
- <script>
- export default {
- data() {
- return {
- tableData: [],
- tableHeight: 500,
- isLoading: false,
- page: 1,
- total: 0,
- dialogVisible1: false,
- itemCount: 1,
- askTitle: "",
- askJson: [{ askstitle: "", askItem: 1, checkList: [] }],
- radio: [],
- userid: this.$route.query.userid,
- };
- },
- methods: {
- handleClose(done) {
- done();
- },
- goTo(path) {
- this.$router.push(path);
- },
- deleteAsk(id) {
- let params = [{ id: id }];
- this.$confirm("确定删除此学生的问卷吗?", "提示", {
- confirmButtonText: "确定",
- cancelButtonText: "取消",
- type: "warning",
- })
- .then(() => {
- this.ajax
- .post(this.$store.state.api + "deleteAskList", params)
- .then((res) => {
- this.$message({
- message: "删除成功",
- type: "success",
- });
- if (this.page != 1 && this.tableData.length == 1) {
- this.page--;
- }
- this.getAsk();
- })
- .catch((err) => {
- this.$message.error("删除失败");
- console.error(err);
- });
- })
- .catch(() => {});
- },
- handleCurrentChange(val) {
- this.page = val;
- this.getAsk();
- },
- //获取
- getAsk() {
- this.isLoading = true;
- let params = {
- uid: this.userid,
- page: this.page,
- };
- this.ajax
- .get(this.$store.state.api + "getAskList", params)
- .then((res) => {
- this.isLoading = false;
- this.total = res.data[0].length > 0 ? res.data[0][0].num : 0;
- this.tableData = res.data[0];
- })
- .catch((err) => {
- this.dialogVisible = false;
- console.error(err);
- });
- },
- getAskList(res) {
- this.askTitle = res.title;
- this.askJson = JSON.parse(res.askContent);
- this.radio = res.content.split(",");
- this.itemCount = this.askJson.length;
- this.dialogVisible1 = true;
- },
- changeHeight() {
- this.tableHeight =
- window.innerHeight - this.$refs.table.$el.offsetTop - 200;
- if (this.tableHeight <= 530) {
- this.tableHeight = 530;
- }
- // 监听窗口大小变化
- let self = this;
- window.onresize = function () {
- self.tableHeight =
- window.innerHeight - self.$refs.table.$el.offsetTop - 200;
- if (self.tableHeight <= 530) {
- self.tableHeight = 530;
- }
- };
- // this.$refs.table.$el.offsetTop:表格距离浏览器的高度 //200表示你想要调整的表格距离底部的高度(你可以自己随意调整),因为我们一般都有放分页组件的,所以需要给它留一个高度
- },
- },
- created() {
- this.$nextTick(function () {
- this.page = 1;
- this.changeHeight();
- this.getAsk();
- });
- },
- };
- </script>
- <style scoped>
- .dialog_diy >>> .el-dialog__header {
- background: #3d67bc !important;
- padding: 15px 20px;
- }
- .dialog_diy >>> .el-dialog__title {
- color: #fff;
- }
- .dialog_diy >>> .el-dialog__headerbtn {
- top: 19px;
- }
- .dialog_diy >>> .el-dialog__headerbtn .el-dialog__close {
- color: #fff;
- }
- .dialog_diy >>> .el-dialog__headerbtn .el-dialog__close:hover {
- color: #fff;
- }
- .dialog_diy >>> .el-dialog__body {
- max-height: 750px;
- overflow: auto;
- }
- .dialog_diy >>> .el-dialog {
- background: #fafafa;
- }
- .cd_bread {
- margin: 20px auto;
- }
- .student_table {
- margin: 20px 0;
- }
- .a_add_title {
- }
- .a_addBox {
- margin: 10px 0;
- background: #fff;
- padding: 15px;
- }
- .a_add_box {
- border-bottom: 2px solid #eee;
- padding-bottom: 10px;
- }
- .a_add_head {
- display: flex;
- align-items: center;
- justify-content: space-between;
- margin: 10px 0;
- font-size: 18px;
- }
- .a_add_head .a_add_head_input {
- width: 300px;
- }
- .a_add_head .a_add_head_div {
- display: flex;
- align-items: center;
- justify-content: space-between;
- }
- .a_add_body {
- display: flex;
- align-items: center;
- }
- .a_add_input {
- display: flex;
- align-items: center;
- flex-wrap: wrap;
- }
- .a_add_body_div {
- display: flex;
- align-items: center;
- justify-content: center;
- flex-direction: column;
- }
- </style>
|