Channel.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. <template>
  2. <div class="channel">
  3. <el-card class="box-card">
  4. <div slot="header" class="clearfix">
  5. <span>渠道管理</span>
  6. <el-button style="float: right; padding: 3px 0" type="text" @click="add">增加</el-button>
  7. </div>
  8. <el-table
  9. :data="channeList.list"
  10. style="width: 100%"
  11. height="700">
  12. <el-table-column
  13. label="渠道 CODE"
  14. prop="code">
  15. </el-table-column>
  16. <el-table-column
  17. label="渠道名称"
  18. prop="title">
  19. </el-table-column>
  20. <el-table-column
  21. label="CDN 前缀"
  22. prop="cdnPrefix">
  23. </el-table-column>
  24. <el-table-column
  25. label="联系人"
  26. prop="contact">
  27. </el-table-column>
  28. <el-table-column
  29. label="联系人电话"
  30. prop="mobileNo">
  31. </el-table-column>
  32. <!--
  33. <el-table-column label="操作">
  34. <template slot-scope="scope">
  35. <el-button
  36. size="mini"
  37. @click="handleEdit(scope.$index, scope.row)">编辑</el-button>
  38. <el-button
  39. size="mini"
  40. type="danger"
  41. @click="handleDelete(scope.$index, scope.row)">删除</el-button>
  42. </template>
  43. </el-table-column>
  44. -->
  45. </el-table>
  46. <el-pagination
  47. background
  48. layout="prev, pager, next"
  49. :total="channeList.totalSize"
  50. @current-change="changePage">
  51. </el-pagination>
  52. </el-card>
  53. <el-dialog
  54. title="增加"
  55. :visible.sync="dialogVisible"
  56. width="50%"
  57. center>
  58. <el-form :model="channelForm" ref="channelEdit" label-position="left">
  59. <el-form-item label="CDN 前缀" prop="cdnPrefix" label-width="90px" :rules="{required: true, message: 'CDN 前缀不能为空'}">
  60. <el-input size="small" v-model="channelForm.cdnPrefix" autocomplete="off"></el-input>
  61. </el-form-item>
  62. <el-form-item label="CODE" prop="code" label-width="90px" :rules="{required: true, message: 'CODE 不能为空'}">
  63. <el-input size="small" v-model="channelForm.code" autocomplete="off"></el-input>
  64. </el-form-item>
  65. <el-form-item label="渠道名字" prop="title" label-width="90px" :rules="{required: true, message: '渠道名字不能为空'}">
  66. <el-input size="small" v-model="channelForm.title" autocomplete="off"></el-input>
  67. </el-form-item>
  68. <el-form-item label="联系人" prop="contact" label-width="90px">
  69. <el-input size="small" v-model="channelForm.contact" autocomplete="off"></el-input>
  70. </el-form-item>
  71. <el-form-item label="联系人电话" prop="mobileNo" label-width="90px">
  72. <el-input size="small" v-model="channelForm.mobileNo" autocomplete="off"></el-input>
  73. </el-form-item>
  74. </el-form>
  75. <span slot="footer" class="dialog-footer">
  76. <el-button @click="dialogVisible = false">取 消</el-button>
  77. <el-button type="primary" @click="setTable('channelEdit')">确 定</el-button>
  78. </span>
  79. </el-dialog>
  80. </div>
  81. </template>
  82. <script>
  83. import { mapGetters } from 'vuex';
  84. export default {
  85. data () {
  86. return{
  87. channelForm: {
  88. cdnPrefix: '',
  89. code: '',
  90. title: '',
  91. contact: '',
  92. mobileNo: ''
  93. },
  94. dialogVisible: false,
  95. page: ''
  96. }
  97. },
  98. computed: {
  99. ...mapGetters(['channeList'])
  100. },
  101. created() {
  102. this.$store.dispatch('getChannelList', {pageNo: 1, pageSize: 10 })
  103. },
  104. methods: {
  105. add () {
  106. this.dialogVisible = true;
  107. },
  108. // 分页
  109. changePage (e) {
  110. this.page = e;
  111. this.$store.dispatch('getChannelList', {pageNo: e, pageSize: 10})
  112. },
  113. // 提交确认
  114. setTable (formName) {
  115. this.$refs[formName].validate((valid) => {
  116. if (valid) {
  117. this.$store.dispatch('addChannelList', this.channelForm)
  118. } else {
  119. console.log('error submit!!');
  120. return false;
  121. }
  122. });
  123. this.dialogVisible = false;
  124. }
  125. }
  126. }
  127. </script>
  128. <style lang="less">
  129. .el-pagination {
  130. text-align: center;
  131. margin-top: 20px;
  132. }
  133. .el-form-item__content {
  134. width: 50%;
  135. }
  136. </style>