wang.sq@aliyun.com před 2 týdny
rodič
revize
4c2e9b8643

+ 1 - 0
imcs-ui/package.json

@@ -51,6 +51,7 @@
     "normalize.css": "7.0.0",
     "nprogress": "0.2.0",
     "path-to-regexp": "2.4.0",
+    "print-js": "^1.6.0",
     "screenfull": "4.2.0",
     "showdown": "^1.9.1",
     "sortablejs": "1.8.4",

+ 34 - 1
imcs-ui/src/views/zuihou/runManageCenter/orderMgr/components/runningOrder/components/checkCuttingTools/index.vue

@@ -45,7 +45,7 @@
         </el-table-column> -->
       </el-table>
       <el-button  v-if="cutterApplyData.length>0" class="el-button--primary generateTask" @click="applySave()">发送申请</el-button>
-      <el-button  v-if="cutterApplyData.length>0" class="el-button--primary generateTask" @click="window.print()">打印</el-button>
+      <el-button  v-if="cutterApplyData.length>0" type="info" @click="handlePrint">打印</el-button>
     </div>
     
     <div>
@@ -101,6 +101,7 @@
 </template>
 
 <script>
+  import printJS from 'print-js'
 	// 【订单计划】-API
 	import planMgrApi from "@/api/runManageCenter/planMgr"
   import checkDetailCuttingTools from "@/views/zuihou/runManageCenter/orderMgr/components/runningOrder/components/checkCuttingTools/checkDetailCuttingTools"
@@ -234,6 +235,38 @@
            }
 
         })
+      },
+      handlePrint() {
+          let data = []
+          // list为要打印的数据
+          for (let i=0; i < this.cutterApplyData.length; i++) {
+              data.push({
+                  field1: this.cutterApplyData[i].orderNo,
+                  field2: this.cutterApplyData[i].orderName,
+                  field3: this.cutterApplyData[i].name,
+                  field4: this.cutterApplyData[i].applyType==1?"量具<br>":"刀具"
+              })
+          }
+          printJS({
+              type: 'json',
+              header: '打印表格数据',
+              headerStyle: 'text-align: center',
+              // 打印的数据
+              printable: data,
+              // 表头名称(必传),要和json中的键值对的键保持一致
+              properties: [
+                  {field: 'field1', displayName: '订单编号', columnSize: 1},
+                  {field: 'field2', displayName: '订单名称', columnSize: 1},
+                  {field: 'field3', displayName: '零件名称', columnSize: 1},
+                  {field: 'field4', displayName: '类型', columnSize: 1, 
+                  properties: [{field: 'field1', displayName: '订单编号', columnSize: 1},
+                              {field: 'field2', displayName: '订单名称', columnSize: 1}]}
+              ],
+              // 表头的自定义样式设置
+              gridHeaderStyle: 'font-weight: 500; border: 1px solid lightgray; font-size: 18px; line-height: 32px;',
+              // 表格的自定义样式设置
+              gridStyle: 'text-align: center; border: 1px solid lightgray; font-size: 15px; line-height: 30px;',
+          })
       }
 
 	  }