修复品种bug
This commit is contained in:
parent
b4b8acecd3
commit
1ad3d7379f
|
|
@ -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 />
|
||||
|
|
|
|||
|
|
@ -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>
|
||||
|
|
|
|||
|
|
@ -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 },
|
||||
]
|
||||
|
|
|
|||
Loading…
Reference in New Issue