outbound-processing.js 15 KB

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