outbound-processing.js 13 KB

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