廖井涛
2025-08-21 bf90cf8568301edb38920e8b0a0ce7e137a668ef
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
<script setup>
import request from "@/utils/request"
import {ElDatePicker, ElMessage} from "element-plus"
import {nextTick, onMounted, onUnmounted, onUpdated, reactive, ref, watch} from "vue"
import {Search} from "@element-plus/icons-vue"
import {useRouter} from 'vue-router'
import {changeFilterEvent, filterChanged} from "@/hook"
import {useI18n} from 'vue-i18n'
import deepClone from "@/utils/deepClone";
import QRCode from "qrcode";
import companyInfo from "@/stores/sd/companyInfo";
import userInfo from "@/stores/userInfo"
import {add,addAuto} from '@/utils/decimal';
//语言获取
const company = companyInfo()
const {t} = useI18n()
let router = useRouter()
let produceList = ref([])
let count = ref([{id:1},{id:2}])
let list = ref()
const details = ref([])
const user=userInfo()
const name1=ref("admin")
const name2=ref("admin")
 
const printStyle = ref(null);
 
 
 
const data = ref({
  printList: []
})
 
let props = defineProps({
  printList: null,
  companyVal: null
})
 
const {currentRoute} = useRouter()
const route = currentRoute.value
 
 
data.value.printList = JSON.parse(props.printList)
 
onMounted(() => {
  clearPrintStyles()
  addPrintStyles()
  selectPrint()
})
onUnmounted(() => {
  clearPrintStyles()
})
 
const clearPrintStyles = () => {
  // 2. 清除所有样式表中包含@media print的规则(适用于全局样式)
  Array.from(document.styleSheets).forEach(styleSheet => {
    try {
      // 遍历样式规则
      const rules = styleSheet.cssRules || styleSheet.rules;
      if (!rules) return;
 
      // 从后往前删除,避免索引错乱
      for (let i = rules.length - 1; i >= 0; i--) {
        const rule = rules[i];
        // 检查是否为打印媒体查询规则
        if (rule.media && rule.media.mediaText.includes('print')) {
          styleSheet.deleteRule(i);
        }
      }
    } catch (e) {
      // 跨域样式表可能无法访问,忽略错误
      console.log('无法清理跨域样式表:', e);
    }
  });
 
 
};
 
 
const addPrintStyles = () => {
  printStyle.value = document.createElement('style');
  printStyle.value.id = 'dynamic-print-style';
  printStyle.value.textContent = `
    @media print {
  @page {
    margin: 7.5mm 8mm 3.5mm 8mm ;
 
  }
 
  .pages{
    height: 94vh;
  }
  #footsum{
    position: absolute;
    bottom: 0cm;
    width: 100%; /* 或者设置成具体的宽度 */
  }
  #sticky-footer {
    position: fixed;
    bottom: 0.5cm;
    width: 100%; /* 或者设置成具体的宽度 */
  }
 
}
  `;
  document.head.appendChild(printStyle.value);
 
};
 
 
const companyList = ref([{
  company:'洛阳北方玻璃技术股份有限公司',
  companyInfo:"LUOYANG NORTH GLASS TECHNOLOGY CO.,LTD.",
  address:'洛阳国家高新技术开发区张庄',
  phone:'0379-64312861.64331830',
  url:'http://www.northglass.com',
  fax:'0379-64332066',
  email:"luoyang@northglass.com",
  postcode:'471003'
 
},
  {
    company:'上海北玻玻璃技术工业有限公司',
    companyInfo:"SHANGHAI NORTH GLASS TECHNOLOGY&INDUSTRY CO.,LTD.",
    address:'上海市松江区小昆山镇光华路328号',
    phone:'(021)57858640',
    url:'http://www.northglass.com',
    fax:'(021)57858600',
    email:"sngpzb@163.com",
    postcode:'201614'
 
  }
])
let companyAddress = ref(companyList.value[0])
watch(props, (newVal, oldVal) => {
  companyAddress.value = companyList.value[props.companyVal-1]
})
 
 
onUpdated(() => {
  const element = document.getElementById('my-paragraph');
  if (element) {
    //console.log(element.style.height)
  }
});
const orderDetailList = ref([])
const customer = ref({})
const selectPrint =async () => {
  request.post(`/finishedGoodsInventory/getSelectPrints`, data.value).then((res) => {
    if (res.code == 200) {
      produceList.value = deepClone(res.data.data)
      customer.value = produceList.value[0].detail[0]
      let height = 0
      let index = 0
      for(let i=0;i<produceList.value.length;i++){
        //换产品就换页
        if(i>0){
          index+=1
        }
        orderDetailList.value[index]=[]
        orderDetailList.value[index].push({
          type:'customer',
          customer:produceList.value[i].detail[0]
        })
        produceList.value[i].detailList.forEach(order => {
          height+=50
          //判断高度是否超过350,则换页
          if(height>=500){
            height=0
            index+=1
            orderDetailList.value[index]=[]
 
            orderDetailList.value[index].push({
              type:'customer',
              customer:produceList.value[i].detail[0]
            })
          }
          orderDetailList.value[index].push({
            type:'product',
            productName:order.product_name
          })
 
 
          order.detailList.forEach(item => {
            height+=30
            if(height>=500){
              height=0
              index+=1
              orderDetailList.value[index]=[]
              orderDetailList.value[index].push({
                type:'customer',
                customer:produceList.value[i].detail[0]
              })
            }
            orderDetailList.value[index].push({
              type:'size',
              size:item
            })
          })
        })
      }
      orderDetailList.value.forEach((page,index)=>{
        let sum = {
          quantity:0,
          area:0,
          weight:0
        }
        page.forEach((row)=>{
          if(row.type==='size'){
            sum.quantity +=row.size.quantity
            sum.area =addAuto(row.size.area,sum.area,2)
            sum.weight =addAuto(row.size.weight,sum.weight,2)
          }
        })
        page.push({
          type:'sum',
          sum:sum
        })
      })
    } else {
      ElMessage.warning(res.msg)
      router.push("/login")
    }
  })
}
 
