Sfoglia il codice sorgente

以逗号分隔手机号,提交时再以逗号分隔提交给后端。手机号最多可填三个。(固定电话不做处理)

lifanagju_citu 4 giorni fa
parent
commit
808e022f4f

+ 9 - 19
src/views/menduner/system/talentMap/maintenance/gather/businessCard/FormPage.vue

@@ -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 = () => {

+ 1 - 4
src/views/menduner/system/talentMap/maintenance/gather/businessCard/index.vue

@@ -260,10 +260,7 @@ const FormPageRef = ref(null)
 const mergeFormRef = ref() // 合并表单 Ref
 const handleSave = async () => {
   const params = FormPageRef.value.formQuery
-  // 等后端改接口,目前接口是字符串,非数组
-  params.mobile = params.mobile[0]
-  // const filtered = params.mobile.filter(e => e !== undefined && e !== null && e !== '')
-  // params.mobile = filtered?.length > 1 ? filtered : filtered[0]
+  params.mobile = params.mobile.filter(item => Boolean(item)).map(item => String(item).replace(/,|,/g, '')).join(',');
   console.log(params, 'handleSubmit')
   try {
     formLoading.value = true