voyageManage.js 5.5 KB

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