notice-select.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. <template>
  2. <div class="product-select">
  3. <el-form :inline="true" :model="formData" class="demo-form-inline">
  4. <el-form-item label="">
  5. <el-input v-model="formData.keyword" maxlength="20" placeholder="店铺名称"></el-input>
  6. </el-form-item>
  7. <el-form-item>
  8. <el-button type="primary" @click="onSubmit">查询</el-button>
  9. </el-form-item>
  10. </el-form>
  11. <el-table
  12. :data="tableData"
  13. max-height="500"
  14. border
  15. style="width: 100%">
  16. <el-table-column label="" width="35" align="center">
  17. <template slot-scope="scope">
  18. <el-radio v-model="tableRadio" :label="scope.row"><i></i></el-radio>
  19. </template>
  20. </el-table-column>
  21. <el-table-column prop="noticeTitle" label="标题" />
  22. <el-table-column label="内容">
  23. <template slot-scope="scope">
  24. <span v-html="scope.row.noticeContent" />
  25. </template>
  26. </el-table-column>
  27. <el-table-column prop="createTime" label="发送时间" />
  28. </el-table>
  29. <el-pagination
  30. @size-change="handleSizeChange"
  31. @current-change="handleCurrentChange"
  32. :current-page="currentPage"
  33. :page-sizes="[10, 20, 50, 100]"
  34. :page-size="pageSize"
  35. layout="total, sizes, prev, pager, next, jumper"
  36. :total="total">
  37. </el-pagination>
  38. </div>
  39. </template>
  40. <script>
  41. import api from '@@/components/canvasShow/config/api'
  42. import {sendReqMixin} from '@@/components/canvasShow/config/mixin'
  43. export default {
  44. name: 'notice-select',
  45. mixins: [sendReqMixin],
  46. data () {
  47. return {
  48. tableRadio: '',
  49. currentPage: 1,
  50. total: 0,
  51. pageSize: 10,
  52. formData: {
  53. keyword: ''
  54. },
  55. tableData: []
  56. }
  57. },
  58. mounted () {
  59. this.getTableData()
  60. },
  61. methods: {
  62. // 获取公告信息
  63. getTableData () {
  64. var _this = this
  65. var paramsUrl = `${api.getNoticesAll}?page=${this.currentPage}&pageSize=${this.pageSize}`
  66. if (this.formData.keyword) {
  67. paramsUrl += `&noticeTitle=${this.formData.keyword}`
  68. }
  69. var data = {
  70. page: this.currentPage,
  71. pageSize: this.pageSize,
  72. noticeType: 2
  73. }
  74. if (this.formData.keyword) {
  75. data.noticeTitle = this.formData.keyword
  76. }
  77. let params = {
  78. url: paramsUrl,
  79. method: 'POST',
  80. data
  81. }
  82. this.sendReq(params, (res) => {
  83. _this.tableData = res.data.list
  84. _this.total = res.data.total
  85. })
  86. },
  87. // 搜索
  88. onSubmit () {
  89. this.getTableData()
  90. },
  91. // 每页条数改变
  92. handleSizeChange (val) {
  93. this.pageSize = val
  94. this.getTableData()
  95. },
  96. // 当前页改变
  97. handleCurrentChange (val) {
  98. this.currentPage = val
  99. this.getTableData()
  100. }
  101. }
  102. }
  103. </script>
  104. <style lang="scss" scoped>
  105. .product-select{
  106. .el-pagination{
  107. padding: 0px;
  108. margin-top: 30px;
  109. }
  110. }
  111. </style>