warehousing-processing.js 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691
  1. /*******************************************************************************
  2. * Copyright(c) 2022 dongke All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称: 入库办理列表-采购入库 其它入库 销售退货出库的数据240408
  5. * 编辑履历:
  6. * 作者 日期 版本 修改内容
  7. * 姜永辉 2024-03-12 1.00
  8. *******************************************************************************/
  9. const Constants = require('@/utils/Constants.js');
  10. const mixins = require('@/mixins/index.js')
  11. const app = getApp()
  12. Page({
  13. mixins: [mixins],
  14. /**
  15. * 页面的初始数据
  16. */
  17. data: {
  18. // 待入库 已入库的taglist
  19. tagList: [
  20. { title: mixins.$t('warehousingProcessing') },
  21. { title: mixins.$t('checkined') }],
  22. // 查询条件
  23. searchContent: [{
  24. code: 'makeTime',
  25. title: mixins.$t('pastThirthtyDays'),
  26. defaultValue: 5,
  27. searchType: Constants.searchType.date
  28. }, {
  29. code: 'choose',
  30. title: mixins.$t('choose'),
  31. searchType: Constants.searchType.pick
  32. }],
  33. // 查询条件-筛选
  34. pullMenuList: (app.globalData.company.gradeCode == Constants.gradeCode.PRO) ? [
  35. {
  36. code: 'intoType',
  37. pullType: 'mSelect',
  38. typeName: 'intoType'
  39. },
  40. {
  41. code: 'cusName',
  42. },
  43. {
  44. code: 'cusPhone',
  45. },
  46. {
  47. code: 'addressFull',
  48. },
  49. {
  50. code: 'supName',
  51. },
  52. {
  53. code: 'whName',
  54. title: mixins.$t('reservoirArea')
  55. },
  56. {
  57. code: 'staffName',
  58. },
  59. {
  60. code: 'orgName',
  61. },
  62. {
  63. code: 'flgValid',
  64. title: mixins.$t('flgValid'),
  65. dataType: 'checkbox'
  66. },
  67. ] : [
  68. {
  69. code: 'intoType',
  70. pullType: 'mSelect',
  71. typeName: 'intoTypeSt'
  72. },
  73. {
  74. code: 'cusName',
  75. },
  76. {
  77. code: 'cusPhone',
  78. },
  79. {
  80. code: 'addressFull',
  81. },
  82. {
  83. code: 'whName',
  84. title: mixins.$t('reservoirArea')
  85. },
  86. {
  87. code: 'staffName',
  88. },
  89. {
  90. code: 'orgName',
  91. },
  92. {
  93. code: 'flgValid',
  94. title: mixins.$t('flgValid'),
  95. dataType: 'checkbox'
  96. },
  97. ],
  98. // 列表区(脚部金额)
  99. footerAmount: {
  100. name: 'intoingAmt',
  101. title: mixins.$t('totalAmount')
  102. },
  103. // 列表区(脚部信息)
  104. footerInfo: [{ prefix: mixins.$t('together'), name: 'intoQty', title: mixins.$t('piece') }],
  105. // 列表区(内容)
  106. contentList: [],
  107. // 列表的显示字段
  108. contentObj: {
  109. [mixins.$t('purInBound')]: [{
  110. name: 'intoNo',
  111. title: mixins.$t('orderNo')
  112. }, {
  113. name: 'whName',
  114. title: mixins.$t('eiWhName')
  115. }, {
  116. name: [{
  117. name: 'orgName',
  118. title: ''
  119. }, {
  120. name: 'staffName',
  121. title: mixins.$t('staffId')
  122. }],
  123. title: mixins.$t('purInfo')
  124. }, {
  125. name: 'intoDate',
  126. title: mixins.$t('intoDate')
  127. }],
  128. [mixins.$t('saleReturnInBound')]: [{
  129. name: 'intoNo',
  130. title: mixins.$t('orderNo')
  131. }, {
  132. name: 'cusPhone',
  133. title: mixins.$t('cusPhone')
  134. }, {
  135. name: 'addressFull',
  136. title: mixins.$t('addressFull')
  137. }, {
  138. name: [{
  139. name: 'orgName',
  140. title: ''
  141. }, {
  142. name: 'staffName',
  143. title: mixins.$t('staffId')
  144. }],
  145. title: mixins.$t('storeInformation')
  146. }, {
  147. name: 'intoDate',
  148. title: mixins.$t('intoDate')
  149. }],
  150. [mixins.$t('otherInWh')]: [{
  151. name: 'intoNo',
  152. title: mixins.$t('inOrderNo')
  153. }, {
  154. name: 'intoReasonName',
  155. title: mixins.$t('intoReason')
  156. }, {
  157. name: [{
  158. name: 'orgName',
  159. title: ''
  160. }, {
  161. name: 'staffName',
  162. title: mixins.$t('staffId')
  163. }],
  164. title: mixins.$t('cpManager')
  165. }, {
  166. name: 'intoDate',
  167. title: mixins.$t('intoDate')
  168. }],
  169. [mixins.$t('firstInWh')]: [{
  170. name: 'intoNo',
  171. title: mixins.$t('inOrderNo')
  172. },
  173. {
  174. name: [{
  175. name: 'orgName',
  176. title: ''
  177. }, {
  178. name: 'staffName',
  179. title: mixins.$t('staffId')
  180. }],
  181. title: mixins.$t('cpManager')
  182. }, {
  183. name: 'intoDate',
  184. title: mixins.$t('intoDate')
  185. }],
  186. },
  187. // 弹出按钮
  188. buttonList: [
  189. {
  190. name: 'editOrder',
  191. title: mixins.$t('edit'),
  192. },
  193. {
  194. name: 'invaidOrder',
  195. title: mixins.$t('invaidOrder'),
  196. }, {
  197. name: 'ticketPirnt',
  198. title: mixins.$t('ticketPirnt'),
  199. }
  200. ,
  201. ],
  202. // 底部保存按钮
  203. buttonFootList: [{
  204. name: 'addOther',
  205. title: mixins.$t('otherInWh'),
  206. }],
  207. // 底部左侧合计金额及数量
  208. contentnFootList: [
  209. {
  210. title: mixins.$t('totalAmount'),
  211. code: 'intoingAmt',
  212. content: 10,
  213. type: 'number'
  214. }, {
  215. type: 'count',
  216. code: 'count',
  217. bill: 1,
  218. quantity: 1
  219. }
  220. ],
  221. // 底部的按钮数据
  222. btnFormData: null,
  223. // 路由
  224. routeObjName: 'inboundProcessing',
  225. inboundOtherService: app.globalData['inboundOtherService'],
  226. outboundSaleReturnService: app.globalData['outboundSaleReturnService'],
  227. // active
  228. active: 0,
  229. // 主键Id
  230. primaryKey: 'intoId',
  231. // 系统参数
  232. flgHandleSetting: app.globalData.setting[Constants.settingCode.IVT001] == "true" ? true : false,
  233. },
  234. /**
  235. * @desc : 切换 待入库 已出库
  236. * @date : 2024年3月8日
  237. * @author : 姜永辉
  238. */
  239. onChangeTabs(e) {
  240. let index = e.detail.detail.index
  241. this.setData({
  242. active: index,
  243. })
  244. this.searchData()
  245. },
  246. /**
  247. * @desc : addOther
  248. * @date : 2024年3月8日
  249. * @author : 姜永辉
  250. */
  251. addOther() {
  252. let that = this
  253. wx.navigateTo({
  254. url: this.data.route.addOther.url,
  255. events: {
  256. // 回调后,在这里给页面赋值
  257. refresh: function (e) {
  258. that.searchData()
  259. }
  260. },
  261. success: function (res) {
  262. // 通过eventChannel向被打开页面传送数据 TODO 测试例子url是写死的,实际中,需要从route中读取
  263. res.eventChannel.emit('params', {})
  264. }
  265. })
  266. },
  267. /**
  268. * @desc : 跳转明细
  269. * @author : 周兴
  270. * @date : 2024/1/22
  271. */
  272. toDetail(e) {
  273. if (e) {
  274. let item = e.detail.item;
  275. if (e.detail.item) {
  276. let button = {
  277. formMode: Constants.formMode.edit
  278. }
  279. e.detail.item.button = button
  280. }
  281. // 如果name不传递,默认为edit
  282. if (item.intoType == Constants.intoType.pur
  283. || item.intoType == Constants.intoType.other
  284. || item.intoType == Constants.intoType.first) {
  285. e.detail.name = 'edit'
  286. } else {
  287. e.detail.name = 'editReturn'
  288. }
  289. }
  290. this.open(e);
  291. },
  292. /**
  293. * @desc : 设置查询参数
  294. * @date : 2024年3月8日
  295. * @author : 姜永辉
  296. */
  297. setSearchParams(params) {
  298. if (this.data.active == 0 && !this.data.flgHandleSetting) {
  299. //待入库的查询参数
  300. params.intoStatus = Constants.intoStatus.inBounding
  301. params.outStatus = Constants.outStatus.outBounding
  302. }
  303. else {
  304. //已入库的查询参数
  305. params.intoStatus = Constants.intoStatus.inBounded
  306. params.outStatus = Constants.outStatus.outBounded
  307. }
  308. if (app.globalData.company.gradeCode == Constants.gradeCode.PRO) {
  309. params.intoTypes = params.intoTypeList
  310. } else {
  311. params.intoTypes = params.intoTypeStList
  312. }
  313. return params;
  314. },
  315. /**
  316. * @desc : 查询 入库单
  317. * @date : 2024年3月8日
  318. * @author : 姜永辉
  319. */
  320. getData(params) {
  321. return this.excute(this.data.inboundOtherService, this.data.inboundOtherService.selectInbound, params);
  322. },
  323. /**
  324. * @desc : 处理接口返回数据
  325. * @date : 2024年3月8日
  326. * @author : 姜永辉
  327. */
  328. handleSearchData(tableData) {
  329. let temp = tableData
  330. temp.forEach(it => {
  331. // 入库对象 - 出库类型-销退回库
  332. if (it.intoType == Constants.outType.purReturn) {
  333. it.supplierName = it.cusName
  334. }
  335. })
  336. let contentnFootList = this.data.contentnFootList
  337. let footerAmount = this.data.footerAmount
  338. let footerInfo = this.data.footerInfo
  339. let intoingQty = Number(0)
  340. let intoingAmt = Number(0)
  341. if (this.data.active == 0 && !this.data.flgHandleSetting) {
  342. // 列表区(脚部金额)
  343. footerAmount.name = 'intoingAmt'
  344. // 列表区(脚部信息)
  345. footerInfo[0].name = 'intoingQty'
  346. temp.forEach(it => {
  347. it.makeTime = it.makeTime.substring(0, 10)
  348. intoingQty += Math.abs(Number(it.intoingQty))
  349. intoingAmt += Math.abs(Number(it.intoingAmt))
  350. // 入库对象
  351. if (it.intoType == Constants.intoType.other) {
  352. it.intoObject = it.cusName != null ? it.cusName : it.supplierName
  353. }
  354. })
  355. } else {
  356. // 列表区(脚部金额)
  357. footerAmount.name = 'intoAmt'
  358. // 列表区(脚部信息)
  359. footerInfo[0].name = 'intoQty'
  360. temp.forEach(it => {
  361. it.makeTime = it.makeTime.substring(0, 10)
  362. intoingQty += Math.abs(Number(it.intoQty))
  363. intoingAmt += Math.abs(Number(it.intoAmt))
  364. // 入库对象
  365. if (it.intoType == Constants.intoType.other) {
  366. it.intoObject = it.cusName != null ? it.cusName : it.supplierName
  367. }
  368. })
  369. }
  370. contentnFootList.forEach(it => {
  371. if (it.type == 'count') {
  372. it.bill = tableData.length
  373. it.quantity = intoingQty
  374. }
  375. if (it.type == 'number') {
  376. it.content = intoingAmt
  377. }
  378. })
  379. this.setData({
  380. tableData: temp,
  381. footerInfo,
  382. footerAmount,
  383. contentnFootList,
  384. })
  385. },
  386. /**
  387. * @desc : 三个小点点击回调
  388. * @date : 2024年3月8日
  389. * @author : 姜永辉
  390. */
  391. toPoint(e) {
  392. let item = e.detail.item
  393. if (item.flgValid && item.intoType != Constants.intoType.first) {
  394. // 待入库
  395. if (this.data.active == 0 && !this.data.flgHandleSetting) {
  396. this.setData({
  397. buttonList: [
  398. {
  399. name: 'editOrder',
  400. title: mixins.$t('edit'),
  401. },
  402. {
  403. name: 'invaidOrder',
  404. title: mixins.$t('invaidOrder'),
  405. }, {
  406. name: 'ticketPirnt',
  407. title: mixins.$t('ticketPirnt'),
  408. }
  409. ],
  410. })
  411. } else {
  412. // 参数自动出入库:作废显示没有撤回
  413. if (item.flgHandleSetting == true || item.flgHandleSetting == "true") {
  414. this.setData({
  415. buttonList: [
  416. {
  417. name: 'editOrder',
  418. title: mixins.$t('edit'),
  419. },
  420. {
  421. name: 'invaidOrder',
  422. title: mixins.$t('invaidOrder'),
  423. }, {
  424. name: 'ticketPirnt',
  425. title: mixins.$t('ticketPirnt'),
  426. }
  427. ],
  428. })
  429. } else {
  430. // 参数手动出入库:撤回显示没有作废
  431. this.setData({
  432. buttonList: [
  433. {
  434. name: 'editOrder',
  435. title: mixins.$t('edit'),
  436. },
  437. {
  438. name: 'ticketPirnt',
  439. title: mixins.$t('ticketPirnt'),
  440. },
  441. {
  442. name: 'returnCancel',
  443. title: mixins.$t('returnCancel'),
  444. },
  445. {
  446. name: 'invaidOrder',
  447. title: mixins.$t('invaidOrder'),
  448. },
  449. ],
  450. })
  451. }
  452. }
  453. } else {
  454. this.setData({
  455. // 弹出按钮
  456. buttonList: [{
  457. name: 'ticketPirnt',
  458. title: mixins.$t('ticketPirnt') //打印票据
  459. }],
  460. })
  461. }
  462. },
  463. /**
  464. * @desc : (撤销)
  465. * @date : 2024/2/1 15:49
  466. * @author : 姜永辉
  467. */
  468. returnCancel(e) {
  469. let item = e
  470. let id = item.intoId
  471. // 采购入库
  472. if (item.intoType == Constants.intoType.pur) {
  473. this.excute(this.data.service, this.data.service.inBoundCancel, { intoId: id }).then(res => {
  474. if (res.data.code == Constants.SUCESS_CODE) {
  475. // 重新查询
  476. this.searchData()
  477. }
  478. })
  479. }
  480. // 其他入库
  481. else if (item.intoType == Constants.intoType.other) {
  482. this.excute(this.data.inboundOtherService, this.data.inboundOtherService.inBoundCancel, { intoId: id }).then(res => {
  483. if (res.data.code == Constants.SUCESS_CODE) {
  484. // 重新查询
  485. this.searchData()
  486. }
  487. })
  488. // 销售退货
  489. } else {
  490. this.excute(this.data.outboundSaleReturnService, this.data.outboundSaleReturnService.cancel, { outId: id }).then(res => {
  491. if (res.data.code == Constants.SUCESS_CODE) {
  492. // 重新查询
  493. this.searchData()
  494. }
  495. })
  496. }
  497. },
  498. /**
  499. * @desc : (编辑)
  500. * @date : 2024/2/1 15:49
  501. * @author : 姜永辉
  502. */
  503. editOrder(e) {
  504. let item = e
  505. let id = item.intoId
  506. // 采购入库
  507. if (item.intoType == Constants.intoType.pur) {
  508. wx.navigateTo({
  509. url: this.data.route.add.url,
  510. events: {
  511. // 回调后,在这里给页面赋值
  512. bandData: function (e) { }
  513. },
  514. success: function (res) {
  515. res.eventChannel.emit('params', {
  516. id: id,
  517. item: item,
  518. formMode: Constants.formMode.edit
  519. })
  520. }
  521. })
  522. }
  523. // 其他入库
  524. else if (item.intoType == Constants.intoType.other) {
  525. wx.navigateTo({
  526. url: this.data.route.addOther.url,
  527. events: {
  528. // 回调后,在这里给页面赋值
  529. bandData: function (e) { }
  530. },
  531. success: function (res) {
  532. res.eventChannel.emit('params', {
  533. id: id,
  534. item: item,
  535. formMode: Constants.formMode.edit
  536. })
  537. }
  538. })
  539. // 销售退货
  540. } else {
  541. wx.navigateTo({
  542. url: this.data.route.addReturn.url,
  543. events: {
  544. // 回调后,在这里给页面赋值
  545. bandData: function (e) { }
  546. },
  547. success: function (res) {
  548. res.eventChannel.emit('params', {
  549. id: id,
  550. item: item,
  551. formType: Constants.formMode.detail,
  552. formMode: Constants.formMode.detail,
  553. })
  554. }
  555. })
  556. }
  557. },
  558. /**
  559. * @desc : 作废
  560. * @date : 2024/2/1 15:49
  561. * @author : 姜永辉
  562. */
  563. invaidOrder(e) {
  564. let item = e
  565. let id = item.intoId
  566. // 采购入库
  567. if (item.intoType == Constants.intoType.pur) {
  568. this.excute(this.data.service, this.data.service.inboundRepeal + id, null).then(res => {
  569. if (res.data.code == Constants.SUCESS_CODE) {
  570. // 重新查询
  571. this.searchData()
  572. }
  573. })
  574. }
  575. // 其他入库
  576. else if (item.intoType == Constants.intoType.other) {
  577. this.excute(this.data.inboundOtherService, this.data.inboundOtherService.inboundRepeal + id, null).then(res => {
  578. if (res.data.code == Constants.SUCESS_CODE) {
  579. // 重新查询
  580. this.searchData()
  581. }
  582. })
  583. // 销售退货
  584. } else {
  585. this.excute(this.data.outboundSaleReturnService, this.data.outboundSaleReturnService.outboundRepeal + id, null).then(res => {
  586. if (res.data.code == Constants.SUCESS_CODE) {
  587. // 重新查询
  588. this.searchData()
  589. }
  590. })
  591. }
  592. },
  593. /**
  594. * @desc : 加载数据
  595. * @date : 2024/2/1 15:49
  596. * @author : 姜永辉
  597. */
  598. loadInit() {
  599. let pullMenuList = []
  600. if (app.globalData.company.gradeCode == Constants.gradeCode.PRO) {
  601. //专业
  602. pullMenuList = [
  603. {
  604. code: 'intoType',
  605. pullType: 'mSelect',
  606. typeName: 'intoType'
  607. },
  608. {
  609. code: 'cusName',
  610. },
  611. {
  612. code: 'cusPhone',
  613. },
  614. {
  615. code: 'addressFull',
  616. },
  617. {
  618. code: 'supName',
  619. },
  620. {
  621. code: 'staffName',
  622. },
  623. {
  624. code: 'orgName',
  625. },
  626. {
  627. code: 'flgValid',
  628. title: mixins.$t('flgValid'),
  629. dataType: 'checkbox'
  630. },
  631. ]
  632. } else {
  633. pullMenuList = [
  634. {
  635. code: 'intoType',
  636. pullType: 'mSelect',
  637. typeName: 'intoTypeSt'
  638. },
  639. {
  640. code: 'cusName',
  641. },
  642. {
  643. code: 'cusPhone',
  644. },
  645. {
  646. code: 'addressFull',
  647. },
  648. {
  649. code: 'supName',
  650. },
  651. {
  652. code: 'staffName',
  653. },
  654. {
  655. code: 'orgName',
  656. },
  657. {
  658. code: 'flgValid',
  659. title: mixins.$t('flgValid'),
  660. dataType: 'checkbox'
  661. },
  662. ]
  663. }
  664. this.setData({
  665. pullMenuList,
  666. })
  667. },
  668. })