This commit is contained in:
dzc committed 2025-03-29 16:35:00 +08:00
1 parent 42d3e93adb
commit 5c67785e2c
3 files changed
+74 -32

No files matched your search

+7
View File
@@ -31,6 +31,13 @@ export function getObj(id?: string) {
})
}
export function getJoinDetail(id?: string) {
return request({
url: "/wallet/mch-rule-join/join-detail/" + id,
method: "get",
})
}
export function delObjs(ids?: Object) {
return request({
url: "/wallet/mch-rule-join",
@@ -13,10 +13,18 @@
</el-form-item>
</el-col>
<el-col :span="24" class="mb20">
<el-form-item label="目标商户" prop="tragetDeptId">
<select-mch v-model="form.tragetDeptId" :apiParams="{ types: '1' }" />
<el-form-item label="目标商户" prop="targetMchId">
<select-mch v-model="form.targetMchId" :apiParams="{ types: '1' }" />
</el-form-item>
</el-col>
<el-col :span="24" class="mb20">
<el-alert title="提示" type="info" :closable="false">
<span class="color-primary">老县府</span>
<span>到</span>
<span class="color-primary">新县府</span>
<span>消费</span>
</el-alert>
</el-col>
</el-row>
</el-form>
<template #footer>
@@ -31,7 +39,7 @@
<script setup lang="ts" name="WalletRuleMchConfigFormDialog">
import { useDict } from "/@/hooks/dict"
import { useMessage } from "/@/hooks/message"
import * as walletRuleMchConfigApi from "../../../api/wallet/mch-rule-join"
import * as walletRuleMchConfigApi from "/@/api/wallet/mch-rule-join"
import { rule } from "/@/utils/validate"
const emit = defineEmits(["refresh"])
@@ -43,16 +51,28 @@ const loading = ref(false)
// 提交表单数据
const form = reactive({
id: "",
sourceMchId: "",
targetMchId: "",
targetDeptId: "",
rulePriceConfigId: "",
})
const detail = reactive({
id: "",
sourceMchId: "",
tragetDeptId: "",
rulePriceConfigId: "",
basePrice: "",
multiple: "",
sourceMchName: "",
targetMchName: "",
})
// 定义校验规则
const dataRules = ref({
sourceMchId: [{ required: true, message: "请选择源商户", trigger: "blur" }],
tragetDeptId: [{ required: true, message: "请选择目标商户", trigger: "blur" }],
targetMchId: [{ required: true, message: "请选择目标商户", trigger: "blur" }],
rulePriceConfigId: [{ required: true, message: "请选择规则", trigger: "blur" }],
})
@@ -77,12 +97,14 @@ const openDialog = (id: string) => {
const onSubmit = async () => {
const valid = await dataFormRef.value.validate().catch(() => {})
if (!valid) return false
try {
loading.value = true
form.id ? await walletRuleMchConfigApi.putObj(form) : await walletRuleMchConfigApi.addObj(form)
const { data } = form.id ? await walletRuleMchConfigApi.putObj(form) : await walletRuleMchConfigApi.addObj(form)
useMessage().success(form.id ? "修改成功" : "添加成功")
visible.value = false
// visible.value = false
// 更新
await getwalletRuleMchConfigData(data)
await getDetails(data)
emit("refresh")
} catch (err: any) {
useMessage().error(err.msg)
@@ -92,17 +114,26 @@ const onSubmit = async () => {
}
// 初始化表单数据
const getwalletRuleMchConfigData = (id: string) => {
const getwalletRuleMchConfigData = async (id: string) => {
// 获取数据
loading.value = true
walletRuleMchConfigApi
.getObj(id)
.then((res: any) => {
Object.assign(form, res.data)
})
.finally(() => {
loading.value = false
})
try {
const { data } = await walletRuleMchConfigApi.getObj(id)
Object.assign(form, data)
} catch (err) {
console.error(err)
} finally {
loading.value = false
}
}
const getDetails = async (id: any) => {
try {
const { data } = await walletRuleMchConfigApi.getJoinDetail(id)
Object.assign(detail, data)
} catch (e) {
console.log(e)
}
}
// 暴露变量
+20 -16
View File
@@ -3,7 +3,7 @@
<div>
<el-tabs v-model="form.activeTab" class="demo-tabs">
<div v-for="v in data.tabList" :key="v.id">
<el-tab-pane :label="v.label" :name="v.id" />
<el-tab-pane v-if="v.visible" :label="v.label" :name="v.id" />
</div>
</el-tabs>
<el-form ref="dataFormRef" v-if="form.activeTab == 10" :model="form" :rules="dataRules" label-width="120px" v-loading="loading">
@@ -15,7 +15,7 @@
</el-col>
</el-row>
</el-form>
<mch-rule-config-dialog v-if="form.activeTab == 20" />
<mch-rule-config-dialog v-if="form.activeTab == 20 && form.merchantType == '1'" />
</div>
<template #footer>
<el-button @click="visible = false">取消</el-button>
@@ -36,12 +36,12 @@ const dataFormRef = ref()
const visible = ref(false)
const loading = ref(false)
const data = {
const data = reactive({
tabList: [
{ id: 10, label: "钱包配置" },
{ id: 20, label: "钱包规则" },
{ id: 10, label: "钱包配置", visible: true },
{ id: 20, label: "钱包规则", visible: false },
],
}
})
// 提交表单数据
const form = reactive({
@@ -58,15 +58,15 @@ const dataRules = ref({
// 打开弹窗
const openDialog = (id: string) => {
if (id) {
visible.value = true
form.id = id
// 重置表单数据
dataFormRef.value?.resetFields()
getmerchantInfoData(id)
} else {
if (!id) {
useMessage().success("商户id不存在")
return
}
visible.value = true
form.id = id
// 重置表单数据
dataFormRef.value?.resetFields()
getmerchantInfoData(id)
}
// 初始化表单数据
@@ -76,10 +76,14 @@ const getmerchantInfoData = async (id: string) => {
try {
const res = await getObj(id)
if (res.code === 0) {
const data = res.data
Object.assign(form, data, {
merchantType: data.types,
const _data = res.data
Object.assign(form, _data, {
merchantType: _data.types,
})
// tab
if (_data.types == "1") {
data.tabList[1].visible = true
}
}
} catch (error: any) {
useMessage().success(error)