index.vue 4.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. <template>
  2. <div class="subPage">
  3. <div class="system-table-search">
  4. <div class="flex-h">
  5. <div class="flex-item flex-h">
  6. <el-button size="mini" type="success" @click='addChannel'>新增渠道</el-button>
  7. </div>
  8. <ul>
  9. <li>
  10. <!-- <span>选择案场:</span> -->
  11. <el-select v-model="CaseId" placeholder="请选择">
  12. <el-option
  13. v-for="item in cases"
  14. :key="item.CaseId"
  15. :label="item.CaseName"
  16. :value="item.CaseId">
  17. </el-option>
  18. </el-select>
  19. </li>
  20. </ul>
  21. <el-button
  22. size="mini"
  23. type="primary" @click="search">搜索</el-button>
  24. </div>
  25. <div class="moreFilter"></div>
  26. </div>
  27. <div class="system-table-box">
  28. <el-table
  29. :data="currentList"
  30. stripe
  31. style="width: 100%">
  32. <el-table-column
  33. prop="CaseName"
  34. label="案场">
  35. </el-table-column>
  36. <el-table-column
  37. prop="ChannelName"
  38. label="渠道名称">
  39. </el-table-column>
  40. <el-table-column label="操作">
  41. <template slot-scope="scope">
  42. <el-button
  43. size="mini"
  44. type="warning"
  45. @click="handleEdit(scope.$index, scope.row)">编辑</el-button>
  46. <el-button
  47. size="mini"
  48. type="danger"
  49. @click="handleDelete(scope.$index, scope.row)">删除</el-button>
  50. </template>
  51. </el-table-column>
  52. </el-table>
  53. </div>
  54. <el-pagination
  55. @current-change="handleCurrentChange"
  56. :current-page.sync="postData.page"
  57. :page-size="postData.pagesize"
  58. layout="prev, pager, next, jumper"
  59. :total="total">
  60. </el-pagination>
  61. </div>
  62. </template>
  63. <script>
  64. import { mapState } from 'vuex'
  65. export default {
  66. name: '',
  67. data () {
  68. return {
  69. total: 0,
  70. postData: { // 表格搜索条件
  71. caseid: '', // 案场id
  72. page: 1, // 当前页码
  73. pagesize: 10, // 请求数据量
  74. },
  75. currentList: []
  76. }
  77. },
  78. mounted () {
  79. this.$nextTick(function () {
  80. this.getList()
  81. })
  82. },
  83. computed: {
  84. ...mapState({
  85. cases: x => x.app.cases.list,
  86. defaultCaseId: x => x.app.cases.default
  87. }),
  88. CaseId: {
  89. get () {
  90. return this.postData.caseid || this.defaultCaseId
  91. },
  92. set (val) {
  93. this.postData.caseid = val
  94. }
  95. }
  96. },
  97. methods: {
  98. search () { // 搜索
  99. this.postData.page = 1
  100. this.currentList = []
  101. this.getList()
  102. },
  103. getList () { // 获取列表
  104. this.$ajax(this.$api.channelManager.getChannelList.url, {
  105. method: this.$api.channelManager.getChannelList.method,
  106. queryData: { ...this.postData, caseid: this.CaseId }
  107. }).then(res => {
  108. this.currentList = res.list
  109. this.postData.page = res.page
  110. this.total = res.pagenum
  111. })
  112. },
  113. handleCurrentChange (val) { // 跳转到分页
  114. this.getList()
  115. },
  116. handleEdit (index, row) { // 编辑
  117. this.$router.push({ name: 'editChannel', query: { id: row.ChannelId } })
  118. },
  119. handleDelete (index, row) { // 删除
  120. let name = '确认删除渠道“' + row.ChannelName + '”?'
  121. this.$confirm(name, '提示', {
  122. confirmButtonText: '确定',
  123. cancelButtonText: '取消',
  124. type: 'warning'
  125. }).then(() => {
  126. this.$ajax(this.$api.channelManager.deleteChannel.url, {
  127. method: this.$api.channelManager.deleteChannel.method,
  128. urlData: { channelId: row.ChannelId }
  129. }).then(res => {
  130. this.$message({
  131. type: 'success',
  132. message: '删除成功!'
  133. })
  134. this.search()
  135. })
  136. }).catch(() => {
  137. this.$message({
  138. type: 'info',
  139. message: '已取消删除'
  140. })
  141. })
  142. },
  143. addChannel () {
  144. this.$router.push({ name: 'addChannel' })
  145. }
  146. }
  147. }
  148. </script>
  149. <!-- Add "scoped" attribute to limit CSS to this component only -->
  150. <style lang="scss" scoped>
  151. @import "page.scss";
  152. </style>