outbound-processing.js 10.0 KB

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