voyageManage.js 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294
  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. this.setData({
  54. list: [{
  55. shipName: '体验航次 #1',
  56. loadPort: '南京',
  57. discPort: "小池",
  58. cargo: '石油焦',
  59. tons: '10000',
  60. }, {
  61. shipName: '体验航次 #2',
  62. loadPort: '小池',
  63. discPort: "武汉",
  64. cargo: '豆粕',
  65. tons: '15000',
  66. }, {
  67. shipName: '体验航次 #3',
  68. loadPort: '北仑港',
  69. discPort: "小池",
  70. cargo: '煤炭',
  71. tons: '25000',
  72. }, {
  73. shipName: '体验航次 #4',
  74. loadPort: '张家港',
  75. discPort: "汉口",
  76. cargo: '玉米',
  77. tons: '15000',
  78. }, {
  79. shipName: '体验航次 #5',
  80. loadPort: '武汉',
  81. discPort: "小池",
  82. cargo: '大豆',
  83. tons: '3000',
  84. }],
  85. })
  86. return
  87. }
  88. this.setData({
  89. isFreshing: true
  90. })
  91. let url
  92. if (this.data.maintab == 3 && this.data.status == 2) {
  93. url = '/voyage/wx/lab/list'
  94. } else {
  95. url = this.data.apiArr[this.data.maintab - 1]
  96. }
  97. let res = await postApi(url, {
  98. loginAccountId: wx.getStorageSync('loginAccountId'),
  99. // cargoOwnerId: this.data.cargoOwnerId,
  100. term: this.data.term,
  101. status: this.data.status,
  102. currentPage: this.data.currentPage,
  103. size: this.data.size,
  104. })
  105. this.setData({
  106. currentPage: this.data.currentPage,
  107. isFreshing: false
  108. })
  109. if (res.data.status == 0) {
  110. if (isScroll) {
  111. this.setData({
  112. list: [...this.data.list, ...res.data.result],
  113. total: res.data.total
  114. })
  115. } else {
  116. this.setData({
  117. list: res.data.result,
  118. total: res.data.total
  119. })
  120. }
  121. } else {
  122. this.setData({
  123. list: [],
  124. total: 0
  125. })
  126. wx.showToast({
  127. icon: "none",
  128. title: res.data.msg,
  129. })
  130. }
  131. },
  132. async getLabList(isScroll) {
  133. if (!wx.getStorageSync('loginAccountId')) {
  134. wx.showToast({
  135. title: '尚未登录',
  136. icon: "error"
  137. })
  138. return
  139. }
  140. this.setData({
  141. isFreshing: true
  142. })
  143. let res = await postApi('/voyage/wx/lab/list', {
  144. loginAccountId: wx.getStorageSync('loginAccountId'),
  145. term: this.data.term,
  146. currentPage: this.data.currentPage,
  147. size: this.data.size,
  148. })
  149. this.setData({
  150. currentPage: this.data.currentPage,
  151. isFreshing: false
  152. })
  153. if (res.data.status == 0) {
  154. if (isScroll) {
  155. this.setData({
  156. list: [...this.data.list, ...res.data.result],
  157. total: res.data.total
  158. })
  159. } else {
  160. this.setData({
  161. list: res.data.result,
  162. total: res.data.total
  163. })
  164. }
  165. } else {
  166. this.setData({
  167. list: [],
  168. total: 0
  169. })
  170. wx.showToast({
  171. icon: "none",
  172. title: res.data.msg,
  173. })
  174. }
  175. },
  176. changeStatus(e) {
  177. let {
  178. status,
  179. islab
  180. } = e.currentTarget.dataset
  181. this.setData({
  182. status,
  183. currentPage: 1,
  184. size: 20,
  185. total: 0
  186. })
  187. this.getList()
  188. return
  189. if (islab) {
  190. this.getLabList()
  191. } else {
  192. this.getList()
  193. }
  194. },
  195. goToDetail(e) {
  196. if (!wx.getStorageSync('loginAccountId')) return
  197. let {
  198. id,
  199. trans
  200. } = e.currentTarget.dataset
  201. let url = ''
  202. switch (this.data.maintab) {
  203. case 1: {
  204. url = `/pages/voyages/detail/detail?id=${id}`
  205. break
  206. }
  207. case 2: {
  208. if (this.data.status == 2) {
  209. wx.showToast({
  210. title: '请联系船东拍照',
  211. icon: "error"
  212. })
  213. return
  214. }
  215. url = `/pages/voyageManage/myDaily/myDaily?id=${id}&trans=${trans}`
  216. // let {
  217. // medias,
  218. // trans,
  219. // index
  220. // } = e.currentTarget.dataset
  221. // if (medias.length == 1) {
  222. // app.globalData.currentExamineMedia = medias[0]
  223. // url = `/pages/voyageManage/myDaily/examine/examine?id=${id}&trans=${trans}`
  224. // } else {
  225. // url = `/pages/voyageManage/myDaily/myDaily?id=${id}&trans=${trans}`
  226. // }
  227. break
  228. }
  229. case 3: {
  230. if (this.data.status == 1) {
  231. let {
  232. index
  233. } = e.currentTarget.dataset
  234. if (this.data.list[index].shipownerUploadFiles.length == 1) {
  235. this.data.list[index].shipownerUploadFiles[0].checked = true
  236. app.globalData.currentBillItem = this.data.list[index]
  237. url = `/pages/voyageManage/myBills/examine/examine?id=${id}`
  238. } else {
  239. app.globalData.currentBillItem = this.data.list[index]
  240. url = `/pages/voyageManage/myBills/myBills?id=${id}`
  241. }
  242. } else {
  243. url = `/pages/voyageManage/myBills/myLab/myLab?id=${id}`
  244. }
  245. break
  246. }
  247. }
  248. wx.navigateTo({
  249. url
  250. })
  251. },
  252. scrollList() {
  253. if (this.data.total == 0 || this.data.total <= this.data.size * this.data.currentPage) return
  254. this.data.currentPage += 1
  255. this.getList(true)
  256. },
  257. scrollDownList() {
  258. this.setData({
  259. total: 0,
  260. currentPage: 1,
  261. list: []
  262. })
  263. this.getList()
  264. },
  265. call(e) {
  266. if (!wx.getStorageSync('loginAccountId')) return
  267. wx.makePhoneCall({
  268. phoneNumber: e.currentTarget.dataset.phone
  269. })
  270. },
  271. inputSearch(e) {
  272. this.setData({
  273. currentPage: 1
  274. })
  275. this.getList()
  276. },
  277. onLoad(option) {
  278. },
  279. onShow(option) {
  280. this.setData({
  281. maintab: app.globalData.maintab || 1,
  282. todayDate: datetimeFormat("年月月日日"),
  283. loginAccountId: wx.getStorageSync('loginAccountId')
  284. })
  285. this.getList()
  286. }
  287. })