outbound-processing.js 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574
  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. '销售出库': [{
  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. '采退出库': [{
  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. '其他出库': [{
  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. wx.navigateTo({
  211. url: this.data.route.addOther.url,
  212. success: function (res) {
  213. // 通过eventChannel向被打开页面传送数据 TODO 测试例子url是写死的,实际中,需要从route中读取
  214. res.eventChannel.emit('params', {})
  215. }
  216. })
  217. },
  218. /**
  219. * @desc : 跳转明细
  220. * @author : 周兴
  221. * @date : 2024/1/22
  222. */
  223. toDetail(e) {
  224. if (e) {
  225. let item = e.detail.item;
  226. if (e.detail.item) {
  227. let button = {
  228. formMode: Constants.formMode.edit
  229. }
  230. e.detail.item.button = button
  231. }
  232. // 如果name不传递,默认为edit
  233. if (item.outType == Constants.outType.sale || item.outType == Constants.outType.other) {
  234. e.detail.name = 'edit'
  235. } else {
  236. e.detail.name = 'editReturn'
  237. }
  238. }
  239. this.open(e);
  240. },
  241. /**
  242. * @desc : 设置查询参数
  243. * @date : 2024年3月8日
  244. * @author : 姜永辉
  245. */
  246. setSearchParams(params) {
  247. console.log(params);
  248. if (this.data.active == 0 && !this.data.flgHandleSetting) {
  249. //待出库的查询参数
  250. params.intoStatus = Constants.intoStatus.inBounding
  251. params.outStatus = Constants.outStatus.outBounding
  252. }
  253. else {
  254. //已出库的查询参数
  255. params.intoStatus = Constants.intoStatus.inBounded
  256. params.outStatus = Constants.outStatus.outBounded
  257. }
  258. params.outTypes = params.outTypeList
  259. //采购订单明细 跳转到出库办理
  260. let isfirst = this.data.isfirst
  261. let purNo = this.data.item ? this.data.item.purNo : null
  262. if (isfirst && purNo) { //第一次进入 取传过来的
  263. let searchForm = this.data.searchForm ? JSON.parse(this.data.searchForm) : {}
  264. searchForm.searchText = purNo || ''
  265. this.setData({
  266. searchForm: JSON.stringify(searchForm),
  267. searchText: purNo || '',
  268. })
  269. params.searchForm = JSON.stringify(searchForm)
  270. params.searchText = purNo
  271. }
  272. this.setData({
  273. isfirst: false
  274. })
  275. return params;
  276. },
  277. /**
  278. * @desc : 查询 出库单
  279. * @date : 2024年3月8日
  280. * @author : 姜永辉
  281. */
  282. getData(params) {
  283. return this.excute(this.data.outboundOtherService, this.data.outboundOtherService.selectOutbound, params);
  284. },
  285. /**
  286. * @desc : 处理接口返回数据
  287. * @date : 2024年3月8日
  288. * @author : 姜永辉
  289. */
  290. handleSearchData(tableData) {
  291. let temp = tableData
  292. temp.forEach(it => {
  293. // 入库对象 - 出库类型-销退回库
  294. if (it.outType == Constants.intoType.saleReturn) {
  295. it.cusName = it.supplierName
  296. }
  297. })
  298. let contentnFootList = this.data.contentnFootList
  299. let footerAmount = this.data.footerAmount
  300. let footerInfo = this.data.footerInfo
  301. let outingQty = Number(0)
  302. let outingAmt = Number(0)
  303. if (this.data.active == 0 && !this.data.flgHandleSetting) {
  304. // 列表区(脚部金额)
  305. footerAmount.name = 'outingAmt'
  306. // 列表区(脚部信息)
  307. footerInfo[0].name = 'outingQty'
  308. temp.forEach(it => {
  309. it.makeTime = it.makeTime.substring(0, 10)
  310. outingQty += Math.abs(Number(it.outingQty))
  311. outingAmt += Math.abs(Number(it.outingAmt))
  312. // 出库对象
  313. if (it.outType == Constants.outType.other) {
  314. it.outObject = it.cusName != null ? it.cusName : it.supplierName
  315. }
  316. })
  317. } else {
  318. // 列表区(脚部金额)
  319. footerAmount.name = 'outAmt'
  320. // 列表区(脚部信息)
  321. footerInfo[0].name = 'outQty'
  322. temp.forEach(it => {
  323. it.makeTime = it.makeTime.substring(0, 10)
  324. outingQty += Math.abs(Number(it.outQty))
  325. outingAmt += Math.abs(Number(it.outAmt))
  326. // 出库对象
  327. if (it.outType == Constants.outType.other) {
  328. it.outObject = it.cusName != null ? it.cusName : it.supplierName
  329. }
  330. })
  331. }
  332. contentnFootList.forEach(it => {
  333. if (it.type == 'count') {
  334. it.bill = tableData.length
  335. it.quantity = outingQty
  336. }
  337. if (it.type == 'number') {
  338. it.content = outingAmt
  339. }
  340. })
  341. this.setData({
  342. tableData: temp,
  343. footerInfo,
  344. footerAmount,
  345. contentnFootList,
  346. })
  347. },
  348. /**
  349. * @desc : 三个小点点击回调
  350. * @date : 2024年3月8日
  351. * @author : 姜永辉
  352. */
  353. toPoint(e) {
  354. console.log("toPoint", e);
  355. let item = e.detail.item
  356. if (item.flgValid) {
  357. // 待入库
  358. if (this.data.active == 0 && !this.data.flgHandleSetting) {
  359. this.setData({
  360. buttonList: [
  361. {
  362. name: 'editOrder',
  363. title: mixins.$t('edit'),
  364. },
  365. {
  366. name: 'invaidOrder',
  367. title: mixins.$t('invaidOrder'),
  368. }, {
  369. name: 'ticketPirnt',
  370. title: mixins.$t('ticketPirnt'),
  371. }
  372. ],
  373. })
  374. } else {
  375. // 参数自动出入库:作废显示没有撤回
  376. if (item.flgHandleSetting == true || item.flgHandleSetting == "true") {
  377. this.setData({
  378. buttonList: [
  379. {
  380. name: 'editOrder',
  381. title: mixins.$t('edit'),
  382. },
  383. {
  384. name: 'invaidOrder',
  385. title: mixins.$t('invaidOrder'),
  386. }, {
  387. name: 'ticketPirnt',
  388. title: mixins.$t('ticketPirnt'),
  389. }
  390. ],
  391. })
  392. } else {
  393. // 参数手动出入库:撤回显示没有作废
  394. this.setData({
  395. buttonList: [
  396. {
  397. name: 'editOrder',
  398. title: mixins.$t('edit'),
  399. },
  400. {
  401. name: 'ticketPirnt',
  402. title: mixins.$t('ticketPirnt'),
  403. },
  404. {
  405. name: 'returnCancel',
  406. title: mixins.$t('returnCancel'),
  407. }
  408. ],
  409. })
  410. }
  411. }
  412. } else {
  413. this.setData({
  414. // 弹出按钮
  415. buttonList: [{
  416. name: 'ticketPirnt',
  417. title: mixins.$t('ticketPirnt') //打印票据
  418. }],
  419. })
  420. }
  421. },
  422. /**
  423. * @desc : (撤销)
  424. * @date : 2024/2/1 15:49
  425. * @author : 姜永辉
  426. */
  427. returnCancel(e) {
  428. let item = e
  429. let id = item.outId
  430. // 销售出库
  431. if (item.outType == Constants.outType.sale) {
  432. this.excute(this.data.outboundProcessingService, this.data.outboundProcessingService.outBoundCancel, item).then(res => {
  433. if (res.data.code == Constants.SUCESS_CODE) {
  434. // 重新查询
  435. this.searchData()
  436. }
  437. })
  438. }
  439. // 其他出库
  440. else if (item.outType == Constants.outType.other) {
  441. this.excute(this.data.outboundOtherService, this.data.outboundOtherService.outBoundCancel, item).then(res => {
  442. if (res.data.code == Constants.SUCESS_CODE) {
  443. // 重新查询
  444. this.searchData()
  445. }
  446. })
  447. // 采购退货
  448. } else {
  449. this.excute(this.data.inboundReturnService, this.data.inboundReturnService.inboundReturnCancel, {
  450. intoId: id
  451. }).then(res => {
  452. if (res.data.code == Constants.SUCESS_CODE) {
  453. // 重新查询
  454. this.searchData()
  455. }
  456. })
  457. }
  458. },
  459. /**
  460. * @desc : (编辑)
  461. * @date : 2024/2/1 15:49
  462. * @author : 姜永辉
  463. */
  464. editOrder(e) {
  465. let item = e
  466. let id = item.outId
  467. // 销售出库
  468. if (item.outType == Constants.outType.sale) {
  469. wx.navigateTo({
  470. url: this.data.route.add.url,
  471. events: {
  472. // 回调后,在这里给页面赋值
  473. bandData: function (e) { }
  474. },
  475. success: function (res) {
  476. res.eventChannel.emit('params', {
  477. id: id,
  478. formMode: Constants.formMode.edit
  479. })
  480. }
  481. })
  482. }
  483. // 其他出库
  484. else if (item.outType == Constants.outType.other) {
  485. wx.navigateTo({
  486. url: this.data.route.addOther.url,
  487. events: {
  488. // 回调后,在这里给页面赋值
  489. bandData: function (e) { }
  490. },
  491. success: function (res) {
  492. res.eventChannel.emit('params', {
  493. id: id,
  494. formMode: Constants.formMode.edit
  495. })
  496. }
  497. })
  498. // 销售退货
  499. } else {
  500. wx.navigateTo({
  501. url: this.data.route.addReturn.url,
  502. events: {
  503. // 回调后,在这里给页面赋值
  504. bandData: function (e) { }
  505. },
  506. success: function (res) {
  507. res.eventChannel.emit('params', {
  508. id: id,
  509. formMode: Constants.formMode.edit
  510. })
  511. }
  512. })
  513. }
  514. },
  515. /**
  516. * @desc : 作废
  517. * @date : 2024/2/1 15:49
  518. * @author : 姜永辉
  519. */
  520. invaidOrder(e) {
  521. let item = e
  522. let id = item.outId
  523. // 销售出库
  524. if (item.outType == Constants.outType.sale) {
  525. this.excute(this.data.outboundProcessingService, this.data.outboundProcessingService.outboundRepeal + id, null).then(res => {
  526. if (res.data.code == Constants.SUCESS_CODE) {
  527. // 重新查询
  528. this.searchData()
  529. }
  530. })
  531. }
  532. // 其他出库
  533. else if (item.outType == Constants.outType.other) {
  534. this.excute(this.data.outboundOtherService, this.data.outboundOtherService.outboundRepeal + id, null).then(res => {
  535. if (res.data.code == Constants.SUCESS_CODE) {
  536. // 重新查询
  537. this.searchData()
  538. }
  539. })
  540. // 采购退货
  541. } else {
  542. this.excute(this.data.inboundReturnService, this.data.inboundReturnService.cancel, {
  543. intoId: id
  544. }).then(res => {
  545. if (res.data.code == Constants.SUCESS_CODE) {
  546. // 重新查询
  547. this.searchData()
  548. }
  549. })
  550. }
  551. },
  552. })