浏览代码

labels format fix 2

chemi ledon 7 年之前
父节点
当前提交
d9dc310822
共有 3 个文件被更改,包括 31 次插入9 次删除
  1. 10 0
      app/models/product.rb
  2. 1 1
      app/views/layouts/labels.html.erb
  3. 20 8
      app/views/products/print_labels.pdf.erb

+ 10 - 0
app/models/product.rb

@@ -388,6 +388,16 @@ class Product < ActiveRecord::Base
     attributes
   end
 
+  def attrs_array
+    attributes = []
+    unless attributes_json.nil?
+      attributes_to_hash.each do |attr_, value|
+        attributes << I18n.t("dictionary." + attr_) + ": #{value.capitalize}"
+      end
+    end
+    attributes
+  end
+
   def display_attributes_receipt
     attributes = ""
     unless attributes_json.nil?

+ 1 - 1
app/views/layouts/labels.html.erb

@@ -13,7 +13,7 @@
         width: 60mm;
         height: auto;
         font-family: 'OpenSansRegular';
-        font-size: 12px;
+        font-size: 14px;
       }
       .text-center {
         text-align: center;

+ 20 - 8
app/views/products/print_labels.pdf.erb

@@ -4,25 +4,37 @@
     }
 
     .left {
-        width: 70%;
-        font-size: 10px;
+        width: 60%;
+        font-size: 12px;
         min-height:5px;
     }
 
     .right {
-        width: 30%;
-        font-size: 12px;
+        width: 40%;
+        font-size: 14px;
         font-weight: bold;
     }
 </style>
 <div class='pdf-body'>
     <% @products.each do |obj| %>
         <% (1..obj['print']).each do |i| %>
-            <div class="text-center"><%= wicked_pdf_barcode_image("#{obj['product'].barcode}.png", options = { width: 150, height: 50 }) %></div>
-            <p style="margin:0px"><%= obj['product'].name %></p>
+            <div class="text-center" style="padding-top:5px;margin-bottom:5px">
+                <%= wicked_pdf_barcode_image("#{obj['product'].barcode}.png", options = { width: 150, height: 50 }) %>
+            </div>
+
+            <p style="margin-left:0px;margin-right:0px;margin-top:0px;margin-bottom:10px"><%= obj['product'].name %></p>
+
             <div class="row">
-                <div class="column left"><%= obj['product'].display_attributes %></div>
-                <div class="column right"><%= number_to_currency(obj['price'], precision: 2) %></div>
+                <div class="column left">
+                    <ul style="list-style: none; margin:0px; padding:0px">
+                        <% obj['product'].attrs_array.each do |attribute| %>
+                            <li><%= attribute %></li>
+                        <% end %>
+                    </ul>
+                </div>
+                <div class="column right">
+                    <span style="margin:auto"><%= number_to_currency(obj['price'], precision: 2) %></span>
+                </div>
             </div>
             <br>
             <br>