修复bug

This commit is contained in:
2026-04-23 17:03:58 +08:00
parent cb805781bd
commit b4b8acecd3
6 changed files with 76 additions and 39 deletions

View File

@ -179,7 +179,7 @@ export const request = {
}); });
}, },
post<T = unknown>(url: string, data?: unknown, config?: InternalAxiosRequestConfig): Promise<T> { post<T = unknown>(url: string, data?: unknown, config?: InternalAxiosRequestConfig): Promise<T> {
return service.post<ApiResponse<T>>(url, data, {config,showMessage: true,}).then((res) => { return service.post<ApiResponse<T>>(url, data, { ...config, showMessage: true,}).then((res) => {
return res as T; return res as T;
}); });
}, },

View File

@ -9,7 +9,6 @@ export const uploadImageApi = (file: any): Promise<{ url: string }> => {
// 构建FormData图片上传必须用FormData格式 // 构建FormData图片上传必须用FormData格式
const formData = new FormData(); const formData = new FormData();
formData.append('image', file); // 对应后端接收字段名image formData.append('image', file); // 对应后端接收字段名image
// 使用你已封装的post请求禁用loading富文本自身有状态提示 // 使用你已封装的post请求禁用loading富文本自身有状态提示
return request.post<{ url: string }>( return request.post<{ url: string }>(
'/upload/image', '/upload/image',
@ -17,7 +16,7 @@ export const uploadImageApi = (file: any): Promise<{ url: string }> => {
{ {
// 覆盖默认配置:图片上传需要特殊的请求头 // 覆盖默认配置:图片上传需要特殊的请求头
headers: { headers: {
'Content-Type': 'multipart/form-data', // 表单上传必须的头 'Content-type': 'multipart/form-data', // 表单上传必须的头
showLoading: false // 禁用全局loading避免和编辑器loading冲突 showLoading: false // 禁用全局loading避免和编辑器loading冲突
}, },
timeout: 30 * 1000, // 图片上传超时时间30秒 timeout: 30 * 1000, // 图片上传超时时间30秒

View File

@ -63,7 +63,7 @@
:range-separator="item.rangeSeparator || '至'" :range-separator="item.rangeSeparator || '至'"
:start-placeholder="item.startPlaceholder || '开始时间'" :start-placeholder="item.startPlaceholder || '开始时间'"
:end-placeholder="item.endPlaceholder || '结束时间'" :end-placeholder="item.endPlaceholder || '结束时间'"
:value-format="item.valueFormat || 'HH:mm:ss'" is-range /> :value-format="item.valueFormat || 'HH:mm:ss'" :is-range="item.isRange ?? true" />
<!-- 自定义插槽 --> <!-- 自定义插槽 -->
<slot v-else :name="item.slotName" :formData="formData" /> <slot v-else :name="item.slotName" :formData="formData" />
</el-form-item> </el-form-item>
@ -98,6 +98,7 @@ interface FormItem {
valueFormat?: string valueFormat?: string
clearable?: boolean clearable?: boolean
disabledDate?: (time: Date) => boolean disabledDate?: (time: Date) => boolean
isRange?: boolean
} }
interface Props { interface Props {

View File

@ -107,8 +107,8 @@ const varietyForm = ref({
minFlux: '', minFlux: '',
// //
unit: '', unit: '',
// //
tradeGroup: '', tradeTime: '',
// //
longStockFee: '', longStockFee: '',
// //
@ -130,29 +130,43 @@ const varietyForm = ref({
type: '', type: '',
// //
imageUrl: '', imageUrl: '',
//
feeInventoryTime: '',
//
tradeGroup: '',
}) })
const varietyFormRef = ref<any>() const varietyFormRef = ref<any>()
const varietyFormRules = ref(rules()) const varietyFormRules = ref(rules())
const dialogFormItemOptions = ref(editDialogFormItem) const dialogFormItemOptions = ref(editDialogFormItem)
const varietyFormOptionsMap = ref({ const varietyFormOptionsMap = ref({
tradeTime: [
{
label: '2026-4-23',
value: '2026-4-23',
},
],
tradeGroup: [], tradeGroup: [],
type: [ type: [
{ {
label: '金属', label: '外汇',
value: 1, value: 1,
}, },
{ {
label: '能源', label: '金属',
value: 2, value: 2,
}, },
{ {
label: '指数', label: '能源',
value: 3, value: 3,
}, },
{ {
label: '股票', label: '指数',
value: 4, value: 4,
}, },
{
label: '数字货币',
value: 5,
},
], ],
}) })
// //
@ -163,10 +177,11 @@ const colSpan = ref(12)
const fileList = ref([]) const fileList = ref([])
const typeMap: any = { const typeMap: any = {
1: '金属', 1: '外汇',
2: '能源', 2: '金属',
3: '指数', 3: '能源',
4: '股票', 4: '指数',
5: '数字货币',
} }
/** /**
@ -193,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.name, tradeGroup: item.group,
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,
@ -202,7 +217,7 @@ const getVarietyList = async () => {
})) }))
} }
// //
const getTradeGroupList = async () => { const getTradeGroupList = async () => {
const data = await getTradeGroupListApi() const data = await getTradeGroupListApi()
varietyFormOptionsMap.value.tradeGroup = data.map((item: any) => ({ varietyFormOptionsMap.value.tradeGroup = data.map((item: any) => ({
@ -271,7 +286,7 @@ const handleAdd = () => {
contractSize: '', contractSize: '',
minFlux: '', minFlux: '',
unit: '', unit: '',
tradeGroup: '', tradeTime: '',
longStockFee: '', longStockFee: '',
shortStockFee: '', shortStockFee: '',
profitLevel: '', profitLevel: '',
@ -286,6 +301,8 @@ const handleAdd = () => {
type: '', type: '',
// //
imageUrl: '', imageUrl: '',
feeInventoryTime: '',
tradeGroup: '',
} }
fileList.value = [] fileList.value = []
} }
@ -309,18 +326,30 @@ const handleUpload = async (options: any) => {
// + 20KB = 20 * 1024 // + 20KB = 20 * 1024
const beforeUpload = (file: File) => { const beforeUpload = (file: File) => {
const isTypeValid = file.type === 'image/jpeg' || file.type === 'image/png' //
if (!isTypeValid) { const fileName = file.name.toLowerCase();
ElMessage.error('只能上传 JPG/PNG 格式!') const isJpgOrPng = fileName.endsWith('.jpg') || fileName.endsWith('.jpeg') || fileName.endsWith('.png');
return false
} if (!isJpgOrPng) {
ElMessage.error('上传图片只能是 JPG/PNG 格式,且必须包含后缀名!');
return false;
}
const isSizeValid = file.size / 1024 < 20 // MIME
if (!isSizeValid) { const isTypeValid = file.type === 'image/jpeg' || file.type === 'image/png';
ElMessage.error('图片大小不能超过 20KB') if (!isTypeValid) {
return false ElMessage.error('图片MIME类型不正确请重新选择!');
} return false;
return true }
// (20KB)
const isSizeValid = file.size / 1024 < 20;
if (!isSizeValid) {
ElMessage.error('图片大小不能超过 20KB!');
return false;
}
return true;
} }
@ -333,7 +362,7 @@ const handleSubmit = async () => {
id: varietyForm.value.id, id: varietyForm.value.id,
code: varietyForm.value.varietyCode, code: varietyForm.value.varietyCode,
name: varietyForm.value.varietyName, name: varietyForm.value.varietyName,
group_id: varietyForm.value.groupId, group_id: varietyForm.value.tradeGroup,
point_diff: varietyForm.value.minPoint, point_diff: varietyForm.value.minPoint,
fee_inventory_short: varietyForm.value.shortStockFee, fee_inventory_short: varietyForm.value.shortStockFee,
status: varietyForm.value.tradeStatus, status: varietyForm.value.tradeStatus,
@ -350,6 +379,7 @@ const handleSubmit = async () => {
online_status: varietyForm.value.onlineStatus, online_status: varietyForm.value.onlineStatus,
type: Number(varietyForm.value.type), type: Number(varietyForm.value.type),
image: varietyForm.value.imageUrl, image: varietyForm.value.imageUrl,
fee_inventory_time: varietyForm.value.feeInventoryTime,
} }
console.log(params) console.log(params)
@ -358,7 +388,7 @@ const handleSubmit = async () => {
await editVarietyApi(params) await editVarietyApi(params)
getVarietyList() getVarietyList()
} else { } else {
await createVarietyApi({ ...params, group_id: varietyForm.value.tradeGroup }) await createVarietyApi({ ...params })
getVarietyList() getVarietyList()
} }
dialogVisible.value = false dialogVisible.value = false

View File

@ -51,12 +51,7 @@ export const editDialogFormItem = [
// 编号 // 编号
{ 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: '请输入最大点差' },
// 最小点差 // 最小点差
@ -113,6 +108,14 @@ export const editDialogFormItem = [
{ prop: 'minFlux', label: '最小波动', type: 'input' as const, placeholder: '请输入最小波动' }, { prop: 'minFlux', label: '最小波动', type: 'input' as const, placeholder: '请输入最小波动' },
// 类型 // 类型
{ prop: 'type', label: '类型', type: 'select' as const, placeholder: '请选择类型' }, { prop: 'type', label: '类型', type: 'select' as const, placeholder: '请选择类型' },
// 库存费收取时间
{
prop: 'feeInventoryTime', label: '库存费收取时间', type: 'time' as const,
valueFormat: 'HH:mm:ss',
isRange: false,
},
// 交易分组
{ prop: 'tradeGroup', label: '交易分组', type: 'select' as const, placeholder: '请选择交易分组' },
// 上传图片地址 // 上传图片地址
{ prop: 'imageUrl', slotName: 'upload', label: '上传图片', type: 'upload' as const }, { prop: 'imageUrl', slotName: 'upload', label: '上传图片', type: 'upload' as const },
// 上下线状态 // 上下线状态

View File

@ -45,9 +45,9 @@ export const rules = (): FormRules => {
varietyCode: [ varietyCode: [
{ required: true, message: '请输入编号', trigger: ['blur', 'change'] } { required: true, message: '请输入编号', trigger: ['blur', 'change'] }
], ],
// 所属交易 // 所属交易时间
tradeGroup: [ tradeTime: [
{ required: true, message: '请输入所属交易组', trigger: ['blur', 'change'] } { required: true, message: '请选择交易时间', trigger: ['blur', 'change'] }
], ],
// 最大点差 // 最大点差
maxPoint: [ maxPoint: [
@ -118,5 +118,9 @@ export const rules = (): FormRules => {
imageUrl: [ imageUrl: [
{ required: true, message: '请上传图片', trigger: ['blur', 'change'] } { required: true, message: '请上传图片', trigger: ['blur', 'change'] }
], ],
// 库存费收取时间
feeInventoryTime: [
{ required: true, message: '请选择库存费收取时间', trigger: ['blur', 'change'] }
],
} }
} }