PrintedPurchaseOrder.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485
  1. <template>
  2. <div class="container-fluid">
  3. <Navbar title="已打印" :is-go-back="true" />
  4. <div class="flex-container" style="margin-top: 10px">
  5. <div class="flex-header">
  6. <div class="form-inline">
  7. <PrintWidget
  8. ref="printWidget"
  9. :printer-localstorage-id="'#InventoryPrinterPrinter'"
  10. @selected-printer-name="getPrintName"
  11. />
  12. <div class="form-group">
  13. <label>采购订单号</label>
  14. <input
  15. v-model="documentNo"
  16. autocomplete="off"
  17. type="text"
  18. placeholder="输入采购订单号"
  19. class="form-control"
  20. />
  21. </div>
  22. <div class="form-group">
  23. <label>存货名称</label>
  24. <input
  25. v-model="inventoryName"
  26. autocomplete="off"
  27. type="text"
  28. placeholder="输入存货档案名称"
  29. class="form-control"
  30. />
  31. </div>
  32. <div class="form-group">
  33. <label>存货编码</label>
  34. <input
  35. v-model="inventoryCode"
  36. autocomplete="off"
  37. type="text"
  38. placeholder="输入存货档案编码"
  39. class="form-control"
  40. />
  41. </div>
  42. <div class="form-group">
  43. <label>规格型号</label>
  44. <input
  45. v-model="inventoryType"
  46. autocomplete="off"
  47. type="text"
  48. placeholder="输入规格型号"
  49. class="form-control m-form-control"
  50. />
  51. </div>
  52. </div>
  53. <div class="form-inline" style="margin-top: 10px">
  54. <button
  55. type="button"
  56. class="btn btn-primary"
  57. @click="loadPrintedInventoryInstance"
  58. >
  59. 查询
  60. </button>
  61. <!-- <button type="button"
  62. class="btn btn-primary"
  63. @click="printInvoice">打印发货单</button> -->
  64. <button type="button" class="btn btn-primary" @click="printBarCode">
  65. 打印条码
  66. </button>
  67. <button type="button" class="btn btn-primary" @click="printPdf">
  68. 打印PDF
  69. </button>
  70. </div>
  71. </div>
  72. <div class="flex-content">
  73. <table
  74. v-if="inventoryInstances.length > 0"
  75. id="myTable"
  76. class="table table-bordered"
  77. >
  78. <thead>
  79. <tr>
  80. <th>
  81. <input
  82. id="checkAll"
  83. v-model="checkAll"
  84. autocomplete="off"
  85. type="checkbox"
  86. @click="checkedAll($event)"
  87. />
  88. </th>
  89. <th>序号</th>
  90. <th>订单编号</th>
  91. <th>存货名称</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. </tr>
  101. </thead>
  102. <tbody id="table-notPrint">
  103. <tr v-for="(item, index) in inventoryInstances" :key="item.id">
  104. <td>
  105. <input
  106. :id="item"
  107. v-model="checkboxModel"
  108. autocomplete="off"
  109. type="checkbox"
  110. :value="item"
  111. /><label :for="item" />
  112. </td>
  113. <td>
  114. {{
  115. (pagination.current_page - 1) * pagination.per_page +
  116. 1 +
  117. index
  118. }}
  119. </td>
  120. <td>{{ item.purchaseOrderDocumentNo }}</td>
  121. <td>{{ item.inventoryName }}</td>
  122. <td>{{ item.inventoryCode }}</td>
  123. <td>{{ item.inventoryType }}</td>
  124. <td>{{ item.createDate }}</td>
  125. <td>{{ item.printedDate }}</td>
  126. <td>{{ item.barCode }}</td>
  127. <td>{{ item.printQuantity }}</td>
  128. <td>{{ item.quantity }}</td>
  129. <td>已打印</td>
  130. </tr>
  131. </tbody>
  132. </table>
  133. </div>
  134. <div class="flex-footer">
  135. <VueBootstrapPagination
  136. :pagination="pagination"
  137. :callback="loadPrintedInventoryInstance"
  138. />
  139. </div>
  140. <Modal v-model:show="modal">
  141. <ProcessReportResult :process-report-result="processReportResult" />
  142. <template #header>执行结果</template>
  143. </Modal>
  144. </div>
  145. <Loading v-if="loading" />
  146. </div>
  147. </template>
  148. <script>
  149. import Common from '../common/Common.js';
  150. import InventoryInstancePrintResource from '../api/wms/InventoryInstancePrintResource.js';
  151. import { PrintUtil } from 'pc-component-v3';
  152. export default {
  153. name: 'PrintedPurchaseOrder',
  154. components: {
  155. },
  156. data: function () {
  157. return {
  158. inventoryName: '',
  159. inventoryCode: '',
  160. inventoryType: '',
  161. documentNo: '',
  162. inventoryInstances: [],
  163. checkboxModel: [], //获取选项框数据
  164. checkAll: '', //全选,
  165. reportResult: {},
  166. pagination: {
  167. total: 0,
  168. per_page: 30,
  169. current_page: 1,
  170. last_page: 10,
  171. },
  172. processReportResult: {},
  173. loading: false,
  174. modal: false,
  175. selectedPrinterTitle:'',
  176. };
  177. },
  178. watch: {
  179. // 反选
  180. checkboxModel: {
  181. handler: function (val, oldVal) {
  182. console.log(this.checkboxModel.toString());
  183. if (this.inventoryInstances.length == this.checkboxModel.length) {
  184. this.checkAll = true;
  185. } else {
  186. this.checkAll = false;
  187. }
  188. },
  189. deep: true,
  190. },
  191. },
  192. mounted: function () {
  193. this.loadPrintedInventoryInstance();
  194. this.keydown();
  195. },
  196. methods: {
  197. getPrintName:function(value){
  198. this.selectedPrinterTitle = value;
  199. },
  200. /**
  201. * 打印PDF条码
  202. * @return {[type]} [description]
  203. */
  204. printPdf: function () {
  205. var _self = this;
  206. if (_self.checkboxModel.length == 0) {
  207. Notify.notice('提示', '请至少选择一项打印', false);
  208. return;
  209. }
  210. _self.loading=true;
  211. var ids = [];
  212. _self.checkboxModel.forEach(function (item) {
  213. ids.push(item.id);
  214. });
  215. // ProcessReportResource.runProcessByIds(287681, ids).then(
  216. // successData => {
  217. // _self.loading=false;
  218. // _self.$refs.modal.show = true;
  219. // _self.processReportResult = successData;
  220. // _self.checkboxModel = [];
  221. // _self.loadPrintedInventoryInstance();
  222. // },
  223. // errorData => {
  224. // _self.loading=false;
  225. // Common.processException(errorData);
  226. // },
  227. // );
  228. },
  229. loadPrintedInventoryInstance: function () {
  230. var _self = this;
  231. var documentNo = _self.documentNo;
  232. var inventoryName = _self.inventoryName;
  233. var inventoryCode = _self.inventoryCode;
  234. var inventoryType = _self.inventoryType;
  235. // eslint-disable-next-line
  236. InventoryInstancePrintResource.queryPrintedInventoryInstancePrint(
  237. true,
  238. _self.pagination.current_page,
  239. _self.pagination.per_page,
  240. inventoryName,
  241. inventoryCode,
  242. inventoryType,
  243. ).then(
  244. successData1 => {
  245. if (successData1) {
  246. _self.inventoryInstances = successData1.inventoryInstancePrintDtos;
  247. //_self.checkboxModel.splice(0,_self.checkboxModel.length);
  248. console.log(successData1);
  249. // 分页相关
  250. // eslint-disable-next-line
  251. _self.pagination.total = successData1.totalCount;
  252. // eslint-disable-next-line
  253. _self.pagination.last_page =
  254. successData1.totalCount % _self.pagination.per_page == 0
  255. ? successData1.totalCount / _self.pagination.per_page
  256. : Math.floor(
  257. successData1.totalCount / _self.pagination.per_page,
  258. ) + 1;
  259. }
  260. },
  261. errorData => {
  262. Common.processException(errorData);
  263. },
  264. );
  265. },
  266. //打印条码
  267. printBarCode: function () {
  268. var _self = this;
  269. let selectedPrinter = this.selectedPrinterTitle;
  270. if (_self.checkboxModel.length == 0) {
  271. Notify.notice('提示', '请至少选择一项打印', false);
  272. } else if (selectedPrinter == null || selectedPrinter.length == 0) {
  273. Notify.error('提示', '请先选择打印机。', false);
  274. return;
  275. } else {
  276. _self.loading=true;
  277. var inventoryInstanceIds = [];
  278. _self.checkboxModel.forEach(function (item) {
  279. inventoryInstanceIds.push(item.inventoryInstanceId);
  280. });
  281. InventoryInstancePrintResource.print(inventoryInstanceIds).then(
  282. baseListResponse => {
  283. if (baseListResponse.errorCode == 0) {
  284. _self.loading=false;
  285. var contents = [];
  286. baseListResponse.datas.forEach(function (item) {
  287. var printItem = {
  288. id: null,
  289. name: null,
  290. content: item,
  291. };
  292. if (
  293. printItem.content == null ||
  294. printItem.content.printItems == null ||
  295. printItem.content.printItems.length == 0
  296. ) {
  297. Notify.error('错误', '打印模板无数据,不能打印。');
  298. return;
  299. }
  300. var content = JSON.stringify(printItem.content);
  301. if (content == null || content == '' || content == '{}') {
  302. Notify.error('错误', '请先选择模板,再点击下载。');
  303. return;
  304. }
  305. contents.push(printItem.content);
  306. });
  307. PrintUtil.printPrintPages(contents, selectedPrinter);
  308. }
  309. },
  310. errorData => {
  311. _self.loading=false;
  312. Common.processException(errorData);
  313. },
  314. );
  315. // 延时 2 秒钟再进行打印
  316. var timer1 = window.setTimeout(function () {
  317. _self.loadPrintedInventoryInstance();
  318. _self.checkboxModel = [];
  319. window.clearTimeout(timer1);
  320. }, 2000);
  321. }
  322. },
  323. /**
  324. * 打印发货单
  325. * @return {[type]} [description]
  326. */
  327. printInvoice: function () {
  328. var _self = this;
  329. var id = 287680;
  330. var data = _self.checkboxModel;
  331. _self.loading=true;
  332. // ProcessReportResource.runProcessByIds(_self.checkboxModel).then(
  333. // successData1 => {
  334. // if (successData1) {
  335. // _self.loading=false;
  336. // _self.$refs.modal.show = true;
  337. // _self.loading=false;
  338. // _self.processReportResult = data;
  339. // }
  340. // },
  341. // errorData => {
  342. // _self.loading=false;
  343. // Common.processException(errorData);
  344. // },
  345. // );
  346. },
  347. checkedAll: function (event) {
  348. var _self = this;
  349. if (event.currentTarget.checked) {
  350. _self.checkboxModel.splice(0, _self.checkboxModel.length);
  351. _self.inventoryInstances.forEach(function (item) {
  352. _self.checkboxModel.push(item);
  353. });
  354. } else {
  355. _self.checkboxModel.splice(0, _self.checkboxModel.length);
  356. }
  357. },
  358. // 键盘回车事件
  359. keydown: function () {
  360. var _self = this;
  361. document.onkeydown = function (event) {
  362. var currentEvent = event || window.event || arguments[0];
  363. if (currentEvent && currentEvent.keyCode == 13) {
  364. currentEvent.preventDefault();
  365. _self.loadPrintedInventoryInstance();
  366. }
  367. };
  368. },
  369. },
  370. };
  371. </script>
  372. <style scoped>
  373. table.fixed-table tr th {
  374. text-align: center;
  375. }
  376. .myTable {
  377. margin-top: 10px;
  378. border-left: 1px solid #c9c9c9;
  379. border-top: 1px solid #c9c9c9;
  380. border-collapse: collapse;
  381. width: 100%;
  382. }
  383. .myTable th {
  384. border-right: 1px solid #c9c9c9;
  385. border-bottom: 1px solid #c9c9c9;
  386. padding: 10px 0px;
  387. font-size: 18px;
  388. font-family: "宋体";
  389. text-align: center;
  390. }
  391. .myTable td {
  392. border-right: 1px solid #c9c9c9;
  393. border-bottom: 1px solid #c9c9c9;
  394. background: #fff;
  395. padding: 6px 0px;
  396. font-size: 16px;
  397. line-height: 20px;
  398. color: #676767;
  399. text-align: center;
  400. }
  401. .m-form-group {
  402. margin-bottom: 5px;
  403. margin-top: 5px;
  404. }
  405. .m-form-label {
  406. width: 120px;
  407. text-align: right;
  408. padding-right: 6px;
  409. }
  410. .m-form-control {
  411. width: 150px;
  412. }
  413. div.panel {
  414. margin-top: 15px;
  415. }
  416. tbody > tr:hover {
  417. background-color: #c0c0c0;
  418. }
  419. input[type="checkbox"] {
  420. display: none;
  421. }
  422. input#checkAll {
  423. display: inline-block;
  424. width: 1.2em;
  425. height: 1.2em;
  426. border: 1px solid black;
  427. border-radius: 2px;
  428. }
  429. input[type="checkbox"] + label {
  430. width: 1.2em;
  431. height: 1.2em;
  432. border: 1px solid black;
  433. border-radius: 2px;
  434. position: relative;
  435. }
  436. input[type="checkbox"] + label:hover {
  437. cursor: pointer;
  438. }
  439. input[type="checkbox"]:checked + label::before {
  440. font-size: 1.9em;
  441. content: "\2714";
  442. background: yellowgreen;
  443. position: absolute;
  444. top: -2px;
  445. left: -2px;
  446. right: -2px;
  447. bottom: -2px;
  448. border-radius: 3px;
  449. border: 1px solid black;
  450. line-height: 10px;
  451. }
  452. </style>