detail.js 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. const _Http = getApp().globalData.http,
  2. currency = require("../../utils/currency"),
  3. CNY = num => currency(num, {
  4. symbol: "¥",
  5. precision: 2
  6. }).format();
  7. Page({
  8. loading: true,
  9. data: {
  10. tabsActive: 2,
  11. sa_invoiceapplyid: "",
  12. tabsList: [{
  13. label: "详细信息",
  14. icon: "icon-tabchanpin"
  15. }, {
  16. label: "开票单位",
  17. icon: "icon-tabchanpin"
  18. }, {
  19. label: "开票明细",
  20. icon: "icon-tabchanpin",
  21. model: "#DetailLine"
  22. }, {
  23. label: "发票",
  24. icon: "icon-tabchanpin",
  25. model: "#InvoiceList"
  26. }]
  27. },
  28. onLoad(options) {
  29. this.setData({
  30. sa_invoiceapplyid: options.id
  31. });
  32. this.getDetail();
  33. },
  34. getDetail() {
  35. _Http.basic({
  36. "id": "20221216143003",
  37. "version": 1,
  38. "content": {
  39. "sa_invoiceapplyid": this.data.sa_invoiceapplyid
  40. }
  41. }).then(res => {
  42. console.log("开票单详情", res)
  43. if (res.msg != '成功') return wx.showToast({
  44. title: res.msg,
  45. icon: "none"
  46. })
  47. this.setData({
  48. detail: res.data,
  49. loading: false
  50. });
  51. this.setPreview();
  52. this.partialRenewal();
  53. })
  54. },
  55. /* 设置显示信息 */
  56. setPreview() {
  57. let item = this.data.detail;
  58. let list1 = [{
  59. label: "申请单号",
  60. value: item.billno
  61. }, {
  62. label: "发票限额",
  63. value: CNY(item.quota)
  64. }, {
  65. label: "是否手工单",
  66. value: item.byhand ? '是' : '否'
  67. }, {
  68. label: "发票种类",
  69. value: item.invoiceline
  70. }, {
  71. label: "发票收款人",
  72. value: item.invoicepayee
  73. }, {
  74. label: "开票员",
  75. value: item.invoiceclerk
  76. }, {
  77. label: "发票复核人",
  78. value: item.invoicechecker
  79. }, {
  80. label: "提交人",
  81. value: item.submitby
  82. }, {
  83. label: "提交日期",
  84. value: item.submitdate
  85. }, {
  86. label: "备注",
  87. value: item.remarks
  88. }];
  89. let list2 = [{
  90. label: "状态",
  91. value: item.status
  92. }, {
  93. label: "创建人",
  94. value: item.createby
  95. }, {
  96. label: "创建时间",
  97. value: item.createdate
  98. }, {
  99. label: "审核人",
  100. value: item.checkby
  101. }, {
  102. label: "审核时间",
  103. value: item.checkdate
  104. }, {
  105. label: "修改人",
  106. value: item.changeby
  107. }, {
  108. label: "修改时间",
  109. value: item.changedate
  110. }, ];
  111. let riseLine = [{
  112. label: "抬头",
  113. value: item.enterprisename
  114. }, {
  115. label: "税号",
  116. value: item.taxno
  117. }, {
  118. label: "开户行",
  119. value: item.bank
  120. }, {
  121. label: "开户账号",
  122. value: item.bankcardno
  123. }, {
  124. label: "开票地址",
  125. value: item.address
  126. }, {
  127. label: "联系方式",
  128. value: item.phonenumber
  129. }];
  130. this.setData({
  131. list1,
  132. list2,
  133. riseLine
  134. })
  135. },
  136. //tabs 切换
  137. tabsChange({
  138. detail
  139. }) {
  140. this.setData({
  141. tabsActive: detail
  142. });
  143. this.partialRenewal();
  144. },
  145. //局部数据更新 tabs
  146. partialRenewal(init = false) {
  147. let model = this.data.tabsList[this.data.tabsActive].model;
  148. if (model) {
  149. let Component = this.selectComponent(model),
  150. {
  151. total,
  152. pageNumber,
  153. pageTotal
  154. } = Component.data.content,
  155. id = this.data.sa_invoiceapplyid;
  156. if (total == null || init) {
  157. Component.getList(id, init);
  158. } else if (pageNumber <= pageTotal) {
  159. Component.getList(id, false);
  160. }
  161. }
  162. },
  163. submit() {
  164. if (this.selectComponent("#DetailLine").data.list.length == 0) {
  165. wx.showToast({
  166. title: '还未添加开票订单行不可提交!',
  167. icon: "none"
  168. });
  169. this.setData({
  170. tabsActive: 2
  171. })
  172. } else {
  173. let that = this;
  174. wx.showModal({
  175. title: '提示',
  176. content: '是否确认提交该申请单?',
  177. complete: ({
  178. confirm
  179. }) => {
  180. if (confirm) _Http.basic({
  181. "id": "20221219133803",
  182. "version": 1,
  183. "content": {
  184. "sa_invoiceapplyid": that.data.sa_invoiceapplyid
  185. }
  186. }).then(res => {
  187. console.log("提交申请单", res);
  188. if (res.msg != '成功') return wx.showToast({
  189. title: res.msg,
  190. icon: "none"
  191. });
  192. that.getDetail();
  193. })
  194. }
  195. })
  196. }
  197. },
  198. onReachBottom() {
  199. this.partialRenewal();
  200. },
  201. onUnload() {
  202. let page = getCurrentPages().find(v => v.__route__ == 'packageA/invoice/index');
  203. let content = JSON.parse(JSON.stringify(page.data.content));
  204. content.pageNumber = 1;
  205. content.pageSize = (page.data.content.pageNumber - 1) * page.data.content.pageSize;
  206. _Http.basic({
  207. "id": 20221216143103,
  208. "version": 1,
  209. content
  210. }).then(res => {
  211. console.log("开票列表", res)
  212. page.setData({
  213. list: res.data
  214. })
  215. })
  216. },
  217. })