Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions backend/apps/data_training/api/data_training.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from common.core.config import settings
from common.core.deps import SessionDep, CurrentUser, Trans
from common.utils.data_format import DataFormat
from common.utils.excel import get_excel_column_count

router = APIRouter(tags=["DataTraining"], prefix="/system/data-training")

Expand Down Expand Up @@ -136,6 +137,9 @@ def inner():

for sheet_name in sheet_names:

if get_excel_column_count(save_path, sheet_name) < len(use_cols):
raise Exception(trans("i18n_excel_import.col_num_not_match"))

df = pd.read_excel(
save_path,
sheet_name=sheet_name,
Expand Down
4 changes: 4 additions & 0 deletions backend/apps/terminology/api/terminology.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from common.core.config import settings
from common.core.deps import SessionDep, CurrentUser, Trans
from common.utils.data_format import DataFormat
from common.utils.excel import get_excel_column_count

router = APIRouter(tags=["Terminology"], prefix="/system/terminology")

Expand Down Expand Up @@ -133,6 +134,9 @@ def inner():

for sheet_name in sheet_names:

if get_excel_column_count(save_path, sheet_name) < len(use_cols):
raise Exception(trans("i18n_excel_import.col_num_not_match"))

df = pd.read_excel(
save_path,
sheet_name=sheet_name,
Expand Down
12 changes: 12 additions & 0 deletions backend/common/utils/excel.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import pandas as pd

def get_excel_column_count(file_path, sheet_name):
"""获取Excel文件的列数"""
df_temp = pd.read_excel(
file_path,
sheet_name=sheet_name,
engine='calamine',
header=0,
nrows=0
)
return len(df_temp.columns)
3 changes: 3 additions & 0 deletions backend/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,5 +83,8 @@
},
"i18n_excel_export": {
"data_is_empty": "Form data is empty, unable to export data"
},
"i18n_excel_import": {
"col_num_not_match": "Number of columns in Excel does not match"
}
}
3 changes: 3 additions & 0 deletions backend/locales/ko-KR.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,5 +83,8 @@
},
"i18n_excel_export": {
"data_is_empty": "폼 데이터가 비어 있어 데이터를 내보낼 수 없습니다"
},
"i18n_excel_import": {
"col_num_not_match": "Excel 열 개수가 일치하지 않습니다"
}
}
3 changes: 3 additions & 0 deletions backend/locales/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,5 +83,8 @@
},
"i18n_excel_export": {
"data_is_empty": "表单数据为空,无法导出数据"
},
"i18n_excel_import": {
"col_num_not_match": "EXCEL列数量不匹配"
}
}
13 changes: 11 additions & 2 deletions frontend/src/views/system/professional/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import IconOpeDelete from '@/assets/svg/icon_delete.svg'
import icon_searchOutline_outlined from '@/assets/svg/icon_search-outline_outlined.svg'
import EmptyBackground from '@/views/dashboard/common/EmptyBackground.vue'
import { useI18n } from 'vue-i18n'
import { cloneDeep } from 'lodash-es'
import { cloneDeep, endsWith, startsWith } from 'lodash-es'
import { genFileId, type UploadInstance, type UploadProps, type UploadRawFile } from 'element-plus'
import { useCache } from '@/utils/useCache.ts'
import { settingsApi } from '@/api/setting.ts'
Expand Down Expand Up @@ -164,9 +164,18 @@ const onSuccess = (response: any) => {
}
}

const onError = () => {
const onError = (err: Error) => {
uploadLoading.value = false
uploadRef.value!.clearFiles()
let msg = err.message
if (startsWith(msg, '"') && endsWith(msg, '"')) {
msg = msg.slice(1, msg.length - 1)
}
ElMessage({
message: msg,
type: 'error',
showClose: true,
})
}

const exportExcel = () => {
Expand Down
13 changes: 11 additions & 2 deletions frontend/src/views/system/prompt/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import icon_searchOutline_outlined from '@/assets/svg/icon_search-outline_outlin
import EmptyBackground from '@/views/dashboard/common/EmptyBackground.vue'
import { useClipboard } from '@vueuse/core'
import { useI18n } from 'vue-i18n'
import { cloneDeep } from 'lodash-es'
import { cloneDeep, endsWith, startsWith } from 'lodash-es'
import { genFileId, type UploadInstance, type UploadProps, type UploadRawFile } from 'element-plus'
import { settingsApi } from '@/api/setting.ts'
import { useCache } from '@/utils/useCache.ts'
Expand Down Expand Up @@ -167,9 +167,18 @@ const onSuccess = (response: any) => {
}
}

const onError = () => {
const onError = (err: Error) => {
uploadLoading.value = false
uploadRef.value!.clearFiles()
let msg = err.message
if (startsWith(msg, '"') && endsWith(msg, '"')) {
msg = msg.slice(1, msg.length - 1)
}
ElMessage({
message: msg,
type: 'error',
showClose: true,
})
}

const exportExcel = () => {
Expand Down
13 changes: 11 additions & 2 deletions frontend/src/views/system/training/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import EmptyBackground from '@/views/dashboard/common/EmptyBackground.vue'
import { useClipboard } from '@vueuse/core'
import { useUserStore } from '@/stores/user'
import { useI18n } from 'vue-i18n'
import { cloneDeep } from 'lodash-es'
import { cloneDeep, endsWith, startsWith } from 'lodash-es'
import { getAdvancedApplicationList } from '@/api/embedded.ts'
import { genFileId } from 'element-plus'

Expand Down Expand Up @@ -172,9 +172,18 @@ const onSuccess = (response: any) => {
}
}

const onError = () => {
const onError = (err: Error) => {
uploadLoading.value = false
uploadRef.value!.clearFiles()
let msg = err.message
if (startsWith(msg, '"') && endsWith(msg, '"')) {
msg = msg.slice(1, msg.length - 1)
}
ElMessage({
message: msg,
type: 'error',
showClose: true,
})
}

const exportExcel = () => {
Expand Down