pad-app/pages/shipWork/mafiAdd.vue

408 lines
10 KiB
Vue
Raw Normal View History

2023-07-12 17:46:47 +08:00
<template>
<view class="mafiAdd">
2023-08-24 17:06:35 +08:00
<head-view :title="title" url="/pages/shipWork/mafi"></head-view>
2023-11-01 18:40:05 +08:00
<view class="container contentFixed">
<view class="info">
<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>{{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-datetime-picker v-model="workDate" type="date" :clear-icon="false" @change="changeLog"
v-if="obj.state != 'look'" :border="false" />
<text v-else>{{workDate}}</text>
</view>
<view class="li">
<p><text class="required" v-if="obj.state != 'look'">*</text></p>
<uni-easyinput v-if="obj.state != 'look'" v-model="mafiBarcode"
placeholder="请输入"></uni-easyinput>
<text v-else>{{mafiBarcode}}</text>
</view>
<view class="li">
<p><text class="required" v-if="obj.state != 'look'">*</text></p>
<uni-number-box v-model="size" :max="1000000000" v-if="obj.state != 'look'" />
<text v-else>{{size}}</text>
</view>
<view class="li">
<p><text class="required" v-if="obj.state != 'look'">*</text></p>
<uni-data-select v-model="typeId" :localdata="lxList" @change="lxChange"
v-if="obj.state != 'look'"></uni-data-select>
<text v-else>{{type}}</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>{{loadType}}</text>
</view>
2023-07-20 17:16:08 +08:00
</view>
2023-11-01 18:40:05 +08:00
<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>
<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-20 17:16:08 +08:00
</view>
2023-07-12 17:46:47 +08:00
</view>
</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-08-01 16:50:18 +08:00
import {
v4 as uuidv4
} from 'uuid';
2023-07-12 17:46:47 +08:00
export default {
data() {
return {
2023-08-24 16:22:29 +08:00
title: "",
2023-08-23 17:42:44 +08:00
shipInfo: {},
2023-07-12 17:46:47 +08:00
obj: {},
2023-11-01 18:40:05 +08:00
vtpId: "",
2023-07-20 17:16:08 +08:00
mafiRow: {},
mafiRowIndex: 0,
2023-07-12 17:46:47 +08:00
// 航次下拉框
2023-07-20 17:16:08 +08:00
vvyId: "",
vvyName: "",
hcList: [],
2023-07-12 17:46:47 +08:00
// 作业时间
2023-08-01 09:32:45 +08:00
workDate: [""],
2023-07-12 17:46:47 +08:00
// 马菲板号
2023-07-20 17:16:08 +08:00
mafiBarcode: "",
2023-07-12 17:46:47 +08:00
// 尺码
2023-07-20 17:16:08 +08:00
size: 0,
2023-07-12 17:46:47 +08:00
// 类型下拉框
2023-08-01 09:32:45 +08:00
typeId: "",
type: "",
2023-07-12 17:46:47 +08:00
lxList: [{
2023-11-01 18:40:05 +08:00
value: "FULL",
2023-11-24 15:55:58 +08:00
text: "重板"
2023-07-12 17:46:47 +08:00
},
{
2023-11-01 18:40:05 +08:00
value: "EMPTY",
2023-11-24 15:55:58 +08:00
text: "空板"
2023-07-12 17:46:47 +08:00
},
],
// 装卸类型下拉框
2023-07-20 17:16:08 +08:00
loaderTypeId: "",
2023-11-01 18:40:05 +08:00
loadType: "",
zxList: [{
value: "LOAD",
text: "装货"
},
{
value: "DISC",
text: "卸货"
}
],
// 审核状态
status: 0,
// 删除MAFIid
delMfIds: [],
vvyInfo: [],
importExportFlagName: "",
2023-11-21 17:43:02 +08:00
spmTradeName: "",
2023-08-23 17:42:44 +08:00
2023-08-03 15:36:23 +08:00
// 下拉数据
optionData: [],
2023-07-12 17:46:47 +08:00
}
},
onLoad(options) {
if ('params' in options) {
// 获取传递的对象参数使用decodeURIComponent解码并转为对象
this.obj = JSON.parse(decodeURIComponent(options.params))
}
},
2023-07-20 17:16:08 +08:00
mounted() {
if (this.obj.state == 'edit' || this.obj.state == 'look') {
this.getRow();
}
2023-08-24 16:22:29 +08:00
if (this.obj.state == "edit") {
this.title = "编辑MAFI清单"
} else if (this.obj.state == "look") {
this.title = "查看MAFI清单"
} else {
this.title = "新增MAFI清单"
}
2023-11-01 18:40:05 +08:00
this.vtpId = uni.getStorageSync('vtpId')
this.delMfIds = uni.getStorageSync("delMfIds")
2023-08-03 15:36:23 +08:00
this.executeSql1('shipOption')
2023-08-23 17:42:44 +08:00
this.executeSql1("shipInfoTable")
2023-11-01 18:40:05 +08:00
this.executeSql1("voyageScheduleDataDetailRespDTOList")
2023-07-20 17:16:08 +08:00
},
2023-07-12 17:46:47 +08:00
methods: {
2023-08-03 15:36:23 +08:00
// 查
executeSql1(tableName) {
2023-11-01 18:40:05 +08:00
let sql = `select * from ${tableName} WHERE vtpId = '${this.vtpId}'`
2023-08-03 15:36:23 +08:00
sqlite.executeSqlCeshi(sql).then((value) => {
// 在resolve时执行的回调函数
2023-08-23 17:42:44 +08:00
if (tableName == 'shipOption') {
this.optionData = value
} 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
})
})
2023-08-23 17:42:44 +08:00
}
2023-08-03 15:36:23 +08:00
}).catch((error) => {
// 在reject时执行的回调函数
console.error(error);
});
},
2023-07-20 17:16:08 +08:00
// 获取当前行信息
getRow() {
this.mafiRow = uni.getStorageSync('mafiRow');
this.mafiRowIndex = uni.getStorageSync('mafiRowIndex');
this.vvyId = this.mafiRow.vvyId
this.vvyName = this.mafiRow.vvyName
2023-11-01 18:40:05 +08:00
this.importExportFlagName = this.mafiRow.importExportFlagName
2023-07-20 17:16:08 +08:00
this.loaderTypeId = this.mafiRow.loaderTypeId
2023-11-01 18:40:05 +08:00
this.loadType = this.mafiRow.loadType
if (this.mafiRow.workDate != "") {
this.workDate = this.mafiRow.workDate
} else {
this.workDate = ""
}
2023-08-01 09:32:45 +08:00
this.typeId = this.mafiRow.typeId
2023-11-01 18:40:05 +08:00
this.type = this.mafiRow.typeId
2023-07-20 17:16:08 +08:00
this.size = this.mafiRow.size
this.mafiBarcode = this.mafiRow.mafiBarcode
2023-11-01 18:40:05 +08:00
this.status = this.mafiRow.status
2023-07-20 17:16:08 +08:00
},
2023-07-12 17:46:47 +08:00
// 航次下拉
hcChange(e) {
2023-07-20 17:16:08 +08:00
this.vvyId = e;
this.hcList.forEach(v => {
if (v.value == e) {
this.vvyName = 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-07-12 17:46:47 +08:00
},
// 类型下拉
lxChange(e) {
2023-11-01 18:40:05 +08:00
console.log(e)
2023-08-01 09:32:45 +08:00
this.typeId = e;
2023-07-20 17:16:08 +08:00
this.lxList.forEach(v => {
if (v.value == e) {
2023-08-01 09:32:45 +08:00
this.type = v.text
2023-07-20 17:16:08 +08:00
}
})
2023-07-12 17:46:47 +08:00
},
// 装卸类型下拉
zxChange(e) {
2023-07-20 17:16:08 +08:00
this.loaderTypeId = e;
this.zxList.forEach(v => {
if (v.value == e) {
2023-11-01 18:40:05 +08:00
this.loadType = v.text
2023-07-20 17:16:08 +08:00
}
})
},
// 作业时间
changeLog(e) {
2023-08-01 09:32:45 +08:00
this.workDate = e
2023-07-12 17:46:47 +08:00
},
// 取消
cancel() {
uni.navigateTo({
url: '/pages/shipWork/mafi'
})
},
// 弹框删除
delConfirm() {
2023-11-01 18:40:05 +08:00
let sql = `DELETE FROM mafiListRespList WHERE smlId = '${this.mafiRow.smlId}';`
2023-08-01 09:32:45 +08:00
this.executeSql(sql)
2023-11-01 18:40:05 +08:00
this.delMfIds.push(this.mafiRow.smlId)
uni.setStorageSync('delMfIds', this.delMfIds);
2023-07-20 17:16:08 +08:00
uni.navigateTo({
url: '/pages/shipWork/mafi'
})
},
// 删除
del() {
this.$refs.popup.open()
},
2023-07-12 17:46:47 +08:00
// 保存
save() {
2023-08-01 09:32:45 +08:00
let date = new Date().getTime()
2023-11-01 18:40:05 +08:00
let smlId = uuidv4()
2023-08-01 09:32:45 +08:00
let webStatus = 0
2023-08-01 14:35:05 +08:00
let webDate = api.getDate(date)
2023-07-20 17:16:08 +08:00
if (this.obj.state == "edit") {
2023-08-01 09:32:45 +08:00
let sql =
2023-11-01 18:40:05 +08:00
`UPDATE mafiListRespList SET vvyId = '${this.vvyId}', vvyName = '${this.vvyName}', importExportFlagName = '${this.importExportFlagName}',
loaderTypeId = '${this.loaderTypeId}',loadType = '${this.loaderTypeId}', typeId = '${this.typeId}',
type = '${this.typeId}',size = '${this.size}',mafiBarcode = '${this.mafiBarcode}',workDate = '${this.workDate}',
webStatus = '${webStatus}',webDate = '${webDate}' WHERE smlId = '${this.mafiRow.smlId}';`
2023-08-01 09:32:45 +08:00
this.executeSql(sql)
2023-07-20 17:16:08 +08:00
} else if (this.obj.state == "add") {
2023-11-01 18:40:05 +08:00
let sql = `insert into mafiListRespList values('${smlId}','${this.vtpId}','${this.vvyId}','${this.vvyName}','${this.importExportFlagName}',
'${this.loaderTypeId}','${this.loaderTypeId}','${this.typeId}','${this.typeId}','${this.size}',
'${this.mafiBarcode}','${this.workDate}','${0}','${webStatus}','${webDate}')`
2023-08-01 09:32:45 +08:00
this.executeSql(sql)
2023-07-20 17:16:08 +08:00
}
2023-07-12 17:46:47 +08:00
uni.navigateTo({
url: '/pages/shipWork/mafi'
})
},
// 编辑
toGo(state) {
this.obj.state = state;
const params = encodeURIComponent(JSON.stringify(this.obj));
uni.navigateTo({
url: `/pages/shipWork/mafiAdd?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);
});
},
2023-07-12 17:46:47 +08:00
}
}
</script>
<style lang="less" scoped>
.mafiAdd {
.container {
2023-11-01 18:40:05 +08:00
padding: 16px;
background-color: #F6F7F9;
.info {
background-color: #fff;
}
2023-07-12 17:46:47 +08:00
2023-07-20 17:16:08 +08:00
.ul {
2023-07-12 17:46:47 +08:00
display: flex;
flex-wrap: wrap;
justify-content: space-between;
2023-11-01 18:40:05 +08:00
.wLi {
width: 100% !important;
}
2023-07-20 17:16:08 +08:00
.li {
2023-11-01 18:40:05 +08:00
width: 49%;
2023-07-12 17:46:47 +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-12 17:46:47 +08:00
.required {
color: red;
margin-right: 5px;
}
/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-07-12 17:46:47 +08:00
}
/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;
}
2023-11-21 17:43:02 +08:00
2023-11-01 18:40:05 +08:00
/deep/.is-input-border {
margin-top: 8px;
height: 40px;
}
/deep/.uni-date {
flex: none;
width: 25%;
text-align: right;
display: flex;
flex-direction: column;
justify-content: center;
}
/deep/.uni-date-x .icon-calendar {
display: none;
}
/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;
}
2023-07-12 17:46:47 +08:00
}
}
.btnList {
display: flex;
justify-content: center;
/deep/ .van-button {
margin: 30px 20px;
width: 120px;
height: 50px;
}
}
}
}
</style>