微信小程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

197 line
4.4 KiB

  1. // pages/finance/index.js
  2. import * as UTIL from '../../utils/util.js';
  3. import * as API from '../../utils/API.js';
  4. const app = getApp();
  5. Page({
  6. /**
  7. * 页面的初始数据
  8. */
  9. data: {
  10. isIPX: app.globalData.isIPX,
  11. list:[]
  12. },
  13. goList(e){
  14. let type = e.currentTarget.dataset.type;
  15. if(type == 'yeb'){
  16. wx.navigateTo({
  17. url: 'list_balance_ranking/list_balance_ranking',
  18. })
  19. }
  20. if(type == 'fzb'){
  21. wx.navigateTo({
  22. url: 'detailed_liabilities/detailed_liabilities',
  23. })
  24. }
  25. if(type == 'gkb'){
  26. wx.navigateTo({
  27. url: 'detailed_incomeAndExpenditurePublic/detailed_incomeAndExpenditurePublic',
  28. })
  29. }
  30. },
  31. /**
  32. * 生命周期函数--监听页面加载
  33. */
  34. onLoad(options) {
  35. },
  36. back:function(){
  37. wx.navigateBack({
  38. delta: 1
  39. })
  40. },
  41. /**
  42. * 生命周期函数--监听页面初次渲染完成
  43. */
  44. onReady() {
  45. },
  46. /**
  47. * 生命周期函数--监听页面显示
  48. */
  49. onShow() {
  50. var that = this;
  51. that.setData({
  52. imgUrl:wx.getStorageSync('dressCode')
  53. })
  54. UTIL.httpRequest(API.URL_GET_GETOPENLIST, {method:'GET'},{
  55. success: (res) => {
  56. if(res.code == 200){
  57. for (let i = 0; i < res.rows.length; i++) {
  58. const element = res.rows[i];
  59. if(element.openPic){
  60. element.openPic = element.openPic.split(',');
  61. }
  62. if(element.openFile){
  63. element.openFile = element.openFile.split(',');
  64. }
  65. }
  66. // wx.getStorageSync('dressCode')+
  67. if (res.rows.length>0) {
  68. that.setData({
  69. bookId:res.rows[0].bookId,
  70. deptId:res.rows[0].deptId,
  71. })
  72. }
  73. console.log(res.rows);
  74. that.setData({
  75. list:res.rows
  76. })
  77. }else{
  78. UTIL.showToastNoneIcon(res.msg);
  79. }
  80. }
  81. })
  82. },
  83. openPreview(e){
  84. let array = [];
  85. array.push(e.currentTarget.dataset.url)
  86. wx.previewImage({
  87. urls: array,
  88. showmenu:true,
  89. })
  90. },
  91. // 预览文件
  92. previewFile(e) {
  93. if(!e.currentTarget.dataset.url) {
  94. return false
  95. }
  96. UTIL.showLoading()
  97. // 单次下载允许的最大文件为 200MB
  98. wx.downloadFile({
  99. url: e.currentTarget.dataset.url,
  100. success: function (res) {
  101. console.log(res, "wx.downloadFile success res")
  102. if(res.statusCode != 200) {
  103. UTIL.hideLoadingWithErrorTips()
  104. return false
  105. }
  106. var Path = res.tempFilePath //返回的文件临时地址,用于后面打开本地预览所用
  107. wx.openDocument({
  108. filePath: Path,
  109. showMenu: true,
  110. success: function (res) {
  111. console.log('打开成功');
  112. UTIL.hideLoadings()
  113. }
  114. })
  115. },
  116. fail: function (err) {
  117. console.log(err, "wx.downloadFile fail err");
  118. UTIL.hideLoadingWithErrorTips()
  119. }
  120. })
  121. },
  122. goSearch(e){
  123. var that = this;
  124. let query = {
  125. openName:e.detail,
  126. bookId:that.data.bookId,
  127. deptId:that.data.deptId,
  128. method:'GET'
  129. }
  130. UTIL.httpRequest(API.URL_GET_GETOPENLIST,query,{
  131. success: (res) => {
  132. if(res.code == 200){
  133. for (let i = 0; i < res.rows.length; i++) {
  134. const element = res.rows[i];
  135. element.openPic = wx.getStorageSync('dressCode')+element.openPic;
  136. element.openFile = wx.getStorageSync('dressCode')+element.openFile;
  137. }
  138. that.setData({
  139. list:res.rows
  140. })
  141. }else{
  142. UTIL.showToastNoneIcon(res.msg);
  143. }
  144. }
  145. })
  146. },
  147. goFinace(e){
  148. let date = e.currentTarget.dataset.date;
  149. let bookId = e.currentTarget.dataset.bookid;
  150. let deptId = e.currentTarget.dataset.deptid;
  151. wx.navigateTo({
  152. url: 'finance?date='+date+'&bookId='+bookId+'&deptId='+deptId,
  153. })
  154. },
  155. /**
  156. * 生命周期函数--监听页面隐藏
  157. */
  158. onHide() {
  159. },
  160. /**
  161. * 生命周期函数--监听页面卸载
  162. */
  163. onUnload() {
  164. },
  165. /**
  166. * 页面相关事件处理函数--监听用户下拉动作
  167. */
  168. onPullDownRefresh() {
  169. },
  170. /**
  171. * 页面上拉触底事件的处理函数
  172. */
  173. onReachBottom() {
  174. },
  175. /**
  176. * 用户点击右上角分享
  177. */
  178. onShareAppMessage() {
  179. }
  180. })