144 lines
3.7 KiB
Vue
144 lines
3.7 KiB
Vue
<template>
|
|
<el-dialog :title="form.id ? '编辑' : '新增'" width="50%" v-model="visible" :close-on-click-modal="false" draggable>
|
|
<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="rulePriceConfigId">
|
|
<select-mch-rule v-model="form.rulePriceConfigId" />
|
|
</el-form-item>
|
|
</el-col>
|
|
<el-col :span="24" class="mb20">
|
|
<el-form-item label="源商户" prop="sourceMchId">
|
|
<select-mch v-model="form.sourceMchId" :apiParams="{ types: '1' }" />
|
|
</el-form-item>
|
|
</el-col>
|
|
<el-col :span="24" class="mb20">
|
|
<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>
|
|
<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="WalletRuleMchConfigFormDialog">
|
|
import { useDict } from "/@/hooks/dict"
|
|
import { useMessage } from "/@/hooks/message"
|
|
import * as walletRuleMchConfigApi from "/@/api/wallet/mch-rule-join"
|
|
import { rule } from "/@/utils/validate"
|
|
const emit = defineEmits(["refresh"])
|
|
|
|
// 定义变量内容
|
|
const dataFormRef = ref()
|
|
const visible = ref(false)
|
|
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" }],
|
|
targetMchId: [{ required: true, message: "请选择目标商户", trigger: "blur" }],
|
|
rulePriceConfigId: [{ required: true, message: "请选择规则", trigger: "blur" }],
|
|
})
|
|
|
|
// 打开弹窗
|
|
const openDialog = (id: string) => {
|
|
visible.value = true
|
|
form.id = ""
|
|
|
|
// 重置表单数据
|
|
nextTick(() => {
|
|
dataFormRef.value?.resetFields()
|
|
})
|
|
|
|
// 获取walletRuleMchConfig信息
|
|
if (id) {
|
|
form.id = id
|
|
getwalletRuleMchConfigData(id)
|
|
}
|
|
}
|
|
|
|
// 提交
|
|
const onSubmit = async () => {
|
|
const valid = await dataFormRef.value.validate().catch(() => {})
|
|
if (!valid) return false
|
|
try {
|
|
loading.value = true
|
|
const { data } = form.id ? await walletRuleMchConfigApi.putObj(form) : await walletRuleMchConfigApi.addObj(form)
|
|
useMessage().success(form.id ? "修改成功" : "添加成功")
|
|
// visible.value = false
|
|
// 更新
|
|
await getwalletRuleMchConfigData(data)
|
|
await getDetails(data)
|
|
emit("refresh")
|
|
} catch (err: any) {
|
|
useMessage().error(err.msg)
|
|
} finally {
|
|
loading.value = false
|
|
}
|
|
}
|
|
|
|
// 初始化表单数据
|
|
const getwalletRuleMchConfigData = async (id: string) => {
|
|
// 获取数据
|
|
loading.value = true
|
|
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)
|
|
}
|
|
}
|
|
|
|
// 暴露变量
|
|
defineExpose({
|
|
openDialog,
|
|
})
|
|
</script>
|