[表单设计]同一个表单多人编辑或多机器编辑id重复问题修改

zzq
Zhufu 2024-06-15 15:31:16 +08:00
parent e754a4ac20
commit 1acac4aef3
1 changed files with 3 additions and 2 deletions

View File

@ -1,6 +1,7 @@
// import { VueConstructor } from 'vue';
import { IVFormComponent, IFormConfig, IValidationRule } from '../typings/v-form-component';
import { cloneDeep, isArray, isFunction, isNumber, uniqueId } from 'lodash-es';
import { v4 as uuidv4 } from 'uuid';
// import { del } from '@vue/composition-api';
// import { withInstall } from '@/utils';
@ -23,13 +24,13 @@ import { cloneDeep, isArray, isFunction, isNumber, uniqueId } from 'lodash-es';
*/
export function generateKey(formItem?: IVFormComponent): string | boolean {
if (formItem && formItem.component) {
const key = uniqueId(`${toLine(formItem.component)}_`);
const key = `${toLine(formItem.component)}_${uuidv4().replace(/-/g, '')}`;
formItem.key = key;
formItem.field = formItem.field || key;
return true;
}
return uniqueId('key_');
return `key_${uuidv4().replace(/-/g, '')}`;
}
/**