pad-app/pages/index/index.vue

387 lines
9.3 KiB
Vue
Raw Normal View History

2023-07-03 17:49:29 +08:00
<template>
<view class="app">
2023-08-18 17:28:11 +08:00
<head-info :navIndex="0"></head-info>
2023-07-03 17:49:29 +08:00
<view class="container">
<view class="content">
<view class="form">
2023-07-06 17:08:59 +08:00
<view class="end">
2023-07-21 17:28:30 +08:00
<superwei-combox class="input" :candidates="portList" :isJSON="true" keyName="pamName"
placeholder="港区" v-model="portName" @input="portInput"
@select="portSelect"></superwei-combox>
<superwei-combox class="input" :candidates="shipList" :isJSON="true" keyName="vvyName"
placeholder="船名/航次" v-model="shipName" @input="shipInput"
@select="shipSelect"></superwei-combox>
2023-07-06 17:08:59 +08:00
</uni-easyinput>
2023-07-21 17:28:30 +08:00
<button class="btn" @click="onSearch"></button>
2023-07-28 09:42:53 +08:00
<button class="btn" @click="open"></button>
<button class="btn" @click="isOpenDatabase"></button>
<button class="btn" @click="createTable"></button>
<button class="btn" @click="dropTable"></button>
2023-08-01 16:37:41 +08:00
<button class="btn" @click="insertChatRowTwo"></button>
2023-07-28 09:42:53 +08:00
<button class="btn" @click="executeSql1"></button>
2023-07-06 17:08:59 +08:00
</view>
2023-07-03 17:49:29 +08:00
</view>
<view class="itemList">
2023-07-21 17:28:30 +08:00
<view v-for="(item, index) in ltemList" :key="index" class="item" @click="toDetails(item.spmId)">
2023-07-06 17:08:59 +08:00
<view class="title">
<view class="name">
海王星领袖
</view>
<view class="status">
2023-07-21 17:28:30 +08:00
<text v-if="item.vvyStatus==2" class="green"> </text>
2023-07-06 17:08:59 +08:00
<text v-else> </text>
</view>
</view>
<view class="table">
<view class="row">
<view class="nitem">
航次: <text>735546</text>
</view>
<view class="nitem">
2023-07-21 17:28:30 +08:00
贸易类型: <text>{{item.tradeType}}</text>
2023-07-06 17:08:59 +08:00
</view>
</view>
<view class="row">
<view class="nitem">
2023-07-21 17:28:30 +08:00
进出口: <text>{{item.importExportFlag}}</text>
2023-07-05 10:56:11 +08:00
</view>
2023-07-06 17:08:59 +08:00
<view class="nitem">
2023-07-21 17:28:30 +08:00
泊位: <text>{{item.actualBerthage}}</text>
2023-07-06 17:08:59 +08:00
</view>
</view>
</view>
2023-07-03 17:49:29 +08:00
</view>
</view>
</view>
</view>
</view>
</template>
<script>
import HeadInfo from '@/components/head-info/head-info';
2023-07-28 09:42:53 +08:00
import sqlite from "../../common/sqlite.js"
2023-08-01 16:37:41 +08:00
import rSqlite from "../../common/rSqlite.js"
2023-07-21 17:28:30 +08:00
import {
mapActions
} from 'vuex'
let timers = null;
2023-07-03 17:49:29 +08:00
export default {
data() {
return {
2023-07-21 17:28:30 +08:00
ltemList: [],
portName: '',
portItem: {},
portList: [],
shipName: '',
shipItem: {},
shipList: []
2023-07-03 17:49:29 +08:00
}
},
2023-08-18 17:28:11 +08:00
onLoad() {},
2023-07-03 17:49:29 +08:00
components: {
HeadInfo
},
methods: {
2023-07-21 17:28:30 +08:00
...mapActions([
'majax',
'najax'
]),
2023-07-28 09:42:53 +08:00
open() {
plus.sqlite.openDatabase({
name: 'dianji_chat',
path: '_doc/dianji_chat.db',
success: function(e) {
console.log('打开数据库成功')
},
fail: function(e) {
console.log(e, '打开数据库失败')
}
});
},
isOpenDatabase() {
let res = plus.sqlite.isOpenDatabase({
name: 'dianji_chat',
path: '_doc/dianji_chat.db',
});
if (res) {
uni.showToast({
icon: 'none',
title: '数据库已打开'
});
return;
} else {
uni.showToast({
icon: 'none',
title: '数据库未打开'
});
return;
}
},
createTable() {
console.log('创建表');
let sql =
'CREATE TABLE if not exists cesTable ( "id" varchar(32) NOT NULL,"content" varchar(1024),"fromId" varchar(32), "toId" varchar(32), "flag" varchar(2), PRIMARY KEY ("id"));'
sqlite.executeSqlCeshi(sql).then((value) => {
// 在resolve时执行的回调函数
console.log(value); // 输出Hello, World!
}).catch((error) => {
// 在reject时执行的回调函数
console.error(error);
});
},
dropTable() {
console.log('删除表');
let sql = 'DROP TABLE cesTable;'
plus.sqlite.executeSql({
name: 'dianji_chat',
sql: sql,
success: function(e) {
console.log("删除数据表成功");
},
fail: function(e) {
console.log('executeSql failed: ' + JSON.stringify(e));
}
})
},
2023-08-01 16:37:41 +08:00
// insertChatRow() {
// let data = {
// id: 1,
// fromId: '123',
// toId: '321',
// content: 'bihao1',
// flag: 1
// }
// data.id = Math.floor(Math.random() * 100);
// let dbTable = 'cesTable'
// // let sql = "insert into " + this.dbTable + " values('" + data.id + "','" + data.content +
// // "','" + data.fromId + "','" + data.toId + "'," + data.flag + ")";
// let sql = "insert into " + dbTable + " values('" + data.id + "','" +
// data.content + "','" + data.fromId + "','" + data.toId + "','" + data.flag + "')";
// this.executeSql(sql)
// },
insertChatRowTwo() {
2023-07-28 09:42:53 +08:00
let data = {
id: 1,
fromId: '123',
2023-08-18 17:28:11 +08:00
toId: '321',
2023-07-28 09:42:53 +08:00
content: 'bihao1',
flag: 1
2023-08-18 17:28:11 +08:00
} // => "'1','123','312'"
2023-07-28 09:42:53 +08:00
data.id = Math.floor(Math.random() * 100);
let dbTable = 'cesTable'
2023-08-01 16:37:41 +08:00
let Arr = []
for (let key in data) {
2023-08-18 17:28:11 +08:00
Arr.push(`'${data[key]}'`);
2023-08-01 16:37:41 +08:00
}
let Str = Arr.join(',')
rSqlite.insertTableData(dbTable, Str).then((value) => {
// 在resolve时执行的回调函数
console.log(value); // 输出Hello, World!
this.executeSql(value)
}).catch((error) => {
// 在reject时执行的回调函数
console.error(error);
});
2023-07-28 09:42:53 +08:00
},
// 查
executeSql(sql) {
sqlite.executeSqlCeshi(sql).then((value) => {
// 在resolve时执行的回调函数
// this.sqlData = value
console.log(value); // 输出Hello, World!
}).catch((error) => {
// 在reject时执行的回调函数
console.error(error);
});
},
executeSql1() {
let sql = 'select * from cesTable'
sqlite.executeSqlCeshi(sql).then((value) => {
// 在resolve时执行的回调函数
// this.sqlData = value
console.log(value); // 输出Hello, World!
}).catch((error) => {
// 在reject时执行的回调函数
console.error(error);
});
},
2023-07-21 17:28:30 +08:00
portInput(e) {
clearTimeout(timers)
timers = setTimeout(() => {
this.getPort(e)
}, 500)
},
portSelect(e) {
this.portItem = e
this.shipName = ''
this.shipItem = {}
},
// 获取港口
getPort(keyWords) {
let data = {}
data.pamName = keyWords
this.majax({
url: this.$local + "/api/miniapp/portAreaManage/getPortArea",
params: data,
method: 'GET'
}).then(res => {
this.portList = res.data
})
// 模拟
this.portList = [{
potId: 1123,
pamName: '测试港口'
}]
},
shipInput(e) {
clearTimeout(timers)
timers = setTimeout(() => {
this.getShip(e)
}, 500)
},
shipSelect(e) {
this.shipItem = e
},
// 获取船舶
getShip(keyWords) {
console.log(this.portName);
let data = {}
data.ieType = 'I' // I进口 E出口 暂无法区分
data.key = keyWords
data.pamId = this.portItem.pamId
this.majax({
url: this.$local + "/api/shipInstructions/queryByKey",
params: data,
method: 'GET'
}).then(res => {
this.shipList = res.data
})
// 模拟
this.shipList = [{
vvyId: 1123,
vvyName: '测试航次'
}]
},
onSearch() {
let data = {}
data.tradeType = '外贸' // I进口 E出口 暂无法区分
data.vvyId = this.shipItem.vvyId
data.pamId = this.portItem.pamId
this.majax({
url: this.$local + "/api/shipInstructions/queryStowageVoyages",
params: data,
method: 'GET'
}).then(res => {
this.ltemList = res.data.records
})
// 模拟
this.ltemList = [{
actualBerthage: "一号位置",
actualBerthageDesc: "",
importExportFlag: "出口",
spmId: "spm1112",
spmIdDesc: "331122",
tradeType: "内贸",
vvyId: "11231",
vvyName: "海王星领袖",
vvyStatus: "2",
vvyStatusName: "作业中",
}]
},
toDetails(id) {
2023-07-06 17:08:59 +08:00
uni.navigateTo({
2023-07-21 17:28:30 +08:00
url: '/pages/index/instruct?id=' + id
2023-07-06 17:08:59 +08:00
})
2023-07-13 17:21:12 +08:00
},
2023-07-03 17:49:29 +08:00
}
};
</script>
2023-07-25 13:20:04 +08:00
<style lang="less">
2023-07-03 17:49:29 +08:00
.container {
display: flex;
}
.content {
flex: 1;
padding: 20px;
.form {
display: flex;
justify-content: flex-end;
2023-07-06 17:08:59 +08:00
.end {
display: flex;
justify-content: space-between;
.input {
width: 200px;
height: 35px;
line-height: 35px;
padding-left: 10px;
2023-08-18 17:28:11 +08:00
margin-right: 15px;
2023-07-06 17:08:59 +08:00
}
2023-07-21 17:28:30 +08:00
.btn {
height: 35px;
line-height: 35px;
margin-left: 20px;
}
2023-07-03 17:49:29 +08:00
}
2023-07-06 17:08:59 +08:00
2023-07-03 17:49:29 +08:00
}
.itemList {
width: 100%;
display: flex;
justify-content: flex-start;
flex-wrap: wrap;
2023-07-06 17:08:59 +08:00
2023-07-03 17:49:29 +08:00
.item {
width: 32%;
margin-top: 15px;
margin-right: 2%;
2023-07-05 10:56:11 +08:00
height: 160px;
2023-07-03 17:49:29 +08:00
border: 1px solid #c9cacb;
2023-07-05 10:56:11 +08:00
padding: 22px 15px;
2023-07-06 17:08:59 +08:00
2023-07-05 10:56:11 +08:00
.title {
display: flex;
justify-content: space-between;
font-size: 21px;
margin-bottom: 20px;
font-weight: 700;
}
2023-07-06 17:08:59 +08:00
2023-07-05 10:56:11 +08:00
.status {
font-size: 16px;
font-weight: 400;
}
2023-07-06 17:08:59 +08:00
2023-07-05 10:56:11 +08:00
.row {
display: flex;
justify-content: space-between;
font-size: 18px;
margin: 10px 0;
2023-07-06 17:08:59 +08:00
.nitem {
width: 46%;
text {
color: #929292;
}
2023-07-05 10:56:11 +08:00
}
2023-07-06 17:08:59 +08:00
2023-07-05 10:56:11 +08:00
}
2023-07-03 17:49:29 +08:00
}
2023-07-06 17:08:59 +08:00
2023-07-03 17:49:29 +08:00
.item:nth-child(3n) {
margin-right: 0;
}
}
}
2023-07-13 17:21:12 +08:00
</style>