pad-app/pages/shipWork/peopleAdd.vue

519 lines
14 KiB
Vue
Raw Normal View History

2023-08-24 16:22:29 +08:00
<template>
<view class="peopleAdd">
2023-08-24 17:06:35 +08:00
<head-view :title="title" url="/pages/shipWork/mixWork"></head-view>
2023-11-01 18:40:05 +08:00
<view class="container contentFixed">
<view class="info">
<view class="ul">
<view class="li">
<text>船名</text>
<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>{{importExportFlagName}}</text>
</view>
<view class="li">
<p>贸易类型</p>
2023-11-21 17:43:02 +08:00
<text>{{spmTradeName}}</text>
2023-11-01 18:40:05 +08:00
</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> -->
<uni-easyinput v-if="obj.state != 'look'" v-model="tqTextValue"
placeholder="请输入"></uni-easyinput>
<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>
<template v-if="flag">
<uni-datetime-picker v-model="datetime" type="datetimerange" rangeSeparator="-"
@change="changeLog" v-if="obj.state != 'look'" :hide-second="true" :border="false" />
<text v-else>{{startTime}} - {{endTime}}</text>
</template>
</view>
2023-07-18 17:37:15 +08:00
</view>
2023-11-01 18:40:05 +08:00
<view class="btnList">
<van-button type="default" @click="cancel"></van-button>
<template v-if="status == 0 || status == 4 || status == 5 || status == 'null'">
<van-button type="danger" v-if="obj.state == 'look'" @click="del"></van-button>
<van-button type="info" v-if="obj.state == 'look'" @click="toGo('edit')"></van-button>
<van-button type="info" v-if="obj.state == 'add' || obj.state == 'edit'"
@click="save">保存</van-button>
</template>
2023-07-18 17:37:15 +08:00
</view>
2023-07-11 17:29:53 +08:00
</view>
2023-08-24 16:22:29 +08:00
<uni-popup ref="popup" type="dialog">
<uni-popup-dialog type="error" confirmText="确定" title="通知" content="是否删除此条数据"
@confirm="delConfirm"></uni-popup-dialog>
</uni-popup>
2023-07-11 15:28:40 +08:00
</view>
2023-11-01 18:40:05 +08:00
<LotusLoading :lotusLoadingData="lotusLoadingData"></LotusLoading>
2023-08-24 16:22:29 +08:00
</view>
</template>
2023-08-04 17:06:33 +08:00
2023-08-24 16:22:29 +08:00
<script>
import sqlite from "../../common/sqlite.js"
import api from "../../common/api.js"
2023-11-01 18:40:05 +08:00
import LotusLoading from "../../components/Winglau14-lotusLoading/Winglau14-LotusLoading.vue";
2023-08-24 16:22:29 +08:00
import {
v4 as uuidv4
} from 'uuid';
export default {
data() {
return {
title: "",
shipInfo: {},
peopleRow: {},
peopleRowIndex: 0,
obj: {},
2023-11-01 18:40:05 +08:00
vtpId: "",
2023-08-24 16:22:29 +08:00
// 航次下拉框
hcValue: "",
hcTextValue: "",
hcList: [],
// 泊位下拉框
bwValue: "",
bwTextValue: "",
bwList: [],
// 天气下拉框
tqValue: "",
tqTextValue: "",
2023-11-01 18:40:05 +08:00
tqList: [],
2023-07-12 17:46:47 +08:00
// 作业组数
2023-08-24 16:22:29 +08:00
workValue: 0,
2023-07-11 15:28:40 +08:00
// 单船人数
2023-08-24 16:22:29 +08:00
shipValue: 0,
2023-07-11 17:29:53 +08:00
// 作业时间
2023-08-24 16:22:29 +08:00
datetime: ['', ''],
startTime: "",
endTime: "",
2023-11-01 18:40:05 +08:00
// 开始时间
beginDate: "",
// 结束时间
endDate: "",
flag: true,
lotusLoadingData: {
isShow: false //设置显示加载中组件true显示false隐藏
},
// 审核状态
status: 0,
// 删除人员信息id
delPmIds: [],
vvyInfo: [],
importExportFlagName: "",
2023-11-21 17:43:02 +08:00
spmTradeName: "",
2023-11-01 18:40:05 +08:00
2023-08-24 16:22:29 +08:00
// 下拉数据
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 = "新增人员信息"
}
2023-11-01 18:40:05 +08:00
this.vtpId = uni.getStorageSync('vtpId')
this.delPmIds = uni.getStorageSync("delPmIds")
2023-08-24 16:22:29 +08:00
this.executeSql1('shipOption')
this.executeSql1("shipInfoTable")
2023-11-01 18:40:05 +08:00
this.executeSql1("voyageScheduleDataDetailRespDTOList")
this.executeSql1("shipmentBasicShiftList")
2023-08-24 16:22:29 +08:00
},
methods: {
// 查
executeSql1(tableName) {
2023-11-01 18:40:05 +08:00
let sql = `select * from ${tableName} WHERE vtpId = '${this.vtpId}';`
2023-08-24 16:22:29 +08:00
sqlite.executeSqlCeshi(sql).then((value) => {
// 在resolve时执行的回调函数
if (tableName == 'shipOption') {
this.optionData = value
this.getShip()
} else if (tableName == 'shipInfoTable') {
this.shipInfo = value[0]
2023-11-01 18:40:05 +08:00
} else if (tableName == 'voyageScheduleDataDetailRespDTOList') {
this.vvyInfo = value
value.forEach((v, index) => {
this.hcList.push({
text: v.vvyName,
value: v.vvyId
})
})
} else if (tableName == "shipmentBasicShiftList") {
this.beginDate = value[0].beginTime
this.endDate = value[2].endTime
2023-08-24 16:22:29 +08:00
}
}).catch((error) => {
// 在reject时执行的回调函数
console.error(error);
});
},
// 获取船只信息
getShip() {
// 船舶下拉数据
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
2023-07-18 17:37:15 +08:00
})
2023-08-24 16:22:29 +08:00
})
2023-11-01 18:40:05 +08:00
// // 天气下拉数据
// let tqOption = []
// this.optionData.forEach((v, index) => {
// if (v.dictionariesName == 'weather') {
// tqOption.push(v)
// }
// })
// tqOption.forEach((v, index) => {
// this.tqList.push({
// text: v.weatherType,
// value: v.weatherTypeDesc
// })
// })
2023-08-24 16:22:29 +08:00
},
// 获取当前行信息
getRow() {
this.peopleRow = uni.getStorageSync('peopleRow');
this.hcValue = this.peopleRow.vvyId
this.hcTextValue = this.peopleRow.vvyName
2023-11-01 18:40:05 +08:00
if (this.peopleRow.weatherId != undefined) {
this.tqValue = this.peopleRow.weatherId
} else {
this.tqValue = ""
}
console.log(this.peopleRow)
2023-08-24 16:22:29 +08:00
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-11-01 18:40:05 +08:00
this.importExportFlagName = this.peopleRow.importExportFlagName
this.status = this.peopleRow.status
2023-08-24 16:22:29 +08:00
},
// 航次下拉
hcChange(e) {
this.hcValue = e;
this.hcList.forEach(v => {
if (v.value == e) {
this.hcTextValue = v.text
}
})
2023-11-01 18:40:05 +08:00
this.vvyInfo.forEach(v => {
if (v.vvyId == e) {
this.importExportFlagName = v.importExportFlagName
2023-11-21 17:43:02 +08:00
this.spmTradeName = v.tradeTypeName
2023-11-01 18:40:05 +08:00
}
})
2023-08-24 16:22:29 +08:00
},
// 泊位下拉
bwChange(e) {
this.bwValue = e;
this.bwList.forEach(v => {
if (v.value == e) {
this.bwTextValue = v.text
}
})
},
2023-11-01 18:40:05 +08:00
// // 天气下拉
// tqChange(e) {
// this.tqValue = e;
// this.tqList.forEach(v => {
// if (v.value == e) {
// this.tqTextValue = v.text
// }
// })
// },
2023-08-24 16:22:29 +08:00
// 作业组数
workChange(val) {
this.workValue = val;
},
// 单船人数
shipChange(val) {
this.shipValue = val;
},
// 作业时间
changeLog(e) {
2023-11-01 18:40:05 +08:00
this.lotusLoadingData.isShow = true
// 选择开始结束时间时分
let sTime = e[0].slice(e[0].length - 5)
let eTime = e[1].slice(e[1].length - 5)
// 获取开始结束时间年月日
let sYMD = e[0].split(' ')[0]
let eYMD = e[1].split(' ')[0]
// 获取开始结束时间时分转数字
let nsTime = Number((sTime.split(':')).join(''))
let neTime = Number((eTime.split(':')).join(''))
// 获取限定范围开始结束时间时分转数字
let xsTime = Number((this.beginDate.split(':')).join(''))
let xeTime = Number((this.endDate.split(':')).join(''))
let that = this
if (sYMD != eYMD) {
if (nsTime >= xsTime && neTime <= xeTime) {
that.datetime = e
that.startTime = e[0]
that.endTime = e[1]
} else {
that.datetime = ["", ""]
that.startTime = ""
that.endTime = ""
that.flag = false
setTimeout(function() {
that.flag = true
that.lotusLoadingData.isShow = false
}, 200)
uni.showToast({
title: `请输入正确的作业时间范围`,
icon: 'none',
duration: 2000
})
}
} else {
if (neTime <= xeTime) {
that.flag = true
that.datetime = e
that.startTime = e[0]
that.endTime = e[1]
that.lotusLoadingData.isShow = false
} else {
that.datetime = ["", ""]
that.startTime = ""
that.endTime = ""
that.flag = false
setTimeout(function() {
that.flag = true
that.lotusLoadingData.isShow = false
}, 200)
uni.showToast({
title: `请输入正确的作业时间范围`,
icon: 'none',
duration: 2000
})
}
}
console.log(that.startTime)
console.log(that.endTime)
// this.datetime = e;
// this.startTime = this.datetime[0]
// this.endTime = this.datetime[1]
2023-08-24 16:22:29 +08:00
},
// 取消
cancel() {
uni.navigateTo({
url: '/pages/shipWork/mixWork'
})
},
// 弹框删除
delConfirm() {
2023-11-01 18:40:05 +08:00
let sql = `DELETE FROM messageRespList WHERE pmeId = '${this.peopleRow.pmeId}';`
2023-08-24 16:22:29 +08:00
this.executeSql(sql)
2023-11-28 17:52:09 +08:00
let reg = RegExp(/-/)
if (reg.test(this.peopleRow.pmeId)) {
this.delPmIds.push(this.peopleRow.pmeId)
uni.setStorageSync('delPmIds', this.delPmIds);
}
2023-08-24 16:22:29 +08:00
uni.navigateTo({
url: '/pages/shipWork/mixWork'
})
},
// 删除
del() {
this.$refs.popup.open()
},
// 保存
save() {
let date = new Date().getTime()
2023-11-01 18:40:05 +08:00
let pmeId = uuidv4()
2023-08-24 16:22:29 +08:00
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}',
2023-11-01 18:40:05 +08:00
vvyId = '${this.hcValue}',vvyName = '${this.hcTextValue}',weatherType = '${this.tqTextValue}',
weatherTypeDesc = '${this.tqTextValue}',workSuite = '${this.workValue}',webStatus = '${webStatus}',
importExportFlagName = '${this.importExportFlagName}',webDate = '${webDate}' WHERE pmeId = '${this.peopleRow.pmeId}';`
2023-08-24 16:22:29 +08:00
this.executeSql(sql)
} else if (this.obj.state == "add") {
2023-11-01 18:40:05 +08:00
let sql =
`insert into messageRespList values('${pmeId}','${this.vtpId}','${this.bwValue}','${this.bwTextValue}',
'${this.startTime}','${this.endTime}','${this.shipValue}','${this.hcValue}','${this.hcTextValue}','${this.tqTextValue}',
'${this.tqTextValue}','${this.workValue}','${this.importExportFlagName}','${0}','${webStatus}','${webDate}')`
2023-08-24 16:22:29 +08:00
this.executeSql(sql)
}
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时执行的回调函数
2023-11-01 18:40:05 +08:00
// console.log(value);
2023-08-24 16:22:29 +08:00
}).catch((error) => {
// 在reject时执行的回调函数
console.error(error);
});
},
2023-07-11 15:28:40 +08:00
}
2023-08-24 16:22:29 +08:00
}
</script>
2023-07-11 15:28:40 +08:00
2023-08-24 16:22:29 +08:00
<style lang="less" scoped>
.peopleAdd {
.container {
2023-11-01 18:40:05 +08:00
padding: 16px;
background-color: #F6F7F9;
.info {
background-color: #fff;
}
2023-07-11 15:28:40 +08:00
2023-08-24 16:22:29 +08:00
.ul {
display: flex;
flex-wrap: wrap;
justify-content: space-between;
2023-07-11 15:28:40 +08:00
2023-08-24 16:22:29 +08:00
.li {
2023-11-01 18:40:05 +08:00
width: 49%;
2023-08-24 16:22:29 +08:00
display: flex;
2023-11-01 18:40:05 +08:00
justify-content: space-between;
border-bottom: 1px solid #EEEEEE;
padding: 0 16px;
height: 56px;
line-height: 56px;
2023-07-11 15:28:40 +08:00
2023-08-24 16:22:29 +08:00
.required {
color: red;
margin-right: 5px;
}
2023-07-11 15:28:40 +08:00
2023-08-24 16:22:29 +08:00
/deep/.uni-numbox {
border: 1px solid #ccc;
box-sizing: border-box;
2023-11-01 18:40:05 +08:00
height: 38px;
margin-top: 8px;
2023-08-24 16:22:29 +08:00
}
2023-07-11 15:28:40 +08:00
2023-08-24 16:22:29 +08:00
/deep/.uni-numbox-btns {
padding: 0 14px;
box-sizing: border-box;
}
2023-08-04 17:06:33 +08:00
2023-08-24 16:22:29 +08:00
/deep/.uni-numbox__value {
width: 100px;
height: 35px;
line-height: 35px;
background-color: #fff !important;
2023-07-11 15:28:40 +08:00
}
2023-11-01 18:40:05 +08:00
/deep/.uni-date-x .icon-calendar {
display: none;
}
/deep/.uni-date {
flex: none;
width: 52%;
text-align: right;
display: flex;
flex-direction: column;
justify-content: center;
}
/deep/.uni-date-x {
height: 38px;
}
/deep/.uni-stat__select {
flex: none;
width: 30%;
}
/deep/.uni-select {
border: none;
}
/deep/.uni-select__input-text {
text-align: right;
padding-right: 10px;
}
/deep/.is-input-border {
margin-top: 8px;
height: 40px;
}
2023-07-11 15:28:40 +08:00
}
2023-08-24 16:22:29 +08:00
}
2023-07-11 17:29:53 +08:00
2023-08-24 16:22:29 +08:00
.btnList {
display: flex;
justify-content: center;
2023-07-11 17:29:53 +08:00
2023-08-24 16:22:29 +08:00
/deep/ .van-button {
margin: 30px 20px;
width: 120px;
height: 50px;
2023-07-11 17:29:53 +08:00
}
}
2023-07-11 15:28:40 +08:00
}
2023-08-24 16:22:29 +08:00
}
</style>