pad-app/pages/shipWork/workAssignAdd.vue

404 lines
11 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

<template>
<view class="workAssignAdd">
<head-view :title="title" url="/pages/shipWork/workAssign"></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="vvyId" :localdata="hcList" @change="hcChange"
v-if="obj.state != 'look'"></uni-data-select>
<text v-else>{{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="bthId" :localdata="bwList" @change="bwChange"
v-if="obj.state != 'look'"></uni-data-select>
<text v-else>{{bthIdName}}</text>
</view>
<view class="li">
<p><text class="required" v-if="obj.state != 'look'">*</text>工班:</p>
<uni-data-select v-model="pwcTypeId" :localdata="gbList" @change="gbChange"
v-if="obj.state != 'look'"></uni-data-select>
<text v-else>{{pwcType}}</text>
</view>
<view class="li">
<p><text class="required" v-if="obj.state != 'look'">*</text>人数:</p>
<uni-number-box v-model="personNumber" :max="1000000000" v-if="obj.state != 'look'" />
<text v-else>{{personNumber}}</text>
</view>
<view class="li">
<p><text class="required" v-if="obj.state != 'look'">*</text>装卸类型:</p>
<uni-data-select v-model="loaderTypeId" :localdata="zxList" @change="zxChange"
v-if="obj.state != 'look'"></uni-data-select>
<text v-else>{{loaderType}}</text>
</view>
<view class="li">
<p><text class="required" v-if="obj.state != 'look'">*</text>车辆数量:</p>
<uni-number-box v-model="vehicleSize" :max="1000000000" v-if="obj.state != 'look'" />
<text v-else>{{vehicleSize}}</text>
</view>
<view class="li">
<p><text class="required" v-if="obj.state != 'look'">*</text>备件数量:</p>
<uni-number-box v-model="sparePart" :max="1000000000" v-if="obj.state != 'look'" />
<text v-else>{{sparePart}}</text>
</view>
<view class="li">
<p><text class="required" v-if="obj.state != 'look'">*</text>作业时间:</p>
<uni-datetime-picker v-model="workTime" type="datetimerange" rangeSeparator="-" @change="changeLog"
v-if="obj.state != 'look'" />
<text v-else>{{startTime}} - {{endTime}}</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: {},
obj: {},
assignRow: {},
assignRowIndex: {},
// 航次下拉框
vvyId: "",
vvyName: "",
hcList: [],
// 泊位下拉框
bthId: "",
bthIdName: "",
bwList: [],
// 工班下拉框
pwcTypeId: "",
pwcType: "",
gbList: [],
// 人数
personNumber: 0,
// 装卸类型下拉框
loaderTypeId: "",
loaderType: "",
zxList: [],
// 车辆数量
vehicleSize: 0,
// 备件数量
sparePart: 0,
// 作业时间
workTime: ['', ''],
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
})
})
// 装卸类型数据
let zxOption = []
this.optionData.forEach((v, index) => {
if (v.dictionariesName == 'handTypeList') {
zxOption.push(v)
}
})
zxOption.forEach((v, index) => {
this.zxList.push({
text: v.ptrDesc,
value: v.ptrCode
})
})
// 工班数据
let gbOption = []
this.optionData.forEach((v, index) => {
if (v.dictionariesName == 'shiftList') {
gbOption.push(v)
}
})
gbOption.forEach((v, index) => {
this.gbList.push({
text: v.ptrDesc,
value: v.ptrCode
})
})
},
// 获取当前行信息
getRow() {
this.assignRow = uni.getStorageSync('assignRow');
this.assignRowIndex = uni.getStorageSync('assignRowIndex');
this.vvyId = this.assignRow.vvyId
this.vvyName = this.assignRow.vvyName
this.bthId = this.assignRow.bthId
this.bthIdName = this.assignRow.bthIdName
this.pwcTypeId = this.assignRow.pwcTypeId
this.pwcType = this.assignRow.pwcType
this.personNumber = this.assignRow.personNumber
this.loaderTypeId = this.assignRow.loaderTypeId
this.loaderType = this.assignRow.loaderType
this.vehicleSize = this.assignRow.vehicleSize
this.sparePart = this.assignRow.sparePart
this.workTime = [this.assignRow.startTime, this.assignRow.endTime]
this.startTime = this.assignRow.startTime
this.endTime = this.assignRow.endTime
},
// 航次下拉
hcChange(e) {
this.vvyId = e;
this.hcList.forEach(v => {
if (v.value == e) {
this.vvyName = v.text
}
})
},
// 泊位下拉
bwChange(e) {
this.bthId = e;
this.bwList.forEach(v => {
if (v.value == e) {
this.bthIdName = v.text
}
})
},
// 工班下拉
gbChange(e) {
this.pwcTypeId = e;
this.gbList.forEach(v => {
if (v.value == e) {
this.pwcType = v.text
}
})
},
// 装卸类型下拉
zxChange(e) {
this.loaderTypeId = e;
this.zxList.forEach(v => {
if (v.value == e) {
this.loaderType = v.text
}
})
},
// 作业时间
changeLog(e) {
this.workTime = e
this.startTime = this.workTime[0].slice(0, this.workTime[0].length - 3)
this.endTime = this.workTime[1].slice(0, this.workTime[1].length - 3)
},
// 取消
cancel() {
uni.navigateTo({
url: '/pages/shipWork/workAssign'
})
},
// 弹框删除
delConfirm() {
let sql = `DELETE FROM shipmentAdviserLayoutRespList WHERE webId = '${this.assignRow.webId}';`
this.executeSql(sql)
uni.navigateTo({
url: '/pages/shipWork/workAssign'
})
},
// 删除
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 shipmentAdviserLayoutRespList SET vvyId = '${this.vvyId}', vvyName = '${this.vvyName}',
bthId = '${this.bthId}',bthIdName = '${this.bthIdName}', pwcTypeId = '${this.pwcTypeId}',
pwcType = '${this.pwcType}', personNumber = '${this.personNumber}',loaderTypeId = '${this.loaderTypeId}',
loaderType = '${this.loaderType}', vehicleSize = '${this.vehicleSize}', sparePart = '${this.sparePart}',
workTime = '${this.workTime}', startTime = '${this.startTime}', endTime = '${this.endTime}',webStatus = '${webStatus}',
webDate = '${webDate}' WHERE webId = '${this.assignRow.webId}';`
this.executeSql(sql)
} else if (this.obj.state == "add") {
let sql = `insert into shipmentAdviserLayoutRespList values('${webId}','${this.vvyId}','${this.vvyName}',
'${this.bthId}','${this.bthIdName}','${this.pwcTypeId}','${this.pwcType}','${this.personNumber}',
'${this.loaderTypeId}','${this.loaderType}','${this.vehicleSize}','${this.sparePart}','${this.workTime}',
'${this.startTime}','${this.endTime}','${this.shipInfo.tradeTypeName}',
'${this.shipInfo.importExportFlagName}','${this.shipInfo.spmName}',
'${webStatus}','${webDate}')`
this.executeSql(sql)
}
uni.navigateTo({
url: '/pages/shipWork/workAssign'
})
},
// 编辑
toGo(state) {
this.obj.state = state;
const params = encodeURIComponent(JSON.stringify(this.obj));
uni.navigateTo({
url: `/pages/shipWork/workAssignAdd?params=${params}`
})
},
executeSql(sql) {
sqlite.executeSqlCeshi(sql).then((value) => {
// 在resolve时执行的回调函数
console.log(value);
}).catch((error) => {
// 在reject时执行的回调函数
console.error(error);
});
},
}
}
</script>
<style lang="less" scoped>
.workAssignAdd {
.container {
padding: 30px 20px;
.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;
.required {
color: red;
margin-right: 5px;
}
p {
min-width: 85px;
text-align: right;
}
/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>