|
|
@@ -0,0 +1,99 @@
|
|
|
+<!-- 系统运行管理-开户黑名单管理-新增/修改 -->
|
|
|
+<template>
|
|
|
+ <app-drawer title="编辑" width="500" v-model:show="show" :loading="loading" :refresh="refresh">
|
|
|
+ <el-form ref="formRef" label-width="80px" :model="formData" :rules="formRules" :show-message="false">
|
|
|
+ <el-form-item label="源币种" prop="oricurrencyid">
|
|
|
+ <app-enum code="currency" v-model="formData.oricurrencyid" />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="目标币种" prop="descurrencyid">
|
|
|
+ {{ currencyEnum.getEnumTypeName(data?.descurrencyid ?? 1) }}
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="汇率值" prop="exchangerate">
|
|
|
+ <el-input v-model="formData.exchangerate" maxlength="50" :placeholder="t('common.pleaseenter')" />
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+ <template #footer>
|
|
|
+ <el-button @click="onCancel(false)">{{ t('operation.cancel') }}</el-button>
|
|
|
+ <el-button type="primary" @click="onSubmit">{{ t('operation.save') }}</el-button>
|
|
|
+ </template>
|
|
|
+ </app-drawer>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script lang="ts" setup>
|
|
|
+import { shallowRef, ref, PropType, onMounted } from 'vue'
|
|
|
+import { ElMessage, FormInstance, FormRules } from 'element-plus'
|
|
|
+import { i18n } from '@/stores'
|
|
|
+import { dealRate, dealinit } from '@/services/api/system'
|
|
|
+import AppDrawer from '@pc/components/base/drawer/index.vue'
|
|
|
+import AppEnum from '@pc/components/modules/enum/index.vue'
|
|
|
+import { useRequest } from '@/hooks/request'
|
|
|
+import { useEnum } from '@/hooks/enum'
|
|
|
+
|
|
|
+const props = defineProps({
|
|
|
+ record: {
|
|
|
+ type: Object as PropType<Model.RateRsp>
|
|
|
+ }
|
|
|
+})
|
|
|
+
|
|
|
+const formData = ref<Partial<Model.DealRateReq>>({
|
|
|
+ flag: props.record ? 1 : 0
|
|
|
+})
|
|
|
+
|
|
|
+const { global: { t } } = i18n
|
|
|
+const formRef = ref<FormInstance>()
|
|
|
+const show = shallowRef(true)
|
|
|
+const refresh = shallowRef(false)
|
|
|
+
|
|
|
+const currencyEnum = useEnum('currency')
|
|
|
+
|
|
|
+// 表单验证规则
|
|
|
+const formRules: FormRules = {
|
|
|
+ cardtype: [{ required: true }],
|
|
|
+ cardnum: [{ required: true }]
|
|
|
+}
|
|
|
+
|
|
|
+const { data, loading }= useRequest(dealinit, {
|
|
|
+ onSuccess: (res) => {
|
|
|
+ const { descurrencyid } = res.data[0]
|
|
|
+ if (descurrencyid) {
|
|
|
+ formData.value.descurrencyid = descurrencyid
|
|
|
+ }
|
|
|
+ }
|
|
|
+})
|
|
|
+
|
|
|
+const onSubmit = () => {
|
|
|
+ // 目标币种
|
|
|
+ formData.value.descurrencyid = data.value?.descurrencyid
|
|
|
+ const rawData = { ...formData.value }
|
|
|
+ formRef.value?.validate((valid) => {
|
|
|
+ if (valid) {
|
|
|
+ loading.value = true
|
|
|
+ dealRate({
|
|
|
+ data: rawData
|
|
|
+ }).then(() => {
|
|
|
+ ElMessage.success(t('common.tips3'))
|
|
|
+ onCancel(true)
|
|
|
+ }).catch((err) => {
|
|
|
+ ElMessage.error(t('common.tips4') + err)
|
|
|
+ }).finally(() => {
|
|
|
+ loading.value = false
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+const onCancel = (isRefresh = false) => {
|
|
|
+ show.value = false
|
|
|
+ refresh.value = isRefresh
|
|
|
+}
|
|
|
+
|
|
|
+onMounted(() => {
|
|
|
+ const { descurrencyid, exchangerate, oricurrencyid } = props.record ?? {}
|
|
|
+ if (descurrencyid) {
|
|
|
+ formData.value.exchangerate = exchangerate
|
|
|
+ formData.value.oricurrencyid = oricurrencyid
|
|
|
+ formData.value.descurrencyid = descurrencyid
|
|
|
+ }
|
|
|
+})
|
|
|
+
|
|
|
+</script>
|