ticketQuery.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482
  1. // pages/ticketQuery/ticketQuery.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. customerName: '', //客户名称
  14. invoiceDateBegin: '', //开票日期范围查询-开始时间yyyy-MM-dd HH:mm:ss
  15. invoiceDateEnd: '', //开票日期范围查询-结束时间yyyy-MM-dd HH:mm:ss
  16. hongchongFlag: '', //红冲状态
  17. status: '', //开票状态
  18. statusList: ['开票中', '正数开具成功', '负数开具成功', '正数已作废', '负数已作废', '空白作废'],
  19. statusIndex: '',
  20. tabIndex: 0,
  21. monthDate: '',
  22. userInfo: '',
  23. company: '',
  24. },
  25. /**
  26. * 生命周期函数--监听页面加载
  27. */
  28. onLoad: function (options) {
  29. this.getUser()
  30. this.getMonthDate()
  31. this.getList()
  32. },
  33. //获取企业信息(当前登录用户的默认企业信息)
  34. getUser() {
  35. this.setData({
  36. userInfo: utils.getInfo(),
  37. company: utils.getCurrEntInfo()
  38. })
  39. },
  40. //列表
  41. getList(type) {
  42. let params = {
  43. mobile: utils.getInfo().mobile,
  44. belongEntTaxId: this.data.company.entTaxId,
  45. reqChannel: 5,
  46. pageNum: this.data.pageNum,
  47. pageSize: this.data.pageSize
  48. }
  49. let customerName = utils.trimAll(this.data.customerName)
  50. if (customerName !== '') {
  51. params.customerName = customerName
  52. }
  53. if (this.data.invoiceDateBegin !== '') {
  54. params.invoiceDateBegin = this.data.invoiceDateBegin + ' 00:00:00'
  55. }
  56. if (this.data.invoiceDateEnd !== '') {
  57. params.invoiceDateEnd = this.data.invoiceDateEnd + ' 23:59:59'
  58. }
  59. if (this.data.status !== '') {
  60. params.status = this.data.status
  61. }
  62. if (this.data.hongchongFlag !== '') {
  63. params.hongchongFlag = this.data.hongchongFlag
  64. }
  65. utils.axios({
  66. method: 'get',
  67. url: '/sys/invoice/findPage',
  68. data: params,
  69. sendBefore() {
  70. wx.showLoading({
  71. title: '加载中...'
  72. })
  73. },
  74. complete() {
  75. wx.hideLoading()
  76. wx.stopPullDownRefresh()
  77. },
  78. success: res => {
  79. let result = res.data
  80. if (type === 'toFresh') {
  81. result.records.forEach((item) => {
  82. let beginDate = this.data.monthDate.start_day + ' 00:00:00'
  83. let endDate = this.data.monthDate.end_day + ' 23:59:59'
  84. if (item.createTime >= beginDate && item.createTime <= endDate) {
  85. item.isInvalid = true
  86. } else {
  87. item.isInvalid = false
  88. }
  89. });
  90. this.setData({
  91. list: result.records,
  92. pages: result.pages
  93. })
  94. } else {
  95. let list = this.data.list
  96. result.records.forEach((item) => {
  97. let beginDate = this.data.monthDate.start_day + ' 00:00:00'
  98. let endDate = this.data.monthDate.end_day + ' 23:59:59'
  99. if (item.createTime >= beginDate && item.createTime <= endDate) {
  100. item.isInvalid = true
  101. } else {
  102. item.isInvalid = false
  103. }
  104. });
  105. list = list.concat(result.records)
  106. console.log(list);
  107. this.setData({
  108. list,
  109. pages: result.pages
  110. })
  111. }
  112. if (result.total <= this.data.pageSize) {
  113. this.setData({
  114. finish: true
  115. })
  116. }
  117. }
  118. })
  119. },
  120. toFresh() {
  121. this.setData({
  122. pageNum: 1,
  123. pages: '',
  124. finish: false
  125. })
  126. wx.pageScrollTo({
  127. scrollTop: 0,
  128. duration: 300
  129. })
  130. this.getList('toFresh')
  131. },
  132. //刷新
  133. refresh(e) {
  134. let index = e.currentTarget.dataset.index
  135. let invoiceReqFlowNo = e.currentTarget.dataset.invoiceno
  136. let params = {
  137. invoiceReqFlowNo,
  138. mobile: utils.getInfo().mobile,
  139. reqChannel: 5
  140. }
  141. utils.axios({
  142. method: 'post',
  143. url: '/sys/invoiceInfo/refreshResult',
  144. data: params,
  145. sendBefore() {
  146. wx.showLoading({
  147. title: '刷新中...',
  148. mask: true
  149. })
  150. },
  151. complete() {
  152. wx.hideLoading()
  153. },
  154. success: res => {
  155. utils.toast('已刷新')
  156. let result = res.data
  157. let str = `list[${index}].status`
  158. this.setData({
  159. [str]: result.status
  160. })
  161. }
  162. })
  163. },
  164. // 获取本月开始结束日期
  165. getMonthDate() {
  166. var monthDate = {};
  167. var now = new Date(); //当前日期
  168. var nowMonth = now.getMonth(); //当前月
  169. var nowYear = now.getFullYear(); //当前年
  170. //本月的开始时间
  171. var monthStartDate = new Date(nowYear, nowMonth, 1);
  172. var yy = monthStartDate.getFullYear() + "-";
  173. var mm =
  174. (monthStartDate.getMonth() + 1 < 10
  175. ? "0" + (monthStartDate.getMonth() + 1)
  176. : monthStartDate.getMonth() + 1) + "-";
  177. var dd =
  178. monthStartDate.getDate() < 10
  179. ? "0" + monthStartDate.getDate()
  180. : monthStartDate.getDate();
  181. //本月的结束时间
  182. var monthEndDate = new Date(nowYear, nowMonth + 1, 0);
  183. var YY = monthEndDate.getFullYear() + "-";
  184. var MM =
  185. (monthEndDate.getMonth() + 1 < 10
  186. ? "0" + (monthEndDate.getMonth() + 1)
  187. : monthEndDate.getMonth() + 1) + "-";
  188. var DD =
  189. monthEndDate.getDate() < 10
  190. ? "0" + monthEndDate.getDate()
  191. : monthEndDate.getDate();
  192. monthDate.start_day = yy + mm + dd;
  193. monthDate.end_day = YY + MM + DD;
  194. this.setData({
  195. monthDate: monthDate
  196. })
  197. },
  198. // 发票作废
  199. invoiceInvalid(e) {
  200. let invoiceInfo = e.currentTarget.dataset.invoiceno
  201. let params = {
  202. entTaxId: this.data.company.entTaxId,
  203. deviceType: this.data.company.defaultDeviceInfo.deviceType,
  204. taxDiscId: this.data.company.defaultDeviceInfo.taxDiscId,
  205. invoiceInvalidType: invoiceInfo.invoiceType,
  206. invoiceCategory: invoiceInfo.invoiceCategory,
  207. invoiceCode: invoiceInfo.invoiceCode,
  208. invoiceNumber: invoiceInfo.invoiceNumber,
  209. invalidOper: this.data.userInfo.userName,
  210. mobile: this.data.userInfo.mobile,
  211. reqChannel: 5
  212. }
  213. utils.axios({
  214. method: 'post',
  215. url: '/sys/invoiceExt/invalid',
  216. data: params,
  217. sendBefore() {
  218. wx.showLoading({
  219. title: '加载中...'
  220. })
  221. },
  222. complete() {
  223. wx.hideLoading()
  224. wx.stopPullDownRefresh()
  225. },
  226. success: res => {
  227. if (res.code === 0) {
  228. utils.toast(res.msg)
  229. this.toFresh()
  230. }
  231. }
  232. })
  233. },
  234. // 发票红冲
  235. invoiceHongChong(e) {
  236. let invoiceInfo = e.currentTarget.dataset.invoiceno
  237. let params = {
  238. oriInvoiceReqFlowNo: invoiceInfo.invoiceReqFlowNo,
  239. mobile: this.data.userInfo.mobile,
  240. reqChannel: 5
  241. }
  242. utils.axios({
  243. method: 'post',
  244. url: '/sys/invoice/quickyHongchong',
  245. data: params,
  246. sendBefore() {
  247. wx.showLoading({
  248. title: '加载中...'
  249. })
  250. },
  251. complete() {
  252. wx.hideLoading()
  253. wx.stopPullDownRefresh()
  254. },
  255. success: res => {
  256. if (res.code === 0) {
  257. utils.toast(res.msg)
  258. this.toFresh()
  259. }
  260. }
  261. })
  262. },
  263. //点击重开
  264. showRetry(e) {
  265. wx.showModal({
  266. content: '确定重开该发票吗?',
  267. confirmColor: '#007dff',
  268. success: res => {
  269. if (res.confirm) {
  270. this.retry(e)
  271. }
  272. }
  273. })
  274. },
  275. retry(e) {
  276. let index = e.currentTarget.dataset.index
  277. let invoiceReqFlowNo = e.currentTarget.dataset.invoiceno
  278. let params = {
  279. invoiceReqFlowNo,
  280. mobile: utils.getInfo().mobile,
  281. reqChannel: 5
  282. }
  283. utils.axios({
  284. method: 'post',
  285. url: '/sys/invoiceInfo/retry',
  286. data: params,
  287. sendBefore() {
  288. wx.showLoading({
  289. title: '推送中...',
  290. mask: true
  291. })
  292. },
  293. complete() {
  294. wx.hideLoading()
  295. },
  296. success: res => {
  297. utils.toast('已推送')
  298. let result = res.data
  299. let str = `list[${index}].status`
  300. this.setData({
  301. [str]: result.status
  302. })
  303. }
  304. })
  305. },
  306. //开票详情
  307. toDetail(e) {
  308. let index = e.currentTarget.dataset.index
  309. let list = this.data.list
  310. let item = list[index]
  311. wx.setStorageSync('ticketDetail', item)
  312. wx.navigateTo({
  313. url: '/pages/ticketDetail/ticketDetail'
  314. })
  315. },
  316. //搜素
  317. search(e) {
  318. let customerName = e.detail.value
  319. this.setData({
  320. customerName
  321. })
  322. this.toFresh()
  323. },
  324. //全部状态
  325. setStatus(e) {
  326. let statusIndex = Number(e.detail.value)
  327. let status = ''
  328. if (statusIndex === 0) {
  329. status = 1
  330. }
  331. if (statusIndex === 1) {
  332. status = 3
  333. }
  334. if (statusIndex === 2) {
  335. status = 4
  336. }
  337. if (statusIndex === 3) {
  338. status = 5
  339. }
  340. if (statusIndex === 4) {
  341. status = 6
  342. }
  343. if (statusIndex === 5) {
  344. status = 7
  345. }
  346. this.setData({
  347. statusIndex,
  348. status
  349. })
  350. this.toFresh()
  351. },
  352. clearStatus() {
  353. this.setData({
  354. statusIndex: '',
  355. status: ''
  356. })
  357. this.toFresh()
  358. },
  359. //设置开始结束时间
  360. setStart(e) {
  361. let invoiceDateBegin = e.detail.value
  362. this.setData({
  363. invoiceDateBegin
  364. })
  365. this.toFresh()
  366. },
  367. setEnd(e) {
  368. let invoiceDateEnd = e.detail.value
  369. this.setData({
  370. invoiceDateEnd
  371. })
  372. this.toFresh()
  373. },
  374. clearStart() {
  375. this.setData({
  376. invoiceDateBegin: ''
  377. })
  378. this.toFresh()
  379. },
  380. clearEnd() {
  381. this.setData({
  382. invoiceDateEnd: ''
  383. })
  384. this.toFresh()
  385. },
  386. //切换
  387. switchTab(e) {
  388. let index = e.currentTarget.dataset.index
  389. let status = ''
  390. let hongchongFlag = ''
  391. if (index === 1) {
  392. status = 2
  393. }
  394. if (index === 2) {
  395. status = 3
  396. }
  397. if (index === 3) {
  398. status = ''
  399. hongchongFlag = 5
  400. }
  401. this.setData({
  402. status,
  403. hongchongFlag,
  404. tabIndex: index
  405. })
  406. this.toFresh()
  407. },
  408. /**
  409. * 生命周期函数--监听页面初次渲染完成
  410. */
  411. onReady: function () {
  412. },
  413. /**
  414. * 生命周期函数--监听页面显示
  415. */
  416. onShow: function () {
  417. },
  418. /**
  419. * 生命周期函数--监听页面隐藏
  420. */
  421. onHide: function () {
  422. },
  423. /**
  424. * 生命周期函数--监听页面卸载
  425. */
  426. onUnload: function () {
  427. },
  428. /**
  429. * 页面相关事件处理函数--监听用户下拉动作
  430. */
  431. onPullDownRefresh: function () {
  432. this.toFresh()
  433. },
  434. /**
  435. * 页面上拉触底事件的处理函数
  436. */
  437. onReachBottom: function () {
  438. let pageNum = this.data.pageNum
  439. let pages = this.data.pages
  440. pageNum++
  441. if (pageNum <= pages) {
  442. this.setData({
  443. pageNum
  444. })
  445. this.getList()
  446. } else {
  447. this.setData({
  448. finish: true
  449. })
  450. return
  451. }
  452. },
  453. /**
  454. * 用户点击右上角分享
  455. */
  456. onShareAppMessage: function () {
  457. return {
  458. title: '诺信云',
  459. path: '/pages/index/index'
  460. }
  461. }
  462. })