billVoyageList.js 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257
  1. const {
  2. postApi
  3. } = require("../../../apis/api")
  4. import {
  5. datetimeFormat
  6. } from "../../../utils/utils"
  7. const app = getApp()
  8. Page({
  9. data: {
  10. cargoOwnerId: 0,
  11. defaultParams: {
  12. loginAccountId: wx.getStorageSync('loginAccountId')
  13. },
  14. maintab: 3,
  15. status: 1,
  16. currentPage: 1,
  17. size: 20,
  18. list: [],
  19. total: 0,
  20. term: "",
  21. isFreshing: false,
  22. apiArr: ['/voyage/wx/list', '/dayReport/list', '/bill/list']
  23. },
  24. selectCargoOwner(e) {
  25. this.setData({
  26. cargoOwnerId: e.detail.value,
  27. list: [],
  28. currentPage: 1,
  29. })
  30. this.getList()
  31. },
  32. changeMainTab(e) {
  33. let {
  34. maintab,
  35. api: currentApi
  36. } = e.currentTarget.dataset
  37. app.globalData.maintab = maintab
  38. this.setData({
  39. maintab,
  40. currentApi,
  41. status: 1,
  42. list: [],
  43. currentPage: 1
  44. })
  45. this.getList()
  46. },
  47. async getList(isScroll) {
  48. if (!wx.getStorageSync('loginAccountId')) {
  49. wx.showToast({
  50. title: '尚未登录',
  51. icon: "error"
  52. })
  53. return
  54. }
  55. this.setData({
  56. isFreshing: true
  57. })
  58. let url
  59. if (this.data.maintab == 3 && this.data.status == 2) {
  60. url = '/voyage/wx/lab/list'
  61. } else {
  62. url = this.data.apiArr[this.data.maintab - 1]
  63. }
  64. let res = await postApi(url, {
  65. loginAccountId: wx.getStorageSync('loginAccountId'),
  66. // cargoOwnerId: this.data.cargoOwnerId,
  67. term: this.data.term,
  68. status: this.data.status,
  69. currentPage: this.data.currentPage,
  70. size: this.data.size,
  71. })
  72. this.setData({
  73. currentPage: this.data.currentPage,
  74. isFreshing: false
  75. })
  76. if (res.data.status == 0) {
  77. if (isScroll) {
  78. this.setData({
  79. list: [...this.data.list, ...res.data.result],
  80. total: res.data.total
  81. })
  82. } else {
  83. this.setData({
  84. list: res.data.result,
  85. total: res.data.total
  86. })
  87. }
  88. } else {
  89. this.setData({
  90. list: [],
  91. total: 0
  92. })
  93. wx.showToast({
  94. icon: "none",
  95. title: res.data.msg,
  96. })
  97. }
  98. },
  99. async getLabList(isScroll) {
  100. if (!wx.getStorageSync('loginAccountId')) {
  101. wx.showToast({
  102. title: '尚未登录',
  103. icon: "error"
  104. })
  105. return
  106. }
  107. this.setData({
  108. isFreshing: true
  109. })
  110. let res = await postApi('/voyage/wx/lab/list', {
  111. loginAccountId: wx.getStorageSync('loginAccountId'),
  112. term: this.data.term,
  113. currentPage: this.data.currentPage,
  114. size: this.data.size,
  115. })
  116. this.setData({
  117. currentPage: this.data.currentPage,
  118. isFreshing: false
  119. })
  120. if (res.data.status == 0) {
  121. if (isScroll) {
  122. this.setData({
  123. list: [...this.data.list, ...res.data.result],
  124. total: res.data.total
  125. })
  126. } else {
  127. this.setData({
  128. list: res.data.result,
  129. total: res.data.total
  130. })
  131. }
  132. } else {
  133. this.setData({
  134. list: [],
  135. total: 0
  136. })
  137. wx.showToast({
  138. icon: "none",
  139. title: res.data.msg,
  140. })
  141. }
  142. },
  143. changeStatus(e) {
  144. let {
  145. status,
  146. islab
  147. } = e.currentTarget.dataset
  148. this.setData({
  149. status,
  150. currentPage: 1,
  151. size: 20,
  152. total: 0
  153. })
  154. this.getList()
  155. return
  156. if (islab) {
  157. this.getLabList()
  158. } else {
  159. this.getList()
  160. }
  161. },
  162. goToDetail(e) {
  163. let {
  164. id,
  165. trans
  166. } = e.currentTarget.dataset
  167. let url = ''
  168. switch (this.data.maintab) {
  169. case 1: {
  170. url = `/pages/voyages/detail/detail?id=${id}`
  171. break
  172. }
  173. case 2: {
  174. if (this.data.status == 2) {
  175. wx.showToast({
  176. title: '请联系船东拍照',
  177. icon: "error"
  178. })
  179. return
  180. }
  181. url = `/pages/voyageManage/myDaily/myDaily?id=${id}&trans=${trans}`
  182. // let {
  183. // medias,
  184. // trans,
  185. // index
  186. // } = e.currentTarget.dataset
  187. // if (medias.length == 1) {
  188. // app.globalData.currentExamineMedia = medias[0]
  189. // url = `/pages/voyageManage/myDaily/examine/examine?id=${id}&trans=${trans}`
  190. // } else {
  191. // url = `/pages/voyageManage/myDaily/myDaily?id=${id}&trans=${trans}`
  192. // }
  193. break
  194. }
  195. case 3: {
  196. if (this.data.status == 1) {
  197. let {
  198. index
  199. } = e.currentTarget.dataset
  200. if (this.data.list[index].shipownerUploadFiles.length == 1) {
  201. this.data.list[index].shipownerUploadFiles[0].checked = true
  202. app.globalData.currentBillItem = this.data.list[index]
  203. url = `/pages/voyageManage/myBills/examine/examine?id=${id}`
  204. } else {
  205. app.globalData.currentBillItem = this.data.list[index]
  206. url = `/pages/voyageManage/myBills/myBills?id=${id}`
  207. }
  208. } else {
  209. url = `/pages/voyageManage/myBills/myLab/myLab?id=${id}`
  210. }
  211. break
  212. }
  213. }
  214. wx.navigateTo({
  215. url
  216. })
  217. },
  218. scrollList() {
  219. if (this.data.total == 0 || this.data.total <= this.data.size * this.data.currentPage) return
  220. this.data.currentPage += 1
  221. this.getList(true)
  222. },
  223. scrollDownList() {
  224. this.setData({
  225. total: 0,
  226. currentPage: 1,
  227. list: []
  228. })
  229. this.getList()
  230. },
  231. call(e) {
  232. wx.makePhoneCall({
  233. phoneNumber: e.currentTarget.dataset.phone
  234. })
  235. },
  236. inputSearch(e) {
  237. this.setData({
  238. currentPage: 1
  239. })
  240. this.getList()
  241. },
  242. onLoad(option) {
  243. },
  244. onShow(option) {
  245. this.setData({
  246. loginAccountId: wx.getStorageSync('loginAccountId')
  247. })
  248. this.getList()
  249. }
  250. })