mirror of
https://github.com/dataease/dataease.git
synced 2026-05-15 13:32:18 +08:00
fix: 【数据源】API数据源复制设置了主键的表无法修改主键
This commit is contained in:
@@ -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<FormRules>({
|
||||
})
|
||||
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({
|
||||
<el-checkbox
|
||||
:key="scope.row.jsonPath"
|
||||
v-model="scope.row.primaryKey"
|
||||
:disabled="editItem || !scope.row.checked"
|
||||
:disabled="disabledSetKey(scope.row)"
|
||||
>
|
||||
</el-checkbox>
|
||||
</template>
|
||||
|
||||
@@ -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++) {
|
||||
|
||||
@@ -39,6 +39,7 @@ interface Form {
|
||||
id?: string
|
||||
description: string
|
||||
type: string
|
||||
copy: boolean
|
||||
configuration?: Configuration
|
||||
apiConfiguration?: ApiConfiguration[]
|
||||
paramsConfiguration?: ApiConfiguration[]
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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++) {
|
||||
|
||||
Reference in New Issue
Block a user