warehousing-processing.js 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482
  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. // 列表区(脚部金额)
  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: 'addressFull',
  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. outboundSaleReturnService: app.globalData['outboundSaleReturnService'],
  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. let buttonList = this.data.buttonList
  194. buttonList = buttonList.filter(item => item.name !== 'returnCancel')
  195. console.log();
  196. if (index == 1 && buttonList.length == 3) {
  197. buttonList.push(
  198. {
  199. name: 'returnCancel',
  200. title: mixins.$t('returnCancel'),
  201. }
  202. )
  203. }
  204. this.setData({
  205. buttonList,
  206. })
  207. this.searchData()
  208. },
  209. /**
  210. * @desc : addOther
  211. * @date : 2024年3月8日
  212. * @author : 姜永辉
  213. */
  214. addOther() {
  215. wx.navigateTo({
  216. url: this.data.route.addOther.url,
  217. success: function (res) {
  218. // 通过eventChannel向被打开页面传送数据 TODO 测试例子url是写死的,实际中,需要从route中读取
  219. res.eventChannel.emit('params', {})
  220. }
  221. })
  222. },
  223. /**
  224. * @desc : 跳转明细
  225. * @author : 周兴
  226. * @date : 2024/1/22
  227. */
  228. toDetail(e) {
  229. console.log(e, "toDetail");
  230. if (e) {
  231. let item = null;
  232. if (e.currentTarget.dataset.item) {
  233. item = e.currentTarget.dataset.item
  234. }
  235. if (!e.detail) {
  236. e.detail = {
  237. }
  238. }
  239. if (item) {
  240. e.detail.item = item;
  241. }
  242. if (e.detail.item) {
  243. let button = {
  244. formMode: Constants.formMode.edit
  245. }
  246. e.detail.item.button = button
  247. }
  248. // 如果name不传递,默认为edit
  249. e.detail.name = 'edit'
  250. }
  251. this.open(e);
  252. },
  253. /**
  254. * @desc : 设置查询参数
  255. * @date : 2024年3月8日
  256. * @author : 姜永辉
  257. */
  258. setSearchParams(params) {
  259. if (this.data.active == 0) {
  260. //待入库的查询参数
  261. params.intoStatus = Constants.intoStatus.inBounding
  262. params.outStatus = Constants.outStatus.outBounding
  263. }
  264. if (this.data.active == 1) {
  265. //已入库的查询参数
  266. params.intoStatus = Constants.intoStatus.inBounded
  267. params.outStatus = Constants.outStatus.outBounded
  268. }
  269. params.intoTypes = params.intoTypeList
  270. return params;
  271. },
  272. /**
  273. * @desc : 查询 入库单
  274. * @date : 2024年3月8日
  275. * @author : 姜永辉
  276. */
  277. getData(params) {
  278. return this.excute(this.data.inboundOtherService, this.data.inboundOtherService.selectInbound, params);
  279. },
  280. /**
  281. * @desc : 处理接口返回数据
  282. * @date : 2024年3月8日
  283. * @author : 姜永辉
  284. */
  285. handleSearchData(tableData) {
  286. let temp = tableData
  287. let contentnFootList = this.data.contentnFootList
  288. let footerAmount = this.data.footerAmount
  289. let footerInfo = this.data.footerInfo
  290. let intoingQty = Number(0)
  291. let intoingAmt = Number(0)
  292. if (this.data.active == 0) {
  293. // 列表区(脚部金额)
  294. footerAmount.name = 'intoingAmt'
  295. // 列表区(脚部信息)
  296. footerInfo[0].name = 'intoingQty'
  297. temp.forEach(it => {
  298. it.makeTime = it.makeTime.substring(0, 10)
  299. intoingQty += Math.abs(Number(it.intoingQty))
  300. intoingAmt += Math.abs(Number(it.intoingAmt))
  301. // 入库对象
  302. if (it.intoType == Constants.intoType.other) {
  303. it.intoObject = it.cusName != null ? it.cusName : it.supplierName
  304. }
  305. })
  306. } else {
  307. // 列表区(脚部金额)
  308. footerAmount.name = 'intoAmt'
  309. // 列表区(脚部信息)
  310. footerInfo[0].name = 'intoQty'
  311. temp.forEach(it => {
  312. it.makeTime = it.makeTime.substring(0, 10)
  313. intoingQty += Math.abs(Number(it.intoQty))
  314. intoingAmt += Math.abs(Number(it.intoAmt))
  315. // 入库对象
  316. if (it.intoType == Constants.intoType.other) {
  317. it.intoObject = it.cusName != null ? it.cusName : it.supplierName
  318. }
  319. })
  320. }
  321. contentnFootList.forEach(it => {
  322. if (it.type == 'count') {
  323. it.bill = tableData.length
  324. it.quantity = intoingQty
  325. }
  326. if (it.type == 'number') {
  327. it.content = intoingAmt
  328. }
  329. })
  330. this.setData({
  331. tableData: temp,
  332. footerInfo,
  333. footerAmount,
  334. contentnFootList,
  335. })
  336. },
  337. /**
  338. * @desc : (撤销)
  339. * @date : 2024/2/1 15:49
  340. * @author : 姜永辉
  341. */
  342. returnCancel(e) {
  343. let item = e
  344. let id = item.intoId
  345. // 采购入库
  346. if (item.intoType == Constants.intoType.pur) {
  347. this.excute(this.data.service, this.data.service.inBoundCancel, item).then(res => {
  348. if (res.data.code == Constants.SUCESS_CODE) {
  349. // 重新查询
  350. this.searchData()
  351. }
  352. })
  353. }
  354. // 其他入库
  355. else if (item.intoType == Constants.intoType.other) {
  356. this.excute(this.data.inboundOtherService, this.data.inboundOtherService.inBoundCancel, item).then(res => {
  357. if (res.data.code == Constants.SUCESS_CODE) {
  358. // 重新查询
  359. this.searchData()
  360. }
  361. })
  362. // 销售退货
  363. } else {
  364. this.excute(this.data.outboundSaleReturnService, this.data.outboundSaleReturnService.cancel, { outId: id }).then(res => {
  365. if (res.data.code == Constants.SUCESS_CODE) {
  366. // 重新查询
  367. this.searchData()
  368. }
  369. })
  370. }
  371. },
  372. /**
  373. * @desc : (编辑)
  374. * @date : 2024/2/1 15:49
  375. * @author : 姜永辉
  376. */
  377. editOrder(e) {
  378. let item = e
  379. let id = item.intoId
  380. // 采购入库
  381. if (item.intoType == Constants.intoType.pur) {
  382. wx.navigateTo({
  383. url: this.data.route.add.url,
  384. events: {
  385. // 回调后,在这里给页面赋值
  386. bandData: function (e) { }
  387. },
  388. success: function (res) {
  389. res.eventChannel.emit('params', {
  390. id: id,
  391. formMode: Constants.formMode.edit
  392. })
  393. }
  394. })
  395. }
  396. // 其他入库
  397. else if (item.intoType == Constants.intoType.other) {
  398. wx.navigateTo({
  399. url: this.data.route.addOther.url,
  400. events: {
  401. // 回调后,在这里给页面赋值
  402. bandData: function (e) { }
  403. },
  404. success: function (res) {
  405. res.eventChannel.emit('params', {
  406. id: id,
  407. formMode: Constants.formMode.edit
  408. })
  409. }
  410. })
  411. // 销售退货
  412. } else {
  413. wx.navigateTo({
  414. url: this.data.route.addReturn.url,
  415. events: {
  416. // 回调后,在这里给页面赋值
  417. bandData: function (e) { }
  418. },
  419. success: function (res) {
  420. res.eventChannel.emit('params', {
  421. id: id,
  422. formMode: Constants.formMode.other,
  423. formType: Constants.formType.edit,
  424. })
  425. }
  426. })
  427. }
  428. },
  429. /**
  430. * @desc : 作废
  431. * @date : 2024/2/1 15:49
  432. * @author : 姜永辉
  433. */
  434. invaidOrder(e) {
  435. let item = e
  436. let id = item.intoId
  437. // 采购入库
  438. if (item.intoType == Constants.intoType.pur) {
  439. this.excute(this.data.service, this.data.service.inboundRepeal + id, null).then(res => {
  440. if (res.data.code == Constants.SUCESS_CODE) {
  441. // 重新查询
  442. this.searchData()
  443. }
  444. })
  445. }
  446. // 其他入库
  447. else if (item.intoType == Constants.intoType.other) {
  448. this.excute(this.data.inboundOtherService, this.data.inboundOtherService.inboundRepeal + id, null).then(res => {
  449. if (res.data.code == Constants.SUCESS_CODE) {
  450. // 重新查询
  451. this.searchData()
  452. }
  453. })
  454. // 销售退货
  455. } else {
  456. this.excute(this.data.outboundSaleReturnService, this.data.outboundSaleReturnService.outboundRepeal + id, null).then(res => {
  457. if (res.data.code == Constants.SUCESS_CODE) {
  458. // 重新查询
  459. this.searchData()
  460. }
  461. })
  462. }
  463. },
  464. })