diff --git a/src/api/index.ts b/src/api/index.ts index 1544c7f..a69c189 100644 --- a/src/api/index.ts +++ b/src/api/index.ts @@ -95,7 +95,7 @@ const responseInterceptor = (response: AxiosResponse }) return data.data } else { - if (data.code === 1 && data.msg === '用户不存在') { + if (data.code === 1) { // 不弹错误提示,返回带特殊标识的结果 // 其他业务失败:弹错误提示并拒绝Promise ElNotification({ diff --git a/src/api/modules/risk/index.ts b/src/api/modules/risk/index.ts new file mode 100644 index 0000000..5140160 --- /dev/null +++ b/src/api/modules/risk/index.ts @@ -0,0 +1,14 @@ +import { request } from '@/api'; + +//获取风险列表 +export const getRiskListApi = () => { + return request.get('/riskControl/getRiskControlList') +} +//添加风险控制 +export const addRiskApi = (params: any) => { + return request.post('/riskControl/createRiskControl', params) +} +//编辑风险控制 +export const editRiskApi = (params: any) => { + return request.post('/riskControl/editRiskControlSetting', params) +} diff --git a/src/components/common/Form.vue b/src/components/common/Form.vue index edf838f..50dc62f 100644 --- a/src/components/common/Form.vue +++ b/src/components/common/Form.vue @@ -7,7 +7,7 @@ - @@ -56,6 +56,12 @@ :end-placeholder="item.endPlaceholder || '结束时间'" :value-format="item.valueFormat || 'YYYY-MM-DD'" :clearable="item.clearable ?? true" :disabled-date="item.disabledDate" :locale="'zhCn'" /> + + @@ -70,7 +76,7 @@ import type { FormInstance, FormRules } from 'element-plus' import type { Component } from 'vue' interface FormItem { - type: 'input' | 'select' | 'number' | 'radio' | 'slot' | 'checkbox' | 'date' | 'switch' | 'edit' + type: 'input' | 'select' | 'number' | 'radio' | 'slot' | 'checkbox' | 'date' | 'switch' | 'edit' | 'time' label: string prop: string placeholder?: string @@ -83,13 +89,13 @@ interface FormItem { labelWidth?: string class?: string dateType?: 'date' | 'daterange' | 'monthrange' | 'yearrange' | 'datetimerange' + timeType?: 'time' | 'timerange' rangeSeparator?: string startPlaceholder?: string endPlaceholder?: string valueFormat?: string clearable?: boolean disabledDate?: (time: Date) => boolean - } interface Props { diff --git a/src/views/risk/index.vue b/src/views/risk/index.vue index e6ce8aa..7824e56 100644 --- a/src/views/risk/index.vue +++ b/src/views/risk/index.vue @@ -1,3 +1,362 @@ + + + + + diff --git a/src/views/risk/options.ts b/src/views/risk/options.ts new file mode 100644 index 0000000..e138309 --- /dev/null +++ b/src/views/risk/options.ts @@ -0,0 +1,48 @@ +export const tableColumnsSwitch = [ + { + label: '名称', + prop: 'name', + align: 'center' as const, + }, + { + label: '状态', + slotName: 'status', + align: 'center' as const, + }, +] +export const tableColumnsContent = [ + // 内容 + {label: '内容', prop: 'content', align: 'center' as const,slotName: 'contentName'}, + ] +export const formItem = [ + // 名称 + {label: '名称', prop: 'name', type: 'input' as const, placeholder: '请输入名称',labelWidth: '150px'}, + // 状态 + {label: '状态', prop: 'status', type: 'switch' as const}, + // 是否默认 + {label: '是否默认', prop: 'isDefault', type: 'radio' as const,labelWidth: '150px'}, + // 是否允许出金 + {label: '是否允许出金', prop: 'isWithdrawalAllowed', type: 'radio' as const,labelWidth: '150px'}, + // 是否需要出金审核 + {label: '是否需要出金审核', prop: 'isWithdrawalAuditRequired', type: 'radio' as const ,labelWidth: '150px'}, + // 单笔开仓最大数量 + {label: '单笔开仓最大数量', prop: 'maxOpenPosition', type: 'input' as const, placeholder: '请输入单笔开仓最大数量',labelWidth: '150px'}, + // 单品种最大持仓数量 + {label: '单品种最大持仓数量', prop: 'maxPositionPerSymbol', type: 'input' as const, placeholder: '请输入单品种最大持仓数量',labelWidth: '150px'}, + //总品种最大持仓数量 + {label: '总品种最大持仓数量', prop: 'maxTotalPosition', type: 'input' as const, placeholder: '请输入总品种最大持仓数量',labelWidth: '150px'}, + // 强平比例 + {label: '强平比例', prop: 'strongCloseRatio', type: 'input' as const, placeholder: '请输入强平比例',labelWidth: '150px'}, + // 每次出金最大金额 + {label: '每次出金最大金额', prop: 'maxWithdrawalAmount', type: 'input' as const, placeholder: '请输入每次出金最大金额',labelWidth: '150px'}, + // 出金时间设置 + { label: '出金时间设置', prop: 'withdrawalTimeSetting', type: 'time' as const, placeholder: '请选择出金时间', valueFormat: 'HH:mm',labelWidth: '150px'}, + // 建仓多少秒不能平仓 + {label: '建仓多少秒不能平仓', prop: 'buildCloseTime', type: 'input' as const, placeholder: '请输入建仓多少秒不能平仓',labelWidth: '150px'}, + // 每次出金最小金额 + {label: '每次出金最小金额', prop: 'minWithdrawalAmount', type: 'input' as const, placeholder: '请输入每次出金最小金额',labelWidth: '150px'}, + //滑点 + {label: '滑点', prop: 'slippage', type: 'input' as const, placeholder: '请输入滑点',labelWidth: '150px'}, + //每次入金最小金额 + {label: '每次入金最小金额', prop: 'minDepositAmount', type: 'input' as const, placeholder: '请输入每次入金最小金额',labelWidth: '150px'}, +] diff --git a/src/views/risk/rules.ts b/src/views/risk/rules.ts new file mode 100644 index 0000000..fb67ea1 --- /dev/null +++ b/src/views/risk/rules.ts @@ -0,0 +1,60 @@ +import type { FormRules } from 'element-plus' + +export const rules = (): FormRules => { + return { + name: [ + { required: true, message: '请输入名称', trigger: ['blur'] } + ], + status: [ + { required: true, message: '请选择状态', trigger: ['change'] } + ], + isDefault: [ + { required: true, message: '请选择是否默认', trigger: ['change'] } + ], + isWithdrawalAllowed: [ + { required: true, message: '请选择是否允许出金', trigger: ['change'] } + ], + isWithdrawalAuditRequired: [ + { required: true, message: '请选择是否需要出金审核', trigger: ['change'] } + ], + maxOpenPosition: [ + { required: true, message: '请输入单笔开仓最大数量', trigger: ['blur','change'] }, + { pattern: /^[0-9]+(\.[0-9]+)?$/, message: '请输入有效的数字' } + ], + maxPositionPerSymbol: [ + { required: true, message: '请输入单品种最大持仓数量', trigger: ['blur','change'] }, + { pattern: /^[0-9]+(\.[0-9]+)?$/, message: '请输入有效的数字' } + ], + maxTotalPosition: [ + { required: true, message: '请输入总品种最大持仓数量', trigger: ['blur','change'] }, + { pattern: /^[0-9]+(\.[0-9]+)?$/, message: '请输入有效的数字' } + ], + strongCloseRatio: [ + { required: true, message: '请输入强平比例', trigger: ['blur','change'] }, + { pattern: /^[0-9]+(\.[0-9]+)?$/, message: '请输入有效的数字' } + ], + maxWithdrawalAmount: [ + { required: true, message: '请输入最大出金金额', trigger: ['blur','change'] }, + { pattern: /^[0-9]+(\.[0-9]+)?$/, message: '请输入有效的数字' } + ], + withdrawalTimeSetting: [ + { required: true, message: '请选择出金时间', trigger: ['change'] } + ], + buildCloseTime: [ + { required: true, message: '请输入建仓多少秒不能平仓', trigger: ['blur','change'] }, + { pattern: /^[0-9]+$/, message: '请输入整数' } + ], + minWithdrawalAmount: [ + { required: true, message: '请输入出金最小金额', trigger: ['blur','change'] }, + { pattern: /^[0-9]+(\.[0-9]+)?$/, message: '请输入有效的数字' } + ], + slippage: [ + { required: true, message: '请输入滑点', trigger: ['blur','change'] }, + { pattern: /^[0-9]+(\.[0-9]+)?$/, message: '请输入有效的数字' } + ], + minDepositAmount: [ + { required: true, message: '请输入入金最小金额', trigger: ['blur','change'] }, + { pattern: /^[0-9]+(\.[0-9]+)?$/, message: '请输入有效的数字' } + ], + } +} \ No newline at end of file