pad-app/pages/shipWork/peopleAdd.vue

371 lines
11 KiB
Vue
Raw Normal View History

2023-07-11 15:28:40 +08:00
<template>
2023-07-11 17:29:53 +08:00
<view class="peopleAdd">
2023-07-11 15:28:40 +08:00
<view class="container">
2023-07-18 17:37:15 +08:00
<view class="ul">
<view class="li">
2023-07-11 15:28:40 +08:00
<p>船名</p>
2023-07-18 17:37:15 +08:00
<text>{{shipInfo.voyageScheduleDataList[0].spmName}}</text>
</view>
<view class="li">
<p><text class="required" v-if="obj.state != 'look'">*</text></p>
2023-07-11 17:29:53 +08:00
<uni-data-select v-model="hcValue" :localdata="hcList" @change="hcChange"
v-if="obj.state != 'look'"></uni-data-select>
2023-07-18 17:37:15 +08:00
<text v-else>{{peopleRow.vvyName}}</text>
</view>
<view class="li">
2023-07-11 15:28:40 +08:00
<p>进出口</p>
2023-07-18 17:37:15 +08:00
<text>{{shipInfo.voyageScheduleDataList[0].importExportFlagName}}</text>
</view>
<view class="li">
2023-07-11 15:28:40 +08:00
<p>贸易类型</p>
2023-07-18 17:37:15 +08:00
<text>{{shipInfo.voyageScheduleDataList[0].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>
2023-07-11 17:29:53 +08:00
<uni-data-select v-model="bwValue" :localdata="bwList" @change="bwChange"
v-if="obj.state != 'look'"></uni-data-select>
2023-07-18 17:37:15 +08:00
<text v-else>{{peopleRow.bthIdName}}</text>
</view>
<view class="li">
<p><text class="required" v-if="obj.state != 'look'">*</text></p>
2023-07-12 17:46:47 +08:00
<uni-number-box @change="workChange" v-model="workValue" v-if="obj.state != 'look'" />
2023-07-18 17:37:15 +08:00
<text v-else>{{peopleRow.workSuite}}</text>
</view>
<view class="li">
<p><text class="required" v-if="obj.state != 'look'">*</text></p>
2023-07-12 17:46:47 +08:00
<uni-number-box @change="shipChange" v-model="shipValue" v-if="obj.state != 'look'" />
2023-07-18 17:37:15 +08:00
<text v-else>{{peopleRow.shipPerson}}</text>
</view>
<view class="li">
2023-07-11 15:28:40 +08:00
<p>作业时间</p>
2023-07-11 17:29:53 +08:00
<uni-datetime-picker v-model="datetime" type="datetimerange" rangeSeparator="-" @change="changeLog"
v-if="obj.state != 'look'" />
2023-07-18 17:37:15 +08:00
<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>
2023-07-11 17:29:53 +08:00
<view class="btnList">
<van-button type="default" @click="cancel"></van-button>
2023-07-18 17:37:15 +08:00
<van-button type="danger" v-if="obj.state == 'look'" @click="del"></van-button>
2023-07-11 17:29:53 +08:00
<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>
2023-07-11 15:28:40 +08:00
</view>
</view>
</template>
<script>
2023-08-01 09:32:45 +08:00
import sqlite from "../../common/sqlite.js"
2023-08-01 14:35:05 +08:00
import api from "../../common/api.js"
2023-07-11 15:28:40 +08:00
export default {
data() {
return {
2023-07-18 17:37:15 +08:00
shipInfo: {
voyageScheduleDataList: [{
spmName: "",
importExportFlagName: "",
tradeTypeName: ""
}]
},
peopleRow: {},
peopleRowIndex: 0,
2023-07-11 17:29:53 +08:00
obj: {},
2023-07-11 15:28:40 +08:00
// 航次下拉框
hcValue: "",
2023-07-18 17:37:15 +08:00
hcTextValue: "",
hcList: [],
2023-07-11 15:28:40 +08:00
// 泊位下拉框
bwValue: "",
2023-07-18 17:37:15 +08:00
bwTextValue: "",
bwList: [],
// 天气下拉框
tqValue: "",
tqTextValue: "",
tqList: [{
2023-08-01 09:32:45 +08:00
value: "0",
2023-07-18 17:37:15 +08:00
text: "晴"
}, {
2023-08-01 09:32:45 +08:00
value: " 1",
2023-07-18 17:37:15 +08:00
text: "阴"
}, {
2023-08-01 09:32:45 +08:00
value: "2",
2023-07-18 17:37:15 +08:00
text: "雨"
}],
2023-07-12 17:46:47 +08:00
// 作业组数
2023-07-11 15:28:40 +08:00
workValue: 0,
// 单船人数
shipValue: 0,
2023-07-11 17:29:53 +08:00
// 作业时间
2023-07-18 17:37:15 +08:00
datetime: ['', ''],
startTime: "",
endTime: "",
2023-07-11 17:29:53 +08:00
}
},
onLoad(options) {
if ('params' in options) {
// 获取传递的对象参数使用decodeURIComponent解码并转为对象
this.obj = JSON.parse(decodeURIComponent(options.params))
2023-07-11 15:28:40 +08:00
}
},
2023-07-18 17:37:15 +08:00
mounted() {
if (this.obj.state == "edit" || this.obj.state == "look") {
this.getRow()
}
this.getShip()
},
2023-07-11 15:28:40 +08:00
methods: {
2023-07-18 17:37:15 +08:00
// 获取船只信息
getShip() {
this.shipInfo = uni.getStorageSync('shipInfo')
this.shipInfo.pubBerthesManageRespList.forEach((v, index) => {
this.bwList.push({
text: v.bthBthnm,
value: v.bthId
})
})
this.shipInfo.voyageScheduleDataList.forEach((v, index) => {
this.hcList.push({
text: v.vvyName,
value: v.vvyId
})
})
},
// 获取当前行信息
getRow() {
this.peopleRow = uni.getStorageSync('peopleRow');
this.peopleRowIndex = uni.getStorageSync('peopleRowIndex');
2023-07-19 18:12:19 +08:00
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
2023-07-18 17:37:15 +08:00
},
2023-07-11 15:28:40 +08:00
// 航次下拉
hcChange(e) {
this.hcValue = e;
2023-07-18 17:37:15 +08:00
this.hcList.forEach(v => {
if (v.value == e) {
this.hcTextValue = v.text
}
})
2023-07-11 15:28:40 +08:00
},
// 泊位下拉
bwChange(e) {
this.bwValue = e;
2023-07-18 17:37:15 +08:00
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
}
})
2023-07-11 15:28:40 +08:00
},
// 作业组数
workChange(val) {
this.workValue = val;
},
// 单船人数
shipChange(val) {
this.shipValue = val;
},
2023-07-11 17:29:53 +08:00
// 作业时间
changeLog(e) {
this.datetime = e;
2023-07-18 17:37:15 +08:00
this.startTime = this.datetime[0].slice(0, this.datetime[0].length - 3)
this.endTime = this.datetime[1].slice(0, this.datetime[1].length - 3)
2023-07-11 17:29:53 +08:00
},
// 取消
cancel() {
2023-07-26 14:34:20 +08:00
uni.setStorageSync('tabsType', 0);
2023-07-11 17:29:53 +08:00
uni.navigateTo({
2023-07-26 14:34:20 +08:00
url: '/pages/shipWork/mixWork'
2023-07-11 17:29:53 +08:00
})
},
// 弹框删除
delConfirm() {
2023-08-01 09:32:45 +08:00
// let addPeopleArr = uni.getStorageSync('addPeopleArr')
// addPeopleArr.splice(this.peopleRowIndex, 1)
// uni.setStorageSync('addPeopleArr', addPeopleArr);
let sql = `DELETE FROM messageRespList WHERE webId = ${this.peopleRow.webId};`
this.executeSql(sql)
2023-07-26 14:34:20 +08:00
uni.setStorageSync('tabsType', 0);
2023-07-18 17:37:15 +08:00
uni.navigateTo({
2023-07-26 14:34:20 +08:00
url: '/pages/shipWork/mixWork'
2023-07-18 17:37:15 +08:00
})
},
// 删除
del() {
this.$refs.popup.open()
},
2023-07-11 17:29:53 +08:00
// 保存
2023-07-12 17:46:47 +08:00
save() {
2023-08-01 09:32:45 +08:00
let date = new Date().getTime()
let str = String(date)
let webId = Number(str.slice(str.length - 5))
let webStatus = 0
2023-08-01 14:35:05 +08:00
let webDate = api.getDate(date)
2023-07-18 17:37:15 +08:00
if (this.obj.state == "edit") {
2023-08-01 09:32:45 +08:00
let sql =
`UPDATE messageRespList SET bthId = '${this.bwValue}',bthIdName = '${this.bthIdName}',
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)
2023-07-18 17:37:15 +08:00
} else if (this.obj.state == "add") {
2023-08-01 09:32:45 +08:00
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}','${this.shipInfo.voyageScheduleDataList[0].tradeTypeName}',
'${this.shipInfo.voyageScheduleDataList[0].importExportFlagName}','${this.shipInfo.voyageScheduleDataList[0].spmName}',
'${webStatus}','${webDate}')`
this.executeSql(sql)
2023-07-18 17:37:15 +08:00
}
2023-08-01 09:32:45 +08:00
// let addPeopleArr = uni.getStorageSync('addPeopleArr')
// let addPeopleObj = {
// bthId: this.bwValue, // 泊位id
// bthIdName: this.bwTextValue, // 泊位名转义
// jobStartTime: this.startTime, // 作业开始时间
// jobEndTime: this.endTime, // 作业结束时间
// shipPerson: this.shipValue, // 单船人数
// vvyId: this.hcValue, // 航次id
// vvyName: this.hcTextValue, // 航次id名
// weatherId: this.tqValue, // 天气ID
// weatherType: this.tqTextValue, // 天气类型
// workSuite: this.workValue, // 作业组数
// tradeTypeName: this.shipInfo.voyageScheduleDataList[0].tradeTypeName, // 贸易类型
// importExportFlagName: this.shipInfo.voyageScheduleDataList[0].importExportFlagName, // 进出口
// spmName: this.shipInfo.voyageScheduleDataList[0].spmName, // 船只名
// }
// if (this.obj.state == "edit") {
// addPeopleArr[this.peopleRowIndex] = addPeopleObj;
// uni.setStorageSync('addPeopleArr', addPeopleArr);
// } else if (this.obj.state == "add") {
// if (addPeopleArr != "") {
// addPeopleArr.push(addPeopleObj)
// uni.setStorageSync('addPeopleArr', addPeopleArr);
// } else {
// addPeopleArr = []
// addPeopleArr.push(addPeopleObj)
// uni.setStorageSync('addPeopleArr', addPeopleArr);
// }
// }
2023-07-26 14:34:20 +08:00
uni.setStorageSync('tabsType', 0);
2023-07-11 17:29:53 +08:00
uni.navigateTo({
2023-07-26 14:34:20 +08:00
url: '/pages/shipWork/mixWork'
2023-07-11 17:29:53 +08:00
})
},
// 编辑
toGo(state) {
this.obj.state = state;
const params = encodeURIComponent(JSON.stringify(this.obj));
uni.navigateTo({
url: `/pages/shipWork/peopleAdd?params=${params}`
})
2023-08-01 09:32:45 +08:00
},
executeSql(sql) {
sqlite.executeSqlCeshi(sql).then((value) => {
// 在resolve时执行的回调函数
console.log(value);
}).catch((error) => {
// 在reject时执行的回调函数
console.error(error);
});
},
onBackPress(event) {
uni.setStorageSync('tabsType', 0);
uni.navigateTo({
url: '/pages/shipWork/mixWork'
})
return true;
},
2023-07-11 15:28:40 +08:00
}
}
</script>
<style lang="less" scoped>
2023-07-11 17:29:53 +08:00
.peopleAdd {
2023-07-11 15:28:40 +08:00
.container {
padding: 30px 20px;
2023-07-11 17:29:53 +08:00
background-color: #fff;
2023-07-11 15:28:40 +08:00
2023-07-18 17:37:15 +08:00
.ul {
2023-07-11 15:28:40 +08:00
display: flex;
flex-wrap: wrap;
justify-content: space-between;
2023-07-18 17:37:15 +08:00
.li {
2023-07-11 15:28:40 +08:00
width: 44%;
border-top: 1px solid #ccc;
border-bottom: 1px solid #ccc;
display: flex;
padding: 10px 20px;
line-height: 35px;
margin-bottom: 20px;
2023-07-12 17:46:47 +08:00
p {
min-width: 85px;
text-align: right;
}
2023-07-11 15:28:40 +08:00
.required {
color: red;
margin-right: 5px;
}
/deep/.uni-numbox {
border: 1px solid #ccc;
box-sizing: border-box;
}
/deep/.uni-numbox-btns {
border-right: 1px solid #ccc;
border-left: 1px solid #ccc;
padding: 0 14px;
box-sizing: border-box;
}
/deep/.uni-numbox__value {
width: 100px;
height: 35px;
line-height: 35px;
background-color: #fff !important;
}
}
}
2023-07-11 17:29:53 +08:00
.btnList {
display: flex;
justify-content: center;
/deep/ .van-button {
margin: 30px 20px;
width: 120px;
height: 50px;
}
}
2023-07-11 15:28:40 +08:00
}
}
</style>