outbound-processing.js 13 KB

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