|
@ -6,27 +6,28 @@ import axios from 'axios' |
|
|
import { ElMessageBox } from 'element-plus' |
|
|
import { ElMessageBox } from 'element-plus' |
|
|
import API from '@/util/http' |
|
|
import API from '@/util/http' |
|
|
import { uploadFile } from '@/util/request'; |
|
|
import { uploadFile } from '@/util/request'; |
|
|
|
|
|
import request from '@/util/http' |
|
|
import moment from 'moment' |
|
|
import moment from 'moment' |
|
|
import { range, re } from 'mathjs' |
|
|
|
|
|
|
|
|
import { e, range, re } from 'mathjs' |
|
|
import { utils, read } from 'xlsx' |
|
|
import { utils, read } from 'xlsx' |
|
|
import throttle from 'lodash/throttle' |
|
|
import throttle from 'lodash/throttle' |
|
|
|
|
|
|
|
|
|
|
|
import { useAdminStore } from "@/store/index.js"; |
|
|
|
|
|
import { storeToRefs } from "pinia"; |
|
|
const user = ref({}) |
|
|
const user = ref({}) |
|
|
const getUser = async function (jwcode) { |
|
|
const getUser = async function (jwcode) { |
|
|
if (addForm.value.jwcode) { |
|
|
if (addForm.value.jwcode) { |
|
|
addForm.value.jwcode = addForm.value.jwcode.replace(/\s/g, ''); |
|
|
addForm.value.jwcode = addForm.value.jwcode.replace(/\s/g, ''); |
|
|
|
|
|
} else { |
|
|
|
|
|
ElMessage.error('请先输入精网号') |
|
|
|
|
|
return false |
|
|
} |
|
|
} |
|
|
try { |
|
|
try { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const result = await API({ |
|
|
const result = await API({ |
|
|
url: '/user/selectUser', |
|
|
|
|
|
|
|
|
url: '/beanUser/userCard', |
|
|
data: { |
|
|
data: { |
|
|
jwcode: addForm.value.jwcode |
|
|
jwcode: addForm.value.jwcode |
|
|
} |
|
|
} |
|
|
}) |
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (result.code === 0) { |
|
|
if (result.code === 0) { |
|
|
ElMessage.error(result.msg); |
|
|
ElMessage.error(result.msg); |
|
|
} else if (result.data === null) { |
|
|
} else if (result.data === null) { |
|
@ -48,87 +49,70 @@ const addForm = ref({ |
|
|
remark: '', |
|
|
remark: '', |
|
|
adminId: '' |
|
|
adminId: '' |
|
|
}) |
|
|
}) |
|
|
const Ref = ref(null) |
|
|
|
|
|
|
|
|
|
|
|
// const rules = reactive({ |
|
|
|
|
|
// jwcode: [{ required: true, validator: validateJwCode, trigger: 'blur' }], |
|
|
|
|
|
// gode: [ |
|
|
|
|
|
// { required: true, message: '请输入永久金币数', trigger: 'blur' }, |
|
|
|
|
|
// { |
|
|
|
|
|
// validator: (rule, value, callback) => { |
|
|
|
|
|
// // 检查是否包含特殊符号 |
|
|
|
|
|
// if (/[^0-9.]/.test(value)) { |
|
|
|
|
|
// callback(new Error('不能包含特殊符号或负数')); |
|
|
|
|
|
// return; |
|
|
|
|
|
// } |
|
|
|
|
|
|
|
|
const formRef = ref(null) |
|
|
|
|
|
const adminStore = useAdminStore() |
|
|
|
|
|
const { adminData } = storeToRefs(adminStore) |
|
|
|
|
|
const rules = reactive({ |
|
|
|
|
|
jwcode: [ |
|
|
|
|
|
{ required: true, message: '请输入精网号', trigger: 'blur' }, |
|
|
|
|
|
{ |
|
|
|
|
|
validator: (rule, value, callback) => { |
|
|
|
|
|
if (!value) { |
|
|
|
|
|
callback(new Error('精网号不能为空')); |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
if (/[^0-9]/.test(value)) { |
|
|
|
|
|
callback(new Error('精网号只能包含数字')); |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
callback(); |
|
|
|
|
|
}, trigger: 'blur' |
|
|
|
|
|
}], |
|
|
|
|
|
gode: [ |
|
|
|
|
|
{ required: true, message: '请输入永久金豆数', trigger: 'blur' }, |
|
|
|
|
|
{ |
|
|
|
|
|
validator: (rule, value, callback) => { |
|
|
|
|
|
// 检查是否为非负整数 |
|
|
|
|
|
if (!/^\d+$/.test(value)) { |
|
|
|
|
|
callback(new Error('请输入非负整数')); |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
// // 检查整数位数 |
|
|
|
|
|
// const integerPart = value.split('.')[0]; |
|
|
|
|
|
// if (integerPart.length > 6) { |
|
|
|
|
|
// callback(new Error('整数位数不能超过6位')); |
|
|
|
|
|
// return; |
|
|
|
|
|
// } |
|
|
|
|
|
|
|
|
// 检查位数 |
|
|
|
|
|
if (value.length > 6) { |
|
|
|
|
|
callback(new Error('整数位数不能超过6位')); |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
callback(); |
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
// // 检查小数位数 |
|
|
|
|
|
// if (value.includes('.')) { |
|
|
|
|
|
// const decimalPart = value.split('.')[1]; |
|
|
|
|
|
// if (decimalPart.length > 2) { |
|
|
|
|
|
// callback(new Error('小数位数不能超过两位')); |
|
|
|
|
|
// return; |
|
|
|
|
|
// } |
|
|
|
|
|
// } |
|
|
|
|
|
|
|
|
|
|
|
// const numValue = Number(value); |
|
|
|
|
|
// if (isNaN(numValue)) { |
|
|
|
|
|
// callback(new Error('请输入有效的数字')); |
|
|
|
|
|
// } else if (numValue < 0) { |
|
|
|
|
|
// callback(new Error('输入金额不能小于0')); |
|
|
|
|
|
// } else { |
|
|
|
|
|
// callback(); |
|
|
|
|
|
// } |
|
|
|
|
|
// }, |
|
|
|
|
|
// trigger: 'blur' |
|
|
|
|
|
// } |
|
|
|
|
|
// ], |
|
|
|
|
|
// freeGode: [ |
|
|
|
|
|
// { required: true, message: '请输入免费金币数', trigger: 'blur' }, |
|
|
|
|
|
// { |
|
|
|
|
|
// validator: (rule, value, callback) => { |
|
|
|
|
|
// // 检查是否包含特殊符号 |
|
|
|
|
|
// if (/[^0-9.]/.test(value)) { |
|
|
|
|
|
// callback(new Error('不能包含特殊符号或负数')); |
|
|
|
|
|
// return; |
|
|
|
|
|
// } |
|
|
|
|
|
|
|
|
|
|
|
// // 检查整数位数 |
|
|
|
|
|
// const integerPart = value.split('.')[0]; |
|
|
|
|
|
// if (integerPart.length > 6) { |
|
|
|
|
|
// callback(new Error('整数位数不能超过6位')); |
|
|
|
|
|
// return; |
|
|
|
|
|
// } |
|
|
|
|
|
|
|
|
|
|
|
// // 检查小数位数 |
|
|
|
|
|
// if (value.includes('.')) { |
|
|
|
|
|
// const decimalPart = value.split('.')[1]; |
|
|
|
|
|
// if (decimalPart.length > 2) { |
|
|
|
|
|
// callback(new Error('小数位数不能超过两位')); |
|
|
|
|
|
// return; |
|
|
|
|
|
// } |
|
|
|
|
|
// } |
|
|
|
|
|
|
|
|
trigger: 'blur' |
|
|
|
|
|
} |
|
|
|
|
|
], |
|
|
|
|
|
freeGode: [ |
|
|
|
|
|
{ required: true, message: '请输入免费金豆数', trigger: 'blur' }, |
|
|
|
|
|
{ |
|
|
|
|
|
validator: (rule, value, callback) => { |
|
|
|
|
|
// 检查是否为非负整数 |
|
|
|
|
|
if (!/^\d+$/.test(value)) { |
|
|
|
|
|
callback(new Error('请输入非负整数')); |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
// const numValue = Number(value); |
|
|
|
|
|
// if (isNaN(numValue)) { |
|
|
|
|
|
// callback(new Error('请输入有效的数字')); |
|
|
|
|
|
// } else if (numValue < 0) { |
|
|
|
|
|
// callback(new Error('输入金额不能小于0')); |
|
|
|
|
|
// } else { |
|
|
|
|
|
// callback(); |
|
|
|
|
|
// } |
|
|
|
|
|
// }, |
|
|
|
|
|
// trigger: 'blur' |
|
|
|
|
|
// } |
|
|
|
|
|
// ], |
|
|
|
|
|
// }); |
|
|
|
|
|
|
|
|
// 检查位数 |
|
|
|
|
|
if (value.length > 6) { |
|
|
|
|
|
callback(new Error('整数位数不能超过6位')); |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
callback(); |
|
|
|
|
|
}, |
|
|
|
|
|
trigger: 'blur' |
|
|
|
|
|
} |
|
|
|
|
|
], |
|
|
|
|
|
remark: [ |
|
|
|
|
|
{ required: true, message: '请输入备注', trigger: 'blur' } |
|
|
|
|
|
] |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
//重置表单 |
|
|
//重置表单 |
|
|
const deleteAddForm = function () { |
|
|
const deleteAddForm = function () { |
|
@ -141,118 +125,110 @@ const deleteAddForm = function () { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
const handleAddForm = () => { |
|
|
|
|
|
|
|
|
const handleAddForm = async () => { |
|
|
|
|
|
try { |
|
|
|
|
|
await new Promise((resolve, reject) => { |
|
|
|
|
|
formRef.value.validate((valid) => { |
|
|
|
|
|
if (valid) { |
|
|
|
|
|
if (Number(addForm.value.gode) === 0 && Number(addForm.value.freeGode) === 0) { |
|
|
|
|
|
reject(new Error('永久金豆和付费金豆不能同时为0')); |
|
|
|
|
|
} |
|
|
|
|
|
resolve(); // 验证通过,继续执行后续代码 |
|
|
|
|
|
} else { |
|
|
|
|
|
reject(new Error('请检查并完善表单信息')); // 验证失败,抛出错误 |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
}); |
|
|
|
|
|
console.log('adminData', adminData.value); |
|
|
|
|
|
|
|
|
|
|
|
const result = await request({ |
|
|
|
|
|
url: '/bean/add', |
|
|
|
|
|
data: { |
|
|
|
|
|
jwcode: addForm.value.jwcode, |
|
|
|
|
|
gode: addForm.value.gode, |
|
|
|
|
|
freeGode: addForm.value.freeGode, |
|
|
|
|
|
remark: addForm.value.remark, |
|
|
|
|
|
adminId: adminData.adminId |
|
|
|
|
|
} |
|
|
|
|
|
}) |
|
|
|
|
|
} catch (error) { |
|
|
|
|
|
console.log('金豆新增充值失败'); |
|
|
|
|
|
ElMessage.error(error.message || '操作失败'); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
</script> |
|
|
</script> |
|
|
<template> |
|
|
<template> |
|
|
<div> |
|
|
<div> |
|
|
<el-form :model="addForm" ref="Ref" label-width="auto" style="max-width: 600px" class="add-form"> |
|
|
|
|
|
<el-form-item prop="jwcode" label="精网号"> |
|
|
|
|
|
|
|
|
<el-form :model="addForm" :rules="rules" ref="formRef" label-width="auto" style="max-width: 600px" class="add-form"> |
|
|
|
|
|
<el-form-item prop="jwcode" label="精网号" label-position="left"> |
|
|
<el-input v-model="addForm.jwcode" style="width: 220px" /> |
|
|
<el-input v-model="addForm.jwcode" style="width: 220px" /> |
|
|
<el-button type="primary" @click="getUser(addForm.jwcode)" style="margin-left: 20px">查询</el-button> |
|
|
<el-button type="primary" @click="getUser(addForm.jwcode)" style="margin-left: 20px">查询</el-button> |
|
|
</el-form-item> |
|
|
</el-form-item> |
|
|
|
|
|
|
|
|
<el-form-item prop="permanentGold" label="付费金豆"> |
|
|
|
|
|
|
|
|
<el-form-item prop="gode" label="付费金豆" label-position="left"> |
|
|
<el-input v-model="addForm.gode" style="width: 100px" /> |
|
|
<el-input v-model="addForm.gode" style="width: 100px" /> |
|
|
<p>个</p> |
|
|
|
|
|
|
|
|
|
|
|
</el-form-item> |
|
|
</el-form-item> |
|
|
<el-form-item prop="freeGold" label="免费金豆"> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<el-form-item prop="freeGode" label="免费金豆" label-position="left"> |
|
|
<el-input v-model="addForm.freeGode" style="width: 100px" /> |
|
|
<el-input v-model="addForm.freeGode" style="width: 100px" /> |
|
|
<p>个</p> |
|
|
|
|
|
</el-form-item> |
|
|
</el-form-item> |
|
|
<el-form-item prop="remark" label="备注"> |
|
|
|
|
|
<el-input v-model="addForm.remark" style="width: 300px" :rows="2" maxlength="100" show-word-limit |
|
|
|
|
|
|
|
|
<el-form-item prop="remark" label="备注" label-position="left"> |
|
|
|
|
|
<el-input v-model="addForm.remark" style="width: 300px" :rows="5" maxlength="100" show-word-limit |
|
|
type="textarea" /> |
|
|
type="textarea" /> |
|
|
</el-form-item> |
|
|
</el-form-item> |
|
|
<el-form-item prop="adminId" label="提交人"> |
|
|
|
|
|
|
|
|
<!-- <el-form-item prop="adminId" label="提交人"> |
|
|
<el-input style="width: 300px" :value="adminData.adminName" disabled placeholder="提交人姓名" /> |
|
|
<el-input style="width: 300px" :value="adminData.adminName" disabled placeholder="提交人姓名" /> |
|
|
</el-form-item> |
|
|
|
|
|
|
|
|
</el-form-item> --> |
|
|
<el-button @click="deleteAddForm" style="margin-left: 280px" type="success">重置</el-button> |
|
|
<el-button @click="deleteAddForm" style="margin-left: 280px" type="success">重置</el-button> |
|
|
<el-button type="primary" @click="handleAddForm"> 提交 </el-button> |
|
|
<el-button type="primary" @click="handleAddForm"> 提交 </el-button> |
|
|
</el-form> |
|
|
</el-form> |
|
|
|
|
|
|
|
|
<!-- 客户信息栏 --> |
|
|
<!-- 客户信息栏 --> |
|
|
<el-card v-if="user.jwcode" style="width: 800px; float: right" class="customer-info"> |
|
|
|
|
|
|
|
|
<el-card v-if="user.jwcode" style="width: 800px; float: right" class="customer-info"> |
|
|
<el-form :model="user" label-width="auto" style="max-width: 1000px" label-position="left"> |
|
|
<el-form :model="user" label-width="auto" style="max-width: 1000px" label-position="left"> |
|
|
<el-text size="large" style="margin-left: 20px">客户信息</el-text> |
|
|
<el-text size="large" style="margin-left: 20px">客户信息</el-text> |
|
|
|
|
|
|
|
|
<!-- 第一行:姓名 + 历史金币 --> |
|
|
|
|
|
|
|
|
<!-- 第一行:姓名 + 当前付费金豆 --> |
|
|
<el-row style="margin-top: 20px"> |
|
|
<el-row style="margin-top: 20px"> |
|
|
<el-col :span="9"> |
|
|
<el-col :span="9"> |
|
|
<el-form-item label="姓名:"> |
|
|
<el-form-item label="姓名:"> |
|
|
<p>{{ user.name }}</p> |
|
|
|
|
|
|
|
|
<p style="color: #2fa1ff; margin-right: 5px">{{ user.name }}</p> |
|
|
</el-form-item> |
|
|
</el-form-item> |
|
|
</el-col> |
|
|
</el-col> |
|
|
<el-col :span="14"> |
|
|
<el-col :span="14"> |
|
|
<el-form-item label="历史金币总数"> |
|
|
|
|
|
<!-- 检查 user.historySumGold 是否为有效的数字 --> |
|
|
|
|
|
<p style="color: #2fa1ff; margin-right: 5px" v-if="!isNaN(Number(user.historySumGold))"> |
|
|
|
|
|
{{ Number(user.historySumGold) / 100 }} |
|
|
|
|
|
|
|
|
<el-form-item label="当前付费金豆:"> |
|
|
|
|
|
<p style="color: #2fa1ff; margin-right: 5px" v-if="!isNaN(Number(user.permanentBean))"> |
|
|
|
|
|
{{ Number(user.permanentBean) }} |
|
|
</p> |
|
|
</p> |
|
|
|
|
|
|
|
|
<!-- 如果不是有效的数字,显示默认值 --> |
|
|
<!-- 如果不是有效的数字,显示默认值 --> |
|
|
<p v-else></p> |
|
|
<p v-else></p> |
|
|
</el-form-item> |
|
|
</el-form-item> |
|
|
<el-form-item style="margin-top: -23px"> |
|
|
|
|
|
<span style="display: inline; white-space: nowrap; color: #b1b1b1" |
|
|
|
|
|
v-if="user.historyPermanentGold !== undefined">(永久金币:{{ user.historyPermanentGold / 100 }};免费金币:{{ |
|
|
|
|
|
(user.historyFreeGold) / 100 |
|
|
|
|
|
}};任务金币:{{ user.historyTaskGold / 100 }})</span> |
|
|
|
|
|
</el-form-item> |
|
|
|
|
|
</el-col> |
|
|
</el-col> |
|
|
</el-row> |
|
|
</el-row> |
|
|
|
|
|
|
|
|
<!-- 第二行:精网号 + 当前金币(独立行) --> |
|
|
|
|
|
<el-row style="margin-top:-23px"> |
|
|
|
|
|
|
|
|
<!-- 第二行:精网号 + 免费金豆 --> |
|
|
|
|
|
<el-row > |
|
|
<el-col :span="9"> |
|
|
<el-col :span="9"> |
|
|
<el-form-item label="精网号"> |
|
|
<el-form-item label="精网号"> |
|
|
<p>{{ user.jwcode }}</p> |
|
|
|
|
|
|
|
|
<p style="color: #2fa1ff; margin-right: 5px">{{ user.jwcode }}</p> |
|
|
</el-form-item> |
|
|
</el-form-item> |
|
|
</el-col> |
|
|
</el-col> |
|
|
<el-col :span="14"> |
|
|
<el-col :span="14"> |
|
|
<el-form-item label="当前金币总数" style="width: 500px"> |
|
|
|
|
|
<span style="color: #2fa1ff; margin-right: 5px" v-if="user.nowSumGold !== undefined">{{ user.nowSumGold |
|
|
|
|
|
/100}}</span> |
|
|
|
|
|
</el-form-item> |
|
|
|
|
|
<!-- 金币详情独立显示 --> |
|
|
|
|
|
<el-form-item style="margin-top: -23px"> <!-- 负边距减少间距 --> |
|
|
|
|
|
<span style="color: #b1b1b1; margin-left: 0px" v-if="user.nowPermanentGold !== undefined">(永久金币:{{ |
|
|
|
|
|
user.nowPermanentGold /100}}; |
|
|
|
|
|
免费金币:{{ user.nowFreeGold / 100 }}; |
|
|
|
|
|
任务金币:{{ user.nowTaskGold / 100 }})</span> |
|
|
|
|
|
|
|
|
<el-form-item label="当前免费金豆:"> |
|
|
|
|
|
<span style="color: #2fa1ff; margin-right: 5px" v-if="user.freeBean !== undefined">{{ user.freeBean }} |
|
|
|
|
|
</span> |
|
|
</el-form-item> |
|
|
</el-form-item> |
|
|
</el-col> |
|
|
</el-col> |
|
|
</el-row> |
|
|
</el-row> |
|
|
|
|
|
|
|
|
<!-- 第三行:首次充值日期 + 充值次数 --> |
|
|
|
|
|
<el-row style="margin-top:-23px"> |
|
|
|
|
|
<el-col :span="9"> |
|
|
|
|
|
<el-form-item label="首次充值日期"> |
|
|
|
|
|
<p v-if="user.firstRecharge"> |
|
|
|
|
|
{{ moment(user.firstRecharge).format('YYYY-MM-DD HH:mm:ss') }} |
|
|
|
|
|
</p> |
|
|
|
|
|
</el-form-item> |
|
|
|
|
|
</el-col> |
|
|
|
|
|
<el-col :span="14"> |
|
|
|
|
|
<el-form-item label="充值次数"> |
|
|
|
|
|
<p style="color: #2fa1ff">{{ user.rechargeNum }}</p> |
|
|
|
|
|
</el-form-item> |
|
|
|
|
|
</el-col> |
|
|
|
|
|
</el-row> |
|
|
|
|
|
|
|
|
|
|
|
<!-- 第四行:消费次数 + 所属门店 --> |
|
|
|
|
|
|
|
|
<!-- 第三行:消费次数 + 所属门店 --> |
|
|
<el-row> |
|
|
<el-row> |
|
|
<el-col :span="9"> |
|
|
<el-col :span="9"> |
|
|
<el-form-item label="消费次数"> |
|
|
|
|
|
<p style="color: #2fa1ff">{{ user.consumeNum }}</p> |
|
|
|
|
|
|
|
|
<el-form-item label="所属门店"> |
|
|
|
|
|
<p style="color: #2fa1ff">{{ user.market }}</p> |
|
|
</el-form-item> |
|
|
</el-form-item> |
|
|
</el-col> |
|
|
</el-col> |
|
|
<el-col :span="9"> |
|
|
<el-col :span="9"> |
|
|
<el-form-item label="所属门店"> |
|
|
|
|
|
<p>{{ user.market }}</p> |
|
|
|
|
|
|
|
|
<el-form-item label="消费次数"> |
|
|
|
|
|
<p style="color: #2fa1ff; margin-right: 5px" v-if="user.consumeNum!=null">{{ user.consumeNum }}</p> |
|
|
|
|
|
<p style="color: #2fa1ff; margin-right: 5px" v-else>{{ 0 }}</p> |
|
|
</el-form-item> |
|
|
</el-form-item> |
|
|
</el-col> |
|
|
</el-col> |
|
|
</el-row> |
|
|
</el-row> |
|
@ -262,4 +238,22 @@ const handleAddForm = () => { |
|
|
|
|
|
|
|
|
</div> |
|
|
</div> |
|
|
</template> |
|
|
</template> |
|
|
<style></style> |
|
|
|
|
|
|
|
|
<style scoped> |
|
|
|
|
|
.add-form { |
|
|
|
|
|
margin-top: 50px; |
|
|
|
|
|
max-width: 50%; |
|
|
|
|
|
float: left; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
.customer-info { |
|
|
|
|
|
max-width: 60%; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
p { |
|
|
|
|
|
margin: 0px; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
.el-form-item { |
|
|
|
|
|
margin-left: 50px; |
|
|
|
|
|
} |
|
|
|
|
|
</style> |