invoiceSummary.js 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310
  1. // miniprogram/pages/invoiceSummary/invoiceSummary.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. userInfo: '',
  15. company: '',
  16. blankInvalidCnt: 0,
  17. blueInvalidCnt: 0,
  18. blueInvoiceCnt: 0,
  19. redInvalidCnt: 0,
  20. redInvoiceCnt: 0,
  21. invoiceDateBegin: '',
  22. invoiceDateEnd: '',
  23. invoiceType: ['增值税普通纸质发票', '增值税专用纸质发票', '增值税普通电子发票', '增值税专用电子发票'],
  24. invoiceTypeIndex: 0,
  25. invoiceStatus: 3
  26. },
  27. /**
  28. * 生命周期函数--监听页面加载
  29. */
  30. onLoad: function (options) {
  31. this.getUser()
  32. },
  33. //获取企业信息(当前登录用户的默认企业信息)
  34. getUser() {
  35. this.getMonthFirstDay()
  36. this.getMonthLastDay()
  37. this.setData({
  38. userInfo: utils.getInfo(),
  39. company:utils.getCurrEntInfo()
  40. })
  41. this.getList()
  42. // utils.getCompany().then(res => {
  43. // let result = res.data
  44. // this.setData({
  45. // company: result
  46. // })
  47. // this.getList()
  48. // })
  49. },
  50. //获取待开抬头
  51. getList(type) {
  52. let params = {
  53. entTaxId: this.data.company.entTaxId,
  54. deviceType: this.data.company.defaultDeviceInfo.deviceType,
  55. taxDiscId: this.data.company.defaultDeviceInfo.taxDiscId,
  56. mobile: this.data.userInfo.mobile,
  57. invoiceDateBegin: this.data.invoiceDateBegin + ' 00:00:00',
  58. invoiceDateEnd: this.data.invoiceDateEnd + ' 23:59:59',
  59. invoiceCategory: this.data.invoiceStatus,
  60. reqChannel: 5
  61. }
  62. utils.axios({
  63. method: 'get',
  64. url: '/sys/invoiceExt/reports',
  65. data: params,
  66. sendBefore() {
  67. wx.showLoading({
  68. title: '加载中...'
  69. })
  70. },
  71. complete() {
  72. wx.hideLoading()
  73. wx.stopPullDownRefresh()
  74. },
  75. success: res => {
  76. this.setData({
  77. list: res.data.reportsData,
  78. pages: 1,
  79. finish: true,
  80. blankInvalidCnt: res.data.blankInvalidCnt,
  81. blueInvalidCnt: res.data.blueInvalidCnt,
  82. blueInvoiceCnt: res.data.blueInvoiceCnt,
  83. redInvalidCnt: res.data.redInvalidCnt,
  84. redInvoiceCnt: res.data.redInvoiceCnt
  85. })
  86. }
  87. })
  88. },
  89. toFresh() {
  90. this.setData({
  91. pageNum: 1,
  92. pages: '',
  93. finish: false
  94. })
  95. wx.pageScrollTo({
  96. scrollTop: 0,
  97. duration: 300
  98. })
  99. this.getList('toFresh')
  100. },
  101. //搜素
  102. search(e) {
  103. let customerName = e.detail.value
  104. this.setData({
  105. customerName
  106. })
  107. this.toFresh()
  108. },
  109. //确认框
  110. showDel(e) {
  111. let params = {
  112. mobile: utils.getInfo().mobile,
  113. reqChannel: 5,
  114. delList: [{
  115. recordId: e.currentTarget.dataset.recordid,
  116. belongEntTaxId: e.currentTarget.dataset.belong
  117. }]
  118. }
  119. let index = Number(e.currentTarget.dataset.index)
  120. wx.showModal({
  121. content: '确定删除该条数据吗?',
  122. confirmColor: '#007dff',
  123. success: res => {
  124. if (res.confirm) {
  125. this.del(params, index)
  126. }
  127. }
  128. })
  129. },
  130. //删除
  131. del(params, index) {
  132. utils.axios({
  133. method: 'post',
  134. url: '/sys/taitou/todo/delete',
  135. data: params,
  136. sendBefore() {
  137. wx.showLoading({
  138. title: '删除中...',
  139. mask: true
  140. })
  141. },
  142. complete() {
  143. wx.hideLoading()
  144. },
  145. success: res => {
  146. let list = this.data.list
  147. list.splice(index, 1)
  148. this.setData({
  149. list
  150. })
  151. utils.toast('删除成功')
  152. }
  153. })
  154. },
  155. //点击开票
  156. toTicket(e) {
  157. let index = e.currentTarget.dataset.index
  158. let item = this.data.list[index]
  159. wx.setStorageSync('ticketMakeData', item)
  160. wx.navigateTo({
  161. url: '/pages/ticketMake/ticketMake'
  162. })
  163. },
  164. // 获取当月第一天
  165. getMonthFirstDay() {
  166. var date = new Date();
  167. date.setDate(1);
  168. var month = parseInt(date.getMonth() + 1);
  169. var day = date.getDate();
  170. if (month < 10) {
  171. month = '0' + month
  172. }
  173. if (day < 10) {
  174. day = '0' + day
  175. }
  176. this.setData({
  177. invoiceDateBegin: date.getFullYear() + '-' + month + '-' + day
  178. })
  179. },
  180. // 获取当月最后一天
  181. getMonthLastDay() {
  182. var endDate = new Date();
  183. var currentMonth = endDate.getMonth();
  184. var nextMonth = ++currentMonth;
  185. var nextMonthFirstDay = new Date(endDate.getFullYear(), nextMonth, 1);
  186. var oneDay = 1000 * 60 * 60 * 24;
  187. var lastTime = new Date(nextMonthFirstDay - oneDay);
  188. var endMonth = parseInt(lastTime.getMonth() + 1);
  189. var endDay = lastTime.getDate();
  190. if (endMonth < 10) {
  191. endMonth = '0' + endMonth
  192. }
  193. if (endDay < 10) {
  194. endDay = '0' + endDay
  195. }
  196. this.setData({
  197. invoiceDateEnd: endDate.getFullYear() + '-' + endMonth + '-' + endDay
  198. })
  199. },
  200. //设置开始结束时间
  201. setStart(e) {
  202. let invoiceDateBegin = e.detail.value
  203. this.setData({
  204. invoiceDateBegin
  205. })
  206. this.toFresh()
  207. },
  208. //设置结束时间
  209. setEnd(e) {
  210. let invoiceDateEnd = e.detail.value
  211. this.setData({
  212. invoiceDateEnd
  213. })
  214. this.toFresh()
  215. },
  216. //发票类型
  217. setInvoiceType(e) {
  218. let value = Number(e.detail.value)
  219. let status = ''
  220. if (value === 0) {
  221. status = 3
  222. }
  223. if (value === 1) {
  224. status = 4
  225. }
  226. if (value === 2) {
  227. status = 1
  228. }
  229. if (value === 3) {
  230. status = 2
  231. }
  232. this.setData({
  233. invoiceTypeIndex: value,
  234. invoiceStatus: status
  235. })
  236. this.toFresh()
  237. },
  238. /**
  239. * 生命周期函数--监听页面初次渲染完成
  240. */
  241. onReady: function () {
  242. },
  243. /**
  244. * 生命周期函数--监听页面显示
  245. */
  246. onShow: function () {
  247. },
  248. /**
  249. * 生命周期函数--监听页面隐藏
  250. */
  251. onHide: function () {
  252. },
  253. /**
  254. * 生命周期函数--监听页面卸载
  255. */
  256. onUnload: function () {
  257. },
  258. /**
  259. * 页面相关事件处理函数--监听用户下拉动作
  260. */
  261. onPullDownRefresh: function () {
  262. this.toFresh()
  263. },
  264. /**
  265. * 页面上拉触底事件的处理函数
  266. */
  267. onReachBottom: function () {
  268. let pageNum = this.data.pageNum
  269. let pages = this.data.pages
  270. pageNum++
  271. if (pageNum <= pages) {
  272. this.setData({
  273. pageNum
  274. })
  275. this.getList()
  276. } else {
  277. this.setData({
  278. finish: true
  279. })
  280. return
  281. }
  282. },
  283. /**
  284. * 用户点击右上角分享
  285. */
  286. onShareAppMessage: function () {
  287. return {
  288. title: '诺信云',
  289. path: '/pages/index/index'
  290. }
  291. }
  292. })