chnangguirukudan.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501
  1. <template>
  2. <div class="bg">
  3. <!-- 常规列表页面打印入库单 -->
  4. <el-dialog
  5. width="900px"
  6. height="12cm"
  7. :modal-append-to-body="false"
  8. title="采购入库单"
  9. :visible.sync="scanVisible"
  10. id="pageid"
  11. >
  12. <!-- 表单是否显示 -->
  13. <div style="height: 500px; width: 95%; margin: 0 auto" >
  14. <div ref="qrcode" id="box">
  15. <vue-easy-print tableShow ref="easyPrint" :onePageRow="onePageRow">
  16. <div
  17. v-for="(item1, index1) in list"
  18. :key="index1"
  19. style="margin-bottom: 30px;width: 85%;margin: 0 auto;"
  20. >
  21. <div style="page-break-after: always">
  22. <div >
  23. <table :border="1">
  24. <thead>
  25. <tr class="title" style="background:#ffffff">
  26. <th colspan="15">
  27. <h1 style="display:block">采购入库单</h1>
  28. </th>
  29. </tr>
  30. <tr class="title" style="background:#ffffff">
  31. <th colspan="15">
  32. <span style="float: left;">
  33. 申购部门:<span style="margin-left: 10px">{{item1.shen_gou_bu_men_|bumenfilters(bumenList)}}</span>
  34. </span>
  35. <span style="float:right;padding-right: 8px;">日期 :{{item1.dao_huo_ri_qi_}}</span>
  36. </th>
  37. </tr>
  38. <tr class="title" style="background:#ffffff">
  39. <th colspan="15">
  40. <span style="float:left;">供应商:<span style="margin-left: 10px">{{item1.gong_ying_shang_| gongyingshang(gongyingshangList)}}</span></span>
  41. <span style="float:right;padding-right: 8px;">采购订单编号:{{item1.cai_gou_ding_dan_}}</span>
  42. </th>
  43. </tr>
  44. <!-- <tr class="title" >
  45. <th colspan="15">
  46. <div class="word-title" style="background:#fff;">
  47. <h4 style="display:block">采购入库单</h4>
  48. <div class="tagBox">
  49. <div>
  50. <div style="font-size: 10px;text-align: left;">申购部门:
  51. <span style="margin-left: 10px">{{item1.shen_gou_bu_men_|bumenfilters(bumenList)}}</span>
  52. </div>
  53. <div style="font-size: 10px">供应商:
  54. <span style="margin-left: 10px">{{item1.gong_ying_shang_| gongyingshang(gongyingshangList)}}</span>
  55. </div>
  56. </div>
  57. <div style="text-align: left;">
  58. <div style="font-size: 10px; padding-right: 10px;">采购订单编号:
  59. <span >{{item1.cai_gou_ding_dan_}}</span>
  60. </div>
  61. <div style="font-size: 10px; ">日期 :
  62. <span >{{item1.dao_huo_ri_qi_}}</span>
  63. </div>
  64. </div>
  65. </div>
  66. </div>
  67. </th>
  68. </tr> -->
  69. <tr >
  70. <th style="width: 40px">序号</th>
  71. <th style="font-weight: normal">物料编码</th>
  72. <th style="font-weight: normal">物料名称</th>
  73. <th >货号</th>
  74. <th >批号</th>
  75. <th >规格/特征</th>
  76. <th >生产商/品牌</th>
  77. <th >数量</th>
  78. <th >单位</th>
  79. <th >单价(含税)</th>
  80. <th >税率</th>
  81. <th >单价</th>
  82. <th >税额</th>
  83. <th >金额</th>
  84. <th >含税合计</th>
  85. </tr>
  86. </thead>
  87. <!-- <thead>
  88. <tr >
  89. <th style="width: 40px">序号</th>
  90. <th style="font-weight: normal">物料编码</th>
  91. <th style="font-weight: normal">物料名称</th>
  92. <th>货号</th>
  93. <th>批号</th>
  94. <th>规格/特征</th>
  95. <th>生产商/品牌</th>
  96. <th>数量</th>
  97. <th>单位</th>
  98. <th>单价(含税)</th>
  99. <th>税率</th>
  100. <th>单价</th>
  101. <th>税额</th>
  102. <th>金额</th>
  103. <th>含税合计</th>
  104. </tr>
  105. </thead> -->
  106. <tbody>
  107. <tr v-for="(item, index) in item1" :key="index">
  108. <td style="width: 30px">{{ index + 1 }}</td>
  109. <td style="width: 70px">{{ item.wu_liao_bian_ma_ }}</td>
  110. <td style="width: 120px">{{ item.wu_liao_ming_chen }}</td>
  111. <td style="width: 60px">{{ item.huo_hao_ }}</td>
  112. <td style="width: 60px">{{ item.pi_hao_ }}</td>
  113. <td style="width: 80px">{{ item.gui_ge_xing_hao_ }}</td>
  114. <td style="width: 120px"> {{ item.gong_ying_shang_| gongyingshang(gongyingshangList) }} </td>
  115. <td style="width: 45px">{{ item.shu_liang_ }}</td>
  116. <td style="width: 45px">{{ item.dan_wei_ }}</td>
  117. <td style="width: 60px">{{ item.dan_jia_han_shui_ |numToFixed}}</td>
  118. <td style="width: 45px">{{ item.shui_lv_ }}</td>
  119. <td style="width: 45px">{{ item.dan_jia_|numToFixed}}</td>
  120. <td style="width: 45px"> {{ item.dan_jia_han_shui_|shuieToFixed(item.shu_liang_,item.dan_jia_) }}</td>
  121. <td style="width: 45px">{{ item.dan_jia_|jineToFixed(item.shu_liang_)}}</td>
  122. <td style="width: 60px">{{ item.dan_jia_han_shui_|jineToFixed(item.shu_liang_) }}</td>
  123. </tr>
  124. <tr>
  125. <td style="width: 30px"></td>
  126. <td style="width: 70px"></td>
  127. <td style="width: 120px"></td>
  128. <td style="width: 60px"></td>
  129. <td style="width: 60px"></td>
  130. <td style="width: 80px"></td>
  131. <td style="width: 120px"></td>
  132. <td style="width: 45px"></td>
  133. <td style="width: 45px"></td>
  134. <td style="width: 60px"></td>
  135. <td style="width: 45px"></td>
  136. <td style="width: 45px">合计:</td>
  137. <td style="width: 45px">{{ item1|addshuieToFixed}}</td>
  138. <td style="width: 45px">{{ item1|addjineToFixed}}</td>
  139. <td style="width: 60px">{{ item1|addhshjToFixed }}</td>
  140. </tr>
  141. </tbody>
  142. <tfoot class="bottom">
  143. <tr>
  144. <td colspan="6" style="text-align:left">
  145. <div style="margin-top:10px">仓管员:{{ item1.name2 }}</div>
  146. </td>
  147. <td colspan="1" class="footer-row">
  148. <div style="margin-top:10px" ref="innerRef"></div>
  149. </td>
  150. <td colspan="9" style="text-align:right">
  151. <div style="margin-top:10px">审核人:{{ item1.name3 }} </div>
  152. </td>
  153. </tr>
  154. </tfoot>
  155. </table>
  156. </div>
  157. </div>
  158. </div>
  159. </vue-easy-print>
  160. </div>
  161. </div>
  162. <span slot="footer" class="dialog-footer">
  163. <el-button type="primary" @click="printDemo">打印</el-button>
  164. </span>
  165. </el-dialog>
  166. </div>
  167. </template>
  168. <script>
  169. import VueBarcode from "vue-barcode";
  170. import vueEasyPrint from "vue-easy-print";
  171. import repostCurd from "@/business/platform/form/utils/custom/joinCURD.js";
  172. export default {
  173. components: {
  174. VueBarcode,
  175. vueEasyPrint,
  176. },
  177. props: {
  178. obj: {
  179. default: [],
  180. type: Array,
  181. },
  182. onePageRow: {
  183. type: Number,
  184. default: 3,
  185. },
  186. blankLines: {
  187. type: Boolean,
  188. default: true,
  189. },
  190. scanVisible: {
  191. type: Boolean,
  192. default: false,
  193. },
  194. currentScan: {
  195. type: Boolean,
  196. default: false,
  197. },
  198. },
  199. data() {
  200. return {
  201. // onePageRow: 1,
  202. value: "",
  203. id: "",
  204. list: [],
  205. visible: true,
  206. gongyingshangList: [],
  207. bumenList: [],
  208. };
  209. },
  210. created() {
  211. this.getInit();
  212. let sql = `select * FROM t_gysml`;
  213. repostCurd("sql", sql).then((res) => {
  214. this.gongyingshangList = res.variables.data;
  215. });
  216. let sql1 = `select ID_,NAME_ FROM ibps_party_org `;
  217. repostCurd("sql", sql1).then((res) => {
  218. return (this.bumenList = res.variables.data);
  219. });
  220. },
  221. filters: {
  222. gongyingshang: function (value, list) {
  223. for (let i = 0; i < list.length; i++) {
  224. if (value == list[i].id_) {
  225. return list[i].gong_ying_shang_m;
  226. } else if (i == list.length - 1) {
  227. return value;
  228. }
  229. }
  230. },
  231. numToFixed: function (value) {
  232. return (value*1).toFixed(2)
  233. },
  234. jineToFixed:function(a,b){
  235. let value = (a * 1) * (b * 1);
  236. return value.toFixed(2)
  237. },
  238. shuieToFixed:function(a,b,c){
  239. let jine = b*1*(c*1);
  240. let hshj = b*1*(a*1);
  241. let value = hshj - jine;
  242. return value.toFixed(2);
  243. },
  244. addshuieToFixed:function(arr){
  245. let adds =0;
  246. arr.forEach(item=>{
  247. adds =adds+(((item.shu_liang_*1) * (item.dan_jia_han_shui_*1)) - ((item.shu_liang_*1) * (item.dan_jia_*1)) );
  248. })
  249. return adds.toFixed(2);
  250. },
  251. addjineToFixed(arr){
  252. let adds =0;
  253. arr.forEach(item=>{
  254. adds =adds+((item.shu_liang_*1) * (item.dan_jia_*1));
  255. })
  256. return adds.toFixed(2);
  257. },
  258. addhshjToFixed(arr){
  259. let adds =0;
  260. arr.forEach(item=>{
  261. adds =adds+((item.shu_liang_*1) * (item.dan_jia_han_shui_*1));
  262. })
  263. return adds.toFixed(2);
  264. },
  265. bumenfilters: function (value, list) {
  266. //
  267. for (let i = 0; i < list.length; i++) {
  268. if (value == list[i].ID_) {
  269. return list[i].NAME_;
  270. } else if (i == list.length - 1) {
  271. return value;
  272. }
  273. }
  274. },
  275. },
  276. watch: {
  277. obj() {
  278. this.getInit();
  279. },
  280. },
  281. methods: {
  282. printDemo() {
  283. this.$refs.easyPrint.print();
  284. // this.$refs.easyPrint.window.print()
  285. },
  286. toDecimal2(x) {
  287. var f = parseFloat(x);
  288. if (isNaN(f)) {
  289. return false;
  290. }
  291. var f = Math.round(x * 100) / 100;
  292. var s = f.toString();
  293. var rs = s.indexOf(".");
  294. if (rs < 0) {
  295. rs = s.length;
  296. s += ".";
  297. }
  298. while (s.length <= rs + 2) {
  299. s += "0";
  300. }
  301. return s;
  302. },
  303. addNumber(num1, num2) {
  304. let a = parseFloat(num1);
  305. let b = parseFloat(num2);
  306. return a.toFixed("2") * 1 + b.toFixed("2") * 1;
  307. },
  308. getInit() {
  309. var idStr = "";
  310. this.obj.forEach((item) => {idStr += item + ",";});
  311. idStr = idStr.substring(0, idStr.length - 1);
  312. this.getLook(idStr);
  313. },
  314. getLook(id) {
  315. this.list = [];
  316. let this_ = this;
  317. let sql = `select * FROM t_yszb WHERE FIND_IN_SET(id_,'${id}')`;
  318. let zhubiao = [];
  319. let name1, name2, name3;
  320. let time1, time2, time3;
  321. let addhanshuiheji = 0;
  322. let addjine = 0;
  323. let addshuie = 0;
  324. repostCurd("sql", sql).then((res) => {
  325. zhubiao = res.variables.data;
  326. zhubiao.forEach((item) => {
  327. let sql1 = `select * FROM t_cgysjlb WHERE FIND_IN_SET(wai_jian_,'${item.id_}')`;
  328. repostCurd("sql", sql1).then((res) => {
  329. let data = res.variables.data;
  330. let s2 = `select a.NAME_,DATE_FORMAT(b.CREATE_TIME_,'%Y-%m-%d') AS CREATE_TIME_ FROM ibps_party_employee as a join ibps_bpm_oper_log as b on a.ID_ = b.CREATE_BY_ where b.PROC_INST_ID_ = ( SELECT PROC_INST_ID_ FROM ibps_bpm_bus_rel WHERE BUSINESSKEY_ = '${item.id_}' LIMIT 1) AND b.NODE_ID_ = 'Activity_04lhxla' ORDER BY b.CREATE_TIME_ DESC LIMIT 1`;
  331. repostCurd("sql", s2).then((res) => {
  332. name2 = res.variables.data[0].NAME_;
  333. time2 = res.variables.data[0].CREATE_TIME_;
  334. data["name2"] = name2;
  335. data["time2"] = time2;
  336. let s3 = `select a.NAME_,DATE_FORMAT(b.CREATE_TIME_,'%Y-%m-%d') AS CREATE_TIME_ FROM ibps_party_employee as a join ibps_bpm_oper_log as b on a.ID_ = b.CREATE_BY_ where b.PROC_INST_ID_ = ( SELECT PROC_INST_ID_ FROM ibps_bpm_bus_rel WHERE BUSINESSKEY_ = '${item.id_}' LIMIT 1) AND b.NODE_ID_ = 'Activity_1dk76gy' ORDER BY b.CREATE_TIME_ DESC LIMIT 1`;
  337. repostCurd("sql", s3).then((res) => {
  338. name3 = res.variables.data[0].NAME_;
  339. time3 = res.variables.data[0].CREATE_TIME_;
  340. data["name3"] = name3;
  341. data["time3"] = time3;
  342. data["gong_ying_shang_"] = item.gong_ying_shang_;
  343. data["shen_gou_bu_men_"] = item.shen_gou_bu_men_;
  344. data["cai_gou_ding_dan_"] = item.cai_gou_ding_dan_;
  345. data["dao_huo_ri_qi_"] = item.dao_huo_ri_qi_;
  346. data.forEach((it) => {
  347. data["addhanshuiheji"] = this.addNumber(
  348. addhanshuiheji,
  349. it.han_shui_he_ji_
  350. );
  351. data["addjine"] = this.addNumber(addjine, it.jin_e_);
  352. data["addshuie"] = this.addNumber(addshuie, it.shui_e_);
  353. addhanshuiheji = data["addhanshuiheji"];
  354. addjine = data["addjine"];
  355. addshuie = data["addshuie"];
  356. });
  357. data["addhanshuiheji"] = this_.toDecimal2(
  358. data["addhanshuiheji"]
  359. );
  360. data["addjine"] = this_.toDecimal2(data["addjine"]);
  361. data["addshuie"] = this_.toDecimal2(data["addshuie"]);
  362. this_.list.push(data);
  363. addhanshuiheji = 0;
  364. addjine = 0;
  365. addshuie = 0;
  366. // this_.getPage();
  367. });
  368. });
  369. });
  370. });
  371. });
  372. },
  373. getPage(){
  374. let bodyEle = document.getElementById("pageid");
  375. //获取页面总长度
  376. // this.$refs.innerRef[0].innerHTML ='11'
  377. let bodyHeight = bodyEle.clientHeight;
  378. //获取页数 1026:单页A4纸总高度(不同得浏览器打印高度不一致,根据自己需求调整)
  379. let count =parseInt((bodyHeight / 383)) +2;
  380. console.log(bodyHeight,count,"高度")
  381. //动态添加页码 通过绝对定位
  382. for (let i = 0; i < count; i++) {
  383. this.$refs.innerRef[i].innerHTML = i+1;
  384. }
  385. }
  386. },
  387. };
  388. </script>
  389. <!-- <style scoped>
  390. @page {
  391. size: auto; /* auto is the initial value */
  392. color: #fff;
  393. }
  394. </style> -->
  395. <style lang="scss" scoped>
  396. // @page :first {
  397. // color: green;
  398. // @top-left {
  399. // content: "foo" !important;
  400. // color: blue;
  401. // }
  402. // @top-right {
  403. // content: "bar";
  404. // }
  405. // }
  406. .bottom {
  407. margin-top: 15px;
  408. border-bottom: 1px solid #fff;
  409. border-left: 1px solid #fff;
  410. border-right: 1px solid #fff;
  411. }
  412. .title{
  413. border-top: 1px solid #fff;
  414. border-left: 1px solid #fff;
  415. border-right: 1px solid #fff;
  416. }
  417. // .word-title {
  418. // display: flex;
  419. // justify-content: center;
  420. // }
  421. thead {
  422. background: #f3f3f3;
  423. }
  424. .el-dialog__body {
  425. color: #0d0e0f;
  426. font-size: 10px !important;
  427. word-break: none;
  428. }
  429. thead > tr > th {
  430. font-size: 10px;
  431. text-align: center;
  432. font-weight: normal;
  433. color: #01060c;
  434. }
  435. .logo {
  436. position: absolute;
  437. top: -32px;
  438. left: 0;
  439. }
  440. .tagBox {
  441. position: relative;
  442. width: 100%;
  443. // border: 1px solid #000000;
  444. padding: 5px;
  445. // height: 30px;
  446. display: flex;
  447. justify-content: space-between;
  448. background-color: #fff;
  449. }
  450. .la {
  451. display: flex;
  452. align-items: center;
  453. }
  454. .lh {
  455. // line-height: auto;
  456. font-size: 12px;
  457. display: flex;
  458. align-items: center;
  459. }
  460. * {
  461. margin: 0;
  462. padding: 0;
  463. }
  464. table {
  465. border-collapse: collapse;
  466. text-align: center;
  467. border: 1px solid #01060c;
  468. }
  469. td {
  470. width: 120px;
  471. // height: 50px;
  472. text-align: center;
  473. font-size: 10px;
  474. }
  475. .friday {
  476. width: 100px;
  477. height: 50px;
  478. }
  479. </style>