pad-app/pages/index/index.vue

338 lines
7.9 KiB
Vue

<template>
<view class="app">
<head-info :navIndex="0"></head-info>
<view class="container">
<view class="content">
<view class="form">
<view class="end">
<superwei-combox class="input" :candidates="tradeList" :isJSON="true" keyName="name"
placeholder="请选择贸易类型" v-model="tradeName" @select="tradeSelect"></superwei-combox>
</uni-easyinput>
<superwei-combox class="input" :candidates="shipList" :isJSON="true" keyName="vvyShip"
placeholder="请选择船名/航次" v-model="vvyShip" @select="shipSelect"></superwei-combox>
</uni-easyinput>
<button class="btn" @click="onSearch">搜索</button>
</view>
</view>
<view class="itemList">
<template v-if="itemList.length > 0">
<view v-for="(item, index) in itemList" :key="index" class="item">
<view @click="toDetails(item)">
<view class="title">
<view class="titleft">
<image src="../../static/images/ship.png" mode="widthFix"></image>
<view class="name">
{{item.spmIdDesc}}
</view>
</view>
<view class="status">
<text v-if="item.vvyStatus==0" class="nStarted">● {{item.vvyStatusName}}</text>
<text v-if="item.vvyStatus==1" class="green">● {{item.vvyStatusName}}</text>
<text v-if="item.vvyStatus==2" class="complete">● {{item.vvyStatusName}}</text>
</view>
</view>
<view class="row">
<view class="nitem">
航次: <text>{{item.vvyName}}</text>
</view>
<view class="nitem">
贸易类型: <text>{{item.tradeType}}</text>
</view>
</view>
<view class="row">
<view class="nitem">
进出口: <text>{{item.importExportFlag}}</text>
</view>
<view class="nitem">
泊位: <text>{{item.actualBerthageDesc}}</text>
</view>
</view>
</view>
</view>
</template>
<o-empty v-else height="70vh" bg="#f5f6fa" />
</view>
<view class="pageBox" v-if="itemList.length > 0">
<uni-pagination :show-icon="true" :total="total" :pageSize="pageSize" :current="current"
@change="changePage" />
</view>
</view>
</view>
</view>
</template>
<script>
import HeadInfo from '@/components/head-info/head-info';
import api from "../../common/api.js"
let timers = null;
export default {
data() {
return {
loginObj: {},
itemList: [],
tradeName: "外贸",
tradeType: "W",
tradeItem: {},
tradeList: [{
value: "1",
name: "内贸"
},
{
value: "2",
name: "外贸"
}
],
vvyShip: "",
vvyId: "",
shipId: "",
shipName: '',
shipList: [],
// 分页
total: 0,
pageSize: 6,
current: 1,
// 港区信息
portObj: {}
}
},
onLoad() {
this.portObj = uni.getStorageSync('portObj')
this.loginObj = uni.getStorageSync('loginObj')
this.getShip()
},
onBackPress(options) {
// 触发返回就会调用此方法,这里实现的是禁用物理返回,顶部导航栏的自定义返回 uni.navigateBack 仍可使用
if (options.from == 'backbutton') {
return true;
} else if (options.from == 'navigateBack') {
return false;
}
},
components: {
HeadInfo
},
mounted() {
this.initData()
},
methods: {
// 切换贸易类型
tradeSelect(e) {
this.tradeItem = e
this.tradeName = e.name
this.shipId = ""
this.shipName = ""
this.vvyId = ""
this.vvyShip = ""
this.getShip()
},
// 选择船
shipSelect(e) {
this.shipId = e.spmId
this.shipName = e.vslCnname
this.vvyId = e.vvyId
this.vvyShip = e.vvyShip
},
// 获取船舶
getShip() {
if (this.tradeName == '外贸') {
this.tradeType = "W"
} else {
this.tradeType = "N"
}
let ieType = "E"
let key = ""
let spmId = ""
uni.request({
url: `${this.$local}/api/shipInstructions/queryByKey?ieType=${ieType}&key=${ieType}&pamId=${this.portObj.portId}&spmId=${spmId}&tradeType=${this.tradeType}`,
header: {
'Content-Type': 'application/json', //自定义请求头信息
'Authorization': `Bearer ${this.loginObj.access_token}`
},
method: 'GET', //请求方式,必须为大写
success: (res) => {
if (res.data.status == "200") {
this.shipList = res.data.data
this.shipList.forEach(v => {
let vvyShip = `${v.vslCnname}/${v.vvyName}`
this.$set(v, "vvyShip", vvyShip)
})
}
}
})
},
// 点击搜索
onSearch() {
this.initData()
},
initData() {
let url = ""
if (this.tradeName == '内贸') {
url =
`${this.$local}/api/domestic/load/command/queryLoadVoyages?pamId=${this.portObj.portId}&vvyId=${this.vvyId}&size=${this.pageSize}&current=${this.current}`
} else if (this.tradeName == '外贸') {
url =
`${this.$local}/api/shipInstructions/queryStowageVoyages?pamId=${this.portObj.portId}&vvyId=${this.vvyId}&tradeType=${this.tradeType}&size=${this.pageSize}&current=${this.current}`
}
uni.request({
url: url,
header: {
'Content-Type': 'application/json', //自定义请求头信息
'Authorization': `Bearer ${this.loginObj.access_token}`
},
method: 'GET', //请求方式,必须为大写
success: (res) => {
console.log(res)
this.total = res.data.data.total
this.itemList = res.data.data.records
}
})
},
// 点击分页
changePage(e) {
this.current = e.current;
this.initData()
},
toDetails(item) {
let obj = {
shipInfo: item,
}
const params = encodeURIComponent(JSON.stringify(obj));
if (this.tradeName == '外贸') {
uni.navigateTo({
url: '/pages/index/instruct?params=' + params
})
} else {
uni.navigateTo({
url: '/pages/index/domesticTrade?params=' + params
})
}
},
}
};
</script>
<style lang="less" scoped>
.container {
display: flex;
}
.content {
flex: 1;
padding: 20px;
min-height: calc(100vh - 68px - 40px);
.form {
display: flex;
justify-content: flex-end;
.end {
display: flex;
justify-content: space-between;
.input {
width: 200px;
height: 35px;
line-height: 35px;
padding-left: 10px;
margin-right: 15px;
}
.btn {
height: 35px;
line-height: 35px;
margin-left: 0;
font-size: 16px;
color: #fff;
background-color: #0067CF;
margin-right: 10px;
}
}
}
.itemList {
width: 100%;
display: flex;
justify-content: flex-start;
flex-wrap: wrap;
position: relative;
/deep/.o-empty {
width: 100%;
margin-top: 15px;
}
.item {
width: 32%;
margin-top: 15px;
margin-right: 2%;
background-color: #fff;
border-radius: 8px;
padding: 20px;
position: relative;
.title {
display: flex;
padding: 10px 0;
justify-content: space-between;
.titleft {
display: flex;
}
image {
width: 32px;
height: 32px;
margin-right: 12px;
}
.name {
margin-top: 5px;
font-size: 16px;
color: #23262E;
font-weight: bold;
}
}
.row {
display: flex;
justify-content: space-between;
font-size: 14px;
padding: 10px 0;
font-size: 16px;
.nitem {
width: 46%;
.text {
color: #929292;
}
}
}
.status {
margin-top: 5px;
font-size: 16px;
.nStarted {
color: #bbb;
}
.complete {
color: #0067CF;
}
}
}
.item:nth-child(3n) {
margin-right: 0;
}
}
.pageBox {
margin-top: 20px;
}
}
</style>