|
@@ -239,31 +239,21 @@ const formQuery = ref({
|
|
|
})
|
|
|
const careerTrajectory = ref([{ hotel_zh: null, title_zh: null, date: null }])
|
|
|
|
|
|
-// 保持电话数量为3
|
|
|
-function processVariable(input) {
|
|
|
- if (Array.isArray(input)) {
|
|
|
- // 如果是数组,保持长度为3
|
|
|
- if (input.length > 3) {
|
|
|
- return input.slice(0, 3); // 截取前3个元素
|
|
|
- } else if (input.length < 3) {
|
|
|
- // 填充到长度为3,用undefined填充
|
|
|
- return input.concat(new Array(3 - input.length).fill(undefined));
|
|
|
- }
|
|
|
- return input; // 正好是3个元素,直接返回
|
|
|
- } else if (typeof input === 'string') {
|
|
|
- // 如果是字符串,转换为长度为3的数组
|
|
|
- const result = new Array(3);
|
|
|
- result[0] = input;
|
|
|
- return result;
|
|
|
+// 保持手机号码数量为三个
|
|
|
+function splitStringToArray(str) {
|
|
|
+ const parts = str.split(',').map(item => item.trim());
|
|
|
+ let result = [];
|
|
|
+ for (let i = 0; i < 3; i++) {
|
|
|
+ result.push(parts[i] || ''); // 如果元素不存在则使用空字符串
|
|
|
}
|
|
|
- // 如果不是数组也不是字符串
|
|
|
- return [undefined, undefined, undefined]
|
|
|
+ return result;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
if (props.itemData) {
|
|
|
formQuery.value = cloneDeep(props.itemData)
|
|
|
careerTrajectory.value = cloneDeep(props.itemData?.career_path) ?? []
|
|
|
- formQuery.value.mobile = processVariable(formQuery.value.mobile)
|
|
|
+ formQuery.value.mobile = splitStringToArray(formQuery.value.mobile)
|
|
|
}
|
|
|
|
|
|
const addCareer = () => {
|