369 lines
9.8 KiB
Vue
369 lines
9.8 KiB
Vue
<template>
|
||
<view class="peopleAdd">
|
||
<head-view :title="title" url="/pages/shipWork/mixWork"></head-view>
|
||
<view class="container">
|
||
<view class="ul">
|
||
<view class="li">
|
||
<p>船名:</p>
|
||
<text>{{shipInfo.vslCnname}}</text>
|
||
</view>
|
||
<view class="li">
|
||
<p><text class="required" v-if="obj.state != 'look'">*</text>航次:</p>
|
||
<uni-data-select v-model="hcValue" :localdata="hcList" @change="hcChange"
|
||
v-if="obj.state != 'look'"></uni-data-select>
|
||
<text v-else>{{peopleRow.vvyName}}</text>
|
||
</view>
|
||
<view class="li">
|
||
<p>进出口:</p>
|
||
<text>{{shipInfo.importExportFlagName}}</text>
|
||
</view>
|
||
<view class="li">
|
||
<p>贸易类型:</p>
|
||
<text>{{shipInfo.tradeTypeName}}</text>
|
||
</view>
|
||
<view class="li">
|
||
<p><text class="required" v-if="obj.state != 'look'">*</text>天气:</p>
|
||
<uni-data-select v-model="tqValue" :localdata="tqList" @change="tqChange"
|
||
v-if="obj.state != 'look'"></uni-data-select>
|
||
<text v-else>{{peopleRow.weatherType}}</text>
|
||
</view>
|
||
<view class="li">
|
||
<p><text class="required" v-if="obj.state != 'look'">*</text>泊位:</p>
|
||
<uni-data-select v-model="bwValue" :localdata="bwList" @change="bwChange"
|
||
v-if="obj.state != 'look'"></uni-data-select>
|
||
<text v-else>{{peopleRow.bthIdName}}</text>
|
||
</view>
|
||
<view class="li">
|
||
<p><text class="required" v-if="obj.state != 'look'">*</text>作业组数:</p>
|
||
<uni-number-box @change="workChange" v-model="workValue" :max="1000000000"
|
||
v-if="obj.state != 'look'" />
|
||
<text v-else>{{peopleRow.workSuite}}</text>
|
||
</view>
|
||
<view class="li">
|
||
<p><text class="required" v-if="obj.state != 'look'">*</text>单船人数:</p>
|
||
<uni-number-box @change="shipChange" v-model="shipValue" :max="1000000000"
|
||
v-if="obj.state != 'look'" />
|
||
<text v-else>{{peopleRow.shipPerson}}</text>
|
||
</view>
|
||
<view class="li">
|
||
<p>作业时间:</p>
|
||
<uni-datetime-picker v-model="datetime" type="datetimerange" rangeSeparator="-" @change="changeLog"
|
||
v-if="obj.state != 'look'" />
|
||
<text v-else>{{peopleRow.jobStartTime}} - {{peopleRow.jobEndTime}}</text>
|
||
</view>
|
||
</view>
|
||
<uni-popup ref="popup" type="dialog">
|
||
<uni-popup-dialog type="error" confirmText="确定" title="通知" content="是否删除此条数据"
|
||
@confirm="delConfirm"></uni-popup-dialog>
|
||
</uni-popup>
|
||
<view class="btnList">
|
||
<van-button type="default" @click="cancel">取消</van-button>
|
||
<van-button type="danger" v-if="obj.state == 'look'" @click="del">删除</van-button>
|
||
<van-button type="info" v-if="obj.state == 'add' || obj.state == 'edit'" @click="save">保存</van-button>
|
||
<van-button type="info" v-if="obj.state == 'look'" @click="toGo('edit')">编辑</van-button>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
</template>
|
||
|
||
<script>
|
||
import sqlite from "../../common/sqlite.js"
|
||
import api from "../../common/api.js"
|
||
import {
|
||
v4 as uuidv4
|
||
} from 'uuid';
|
||
export default {
|
||
data() {
|
||
return {
|
||
title: "",
|
||
shipInfo: {},
|
||
peopleRow: {},
|
||
peopleRowIndex: 0,
|
||
obj: {},
|
||
// 航次下拉框
|
||
hcValue: "",
|
||
hcTextValue: "",
|
||
hcList: [],
|
||
// 泊位下拉框
|
||
bwValue: "",
|
||
bwTextValue: "",
|
||
bwList: [],
|
||
// 天气下拉框
|
||
tqValue: "",
|
||
tqTextValue: "",
|
||
tqList: [{
|
||
value: "0",
|
||
text: "晴"
|
||
},
|
||
{
|
||
value: " 1",
|
||
text: "阴"
|
||
}, {
|
||
value: "2",
|
||
text: "雨"
|
||
}
|
||
],
|
||
// 作业组数
|
||
workValue: 0,
|
||
// 单船人数
|
||
shipValue: 0,
|
||
// 作业时间
|
||
datetime: ['', ''],
|
||
startTime: "",
|
||
endTime: "",
|
||
|
||
// 下拉数据
|
||
optionData: [],
|
||
}
|
||
},
|
||
onLoad(options) {
|
||
if ('params' in options) {
|
||
// 获取传递的对象参数,使用decodeURIComponent解码,并转为对象
|
||
this.obj = JSON.parse(decodeURIComponent(options.params))
|
||
}
|
||
},
|
||
mounted() {
|
||
if (this.obj.state == "edit" || this.obj.state == "look") {
|
||
this.getRow()
|
||
}
|
||
if (this.obj.state == "edit") {
|
||
this.title = "编辑人员信息"
|
||
} else if (this.obj.state == "look") {
|
||
this.title = "查看人员信息"
|
||
} else {
|
||
this.title = "新增人员信息"
|
||
}
|
||
this.executeSql1('shipOption')
|
||
this.executeSql1("shipInfoTable")
|
||
},
|
||
methods: {
|
||
// 查
|
||
executeSql1(tableName) {
|
||
let sql = `select * from ${tableName}`
|
||
sqlite.executeSqlCeshi(sql).then((value) => {
|
||
// 在resolve时执行的回调函数
|
||
if (tableName == 'shipOption') {
|
||
this.optionData = value
|
||
this.getShip()
|
||
} else if (tableName == 'shipInfoTable') {
|
||
this.shipInfo = value[0]
|
||
}
|
||
}).catch((error) => {
|
||
// 在reject时执行的回调函数
|
||
console.error(error);
|
||
});
|
||
},
|
||
// 获取船只信息
|
||
getShip() {
|
||
// this.shipInfo = uni.getStorageSync('shipInfo')
|
||
// 航次下拉数据
|
||
let hcOption = []
|
||
this.optionData.forEach((v, index) => {
|
||
if (v.dictionariesName == 'vvyList') {
|
||
hcOption.push(v)
|
||
}
|
||
})
|
||
hcOption.forEach((v, index) => {
|
||
this.hcList.push({
|
||
text: v.ptrDesc,
|
||
value: v.ptrCode
|
||
})
|
||
})
|
||
// 船舶下拉数据
|
||
let bwOption = []
|
||
this.optionData.forEach((v, index) => {
|
||
if (v.dictionariesName == 'bthList') {
|
||
bwOption.push(v)
|
||
}
|
||
})
|
||
bwOption.forEach((v, index) => {
|
||
this.bwList.push({
|
||
text: v.ptrDesc,
|
||
value: v.ptrCode
|
||
})
|
||
})
|
||
},
|
||
// 获取当前行信息
|
||
getRow() {
|
||
this.peopleRow = uni.getStorageSync('peopleRow');
|
||
this.hcValue = this.peopleRow.vvyId
|
||
this.hcTextValue = this.peopleRow.vvyName
|
||
this.tqValue = this.peopleRow.weatherId
|
||
this.tqTextValue = this.peopleRow.weatherType
|
||
this.bwValue = this.peopleRow.bthId
|
||
this.bwTextValue = this.peopleRow.bthIdName
|
||
this.workValue = this.peopleRow.workSuite
|
||
this.shipValue = this.peopleRow.shipPerson
|
||
this.datetime = [this.peopleRow.jobStartTime, this.peopleRow.jobEndTime]
|
||
this.startTime = this.peopleRow.jobStartTime
|
||
this.endTime = this.peopleRow.jobEndTime
|
||
},
|
||
// 航次下拉
|
||
hcChange(e) {
|
||
this.hcValue = e;
|
||
this.hcList.forEach(v => {
|
||
if (v.value == e) {
|
||
this.hcTextValue = v.text
|
||
}
|
||
})
|
||
},
|
||
// 泊位下拉
|
||
bwChange(e) {
|
||
this.bwValue = e;
|
||
this.bwList.forEach(v => {
|
||
if (v.value == e) {
|
||
this.bwTextValue = v.text
|
||
}
|
||
})
|
||
},
|
||
// 天气下拉
|
||
tqChange(e) {
|
||
this.tqValue = e;
|
||
this.tqList.forEach(v => {
|
||
if (v.value == e) {
|
||
this.tqTextValue = v.text
|
||
}
|
||
})
|
||
},
|
||
// 作业组数
|
||
workChange(val) {
|
||
this.workValue = val;
|
||
},
|
||
// 单船人数
|
||
shipChange(val) {
|
||
this.shipValue = val;
|
||
},
|
||
// 作业时间
|
||
changeLog(e) {
|
||
this.datetime = e;
|
||
this.startTime = this.datetime[0]
|
||
this.endTime = this.datetime[1]
|
||
},
|
||
// 取消
|
||
cancel() {
|
||
uni.setStorageSync('tabsType', 0);
|
||
uni.navigateTo({
|
||
url: '/pages/shipWork/mixWork'
|
||
})
|
||
},
|
||
// 弹框删除
|
||
delConfirm() {
|
||
let sql = `DELETE FROM messageRespList WHERE webId = '${this.peopleRow.webId}';`
|
||
this.executeSql(sql)
|
||
uni.setStorageSync('tabsType', 0);
|
||
uni.navigateTo({
|
||
url: '/pages/shipWork/mixWork'
|
||
})
|
||
},
|
||
// 删除
|
||
del() {
|
||
this.$refs.popup.open()
|
||
},
|
||
// 保存
|
||
save() {
|
||
let date = new Date().getTime()
|
||
let webId = uuidv4()
|
||
let webStatus = 0
|
||
let webDate = api.getDate(date)
|
||
if (this.obj.state == "edit") {
|
||
let sql =
|
||
`UPDATE messageRespList SET bthId = '${this.bwValue}',bthIdName = '${this.bwTextValue}',
|
||
jobStartTime = '${this.startTime}',jobEndTime = '${this.endTime}',shipPerson = '${this.shipValue}',
|
||
vvyId = '${this.hcValue}',vvyName = '${this.hcTextValue}',weatherId = '${this.tqValue}',
|
||
weatherType = '${this.tqTextValue}',workSuite = '${this.workValue}',webStatus = '${webStatus}',
|
||
webDate = '${webDate}' WHERE webId = '${this.peopleRow.webId}';`
|
||
this.executeSql(sql)
|
||
} else if (this.obj.state == "add") {
|
||
let sql = `insert into messageRespList values('${webId}','${this.bwValue}','${this.bwTextValue}',
|
||
'${this.startTime}','${this.endTime}','${this.shipValue}','${this.hcValue}','${this.hcTextValue}','${this.tqValue}',
|
||
'${this.tqTextValue}','${this.workValue}','${webStatus}','${webDate}')`
|
||
this.executeSql(sql)
|
||
}
|
||
uni.setStorageSync('tabsType', 0);
|
||
uni.navigateTo({
|
||
url: '/pages/shipWork/mixWork'
|
||
})
|
||
},
|
||
// 编辑
|
||
toGo(state) {
|
||
this.obj.state = state;
|
||
const params = encodeURIComponent(JSON.stringify(this.obj));
|
||
uni.navigateTo({
|
||
url: `/pages/shipWork/peopleAdd?params=${params}`
|
||
})
|
||
},
|
||
executeSql(sql) {
|
||
sqlite.executeSqlCeshi(sql).then((value) => {
|
||
// 在resolve时执行的回调函数
|
||
console.log(value);
|
||
}).catch((error) => {
|
||
// 在reject时执行的回调函数
|
||
console.error(error);
|
||
});
|
||
},
|
||
}
|
||
}
|
||
</script>
|
||
|
||
<style lang="less" scoped>
|
||
.peopleAdd {
|
||
.container {
|
||
padding: 30px 20px;
|
||
background-color: #fff;
|
||
|
||
.ul {
|
||
display: flex;
|
||
flex-wrap: wrap;
|
||
justify-content: space-between;
|
||
|
||
.li {
|
||
width: 44%;
|
||
border-top: 1px solid #ccc;
|
||
border-bottom: 1px solid #ccc;
|
||
display: flex;
|
||
padding: 10px 20px;
|
||
line-height: 35px;
|
||
margin-bottom: 20px;
|
||
|
||
p {
|
||
min-width: 85px;
|
||
text-align: right;
|
||
}
|
||
|
||
.required {
|
||
color: red;
|
||
margin-right: 5px;
|
||
}
|
||
|
||
/deep/.uni-numbox {
|
||
border: 1px solid #ccc;
|
||
box-sizing: border-box;
|
||
}
|
||
|
||
/deep/.uni-numbox-btns {
|
||
padding: 0 14px;
|
||
box-sizing: border-box;
|
||
}
|
||
|
||
/deep/.uni-numbox__value {
|
||
width: 100px;
|
||
height: 35px;
|
||
line-height: 35px;
|
||
background-color: #fff !important;
|
||
}
|
||
}
|
||
}
|
||
|
||
.btnList {
|
||
display: flex;
|
||
justify-content: center;
|
||
|
||
/deep/ .van-button {
|
||
margin: 30px 20px;
|
||
width: 120px;
|
||
height: 50px;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
</style> |