|
@ -15,25 +15,19 @@ const { adminData, menuTree } = storeToRefs(adminStore); |
|
|
const trimJwCode = () => { |
|
|
const trimJwCode = () => { |
|
|
if (addConsume.value.jwcode) { |
|
|
if (addConsume.value.jwcode) { |
|
|
// 去除所有空格,并尝试转换为整数 |
|
|
// 去除所有空格,并尝试转换为整数 |
|
|
const trimmed = addConsume.value.jwcode.toString().replace(/\s/g, ''); |
|
|
|
|
|
const numeric = Number(trimmed); |
|
|
|
|
|
|
|
|
const trimmed = addConsume.value.jwcode.toString().replace(/\s/g, '') |
|
|
|
|
|
const numeric = Number(trimmed) |
|
|
|
|
|
|
|
|
// 如果转换为数字成功,保存为数字,否则提示错误 |
|
|
// 如果转换为数字成功,保存为数字,否则提示错误 |
|
|
if (!isNaN(numeric)) { |
|
|
if (!isNaN(numeric)) { |
|
|
addConsume.value.jwcode = numeric; |
|
|
|
|
|
|
|
|
addConsume.value.jwcode = numeric |
|
|
} else { |
|
|
} else { |
|
|
ElMessage.error("精网号格式不正确,请输入数字"); |
|
|
|
|
|
|
|
|
ElMessage.error("精网号格式不正确,请输入数字") |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
//提交禁止重复点击 |
|
|
//提交禁止重复点击 |
|
|
const addDisabled = ref(false) |
|
|
const addDisabled = ref(false) |
|
|
/* |
|
|
|
|
|
====================数据================================= |
|
|
|
|
|
*/ |
|
|
|
|
|
//这是获取当前登录的用户信息 |
|
|
|
|
|
// const adminData = ref({}); |
|
|
|
|
|
|
|
|
|
|
|
// 通过精网号查询用户(客户)信息 表单 |
|
|
// 通过精网号查询用户(客户)信息 表单 |
|
|
const user = ref({ |
|
|
const user = ref({ |
|
|
jwcode: null, |
|
|
jwcode: null, |
|
@ -65,14 +59,12 @@ const addConsume = ref({ |
|
|
taskGold: null, // 任务金币 |
|
|
taskGold: null, // 任务金币 |
|
|
remark: "",//备注 |
|
|
remark: "",//备注 |
|
|
adminId: null,// 当前管理员id |
|
|
adminId: null,// 当前管理员id |
|
|
}); |
|
|
|
|
|
// 表单验证 |
|
|
|
|
|
const Ref = ref(null); |
|
|
|
|
|
// 表单验证规则 |
|
|
|
|
|
|
|
|
adminName: null,// 当前管理员姓名 |
|
|
|
|
|
}) |
|
|
|
|
|
const Ref = ref(null) |
|
|
const rules = reactive({ |
|
|
const rules = reactive({ |
|
|
jwcode: [ |
|
|
jwcode: [ |
|
|
{ required: true, message: "请输入精网号", trigger: "blur" }, |
|
|
{ required: true, message: "请输入精网号", trigger: "blur" }, |
|
|
// { type: 'number', message: "精网号必须为数字", trigger: "blur" } |
|
|
|
|
|
], |
|
|
], |
|
|
goodsName: [{ required: true, message: "请选择商品", trigger: "blur" }], |
|
|
goodsName: [{ required: true, message: "请选择商品", trigger: "blur" }], |
|
|
sumGold: [ |
|
|
sumGold: [ |
|
@ -83,7 +75,7 @@ const rules = reactive({ |
|
|
const isValid = /^(0\.\d{1,2})|([1-9]\d*(\.\d{1,2})?)$/.test(value); |
|
|
const isValid = /^(0\.\d{1,2})|([1-9]\d*(\.\d{1,2})?)$/.test(value); |
|
|
|
|
|
|
|
|
if (!isValid) { |
|
|
if (!isValid) { |
|
|
callback(new Error("请输入大于0的正数(可包含最多两位小数)")); |
|
|
|
|
|
|
|
|
callback(new Error("请输入大于0的正数(可包含最多两位小数)")); |
|
|
} else { |
|
|
} else { |
|
|
callback(); |
|
|
callback(); |
|
|
} |
|
|
} |
|
@ -93,30 +85,7 @@ const rules = reactive({ |
|
|
] |
|
|
] |
|
|
}); |
|
|
}); |
|
|
// 查询商品的表单 |
|
|
// 查询商品的表单 |
|
|
const goods = ref([]); |
|
|
|
|
|
|
|
|
|
|
|
/* |
|
|
|
|
|
====================方法================================= |
|
|
|
|
|
*/ |
|
|
|
|
|
const getAdminData = async function () { |
|
|
|
|
|
try {//await 暂停函数执行,直到请求完成 |
|
|
|
|
|
const result = await request({ |
|
|
|
|
|
url: "/admin/userinfo", |
|
|
|
|
|
data: {}, |
|
|
|
|
|
}); |
|
|
|
|
|
adminData.value = result; |
|
|
|
|
|
addConsume.value.adminId = adminData.value.id; |
|
|
|
|
|
|
|
|
|
|
|
addConsume.value.name = adminData.value.adminName; |
|
|
|
|
|
|
|
|
|
|
|
console.log("请求成功", result); |
|
|
|
|
|
console.log("用户信息", adminData.value); |
|
|
|
|
|
} catch (error) { |
|
|
|
|
|
console.log("请求失败", error); |
|
|
|
|
|
} |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const goods = ref([]) |
|
|
// 输入验证函数 |
|
|
// 输入验证函数 |
|
|
function validateInput() { |
|
|
function validateInput() { |
|
|
const sumGold = parseFloat(addConsume.value.sumGold); |
|
|
const sumGold = parseFloat(addConsume.value.sumGold); |
|
@ -261,16 +230,16 @@ const add = async function () { |
|
|
//value 为当前消耗时间 |
|
|
//value 为当前消耗时间 |
|
|
WriteCookiesTime.value = dayjs().format("YYYY-MM-DD HH:mm:ss"); |
|
|
WriteCookiesTime.value = dayjs().format("YYYY-MM-DD HH:mm:ss"); |
|
|
// 设置cookies,用户jwcode为key,value也是jwcode,过期时间为1天 |
|
|
// 设置cookies,用户jwcode为key,value也是jwcode,过期时间为1天 |
|
|
Cookies.set(WriteCookies.value, WriteCookiesTime.value, {expires: |
|
|
|
|
|
1, path: '/'}); |
|
|
|
|
|
|
|
|
Cookies.set(WriteCookies.value, WriteCookiesTime.value, { |
|
|
|
|
|
expires: |
|
|
|
|
|
1, path: '/' |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
addDisabled.value = true |
|
|
addDisabled.value = true |
|
|
// 发送POST请求 |
|
|
// 发送POST请求 |
|
|
const result = await request({ |
|
|
const result = await request({ |
|
|
// url: "/consume/add", |
|
|
|
|
|
url: "/consume/add", |
|
|
url: "/consume/add", |
|
|
data: { |
|
|
data: { |
|
|
...addConsume.value, |
|
|
|
|
|
jwcode: addConsume.value.jwcode, |
|
|
jwcode: addConsume.value.jwcode, |
|
|
adminId: addConsume.value.adminId, |
|
|
adminId: addConsume.value.adminId, |
|
|
sumGold: addConsume.value.sumGold * 100, |
|
|
sumGold: addConsume.value.sumGold * 100, |
|
@ -278,9 +247,10 @@ const add = async function () { |
|
|
taskGold: addConsume.value.taskGold * 100, |
|
|
taskGold: addConsume.value.taskGold * 100, |
|
|
permanentGold: addConsume.value.permanentGold * 100, |
|
|
permanentGold: addConsume.value.permanentGold * 100, |
|
|
goodsName: addConsume.value.goodsName, |
|
|
goodsName: addConsume.value.goodsName, |
|
|
remark: addConsume.value.remark |
|
|
|
|
|
|
|
|
remark: addConsume.value.remark, |
|
|
|
|
|
adminName: adminData.value.adminName |
|
|
} |
|
|
} |
|
|
}); |
|
|
|
|
|
|
|
|
}) |
|
|
addDisabled.value = false |
|
|
addDisabled.value = false |
|
|
console.log("add请求", result); |
|
|
console.log("add请求", result); |
|
|
// 处理响应 |
|
|
// 处理响应 |
|
@ -318,7 +288,7 @@ function resetForm() { |
|
|
remark: "", |
|
|
remark: "", |
|
|
adminId: adminData.value.id, |
|
|
adminId: adminData.value.id, |
|
|
adminName: adminData.value.adminName, |
|
|
adminName: adminData.value.adminName, |
|
|
}; |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
console.log("重置表单") |
|
|
console.log("重置表单") |
|
|
|
|
|
|
|
@ -425,7 +395,6 @@ const addBefore = () => { |
|
|
}); |
|
|
}); |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 查询客户信息(通过精网号) |
|
|
// 查询客户信息(通过精网号) |
|
|
const getUser = async function (jwcode) { |
|
|
const getUser = async function (jwcode) { |
|
|
try { |
|
|
try { |
|
@ -545,9 +514,10 @@ watch( |
|
|
*/ |
|
|
*/ |
|
|
// 挂载 |
|
|
// 挂载 |
|
|
onMounted(async function () { |
|
|
onMounted(async function () { |
|
|
await getAdminData(); |
|
|
|
|
|
await getGoods(); |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
await getGoods() |
|
|
|
|
|
console.log('adminData', adminData.value) |
|
|
|
|
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
</script> |
|
|
</script> |
|
|
|
|
|
|
|
@ -592,8 +562,8 @@ onMounted(async function () { |
|
|
</el-form-item> |
|
|
</el-form-item> |
|
|
|
|
|
|
|
|
<el-form-item prop="remark" label="备注"> |
|
|
<el-form-item prop="remark" label="备注"> |
|
|
<el-input v-model="addConsume.remark" style="width: 13.5vw;margin-left:70px" :rows="4" maxlength="100" show-word-limit |
|
|
|
|
|
type="textarea" /> |
|
|
|
|
|
|
|
|
<el-input v-model="addConsume.remark" style="width: 13.5vw;margin-left:70px" :rows="4" maxlength="100" |
|
|
|
|
|
show-word-limit type="textarea" /> |
|
|
</el-form-item> |
|
|
</el-form-item> |
|
|
|
|
|
|
|
|
<el-button type="success" @click="resetForm()" style="margin-left: 200px;margin-top:10px">重置</el-button> |
|
|
<el-button type="success" @click="resetForm()" style="margin-left: 200px;margin-top:10px">重置</el-button> |
|
@ -685,13 +655,8 @@ onMounted(async function () { |
|
|
</el-row> |
|
|
</el-row> |
|
|
</el-form> |
|
|
</el-form> |
|
|
</el-card> |
|
|
</el-card> |
|
|
<el-dialog |
|
|
|
|
|
v-model="ConsumeDialogVisible" |
|
|
|
|
|
title="操作确认" |
|
|
|
|
|
:before-close="ConsumeDialogVisiblehandleClose" |
|
|
|
|
|
:close-on-click-modal="false" |
|
|
|
|
|
width="480px" |
|
|
|
|
|
> |
|
|
|
|
|
|
|
|
<el-dialog v-model="ConsumeDialogVisible" title="操作确认" :before-close="ConsumeDialogVisiblehandleClose" |
|
|
|
|
|
:close-on-click-modal="false" width="480px"> |
|
|
<!-- 内容整体居中且收窄 --> |
|
|
<!-- 内容整体居中且收窄 --> |
|
|
<div class="confirm-body"> |
|
|
<div class="confirm-body"> |
|
|
<!-- 用户信息 --> |
|
|
<!-- 用户信息 --> |
|
@ -842,22 +807,27 @@ p { |
|
|
height: 50px; |
|
|
height: 50px; |
|
|
display: block; |
|
|
display: block; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
.add-form { |
|
|
.add-form { |
|
|
max-width: 50%; |
|
|
max-width: 50%; |
|
|
float: left; |
|
|
float: left; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/* 标题居中 */ |
|
|
/* 标题居中 */ |
|
|
.el-dialog__header { |
|
|
.el-dialog__header { |
|
|
text-align: center; |
|
|
text-align: center; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
.confirm-body { |
|
|
.confirm-body { |
|
|
width: 420px; |
|
|
width: 420px; |
|
|
margin: 0 auto; |
|
|
margin: 0 auto; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/* 字段块与标签样式 */ |
|
|
/* 字段块与标签样式 */ |
|
|
.field { |
|
|
.field { |
|
|
margin-bottom: 14px; |
|
|
margin-bottom: 14px; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
.customer-info { |
|
|
.customer-info { |
|
|
width: 700px; |
|
|
width: 700px; |
|
|
float: right; |
|
|
float: right; |
|
|