index.vue 4.4KB

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