</script>
 
<template>
  <div >
    <div :class="'div_'+n "  v-for="n in 2" >
      <div class="pages" v-for="page in orderDetailList" :key="page" style="width: 100%;position: relative;" >
        <table >
          <thead style="width: 100%">
          <tr>
            <td colspan="5" >
              <div style="text-align: center;font-weight: bolder;display: flex">
                <div style="width: 35px;height: 35px">
                  <img id="img-pic" style="width:100%;height: 100%" src="@/assets/northGlass.ico" alt="">
                </div>
 
                <div style="font-size: 15px;font-weight: bold;line-height: 15px;width: 300px">
                  <p
                      style="font-size: 15px;
                             font-weight: bold;
                             line-height: 15px;"
                  >{{companyAddress.company}}</p>
                  <span style="font-size: 8px;">&nbsp;&nbsp;&nbsp;&nbsp;{{companyAddress.companyInfo}}</span>
                </div>
              </div>
 
            </td>
 
          </tr>
          <tr>
            <td colspan="5" style="text-align: center;font-size: 10px">
              <div>(装箱单)</div>
            </td>
          </tr>
          <tr style="width: 100%;font-size: 9px"  >
            <td colspan="5">
              <div style="display:flex;">
                <div style="width: 100%"><span style="font-weight: bold;font-size: 10px">客户名称</span>:
                  <input class="contactNumber" style="width: 80%;font-size: 10px" type="text"
                         v-model="page[0].customer.customer_name" />
                </div>
              </div>
              <div style="display:flex;">
                <div style="width: 100%;font-size: 10px"><span style="font-weight: bold">工程名称</span>:{{page[0].customer.project}}({{page[0].customer.batch}})</div>
              </div>
              <div style="display:flex;">
                <div style="width: 50%;font-size: 10px"><span style="font-weight: bold">订单号</span>:{{page[0].customer.order_id}}</div>
                <div style="width: 50%;font-size: 10px"><span style="font-weight: bold">装箱单号</span>:{{page[0].customer.remarks}}</div>
              </div>
              <div style="display:flex;">
                <div style="width: 50%;font-size: 10px"><span style="font-weight: bold">包装日期</span>:{{page[0].customer.reporting_work_time}}</div>
                <div style="width: 50%;font-size: 10px"><span style="font-weight: bold">本架数量</span>:{{page[0].customer.quantity}}</div>
              </div>
              <div style="display:flex;">
                <div style="width: 50%;font-size: 10px"><span style="font-weight: bold;font-size: 10px">加工班组</span>:{{page[0].customer.teams_groups_name2}}</div>
                <div style="width: 50%;font-size: 10px"><span style="font-weight: bold;font-size: 10px">包装班组</span>:{{page[0].customer.teams_groups_name}}</div>
              </div>
              <div style="display:flex;">
                <div style="width: 50%;font-size: 10px"><span style="font-weight: bold">质量检验</span>:刘化菊</div>
                <div style="width: 50%;font-size: 10px"><span style="font-weight: bold">成品发货</span>:郑珊珊</div>
              </div>
 
 
            </td>
          </tr>
          <tr style="width: 100%;font-size: 12px">
            <td style="width: 20%;">编号</td>
            <td style="width: 20%;">宽度</td>
            <td style="width: 20%;">高度</td>
            <td style="width: 20%;">片数</td>
            <td style="width: 20%;">面积(m²)</td>
          </tr>
          <tr style="width: 100%;">
            <td colspan="5" ><hr></td>
          </tr>
          </thead>
          <tbody>
          <template v-for="(row,index) in page" :key="row">
            <tr v-if="row.type==='product'" style="width: 100%;height: 100px" >
              <td colspan="1" style="font-weight: bold;font-size: 11px">加工品种:</td>
              <td colspan="4">
                <textarea style="resize: none;width: 90%;height: 100px;border: 0;word-break:break-all;" class="textarea" type="textarea" v-model="row.productName" /></td>
            </tr>
            <tr v-else-if="row.type==='size'" style="width: 100%;height: 30px">
              <td style="font-size: 10px">{{ row.size.building_number }}</td>
              <td style="font-weight: bold">{{ row.size.width }}</td>
              <td style="font-weight: bold">{{ row.size.height }}</td>
              <td style="font-weight: bold">{{ row.size.quantity }}</td>
              <td>{{ row.size.area }}</td>
            </tr>
 
 
 
          </template>
          </tbody>
          <tfoot id="sticky-footer">
          <tr style="border: 0;font-size: 8px">
            <td colspan="5" style="border: 0;">
              <div style="display:flex;">
                <div>地址:{{companyAddress.address}}</div>&nbsp;&nbsp;&nbsp;&nbsp;
                <div>电话:{{companyAddress.phone}}</div>
              </div>
              <div style="display:flex;">
                <div>{{companyAddress.url}}</div>&nbsp;&nbsp;&nbsp;&nbsp;
                <div>传真:{{companyAddress.fax}}</div>
              </div>
              <div style="display:flex;">
                <div>E-mail:{{companyAddress.email}}</div>&nbsp;&nbsp;&nbsp;&nbsp;
                <div>邮编:{{companyAddress.postcode}}</div>
              </div>
 
            </td>
          </tr>
          </tfoot>
        </table>
 
        <table  id="footsum">
          <template v-for="(row,index) in page" :key="index">
            <tr  v-if="row.type==='sum'" style="border: 0;font-size: 10px">
              <td colspan="5" style="border: 0;">
                <div style="display:flex;">
                  <div>本页数量</div>&nbsp;&nbsp;&nbsp;&nbsp;
                  <div>{{row.sum.quantity}}</div>&nbsp;&nbsp;&nbsp;
                  <div>面积</div>&nbsp;&nbsp;&nbsp;&nbsp;
                  <div>{{row.sum.area}}(m²)</div>&nbsp;&nbsp;&nbsp;
                  <div>重量</div>&nbsp;&nbsp;&nbsp;&nbsp;
                  <div>{{row.sum.weight}}(kg)</div>
                </div>
              </td>
            </tr>
          </template>
        </table>
      </div>
    </div>
 
  </div>
 
</template>
 
<style scoped>
* {
  margin: 0;
  padding: 0;
}
.contactNumber{
  width: 40%;
  height:20px;
  border: none;
  box-shadow: none;
  font-size: 15px;
}
.div_1{
  width: 38%;
}
.div_2{
  width: 40%;
  margin-left: 15%;
}
.element-to-break-after {
  width: 8%;
}
.element-to-breakr{
  page-break-after: always;
}
#contentTable{
  width: 100%;
  height: 100%;
}
 
#record{
  font-size: 15px;
  text-align: left;
  display: flex;
  flex-wrap: wrap
}
.pages{
  width: 100%;
  page-break-after: always;
}
table{
  width: 100%;
}
 
 
 
 
 
.textarea{
  --el-border-color: rgba(255,255,255,0.0);
  --el-input-focus-border-color: rgba(255,255,255,0.0);
  --el-input-focus-border-width: 0px;
  --el-input-hover-border-color: rgba(255,255,255,0.0);
  --el-input-hover-border-width: 0px;
}
 
</style>