微信小程序
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.

222 lines
5.0 KiB

  1. // pages/finance/detailed_liabilities/detailed_liabilities.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. expressionOptions:[],
  12. searchDate: {
  13. bookDate: "",
  14. templateName: '资产负债表',
  15. signature: false, // 添加底部落款
  16. },
  17. list: [],
  18. accountingYear: "",
  19. accountingMonth: "",
  20. // 显示搜索条件
  21. visible: false,
  22. showPickerTime: false,
  23. subjectName:'请选择科目查询',
  24. minDate: new Date().getTime(),
  25. maxDate: new Date().getTime(),
  26. currentDate: new Date(),
  27. date:''
  28. },
  29. /**
  30. * 生命周期函数--监听页面加载
  31. */
  32. onLoad(options) {
  33. UTIL.httpRequest(API.getLoginBook,{}, {
  34. success: (res) => {
  35. if (res.code == API.SUCCESS_CODE) {
  36. let currentDays = res.data.currentDay;
  37. if (currentDays == null) {
  38. UTIL.showToastNoneIcon("当前账套未开启!");
  39. return false;
  40. }
  41. let mindate = res.data.startDay.split('-')
  42. let dealDays = currentDays.split("-");
  43. this.setData({
  44. accountingYear:dealDays[0],
  45. accountingMonth:dealDays[1],
  46. date: dealDays[0]+'年'+dealDays[1]+'月',
  47. ['searchDate.bookDate']:currentDays,
  48. minDate: new Date(mindate[0],mindate[1]-1).getTime(),
  49. })
  50. this.initPage()
  51. }
  52. }
  53. });
  54. UTIL.httpRequest(API.expressionReportByCategory+'资产负债表',{}, {
  55. success: (res) => {
  56. if (res.code == API.SUCCESS_CODE) {
  57. let content = res.data;
  58. this.setData({
  59. expressionOptions:content
  60. })
  61. }
  62. }
  63. });
  64. },
  65. initPage() {
  66. var that = this;
  67. UTIL.httpRequest(API.assetLiabilityReportByExpTpl,this.data.searchDate, {
  68. success: (res) => {
  69. if (res.code == API.SUCCESS_CODE) {
  70. let content = res.data;
  71. this.setData({
  72. list:content.list.map((x) => {
  73. x.ncyeLeft = that.formatNum(x.ncyeLeft);
  74. x.qmyeLeft = that.formatNum(x.qmyeLeft);
  75. x.ncyeRight = that.formatNum(x.ncyeRight);
  76. x.qmyeRight = that.formatNum(x.qmyeRight);
  77. return x;
  78. })
  79. })
  80. }
  81. }
  82. });
  83. },
  84. formatNum(value) {
  85. if(value === undefined || value === null)
  86. return '';
  87. if(typeof(value) === "string")
  88. {
  89. if(value.indexOf(',') !== -1)
  90. return value;
  91. value = Number(value);
  92. if(isNaN(value))
  93. return '';
  94. }
  95. if(value === 0)
  96. return '';
  97. return this.numFormat(value);
  98. },
  99. numFormat(value) {
  100. if (value == null) {
  101. return "";
  102. }
  103. if (!value) return "0.00";
  104. value = value.toFixed(2);
  105. let is_neg = value < 0;
  106. var intPart = Math.abs(Math.trunc(value)); // 获取整数部分
  107. var intPartFormat = intPart.toString()
  108. .replace(/(\d)(?=(?:\d{3})+$)/g, "$1,"); // 将整数部分逢三一断
  109. if(is_neg)
  110. intPartFormat = '-' + intPartFormat;
  111. var floatPart = ".00"; // 预定义小数部分
  112. var value2Array = value.split(".");
  113. // =2表示数据有小数位
  114. if (value2Array.length === 2) {
  115. floatPart = value2Array[1].toString(); // 拿到小数部分
  116. if (floatPart.length === 1) {
  117. // 补0,实际上用不着
  118. return intPartFormat + "." + floatPart + "0";
  119. } else {
  120. return intPartFormat + "." + floatPart;
  121. }
  122. } else {
  123. return intPartFormat + floatPart;
  124. }
  125. },
  126. openPick(){
  127. this.setData({
  128. showPickerTime:true
  129. })
  130. },
  131. closePick(){
  132. this.setData({
  133. showPickerTime:false
  134. })
  135. },
  136. onConfirm(time) {
  137. console.log(time.detail);
  138. let date = UTIL.formatDates(time.detail).split('-');
  139. this.setData({
  140. date:date[0] + '年' + date[1] + '月',
  141. ['queryParams.startDate']:UTIL.formatDates(time.detail),
  142. showPickerTime : false
  143. })
  144. this.getList();
  145. },
  146. back:function(){
  147. wx.navigateBack({
  148. delta: 1
  149. })
  150. },
  151. closePickEx(){
  152. this.setData({
  153. visible : false
  154. })
  155. },
  156. openPickEx(){
  157. this.setData({
  158. visible : true
  159. })
  160. },
  161. onConfirmExpression(data){
  162. console.log(data);
  163. this.setData({
  164. subjectName:data.detail.value.name,
  165. ['searchDate.templateName']: data.detail.value.name,
  166. visible : false
  167. })
  168. this.initPage();
  169. },
  170. /**
  171. * 生命周期函数--监听页面初次渲染完成
  172. */
  173. onReady() {
  174. },
  175. /**
  176. * 生命周期函数--监听页面显示
  177. */
  178. onShow() {
  179. },
  180. /**
  181. * 生命周期函数--监听页面隐藏
  182. */
  183. onHide() {
  184. },
  185. /**
  186. * 生命周期函数--监听页面卸载
  187. */
  188. onUnload() {
  189. },
  190. /**
  191. * 页面相关事件处理函数--监听用户下拉动作
  192. */
  193. onPullDownRefresh() {
  194. },
  195. /**
  196. * 页面上拉触底事件的处理函数
  197. */
  198. onReachBottom() {
  199. },
  200. /**
  201. * 用户点击右上角分享
  202. */
  203. onShareAppMessage() {
  204. }
  205. })