pad-app/components/head-view/head-view.vue

265 lines
6.3 KiB
Vue
Raw Normal View History

2023-07-06 17:08:59 +08:00
<template>
<view class="headInfo">
2023-11-01 18:40:05 +08:00
<view>
2023-12-22 17:48:52 +08:00
<uni-icons class="icon" type="back" size="16" @click="toBack" />
2023-11-01 18:40:05 +08:00
<text @click="tabsPort('center')">{{title}}</text>
<uni-icons class="bottom" type="bottom" size="18" v-if="type" />
</view>
<uni-popup ref="popup" background-color="#fff">
<view class="popupBox">
<view class="popupTitle">
请选择船只
</view>
<view class="ul">
<view class="li" v-for="(item,index) in shipList" :key="index"
:class="{active:activeIndex == index}" @click="selectPort(item,index)">
<text>{{item.shipName}} 进口航次{{item.inVvyName}} / 出口航次{{item.outVvyName}}</text>
</view>
</view>
<view class="btnBox">
<button class="btn" type="primary" @click="toGo"> </button>
</view>
</view>
</uni-popup>
2023-07-06 17:08:59 +08:00
</view>
</template>
<script>
2023-11-01 18:40:05 +08:00
import sqlite from "../../common/sqlite.js"
2023-07-06 17:08:59 +08:00
export default {
name: "headView",
props: {
title: {
type: String
},
2023-08-24 16:22:29 +08:00
type: {
type: Boolean,
default: () => false
2023-08-24 17:06:35 +08:00
},
2023-09-23 20:16:54 +08:00
special: {
type: String,
default: () => ""
},
2023-08-24 17:06:35 +08:00
url: {
type: String,
default: () => ""
},
2023-07-06 17:08:59 +08:00
},
2023-11-01 18:40:05 +08:00
data() {
return {
shipList: [],
activeIndex: 0,
vtpId: "",
inVvyId: "",
inVvyName: "",
outVvyId: "",
outVvyName: "",
shipName: "",
}
},
mounted() {
this.vtpId = uni.getStorageSync('vtpId')
this.executeSql1("voyageScheduleDataDetailRespDTOList")
2023-12-08 17:42:10 +08:00
let that = this
setTimeout(function() {
that.shipList.forEach((v, index) => {
if (v.vtpId == that.vtpId) {
that.activeIndex = index
}
})
}, 100)
2023-11-01 18:40:05 +08:00
},
2023-07-06 17:08:59 +08:00
methods: {
2023-11-01 18:40:05 +08:00
// 船只
tabsPort(type) {
if (this.type) {
this.$refs.popup.open(type)
this.vtpId = this.shipList[0].vtpId
this.shipName = this.shipList[0].shipName
this.inVvyId = this.shipList[0].inVvyId
this.inVvyName = this.shipList[0].inVvyName
this.outVvyId = this.shipList[0].outVvyId
this.outVvyName = this.shipList[0].outVvyName
}
},
// 选择弹框内容
selectPort(item, index) {
this.activeIndex = index
this.vtpId = item.vtpId
this.shipName = item.shipName
this.inVvyId = item.inVvyId
this.inVvyName = item.inVvyName
this.outVvyId = item.outVvyId
this.outVvyName = item.outVvyName
},
// 点击确认
toGo() {
uni.setStorageSync('vtpId', this.vtpId)
this.$refs.popup.close()
this.title = `${this.shipName} 进口航次:${this.inVvyName} / 出口航次:${this.outVvyName}`
uni.setStorageSync('shipWorkTitle', this.title)
2023-12-08 17:42:10 +08:00
this.$emit("isPreview", this.title)
2023-11-01 18:40:05 +08:00
},
// 查
executeSql(sql) {
sqlite.executeSqlCeshi(sql).then((value) => {
value.forEach(v => {
2023-11-24 15:55:58 +08:00
this.inVvyId = ""
this.inVvyName = ""
this.outVvyId = ""
this.outVvyName = ""
2023-11-01 18:40:05 +08:00
if (v.importExportFlagName == '出口') {
this.outVvyId = v.vvyId
this.outVvyName = v.vvyName
2024-04-29 17:03:52 +08:00
} else {
this.inVvyId = v.vvyId
this.inVvyName = v.vvyName
2023-11-01 18:40:05 +08:00
}
let obj = {
inVvyId: this.inVvyId,
inVvyName: this.inVvyName,
outVvyId: this.outVvyId,
outVvyName: this.outVvyName,
shipName: v.spmName,
vtpId: v.vtpId
}
2023-12-08 17:42:10 +08:00
this.shipList.unshift(obj)
2023-11-01 18:40:05 +08:00
})
2023-12-08 17:42:10 +08:00
const array = this.shipList
const mergedArray = array.reduce((accumulator, currentValue) => {
const existingValue = accumulator.find(item => item.vtpId === currentValue.vtpId);
if (existingValue) {
// 如果找到了具有相同 vtpId 的元素,则合并它们的值
if (existingValue.inVvyId == "") {
existingValue.inVvyId = currentValue.inVvyId;
}
if (existingValue.inVvyName == "") {
existingValue.inVvyName = currentValue.inVvyName;
}
if (existingValue.outVvyId == "") {
existingValue.outVvyId = currentValue.outVvyId;
}
if (existingValue.outVvyName == "") {
existingValue.outVvyName = currentValue.outVvyName;
}
} else {
// 如果没有找到具有相同 vtpId 的元素,则将当前元素添加到 accumulator 中
accumulator.push(currentValue);
}
return accumulator;
}, []);
this.shipList = mergedArray
2023-11-01 18:40:05 +08:00
}).catch((error) => {
// 在reject时执行的回调函数
console.error(error);
});
},
executeSql1(tableName) {
let sql = `select * from ${tableName}`
this.executeSql(sql)
},
2023-07-06 17:08:59 +08:00
toBack() {
2023-08-24 17:06:35 +08:00
if (this.url != "") {
2023-12-22 17:48:52 +08:00
uni.redirectTo({
2023-08-24 17:06:35 +08:00
url: `${this.url}`
})
} else {
uni.navigateBack('-1')
}
2023-09-23 20:16:54 +08:00
if (this.special == 1) {
uni.setStorageSync('tabsType', 0);
}
2023-07-06 17:08:59 +08:00
}
}
}
</script>
2023-07-25 13:18:37 +08:00
<style lang="less" scoped>
2023-07-06 17:08:59 +08:00
.headInfo {
2023-11-01 18:40:05 +08:00
position: fixed;
top: 0;
left: 0;
2023-07-06 17:08:59 +08:00
background-color: #fff;
2023-11-01 18:40:05 +08:00
width: 100%;
2023-08-24 16:22:29 +08:00
height: 68px;
line-height: 68px;
font-size: 20px;
color: #23262E;
2023-07-06 17:08:59 +08:00
text-align: center;
2023-08-24 16:22:29 +08:00
font-weight: bold;
box-shadow: 0 2px 6px 0 rgba(0, 0, 0, 0.10);
2023-12-08 17:42:10 +08:00
z-index: 997;
2023-07-06 17:08:59 +08:00
.icon {
position: absolute;
2023-11-01 18:40:05 +08:00
left: 30px;
2023-07-06 17:08:59 +08:00
}
2023-08-24 16:22:29 +08:00
.bottom {
margin-left: 6px;
}
2023-11-01 18:40:05 +08:00
2023-12-22 17:48:52 +08:00
/deep/.uni-popup .uni-popup__wrapper {
border-radius: 8px;
}
2023-11-01 18:40:05 +08:00
.popupBox {
min-width: 500px;
.popupTitle {
width: 100%;
height: 48px;
line-height: 48px;
text-align: center;
font-size: 18px;
color: #23262E;
border-bottom: 1px solid #eee;
}
.ul {
padding: 30px;
2023-12-22 17:48:52 +08:00
max-height: 310px;
2023-11-01 18:40:05 +08:00
overflow: scroll;
.li {
2023-12-22 17:48:52 +08:00
height: 46px;
line-height: 46px;
2023-11-01 18:40:05 +08:00
text-align: center;
2023-12-22 17:48:52 +08:00
border: 1px solid #e7e7e7;
2023-11-01 18:40:05 +08:00
margin-bottom: 10px;
font-size: 14px;
2023-12-22 17:48:52 +08:00
border-radius: 4px;
2023-11-01 18:40:05 +08:00
}
.active {
color: #0079fe;
border-color: #0079fe;
}
}
.btnBox {
2023-12-22 17:48:52 +08:00
height: 46px;
2023-11-01 18:40:05 +08:00
display: flex;
justify-content: center;
box-shadow: 0 -3px 7px 0 rgba(0, 0, 0, 0.10);
border-radius: 0 0 16px 16px;
.btn {
width: 170px;
font-size: 16px;
padding: 10px;
2023-12-22 17:48:52 +08:00
margin: 5px;
2023-11-01 18:40:05 +08:00
height: 36px;
line-height: 18px;
background-color: #fff;
border: 1px solid rgba(0, 0, 0, .1);
}
.btn:last-child {
color: #fff;
background-color: #0067CF;
}
}
}
2023-07-06 17:08:59 +08:00
}
2023-07-12 18:06:16 +08:00
</style>