warehousing-processing.js 12 KB

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