outbound-processing.js 12 KB

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