Pārlūkot izejas kodu

新增 航次管理

wzh 3 gadi atpakaļ
vecāks
revīzija
ffcc33c8cd

+ 3 - 1
miniprogram/app.wxss

@@ -4,7 +4,9 @@ scroll-view,
 cover-view,
 input,
 picker {
-  box-sizing: border-box
+  box-sizing: border-box;
+  color: #333;
+  background: #fff;
 }
 
 .tac {

+ 4 - 0
miniprogram/components/remotePicker/remotePicker.js

@@ -9,6 +9,9 @@ Component({
     },
     params: {
       type: Object
+    },
+    inputStyle: {
+      type: String
     }
   },
   data: {
@@ -50,6 +53,7 @@ Component({
       })
     },
     _clear() {
+      if (this.data.value) return
       this.setData({
         label: ''
       })

+ 1 - 1
miniprogram/components/remotePicker/remotePicker.wxml

@@ -1,6 +1,6 @@
 <!--components/remotePicker/remotePicker.wxml-->
 <view bindtap="_handlerOne" capture-bind:tap="_handlerOne">
-  <input model:value="{{label}}" confirm-type="search" type="text" placeholder="模糊搜索" bindconfirm="_getList" class="remote-picker-input" />
+  <input model:value="{{label}}" confirm-type="search" type="text" placeholder="模糊搜索" bindconfirm="_getList" bindblur="_clear" class="remote-picker-input" style="{{inputStyle}}" />
   <view style="position: relative;">
     <scroll-view wx:if="{{arr.length}}" scroll-y="true" class="scroll">
       <view class="items" wx:for="{{arr}}" bindtap="_selectItem" data-label="{{item.value}}" data-value="{{item.key}}">

+ 0 - 1
miniprogram/pages/voyageManage/createVoyage/createVoyage.wxml

@@ -53,6 +53,5 @@
       </view>
     </picker>
   </view>
-
   <view bindtap="createVoyage" class="next">创建航次</view>
 </view>

+ 0 - 3
miniprogram/pages/voyageManage/myBills/myBills.json

@@ -1,3 +0,0 @@
-{
-  "usingComponents": {}
-}

+ 0 - 1
miniprogram/pages/voyageManage/myBills/myBills.wxss

@@ -1 +0,0 @@
-/* pages/voyageManage/myBills/myBills.wxss */

+ 0 - 3
miniprogram/pages/voyageManage/myDaily/myDaily.json

@@ -1,3 +0,0 @@
-{
-  "usingComponents": {}
-}

+ 0 - 1
miniprogram/pages/voyageManage/myDaily/myDaily.wxss

@@ -1 +0,0 @@
-/* pages/voyageManage/myDaily/myDaily.wxss */

+ 0 - 3
miniprogram/pages/voyageManage/myVoyages/myVoyages.json

@@ -1,3 +0,0 @@
-{
-  "usingComponents": {}
-}

+ 0 - 1
miniprogram/pages/voyageManage/myVoyages/myVoyages.wxss

@@ -1 +0,0 @@
-/* pages/voyageManage/myVoyages/myVoyages.wxss */

+ 99 - 53
miniprogram/pages/voyageManage/voyageManage.js

@@ -1,66 +1,112 @@
-// pages/voyageManage/voyageManage.js
-Page({
+const {
+  postApi
+} = require("../../apis/api")
 
-  /**
-   * 页面的初始数据
-   */
+Page({
   data: {
-
+    cargoOwnerId: 0,
+    defaultParams: {
+      loginAccountId: wx.getStorageSync('loginAccountId')
+    },
+    maintab: 1,
+    status: 1,
+    currentPage: 1,
+    size: 20,
+    list: [],
+    total: 0,
+    isFreshing: false,
+    currentApi: "/voyage/list"
   },
-
-  /**
-   * 生命周期函数--监听页面加载
-   */
-  onLoad(options) {
-
+  selectCargoOwner(e) {
+    this.setData({
+      cargoOwnerId: e.detail.value,
+      list: [],
+      currentPage: 1,
+    })
+    this.getList()
   },
-
-  /**
-   * 生命周期函数--监听页面初次渲染完成
-   */
-  onReady() {
-
+  changeMainTab(e) {
+    this.setData({
+      maintab: e.currentTarget.dataset.maintab,
+      currentApi: e.currentTarget.dataset.api,
+      status: 1,
+      list: [],
+      currentPage: 1
+    })
+    if (!this.data.cargoOwnerId) return
+    this.getList()
   },
-
-  /**
-   * 生命周期函数--监听页面显示
-   */
-  onShow() {
-
+  async getList(isScroll) {
+    this.setData({
+      isFreshing: true
+    })
+    let res = await postApi(this.data.currentApi, {
+      loginAccountId: wx.getStorageSync('loginAccountId'),
+      status: this.data.status,
+      currentPage: this.data.currentPage,
+      size: this.data.size,
+    })
+    this.setData({
+      currentPage: this.data.currentPage,
+      isFreshing: false
+    })
+    if (res.data.status == 0) {
+      if (isScroll) {
+        this.setData({
+          list: [...this.data.list, ...res.data.result],
+          total: res.data.total
+        })
+      } else {
+        this.setData({
+          list: res.data.result,
+          total: res.data.total
+        })
+      }
+    } else {
+      this.setData({
+        list: [],
+        total: 0
+      })
+      wx.showToast({
+        icon: "none",
+        title: res.data.msg,
+      })
+    }
   },
-
-  /**
-   * 生命周期函数--监听页面隐藏
-   */
-  onHide() {
-
+  changeStatus(e) {
+    let {
+      status
+    } = e.currentTarget.dataset
+    this.setData({
+      status,
+      currentPage: 1,
+      size: 20,
+      total: 0
+    })
+    this.getList()
   },
-
-  /**
-   * 生命周期函数--监听页面卸载
-   */
-  onUnload() {
-
+  goToDetail(e) {
+    let {
+      id
+    } = e.currentTarget.dataset
+    wx.navigateTo({
+      url: `/pages/voyages/detail/detail?id=${id}`,
+    })
   },
-
-  /**
-   * 页面相关事件处理函数--监听用户下拉动作
-   */
-  onPullDownRefresh() {
-
+  scrollList() {
+    if (this.data.total == 0 || this.data.total <= this.data.size * this.data.currentPage) return
+    this.data.currentPage += 1
+    this.getList(true)
   },
-
-  /**
-   * 页面上拉触底事件的处理函数
-   */
-  onReachBottom() {
-
+  scrollDownList() {
+    this.setData({
+      total: 0,
+      currentPage: 1,
+      list: []
+    })
+    this.getList()
   },
-
-  /**
-   * 用户点击右上角分享
-   */
-  onShareAppMessage() {
+  onLoad() {
 
   }
 })

+ 5 - 1
miniprogram/pages/voyageManage/voyageManage.json

@@ -1,3 +1,7 @@
 {
-  "usingComponents": {}
+  "usingComponents": {
+    "RemotePicker": "/components/remotePicker/remotePicker"
+  },
+  "navigationBarTitleText": "我的航次",
+  "disableScroll": true
 }

+ 28 - 2
miniprogram/pages/voyageManage/voyageManage.wxml

@@ -1,2 +1,28 @@
-<!--pages/voyageManage/voyageManage.wxml-->
-<text>pages/voyageManage/voyageManage.wxml</text>
+<view class="df aic jcsb line">
+  <view>选择货主</view>
+  <view>
+    <RemotePicker bind:selectItem="selectCargoOwner" url="/user/cargoOwner/select" params="{{defaultParams}}" inputStyle="height:60rpx"></RemotePicker>
+  </view>
+</view>
+<block wx:if="{{cargoOwnerId}}">
+  <view class="df aic jcsa tabs" wx:if="{{maintab!=3}}">
+    <view class="tabsview" bindtap="changeStatus" data-status="{{1}}" style="color:{{status==1?'#0d8fcc':''}};border-bottom:{{status==1?'4rpx solid #0d8fcc':''}}">{{maintab==1?'执行中':'已拍照'}}</view>
+    <view class="tabsview" bindtap="changeStatus" data-status="{{2}}" style="color:{{status==2?'#0d8fcc':''}};border-bottom:{{status==2?'4rpx solid #0d8fcc':''}}">{{maintab==1?'历史航次':'未拍照'}}</view>
+  </view>
+  <scroll-view bindrefresherrefresh="scrollDownList" refresher-triggered="{{isFreshing}}" refresher-enabled="{{true}}" scroll-y="true" style="height:calc(100vh - {{height}}rpx);background: #fff;">
+    <view class="df aic jcsb list" wx:for="{{list}}" wx:key="index" data-id="{{item.id}}" bindtap="goToDetail">
+      <view class="col-1">{{item.shipName}}</view>
+      <view class="col-2">{{item.loadPort}}-{{item.discPort}}</view>
+      <view class="col-3">{{item.cargo}}</view>
+      <view class="col-4">{{item.transStatusName}}</view>
+    </view>
+    <view bindtap="scrollList" class="bottom-text">{{total==0?'暂无数据':(total>size*currentPage?'点击或滑动加载更多...':'已加载完毕')}}</view>
+  </scroll-view>
+</block>
+<view style="position: fixed;bottom: 0;">
+  <view class="bottom-tabs df aic tac">
+    <view bindtap="changeMainTab" data-maintab="{{1}}" class="maintab1" style="color:{{maintab==1?'#fff':''}};background:{{maintab==1?'#0094FE':''}}" data-api="/voyage/list">我的航次</view>
+    <view bindtap="changeMainTab" data-maintab="{{2}}" class="maintab2" style="color:{{maintab==2?'#fff':'/dayReport/list'}};background:{{maintab==2?'#0094FE':''}}" data-api="/dayReport/list">我的日报</view>
+    <view bindtap="changeMainTab" data-maintab="{{3}}" class="maintab3" style="color:{{maintab==3?'#fff':''}};background:{{maintab==3?'#0094FE':''}}" data-api="/bill/list">我的单据</view>
+  </view>
+</view>

+ 93 - 1
miniprogram/pages/voyageManage/voyageManage.wxss

@@ -1 +1,93 @@
-/* pages/voyageManage/voyageManage.wxss */
+/* pages/voyageManage/voyageManage.wxss */
+
+.line {
+  width: 80%;
+  margin: 30rpx auto;
+  font-size: 28rpx;
+  position: relative;
+}
+
+.bottom-tabs>view {
+  height: 90rpx;
+  border-top: 1rpx solid grey;
+  border-bottom: 1rpx solid grey;
+  line-height: 86rpx;
+  font-size: 27rpx;
+}
+
+.current-bottom-tab {
+  background: #0094FE;
+  color: #fff;
+  border: none;
+}
+
+.maintab1 {
+  width: 33vw;
+  border-left: none;
+}
+
+.maintab2 {
+  width: 34vw;
+  border-left: 1rpx solid grey;
+  border-right: 1rpx solid grey;
+}
+
+.maintab3 {
+  width: 33vw;
+  border-right: none;
+}
+
+/* --- */
+
+.tabs {
+  width: 100%;
+  height: 80rpx;
+  background: #fff;
+  box-shadow: rgb(209, 206, 206) 5rpx 5rpx 10rpx;
+  border-bottom: 2rpx solid grey;
+  font-size: 28rpx;
+}
+
+.tabsview {
+  width: 120rpx;
+  height: 50rpx;
+  text-align: center;
+}
+
+.p10 {
+  padding: 10rpx 20rpx;
+}
+
+.m30a {
+  margin: 30rpx auto;
+}
+
+.list {
+  padding: 30rpx;
+  font-size: 28rpx;
+}
+
+.col-1 {
+  width: 29vw;
+}
+
+.col-2 {
+  width: 29vw;
+}
+
+
+.col-3 {
+  width: 13vw;
+}
+
+.col-4 {
+  width: 15vw;
+}
+
+.bottom-text {
+  text-align: center;
+  padding-top: 30rpx;
+  padding-bottom: 50rpx;
+  font-size: 26rpx;
+  color: #777;
+}

+ 2 - 1
miniprogram/pages/voyages/detail/detail.json

@@ -1,3 +1,4 @@
 {
-  "usingComponents": {}
+  "usingComponents": {},
+  "navigationBarTitleText": "航次详情"
 }

+ 7 - 0
project.private.config.json

@@ -71,6 +71,13 @@
           "query": "",
           "launchMode": "default",
           "scene": null
+        },
+        {
+          "name": "",
+          "pathName": "pages/voyages/detail/detail",
+          "query": "id=169",
+          "launchMode": "default",
+          "scene": null
         }
       ]
     }