detail.js 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295
  1. const _Http = getApp().globalData.http,
  2. getTime = require("../../utils/getTime")
  3. Page({
  4. data: {
  5. loading: true,
  6. sa_aftersalesmagid: 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: "#toolBill"
  26. }],
  27. tabbarsList: []
  28. },
  29. onLoad(options) {
  30. this.setData({
  31. sa_aftersalesmagid: 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": 20230104160603,
  40. "content": {
  41. nocache: true,
  42. "sa_aftersalesmagid": this.data.sa_aftersalesmagid
  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-tabgenjinjilu"
  64. }]
  65. if (res.data.status == '审核') tabbarsList = []
  66. this.setPreview(res.data);
  67. this.setData({
  68. detail: res.data,
  69. tabbarsList,
  70. loading: false
  71. });
  72. if (init) this.partialRenewal(true)
  73. })
  74. },
  75. /* 设置详情信息 */
  76. setPreview(data) {
  77. let list1 = [{
  78. label: "单号",
  79. value: data.billno
  80. }, {
  81. label: "单据日期",
  82. value: data.billdate
  83. }, {
  84. label: "状态",
  85. value: getApp().globalData.Language.getMapText(data.status)
  86. },
  87. {
  88. label: '是否实物返回',
  89. value: data.isitemreturn ? language['是'] || '是' : language['否'] || '否'
  90. }, {
  91. label: "提交日期",
  92. value: data.submitdate
  93. }, {
  94. label: "审核日期",
  95. value: data.checkdate
  96. }, {
  97. label: "备注",
  98. value: data.remarks
  99. }
  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. this.setData({
  115. list1,
  116. list2
  117. })
  118. },
  119. /* 审核选择弹出框关闭 */
  120. onClose() {
  121. this.setData({
  122. show: false
  123. })
  124. },
  125. /* 审核提交 */
  126. async checkSubmit({
  127. detail
  128. }) {
  129. let res = await _Http.basic({
  130. "id": "20221226153304",
  131. "content": {
  132. "sa_aftersalesmagid": this.data.sa_aftersalesmagid,
  133. "period": getTime.formatTime(new Date(detail), '-').split(' ')[0]
  134. }
  135. })
  136. console.log(res);
  137. if (res.code == '1') {
  138. this.setData({
  139. show: false
  140. })
  141. this.getDetail(true)
  142. }
  143. },
  144. tabbarOnClick({
  145. detail
  146. }) {
  147. switch (detail.label) {
  148. case "编辑":
  149. wx.navigateTo({
  150. url: `/packageA/toolBill/update?rowData=${JSON.stringify(this.data.detail)}`,
  151. })
  152. break;
  153. case "提交":
  154. wx.showModal({
  155. cancelText: getApp().globalData.Language.getMapText('取消'),
  156. confirmText: getApp().globalData.Language.getMapText('确定'),
  157. title: getApp().globalData.Language.getMapText('提示'),
  158. content: getApp().globalData.Language.getMapText('是否确认提交该工具归还单') + `?`,
  159. complete: ({
  160. confirm
  161. }) => {
  162. if (confirm) _Http.basic({
  163. "id": "20230105161603",
  164. "content": {
  165. "sa_aftersalesmagid": this.data.sa_aftersalesmagid
  166. }
  167. }).then(res => {
  168. wx.showToast({
  169. title: res.code == '1' ? getApp().globalData.Language.getMapText('已提交该工具归还单') : res.msg,
  170. icon: "none"
  171. });
  172. if (res.code == '1') {
  173. this.getDetail()
  174. let pages = getCurrentPages(),
  175. page = pages[pages.length - 2]
  176. page.getList(true)
  177. }
  178. })
  179. }
  180. })
  181. break;
  182. case "取消提交":
  183. wx.showModal({
  184. cancelText: getApp().globalData.Language.getMapText('取消'),
  185. confirmText: getApp().globalData.Language.getMapText('确定'),
  186. title: getApp().globalData.Language.getMapText('提示'),
  187. content: getApp().globalData.Language.getMapText('是否确认取消提交该工具归还单') + `?`,
  188. complete: ({
  189. confirm
  190. }) => {
  191. if (confirm) _Http.basic({
  192. "id": "20230105161703",
  193. "content": {
  194. "sa_aftersalesmagid": this.data.sa_aftersalesmagid
  195. }
  196. }).then(res => {
  197. wx.showToast({
  198. title: res.code == '1' ? getApp().globalData.Language.getMapText('已取消提交该工具归还单') : res.msg,
  199. icon: "none"
  200. });
  201. if (res.code == '1') {
  202. this.getDetail()
  203. let pages = getCurrentPages(),
  204. page = pages[pages.length - 2]
  205. page.getList(true)
  206. }
  207. })
  208. }
  209. })
  210. break;
  211. case "删除":
  212. wx.showModal({
  213. cancelText: getApp().globalData.Language.getMapText('取消'),
  214. confirmText: getApp().globalData.Language.getMapText('确定'),
  215. title: getApp().globalData.Language.getMapText('提示'),
  216. content: getApp().globalData.Language.getMapText('是否删除该工具归还单') + `?`,
  217. complete: ({
  218. confirm
  219. }) => {
  220. if (confirm) _Http.basic({
  221. "id": 20230104160803,
  222. "content": {
  223. sa_aftersalesmagids: [this.data.sa_aftersalesmagid]
  224. }
  225. }).then(res => {
  226. wx.showToast({
  227. title: res.code == '1' ? getApp().globalData.Language.getMapText('已删除该工具归还单') : res.msg,
  228. icon: "none"
  229. });
  230. if (res.code == '1') {
  231. setTimeout(() => {
  232. wx.navigateBack()
  233. getCurrentPages()[getCurrentPages().length - 2].getList(true)
  234. }, 300)
  235. }
  236. })
  237. }
  238. })
  239. break;
  240. }
  241. },
  242. onInput(detail) {
  243. },
  244. //tabs 切换
  245. tabsChange({
  246. detail
  247. }) {
  248. this.setData({
  249. tabsActive: detail
  250. });
  251. console.log(this.data.tabsActive);
  252. this.partialRenewal();
  253. },
  254. //局部数据更新 tabs
  255. partialRenewal(init = false) {
  256. let model = this.data.tabsList[this.data.tabsActive].model;
  257. if (model) {
  258. let Component = this.selectComponent(model),
  259. {
  260. total,
  261. pageNumber,
  262. pageTotal
  263. } = Component.data.content,
  264. id = this.data.detail.sa_aftersalesmagid;
  265. if (total == null || init) {
  266. Component.getList(id, init);
  267. } else if (pageNumber <= pageTotal) {
  268. Component.getList(id, false);
  269. }
  270. }
  271. },
  272. onReachBottom() {
  273. this.partialRenewal();
  274. },
  275. onUnload() {
  276. console.log("更新列表数据")
  277. let page = getCurrentPages().find(v => v.__route__ == 'packageA/toolBill/index');
  278. let content = JSON.parse(JSON.stringify(page.data.content));
  279. content.pageNumber = 1;
  280. content.pageSize = (page.data.content.pageNumber - 1) * page.data.content.pageSize;
  281. _Http.basic({
  282. "id": 20230105161503,
  283. content
  284. }).then(res => {
  285. console.log("更新订单列表", res)
  286. if (res.code == '1') page.setData({
  287. list: res.data
  288. })
  289. })
  290. },
  291. })