print-template-by.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364
  1. <template>
  2. <ele-modal
  3. title="出库单"
  4. :visible.sync="QRvisible"
  5. v-if="QRvisible"
  6. width="90%"
  7. >
  8. <div
  9. id="printSection"
  10. style="
  11. display: flex;
  12. align-items: center;
  13. justify-content: center;
  14. flex-direction: column;
  15. "
  16. >
  17. <table
  18. cellspacing="0"
  19. style="
  20. width: 100%;
  21. table-layout: fixed;
  22. word-break: break-all;
  23. word-wrap: break-word;
  24. font-size: 12px;
  25. "
  26. >
  27. <tbody>
  28. <tr align="center">
  29. <td colspan="3">
  30. <div
  31. style="
  32. display: flex;
  33. align-items: center;
  34. justify-content: center;
  35. "
  36. >
  37. <img
  38. style="width: 80px; height: 80px"
  39. src="@/assets/logo.jpg"
  40. alt=""
  41. v-if="groupName.includes('宝悦')"
  42. />
  43. <div>
  44. <div style="font-size: 14px">{{
  45. groupName || '湖南宝悦新型建材有限公司'
  46. }}</div>
  47. <div style="font-size: 10px" v-if="groupName.includes('宝悦')"
  48. >HUNAN BAO YUE BULIDING MATERAIL</div
  49. >
  50. </div>
  51. </div>
  52. </td>
  53. <td colspan="3" style="font-size: 24px">
  54. <div style="border-bottom: 2px solid #000; width: 150px"
  55. >销 售 发 货 单</div
  56. >
  57. </td>
  58. <td colspan="3"><svg id="print"></svg></td>
  59. </tr>
  60. <tr>
  61. <td colspan="3" style="padding: 1px">
  62. 发货单号:{{ formData.docNo }}
  63. </td>
  64. <td colspan="3" style="padding: 1px">
  65. 项目: {{ formData.projectName }}</td
  66. >
  67. <td colspan="3" style="padding: 1px">
  68. 日期:{{ getNowFormatDate() }}
  69. </td>
  70. </tr>
  71. <tr>
  72. <td colspan="3" style="padding: 1px 1px 10px 1px">
  73. 客户:{{ formData.contactName }}</td
  74. >
  75. <td colspan="3" style="padding: 1px 1px 10px 1px">
  76. 联系电话: {{ formData.linkPhone }}</td
  77. >
  78. <td colspan="3" style="padding: 1px 1px 10px 1px">
  79. 车牌号: {{ formData.carNo }}</td
  80. >
  81. </tr>
  82. </tbody>
  83. </table>
  84. <table
  85. border
  86. cellspacing="0"
  87. style="
  88. width: 100%;
  89. table-layout: fixed;
  90. word-break: break-all;
  91. word-wrap: break-word;
  92. font-size: 12px;
  93. "
  94. >
  95. <tbody>
  96. <tr align="center">
  97. <td style="padding: 1px; width: 120px"> 产品编码 </td>
  98. <td style="padding: 1px"> 产品名称 </td>
  99. <td style="padding: 1px; width: 130px"> 规格 </td>
  100. <!-- <td style="padding: 1px"> 型号 </td> -->
  101. <td style="padding: 1px"> 单位 </td>
  102. <td style="padding: 1px"> 数量 </td>
  103. <td style="padding: 1px"> 块数 </td>
  104. <td style="padding: 1px"> 强度 </td>
  105. <td style="padding: 1px"> 密度 </td>
  106. <td style="padding: 1px" v-if="isPrintPrice"> 单价(元) </td>
  107. <td style="padding: 1px" v-if="isPrintPrice"> 金额(元) </td>
  108. <td style="padding: 1px"> 备注 </td>
  109. </tr>
  110. <tr align="center" v-for="(item, index) in codeList">
  111. <td style="padding: 1px">{{ item.productCode }}</td>
  112. <td style="padding: 1px">{{ item.productName }}</td>
  113. <td style="padding: 1px">{{ item.specification }}</td>
  114. <!-- <td style="padding: 1px">{{ item.modelType }}</td> -->
  115. <td style="padding: 1px">{{ item.measuringUnit }}</td>
  116. <td style="padding: 1px">{{ item.totalCount }}</td>
  117. <td style="padding: 1px">{{ item.blockCount }}</td>
  118. <td style="padding: 1px">{{ item.extField.packagingStrength }}</td>
  119. <td style="padding: 1px">{{ item.extField.packagingDensity }}</td>
  120. <td style="padding: 1px" v-if="isPrintPrice">{{
  121. item.discountSinglePrice
  122. }}</td>
  123. <td style="padding: 1px" v-if="isPrintPrice">{{
  124. item.discountTotalPrice
  125. }}</td>
  126. <td style="padding: 1px">{{ item.remark }}</td>
  127. </tr>
  128. <tr align="center">
  129. <td colspan="4" style="padding: 1px"> 合计 </td>
  130. <td colspan="1" style="padding: 1px">
  131. {{ getTotalValue('totalCount', 4) }}
  132. </td>
  133. <td style="padding: 1px"> {{ getTotalValue('blockCount',1) }}</td>
  134. <td colspan="2" style="padding: 1px"></td>
  135. <td colspan="1" style="padding: 1px" v-if="isPrintPrice">
  136. {{
  137. codeList.reduce((total, item) => {
  138. return (total += item.discountTotalPrice);
  139. }, 0)
  140. }}
  141. </td>
  142. <td colspan="1" v-if="isPrintPrice" style="padding: 1px"></td>
  143. </tr>
  144. <tr align="center">
  145. <td colspan="3" style="padding: 1px">
  146. 注意事项:遗失托盘赔偿260/个
  147. </td>
  148. <td colspan="2" style="padding: 1px">
  149. 装车托盘数:{{ formData.trayNum }}</td
  150. >
  151. <td style="padding: 1px"></td>
  152. <td style="padding: 1px"> 带回托盘数: </td>
  153. <td :colspan="isPrintPrice ? 3 : 1" style="padding: 1px"></td>
  154. </tr>
  155. </tbody>
  156. </table>
  157. <table
  158. cellspacing="0"
  159. style="
  160. width: 100%;
  161. table-layout: fixed;
  162. word-break: break-all;
  163. word-wrap: break-word;
  164. font-size: 12px;
  165. "
  166. >
  167. <tbody>
  168. <tr>
  169. <td colspan="3" style="padding: 1px">
  170. 承运人:{{ this.formData.driverNames }}</td
  171. >
  172. <td colspan="3" style="padding: 1px">
  173. 装卸工:{{ this.formData.carName }}</td
  174. >
  175. <td colspan="3" style="padding: 1px"> 签收人:</td>
  176. <td colspan="3" style="padding: 1px">
  177. 制单人:{{ this.formData.markerName }}</td
  178. >
  179. </tr>
  180. <tr>
  181. <td colspan="8" style="padding: 1px"
  182. >物流服务评价:<input
  183. type="checkbox"
  184. id="vehicle1"
  185. name="vehicle1"
  186. value="Bike"
  187. style="padding: 1px 1px"
  188. />
  189. <span>满意</span>
  190. <input
  191. type="checkbox"
  192. id="vehicle2"
  193. name="vehicle2"
  194. value="Car"
  195. style="padding: 1px 1px"
  196. /><span>不满意</span>
  197. </td>
  198. <td colspan="4" style="padding: 1px"
  199. >打印时间:{{ getNowFormatDate() }}</td
  200. >
  201. </tr>
  202. <tr>
  203. <td colspan="2" style="padding: 1px"> (白)记账联 </td>
  204. <td colspan="2" style="padding: 1px"> (红)客户留存联 </td>
  205. <td colspan="2" style="padding: 1px"> (蓝)结算联 </td>
  206. <td colspan="2" style="padding: 1px"> (绿)运费联 </td>
  207. <td colspan="2" style="padding: 1px"> (黄)装卸联 </td>
  208. <td colspan="2" style="padding: 1px"> (白)出门联 </td>
  209. </tr>
  210. </tbody>
  211. </table>
  212. </div>
  213. <div slot="footer">
  214. <el-button @click="print">打印预览</el-button>
  215. <el-button @click="close">关闭</el-button>
  216. </div>
  217. </ele-modal>
  218. </template>
  219. <script>
  220. import { mapGetters } from 'vuex';
  221. import JsBarcode from 'jsbarcode';
  222. import { getSendSaleOrderrecordDetailSplit } from '@/api/saleManage/saleordersendrecord';
  223. export default {
  224. name: 'print',
  225. computed: {
  226. ...mapGetters(['user'])
  227. },
  228. props: {
  229. groupName: ''
  230. },
  231. data() {
  232. return {
  233. checked: '',
  234. QRvisible: false,
  235. isPrintPrice: false,
  236. codeList: [],
  237. formData: {},
  238. carName: ''
  239. };
  240. },
  241. methods: {
  242. open(id, isPrintPrice) {
  243. this.isPrintPrice = isPrintPrice;
  244. getSendSaleOrderrecordDetailSplit(id).then((data) => {
  245. if (JSON.stringify(data) != '{}') {
  246. this.formData = data;
  247. this.formData['carName'] = data.carList
  248. .map((item) => item.name)
  249. .toString();
  250. this.formData.projectName = data.saleOrderList?.[0]?.projectName;
  251. this.formData.driverNames = data.logisticTrakListNoteVOList
  252. .map((item) => item.driverName)
  253. .join(','); // 承运人
  254. this.codeList = data.productList;
  255. this.formData.markerName = this.user.info.name;
  256. }
  257. this.QRvisible = true;
  258. this.$nextTick(() => {
  259. JsBarcode('#print', data.docNo, {
  260. format: 'CODE39', //选择要使用的条形码类型
  261. width: 0.8, //设置条之间的宽度
  262. height: 50, //高度
  263. displayValue: false, //是否在条形码下方显示文字
  264. text: '', //覆盖显示的文本
  265. fontOptions: 'bold italic', //使文字加粗体或变斜体
  266. font: 'fantasy', //设置文本的字体
  267. textAlign: 'right', //设置文本的水平对齐方式
  268. textPosition: 'top', //设置文本的垂直位置
  269. textMargin: 1, //设置条形码和文本之间的间距
  270. fontSize: 15, //设置文本的大小
  271. background: '#fff', //设置条形码的背景
  272. lineColor: '#000', //设置条和文本的颜色。
  273. margin: 2 //设置条形码周围的空白边距
  274. });
  275. });
  276. });
  277. },
  278. close() {
  279. this.QRvisible = false;
  280. },
  281. getTotalValue(key, num) {
  282. let val = this.codeList.reduce((total, item) => {
  283. return (total += item[key]);
  284. }, 0);
  285. return val.toFixed(4).replace(/\.?0+$/, '');
  286. },
  287. //获取当前日期函数
  288. getNowFormatDate() {
  289. let date = new Date(),
  290. obj = {
  291. year: date.getFullYear(), //获取完整的年份(4位)
  292. month: date.getMonth() + 1, //获取当前月份(0-11,0代表1月)
  293. strDate: date.getDate(), // 获取当前日(1-31)
  294. week: '星期' + '日一二三四五六'.charAt(date.getDay()), //获取当前星期几(0 ~ 6,0代表星期天)
  295. hour: date.getHours(), //获取当前小时(0 ~ 23)
  296. minute: date.getMinutes(), //获取当前分钟(0 ~ 59)
  297. second: date.getSeconds() //获取当前秒数(0 ~ 59)
  298. };
  299. Object.keys(obj).forEach((key) => {
  300. if (obj[key] < 10) obj[key] = `0${obj[key]}`;
  301. });
  302. // return `${obj.year}年${obj.month}月${obj.strDate}日 ${obj.hour}:${obj.minute}:${obj.second}`;
  303. return `${obj.year}-${obj.month}-${obj.strDate}`;
  304. },
  305. print() {
  306. const printSection = document.getElementById('printSection');
  307. // 创建打印任务
  308. const printWindow = window.open('', '_blank');
  309. printWindow.document.open();
  310. printWindow.document.write('<html><head><title>打印预览</title>');
  311. printWindow.document.write(
  312. '<link rel="stylesheet" href="your-stylesheet-url.css" type="text/css" />'
  313. );
  314. printWindow.document.write('</head><body>');
  315. printWindow.document.write(printSection.innerHTML);
  316. printWindow.document.write('</body></html>');
  317. printWindow.document.close();
  318. printWindow.onload = function () {
  319. printWindow.print();
  320. };
  321. }
  322. }
  323. };
  324. </script>
  325. <style lang="scss">
  326. #printSection {
  327. display: flex;
  328. align-items: center;
  329. justify-content: center;
  330. flex-direction: column;
  331. .table_box {
  332. width: 70%;
  333. table-layout: fixed;
  334. word-break: break-all;
  335. word-wrap: break-word;
  336. }
  337. th,
  338. td {
  339. padding: 20px;
  340. position: relative;
  341. }
  342. .barCode {
  343. position: absolute;
  344. right: 10px;
  345. top: 50%;
  346. transform: translateY(-50%);
  347. }
  348. .person {
  349. width: 70%;
  350. display: flex;
  351. align-items: center;
  352. justify-content: center;
  353. margin-bottom: 10px;
  354. > div {
  355. flex: 1;
  356. }
  357. }
  358. }
  359. </style>