warehousing-processing.js 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546
  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: 'intoDate',
  138. title: mixins.$t('intoDate')
  139. }],
  140. },
  141. // 弹出按钮
  142. buttonList: [
  143. {
  144. name: 'editOrder',
  145. title: mixins.$t('edit'),
  146. },
  147. {
  148. name: 'invaidOrder',
  149. title: mixins.$t('invaidOrder'),
  150. }, {
  151. name: 'ticketPirnt',
  152. title: mixins.$t('ticketPirnt'),
  153. }
  154. ,
  155. ],
  156. // 底部保存按钮
  157. buttonFootList: [{
  158. name: 'addOther',
  159. title: mixins.$t('otherInWh'),
  160. }],
  161. // 底部左侧合计金额及数量
  162. contentnFootList: [
  163. {
  164. title: mixins.$t('totalAmount'),
  165. code: 'intoingAmt',
  166. content: 10,
  167. type: 'number'
  168. }, {
  169. type: 'count',
  170. code: 'count',
  171. bill: 1,
  172. quantity: 1
  173. }
  174. ],
  175. // 底部的按钮数据
  176. btnFormData: null,
  177. // 路由
  178. routeObjName: 'inboundProcessing',
  179. inboundOtherService: app.globalData['inboundOtherService'],
  180. outboundSaleReturnService: app.globalData['outboundSaleReturnService'],
  181. // active
  182. active: 0,
  183. // 主键Id
  184. primaryKey: 'intoId',
  185. },
  186. /**
  187. * @desc : 切换 待入库 已出库
  188. * @date : 2024年3月8日
  189. * @author : 姜永辉
  190. */
  191. onChangeTabs(e) {
  192. let index = e.detail.detail.index
  193. this.setData({
  194. active: index,
  195. })
  196. this.searchData()
  197. },
  198. /**
  199. * @desc : addOther
  200. * @date : 2024年3月8日
  201. * @author : 姜永辉
  202. */
  203. addOther() {
  204. wx.navigateTo({
  205. url: this.data.route.addOther.url,
  206. success: function (res) {
  207. // 通过eventChannel向被打开页面传送数据 TODO 测试例子url是写死的,实际中,需要从route中读取
  208. res.eventChannel.emit('params', {})
  209. }
  210. })
  211. },
  212. /**
  213. * @desc : 跳转明细
  214. * @author : 周兴
  215. * @date : 2024/1/22
  216. */
  217. toDetail(e) {
  218. if (e) {
  219. let item = e.detail.item;
  220. if (e.detail.item) {
  221. let button = {
  222. formMode: Constants.formMode.edit
  223. }
  224. e.detail.item.button = button
  225. }
  226. // 如果name不传递,默认为edit
  227. if (item.intoType == Constants.intoType.pur || item.intoType == Constants.intoType.other) {
  228. e.detail.name = 'edit'
  229. } else {
  230. e.detail.name = 'editReturn'
  231. }
  232. }
  233. this.open(e);
  234. },
  235. /**
  236. * @desc : 设置查询参数
  237. * @date : 2024年3月8日
  238. * @author : 姜永辉
  239. */
  240. setSearchParams(params) {
  241. if (this.data.active == 0) {
  242. //待入库的查询参数
  243. params.intoStatus = Constants.intoStatus.inBounding
  244. params.outStatus = Constants.outStatus.outBounding
  245. }
  246. if (this.data.active == 1) {
  247. //已入库的查询参数
  248. params.intoStatus = Constants.intoStatus.inBounded
  249. params.outStatus = Constants.outStatus.outBounded
  250. }
  251. params.intoTypes = params.intoTypeList
  252. return params;
  253. },
  254. /**
  255. * @desc : 查询 入库单
  256. * @date : 2024年3月8日
  257. * @author : 姜永辉
  258. */
  259. getData(params) {
  260. return this.excute(this.data.inboundOtherService, this.data.inboundOtherService.selectInbound, params);
  261. },
  262. /**
  263. * @desc : 处理接口返回数据
  264. * @date : 2024年3月8日
  265. * @author : 姜永辉
  266. */
  267. handleSearchData(tableData) {
  268. let temp = tableData
  269. let contentnFootList = this.data.contentnFootList
  270. let footerAmount = this.data.footerAmount
  271. let footerInfo = this.data.footerInfo
  272. let intoingQty = Number(0)
  273. let intoingAmt = Number(0)
  274. if (this.data.active == 0) {
  275. // 列表区(脚部金额)
  276. footerAmount.name = 'intoingAmt'
  277. // 列表区(脚部信息)
  278. footerInfo[0].name = 'intoingQty'
  279. temp.forEach(it => {
  280. it.makeTime = it.makeTime.substring(0, 10)
  281. intoingQty += Math.abs(Number(it.intoingQty))
  282. intoingAmt += Math.abs(Number(it.intoingAmt))
  283. // 入库对象
  284. if (it.intoType == Constants.intoType.other) {
  285. it.intoObject = it.cusName != null ? it.cusName : it.supplierName
  286. }
  287. })
  288. } else {
  289. // 列表区(脚部金额)
  290. footerAmount.name = 'intoAmt'
  291. // 列表区(脚部信息)
  292. footerInfo[0].name = 'intoQty'
  293. temp.forEach(it => {
  294. it.makeTime = it.makeTime.substring(0, 10)
  295. intoingQty += Math.abs(Number(it.intoQty))
  296. intoingAmt += Math.abs(Number(it.intoAmt))
  297. // 入库对象
  298. if (it.intoType == Constants.intoType.other) {
  299. it.intoObject = it.cusName != null ? it.cusName : it.supplierName
  300. }
  301. })
  302. }
  303. contentnFootList.forEach(it => {
  304. if (it.type == 'count') {
  305. it.bill = tableData.length
  306. it.quantity = intoingQty
  307. }
  308. if (it.type == 'number') {
  309. it.content = intoingAmt
  310. }
  311. })
  312. this.setData({
  313. tableData: temp,
  314. footerInfo,
  315. footerAmount,
  316. contentnFootList,
  317. })
  318. },
  319. /**
  320. * @desc : 三个小点点击回调
  321. * @date : 2024年3月8日
  322. * @author : 姜永辉
  323. */
  324. toPoint(e) {
  325. console.log("toPoint", e);
  326. let item = e.detail.item
  327. if (item.flgValid) {
  328. // 待入库
  329. if (this.data.active == 0) {
  330. this.setData({
  331. buttonList: [
  332. {
  333. name: 'editOrder',
  334. title: mixins.$t('edit'),
  335. },
  336. {
  337. name: 'invaidOrder',
  338. title: mixins.$t('invaidOrder'),
  339. }, {
  340. name: 'ticketPirnt',
  341. title: mixins.$t('ticketPirnt'),
  342. }
  343. ],
  344. })
  345. } else {
  346. // 参数自动出入库:作废显示没有撤回
  347. if (item.flgHandleSetting == "true") {
  348. this.setData({
  349. buttonList: [
  350. {
  351. name: 'editOrder',
  352. title: mixins.$t('edit'),
  353. },
  354. {
  355. name: 'invaidOrder',
  356. title: mixins.$t('invaidOrder'),
  357. }, {
  358. name: 'ticketPirnt',
  359. title: mixins.$t('ticketPirnt'),
  360. }
  361. ],
  362. })
  363. } else {
  364. // 参数手动出入库:撤回显示没有作废
  365. this.setData({
  366. buttonList: [
  367. {
  368. name: 'editOrder',
  369. title: mixins.$t('edit'),
  370. },
  371. {
  372. name: 'ticketPirnt',
  373. title: mixins.$t('ticketPirnt'),
  374. },
  375. {
  376. name: 'returnCancel',
  377. title: mixins.$t('returnCancel'),
  378. }
  379. ],
  380. })
  381. }
  382. }
  383. } else {
  384. this.setData({
  385. // 弹出按钮
  386. buttonList: [{
  387. name: 'ticketPirnt',
  388. title: mixins.$t('ticketPirnt') //打印票据
  389. }],
  390. })
  391. }
  392. },
  393. /**
  394. * @desc : (撤销)
  395. * @date : 2024/2/1 15:49
  396. * @author : 姜永辉
  397. */
  398. returnCancel(e) {
  399. let item = e
  400. let id = item.intoId
  401. // 采购入库
  402. if (item.intoType == Constants.intoType.pur) {
  403. this.excute(this.data.service, this.data.service.inBoundCancel, item).then(res => {
  404. if (res.data.code == Constants.SUCESS_CODE) {
  405. // 重新查询
  406. this.searchData()
  407. }
  408. })
  409. }
  410. // 其他入库
  411. else if (item.intoType == Constants.intoType.other) {
  412. this.excute(this.data.inboundOtherService, this.data.inboundOtherService.inBoundCancel, item).then(res => {
  413. if (res.data.code == Constants.SUCESS_CODE) {
  414. // 重新查询
  415. this.searchData()
  416. }
  417. })
  418. // 销售退货
  419. } else {
  420. this.excute(this.data.outboundSaleReturnService, this.data.outboundSaleReturnService.cancel, { outId: id }).then(res => {
  421. if (res.data.code == Constants.SUCESS_CODE) {
  422. // 重新查询
  423. this.searchData()
  424. }
  425. })
  426. }
  427. },
  428. /**
  429. * @desc : (编辑)
  430. * @date : 2024/2/1 15:49
  431. * @author : 姜永辉
  432. */
  433. editOrder(e) {
  434. let item = e
  435. let id = item.intoId
  436. // 采购入库
  437. if (item.intoType == Constants.intoType.pur) {
  438. wx.navigateTo({
  439. url: this.data.route.add.url,
  440. events: {
  441. // 回调后,在这里给页面赋值
  442. bandData: function (e) { }
  443. },
  444. success: function (res) {
  445. res.eventChannel.emit('params', {
  446. id: id,
  447. item: item,
  448. formMode: Constants.formMode.edit
  449. })
  450. }
  451. })
  452. }
  453. // 其他入库
  454. else if (item.intoType == Constants.intoType.other) {
  455. wx.navigateTo({
  456. url: this.data.route.addOther.url,
  457. events: {
  458. // 回调后,在这里给页面赋值
  459. bandData: function (e) { }
  460. },
  461. success: function (res) {
  462. res.eventChannel.emit('params', {
  463. id: id,
  464. item: item,
  465. formMode: Constants.formMode.edit
  466. })
  467. }
  468. })
  469. // 销售退货
  470. } else {
  471. wx.navigateTo({
  472. url: this.data.route.addReturn.url,
  473. events: {
  474. // 回调后,在这里给页面赋值
  475. bandData: function (e) { }
  476. },
  477. success: function (res) {
  478. res.eventChannel.emit('params', {
  479. id: id,
  480. item: item,
  481. formMode: Constants.formMode.other,
  482. formType: Constants.formType.edit,
  483. })
  484. }
  485. })
  486. }
  487. },
  488. /**
  489. * @desc : 作废
  490. * @date : 2024/2/1 15:49
  491. * @author : 姜永辉
  492. */
  493. invaidOrder(e) {
  494. let item = e
  495. let id = item.intoId
  496. // 采购入库
  497. if (item.intoType == Constants.intoType.pur) {
  498. this.excute(this.data.service, this.data.service.inboundRepeal + id, null).then(res => {
  499. if (res.data.code == Constants.SUCESS_CODE) {
  500. // 重新查询
  501. this.searchData()
  502. }
  503. })
  504. }
  505. // 其他入库
  506. else if (item.intoType == Constants.intoType.other) {
  507. this.excute(this.data.inboundOtherService, this.data.inboundOtherService.inboundRepeal + id, null).then(res => {
  508. if (res.data.code == Constants.SUCESS_CODE) {
  509. // 重新查询
  510. this.searchData()
  511. }
  512. })
  513. // 销售退货
  514. } else {
  515. this.excute(this.data.outboundSaleReturnService, this.data.outboundSaleReturnService.outboundRepeal + id, null).then(res => {
  516. if (res.data.code == Constants.SUCESS_CODE) {
  517. // 重新查询
  518. this.searchData()
  519. }
  520. })
  521. }
  522. },
  523. })