diff --git a/core/core-frontend/src/views/visualized/data/datasource/form/ApiHttpRequestDraw.vue b/core/core-frontend/src/views/visualized/data/datasource/form/ApiHttpRequestDraw.vue index c6f2c62281..a1b18ef258 100644 --- a/core/core-frontend/src/views/visualized/data/datasource/form/ApiHttpRequestDraw.vue +++ b/core/core-frontend/src/views/visualized/data/datasource/form/ApiHttpRequestDraw.vue @@ -31,6 +31,7 @@ export interface ApiItem { type: string deTableName?: string url: string + copy: boolean method: string request: ApiRequest fields: Field[] @@ -163,8 +164,12 @@ const rule = reactive({ }) const activeName = ref('table') const editItem = ref(false) +const copyItem = ref(false) +const copyDs = ref(false) provide('api-active-name', activeName) const initApiItem = (val: ApiItem, from, name, edit) => { + copyItem.value = val.copy + copyDs.value = from.copy activeName.value = name editItem.value = edit apiItemList = from.apiConfiguration @@ -283,10 +288,20 @@ const saveItem = () => { } } } - if (msg !== '') { + if (msg !== '' && !(copyDs.value || copyItem.value)) { ElMessage.error(t('datasource.primary_key_change') + msg) return } + for (let i = 0; i < apiItem.fields.length; i++) { + if ( + apiItem.fields[i].primaryKey && + !apiItem.fields[i].length && + apiItem.fields[i].deExtractType === 0 + ) { + ElMessage.error(t('datasource.primary_key_length') + apiItem.fields[i].name) + return + } + } } else { for (let i = 0; i < apiItem.fields.length; i++) { if ( @@ -402,6 +417,22 @@ const disabledFieldLength = item => { } } +const disabledSetKey = item => { + if (item.hasOwnProperty('children') && item.children.length > 0) { + return true + } + if (copyItem.value || copyDs.value) { + return false + } + if (editItem.value) { + return true + } + if (!item.checked) { + return true + } + return false +} + const disabledChangeFieldByChildren = item => { if (apiItem.type == 'params') { return true @@ -793,7 +824,7 @@ defineExpose({ diff --git a/core/core-frontend/src/views/visualized/data/datasource/form/EditorDetail.vue b/core/core-frontend/src/views/visualized/data/datasource/form/EditorDetail.vue index 85f8b9ee55..c5721ae9df 100644 --- a/core/core-frontend/src/views/visualized/data/datasource/form/EditorDetail.vue +++ b/core/core-frontend/src/views/visualized/data/datasource/form/EditorDetail.vue @@ -367,6 +367,7 @@ const copyItem = (item?: ApiConfiguration) => { newItem.deTableName = '' newItem.serialNumber = form.value.apiConfiguration[form.value.apiConfiguration.length - 1].serialNumber + 1 + newItem.copy = true const reg = new RegExp(item.name + '_copy_' + '([0-9]*)', 'gim') let number = 0 for (let i = 1; i < form.value.apiConfiguration.length; i++) { diff --git a/core/core-frontend/src/views/visualized/data/datasource/form/index.vue b/core/core-frontend/src/views/visualized/data/datasource/form/index.vue index 7abea403d8..c5b7f4a4f9 100644 --- a/core/core-frontend/src/views/visualized/data/datasource/form/index.vue +++ b/core/core-frontend/src/views/visualized/data/datasource/form/index.vue @@ -39,6 +39,7 @@ interface Form { id?: string description: string type: string + copy: boolean configuration?: Configuration apiConfiguration?: ApiConfiguration[] paramsConfiguration?: ApiConfiguration[] diff --git a/core/core-frontend/src/views/visualized/data/datasource/form/option.ts b/core/core-frontend/src/views/visualized/data/datasource/form/option.ts index 08750fe6d2..19e9afe72b 100644 --- a/core/core-frontend/src/views/visualized/data/datasource/form/option.ts +++ b/core/core-frontend/src/views/visualized/data/datasource/form/option.ts @@ -156,6 +156,7 @@ export interface ApiConfiguration { type: string deTableName: string method: string + copy: boolean url: string status: string useJsonPath: boolean @@ -178,6 +179,7 @@ export interface Node { name: string createBy: string creator: string + copy: boolean createTime: string id: number | string size: number diff --git a/core/core-frontend/src/views/visualized/data/datasource/index.vue b/core/core-frontend/src/views/visualized/data/datasource/index.vue index cf41e7ae30..570d343040 100644 --- a/core/core-frontend/src/views/visualized/data/datasource/index.vue +++ b/core/core-frontend/src/views/visualized/data/datasource/index.vue @@ -806,6 +806,7 @@ const handleCopy = async data => { lastSyncTime }) datasource.id = '' + datasource.copy = true datasource.name = t('datasource.copy') if (datasource.type === 'API') { for (let i = 0; i < datasource.apiConfiguration.length; i++) {