140 lines
3.5 KiB
Vue
140 lines
3.5 KiB
Vue
<template>
|
|
<el-dialog title="后台退款" v-model="visible" width="30%" :close-on-click-modal="false" draggable>
|
|
<el-form ref="dataFormRef" :model="form" :rules="dataRules" formDialogRef label-width="120px" v-loading="loading">
|
|
<el-row :gutter="24">
|
|
<el-col :span="24" class="mb20">
|
|
<el-form-item label="售后方式" prop="way">
|
|
<dict-select disabled v-model="form.way" dict-code="hard_after_sale_way" />
|
|
</el-form-item>
|
|
</el-col>
|
|
|
|
<el-col :span="24" class="mb20">
|
|
<el-form-item label="退款原因" prop="applyReason">
|
|
<el-select v-model="form.applyReason">
|
|
<el-option
|
|
v-for="reason in state.setting.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="applyPicUrls">
|
|
<upload-imgs v-model:imageUrls="form.applyPicUrls" />
|
|
</el-form-item>
|
|
</el-col>
|
|
|
|
<el-col :span="24" class="mb20">
|
|
<el-form-item label="相关描述" prop="applyDescription">
|
|
<el-input
|
|
v-model="form.applyDescription"
|
|
placeholder="请输入备注"
|
|
type="textarea"
|
|
:autosize="{ minRows: 6 }"
|
|
/>
|
|
</el-form-item>
|
|
</el-col>
|
|
</el-row>
|
|
</el-form>
|
|
<template #footer>
|
|
<span class="dialog-footer">
|
|
<el-button @click="visible = false">取消</el-button>
|
|
<el-button type="primary" @click="onSubmit" :disabled="loading">确认</el-button>
|
|
</span>
|
|
</template>
|
|
</el-dialog>
|
|
</template>
|
|
|
|
<script setup lang="ts" name="admin-refund-dialog">
|
|
import { useMessage } from "/@/hooks/message"
|
|
import * as hardAfterSaleApi from "/@/api/hard/hard-after-sale"
|
|
import * as walletSettingApi from "/@/api/wallet/wallet-setting"
|
|
|
|
const emit = defineEmits(["refresh"])
|
|
|
|
// 定义变量内容
|
|
const dataFormRef = ref()
|
|
const visible = ref(false)
|
|
const loading = ref(false)
|
|
|
|
// 定义字典
|
|
|
|
// 提交表单数据
|
|
const form = reactive({
|
|
orderId: "",
|
|
way: "10",
|
|
applyReason: "",
|
|
applyPicUrls: "",
|
|
applyDescription: "",
|
|
})
|
|
|
|
const state = reactive<any>({
|
|
setting: {},
|
|
})
|
|
|
|
// 定义校验规则
|
|
const dataRules = ref({
|
|
way: [{ required: true, message: "请选择售后方式", trigger: "change" }],
|
|
applyReason: [{ required: true, message: "请选择退款原因", trigger: "change" }],
|
|
})
|
|
|
|
// 打开弹窗
|
|
const openDialog = (id: string) => {
|
|
visible.value = true
|
|
form.orderId = ""
|
|
// 重置表单数据
|
|
nextTick(() => {
|
|
dataFormRef.value?.resetFields()
|
|
})
|
|
// 获取hardwareOrder信息
|
|
if (id) {
|
|
form.orderId = id
|
|
gethardwareOrderData(id)
|
|
}
|
|
}
|
|
|
|
// 初始化表单数据
|
|
const gethardwareOrderData = async (id: string) => {
|
|
// 获取数据
|
|
loading.value = true
|
|
try {
|
|
const { data } = await walletSettingApi.getObj()
|
|
if (data.afterSaleRefundReasons) {
|
|
data.afterSaleRefundReasons = data.afterSaleRefundReasons?.split(",")
|
|
}
|
|
if (data.afterSaleReturnReasons) {
|
|
data.afterSaleReturnReasons = data.afterSaleReturnReasons?.split(",")
|
|
}
|
|
state.setting = data
|
|
} finally {
|
|
loading.value = false
|
|
}
|
|
}
|
|
|
|
// 提交
|
|
const onSubmit = async () => {
|
|
const valid = await dataFormRef.value.validate().catch(() => {})
|
|
if (!valid) return false
|
|
|
|
try {
|
|
loading.value = true
|
|
await hardAfterSaleApi.adminRefund(form)
|
|
useMessage().success("退款成功")
|
|
visible.value = false
|
|
emit("refresh")
|
|
} catch (err: any) {
|
|
useMessage().error(err.msg)
|
|
} finally {
|
|
loading.value = false
|
|
}
|
|
}
|
|
|
|
// 暴露变量
|
|
defineExpose({
|
|
openDialog,
|
|
})
|
|
</script>
|