detail.js 6.3 KB

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