暂无描述

index.vue 5.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. <template>
  2. <div class="app-container calendar-list-container">
  3. <div v-show="visible.firstLayer">
  4. <div class="app-container">
  5. <el-input @keyup.enter.native="handleFilter" style="width: 200px;" class="filter-item" placeholder="名稱" v-model="listQuery.name">
  6. </el-input>
  7. <el-button class="filter-item" type="primary" v-waves icon="el-icon-search" @click="handleFilter">搜尋</el-button>
  8. <el-button class="filter-item" @click="handleCreate" type="primary" icon="el-icon-edit">創建代理商</el-button>
  9. </div>
  10. <el-table :data="list" v-loading.body="listLoading" element-loading-text="Loading" border fit highlight-current-row
  11. style="width: 100%">
  12. <!-- <el-table-column align="center" label='ID' >
  13. <template slot-scope="scope">
  14. {{scope.row.GambleMember.id}}
  15. </template>
  16. </el-table-column> -->
  17. <el-table-column label="名稱" align="center">
  18. <template slot-scope="scope">
  19. {{scope.row.GambleMember.name}}
  20. </template>
  21. </el-table-column>
  22. <el-table-column label="抽水%" align="center">
  23. <template slot-scope="scope">
  24. {{scope.row.feeRatio}}
  25. </template>
  26. </el-table-column>
  27. <el-table-column align="center" label="操作" width="450">
  28. <template slot-scope="scope">
  29. <router-link to="/agent/index/gambleMemberManagement">
  30. <el-button type="primary" size="mini" icon="el-icon-tickets" @click="handlePage(scope.row)">會員管理</el-button>
  31. </router-link>
  32. </template>
  33. </el-table-column>
  34. </el-table>
  35. <div v-show="!listLoading" class="pagination-container">
  36. <el-pagination background @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page.sync="listQuery.page"
  37. :page-sizes="[10,20,30, 50]" :page-size="listQuery.limit" layout="total, sizes, prev, pager, next, jumper" :total="total">
  38. </el-pagination>
  39. </div>
  40. <el-dialog title="創建代理商" :visible.sync="dialogCreateFormVisible" :before-close="handleDialogClose" center>
  41. <el-form :rules="rules" ref="createForm" :model="createFormData" label-position="left" label-width="100px" style='width: 400px; margin-left:50px;'>
  42. <el-form-item label="名稱" prop="name">
  43. <el-input v-model="createFormData.name"></el-input>
  44. </el-form-item>
  45. <el-form-item label="抽水 %" prop="feeRatio">
  46. <el-input v-model="createFormData.feeRatio"></el-input>
  47. </el-form-item>
  48. </el-form>
  49. <div slot="footer" class="dialog-footer">
  50. <el-button @click="handleDialogClose">取 消</el-button>
  51. <el-button type="primary" @click="createData">確 定</el-button>
  52. </div>
  53. </el-dialog>
  54. </div>
  55. <router-view :agent="agent"></router-view>
  56. </div>
  57. </template>
  58. <script>
  59. import { mapGetters, mapActions } from 'vuex'
  60. import { fetchList, createAgent } from '@/api/agnetManagement'
  61. import waves from '@/directive/waves' // 水波纹指令
  62. export default {
  63. directives: {
  64. waves
  65. },
  66. data() {
  67. return {
  68. list: null,
  69. total: null,
  70. listLoading: true,
  71. listQuery: {
  72. page: 1,
  73. limit: 20,
  74. },
  75. dialogCreateFormVisible: false,
  76. dialogStatus: '',
  77. agent: {},
  78. rules: {
  79. // rewardChips: [{ pattern: /^-?\d+$/, required: true, message: '請輸入整數', trigger: 'change' }],
  80. // depositChips: [{ pattern: /^-?\d+$/, required: true, message: '請輸入整數', trigger: 'change' }],
  81. // chips: [{ pattern: /^(0|[1-9][0-9]*)$/, required: true, message: '請輸入整數', trigger: 'change' }],
  82. // name: [{ type: 'string', required: true, message: '必填', trigger: 'change' }]
  83. },
  84. createFormData: {
  85. name: '',
  86. feeRatio: '',
  87. }
  88. }
  89. },
  90. created() {
  91. this.SetVisible(1)
  92. this.getList()
  93. },
  94. computed: {
  95. ...mapGetters([
  96. 'visible'
  97. ])
  98. },
  99. methods: {
  100. ...mapActions([
  101. 'SetVisible'
  102. ]),
  103. getList() {
  104. this.listLoading = true
  105. fetchList(this.listQuery).then(response => {
  106. this.list = response.data.rows
  107. console.log(this.list)
  108. this.total = response.data.count
  109. this.listLoading = false
  110. })
  111. },
  112. resetCreateData() {
  113. this.temp = {
  114. id: undefined,
  115. name: '',
  116. chips: '',
  117. depositChips: ''
  118. }
  119. },
  120. handleCreate() {
  121. this.resetCreateData()
  122. this.dialogCreateFormVisible = true
  123. this.$nextTick(() => {
  124. this.$refs['createForm'].clearValidate()
  125. })
  126. },
  127. createData() {
  128. this.$refs['createForm'].validate((valid) => {
  129. if (valid) {
  130. createAgent(this.createFormData).then((response) => {
  131. const agent = response.data.gambleAgentSetting;
  132. agent.GambleMember = response.data.agent
  133. this.list.unshift(agent)
  134. this.dialogCreateFormVisible = false
  135. this.$notify({
  136. title: '成功',
  137. message: '創建成功',
  138. type: 'success',
  139. duration: 2000
  140. })
  141. })
  142. }
  143. })
  144. },
  145. handleFilter() {
  146. this.listQuery.page = 1
  147. this.getList()
  148. },
  149. handleSizeChange(val) {
  150. this.listQuery.limit = val
  151. this.getList()
  152. },
  153. handleCurrentChange(val) {
  154. this.listQuery.page = val
  155. this.getList()
  156. },
  157. handleDialogClose() {
  158. this.dialogCreateFormVisible = false;
  159. },
  160. handlePage(row) {
  161. const temp = Object.assign({}, row) // copy obj
  162. this.SetVisible(2)
  163. this.agent = temp
  164. },
  165. },
  166. }
  167. </script>