修复品种bug
This commit is contained in:
parent
b4b8acecd3
commit
1ad3d7379f
|
|
@ -5,7 +5,7 @@
|
||||||
<template v-for="(item, index) in formItems" :key="index">
|
<template v-for="(item, index) in formItems" :key="index">
|
||||||
<el-col :span="props.colSpan || 24">
|
<el-col :span="props.colSpan || 24">
|
||||||
<el-form-item :label="item.label" :prop="item.prop" :required="item.required" :label-position="item.labelPosition || 'left'"
|
<el-form-item :label="item.label" :prop="item.prop" :required="item.required" :label-position="item.labelPosition || 'left'"
|
||||||
:label-width="item.labelWidth || '100px'" :class="item.class">
|
:label-width="item.labelWidth || '125px'" :class="item.class">
|
||||||
<!-- 输入框 -->
|
<!-- 输入框 -->
|
||||||
<el-input v-if="item.type === 'input'" v-model="formData[item.prop]"
|
<el-input v-if="item.type === 'input'" v-model="formData[item.prop]"
|
||||||
:placeholder="item.placeholder" :disabled="item.disabled" clearable />
|
:placeholder="item.placeholder" :disabled="item.disabled" clearable />
|
||||||
|
|
|
||||||
|
|
@ -38,9 +38,16 @@
|
||||||
jpg/png格式 图片大小不能超过20KB
|
jpg/png格式 图片大小不能超过20KB
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<img v-if="dialogType === 'edit'" :src="formData.imageUrl" alt="预览图片" style="width: 100px; height: 100px;">
|
<img v-if="dialogType === 'edit'" :src="formData.imageUrl" alt="预览图片"
|
||||||
|
style="width: 100px; height: 100px;">
|
||||||
</el-upload>
|
</el-upload>
|
||||||
</template>
|
</template>
|
||||||
|
<template #isDefault="{ formData }">
|
||||||
|
<el-radio-group v-model="formData.isDefault" v-if="dialogType === 'edit'">
|
||||||
|
<el-radio :value="1" >是</el-radio>
|
||||||
|
<el-radio :value="2">否</el-radio>
|
||||||
|
</el-radio-group>
|
||||||
|
</template>
|
||||||
</VarietyForm>
|
</VarietyForm>
|
||||||
</VarietyDialog>
|
</VarietyDialog>
|
||||||
<!-- dialog表格 -->
|
<!-- dialog表格 -->
|
||||||
|
|
@ -48,7 +55,6 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import type { UploadProps, UploadUserFile } from 'element-plus'
|
|
||||||
// 组件
|
// 组件
|
||||||
import VarietySearch from '@/components/common/Search.vue'
|
import VarietySearch from '@/components/common/Search.vue'
|
||||||
import VarietyTable from '@/components/common/Table.vue'
|
import VarietyTable from '@/components/common/Table.vue'
|
||||||
|
|
@ -56,7 +62,7 @@ import VarietyDialog from '@/components/common/Dialog.vue'
|
||||||
import VarietyForm from '@/components/common/Form.vue'
|
import VarietyForm from '@/components/common/Form.vue'
|
||||||
|
|
||||||
// 配置以及表单验证
|
// 配置以及表单验证
|
||||||
import { search, tableColumns, editDialogFormItem } from './options'
|
import { search, tableColumns, DialogFormItem } from './options'
|
||||||
import { rules } from './rules'
|
import { rules } from './rules'
|
||||||
|
|
||||||
// 接口
|
// 接口
|
||||||
|
|
@ -107,8 +113,6 @@ const varietyForm = ref({
|
||||||
minFlux: '',
|
minFlux: '',
|
||||||
// 单位
|
// 单位
|
||||||
unit: '',
|
unit: '',
|
||||||
// 交易时间
|
|
||||||
tradeTime: '',
|
|
||||||
// 多头库存费
|
// 多头库存费
|
||||||
longStockFee: '',
|
longStockFee: '',
|
||||||
// 空头库存费
|
// 空头库存费
|
||||||
|
|
@ -134,17 +138,13 @@ const varietyForm = ref({
|
||||||
feeInventoryTime: '',
|
feeInventoryTime: '',
|
||||||
// 交易分组
|
// 交易分组
|
||||||
tradeGroup: '',
|
tradeGroup: '',
|
||||||
|
// 是否默认
|
||||||
|
isDefault: '',
|
||||||
})
|
})
|
||||||
const varietyFormRef = ref<any>()
|
const varietyFormRef = ref<any>()
|
||||||
const varietyFormRules = ref(rules())
|
const varietyFormRules = ref(rules())
|
||||||
const dialogFormItemOptions = ref(editDialogFormItem)
|
const dialogFormItemOptions = ref(DialogFormItem)
|
||||||
const varietyFormOptionsMap = ref({
|
const varietyFormOptionsMap = ref({
|
||||||
tradeTime: [
|
|
||||||
{
|
|
||||||
label: '2026-4-23',
|
|
||||||
value: '2026-4-23',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
tradeGroup: [],
|
tradeGroup: [],
|
||||||
type: [
|
type: [
|
||||||
{
|
{
|
||||||
|
|
@ -208,7 +208,7 @@ const getVarietyList = async () => {
|
||||||
contractSize: item.multiplier,
|
contractSize: item.multiplier,
|
||||||
minFlux: item.undulate_min,
|
minFlux: item.undulate_min,
|
||||||
unit: item.unit,
|
unit: item.unit,
|
||||||
tradeGroup: item.group,
|
tradeGroup: item.group.name,
|
||||||
longStockFee: item.fee_inventory_long,
|
longStockFee: item.fee_inventory_long,
|
||||||
shortStockFee: item.fee_inventory_short,
|
shortStockFee: item.fee_inventory_short,
|
||||||
profitLevel: item.stop_loss_level,
|
profitLevel: item.stop_loss_level,
|
||||||
|
|
@ -247,7 +247,6 @@ const handleReset = () => {
|
||||||
handleSearch()
|
handleSearch()
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('varietyForm.value)', varietyForm.value)
|
|
||||||
const handleEdit = () => {
|
const handleEdit = () => {
|
||||||
getTradeGroupList()
|
getTradeGroupList()
|
||||||
const row = selectedRow.value;
|
const row = selectedRow.value;
|
||||||
|
|
@ -264,7 +263,11 @@ const handleEdit = () => {
|
||||||
// 点差小数位
|
// 点差小数位
|
||||||
pointDecimalPlaces: row.point_diff_decimal_place,
|
pointDecimalPlaces: row.point_diff_decimal_place,
|
||||||
imageUrl: row.image,
|
imageUrl: row.image,
|
||||||
|
feeInventoryTime: row.fee_inventory_time,
|
||||||
|
// 是否默认
|
||||||
|
isDefault: row.is_default,
|
||||||
} as any
|
} as any
|
||||||
|
|
||||||
//数据赋值完成后执行弹窗操作
|
//数据赋值完成后执行弹窗操作
|
||||||
dialogVisible.value = true
|
dialogVisible.value = true
|
||||||
dialogTitle.value = '编辑合约品种'
|
dialogTitle.value = '编辑合约品种'
|
||||||
|
|
@ -286,23 +289,21 @@ const handleAdd = () => {
|
||||||
contractSize: '',
|
contractSize: '',
|
||||||
minFlux: '',
|
minFlux: '',
|
||||||
unit: '',
|
unit: '',
|
||||||
tradeTime: '',
|
|
||||||
longStockFee: '',
|
longStockFee: '',
|
||||||
shortStockFee: '',
|
shortStockFee: '',
|
||||||
profitLevel: '',
|
profitLevel: '',
|
||||||
|
|
||||||
id: '',
|
id: '',
|
||||||
groupId: '',
|
groupId: '',
|
||||||
prepaymentHedge: '',
|
prepaymentHedge: '',
|
||||||
prepaymentPercent: '',
|
prepaymentPercent: '',
|
||||||
decimalPlaces: '',
|
decimalPlaces: '',
|
||||||
pointDecimalPlaces: '',
|
pointDecimalPlaces: '',
|
||||||
// 类型
|
|
||||||
type: '',
|
type: '',
|
||||||
// 上传图片地址
|
|
||||||
imageUrl: '',
|
imageUrl: '',
|
||||||
feeInventoryTime: '',
|
feeInventoryTime: '',
|
||||||
tradeGroup: '',
|
tradeGroup: '',
|
||||||
|
// 是否默认
|
||||||
|
isDefault: '',
|
||||||
}
|
}
|
||||||
fileList.value = []
|
fileList.value = []
|
||||||
}
|
}
|
||||||
|
|
@ -326,30 +327,30 @@ const handleUpload = async (options: any) => {
|
||||||
|
|
||||||
// 上传前校验:格式 + 大小(20KB = 20 * 1024)
|
// 上传前校验:格式 + 大小(20KB = 20 * 1024)
|
||||||
const beforeUpload = (file: File) => {
|
const beforeUpload = (file: File) => {
|
||||||
// 严格校验后缀名
|
// 严格校验后缀名
|
||||||
const fileName = file.name.toLowerCase();
|
const fileName = file.name.toLowerCase();
|
||||||
const isJpgOrPng = fileName.endsWith('.jpg') || fileName.endsWith('.jpeg') || fileName.endsWith('.png');
|
const isJpgOrPng = fileName.endsWith('.jpg') || fileName.endsWith('.jpeg') || fileName.endsWith('.png');
|
||||||
|
|
||||||
if (!isJpgOrPng) {
|
|
||||||
ElMessage.error('上传图片只能是 JPG/PNG 格式,且必须包含后缀名!');
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 校验 MIME 类型
|
if (!isJpgOrPng) {
|
||||||
const isTypeValid = file.type === 'image/jpeg' || file.type === 'image/png';
|
ElMessage.error('上传图片只能是 JPG/PNG 格式,且必须包含后缀名!');
|
||||||
if (!isTypeValid) {
|
return false;
|
||||||
ElMessage.error('图片MIME类型不正确,请重新选择!');
|
}
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 校验大小 (20KB)
|
// 校验 MIME 类型
|
||||||
const isSizeValid = file.size / 1024 < 20;
|
const isTypeValid = file.type === 'image/jpeg' || file.type === 'image/png';
|
||||||
if (!isSizeValid) {
|
if (!isTypeValid) {
|
||||||
ElMessage.error('图片大小不能超过 20KB!');
|
ElMessage.error('图片MIME类型不正确,请重新选择!');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
// 校验大小 (20KB)
|
||||||
|
const isSizeValid = file.size / 1024 < 20;
|
||||||
|
if (!isSizeValid) {
|
||||||
|
ElMessage.error('图片大小不能超过 20KB!');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -382,10 +383,10 @@ const handleSubmit = async () => {
|
||||||
fee_inventory_time: varietyForm.value.feeInventoryTime,
|
fee_inventory_time: varietyForm.value.feeInventoryTime,
|
||||||
}
|
}
|
||||||
console.log(params)
|
console.log(params)
|
||||||
|
|
||||||
if (dialogType.value === 'edit') {
|
if (dialogType.value === 'edit') {
|
||||||
console.log(params)
|
console.log(params)
|
||||||
await editVarietyApi(params)
|
await editVarietyApi({ ...params, group_id: selectedRow.value.group.id, is_default: varietyForm.value.isDefault })
|
||||||
getVarietyList()
|
getVarietyList()
|
||||||
} else {
|
} else {
|
||||||
await createVarietyApi({ ...params })
|
await createVarietyApi({ ...params })
|
||||||
|
|
@ -421,7 +422,8 @@ const handleRowClick = (row: any) => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
:deep(.el-upload){
|
|
||||||
|
:deep(.el-upload) {
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,8 @@
|
||||||
* @description: 搜索配置
|
* @description: 搜索配置
|
||||||
*/
|
*/
|
||||||
export const search = [
|
export const search = [
|
||||||
// 品种名称
|
// 品种名称
|
||||||
{ prop: 'varietyName', label: '品种名称', type: 'input' as const, placeholder: '请输入品种名称' },
|
{ prop: 'varietyName', label: '品种名称', type: 'input' as const, placeholder: '请输入品种名称' },
|
||||||
]
|
]
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -30,8 +30,8 @@ export const tableColumns = [
|
||||||
{ prop: 'minFlux', label: '最小波动', align: 'center' as const },
|
{ prop: 'minFlux', label: '最小波动', align: 'center' as const },
|
||||||
// 单位
|
// 单位
|
||||||
{ prop: 'unit', label: '单位', align: 'center' as const },
|
{ prop: 'unit', label: '单位', align: 'center' as const },
|
||||||
// 交易时间
|
// 交易分组
|
||||||
{ prop: 'tradeGroup', label: '交易时间', align: 'center' as const },
|
{ prop: 'tradeGroup', label: '交易分组', align: 'center' as const },
|
||||||
// 多头库存费
|
// 多头库存费
|
||||||
{ prop: 'longStockFee', label: '多头库存费', align: 'center' as const },
|
{ prop: 'longStockFee', label: '多头库存费', align: 'center' as const },
|
||||||
// 空头库存费
|
// 空头库存费
|
||||||
|
|
@ -45,13 +45,13 @@ export const tableColumns = [
|
||||||
/**
|
/**
|
||||||
* @description: dialog表单配置
|
* @description: dialog表单配置
|
||||||
*/
|
*/
|
||||||
export const editDialogFormItem = [
|
export const DialogFormItem = [
|
||||||
// 名称
|
// 名称
|
||||||
{ prop: 'varietyName', label: '名称', type: 'input' as const, placeholder: '请输入名称' },
|
{ prop: 'varietyName', label: '名称', type: 'input' as const, placeholder: '请输入名称' },
|
||||||
// 编号
|
// 编号
|
||||||
{ prop: 'varietyCode', label: '编号', type: 'input' as const, placeholder: '请输入编号' },
|
{ prop: 'varietyCode', label: '编号', type: 'input' as const, placeholder: '请输入编号' },
|
||||||
// 交易时间
|
// 交易分组
|
||||||
{prop: 'tradeTime',label: '交易时间',type: 'select' as const,placeholder: '请选择交易时间',},
|
{ prop: 'tradeGroup', label: '交易分组', type: 'select' as const, placeholder: '请选择交易分组' },
|
||||||
// 最大点差
|
// 最大点差
|
||||||
{ prop: 'maxPoint', label: '最大点差', type: 'input' as const, placeholder: '请输入最大点差' },
|
{ prop: 'maxPoint', label: '最大点差', type: 'input' as const, placeholder: '请输入最大点差' },
|
||||||
// 最小点差
|
// 最小点差
|
||||||
|
|
@ -114,12 +114,12 @@ export const editDialogFormItem = [
|
||||||
valueFormat: 'HH:mm:ss',
|
valueFormat: 'HH:mm:ss',
|
||||||
isRange: false,
|
isRange: false,
|
||||||
},
|
},
|
||||||
// 交易分组
|
|
||||||
{ prop: 'tradeGroup', label: '交易分组', type: 'select' as const, placeholder: '请选择交易分组' },
|
|
||||||
// 上传图片地址
|
|
||||||
{ prop: 'imageUrl', slotName: 'upload', label: '上传图片', type: 'upload' as const },
|
|
||||||
// 上下线状态
|
// 上下线状态
|
||||||
{ prop: 'onlineStatus', label: '上下线状态', type: 'switch' as const },
|
{ prop: 'onlineStatus', label: '上下线状态', type: 'switch' as const },
|
||||||
// 交易状态
|
// 交易状态
|
||||||
{ prop: 'tradeStatus', label: '交易状态', type: 'switch' as const },
|
{ prop: 'tradeStatus', label: '交易状态', type: 'switch' as const },
|
||||||
|
// 是否默认
|
||||||
|
{ prop: 'isDefault', label: '', type: 'slot' as const, slotName: 'isDefault' },
|
||||||
|
// 上传图片地址
|
||||||
|
{ prop: 'imageUrl', slotName: 'upload', label: '上传图片', type: 'upload' as const },
|
||||||
]
|
]
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue