|
|
|
@ -481,7 +481,23 @@ function asfValueChanged(val:any){ |
|
|
|
if(masterFillRoleFieldsArray1.length>0){ |
|
|
|
masterFillRoleFieldsArray1.forEach((item1:any)=>{ |
|
|
|
let x = convertObjectToArray(getNewObject(item.fillRolesFieldsMap,item1)) |
|
|
|
formProps.value.model[x[0]] = x[1] |
|
|
|
let strOrNumber = convertToStringOrNumber(x[1]) |
|
|
|
let strOrNumberOrArray |
|
|
|
if(isString(strOrNumber)&&strOrNumber.includes("[")){ |
|
|
|
strOrNumberOrArray = convertIfValidNumberArray(strOrNumber) |
|
|
|
} |
|
|
|
|
|
|
|
/* console.log(x[1]) |
|
|
|
console.log(strOrNumberOrArray) |
|
|
|
console.log(formProps.value.model[x[0]]) */ |
|
|
|
if(strOrNumberOrArray){ |
|
|
|
formProps.value.model[x[0]] = strOrNumberOrArray |
|
|
|
}else{ |
|
|
|
formProps.value.model[x[0]] = strOrNumber |
|
|
|
} |
|
|
|
|
|
|
|
//console.log(formProps.value.model[x[0]]) |
|
|
|
|
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
|
@ -492,6 +508,25 @@ function asfValueChanged(val:any){ |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
function isString(value: any): value is string { |
|
|
|
return typeof value === 'string'; |
|
|
|
} |
|
|
|
function convertIfValidNumberArray(str: string): number[] | null { |
|
|
|
const regex = /^\[(\d+(,\d+)*)?\]$/; |
|
|
|
if (regex.test(str)) { |
|
|
|
const numbersStr = str.slice(1, -1); |
|
|
|
if (numbersStr.length === 0) { |
|
|
|
return []; |
|
|
|
} |
|
|
|
return numbersStr.split(',').map(item => Number(item)); |
|
|
|
} else { |
|
|
|
return null; |
|
|
|
} |
|
|
|
} |
|
|
|
function convertToStringOrNumber(str: string): number | string { |
|
|
|
const isOnlyNumbers = /^\d+$/.test(str); |
|
|
|
return isOnlyNumbers? Number(str) : str; |
|
|
|
} |
|
|
|
function convertObjectToArray(obj:any) { |
|
|
|
for (let key in obj) { |
|
|
|
return [key, obj[key]]; |
|
|
|
|