瀏覽代碼

add pdf file

abiao 4 年之前
父節點
當前提交
fc3480e29a

+ 12 - 0
app/models/order_file.rb

@@ -35,6 +35,18 @@ class OrderFile < ActiveRecord::Base
       #field :depart
       field :depart_record
 
+      field :pdf_file do
+        read_only true
+        pretty_value do
+          v = bindings[:view]
+          url = value
+          # value will point to bindings[:object].name
+          if value.length>0
+            v.link_to("清单文件.pdf", url, target: '_blank', rel: 'noopener noreferrer')
+          end
+        end
+      end
+
       field :list_file do
         read_only true
         pretty_value do

+ 1 - 0
config/locales/models/order_file.yml

@@ -12,6 +12,7 @@ zh-CN:
         paied_time: 支付时间(时间戳)
         depart: 部门
         depart_record: 部门
+        pdf_file: 清单文件.pdf
         list_file: 清单文件
         line_file: 快递打印单
         status: 状态

+ 11 - 0
db/migrate/20210422032357_add_pdf_file_column_to_order_files.rb

@@ -0,0 +1,11 @@
+# This migration and CreateVersionAssociations provide the necessary
+# schema for tracking associations.
+class AddPdfFileColumnToOrderFiles < ActiveRecord::Migration
+  def self.up
+    add_column :list_files, :pdf_file, :string,:limit => 128,:null => false, :default => ""
+  end
+
+  def self.down
+    remove_column :list_files, :pdf_file
+  end
+end