detail.js 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299
  1. const _Http = getApp().globalData.http,
  2. getTime = require("../../utils/getTime")
  3. Page({
  4. data: {
  5. loading: true,
  6. sa_paybillid: null,
  7. tabsActive: 1,
  8. currentDate: new Date().getTime(),
  9. formatter(type, value) {
  10. if (type === 'year') {
  11. return value + getApp().globalData.Language.getMapText('年');
  12. }
  13. if (type === 'month') {
  14. return value + getApp().globalData.Language.getMapText('月');
  15. }
  16. return value;
  17. },
  18. show: false,
  19. tabsList: [{
  20. label: "详细信息",
  21. icon: "icon-tabchanpin"
  22. }, {
  23. label: "打款明细",
  24. icon: "icon-tabcaozuojilu1",
  25. model: "#remitVoucher"
  26. }],
  27. tabbarsList: []
  28. },
  29. onLoad(options) {
  30. this.setData({
  31. sa_paybillid: options.id
  32. });
  33. this.getDetail(true);
  34. },
  35. /* 获取详情 */
  36. getDetail(init = false, show = true) {
  37. _Http.basic({
  38. "id": 20221226153404,
  39. "content": {
  40. nocache: true,
  41. "sa_paybillid": this.data.sa_paybillid
  42. }
  43. }, show).then(res => {
  44. console.log("出货详情", res)
  45. if (res.code != '1') return wx.showToast({
  46. title: res.msg,
  47. icon: "none"
  48. });
  49. let tabbarsList = []
  50. if (res.data.status == '新建') tabbarsList = [{
  51. label: "编辑",
  52. icon: "icon-dibu-bianji"
  53. }, {
  54. label: "提交",
  55. icon: "icon-tijiao",
  56. }, {
  57. label: "删除",
  58. icon: "icon-guanlian-shanchu"
  59. }]
  60. if (res.data.status == '提交') tabbarsList = [{
  61. label: "审核",
  62. icon: "icon-shenhe"
  63. }, {
  64. label: "退回",
  65. icon: "icon-a-fanshenhetuihui"
  66. }]
  67. if (res.data.status == '审核') tabbarsList = [{
  68. label: "退回",
  69. icon: "icon-a-fanshenhetuihui"
  70. }]
  71. this.setPreview(res.data);
  72. this.setData({
  73. detail: res.data,
  74. tabbarsList,
  75. loading: false
  76. });
  77. if (init) this.partialRenewal(true)
  78. })
  79. },
  80. /* 设置详情信息 */
  81. setPreview(data) {
  82. let list1 = [{
  83. label: "凭证单号",
  84. value: data.billno
  85. }, {
  86. label: "状态",
  87. value: getApp().globalData.Language.getMapText(data.status)
  88. }, {
  89. label: "经销商编号",
  90. value: data.agentnum
  91. }, {
  92. label: "经销商简称",
  93. value: data.enterprisename
  94. }, {
  95. label: "回款归属月份",
  96. value: data.period
  97. }, {
  98. label: "打款金额",
  99. value: data.amount
  100. }],
  101. list2 = [{
  102. label: "创建人",
  103. value: data.createby
  104. }, {
  105. label: "创建时间",
  106. value: data.createdate
  107. }, {
  108. label: "审核人",
  109. value: data.checkby
  110. }, {
  111. label: "审核时间",
  112. value: data.checkdate
  113. }, {
  114. label: "付款人",
  115. value: data.payer
  116. }, {
  117. label: "付款时间",
  118. value: data.paydate
  119. }];
  120. this.setData({
  121. list1,
  122. list2
  123. })
  124. },
  125. /* 审核选择弹出框关闭 */
  126. onClose() {
  127. this.setData({
  128. show: false
  129. })
  130. },
  131. /* 审核提交 */
  132. async checkSubmit({
  133. detail
  134. }) {
  135. let res = await _Http.basic({
  136. "id": "20221226153304",
  137. "content": {
  138. "sa_paybillid": this.data.sa_paybillid,
  139. "period": getTime.formatTime(new Date(detail), '-').split(' ')[0]
  140. }
  141. })
  142. if (res.code == '1') {
  143. this.setData({
  144. show: false
  145. })
  146. this.getDetail(true)
  147. }
  148. },
  149. tabbarOnClick({
  150. detail
  151. }) {
  152. switch (detail.label) {
  153. case "编辑":
  154. wx.navigateTo({
  155. url: `/packageA/remitVoucher/update?rowData=${JSON.stringify(this.data.detail)}`,
  156. })
  157. break;
  158. case "提交":
  159. wx.showModal({
  160. cancelText: getApp().globalData.Language.getMapText('取消'),
  161. confirmText: getApp().globalData.Language.getMapText('确定'),
  162. title: getApp().globalData.Language.getMapText('提示'),
  163. content: getApp().globalData.Language.getMapText('是否确认提交该打款凭证') + `?`,
  164. complete: ({
  165. confirm
  166. }) => {
  167. if (confirm) _Http.basic({
  168. "id": "20221226153204",
  169. "content": {
  170. "sa_paybillid": this.data.sa_paybillid
  171. }
  172. }).then(res => {
  173. wx.showToast({
  174. title: res.code == '1' ? getApp().globalData.Language.getMapText('已提交改打款凭证') : res.msg,
  175. icon: "none"
  176. });
  177. if (res.code == '1') {
  178. this.getDetail()
  179. let pages = getCurrentPages(),
  180. page = pages[pages.length - 2]
  181. page.getList(true)
  182. }
  183. })
  184. }
  185. })
  186. break;
  187. case "审核":
  188. getApp().globalData.Language.showToast('请选择回款日期')
  189. this.setData({
  190. show: true
  191. })
  192. break;
  193. case "退回":
  194. wx.showModal({
  195. cancelText: getApp().globalData.Language.getMapText('取消'),
  196. confirmText: getApp().globalData.Language.getMapText('确定'),
  197. title: getApp().globalData.Language.getMapText('提示'),
  198. content: getApp().globalData.Language.getMapText('是否确认退回该打款凭证') + `?`,
  199. complete: ({
  200. confirm
  201. }) => {
  202. if (confirm) _Http.basic({
  203. "id": 20221227110104,
  204. "content": {
  205. sa_paybillid: this.data.sa_paybillid
  206. }
  207. }).then(res => {
  208. wx.showToast({
  209. title: res.code == '1' ? getApp().globalData.Language.getMapText('已退回该凭证') : res.msg,
  210. icon: "none"
  211. });
  212. if (res.code == '1') {
  213. this.getDetail()
  214. }
  215. })
  216. }
  217. })
  218. break;
  219. case "删除":
  220. wx.showModal({
  221. cancelText: getApp().globalData.Language.getMapText('取消'),
  222. confirmText: getApp().globalData.Language.getMapText('确定'),
  223. title: getApp().globalData.Language.getMapText('提示'),
  224. content: getApp().globalData.Language.getMapText('是否删除该凭证') + `?`,
  225. complete: ({
  226. confirm
  227. }) => {
  228. if (confirm) _Http.basic({
  229. "id": 20221226153104,
  230. "content": {
  231. sa_paybillids: [this.data.sa_paybillid]
  232. }
  233. }).then(res => {
  234. wx.showToast({
  235. title: res.code == '1' ? getApp().globalData.Language.getMapText('删除成功') : res.msg,
  236. icon: "none"
  237. });
  238. if (res.code == '1') {
  239. setTimeout(() => {
  240. wx.navigateBack()
  241. getCurrentPages()[getCurrentPages().length - 2].getList(true)
  242. }, 300)
  243. }
  244. })
  245. }
  246. })
  247. break;
  248. }
  249. },
  250. //tabs 切换
  251. tabsChange({
  252. detail
  253. }) {
  254. this.setData({
  255. tabsActive: detail
  256. });
  257. console.log(this.data.tabsActive);
  258. this.partialRenewal();
  259. },
  260. //局部数据更新 tabs
  261. partialRenewal(init = false) {
  262. let model = this.data.tabsList[this.data.tabsActive].model;
  263. if (model) {
  264. let Component = this.selectComponent(model),
  265. {
  266. total,
  267. pageNumber,
  268. pageTotal
  269. } = Component.data.content,
  270. id = this.data.detail.sa_paybillid;
  271. if (total == null || init) {
  272. Component.getList(id, init);
  273. } else if (pageNumber <= pageTotal) {
  274. Component.getList(id, false);
  275. }
  276. }
  277. },
  278. onReachBottom() {
  279. this.partialRenewal();
  280. },
  281. onUnload() {
  282. let page = getCurrentPages().find(v => v.__route__ == 'packageA/remitVoucher/index');
  283. let content = JSON.parse(JSON.stringify(page.data.content));
  284. content.pageSize = (page.data.content.pageNumber - 1) * page.data.content.pageSize;
  285. content.pageNumber = 1;
  286. _Http.basic({
  287. "id": 20221226152904,
  288. content
  289. }).then(res => {
  290. console.log("更新订单列表", res)
  291. if (res.code == '1') page.setData({
  292. list: res.data
  293. })
  294. })
  295. },
  296. })