see999 3 years ago
parent
commit
16ebfc8d37

+ 11 - 0
src/router/modules/workforce.js View File

@@ -93,5 +93,16 @@ export default {
93 93
         noCache: true
94 94
       }
95 95
     },
96
+    {
97
+      path: '/scheduleTablePrint',
98
+      component: () => import('@/xt_pages/workforce/scheduleTablePrint'),
99
+      name: 'scheduleTablePrint',
100
+      hidden: true,
101
+      is_menu: false,
102
+      meta: {
103
+        title: 'scheduleTablePrint',
104
+        noCache: true
105
+      }
106
+    },
96 107
   ]
97 108
 }

+ 1 - 7
src/xt_pages/workforce/appointment.vue View File

@@ -228,13 +228,7 @@
228 228
     },
229 229
     methods: {
230 230
       printTable(){
231
-        this.$nextTick(() => {
232
-          if(this.activeName == 'thisWeek'){
233
-            this.$refs.tableData.printHTML('#newTable')
234
-          }
235
-          
236
-        })
237
-        
231
+        this.$router.push({path: '/scheduleTablePrint'})
238 232
       },
239 233
       generateTxt: function(log) {
240 234
         var content = ''

+ 3 - 125
src/xt_pages/workforce/components/tableData.vue View File

@@ -129,7 +129,6 @@
129 129
       :height="tableContainHeight"
130 130
       ref="table"
131 131
       style="width: 100%;cursor: pointer;"
132
-      id="newTable"
133 132
     >
134 133
       <el-table-column
135 134
         prop="area"
@@ -921,6 +920,7 @@ export default {
921 920
         
922 921
         
923 922
           var that = this;
923
+          console.log('that.scheduleZonethat.scheduleZone',that.scheduleZone)
924 924
           this.scheduleZone.forEach(function(zone, index) {
925 925
            
926 926
             that.scheduleZone[index].Mon_M = {
@@ -1078,12 +1078,14 @@ export default {
1078 1078
                           : that.modeOptions[schedule.mode_id].name
1079 1079
                     };
1080 1080
                     that.scheduleZone[index].total += 1;
1081
+                    
1081 1082
                   }
1082 1083
                 }
1083 1084
               });
1084 1085
             }
1085 1086
 
1086 1087
           });
