outbound-processing.js 14 KB

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