detail.js 7.1 KB

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