1088
+          
1087 1089
         } else {
1088 1090
           this.$message.error("网络错误");
1089 1091
           return false;
@@ -2014,130 +2016,6 @@ export default {
2014 2016
      this.schedule_type = val
2015 2017
      this.getSchedules()
2016 2018
     },
2017
-    printHTML(id) {
2018
-      // let printStr = "<html><head><meta http-equiv='Content-Type' content='text/html; charset=utf-8'></head>";
2019
-      //       // 定义element-ui table组件的样式
2020
-      //       const tabStyle = `<style>
2021
-      //           table{width:100%;display:table-cell!important;box-sizing:border-box;}
2022
-      //           .el-table__header,.el-table__body,.el-table__footer{width:100%!important;border-collapse: collapse;text-align:center;}
2023
-      //           table,table tr th, table tr td { border:1px solid #ddd;color:#606266;word-wrap:break-word}
2024
-      //           table tr th,table tr td{padding:4mm 0mm;word-wrap:break-word }
2025
-      //           .el-table__body, tr td .cell{width:100%!important}
2026
-      //           .el-table th.gutter{display: none;}
2027
-      //           .el-table colgroup.gutter{display: none;}
2028
-      //           </style><body>`;
2029
-      //       let content = "";
2030
-      //       // 获取名为传入id的 dom元素内的内容
2031
-      //       let str = document.getElementById(id).innerHTML;
2032
-      //       // 拼接空页面+style样式+dom内容
2033
-      //       content = content + str;
2034
-      //       printStr = printStr + tabStyle + content + "</body></html>";
2035
-      //       // 打开新页面
2036
-      //       let pwin = window.open("_blank");
2037
-      //       // 将内容赋值到新页面
2038
-      //       pwin.document.write(printStr);
2039
-      //       pwin.document.close();
2040
-      //       // 聚焦-不加focuse,在某些情况下,打印页面会有问题。
2041
-      //       pwin.focus();
2042
-      //       // 使用setTimeout,等页面dom元素渲染完成后再打印。
2043
-      //       setTimeout(() => {
2044
-      //           pwin.print(); // 打印功能。 例如 window.print() 直接打印当前整个页面。 
2045
-      //           pwin.close(); // 关闭 打印创建的当前页面
2046
-      //       }, 500);
2047
-    //   const html = document.querySelector(id).innerHTML
2048
-    // // 新建一个 DOM
2049
-    // const div = document.createElement('div')
2050
-    // const printDOMID = 'printDOMElement'
2051
-    // div.id = printDOMID
2052
-    // div.innerHTML = html
2053
-
2054
-    // // 提取第一个表格的内容 即表头
2055
-    // const ths = div.querySelectorAll('.el-table__header-wrapper th')
2056
-    // const ThsTextArry = []
2057
-    // for (let i = 0, len = ths.length; i < len; i++) {
2058
-    //     if (ths[i].innerText !== '') ThsTextArry.push(ths[i].innerText)
2059
-    // }
2060
-
2061
-    // // 删除多余的表头
2062
-    // div.querySelector('.hidden-columns').remove()
2063
-    // // 第一个表格的内容提取出来后已经没用了 删掉
2064
-    // div.querySelector('.el-table__header-wrapper').remove()
2065
-
2066
-    // // 将第一个表格的内容插入到第二个表格
2067
-    // let newHTML = '<tr>'
2068
-    // for (let i = 0, len = ThsTextArry.length; i < len; i++) {
2069
-    //     newHTML += '<td style="text-align: center; font-weight: bold">' + ThsTextArry[i] + '</td>'
2070
-    // }
2071
-
2072
-    // newHTML += '</tr>'
2073
-    // div.querySelector('.el-table__body-wrapper table').insertAdjacentHTML('afterbegin', newHTML)
2074
-    // // 将新的 DIV 添加到页面 打印后再删掉
2075
-    // document.querySelector('body').appendChild(div);
2076
-
2077
-
2078
-let printStr = "<html><head><meta http-equiv='Content-Type' content='text/html; charset=utf-8'></head>";
2079
-            // 定义element-ui table组件的样式
2080
-            const tabStyle = `<style>
2081
-                table{width:100%;display:table-cell!important;box-sizing:border-box;}
2082
-                .el-table__header,.el-table__body,.el-table__footer{width:100%!important;border-collapse: collapse;text-align:center;}
2083
-                table,table tr th, table tr td { border:1px solid #ddd;color:#606266;word-wrap:break-word}
2084
-                table tr th,table tr td{padding:4mm 0mm;word-wrap:break-word }
2085
-                .el-table__body, tr td .cell{width:100%!important}
2086
-                .el-table th.gutter{display: none;}
2087
-                .el-table colgroup.gutter{display: none;}
2088
-                </style><body>`;
2089
-    let content = "";
2090
-            // 获取名为传入id的 dom元素内的内容
2091
-            let newId = document.querySelector(id)
2092
-            // if(document.querySelector('.el-table__fixed') && document.querySelector('.el-table__fixed-right') && document.querySelector('.el-table__fixed-right-patch')){
2093
-            //   document.querySelector('.el-table__fixed').parentNode.removeChild(document.querySelector('.el-table__fixed'))
2094
-            //   document.querySelector('.el-table__fixed-right').parentNode.removeChild(document.querySelector('.el-table__fixed-right'))
2095
-            //   document.querySelector('.el-table__fixed-right-patch').parentNode.removeChild(document.querySelector('.el-table__fixed-right-patch'))
2096
-            // }
2097
-            
2098
-            let str = document.querySelector(id).innerHTML;
2099
-            // var reg = new RegExp(document.querySelector('.el-table__fixed').innerHTML,"g");
2100
-            var a = str.replace(document.querySelector('.el-table__fixed').innerHTML,"")
2101
-            // var reg1 = new RegExp(document.querySelector('.el-table__fixed-right').innerHTML,"g");
2102
-            var b = a.replace(document.querySelector('.el-table__fixed-right').innerHTML,"")
2103
-            // var reg2 = new RegExp(document.querySelector('.el-table__fixed-right-patch').innerHTML,"g");
2104
-            var c = b.replace(document.querySelector('.el-table__fixed-right-patch').innerHTML,"")
2105
-            // 拼接空页面+style样式+dom内容
2106
-            content = content + c;
2107
-            printStr = printStr  + content + "</body></html>";
2108
-            console.log('printStr',document.querySelector(id))
2109
-            
2110
-            // document.querySelector('.el-table__fixed').remove()
2111
-            // document.querySelector('.el-table__fixed-right').remove()
2112
-            // document.querySelector('.el-table__fixed-right-patch').remove()
2113
-            // 打开新页面
2114
-            let pwin = window.open("_blank");
2115
-            // 将内容赋值到新页面
2116
-            pwin.document.write(printStr);
2117
-            pwin.document.close();
2118
-            // 聚焦-不加focuse,在某些情况下,打印页面会有问题。
2119
-            pwin.focus();
2120
-
2121
-            
2122
-            // 使用setTimeout,等页面dom元素渲染完成后再打印。
2123
-            // setTimeout(() => {
2124
-              this.$nextTick(() => {
2125
-                pwin.print(); // 打印功能。 例如 window.print() 直接打印当前整个页面。 
2126
-                // pwin.close(); // 关闭 打印创建的当前页面
2127
-              })
2128
-                
2129
-            // }, 500);
2130
-    // console.log('document.querySelector',document.querySelector('#printDOMElement'))
2131
-    //   printJS({
2132
-    //   printable: printDOMID,
2133
-    //   type: 'html',
2134
-    //   scanStyles: false,
2135
-    //   style: 'table { border-collapse: collapse }' // 表格样式
2136
-    // })
2137
-
2138
-    // div.remove()
2139
- 
2140
-    }
2141 2019
   },
2142 2020
   components: {
2143 2021
     ScheduleItem