Няма описание

index.vue 6.0KB

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