123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308 |
- <template>
- <div class="app-container calendar-list-container">
- <div v-show="visible.firstLayer">
- <div class="app-container">
- <el-input @keyup.enter.native="handleFilter" style="width: 200px;" class="filter-item" placeholder="名稱" v-model="listQuery.name">
- </el-input>
- <el-button class="filter-item" type="primary" v-waves icon="el-icon-search" @click="handleFilter">搜尋</el-button>
- <el-button class="filter-item" @click="handleCreate" type="primary" icon="el-icon-edit">創建代理商</el-button>
- <el-input style='width:100px;' placeholder="輸入檔案名稱" prefix-icon="el-icon-document" v-model="filename"></el-input>
- <el-button style='margin-bottom:20px;' type="primary" icon="document" @click="handleDownload" :loading="downloadLoading">匯出 excel</el-button>
- </div>
- <el-table :data="list" v-loading.body="listLoading" element-loading-text="Loading" border fit highlight-current-row
- style="width: 100%">
-
- {{scope.row.GambleMember.id}}
- <el-table-column label="名稱" align="center">
- <template slot-scope="scope">
- {{scope.row.name}}
- </template>
- </el-table-column>
- <el-table-column label="抽水%" align="center">
- <template slot-scope="scope">
- {{scope.row.feeRatio}}
- </template>
- </el-table-column>
- <el-table-column label="代理商上繳金額" align="center">
- <template slot-scope="scope">
- <span :style="moneyColor(scope.row.all)">{{scope.row.all}}</span>
- </template>
- </el-table-column>
- <el-table-column label="上繳工作室金額70%" align="center">
- <template slot-scope="scope">
- <span :style="moneyColor(scope.row.all70)">{{scope.row.all70}}</span>
- </template>
- </el-table-column>
- <el-table-column align="center" label="操作" width="450">
- <template slot-scope="scope">
- <router-link to="/agent/index/gambleMemberManagement">
- <el-button type="primary" size="mini" icon="el-icon-tickets" @click="handlePage(scope.row)">會員管理</el-button>
- </router-link>
- </template>
- </el-table-column>
- </el-table>
- <div v-show="!listLoading" class="pagination-container">
-
- </div>
- <el-dialog title="創建代理商" :visible.sync="dialogCreateFormVisible" :before-close="handleDialogClose" center>
- <el-form :rules="rules" ref="createForm" :model="createFormData" label-position="left" label-width="100px" style='width: 400px; margin-left:50px;'>
- <el-form-item label="名稱" prop="name">
- <el-input v-model="createFormData.name"></el-input>
- </el-form-item>
- <el-form-item label="抽水 %" prop="feeRatio">
- <el-input v-model="createFormData.feeRatio"></el-input>
- </el-form-item>
- </el-form>
- <div slot="footer" class="dialog-footer">
- <el-button @click="handleDialogClose">取 消</el-button>
- <el-button type="primary" @click="createData">確 定</el-button>
- </div>
- </el-dialog>
- </div>
- <router-view></router-view>
- </div>
- </template>
- <script>
- import { mapGetters, mapActions } from 'vuex'
- import { fetchList, createAgent, fetchMemberList,fetchGroupAll } from '@/api/agnetManagement'
- import waves from '@/directive/waves'
- import moment from 'moment-timezone'
- import _ from 'lodash'
- import { Decimal } from 'decimal.js';
- export default {
- directives: {
- waves
- },
- data() {
- return {
- list: [],
- total: null,
- listLoading: true,
- downloadLoading: false,
- listQuery: {
- page: 1,
- limit: 9999999,
-
-
- },
- filename: '',
- dialogCreateFormVisible: false,
- dialogStatus: '',
-
- rules: {
-
-
-
-
- },
- createFormData: {
- name: '',
- feeRatio: '',
- }
- }
- },
- created() {
- this.SetVisible(1)
- this.getList()
- },
- computed: {
- ...mapGetters([
- 'visible',
- 'data',
- ])
- },
- methods: {
- ...mapActions([
- 'SetVisible',
- 'SetData',
- ]),
- async getList() {
- this.listLoading = true
- await fetchList(this.listQuery).then(response => {
- response.data.rows.map(agent => {
- let combine = []
- this.list = []
- this.visible.firstLayer === true ? fetchGroupAll(agent, this.listQuery).then(response => {
- console.log('response' , response.data.all)
- this.list.push({
-
-
-
-
-
- id: agent.GambleMember.id,
- name: agent.GambleMember.name.slice(19),
- createdAt: agent.GambleMember.createdAt,
- feeRatio: response.data.feeRatio,
- all: response.data.all,
- all70: response.data.all70
- })
- }) : false
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- })
- this.list.sort(function compare(a, b) {
- const dateA = new Date(a.createdAt);
- const dateB = new Date(b.createdAt);
- return dateB - dateA;
- })
-
- this.listLoading = false
- })
- },
- resetCreateData() {
- this.temp = {
- id: undefined,
- name: '',
- chips: '',
- depositChips: ''
- }
- },
- handleCreate() {
- this.resetCreateData()
- this.dialogCreateFormVisible = true
- this.$nextTick(() => {
- this.$refs['createForm'].clearValidate()
- })
- },
- createData() {
- this.$refs['createForm'].validate((valid) => {
- if (valid) {
- createAgent(this.createFormData).then((response) => {
- const agent = response.data.gambleAgentSetting;
- agent.GambleMember = response.data.agent
- this.list.unshift(agent)
- this.dialogCreateFormVisible = false
- this.$notify({
- title: '成功',
- message: '創建成功',
- type: 'success',
- duration: 2000
- })
- })
- }
- })
- },
- handleDownload() {
- this.downloadLoading = true
- import('@/vendor/Export2Excel').then(excel => {
- const tHeader = ['名稱', '抽水%', '代理商上繳金額', '上繳工作室金額70%' ]
- const filterVal = ['name', 'feeRatio', 'all', 'all70' ]
- const list = this.list
- const data = this.formatJson(filterVal, list)
- excel.export_json_to_excel(tHeader, data, this.filename)
- this.downloadLoading = false
- })
- },
- formatJson(filterVal, jsonData) {
- return jsonData.map(v => filterVal.map(j => {
- if (j === 'timestamp') {
- return parseTime(v[j])
- } else {
- return v[j]
- }
- }))
- },
-
-
-
-
-
-
-
-
-
-
-
-
- handleDialogClose() {
- this.dialogCreateFormVisible = false;
- },
- handlePage(row) {
- const temp = Object.assign({}, row)
- this.SetVisible(2)
- this.SetData({layer:2, data: temp})
-
- },
- moneyColor(money) {
- return money >= 0 ? { color: '#67C23A' } : { color: '#FA5555' }
- },
- },
- }
- </script>
|