fix(数据源): 复制API数据表,增加后缀

This commit is contained in:
taojinlong 2022-08-25 17:11:55 +08:00
parent 9c9898b4b5
commit 28cb167fbe
4 changed files with 17 additions and 1 deletions

View File

@ -1641,6 +1641,7 @@ export default {
has_repeat_name: 'Duplicate API data table name',
has_repeat_field_name: 'The field name is duplicate, please modify it before selecting',
api_field_not_empty: 'Field cannot be empty',
success_copy: 'Copy succeeded',
valid: 'Valid',
invalid: 'Invalid',
api_step_1: 'Connection API',

View File

@ -1641,6 +1641,7 @@ export default {
has_repeat_name: 'API 數據表名稱重複',
has_repeat_field_name: '欄位名重複,請修改後再選擇',
api_field_not_empty: '欄位不能為空',
success_copy: '複製成功',
valid: '有效',
invalid: '無效',
api_step_1: '連接API',

View File

@ -1649,6 +1649,7 @@ export default {
has_repeat_name: 'API 数据表名称重复',
has_repeat_field_name: '字段名重复,请修改后再选择',
api_field_not_empty: '字段不能为空',
success_copy: '复制成功',
valid: '有效',
invalid: '无效',
api_step_1: '连接API',

View File

@ -1010,8 +1010,21 @@ export default {
copyItem(item){
var newItem = JSON.parse(JSON.stringify(item))
newItem.serialNumber = this.form.apiConfiguration[this.form.apiConfiguration.length - 1].serialNumber + 1
newItem.name = item.name + '_copy'
var reg = new RegExp(item.name + '_copy_' + '([0-9]*)', "gim");
var number = 0
for(var i =1;i<this.form.apiConfiguration.length;i++){
var match = this.form.apiConfiguration[i].name.match(reg);
if (match !== null) {
var num = match[0].substring(this.form.apiConfiguration[i].name.length + 5, match[0].length - 1)
if( parseInt(num) != NaN && parseInt(num) > number){
number = parseInt(num)
}
}
}
number = number + 1
newItem.name = item.name + '_copy_' + number
this.form.apiConfiguration.push(newItem)
this.$message.success(i18n.t('datasource.success_copy'))
},
addApiItem(item) {
if (item) {