ticketGet.js 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416
  1. // pages/ticketGet/ticketGet.js
  2. const utils = require('../../utils/util.js')
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. list: [],
  9. pageNum: 1,
  10. pageSize: 10,
  11. pages: '',
  12. finish: false,
  13. invoiceDateBegin: "",
  14. invoiceDateEnd: "",
  15. invoiceType: ['增值税普通纸质发票', '增值税专用纸质发票', '增值税普通电子发票', '增值税专用电子发票'],
  16. invoiceTypeIndex: 0,
  17. invoiceStatus: '3',
  18. certType: ['身份证', '护照'],
  19. certTypeIndex: '',
  20. getWay: ['自行领取', '快递配送'],
  21. getWayIndex: '',
  22. number: '', //申领数量
  23. certNo: '', //证件号码
  24. claimant: '', //经办人
  25. remark: '', //备注
  26. tabIndex: 0,
  27. userInfo: '',
  28. company: '',
  29. handleStatusType: ['申领中', '成功', '失败'],
  30. handleStatusTypeIndex: '',
  31. handleStatusTypeInfo: '',
  32. distribute: ['待分发', '分发中', '已分发'],
  33. distributeIndex: '0',
  34. distributeList: [],
  35. pageNums: 1,
  36. pageSizes: 10,
  37. pagesTotal: '',
  38. distributeFinish: false,
  39. distributeInvoiceTypeIndex: 0,
  40. distributeInvoiceStatus: '3',
  41. distributeInfo: {}
  42. },
  43. /**
  44. * 生命周期函数--监听页面加载
  45. */
  46. onLoad: function (options) {
  47. this.setData({
  48. invoiceDateBegin: utils.getNowDate(new Date()),
  49. invoiceDateEnd: utils.getNowDate(new Date())
  50. })
  51. this.getUser()
  52. },
  53. //获取企业信息(当前登录用户的默认企业信息)
  54. getUser() {
  55. this.setData({
  56. userInfo: utils.getInfo(),
  57. company:utils.getCurrEntInfo()
  58. })
  59. this.getList()
  60. this.getDistributeList()
  61. // utils.getCompany().then(res => {
  62. // let result = res.data
  63. // this.setData({
  64. // company: result
  65. // })
  66. // this.getList()
  67. // this.getDistributeList()
  68. // })
  69. },
  70. //获取申领记录
  71. getList(type) {
  72. let params = {
  73. entTaxId: this.data.company.entTaxId,
  74. deviceType: this.data.company.defaultDeviceInfo.deviceType,
  75. taxDiscId: this.data.company.defaultDeviceInfo.taxDiscId,
  76. invoiceCategory: this.data.invoiceStatus,
  77. applyDateBegin: this.data.invoiceDateBegin,
  78. applyDateEnd: this.data.invoiceDateEnd,
  79. handleStatus: this.data.handleStatusTypeInfo,
  80. mobile: this.data.userInfo.mobile,
  81. pageNum: this.data.pageNum,
  82. pageSize: this.data.pageSize
  83. }
  84. utils.axios({
  85. method: 'get',
  86. url: '/sys/invoicePurchase/statusInfos',
  87. data: params,
  88. sendBefore() {
  89. wx.showLoading({
  90. title: '加载中...'
  91. })
  92. },
  93. complete() {
  94. wx.hideLoading()
  95. wx.stopPullDownRefresh()
  96. },
  97. success: res => {
  98. this.setData({
  99. list: res.data.statusInfoVOs
  100. })
  101. if (res.data.statusInfoVOs.length > 0) {
  102. this.setData({
  103. pages: 1
  104. })
  105. } else {
  106. this.setData({
  107. pages: 0
  108. })
  109. }
  110. this.setData({
  111. finish: true
  112. })
  113. }
  114. })
  115. },
  116. //获取分发记录
  117. getDistributeList(type) {
  118. let params = {
  119. entTaxId: this.data.company.entTaxId,
  120. deviceType: this.data.company.defaultDeviceInfo.deviceType,
  121. taxDiscId: this.data.company.defaultDeviceInfo.taxDiscId,
  122. invoiceCategory: this.data.distributeInvoiceStatus,
  123. distributeStatus: this.data.distributeIndex,
  124. pageNo: this.data.pageNums,
  125. pageSize: this.data.pageSizes,
  126. mobile: this.data.userInfo.mobile,
  127. }
  128. utils.axios({
  129. method: 'get',
  130. url: '/sys/invoicePurchase/distributeInfos',
  131. data: params,
  132. sendBefore() {
  133. wx.showLoading({
  134. title: '加载中...'
  135. })
  136. },
  137. complete() {
  138. wx.hideLoading()
  139. wx.stopPullDownRefresh()
  140. },
  141. success: res => {
  142. this.setData({
  143. distributeInfo: res.data
  144. })
  145. if (res.data.distributeVOs.length > 0) {
  146. this.setData({
  147. pagesTotal: 1
  148. })
  149. } else {
  150. this.setData({
  151. pagesTotal: 0
  152. })
  153. }
  154. this.setData({
  155. distributeFinish: true
  156. })
  157. }
  158. })
  159. },
  160. //发票分发
  161. setDistribute(type) {
  162. let params = {
  163. entTaxId: this.data.company.entTaxId,
  164. deviceType: this.data.company.defaultDeviceInfo.deviceType,
  165. taxDiscId: this.data.company.defaultDeviceInfo.taxDiscId,
  166. invoiceCateCode: this.data.distributeInfo.distributeVOs[0].invoiceCateCode,
  167. surplusNum: this.data.distributeInfo.distributeVOs[0].surplusNum,
  168. invoiceCode: this.data.distributeInfo.distributeVOs[0].invoiceCode,
  169. invoiceBeginNo: this.data.distributeInfo.distributeVOs[0].invoiceBeginNo,
  170. invoiceEndNo: this.data.distributeInfo.distributeVOs[0].invoiceEndNo,
  171. distributeNum: this.data.distributeInfo.distributeVOs[0].surplusNum,
  172. mobile: this.data.userInfo.mobile,
  173. reqChannel: 5
  174. }
  175. utils.axios({
  176. method: 'post',
  177. url: '/sys/invoicePurchase/distribute',
  178. data: params,
  179. sendBefore() {
  180. wx.showLoading({
  181. title: '加载中...'
  182. })
  183. },
  184. complete() {
  185. wx.hideLoading()
  186. wx.stopPullDownRefresh()
  187. },
  188. success: res => {
  189. if (res.code === 0) {
  190. utils.toast(res.data.statusMemo)
  191. }
  192. }
  193. })
  194. },
  195. toFresh(status) {
  196. if (status) {
  197. this.setData({
  198. pageNums: 1,
  199. pagesTotal: '',
  200. distributeFinish: false
  201. })
  202. } else {
  203. this.setData({
  204. pageNum: 1,
  205. pages: '',
  206. finish: false
  207. })
  208. }
  209. wx.pageScrollTo({
  210. scrollTop: 0,
  211. duration: 300
  212. })
  213. if (status) {
  214. this.getDistributeList('toFresh')
  215. } else {
  216. this.getList('toFresh')
  217. }
  218. },
  219. // 发票申请
  220. applyInvoice(e) {
  221. let index = e.currentTarget.dataset.index
  222. wx.navigateTo({
  223. url: `/pages/ticketGet/applyInvoice?index=${index}`
  224. })
  225. },
  226. //取消
  227. toBack() {
  228. wx.navigateBack()
  229. },
  230. //发票类型
  231. setInvoiceType(e) {
  232. let value = Number(e.detail.value)
  233. let status = ''
  234. if (value === 0) {
  235. status = 3
  236. }
  237. if (value === 1) {
  238. status = 4
  239. }
  240. if (value === 2) {
  241. status = 1
  242. }
  243. if (value === 3) {
  244. status = 2
  245. }
  246. this.setData({
  247. invoiceTypeIndex: value,
  248. invoiceStatus: status
  249. })
  250. this.toFresh()
  251. },
  252. //发票类型
  253. setDistributeInvoiceType(e) {
  254. let value = Number(e.detail.value)
  255. let status = ''
  256. if (value === 0) {
  257. status = 3
  258. }
  259. if (value === 1) {
  260. status = 4
  261. }
  262. if (value === 2) {
  263. status = 1
  264. }
  265. if (value === 3) {
  266. status = 2
  267. }
  268. this.setData({
  269. distributeInvoiceTypeIndex: value,
  270. distributeInvoiceStatus: status
  271. })
  272. this.toFresh(true)
  273. },
  274. //分发状态
  275. setDistribute(e) {
  276. let value = Number(e.detail.value)
  277. this.setData({
  278. distributeIndex: value
  279. })
  280. this.toFresh(true)
  281. },
  282. // 申领状态
  283. setInvoiceHandType(e) {
  284. let value = Number(e.detail.value)
  285. this.setData({
  286. handleStatusTypeIndex: value,
  287. handleStatusTypeInfo: value
  288. })
  289. this.toFresh()
  290. },
  291. //证件类型
  292. setCertType(e) {
  293. let value = Number(e.detail.value)
  294. this.setData({
  295. certTypeIndex: value
  296. })
  297. },
  298. //领取方式
  299. setGetWay(e) {
  300. let value = Number(e.detail.value)
  301. this.setData({
  302. getWayIndex: value
  303. })
  304. },
  305. //以下是表单信息
  306. getnumber(e) {
  307. this.setData({
  308. number: e.detail.value
  309. })
  310. },
  311. getcertNo(e) {
  312. this.setData({
  313. certNo: e.detail.value
  314. })
  315. },
  316. getclaimant(e) {
  317. this.setData({
  318. claimant: e.detail.value
  319. })
  320. },
  321. getremark(e) {
  322. this.setData({
  323. remark: e.detail.value
  324. })
  325. },
  326. clearStart() {
  327. this.setData({
  328. invoiceDateBegin: ''
  329. })
  330. this.toFresh()
  331. },
  332. //设置开始结束时间
  333. setStart(e) {
  334. let invoiceDateBegin = e.detail.value
  335. this.setData({
  336. invoiceDateBegin
  337. })
  338. this.toFresh()
  339. },
  340. //设置结束时间
  341. setEnd(e) {
  342. let invoiceDateEnd = e.detail.value
  343. this.setData({
  344. invoiceDateEnd
  345. })
  346. this.toFresh()
  347. },
  348. //切换
  349. switchTab(e) {
  350. let tabIndex = e.currentTarget.dataset.index
  351. this.setData({
  352. tabIndex
  353. })
  354. },
  355. /**
  356. * 生命周期函数--监听页面初次渲染完成
  357. */
  358. onReady: function () {
  359. },
  360. /**
  361. * 生命周期函数--监听页面显示
  362. */
  363. onShow: function () {
  364. },
  365. /**
  366. * 生命周期函数--监听页面隐藏
  367. */
  368. onHide: function () {
  369. },
  370. /**
  371. * 生命周期函数--监听页面卸载
  372. */
  373. onUnload: function () {
  374. },
  375. /**
  376. * 页面相关事件处理函数--监听用户下拉动作
  377. */
  378. onPullDownRefresh: function () {
  379. this.toFresh()
  380. },
  381. /**
  382. * 页面上拉触底事件的处理函数
  383. */
  384. onReachBottom: function () {
  385. },
  386. /**
  387. * 用户点击右上角分享
  388. */
  389. onShareAppMessage: function () {
  390. return {
  391. title: '诺信云',
  392. path: '/pages/index/index'
  393. }
  394. }
  395. })