xinyb
2024-07-01 41485264ec9de48ffde1e506b897962e20c8440e
调整控件布局顺序排序保存问题
1个文件已修改
49 ■■■■■ 已修改文件
WebRoot/general/CustomControl/js/utils.js 49 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
WebRoot/general/CustomControl/js/utils.js
@@ -89,11 +89,59 @@
  });
}
// function getResultData(layoutsData){
//   let resultList = [];
//   layoutsData.map((item,index)=>{
//     item.map((item2,index2)=>{
//       item2.map((item3,index3)=>{
//         item3.data.map((item4,index4)=>{
//           if (!item4.userCode||!item4.formId) return;
//           resultList.push({
//             "userCode": item4.userCode,
//             "formId": item4.formId,
//             "formType": item4.formType,
//             "headFlag": item4.headFlag,
//             "fieldId": item4.id,
//             "statisId": (index4+1)*10,
//             "fieldName": item4.name,
//             "dataType": item4.dataType,
//             "dataTypeLength": item4.dataTypeLength,
//             "showOnGrid": item4.showOnGrid,
//             "gridCaption": item4.gridCaption,
//             "visible": item4.visible,
//             "hideLabel": item4.hideLabel,
//             "colNo": item4.x<=0?1:item4.x+1,
//             "rowNo": item4.y<=0?1:item4.y+1,
//             "lengthNum": item4.w,
//             "heightNum": item4.h,
//             "masterFieldShowLocation": item4.masterFieldShowLocation,
//           })
//         })
//       })
//     })
//   })
//   return resultList;
// }
function getResultData(layoutsData){
  console.log('layoutsData原始',layoutsData);
  let resultList = [];
  layoutsData.map((item,index)=>{
    item.map((item2,index2)=>{
      item2.map((item3,index3)=>{
        if (item3.filedName==='master'||item3.filedName==='master1'){
          // 对item3.data进行遍历,按item4的x,y顺序,按从小到大排列顺序
          item3.data.sort((a,b)=>{
            // 首先比较y值,如果相等则比较x值
            if(a.y>b.y) return 1;
            if(a.y<b.y) return -1;
            if (a.x>b.x) return 1;
            if (a.x<b.x) return -1;
            // 相等则返回0
            return 0;
          })
          // console.log('排列后',item3.data);
          // console.table(JSON.parse(JSON.stringify(item3.data)));
        }
        item3.data.map((item4,index4)=>{
          if (!item4.userCode||!item4.formId) return;
          resultList.push({
@@ -122,6 +170,7 @@
  })
  return resultList;
}
function getResultFormId(layoutsData){
  let array=[];
  let json = {};