|
|
@@ -0,0 +1,333 @@
|
|
|
+<template>
|
|
|
+ <div class="agent-profit-commission-page">
|
|
|
+ <div class="commission-panel">
|
|
|
+ <div class="panel-toolbar">
|
|
|
+ <el-button type="primary" icon="el-icon-plus" size="small" @click="handleAdd">新增</el-button>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <el-table v-loading="loading" :data="pagedRows" border class="commission-table" height="calc(100vh - 225px)">
|
|
|
+ <el-table-column type="index" label="序号" width="135" align="center" />
|
|
|
+ <el-table-column prop="name" label="盈亏比例名称" width="180" align="center" />
|
|
|
+ <el-table-column prop="casino" label="真人盈亏比例" min-width="145" align="center">
|
|
|
+ <template slot-scope="{ row }">{{ formatRate(row.casino) }}</template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column prop="electronics" label="电子盈亏比例" min-width="145" align="center">
|
|
|
+ <template slot-scope="{ row }">{{ formatRate(row.electronics) }}</template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column prop="lottery" label="彩票盈亏比例" min-width="145" align="center">
|
|
|
+ <template slot-scope="{ row }">{{ formatRate(row.lottery) }}</template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column prop="sports" label="体育盈亏比例" min-width="145" align="center">
|
|
|
+ <template slot-scope="{ row }">{{ formatRate(row.sports) }}</template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column prop="esports" label="电竞盈亏比例" min-width="145" align="center">
|
|
|
+ <template slot-scope="{ row }">{{ formatRate(row.esports) }}</template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column prop="fishing" label="捕鱼盈亏比例" min-width="145" align="center">
|
|
|
+ <template slot-scope="{ row }">{{ formatRate(row.fishing) }}</template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column prop="chess" label="棋牌盈亏比例" min-width="145" align="center">
|
|
|
+ <template slot-scope="{ row }">{{ formatRate(row.chess) }}</template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="是否默认" width="130" align="center">
|
|
|
+ <template slot-scope="{ row }">
|
|
|
+ <el-tag v-if="row.is_default" type="success" size="mini" effect="plain">是</el-tag>
|
|
|
+ <el-tag v-else type="info" size="mini" effect="plain">否</el-tag>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column prop="created_at" label="创建时间" width="180" align="center" />
|
|
|
+ <el-table-column label="操作" width="150" fixed="right" align="center">
|
|
|
+ <template slot-scope="{ row }">
|
|
|
+ <el-button type="text" size="mini" @click="handleEdit(row)">修改</el-button>
|
|
|
+ <el-button type="text" size="mini" class="danger-action" @click="handleDelete(row)">删除</el-button>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ </el-table>
|
|
|
+
|
|
|
+ <el-pagination
|
|
|
+ background
|
|
|
+ class="commission-pagination"
|
|
|
+ layout="total, sizes, prev, pager, next, jumper"
|
|
|
+ :current-page="page"
|
|
|
+ :page-size="limit"
|
|
|
+ :page-sizes="[10, 20, 50, 100]"
|
|
|
+ :total="rows.length"
|
|
|
+ @size-change="handleSizeChange"
|
|
|
+ @current-change="handleCurrentChange"
|
|
|
+ />
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <el-dialog
|
|
|
+ :title="dialogType === 'add' ? '新增' : '修改'"
|
|
|
+ :visible.sync="dialogVisible"
|
|
|
+ width="50%"
|
|
|
+ top="15vh"
|
|
|
+ @close="resetForm"
|
|
|
+ >
|
|
|
+ <el-form ref="commissionForm" :model="form" :rules="rules" label-width="120px" size="small" class="commission-form">
|
|
|
+ <el-form-item label="盈亏比例名称" prop="name">
|
|
|
+ <el-input v-model="form.name" maxlength="30" placeholder="盈亏比例名称" />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item v-for="field in rateFields" :key="field.prop" :label="field.label" :prop="field.prop">
|
|
|
+ <div class="rate-control">
|
|
|
+ <el-input v-model="form[field.prop]" :placeholder="field.placeholder" />
|
|
|
+ <span class="unit">%</span>
|
|
|
+ </div>
|
|
|
+ </el-form-item>
|
|
|
+ <div class="default-tip">
|
|
|
+ <span>注意:</span>
|
|
|
+ <strong>默认比例仅存在一条,如果勾选默认会覆盖掉已配置过此比例的代理</strong>
|
|
|
+ </div>
|
|
|
+ <el-form-item label="是否默认" prop="is_default" class="default-form-item">
|
|
|
+ <el-radio-group v-model="form.is_default">
|
|
|
+ <el-radio :label="false">否</el-radio>
|
|
|
+ <el-radio :label="true">是</el-radio>
|
|
|
+ </el-radio-group>
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+ <div slot="footer">
|
|
|
+ <el-button size="small" @click="dialogVisible = false">取消</el-button>
|
|
|
+ <el-button type="primary" size="small" @click="submitForm">确定</el-button>
|
|
|
+ </div>
|
|
|
+ </el-dialog>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+const emptyForm = () => ({
|
|
|
+ id: null,
|
|
|
+ name: '',
|
|
|
+ casino: '',
|
|
|
+ electronics: '',
|
|
|
+ lottery: '',
|
|
|
+ sports: '',
|
|
|
+ esports: '',
|
|
|
+ fishing: '',
|
|
|
+ chess: '',
|
|
|
+ is_default: false
|
|
|
+})
|
|
|
+
|
|
|
+export default {
|
|
|
+ name: 'AgentProfitCommission',
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ loading: false,
|
|
|
+ page: 1,
|
|
|
+ limit: 10,
|
|
|
+ dialogVisible: false,
|
|
|
+ dialogType: 'add',
|
|
|
+ form: emptyForm(),
|
|
|
+ rows: [
|
|
|
+ { id: 1, name: '30', casino: 30, electronics: 30, lottery: 30, sports: 30, esports: 30, fishing: 30, chess: 30, is_default: true, created_at: '2026-05-29 19:10:00' },
|
|
|
+ { id: 2, name: '一级代理', casino: 5, electronics: 0, lottery: 0, sports: 0, esports: 0, fishing: 0, chess: 0, is_default: false, created_at: '2025-12-02 23:11:59' },
|
|
|
+ { id: 3, name: '盈亏-官方默认比例', casino: 20, electronics: 10, lottery: 0, sports: 0, esports: 0, fishing: 0, chess: 0, is_default: false, created_at: '2024-11-14 09:02:17' }
|
|
|
+ ],
|
|
|
+ rateFields: [
|
|
|
+ { prop: 'casino', label: '真人盈亏比例', placeholder: '真人盈亏比例' },
|
|
|
+ { prop: 'electronics', label: '电子盈亏比例', placeholder: '电子盈亏比例' },
|
|
|
+ { prop: 'lottery', label: '彩票盈亏比例', placeholder: '彩票盈亏比例' },
|
|
|
+ { prop: 'sports', label: '体育盈亏比例', placeholder: '体育盈亏比例' },
|
|
|
+ { prop: 'esports', label: '电竞盈亏比例', placeholder: '电竞盈亏比例' },
|
|
|
+ { prop: 'fishing', label: '捕鱼盈亏比例', placeholder: '捕鱼盈亏比例' },
|
|
|
+ { prop: 'chess', label: '棋牌盈亏比例', placeholder: '棋牌盈亏比例' }
|
|
|
+ ],
|
|
|
+ rules: {
|
|
|
+ name: [{ required: true, message: '请输入盈亏比例名称', trigger: 'blur' }],
|
|
|
+ casino: [{ required: true, message: '请输入真人盈亏比例', trigger: 'blur' }, { validator: this.validateRate, trigger: 'blur' }],
|
|
|
+ electronics: [{ required: true, message: '请输入电子盈亏比例', trigger: 'blur' }, { validator: this.validateRate, trigger: 'blur' }],
|
|
|
+ lottery: [{ required: true, message: '请输入彩票盈亏比例', trigger: 'blur' }, { validator: this.validateRate, trigger: 'blur' }],
|
|
|
+ sports: [{ required: true, message: '请输入体育盈亏比例', trigger: 'blur' }, { validator: this.validateRate, trigger: 'blur' }],
|
|
|
+ esports: [{ required: true, message: '请输入电竞盈亏比例', trigger: 'blur' }, { validator: this.validateRate, trigger: 'blur' }],
|
|
|
+ fishing: [{ required: true, message: '请输入捕鱼盈亏比例', trigger: 'blur' }, { validator: this.validateRate, trigger: 'blur' }],
|
|
|
+ chess: [{ required: true, message: '请输入棋牌盈亏比例', trigger: 'blur' }, { validator: this.validateRate, trigger: 'blur' }]
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ computed: {
|
|
|
+ pagedRows() {
|
|
|
+ const start = (this.page - 1) * this.limit
|
|
|
+ return this.rows.slice(start, start + this.limit)
|
|
|
+ }
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ validateRate(rule, value, callback) {
|
|
|
+ const rate = Number(value)
|
|
|
+ if (value === '' || Number.isNaN(rate) || rate < 0 || rate > 100) {
|
|
|
+ callback(new Error('请输入0-100之间的比例'))
|
|
|
+ return
|
|
|
+ }
|
|
|
+ callback()
|
|
|
+ },
|
|
|
+ formatRate(value) {
|
|
|
+ return Number(value || 0).toFixed(2).replace(/\.00$/, '')
|
|
|
+ },
|
|
|
+ handleAdd() {
|
|
|
+ this.dialogType = 'add'
|
|
|
+ this.form = emptyForm()
|
|
|
+ this.dialogVisible = true
|
|
|
+ },
|
|
|
+ handleEdit(row) {
|
|
|
+ this.dialogType = 'edit'
|
|
|
+ this.form = { ...row }
|
|
|
+ this.dialogVisible = true
|
|
|
+ },
|
|
|
+ handleDelete(row) {
|
|
|
+ if (row.is_default) {
|
|
|
+ this.$message.warning('默认比例不能删除')
|
|
|
+ return
|
|
|
+ }
|
|
|
+ this.$confirm('确定删除该盈亏佣金比例吗?', '提示', {
|
|
|
+ confirmButtonText: '确定',
|
|
|
+ cancelButtonText: '取消',
|
|
|
+ type: 'warning'
|
|
|
+ }).then(() => {
|
|
|
+ this.rows = this.rows.filter(item => item.id !== row.id)
|
|
|
+ this.$message.success('删除成功')
|
|
|
+ if (this.page > 1 && this.pagedRows.length === 0) this.page -= 1
|
|
|
+ }).catch(() => {})
|
|
|
+ },
|
|
|
+ submitForm() {
|
|
|
+ this.$refs.commissionForm.validate(valid => {
|
|
|
+ if (!valid) return
|
|
|
+ const data = { ...this.form }
|
|
|
+ Object.keys(data).forEach(key => {
|
|
|
+ if (key !== 'name' && key !== 'id' && key !== 'created_at' && key !== 'is_default') data[key] = data[key] === '' ? 0 : Number(data[key])
|
|
|
+ })
|
|
|
+ if (data.is_default) this.rows.forEach(item => { item.is_default = false })
|
|
|
+ if (this.dialogType === 'add') {
|
|
|
+ data.id = Date.now()
|
|
|
+ data.created_at = this.formatDate(new Date())
|
|
|
+ this.rows.push(data)
|
|
|
+ } else {
|
|
|
+ const index = this.rows.findIndex(item => item.id === data.id)
|
|
|
+ if (index > -1) this.$set(this.rows, index, data)
|
|
|
+ }
|
|
|
+ this.dialogVisible = false
|
|
|
+ this.$message.success(this.dialogType === 'add' ? '新增成功' : '修改成功')
|
|
|
+ })
|
|
|
+ },
|
|
|
+ resetForm() {
|
|
|
+ if (this.$refs.commissionForm) this.$refs.commissionForm.resetFields()
|
|
|
+ this.form = emptyForm()
|
|
|
+ },
|
|
|
+ formatDate(date) {
|
|
|
+ const pad = value => String(value).padStart(2, '0')
|
|
|
+ return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())} ${pad(date.getHours())}:${pad(date.getMinutes())}:${pad(date.getSeconds())}`
|
|
|
+ },
|
|
|
+ handleSizeChange(value) {
|
|
|
+ this.limit = value
|
|
|
+ this.page = 1
|
|
|
+ },
|
|
|
+ handleCurrentChange(value) {
|
|
|
+ this.page = value
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+</script>
|
|
|
+
|
|
|
+<style lang="scss" scoped>
|
|
|
+.agent-profit-commission-page {
|
|
|
+ width: 100%;
|
|
|
+ height: 100%;
|
|
|
+ padding: 16px;
|
|
|
+ overflow: hidden;
|
|
|
+ background: #f3f6f8;
|
|
|
+}
|
|
|
+
|
|
|
+.commission-panel {
|
|
|
+ height: 100%;
|
|
|
+ padding: 20px 20px 12px;
|
|
|
+ overflow: hidden;
|
|
|
+ background: #fff;
|
|
|
+ box-shadow: 0 1px 8px rgba(0, 0, 0, 0.08);
|
|
|
+}
|
|
|
+
|
|
|
+.panel-toolbar {
|
|
|
+ height: 44px;
|
|
|
+}
|
|
|
+
|
|
|
+.commission-table {
|
|
|
+ width: 100%;
|
|
|
+
|
|
|
+ ::v-deep th {
|
|
|
+ height: 44px;
|
|
|
+ color: #7b8794;
|
|
|
+ font-weight: 600;
|
|
|
+ background: #fff;
|
|
|
+ }
|
|
|
+
|
|
|
+ ::v-deep td {
|
|
|
+ height: 45px;
|
|
|
+ color: #334155;
|
|
|
+ }
|
|
|
+
|
|
|
+ ::v-deep .el-tag--success {
|
|
|
+ color: #13b6ad;
|
|
|
+ background: #e9fbfb;
|
|
|
+ border-color: #b7eeee;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+.commission-pagination {
|
|
|
+ padding-top: 12px;
|
|
|
+ text-align: right;
|
|
|
+}
|
|
|
+
|
|
|
+.commission-form {
|
|
|
+ padding: 4px 16px 0;
|
|
|
+
|
|
|
+ ::v-deep .el-form-item {
|
|
|
+ margin-bottom: 24px;
|
|
|
+ }
|
|
|
+
|
|
|
+ ::v-deep .el-form-item__label {
|
|
|
+ color: #606266;
|
|
|
+ }
|
|
|
+
|
|
|
+ ::v-deep .el-input__inner {
|
|
|
+ height: 36px;
|
|
|
+ line-height: 36px;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+.rate-control {
|
|
|
+ display: flex;
|
|
|
+ align-items: stretch;
|
|
|
+
|
|
|
+ .el-input {
|
|
|
+ flex: 1;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+.unit {
|
|
|
+ display: flex;
|
|
|
+ width: 56px;
|
|
|
+ align-items: center;
|
|
|
+ justify-content: center;
|
|
|
+ color: #909399;
|
|
|
+ background: #f5f7fa;
|
|
|
+ border: 1px solid #dcdfe6;
|
|
|
+ border-left: 0;
|
|
|
+ border-radius: 0 4px 4px 0;
|
|
|
+}
|
|
|
+
|
|
|
+.default-tip {
|
|
|
+ margin: -2px 0 24px 76px;
|
|
|
+ color: #606266;
|
|
|
+ line-height: 24px;
|
|
|
+
|
|
|
+ strong {
|
|
|
+ margin-left: 10px;
|
|
|
+ color: #f5222d;
|
|
|
+ font-size: 16px;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+.default-form-item {
|
|
|
+ margin-bottom: 0 !important;
|
|
|
+}
|
|
|
+
|
|
|
+.danger-action {
|
|
|
+ color: #f56c6c;
|
|
|
+}
|
|
|
+</style>
|