fix:硬件管理
This commit is contained in:
1 parent
5f757796c8
commit
087d49c6ac
7 files changed
+654
-604
No files matched your search
@@ -1,99 +1,119 @@
|
||||
<template>
|
||||
<div class="w100">
|
||||
<div class="layout-padding-auto layout-padding-view">
|
||||
<div class="flex justify-center flex-col">
|
||||
<div>
|
||||
<el-form ref="dataFormRef" label-width="120px" :model="form" :rules="dataRules" formDialogRef
|
||||
v-loading="loading">
|
||||
<el-row :gutter="24">
|
||||
<el-col :span="24" class="mb20">
|
||||
<el-form-item label="每一餐的上限" prop="payAmountEnable">
|
||||
<el-switch active-value="1" inactive-value="0" v-model="form.payAmountEnable"
|
||||
active-text="开启" inactive-text="关闭" inline-prompt />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="24" class="mb20">
|
||||
<el-form-item label="每一餐的上限" prop="payAmountMealLimit">
|
||||
<el-input style="width: 300px;" type="number" v-model="form.payAmountMealLimit"
|
||||
placeholder="请输入上限金额">
|
||||
<template #append>元</template>
|
||||
</el-input>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="24" class="mb20">
|
||||
<el-form-item label="倍数" prop="payAmountMealTimes">
|
||||
<el-input style="width: 300px;" type="number" v-model="form.payAmountMealTimes"
|
||||
placeholder="请输入倍数">
|
||||
<template #append>倍</template>
|
||||
</el-input>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-form>
|
||||
<div class="flex items-center">
|
||||
<el-button type="primary" @click="onSubmit" :disabled="loading">确认</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="w100">
|
||||
<div class="layout-padding-auto layout-padding-view">
|
||||
<div class="flex justify-center flex-col">
|
||||
<div>
|
||||
<el-form
|
||||
ref="dataFormRef"
|
||||
label-width="120px"
|
||||
:model="form"
|
||||
:rules="dataRules"
|
||||
formDialogRef
|
||||
v-loading="loading"
|
||||
>
|
||||
<el-row :gutter="24">
|
||||
<el-col :span="24" class="mb20">
|
||||
<el-form-item label="每一餐的上限" prop="payAmountEnable">
|
||||
<el-switch
|
||||
active-value="1"
|
||||
inactive-value="0"
|
||||
v-model="form.payAmountEnable"
|
||||
active-text="开启"
|
||||
inactive-text="关闭"
|
||||
inline-prompt
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="24" class="mb20">
|
||||
<el-form-item label="每一餐的上限" prop="payAmountMealLimit">
|
||||
<el-input
|
||||
style="width: 300px"
|
||||
type="number"
|
||||
v-model="form.payAmountMealLimit"
|
||||
placeholder="请输入上限金额"
|
||||
>
|
||||
<template #append>元</template>
|
||||
</el-input>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="24" class="mb20">
|
||||
<el-form-item label="倍数" prop="payAmountMealTimes">
|
||||
<el-input
|
||||
style="width: 300px"
|
||||
type="number"
|
||||
v-model="form.payAmountMealTimes"
|
||||
placeholder="请输入倍数"
|
||||
>
|
||||
<template #append>倍</template>
|
||||
</el-input>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-form>
|
||||
<div class="flex items-center">
|
||||
<el-button type="primary" @click="onSubmit" :disabled="loading">确认</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts" name="extra-price">
|
||||
import { storePrice } from "/@/utils/formatMoney"
|
||||
import { storePrice, displayPrice } from "/@/utils/formatMoney"
|
||||
import { useMessage } from "/@/hooks/message"
|
||||
import { getObj, putObj } from "/@/api/wallet/wallet-setting"
|
||||
// 定义变量内容
|
||||
const dataFormRef = ref();
|
||||
const dataFormRef = ref()
|
||||
const loading = ref(false)
|
||||
// 提交表单数据
|
||||
const form = reactive({
|
||||
id: undefined,
|
||||
payAmountEnable: undefined,
|
||||
payAmountMealLimit: undefined,
|
||||
payAmountMealTimes: undefined,
|
||||
});
|
||||
id: undefined,
|
||||
payAmountEnable: undefined,
|
||||
payAmountMealLimit: undefined,
|
||||
payAmountMealTimes: undefined,
|
||||
})
|
||||
// 定义校验规则
|
||||
const dataRules = ref({
|
||||
payAmountEnable: [{ required: true, message: '请选择是否开启每一餐的上限', trigger: 'change' }],
|
||||
payAmountMealLimit: [{ required: true, message: '请输入上限金额', trigger: 'blur' }],
|
||||
payAmountMealTimes: [{ required: true, message: '请输入倍数', trigger: 'blur' }],
|
||||
payAmountEnable: [{ required: true, message: "请选择是否开启每一餐的上限", trigger: "change" }],
|
||||
payAmountMealLimit: [{ required: true, message: "请输入上限金额", trigger: "blur" }],
|
||||
payAmountMealTimes: [{ required: true, message: "请输入倍数", trigger: "blur" }],
|
||||
})
|
||||
|
||||
onMounted(() => {
|
||||
getwalletRechargePackageData('1')
|
||||
getwalletRechargePackageData("1")
|
||||
})
|
||||
|
||||
// 提交
|
||||
const onSubmit = async () => {
|
||||
const valid = await dataFormRef.value.validate().catch(() => { });
|
||||
if (!valid) return false;
|
||||
|
||||
try {
|
||||
loading.value = true;
|
||||
const pa = {
|
||||
...form,
|
||||
payPrice: storePrice(form.payAmountMealLimit),
|
||||
}
|
||||
await putObj(pa)
|
||||
useMessage().success('修改成功');
|
||||
} catch (err: any) {
|
||||
useMessage().error(err.msg);
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
};
|
||||
const valid = await dataFormRef.value.validate().catch(() => {})
|
||||
if (!valid) return false
|
||||
|
||||
try {
|
||||
loading.value = true
|
||||
const pa = {
|
||||
...form,
|
||||
payAmountMealLimit: storePrice(form.payAmountMealLimit),
|
||||
}
|
||||
await putObj(pa)
|
||||
useMessage().success("修改成功")
|
||||
} catch (err: any) {
|
||||
useMessage().error(err.msg)
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
// 初始化表单数据
|
||||
const getwalletRechargePackageData = (id: string) => {
|
||||
// 获取数据
|
||||
loading.value = true
|
||||
getObj(id).then((res: any) => {
|
||||
Object.assign(form, res.data)
|
||||
}).finally(() => {
|
||||
loading.value = false
|
||||
})
|
||||
};
|
||||
|
||||
</script>
|
||||
// 获取数据
|
||||
loading.value = true
|
||||
getObj(id)
|
||||
.then((res: any) => {
|
||||
Object.assign(form, res.data, { payAmountMealLimit: displayPrice(res.data.payAmountMealLimit, "", 0) })
|
||||
})
|
||||
.finally(() => {
|
||||
loading.value = false
|
||||
})
|
||||
}
|
||||
</script>
|
||||
Reference in new issue
Block a user