修复品种bug

This commit is contained in:
2026-04-24 09:48:58 +08:00
parent b4b8acecd3
commit 1ad3d7379f
3 changed files with 56 additions and 54 deletions

View File

@ -5,7 +5,7 @@
<template v-for="(item, index) in formItems" :key="index">
<el-col :span="props.colSpan || 24">
<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]"
:placeholder="item.placeholder" :disabled="item.disabled" clearable />

View File

@ -38,9 +38,16 @@
jpg/png格式 图片大小不能超过20KB
</div>
</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>
</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>
</VarietyDialog>
<!-- dialog表格 -->
@ -48,7 +55,6 @@
</template>
<script setup lang="ts">
import type { UploadProps, UploadUserFile } from 'element-plus'
//
import VarietySearch from '@/components/common/Search.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 { search, tableColumns, editDialogFormItem } from './options'
import { search, tableColumns, DialogFormItem } from './options'
import { rules } from './rules'
//
@ -107,8 +113,6 @@ const varietyForm = ref({
minFlux: '',
//
unit: '',
//
tradeTime: '',
//
longStockFee: '',
//
@ -134,17 +138,13 @@ const varietyForm = ref({
feeInventoryTime: '',
//
tradeGroup: '',
//
isDefault: '',
})
const varietyFormRef = ref<any>()
const varietyFormRules = ref(rules())
const dialogFormItemOptions = ref(editDialogFormItem)
const dialogFormItemOptions = ref(DialogFormItem)
const varietyFormOptionsMap = ref({
tradeTime: [
{
label: '2026-4-23',
value: '2026-4-23',
},
],
tradeGroup: [],
type: [
{
@ -208,7 +208,7 @@ const getVarietyList = async () => {
contractSize: item.multiplier,
minFlux: item.undulate_min,
unit: item.unit,
tradeGroup: item.group,
tradeGroup: item.group.name,
longStockFee: item.fee_inventory_long,
shortStockFee: item.fee_inventory_short,
profitLevel: item.stop_loss_level,
@ -247,7 +247,6 @@ const handleReset = () => {
handleSearch()
}
console.log('varietyForm.value)', varietyForm.value)
const handleEdit = () => {
getTradeGroupList()
const row = selectedRow.value;
@ -264,7 +263,11 @@ const handleEdit = () => {
//
pointDecimalPlaces: row.point_diff_decimal_place,
imageUrl: row.image,
feeInventoryTime: row.fee_inventory_time,
//
isDefault: row.is_default,
} as any
//
dialogVisible.value = true
dialogTitle.value = '编辑合约品种'
@ -286,23 +289,21 @@ const handleAdd = () => {
contractSize: '',
minFlux: '',
unit: '',
tradeTime: '',
longStockFee: '',
shortStockFee: '',
profitLevel: '',
id: '',
groupId: '',
prepaymentHedge: '',
prepaymentPercent: '',
decimalPlaces: '',
pointDecimalPlaces: '',
//
type: '',
//
imageUrl: '',
feeInventoryTime: '',
tradeGroup: '',
//
isDefault: '',
}
fileList.value = []
}
@ -326,30 +327,30 @@ const handleUpload = async (options: any) => {
// + 20KB = 20 * 1024
const beforeUpload = (file: File) => {
//
const fileName = file.name.toLowerCase();
const isJpgOrPng = fileName.endsWith('.jpg') || fileName.endsWith('.jpeg') || fileName.endsWith('.png');
if (!isJpgOrPng) {
ElMessage.error('上传图片只能是 JPG/PNG 格式,且必须包含后缀名!');
return false;
}
//
const fileName = file.name.toLowerCase();
const isJpgOrPng = fileName.endsWith('.jpg') || fileName.endsWith('.jpeg') || fileName.endsWith('.png');
// MIME
const isTypeValid = file.type === 'image/jpeg' || file.type === 'image/png';
if (!isTypeValid) {
ElMessage.error('图片MIME类型不正确请重新选择!');
return false;
}
if (!isJpgOrPng) {
ElMessage.error('上传图片只能是 JPG/PNG 格式,且必须包含后缀名!');
return false;
}
// (20KB)
const isSizeValid = file.size / 1024 < 20;
if (!isSizeValid) {
ElMessage.error('图片大小不能超过 20KB!');
return false;
}
// MIME
const isTypeValid = file.type === 'image/jpeg' || file.type === 'image/png';
if (!isTypeValid) {
ElMessage.error('图片MIME类型不正确请重新选择!');
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,
}
console.log(params)
if (dialogType.value === 'edit') {
console.log(params)
await editVarietyApi(params)
await editVarietyApi({ ...params, group_id: selectedRow.value.group.id, is_default: varietyForm.value.isDefault })
getVarietyList()
} else {
await createVarietyApi({ ...params })
@ -421,7 +422,8 @@ const handleRowClick = (row: any) => {
}
}
}
:deep(.el-upload){
:deep(.el-upload) {
flex-direction: column;
}
</style>

View File

@ -2,8 +2,8 @@
* @description:
*/
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: '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 },
// 空头库存费
@ -45,13 +45,13 @@ export const tableColumns = [
/**
* @description: dialog表单配置
*/
export const editDialogFormItem = [
export const DialogFormItem = [
// 名称
{ prop: 'varietyName', 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: '请输入最大点差' },
// 最小点差
@ -114,12 +114,12 @@ export const editDialogFormItem = [
valueFormat: 'HH:mm:ss',
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: 'tradeStatus', label: '交易状态', type: 'switch' as const },
// 是否默认
{ prop: 'isDefault', label: '', type: 'slot' as const, slotName: 'isDefault' },
// 上传图片地址
{ prop: 'imageUrl', slotName: 'upload', label: '上传图片', type: 'upload' as const },
]