warehousing-processing.js 10 KB

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