voyageManage.js 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  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: 1,
  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. console.log(this.data.maintab, this.data.status)
  60. if (this.data.maintab == 3 && this.data.status == 2) {
  61. url = '/voyage/wx/lab/list'
  62. } else {
  63. url = this.data.apiArr[this.data.maintab - 1]
  64. }
  65. let res = await postApi(url, {
  66. loginAccountId: wx.getStorageSync('loginAccountId'),
  67. // cargoOwnerId: this.data.cargoOwnerId,
  68. term: this.data.term,
  69. status: this.data.status,
  70. currentPage: this.data.currentPage,
  71. size: this.data.size,
  72. })
  73. this.setData({
  74. currentPage: this.data.currentPage,
  75. isFreshing: false
  76. })
  77. if (res.data.status == 0) {
  78. if (isScroll) {
  79. this.setData({
  80. list: [...this.data.list, ...res.data.result],
  81. total: res.data.total
  82. })
  83. } else {
  84. this.setData({
  85. list: res.data.result,
  86. total: res.data.total
  87. })
  88. }
  89. } else {
  90. this.setData({
  91. list: [],
  92. total: 0
  93. })
  94. wx.showToast({
  95. icon: "none",
  96. title: res.data.msg,
  97. })
  98. }
  99. },
  100. async getLabList(isScroll) {
  101. if (!wx.getStorageSync('loginAccountId')) {
  102. wx.showToast({
  103. title: '尚未登录',
  104. icon: "error"
  105. })
  106. return
  107. }
  108. this.setData({
  109. isFreshing: true
  110. })
  111. let res = await postApi('/voyage/wx/lab/list', {
  112. loginAccountId: wx.getStorageSync('loginAccountId'),
  113. term: this.data.term,
  114. currentPage: this.data.currentPage,
  115. size: this.data.size,
  116. })
  117. this.setData({
  118. currentPage: this.data.currentPage,
  119. isFreshing: false
  120. })
  121. if (res.data.status == 0) {
  122. if (isScroll) {
  123. this.setData({
  124. list: [...this.data.list, ...res.data.result],
  125. total: res.data.total
  126. })
  127. } else {
  128. this.setData({
  129. list: res.data.result,
  130. total: res.data.total
  131. })
  132. }
  133. } else {
  134. this.setData({
  135. list: [],
  136. total: 0
  137. })
  138. wx.showToast({
  139. icon: "none",
  140. title: res.data.msg,
  141. })
  142. }
  143. },
  144. changeStatus(e) {
  145. let {
  146. status,
  147. islab
  148. } = e.currentTarget.dataset
  149. this.setData({
  150. status,
  151. currentPage: 1,
  152. size: 20,
  153. total: 0
  154. })
  155. this.getList()
  156. return
  157. if (islab) {
  158. this.getLabList()
  159. } else {
  160. this.getList()
  161. }
  162. },
  163. goToDetail(e) {
  164. let {
  165. id,
  166. trans
  167. } = e.currentTarget.dataset
  168. let url = ''
  169. switch (this.data.maintab) {
  170. case 1: {
  171. url = `/pages/voyages/detail/detail?id=${id}`
  172. break
  173. }
  174. case 2: {
  175. if (this.data.status == 2) {
  176. wx.showToast({
  177. title: '请联系船东拍照',
  178. icon: "error"
  179. })
  180. return
  181. }
  182. url = `/pages/voyageManage/myDaily/myDaily?id=${id}&trans=${trans}`
  183. // let {
  184. // medias,
  185. // trans,
  186. // index
  187. // } = e.currentTarget.dataset
  188. // if (medias.length == 1) {
  189. // app.globalData.currentExamineMedia = medias[0]
  190. // url = `/pages/voyageManage/myDaily/examine/examine?id=${id}&trans=${trans}`
  191. // } else {
  192. // url = `/pages/voyageManage/myDaily/myDaily?id=${id}&trans=${trans}`
  193. // }
  194. break
  195. }
  196. case 3: {
  197. if (this.data.status == 1) {
  198. let {
  199. index
  200. } = e.currentTarget.dataset
  201. if (this.data.list[index].shipownerUploadFiles.length == 1) {
  202. this.data.list[index].shipownerUploadFiles[0].checked = true
  203. app.globalData.currentBillItem = this.data.list[index]
  204. url = `/pages/voyageManage/myBills/examine/examine?id=${id}`
  205. } else {
  206. app.globalData.currentBillItem = this.data.list[index]
  207. url = `/pages/voyageManage/myBills/myBills?id=${id}`
  208. }
  209. } else {
  210. url = `/pages/voyageManage/myBills/myLab/myLab?id=${id}`
  211. }
  212. break
  213. }
  214. }
  215. wx.navigateTo({
  216. url
  217. })
  218. },
  219. scrollList() {
  220. if (this.data.total == 0 || this.data.total <= this.data.size * this.data.currentPage) return
  221. this.data.currentPage += 1
  222. this.getList(true)
  223. },
  224. scrollDownList() {
  225. this.setData({
  226. total: 0,
  227. currentPage: 1,
  228. list: []
  229. })
  230. this.getList()
  231. },
  232. call(e) {
  233. wx.makePhoneCall({
  234. phoneNumber: e.currentTarget.dataset.phone
  235. })
  236. },
  237. inputSearch(e) {
  238. this.setData({
  239. currentPage: 1
  240. })
  241. this.getList()
  242. },
  243. onLoad() {
  244. },
  245. onShow() {
  246. this.setData({
  247. maintab: app.globalData.maintab || 1,
  248. todayDate: datetimeFormat("年月月日日"),
  249. loginAccountId: wx.getStorageSync('loginAccountId')
  250. })
  251. this.getList()
  252. }
  253. })