Explorar o código

[Mod 0000] 优化风机监测表格可以根据风筒数量自动合并表格

hongrunxia hai 1 día
pai
achega
51ac9b7d0a
Modificáronse 1 ficheiros con 123 adicións e 12 borrados
  1. 123 12
      src/views/vent/monitorManager/comment/GroupMonitorTable.vue

+ 123 - 12
src/views/vent/monitorManager/comment/GroupMonitorTable.vue

@@ -102,6 +102,104 @@
   };
 
   /** 定义table Columns */
+  // function setColumns(columnsType) {
+  //   const isCheckColumn = {
+  //     title: '',
+  //     dataIndex: 'isCheck',
+  //     width: 40,
+  //     align: 'center',
+  //     customCell: (_, index) => {
+
+  //       if (index % 3 == 0) {
+  //         return { rowSpan: 3 };
+  //       } else {
+  //         return { rowSpan: 0 };
+  //       }
+  //     },
+  //   };
+  //   const indexColumn = {
+  //     title: '序号',
+  //     dataIndex: 'key',
+  //     width: 80,
+  //     align: 'center',
+  //     customCell: (_, index) => {
+  //       if (index % 3 == 0) {
+  //         return { rowSpan: 3 };
+  //       } else {
+  //         return { rowSpan: 0 };
+  //       }
+  //     },
+  //     customRender: function ({ index }) {
+  //       return index / 3 + 1;
+  //     },
+  //   };
+  //   const runDevice = {
+  //     title: '风机',
+  //     dataIndex: 'runDevice',
+  //     width: 80,
+  //     align: 'center',
+  //   };
+
+  //   columns.value = getTableHeaderColumns(columnsType);
+  //   console.log('风机columns------------------>', columnsType);
+  //   if (columns.value && columns.value.length < 1) {
+  //     columns.value = getTableHeaderColumns(columnsType.split('_')[0] + '_monitor');
+  //   }
+
+  //   const strinstallpos = columns.value.find((item) => {
+  //     return item.dataIndex === 'strinstallpos' || item.dataIndex === 'strname';
+  //   });
+  //   if (strinstallpos) {
+  //     strinstallpos.customCell = (_, index) => {
+  //       if (index % 3 == 0) {
+  //         return { rowSpan: 3 };
+  //       } else {
+  //         return { rowSpan: 0 };
+  //       }
+  //     };
+  //   }
+  //   columns.value.forEach((item) => {
+  //     if (item.dataIndex === 'strinstallpos' || item.dataIndex === 'strname' || item.dataIndex.endsWith('_merge')) {
+  //       item.customCell = (_, index) => {
+  //         if (index % 3 == 0) {
+  //           return { rowSpan: 3 };
+  //         } else {
+  //           return { rowSpan: 0 };
+  //         }
+  //       };
+  //     }
+  //   });
+
+  //   columns.value.splice(1, 0, runDevice);
+  //   if (props.isShowSelect) {
+  //     columns.value = [isCheckColumn, indexColumn, ...columns.value];
+  //   } else {
+  //     columns.value = [indexColumn, ...columns.value];
+  //   }
+
+  //   if (props.isAction) {
+  //     columns.value = [
+  //       ...columns.value,
+  //       {
+  //         title: '操作',
+  //         dataIndex: 'operation',
+  //         width: 120,
+  //         align: 'center',
+  //         slots: { customRender: 'operation' },
+  //         customCell: (_, index) => {
+  //           if (index % 3 == 0) {
+  //             return { rowSpan: 3 };
+  //           } else {
+  //             return { rowSpan: 0 };
+  //           }
+  //         },
+  //       },
+  //     ];
+  //   }
+  //   // columns.value = [...columns.value, ...columns.value]
+  //   return columns;
+  // }
+
   function setColumns(columnsType) {
     const isCheckColumn = {
       title: '',
@@ -109,8 +207,9 @@
       width: 40,
       align: 'center',
       customCell: (_, index) => {
-        if (index % 3 == 0) {
-          return { rowSpan: 3 };
+        const columnNum = _.modalTyoe === 'lijing_3' ? 3 : 2;
+        if (_.rowIndex % columnNum == 0) {
+          return { rowSpan: columnNum };
         } else {
           return { rowSpan: 0 };
         }
@@ -122,14 +221,17 @@
       width: 80,
       align: 'center',
       customCell: (_, index) => {
-        if (index % 3 == 0) {
-          return { rowSpan: 3 };
+        debugger;
+        const columnNum = _.modalTyoe === 'lijing_3' ? 3 : 2;
+        if (_.rowIndex % columnNum == 0) {
+          return { rowSpan: columnNum };
         } else {
           return { rowSpan: 0 };
         }
       },
-      customRender: function ({ index }) {
-        return index / 3 + 1;
+      customRender: ({ text, record, index }) => {
+        const columnNum = record.modalTyoe === 'lijing_3' ? 3 : 2;
+        return record.rowIndex / columnNum + 1;
       },
     };
     const runDevice = {
@@ -150,8 +252,9 @@
     });
     if (strinstallpos) {
       strinstallpos.customCell = (_, index) => {
-        if (index % 3 == 0) {
-          return { rowSpan: 3 };
+        const columnNum = _.modalTyoe === 'lijing_3' ? 3 : 2;
+        if (_.rowIndex % columnNum == 0) {
+          return { rowSpan: columnNum };
         } else {
           return { rowSpan: 0 };
         }
@@ -160,8 +263,9 @@
     columns.value.forEach((item) => {
       if (item.dataIndex === 'strinstallpos' || item.dataIndex === 'strname' || item.dataIndex.endsWith('_merge')) {
         item.customCell = (_, index) => {
-          if (index % 3 == 0) {
-            return { rowSpan: 3 };
+          const columnNum = _.modalTyoe === 'lijing_3' ? 3 : 2;
+          if (_.rowIndex % columnNum == 0) {
+            return { rowSpan: columnNum };
           } else {
             return { rowSpan: 0 };
           }
@@ -186,8 +290,9 @@
           align: 'center',
           slots: { customRender: 'operation' },
           customCell: (_, index) => {
-            if (index % 3 == 0) {
-              return { rowSpan: 3 };
+            const columnNum = _.modalTyoe === 'lijing_3' ? 3 : 2;
+            if (_.rowIndex % columnNum == 0) {
+              return { rowSpan: columnNum };
             } else {
               return { rowSpan: 0 };
             }
@@ -290,6 +395,8 @@
         if (props.columnsType.startsWith('fanlocal') && sysOrgCode !== 'zmhjhzmy') {
           resultData1['runDevice'] = '主机';
           resultData2['runDevice'] = '备机';
+          resultData1['rowIndex'] = 0;
+          resultData2['rowIndex'] = 1;
         } else {
           resultData1['runDevice'] = '1#风机';
           resultData2['runDevice'] = '2#风机';
@@ -297,6 +404,10 @@
           resultData1['modalTyoe'] = modalTyoe;
           resultData2['modalTyoe'] = modalTyoe;
           resultData3['modalTyoe'] = modalTyoe;
+
+          resultData1['rowIndex'] = 0;
+          resultData2['rowIndex'] = 1;
+          resultData3['rowIndex'] = 2;
         }
         if (modalTyoe === 'lijing_3') {
           list.push(resultData1, resultData2, resultData3);