DocGeneratorExample.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495
  1. <template>
  2. <div class="container-box">
  3. <div class="grid-item-1">
  4. <Navbar :title="title" :is-go-back="false" />
  5. </div>
  6. <div class="grid-item-2" style="margin-bottom: 5px">
  7. <div class="btn-group">
  8. <button class="btn btn-primary" @click="generate()">确定</button>
  9. <button class="btn btn-warning" @click="back()">撤销</button>
  10. </div>
  11. </div>
  12. <div class="grid-item-3">
  13. <DocGenerator
  14. ref="docGenerator"
  15. :info-window-no="infoWindowNo"
  16. :generate-ids="generateIds"
  17. :add-sql="addSql"
  18. @show-title="title = $event"
  19. />
  20. </div>
  21. </div>
  22. </template>
  23. <script>
  24. import Common from '../../packages/common/Common.js';
  25. import DocGenerator from '../../packages/info/src/DocGenerator.vue';
  26. import Notify from '../../packages/common/Notify';
  27. import IFrameUtil from '../../packages/common/IFrameUtil.js';
  28. import Navbar from '../../packages/navbar/src/Navbar.vue';
  29. export default {
  30. components: { DocGenerator, Navbar },
  31. data: function () {
  32. return {
  33. uuid: '',
  34. infoWindowNo: '',
  35. type: '',
  36. title: '',
  37. generateIds: [],
  38. addSql: undefined,
  39. modelData: undefined,
  40. userId: null,
  41. };
  42. },
  43. mounted: function () {
  44. // 测试请手动设置路由
  45. this.uuid = this.$route.params.uuid;
  46. this.infoWindowNo = this.$route.params.infoWindowNo;
  47. this.type = this.$route.params.type;
  48. // 测试请手动设置localStorage
  49. const item = `${this.uuid}#GenerateDocumentTool`;
  50. this.modelData = JSON.parse(localStorage.getItem(item));
  51. // 正式使用
  52. // this.modelData = window.opener.getModelData();
  53. const loginInfo = localStorage.getItem('#LoginInfo');
  54. if (loginInfo) {
  55. this.userId = JSON.parse(loginInfo).userId;
  56. } else {
  57. this.userId = -1;
  58. }
  59. if (this.type == 'currentStock') {
  60. if (this.modelData.data.warehouse.id != null) {
  61. this.addSql = 'c.id = ' + this.modelData.data.warehouse.id;
  62. } else {
  63. this.addSql = 'c.id = -1 ';
  64. }
  65. } else if (this.type == 'currentStockWork') {
  66. if (this.modelData.data.warehouse.id != null) {
  67. this.addSql = 'c.id = ' + this.modelData.data.warehouse.id;
  68. } else {
  69. this.addSql = 'c.id = -1 ';
  70. }
  71. } else if (this.type == 'currentStockProject') {
  72. if (this.modelData.data.warehouse.id != null) {
  73. this.addSql = 'c.id = ' + this.modelData.data.warehouse.id;
  74. } else {
  75. this.addSql = 'c.id = -1 ';
  76. }
  77. } else if (this.type == 'inventoryOut') {
  78. //必选先选择仓库
  79. if (this.modelData.data.warehouse.id != null) {
  80. //分配状态为责任人变更
  81. if (
  82. this.modelData.data.inventoryOutType != null &&
  83. this.modelData.data.inventoryOutType.displayValue[0] != null &&
  84. this.modelData.data.inventoryOutType.displayValue[0] ==
  85. 'Change_Of_Responsible_Person'
  86. ) {
  87. this.addSql =
  88. `c.id = ${this.modelData.data.warehouse.id} AND (csk.inventoryItemStatus = 'Assigned') ` +
  89. ` AND (csk.responsibilityUserId = ${this.userId}) `;
  90. }
  91. //分配状态为退回/归还
  92. else if (
  93. this.modelData.data.inventoryOutType != null &&
  94. this.modelData.data.inventoryOutType.displayValue[0] == 'Send_Back'
  95. ) {
  96. this.addSql =
  97. `c.id = ${this.modelData.data.warehouse.id} AND (csk.inventoryItemStatus = 'Assigned') ` +
  98. ` AND (u.id = ${this.userId}) `;
  99. }
  100. //分配状态为领用/借用
  101. else if (
  102. this.modelData.data.inventoryOutType != null &&
  103. this.modelData.data.inventoryOutType.displayValue[0] ==
  104. 'Requisition_Borrowing'
  105. ) {
  106. this.addSql = `c.id = ${this.modelData.data.warehouse.id} AND (csk.inventoryItemStatus = 'Assignable' OR csk.inventoryItemStatus = 'Returning_Distributable_Funds') `;
  107. }
  108. //管理员分配
  109. else if (this.modelData.data.inventoryOutType == null) {
  110. this.addSql = `c.id = ${this.modelData.data.warehouse.id} AND (csk.inventoryItemStatus = 'Assignable' OR csk.inventoryItemStatus = 'Returning_Distributable_Funds') `;
  111. } else {
  112. this.addSql = 'c.id = -1 ';
  113. }
  114. } else {
  115. this.addSql = 'c.id = -1 ';
  116. }
  117. } else if (this.type == 'stockOutProject') {
  118. //当选择出库类型是正常报废出库的时候,从报废申请明细中生成出库明细
  119. //下面的查询窗口代码是根据报废申请明细查询库存数据
  120. if (
  121. this.modelData.data.stockOutProjectType.displayValue[0] ==
  122. 'Normal_Scrapping'
  123. ) {
  124. this.infoWindowNo = '20240201_161916';
  125. } else if (
  126. this.modelData.data.stockOutProjectType.displayValue[0] ==
  127. 'Systematic_Differences'
  128. ) {
  129. this.infoWindowNo = '20240415_201354';
  130. }
  131. if (this.modelData.data.warehouse.id != null) {
  132. this.addSql = 'c.id = ' + this.modelData.data.warehouse.id;
  133. } else {
  134. this.addSql = 'c.id = -1 ';
  135. }
  136. } else if (this.type == 'scrapApply') {
  137. if (this.modelData.data.warehouse.id != null) {
  138. //报废申请查询的物料库存数据只能查询责任人是当前登录人的
  139. this.addSql = `c.id = ${this.modelData.data.warehouse.id} AND u.id = ${this.userId}`;
  140. } else {
  141. this.addSql = 'c.id = -1 ';
  142. }
  143. } else if (this.type == 'syncStockOutPrepareProject') {
  144. if (this.modelData.data.warehouse.id != null) {
  145. this.addSql = `cwh.id = ${this.modelData.data.warehouse.id}`;
  146. } else {
  147. this.addSql = 'cwh.id = -1 ';
  148. }
  149. } else if (this.type == 'IdleManagement') {
  150. if (this.modelData.data.warehouse.id != null) {
  151. this.addSql = 'w.id = ' + this.modelData.data.warehouse.id;
  152. } else {
  153. this.addSql = 'w.id = -1 ';
  154. }
  155. } else if (this.type == 'IdleManagementWork') {
  156. if (this.modelData.data.warehouse.id != null) {
  157. this.addSql = 'w.id = ' + this.modelData.data.warehouse.id;
  158. } else {
  159. this.addSql = 'w.id = -1 ';
  160. }
  161. }
  162. },
  163. methods: {
  164. generate: function () {
  165. var _self = this;
  166. var selectedDatas = _self.$refs.docGenerator.getSelectedData();
  167. if (
  168. selectedDatas === undefined ||
  169. selectedDatas === null ||
  170. selectedDatas.length === 0
  171. ) {
  172. Notify.error('提示', '未选择任何数据。', false);
  173. return;
  174. }
  175. let modelData = IFrameUtil.getCurdModelData();
  176. let url = null;
  177. if (_self.type == 'purchaseRequest') {
  178. url = 'PurchaseOrderResource/generatePurchaseOrderModelData';
  179. } else if (_self.type == 'purchaseOrder') {
  180. url =
  181. 'purchaseOrderArrivalResource/generatePurchaseOrderArrivalModelData';
  182. } else if (_self.type == 'purchaseOrderArrival') {
  183. url =
  184. 'incomingInspectionRequestResource/generateInspectRequestModelData';
  185. } else if (_self.type == 'inspectionRequest') {
  186. if (selectedDatas.length > 1) {
  187. Notify.error('数据选择错误', '只能选择一条报检单明细数据', false);
  188. return;
  189. } else {
  190. url = 'incomingInspectionResource/generateInspectionModelData';
  191. }
  192. } else if (_self.type == 'inspectionReject') {
  193. if (selectedDatas.length > 1) {
  194. Notify.error('数据选择错误', '只能选择一条检验单数据', false);
  195. return;
  196. } else {
  197. url =
  198. 'incomingInspectionRejectResource/generateInspectionRejectModelData';
  199. }
  200. } else if (_self.type == 'inspectionStockIn') {
  201. url = 'stockInResource/generateStockInModelDataByInspection';
  202. } else if (_self.type == 'purchaseOrderArrivalStockIn') {
  203. url = 'stockInResource/generateStockInModelDataByArrival';
  204. } else if (_self.type == 'purchaseStockIn') {
  205. url = 'StockOutResource/generateMaterialStockOutModelData';
  206. } else if (_self.type == 'purchaseOrderReturn') {
  207. url =
  208. 'purchaseOrderReturnResource/generatePurchaseOrderReturnModelData';
  209. } else if (_self.type == 'materialStockOut') {
  210. url = 'StockOutResource/generateRedStockOutModelData';
  211. } else if (_self.type == 'redPurchaseStockIn') {
  212. url = 'stockInResource/generateRedStockInModelData';
  213. } else if (_self.type == 'stockInPrepareLine') {
  214. url = 'stockInResource/generateRedStockInPrepareModelData';
  215. } else if (_self.type == 'generateStockInByOrder') {
  216. url = 'stockInResource/generateStockInByOrder';
  217. } else if (_self.type == 'newPurchaseRequest') {
  218. //仓库模块-采购订单
  219. url = 'PurchaseOrderResource/generateModelData';
  220. } else if (_self.type == 'newPurchaseOrder') {
  221. //仓库模块-采购到货单
  222. url = 'purchaseOrderArrivalResource/generateModelData';
  223. } else if (_self.type == 'newArrivalStockIn') {
  224. //仓库模块-(到货单生成)入库单
  225. url = 'stockInResource/generateArrivalStockInModelData';
  226. } else if (_self.type == 'newArrivalInspectionRequest') {
  227. //仓库模块-来料报检单
  228. url = 'incomingInspectionRequestResource/generateModelData';
  229. } else if (_self.type == 'newInspectionRequest') {
  230. //仓库模块-来料检验单
  231. if (selectedDatas.length > 1) {
  232. Notify.error('数据选择错误', '只能选择一条报检单数据', false);
  233. return;
  234. } else {
  235. url = 'incomingInspectionResource/generateModelData';
  236. }
  237. } else if (_self.type == 'newInspectionReject') {
  238. //仓库模块-不良品处理单
  239. if (selectedDatas.length > 1) {
  240. Notify.error('数据选择错误', '只能选择一条检验单数据', false);
  241. return;
  242. } else {
  243. url = 'incomingInspectionRejectResource/generateModelData';
  244. }
  245. } else if (_self.type == 'newCurrentStock') {
  246. //仓库模块-(仓库库存生成)出库单
  247. url = 'StockOutResource/generateModelData';
  248. } else if (_self.type == 'newRedStockOut') {
  249. //仓库模块-红字出库单
  250. url = 'StockOutResource/generateRedModelData';
  251. } else if (_self.type == 'newPurchaseOrderReturn') {
  252. //仓库模块-采购退货单
  253. url = 'purchaseOrderReturnResource/generateModelData';
  254. } else if (_self.type == 'newStockOut') {
  255. //仓库模块-红字出库单
  256. url = 'StockOutResource/generateRedModelData';
  257. } else if (_self.type == 'newRedStockIn') {
  258. //仓库模块-红字入库单
  259. url = 'stockInResource/generateRedModelData';
  260. } else if (_self.type == 'invStockIn') {
  261. //仓库模块-(物料批量)入库单
  262. url = 'stockInResource/generateModelDataByInventory';
  263. } else if (_self.type == 'orderToIn') {
  264. //仓库模块-(订单生成)入库单
  265. url = 'stockInResource/generateOrderToInModelData';
  266. } else if (_self.type == 'saleOrderToIn') {
  267. //仓库模块-销售订单生成入库单
  268. url = 'stockInResource/generateSaleOrderToInModelData';
  269. } else if (_self.type == 'saleOrderToOut') {
  270. //仓库模块-销售订单生成出库单
  271. url = 'StockOutResource/generateSaleOrderToOutModelData';
  272. } else if (_self.type == 'saleOrderToPrepare') {
  273. //仓库模块-销售订单生成领料单
  274. url = 'stockOutPrepareResource/generateSaleOrderToPrepareModelData';
  275. } else if (_self.type == 'prepareToOut') {
  276. //仓库模块-领料单生成出库单
  277. url = 'StockOutResource/generatePrepareToOutModelData';
  278. } else if (_self.type == 'saleOrderToStockUp') {
  279. //销售订单生成备货单
  280. url = 'StockUpResource/generateSaleOrderToStockUpModelData';
  281. } else if (_self.type == 'applyToStockUp') {
  282. //布草管理-出库申请单生成仓库备货单
  283. url = 'StockUpResource/generateApplyToUpModelData';
  284. } else if (_self.type == 'purchaseOrderToStockOut') {
  285. //布草管理-采购订单详单生成工厂出库单
  286. url = 'StockOutResource/generateStockOutByPurchaseOrder';
  287. } else if (_self.type == 'newAssetCheck') {
  288. //资产采购单生成验收单
  289. url = 'assetCheckResource/generateModelData';
  290. } else if (_self.type == 'newPurchaseBill') {
  291. //采购单生成采购丁单发票
  292. url = 'purchaseOrderBillResource/generateModelData';
  293. } else if (_self.type == 'newPurchaseOrderPayment') {
  294. //采购订单生成付款单
  295. url = 'purchaseOrderPaymentResource/generateModelData';
  296. } else if (_self.type == 'newSaleOrderReceivables') {
  297. //销售订单生成收款单
  298. url = 'SaleOrderReceiptResource/generateModelData';
  299. } else if (_self.type == 'newSaleOrderBill') {
  300. //销售订单生成销售订单发票
  301. url = 'saleOrderBillResource/generateModelData';
  302. } else if (_self.type == 'newSaleOrderReceipt') {
  303. //销售订单生成收款单
  304. url = 'SaleOrderReceiptResource/generateModelData';
  305. } else if (_self.type == 'generatePurchaseRequest') {
  306. //申购单生成采购订单
  307. url = 'PurchaseOrderResource/generateModelData';
  308. } else if (_self.type == 'generatePurchaseOrder') {
  309. //采购订单生成采购到货
  310. url = 'PurchaseOrderArrivalResource/generateModelData';
  311. } else if (_self.type == 'syncStockOutPrepare') {
  312. //领料申请生成入库单
  313. url = 'stockInResource/generateModelDataBySyncStockOutPrepare';
  314. } else if (_self.type == 'syncStockOutPrepareWork') {
  315. //领料申请生成入库单-办公劳保
  316. url = 'StockInWorkResource/generateModelDataBySyncStockOutPrepareWork';
  317. } else if (_self.type == 'syncStockOutPrepareProject') {
  318. //调拨申请生成入库单-工程设备仓
  319. url =
  320. 'StockInProjectResource/generateModelDataBySyncStockOutPrepareProject';
  321. } else if (_self.type == 'currentStock') {
  322. //库存查询生成领料叫料
  323. url = 'StockOutResource/generateModelDataByCurrentStock';
  324. } else if (_self.type == 'currentStockWork') {
  325. //库存查询生成领料叫料-办公劳保
  326. url = 'StockOutWorkResource/generateModelDataByCurrentStockWork';
  327. } else if (_self.type == 'inventoryOut') {
  328. //库存查询生成物料分配明细-工程设备仓
  329. url = 'InventoryOutResource/generateModelDataByCurrentStockProject';
  330. } else if (_self.type == 'scrapApply') {
  331. //库存查询生成物料报废明细-工程设备仓
  332. url = 'ScrapApplyResource/generateModelDataByCurrentStockProject';
  333. } else if (_self.type == 'stockOutProject') {
  334. //库存查询生成物料出库明细-工程设备仓
  335. url = 'StockOutProjectResource/generateModelDataByCurrentStockProject';
  336. } else if (_self.type == 'stockReturn') {
  337. //领料生成退库
  338. url = 'StockOutResource/generateModelDataByStockReturn';
  339. } else if (_self.type == 'stockWorkReturn') {
  340. //领料生成退库-办公劳保
  341. url = 'StockOutWorkResource/generateModelDataByStockReturn';
  342. } else if (_self.type == 'IdleManagement') {
  343. //库存查询生成闲置
  344. url = 'IdleManagementResource/generateModelDataByCurrentStock';
  345. } else if (_self.type == 'IdleManagementWork') {
  346. //库存查询生成闲置-办公劳保
  347. url = 'IdleManagementWorkResource/generateModelDataByCurrentStock';
  348. } else {
  349. Notify.error('提示', '不识别的生单地址。' + _self.type, false);
  350. return;
  351. }
  352. let generateDocumentModelData = {
  353. windowNo: modelData.windowNo,
  354. tabIndex: modelData.tabIndex,
  355. modelData: modelData,
  356. inputDatas: selectedDatas,
  357. };
  358. $.ajax({
  359. url: Common.getApiURL(url),
  360. type: 'post',
  361. contentType: 'application/json',
  362. data: JSON.stringify(generateDocumentModelData),
  363. beforeSend: function (request) {
  364. Common.addTokenToRequest(request);
  365. },
  366. success: function (modelData) {
  367. if (modelData != undefined) {
  368. if (modelData.saveDatas != undefined) {
  369. modelData.saveDatas.forEach(function (item) {
  370. if (item.editMode == null) {
  371. item.editMode = true;
  372. }
  373. item.tabIndex = 1;
  374. });
  375. }
  376. // IFrameUtil.setCurdModelData(modelData);
  377. window.opener.modelDataChanged(modelData);
  378. _self.back();
  379. }
  380. },
  381. error: function (XMLHttpRequest, textStatus, errorThrown) {
  382. Common.processException(XMLHttpRequest, textStatus, errorThrown);
  383. },
  384. });
  385. },
  386. isShowVendorDialogA: function (data) {
  387. var _self = this;
  388. var messageStr = '';
  389. data.forEach(function (item, index) {
  390. if (index == data.length - 1) {
  391. messageStr += item.name;
  392. } else {
  393. messageStr += item.name + ',';
  394. }
  395. });
  396. Notify.show({
  397. title: '项目确认',
  398. message: '您选择的请购订单明细中存在不同项目【' + messageStr + '】',
  399. buttons: [
  400. {
  401. label: '取消',
  402. action: function (dialogItself) {
  403. dialogItself.close();
  404. },
  405. },
  406. ],
  407. });
  408. },
  409. isShowVendorDialog: function (data) {
  410. var _self = this;
  411. var messageStr = '';
  412. data.forEach(function (item, index) {
  413. if (index == data.length - 1) {
  414. messageStr += item.vendorName;
  415. } else {
  416. messageStr += item.vendorName + ',';
  417. }
  418. });
  419. Notify.show({
  420. title: '供应商确认',
  421. message:
  422. '您选择的请购订单明细中存在不同供应商【' +
  423. messageStr +
  424. '】,如果点击\\"确定\\"按钮,将从供应商【' +
  425. data[data.length - 1].vendorName +
  426. '】下订单,否则点击\\"取消\\"按钮',
  427. buttons: [
  428. {
  429. label: '确定',
  430. cssClass: 'btn-primary',
  431. action: function (dialogItself) {
  432. dialogItself.close();
  433. var url = 'PurchaseOrderResource/generatePurchaseOrderModelData';
  434. _self.responseReceiveData(_self.obj);
  435. },
  436. },
  437. {
  438. label: '取消',
  439. action: function (dialogItself) {
  440. dialogItself.close();
  441. },
  442. },
  443. ],
  444. });
  445. },
  446. /**
  447. * 返回,关闭模态框
  448. */
  449. back: function () {
  450. IFrameUtil.close();
  451. },
  452. },
  453. };
  454. </script>
  455. <style scoped>
  456. .grid-container {
  457. display: grid;
  458. grid-template-columns: 100%;
  459. grid-template-rows: min-content min-content auto;
  460. height: calc(100vh - 35px);
  461. width: 100%;
  462. padding: 10px;
  463. }
  464. .grid-item-1 {
  465. grid-row: 1 / 2;
  466. grid-column: 1 / 2;
  467. }
  468. .grid-item-2 {
  469. grid-row: 2 / 3;
  470. grid-column: 1 / 2;
  471. }
  472. .grid-item-3 {
  473. overflow: auto;
  474. grid-row: 3/4;
  475. grid-column: 1 / 2;
  476. height: 100%;
  477. }
  478. .container-box {
  479. padding: 20px;
  480. height: calc(100vh - 20px);
  481. }
  482. </style>