colmo设计师沙龙pc端后台管理系统

index.vue 3.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. <template>
  2. <div class="body" style="font-size:14px">
  3. <el-card class="box-card" shadow="never">
  4. 问卷名称:
  5. <el-input v-model="name" style="width: 200px; margin-right: 20px" />
  6. <div style="float:right">
  7. <el-button type="primary" @click="onSearch">查询</el-button>
  8. <el-button @click="onReset">重置</el-button>
  9. <el-button type="primary" icon="el-icon-plus" @click="handleAdd">添加问卷</el-button>
  10. </div>
  11. </el-card>
  12. <el-table stripe :data="tableData" border style="width: 100%">
  13. <el-table-column prop="name" label="问卷名" />
  14. <el-table-column prop="createDate" label="创建时间">
  15. <template slot-scope="scope">
  16. {{
  17. scope.row.createDate.substr(0, 10)
  18. }}
  19. </template>
  20. </el-table-column>
  21. <el-table-column fixed="right" label="操作">
  22. <template slot-scope="scope">
  23. <el-link :underline="false" style="margin-right:1em" type="primary">
  24. <router-link
  25. :to="{name: 'questionnaireEdit', query: { id: scope.row.queId }}"
  26. >编辑</router-link>
  27. </el-link>
  28. <el-popconfirm
  29. icon="el-icon-info"
  30. icon-color="red"
  31. title="确定删除这个问卷吗?"
  32. @onConfirm="handleDelete(scope.row)"
  33. >
  34. <el-button slot="reference" type="text" style="color:red">删除</el-button>
  35. </el-popconfirm>
  36. </template>
  37. </el-table-column>
  38. </el-table>
  39. <div v-show="false" id="qrcode" ref="qrcode" />
  40. <el-pagination
  41. v-show="Total!==0"
  42. style="float:right; margin:20px 0"
  43. :total="Total"
  44. :current-page="currentPage"
  45. :page-sizes="[4, 10, 20, 50]"
  46. :page-size="pageSize"
  47. layout="total, prev, pager, next, sizes"
  48. @size-change="handleSizeChange"
  49. @current-change="handleCurrentChange"
  50. />
  51. </div>
  52. </template>
  53. <script>
  54. import { getQuestionnaireList, deleteQuestionnaire } from '@/api/questionnaire'
  55. export default {
  56. data() {
  57. return {
  58. name: undefined,
  59. tableData: [],
  60. //
  61. pageSize: 10,
  62. currentPage: 1,
  63. Total: 0 // 条目总数
  64. }
  65. },
  66. mounted() {
  67. this.onSearch()
  68. },
  69. methods: {
  70. // 改变每页显示条数
  71. handleSizeChange(val) {
  72. this.pageSize = val
  73. this.changePagination()
  74. },
  75. // 改变页码
  76. handleCurrentChange(val) {
  77. this.currentPage = val
  78. this.changePagination()
  79. },
  80. // 改变分页组件重新查询数据
  81. changePagination() {
  82. getQuestionnaireList({
  83. name: this.name,
  84. pageNum: this.currentPage,
  85. pageSize: this.pageSize
  86. }).then((res) => {
  87. this.tableData = res.data.records
  88. })
  89. },
  90. handleAdd() {
  91. this.$router.push({ name: 'questionnaireEdit' })
  92. },
  93. handleDelete(row) {
  94. deleteQuestionnaire(row.queId).then(() => {
  95. this.onSearch()
  96. })
  97. },
  98. onSearch() {
  99. getQuestionnaireList({
  100. name: this.name,
  101. pageSize: this.pageSize
  102. }).then((res) => {
  103. this.tableData = res.data.records
  104. this.Total = res.data.total
  105. this.pageSize = res.data.size
  106. })
  107. },
  108. onReset() {
  109. this.name = undefined
  110. this.currentPage = 1
  111. this.pageSize = 10
  112. this.onSearch()
  113. }
  114. }
  115. }
  116. </script>
  117. <style>
  118. </style>