Browse Source

提交导出页面代码

zcb 4 năm trước cách đây
mục cha
commit
14de375532

+ 2 - 1
kmall-admin/src/main/java/com/kmall/admin/controller/exportPDF/ExportPDFController.java

@@ -33,7 +33,7 @@ public class ExportPDFController {
 
     //打印pdf
     @RequestMapping("/printPdf")
-    public ModelAndView printPdf(String head ,String type,String sku,String storeId) throws Exception {
+    public ModelAndView printPdf(String head ,String type,String sku,String storeId,String headUrl) throws Exception {
 
         PDFGoodsDto pdfGoodsDto = goodsService.queryForPDFData(sku,storeId);
 
@@ -43,6 +43,7 @@ public class ExportPDFController {
             model.put("type",type);
             model.put("fontUrl",fontUrl);
             model.put("uploadDir",uploadDir);
+            model.put("headUrl",headUrl);
             return new ModelAndView(new ViewPDF(), model);
         }else if ("0".equals(head)){
             Map<String, Object> model = new HashMap<>();

+ 7 - 7
kmall-admin/src/main/java/com/kmall/admin/utils/pdf/PdfUtil.java

@@ -11,32 +11,32 @@ import java.io.IOException;
 public class PdfUtil {
 
   public void createPDF(Document document, PdfWriter writer, PDFGoodsDto pdfGoodsDto,
-                        String type, String fontUrl, String uploadDir) throws IOException, com.lowagie.text.DocumentException {
+                        String type, String fontUrl, String uploadDir, String headUrl) throws IOException, com.lowagie.text.DocumentException {
 
       switch (type){
           case "1":
               PDFWrite pdfWrite = new PDFWrite();
-              pdfWrite.write(document,writer,pdfGoodsDto,fontUrl,uploadDir);
+              pdfWrite.write(document,writer,pdfGoodsDto,fontUrl,uploadDir,headUrl);
               break;
           case "2":
               PDFWrite_2 pdfWrite2 = new PDFWrite_2();
-              pdfWrite2.write(document,writer,pdfGoodsDto,fontUrl,uploadDir);
+              pdfWrite2.write(document,writer,pdfGoodsDto,fontUrl,uploadDir,headUrl);
               break;
           case "4":
               PDFWrite_4 pdfWrite4 = new PDFWrite_4();
-              pdfWrite4.write(document,writer,pdfGoodsDto,fontUrl,uploadDir);
+              pdfWrite4.write(document,writer,pdfGoodsDto,fontUrl,uploadDir,headUrl);;
               break;
           case "9":
               PDFWrite_9 pdfWrite9 = new PDFWrite_9();
-              pdfWrite9.write(document,writer,pdfGoodsDto,fontUrl,uploadDir);
+              pdfWrite9.write(document,writer,pdfGoodsDto,fontUrl,uploadDir,headUrl);
               break;
           case "12":
               PDFWrite_12 pdfWrite12 = new PDFWrite_12();
-              pdfWrite12.write(document,writer,pdfGoodsDto,fontUrl,uploadDir);
+              pdfWrite12.write(document,writer,pdfGoodsDto,fontUrl,uploadDir,headUrl);
               break;
           case "36":
               PDFWrite_36 pdfWrite36 = new PDFWrite_36();
-              pdfWrite36.write(document,writer,pdfGoodsDto,fontUrl,uploadDir);
+              pdfWrite36.write(document,writer,pdfGoodsDto,fontUrl,uploadDir,headUrl);
               break;
           default:
               break;

+ 4 - 1
kmall-admin/src/main/java/com/kmall/admin/utils/pdf/ViewPDF.java

@@ -20,11 +20,14 @@ public class ViewPDF extends AbstractPdfView {
       response.setCharacterEncoding("UTF-8");
       response.setContentType("application/pdf");
       response.setHeader("Content-Disposition","filename=" + new String(fileName.getBytes(), "iso8859-1"));
+
+
       PdfUtil pdfUtil = new PdfUtil();
       String type = (String) model.get("type");
       PDFGoodsDto pdfGoodsDto = (PDFGoodsDto) model.get("dto");
       String fontUrl = (String) model.get("fontUrl");
       String uploadDir = (String) model.get("uploadDir");
-      pdfUtil.createPDF(document,writer,pdfGoodsDto,type,fontUrl,uploadDir);
+      String headUrl = (String) model.get("headUrl");
+      pdfUtil.createPDF(document,writer,pdfGoodsDto,type,fontUrl,uploadDir,headUrl);
   }
 }

+ 2 - 2
kmall-admin/src/main/java/com/kmall/admin/utils/pdf/type/PDFWrite.java

@@ -18,7 +18,7 @@ public class PDFWrite {
 
 
     public void write(Document doc, PdfWriter writer, PDFGoodsDto pdfGoodsDto
-            , String fontUrl, String uploadDir) throws IOException, DocumentException {
+            , String fontUrl, String uploadDir, String headUrl) throws IOException, DocumentException {
         // 设置字体
         BaseFont bfHei = BaseFont.createFont(fontUrl,BaseFont.IDENTITY_H,BaseFont.NOT_EMBEDDED);
         Font FontChinese11 = new Font(bfHei, 11);
@@ -33,7 +33,7 @@ public class PDFWrite {
         // -----------------------标签头----------------------
         PdfPTable table1 = new PdfPTable(1);
 
-        Image img = Image.getInstance("H:\\Demo\\cheaper.jpg");
+        Image img = Image.getInstance(headUrl);
         img.setAlignment(Image.MIDDLE);  //设置图片居中
         img.setBorder(Image.BOX);
         img.setBorderWidth(10);

+ 7 - 7
kmall-admin/src/main/java/com/kmall/admin/utils/pdf/type/PDFWrite_12.java

@@ -15,7 +15,7 @@ public class PDFWrite_12 {
 
 
     public void write(Document doc, PdfWriter writer, PDFGoodsDto pdfGoodsDto
-            , String fontUrl, String uploadDir) throws IOException, DocumentException {
+            , String fontUrl, String uploadDir, String headUrl) throws IOException, DocumentException {
 
         // 设置字体
         BaseFont bfHei = BaseFont.createFont(fontUrl,BaseFont.IDENTITY_H,BaseFont.NOT_EMBEDDED);
@@ -31,22 +31,22 @@ public class PDFWrite_12 {
 
         // -----------------------标签头----------------------
 //        PdfPTable table = getPdfPTable(FontChinese11, bfHei, doc);
-        getPdfPTable(FontChinese11, bfHei, doc,pdfGoodsDto);
-        getPdfPTable(FontChinese11, bfHei, doc,pdfGoodsDto);
-        getPdfPTable(FontChinese11, bfHei, doc,pdfGoodsDto);
-        getPdfPTable(FontChinese11, bfHei, doc,pdfGoodsDto);
+        getPdfPTable(FontChinese11, bfHei, doc,pdfGoodsDto,headUrl);
+        getPdfPTable(FontChinese11, bfHei, doc,pdfGoodsDto,headUrl);
+        getPdfPTable(FontChinese11, bfHei, doc,pdfGoodsDto,headUrl);
+        getPdfPTable(FontChinese11, bfHei, doc,pdfGoodsDto,headUrl);
 
 
         doc.close();  //记得关闭document
 
     }
 
-    private static void getPdfPTable(Font fontChinese11, BaseFont bfHei, Document doc, PDFGoodsDto pdfGoodsDto) throws IOException, DocumentException {
+    private static void getPdfPTable(Font fontChinese11, BaseFont bfHei, Document doc, PDFGoodsDto pdfGoodsDto,String headUrl) throws IOException, DocumentException {
         PdfPTable table = new PdfPTable(3);
         table = new PdfPTable(3);
 
         for (int i = 0; i < 3; i++) {
-            Image img = Image.getInstance("H:\\Demo\\cheaper.jpg");
+            Image img = Image.getInstance(headUrl);
             img.setAlignment(Image.ALIGN_CENTER);  //设置图片居中
 
             PdfPCell p = new PdfPCell(img,true);

+ 4 - 4
kmall-admin/src/main/java/com/kmall/admin/utils/pdf/type/PDFWrite_2.java

@@ -15,7 +15,7 @@ public class PDFWrite_2 {
 
 
     public void write(Document doc, PdfWriter writer, PDFGoodsDto pdfGoodsDto
-            , String fontUrl, String uploadDir) throws IOException, DocumentException {
+            , String fontUrl, String uploadDir, String headUrl) throws IOException, DocumentException {
         // 设置字体
         BaseFont bfHei = BaseFont.createFont(fontUrl,BaseFont.IDENTITY_H,BaseFont.NOT_EMBEDDED);
         Font FontChinese11 = new Font(bfHei, 11);
@@ -28,17 +28,17 @@ public class PDFWrite_2 {
         writer.setPdfVersion(PdfWriter.PDF_VERSION_1_2);//版本(默认1.4)
         doc.open();// 打开文档
         // -----------------------标签头----------------------
-        getPdfPTable(FontChinese11, bfHei, doc,pdfGoodsDto);
+        getPdfPTable(FontChinese11, bfHei, doc,pdfGoodsDto,headUrl);
 
         doc.close();  //记得关闭document
 
     }
 
-    private static void getPdfPTable(Font fontChinese11, BaseFont bfHei, Document doc, PDFGoodsDto pdfGoodsDto) throws IOException, DocumentException {
+    private static void getPdfPTable(Font fontChinese11, BaseFont bfHei, Document doc, PDFGoodsDto pdfGoodsDto,String headUrl) throws IOException, DocumentException {
         PdfPTable table = new PdfPTable(2);
 
         for (int i = 0; i < 2; i++) {
-            Image img = Image.getInstance("H:\\Demo\\cheaper.jpg");
+            Image img = Image.getInstance(headUrl);
             img.setAlignment(Image.ALIGN_CENTER);  //设置图片居中
 
             PdfPCell p = new PdfPCell(img,true);

+ 9 - 9
kmall-admin/src/main/java/com/kmall/admin/utils/pdf/type/PDFWrite_36.java

@@ -16,7 +16,7 @@ public class PDFWrite_36 {
 
 
     public void write(Document doc, PdfWriter writer, PDFGoodsDto pdfGoodsDto
-            , String fontUrl, String uploadDir) throws IOException, DocumentException {
+            , String fontUrl, String uploadDir, String headUrl) throws IOException, DocumentException {
 
         // 设置字体
         BaseFont bfHei = BaseFont.createFont(fontUrl,BaseFont.IDENTITY_H,BaseFont.NOT_EMBEDDED);
@@ -31,24 +31,24 @@ public class PDFWrite_36 {
         doc.open();// 打开文档
 
         // -----------------------标签头----------------------
-        getPdfPTable(FontChinese11, bfHei, doc,pdfGoodsDto);
-        getPdfPTable(FontChinese11, bfHei, doc,pdfGoodsDto);
-        getPdfPTable(FontChinese11, bfHei, doc,pdfGoodsDto);
-        getPdfPTable(FontChinese11, bfHei, doc,pdfGoodsDto);
-        getPdfPTable(FontChinese11, bfHei, doc,pdfGoodsDto);
-        getPdfPTable(FontChinese11, bfHei, doc,pdfGoodsDto);
+        getPdfPTable(FontChinese11, bfHei, doc,pdfGoodsDto,headUrl);
+        getPdfPTable(FontChinese11, bfHei, doc,pdfGoodsDto,headUrl);
+        getPdfPTable(FontChinese11, bfHei, doc,pdfGoodsDto,headUrl);
+        getPdfPTable(FontChinese11, bfHei, doc,pdfGoodsDto,headUrl);
+        getPdfPTable(FontChinese11, bfHei, doc,pdfGoodsDto,headUrl);
+        getPdfPTable(FontChinese11, bfHei, doc,pdfGoodsDto,headUrl);
 
 
         doc.close();  //记得关闭document
 
     }
 
-    private static void getPdfPTable(Font fontChinese11, BaseFont bfHei, Document doc, PDFGoodsDto pdfGoodsDto) throws IOException, DocumentException {
+    private static void getPdfPTable(Font fontChinese11, BaseFont bfHei, Document doc, PDFGoodsDto pdfGoodsDto,String headUrl) throws IOException, DocumentException {
         PdfPTable table = new PdfPTable(3);
         table = new PdfPTable(6);
 
         for (int i = 0; i < 6; i++) {
-            Image img = Image.getInstance("H:\\Demo\\cheaper.jpg");
+            Image img = Image.getInstance(headUrl);
             img.setAlignment(Image.ALIGN_CENTER);  //设置图片居中
 
             PdfPCell p = new PdfPCell(img,true);

+ 5 - 5
kmall-admin/src/main/java/com/kmall/admin/utils/pdf/type/PDFWrite_4.java

@@ -15,7 +15,7 @@ public class PDFWrite_4 {
 
 
     public void write(Document doc, PdfWriter writer, PDFGoodsDto pdfGoodsDto
-            , String fontUrl, String uploadDir) throws IOException, DocumentException {
+            , String fontUrl, String uploadDir, String headUrl) throws IOException, DocumentException {
         // 设置字体
         BaseFont bfHei = BaseFont.createFont(fontUrl,BaseFont.IDENTITY_H,BaseFont.NOT_EMBEDDED);
         Font FontChinese11 = new Font(bfHei, 11);
@@ -29,18 +29,18 @@ public class PDFWrite_4 {
         doc.open();// 打开文档
         // -----------------------标签头----------------------
 //        PdfPTable table = getPdfPTable(FontChinese11, bfHei, doc);
-        getPdfPTable(FontChinese11, bfHei, doc,pdfGoodsDto);
-        getPdfPTable(FontChinese11, bfHei, doc,pdfGoodsDto);
+        getPdfPTable(FontChinese11, bfHei, doc,pdfGoodsDto,headUrl);
+        getPdfPTable(FontChinese11, bfHei, doc,pdfGoodsDto,headUrl);
 
         doc.close();  //记得关闭document
 
     }
 
-    private static void getPdfPTable(Font fontChinese11, BaseFont bfHei, Document doc, PDFGoodsDto pdfGoodsDto) throws IOException, DocumentException {
+    private static void getPdfPTable(Font fontChinese11, BaseFont bfHei, Document doc, PDFGoodsDto pdfGoodsDto,String headUrl) throws IOException, DocumentException {
         PdfPTable table = new PdfPTable(2);
 
         for (int i = 0; i < 2; i++) {
-            Image img = Image.getInstance("H:\\Demo\\cheaper.jpg");
+            Image img = Image.getInstance(headUrl);
             img.setAlignment(Image.ALIGN_CENTER);  //设置图片居中
 
             PdfPCell p = new PdfPCell(img,true);

+ 6 - 6
kmall-admin/src/main/java/com/kmall/admin/utils/pdf/type/PDFWrite_9.java

@@ -16,7 +16,7 @@ public class PDFWrite_9 {
 
 
     public void write(Document doc, PdfWriter writer, PDFGoodsDto pdfGoodsDto
-            , String fontUrl, String uploadDir) throws IOException, DocumentException {
+            , String fontUrl, String uploadDir, String headUrl) throws IOException, DocumentException {
         // 设置字体
         BaseFont bfHei = BaseFont.createFont(fontUrl,BaseFont.IDENTITY_H,BaseFont.NOT_EMBEDDED);
         Font FontChinese11 = new Font(bfHei, 11);
@@ -30,21 +30,21 @@ public class PDFWrite_9 {
         doc.open();// 打开文档
         // -----------------------标签头----------------------
 //        PdfPTable table = getPdfPTable(FontChinese11, bfHei, doc);
-        getPdfPTable(FontChinese11, bfHei, doc,pdfGoodsDto);
-        getPdfPTable(FontChinese11, bfHei, doc,pdfGoodsDto);
-        getPdfPTable(FontChinese11, bfHei, doc,pdfGoodsDto);
+        getPdfPTable(FontChinese11, bfHei, doc,pdfGoodsDto,headUrl);
+        getPdfPTable(FontChinese11, bfHei, doc,pdfGoodsDto,headUrl);
+        getPdfPTable(FontChinese11, bfHei, doc,pdfGoodsDto,headUrl);
 
 
         doc.close();  //记得关闭document
 
     }
 
-    private static void getPdfPTable(Font fontChinese11, BaseFont bfHei, Document doc, PDFGoodsDto pdfGoodsDto) throws IOException, DocumentException {
+    private static void getPdfPTable(Font fontChinese11, BaseFont bfHei, Document doc, PDFGoodsDto pdfGoodsDto,String headUrl) throws IOException, DocumentException {
         PdfPTable table = new PdfPTable(3);
         table = new PdfPTable(3);
 
         for (int i = 0; i < 3; i++) {
-            Image img = Image.getInstance("H:\\Demo\\cheaper.jpg");
+            Image img = Image.getInstance(headUrl);
             img.setAlignment(Image.ALIGN_CENTER);  //设置图片居中
 
             PdfPCell p = new PdfPCell(img,true);

+ 8 - 1
kmall-admin/src/main/webapp/WEB-INF/page/shop/goodsexportpdf.html

@@ -38,7 +38,7 @@
     <div class="container-fluid  coldiv">
         <Row :gutter="16">
         <div class="row" style="border:0;margin-bottom:10px">
-            <i-button  v-bind:disabled="selectButtonDisabled"  @click="selectLabelHead" >选择标签头</i-button>
+<!--            <i-button  v-bind:disabled="selectButtonDisabled"  @click="selectLabelHead" >选择标签头</i-button>-->
             <i-button type="primary" @click="exportPdf"><i class="fa fa-cloud-download"></i>&nbsp;导出pdf</i-button>
             <i-col span="3">
                 <i-select v-model="q.storeId" placeholder="门店" filterable label-in-value>
@@ -71,6 +71,13 @@
                     </i-option>
                 </i-select>
             </i-col>
+            <i-col span="3">
+                <i-select v-bind:disabled="selectButtonDisabled" v-model="q.headUrl" placeholder="选择标签头" filterable label-in-value>
+                    <i-option v-for="label in labels" :value="label.labelHeadUrl"
+                              :key="label.labelHeadUrl">{{label.labelHeadName}}
+                    </i-option>
+                </i-select>
+            </i-col>
             <i-input v-model="q.headUrl" type="hidden"/>
 
         </div>

+ 29 - 1
kmall-admin/src/main/webapp/js/shop/goodsexportpdf.js

@@ -15,6 +15,7 @@ let vm = new Vue({
             headUrl: ''
         },
         stores: [],
+        labels:[],
         isHeads: [{
             id: '0',
             name: '无标签头'
@@ -66,18 +67,45 @@ let vm = new Vue({
 
         },
 		selectLabelHead: function () {
+
+
+
+
 			alert("selectLabelHead")
 		},
 
 		exportPdf: function () {
+
+            window.open("../pdf/printPdf?type="+vm.q.pdfType+"&sku="+vm.q.sku+"&barCode="+vm.q.barCode+"&head="+vm.q.isHead+"&headUrl="+vm.q.headUrl+"&storeId="+vm.q.storeId);
+
+            $.get("../pdf/printPdf?type="+vm.q.pdfType+"&sku="+vm.q.sku+"&barCode="+vm.q.barCode+"&head="+vm.q.isHead+"&headUrl="+vm.q.headUrl+"&storeId="+vm.q.storeId, function (r) {
+                vm.mall2OrderingEarlyWarningReminds = r.mall2OrderingEarlyWarningReminds;
+            });
 			alert("exportPdf")
 		}
 
 	},
     mounted() {
+
         $.get("../store/queryAll", function (r) {
             vm.stores = r.list;
         });
+
+        $.ajax({
+            type: "POST",
+            url: "../goodslabelhead/list",
+            contentType: "application/json",
+            success: function (r) {
+                if (r.code === 0) {
+                    console.log(r);
+                    vm.labels = r.page.list
+                } else {
+                    alert(r.msg);
+                }
+            }
+        });
+
+
     }
 
-});
+});

+ 7 - 6
kmall-manager/src/main/resources/spring/spring-manager-context.xml

@@ -5,13 +5,13 @@
        xmlns:aop="http://www.springframework.org/schema/aop"
        xmlns:mvc="http://www.springframework.org/schema/mvc"
        xsi:schemaLocation="
-        http://www.springframework.org/schema/beans 
-        http://www.springframework.org/schema/beans/spring-beans-4.2.xsd        
-        http://www.springframework.org/schema/context 
+        http://www.springframework.org/schema/beans
+        http://www.springframework.org/schema/beans/spring-beans-4.2.xsd
+        http://www.springframework.org/schema/context
         http://www.springframework.org/schema/context/spring-context-4.2.xsd
-     	http://www.springframework.org/schema/aop 
+     	http://www.springframework.org/schema/aop
      	http://www.springframework.org/schema/aop/spring-aop-4.2.xsd
-		http://www.springframework.org/schema/mvc 
+		http://www.springframework.org/schema/mvc
      	http://www.springframework.org/schema/mvc/spring-mvc-4.2.xsd">
 
 
@@ -34,10 +34,11 @@
                 <value>classpath:conf/common.properties</value>
                 <value>classpath:conf/express-sf.properties</value>
                 <value>classpath:conf/alipay.properties</value>
+                <value>classpath:conf/print.properties</value>
             </list>
         </property>
         <property name="fileEncoding" value="UTF-8"/>
     </bean>
 
 
-</beans>
+</beans>