<!DOCTYPE html> 
 <html> 
  <head> 
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 
    <meta content="telephone=no" name="format-detection"> 
    <meta name="apple-mobile-web-app-capable" content="yes"> 
    <meta name="apple-mobile-web-app-status-bar-style" content="black"> 
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0"> 
    <style type="text/css"> 
      td { padding: 3px; } 
    </style> 
  </head> 
   <body style="padding: 10px 10px 0px 10px;font-size:24px;font-family:Microsoft YaHei;"> 
    <div style="position: absolute;right:0;top:0;font-size:14px">打印时间: {{ .print_time }}</div>
     <table width="100%" class="plaintable"> 
      {{ if .__title }}
      <tr> 
        <td align="center" style="font-size:48px;">{{.__title|trim}}</td> 
      </tr> 
      <tr> 
        <td align="center">订货单{{ if .state_text }}<div style="position: absolute;right:0;bottom:10px;font-size:14px;padding:0 10px;border:1px solid black">{{ .state_text }}</div>{{end}}</td> 
      </tr> 
      {{else}}
      <tr> 
        <td align="center" style="font-size:48px;position: relative;">订货单{{ if .state_text }}<div style="position: absolute;right:0;bottom:10px;font-size:14px;padding:0 10px;border:1px solid black">{{ .state_text }}</div>{{end}}</td> 
       
      </tr> 
      {{end}}
     </table> 
     <hr/>
     <div style="width:100%;float:left;"> 
       <table width="100%" class="plaintable" style="float:left;"> 
        <tr> 
          <td align="left">单据编号:</td> 
          <td align="left">{{ .code }}</td> 
          <td align="left">单据日期:</td> 
          <td align="left">{{ .bill_date }}</td> 
          <td align="left">手工单号:</td> 
          <td align="left">{{ .manual_code | empty }}</td> 
        </tr> 
         <tr> 
          <td align="left" width="10%" nowrap>客户名称:</td> 
          <td align="left" width="40%" nowrap>{{ .customer_name | empty }}</td> 
           <td align="left" width="10%" nowrap>客户编号:</td> 
           <td align="left" width="40%" nowrap>{{ .customer_code | empty }}</td> 
           <td align="left" width="10%" nowrap>订货类型:</td> 
           <td align="left" width="40%" nowrap>{{ .order_type | empty }}</td> 
         </tr> 
         <tr> 
          <td align="left" width="10%" nowrap>电话:</td> 
          <td align="left" width="40%" nowrap>{{ .customer_mobile | empty }}</td> 
           <td align="left" width="10%" nowrap></td> 
           <td align="left" width="40%" nowrap></td> 
           <td align="left" width="10%" nowrap>订货方式:</td> 
           <td align="left" width="40%" nowrap>{{ .order_mode | empty }}</td> 
         </tr> 
         <tr> 
          <td align="left">地址:</td> 
          <td align="left" colspan="5">{{ .customer_province | empty }}{{ .customer_city | empty }}{{ .customer_district | empty }}{{ .customer_address | empty }}</td> 
        </tr> 
        <tr> 
          <td align="left">备注:</td> 
          <td align="left" colspan="5">{{ .remark | empty }}</td> 
        </tr> 
       </table> 
     </div> 
     <p> 
     <table id="datatable" width="100%" class="plaintable" border="1" cellpadding="0" cellspacing="0"> 
        <colgroup>
          <col width="auto"/>
          <col width="100"/>
          {{range $si,$sv := (index $.sizes 0)}}
          <col width="70"/>
          {{end}}
          <col width="100"/>
          <col width="100"/>
          <col width="100"/>
        </colgroup>

      {{range $i,$v := .sizes}}
        {{ $title_goods := ``}}
        {{ $title_color := ``}}
        {{ $title_price := ``}}
        {{ $title_quantity := ``}}
        {{ $title_amount := ``}}

        {{if eq $i $.sizes_last_index}}
          {{ $title_goods = `货号`}}
          {{ $title_color = `颜色`}}

          {{ $title_price = `单价`}}
          {{ $title_quantity = `数量`}}
          {{ $title_amount = `金额`}}
        {{end}}

        <tr> 
          <td align="center" nowrap>{{ $title_goods }}</td> 
          <td align="center" nowrap>{{ $title_color }}</td> 

          {{range $si,$sv := $v}}
          <td align="center" nowrap>{{ $sv }}</td> 
          {{end}}

        {{if eq $i $.sizes_last_index}}
        <td align="center" nowrap>{{ $title_price }}</td> 
          <td align="center" nowrap>{{ $title_quantity }}</td> 
          <td align="center" nowrap>{{ $title_amount }}</td> 
        {{end}}
        </tr> 
      {{end}}
      
      {{range $d := .detail}}
      <tr> 
      <td align="center" >{{ $d.code }}</td> 
      <td align="center" >{{ $d.color_name }}</td> 
      {{range $si,$sv := (index $.sizes 0)}}
        <td align="center" >{{ (mapValStr $d (printf `s%d` (addInt $si 1) )) | emptyZero }}</td> 
      {{end}}
      <td align="center">{{ $d.price }}</td> 
      <td align="center">{{ $d.quantity }}</td> 
      <td align="center">{{ $d.amount }}</td> 
      </tr>
      {{end}}

       <tr> 
          <td>合计</td> 
          <td></td> 
          {{range $si,$sv := (index $.sizes 0)}}
            <td align="center"></td> 
          {{end}}
          <td></td> 
          <td align="center" >{{ .bill_quantity }}</td> 
          <td align="center" >{{ .bill_amount }}</td> 
       </tr> 
     </table> 
     </p> 
     <div class="plaintable"> 
       {{range $i,$v := .__tails}}
         <div>{{ $v }}</div>
       {{end}}
     </div> 
     <div style="display:flex;justify-content:space-between">
      <div>制单:</div>
      <div>出纳:</div>
      <div>理单:</div>
      <div>仓库:</div>
      <div>审核:</div>
      </div>
   </body> 
 </html>