114 lines
3.3 KiB
Vue
114 lines
3.3 KiB
Vue
<template>
|
|
<div class="w100">
|
|
<div class="layout-padding-auto layout-padding-view">
|
|
<div class="flex justify-center flex-col">
|
|
<div>
|
|
<el-form ref="dataFormRef" :model="form" :rules="dataRules" formDialogRef label-width="90px" v-loading="loading">
|
|
<el-row :gutter="24">
|
|
<el-col :span="24" class="mb20">
|
|
<el-form-item label="退款理由" prop="afterSaleRefundReasons">
|
|
<el-select
|
|
:disabled="!auth('wallet_setting_edit')"
|
|
style="width: 500px"
|
|
v-model="form.afterSaleRefundReasons"
|
|
allow-create
|
|
filterable
|
|
multiple
|
|
placeholder="请输入退款理由"
|
|
>
|
|
<el-option v-for="reason in form.afterSaleRefundReasons" :key="reason" :label="reason" :value="reason" />
|
|
</el-select>
|
|
</el-form-item>
|
|
</el-col>
|
|
<el-col :span="24" class="mb20">
|
|
<el-form-item label="退货理由" prop="afterSaleReturnReasons">
|
|
<el-select
|
|
:disabled="!auth('wallet_setting_edit')"
|
|
style="width: 500px"
|
|
v-model="form.afterSaleReturnReasons"
|
|
allow-create
|
|
filterable
|
|
multiple
|
|
placeholder="请输入退货理由"
|
|
>
|
|
<el-option v-for="reason in form.afterSaleReturnReasons" :key="reason" :label="reason" :value="reason" />
|
|
</el-select>
|
|
</el-form-item>
|
|
</el-col>
|
|
</el-row>
|
|
</el-form>
|
|
<div class="flex items-center" v-auth="'wallet_setting_edit'">
|
|
<el-button type="primary" @click="onSubmit" :disabled="loading">确认</el-button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
|
|
<script setup lang="ts" name="refund">
|
|
import { storePrice } from "/@/utils/formatMoney"
|
|
import { useMessage } from "/@/hooks/message"
|
|
import { getObj, putObj } from "/@/api/wallet/wallet-setting"
|
|
import { auth } from "/@/utils/authFunction"
|
|
|
|
// 定义变量内容
|
|
const dataFormRef = ref()
|
|
const loading = ref(false)
|
|
// 提交表单数据
|
|
const form = reactive<any>({
|
|
id: undefined,
|
|
afterSaleRefundReasons: undefined,
|
|
afterSaleReturnReasons: undefined,
|
|
})
|
|
// 定义校验规则
|
|
const dataRules = ref({
|
|
afterSaleRefundReasons: [{ required: true, message: "请输入退款理由", trigger: "blur" }],
|
|
afterSaleReturnReasons: [{ required: true, message: "请输入退货理由", trigger: "blur" }],
|
|
})
|
|
|
|
onMounted(() => {
|
|
getwalletRechargePackageData("1")
|
|
})
|
|
|
|
// 提交
|
|
const onSubmit = async () => {
|
|
const valid = await dataFormRef.value.validate().catch(() => {})
|
|
if (!valid) return false
|
|
try {
|
|
loading.value = true
|
|
const pa = {
|
|
...form,
|
|
afterSaleRefundReasons: form.afterSaleRefundReasons?.join(","),
|
|
afterSaleReturnReasons: form.afterSaleReturnReasons?.join(","),
|
|
}
|
|
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) => {
|
|
const data: any = res.data
|
|
if (data.afterSaleRefundReasons) {
|
|
data.afterSaleRefundReasons = data.afterSaleRefundReasons?.split(",")
|
|
}
|
|
if (data.afterSaleReturnReasons) {
|
|
data.afterSaleReturnReasons = data.afterSaleReturnReasons?.split(",")
|
|
}
|
|
Object.assign(form, data)
|
|
})
|
|
.finally(() => {
|
|
loading.value = false
|
|
})
|
|
}
|
|
</script>
|