pad-app/pages/shipWork/opinionAdd.vue

535 lines
17 KiB
Vue
Raw Normal View History

2023-07-12 17:46:47 +08:00
<template>
<view class="opinionAdd">
2023-08-24 17:06:35 +08:00
<head-view :title="title" url="/pages/shipWork/opinion"></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>
2024-03-06 10:22:11 +08:00
<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-datetime-picker v-model="operationDate" type="date" :clear-icon="false" @change="changeLog"
v-if="obj.state != 'look'" :border="false" />
<text v-else>{{operationDate}}</text>
</view>
</view>
<view class="ul" v-for="(item,index) in vvyInfo">
2023-11-01 18:40:05 +08:00
<view class="li">
<p><text class="required" v-if="obj.state != 'look'">*</text></p>
2024-03-06 10:22:11 +08:00
<!-- <uni-data-select v-model="vvyId" :localdata="hcList" @change="hcChange"
2023-11-01 18:40:05 +08:00
v-if="obj.state != 'look'"></uni-data-select>
2024-03-06 10:22:11 +08:00
<text v-else>{{vvyName}}</text> -->
<text>{{ item.vvyName }}</text>
2023-11-01 18:40:05 +08:00
</view>
<view class="li">
<p>进出口</p>
2024-03-06 10:22:11 +08:00
<!-- <text>{{importExportFlagName}}</text> -->
<text>{{ item.importExportFlagName }}</text>
2023-11-01 18:40:05 +08:00
</view>
<view class="li">
<p>贸易类型</p>
2024-03-06 10:22:11 +08:00
<!-- <text>{{spmTradeName}}</text> -->
<text>{{ item.tradeTypeName }}</text>
2023-11-01 18:40:05 +08:00
</view>
<view class="li">
<p><text class="required" v-if="obj.state != 'look'">*</text></p>
2024-01-16 10:04:27 +08:00
<!-- <uni-data-select v-model="handlingType" :localdata="zxList" @change="zxChange"
v-if="obj.state != 'look'"></uni-data-select> -->
2024-03-06 10:22:11 +08:00
<!-- <text>{{handlingName}}</text> -->
<text>{{ item.importExportFlagName == "进口" ? '卸货' : '装货' }}</text>
2023-11-01 18:40:05 +08:00
</view>
<view class="li">
<p><text class="required" v-if="obj.state != 'look'">*</text></p>
2024-03-06 10:22:11 +08:00
<uni-number-box v-model="item['vehiclesNumber' + index]" :max="1000000000" v-if="obj.state != 'look'" />
<text v-else>{{item['vehiclesNumber' + index]}}</text>
2023-11-01 18:40:05 +08:00
</view>
<view class="li">
<p><text class="required" v-if="obj.state != 'look'">*</text></p>
2024-03-06 10:22:11 +08:00
<uni-number-box v-model="item['spareNumber' + index]" :max="1000000000" v-if="obj.state != 'look'" />
<text v-else>{{item['spareNumber' + index]}}</text>
2023-11-01 18:40:05 +08:00
</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">
2023-12-22 17:48:52 +08:00
<view class="btn qx" @click="cancel"></view>
<view class="btn sc" v-if="obj.state == 'look'" @click="del"></view>
<view class="btn bc" v-if="obj.state == 'add' || obj.state == 'edit'" @click="save"></view>
<view class="btn bc" v-if="obj.state == 'look'" @click="toGo('edit')"></view>
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 16:32:50 +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
opinionRow: {},
opinionRowIndex: 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-07-20 17:16:08 +08:00
bthId: "",
bthIdName: "",
bwList: [],
2023-07-12 17:46:47 +08:00
// 装卸类型下拉框
2023-09-23 20:16:54 +08:00
handlingType: "",
2023-11-01 18:40:05 +08:00
handlingName: "",
2023-07-20 17:16:08 +08:00
zxList: [],
2023-07-12 17:46:47 +08:00
// 车辆数量
2023-09-23 20:16:54 +08:00
vehiclesNumber: 0,
2023-07-12 17:46:47 +08:00
// 备件数量
2023-09-23 20:16:54 +08:00
spareNumber: 0,
2023-07-12 17:46:47 +08:00
// 作业时间
2023-09-23 20:16:54 +08:00
operationDate: [''],
2023-08-04 17:06:33 +08:00
2023-11-01 18:40:05 +08:00
// 删除质量意见征询单id
delCsIds: [],
vvyInfo: [],
importExportFlagName: "",
2023-11-21 17:43:02 +08:00
spmTradeName: "",
2023-11-01 18:40:05 +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() {
2024-01-16 10:04:27 +08:00
this.vtpId = uni.getStorageSync('vtpId')
this.delCsIds = uni.getStorageSync("delCsIds")
this.executeSql1('shipOption')
this.executeSql1("shipInfoTable")
this.executeSql1("voyageScheduleDataDetailRespDTOList")
2023-08-24 16:22:29 +08:00
if (this.obj.state == "edit") {
2023-09-23 20:16:54 +08:00
this.title = "编辑质量意见征询"
2023-08-24 16:22:29 +08:00
} else if (this.obj.state == "look") {
2023-09-23 20:16:54 +08:00
this.title = "查看质量意见征询"
2023-08-24 16:22:29 +08:00
} else {
2023-09-23 20:16:54 +08:00
this.title = "新增质量意见征询"
2023-08-24 16:22:29 +08:00
}
2024-01-16 10:04:27 +08:00
let that = this
setTimeout(() => {
if (that.obj.state == 'edit' || that.obj.state == 'look') {
that.getRow();
}
}, 100)
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
this.getShip()
} else if (tableName == 'shipInfoTable') {
this.shipInfo = value[0]
2024-03-06 10:22:11 +08:00
// console.log(this.shipInfo);
if(this.obj.state == "edit" || this.obj.state == "add") {
2024-03-07 13:58:14 +08:00
if(this.shipInfo.actualBerthingTime != 'null') this.operationDate = this.shipInfo.actualBerthingTime.split(' ')[0]
2024-03-06 10:22:11 +08:00
}
2023-11-01 18:40:05 +08:00
} else if (tableName == 'voyageScheduleDataDetailRespDTOList') {
this.vvyInfo = value
2024-03-06 10:22:11 +08:00
this.vvyInfo.map((item,index) => {
let vehiclesNumber = 'vehiclesNumber' + index
let spareNumber = 'spareNumber' + index
item[vehiclesNumber] = 0
item[spareNumber] = 0
return item
})
// console.log(this.vvyInfo);
2023-11-01 18:40:05 +08:00
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
// 获取船只信息
getShip() {
// 装卸类型数据
2023-08-03 15:36:23 +08:00
let zxOption = []
this.optionData.forEach((v, index) => {
if (v.dictionariesName == 'handTypeList') {
zxOption.push(v)
}
2024-05-31 16:53:04 +08:00
if (v.dictionariesName == 'vvyIdPlanNumber') {
if(this.obj.state == 'add') {
this.vehiclesNumber0 = v.ptrDesc
this.vehiclesNumber1 = v.ptrDesc
this.spareNumber0 = v.ptrEnDesc
this.spareNumber1 = v.ptrEnDesc
}
}
2023-08-03 15:36:23 +08:00
})
zxOption.forEach((v, index) => {
2023-07-20 17:16:08 +08:00
this.zxList.push({
text: v.ptrDesc,
value: v.ptrCode
})
})
2023-08-03 15:36:23 +08:00
// 船舶下拉数据
let bwOption = []
this.optionData.forEach((v, index) => {
if (v.dictionariesName == 'bthList') {
bwOption.push(v)
}
})
bwOption.forEach((v, index) => {
2023-07-20 17:16:08 +08:00
this.bwList.push({
2023-08-03 15:36:23 +08:00
text: v.ptrDesc,
value: v.ptrCode
2023-07-20 17:16:08 +08:00
})
})
},
// 获取当前行信息
getRow() {
this.opinionRow = uni.getStorageSync('opinionRow');
this.opinionRowIndex = uni.getStorageSync('opinionRowIndex');
this.vvyId = this.opinionRow.vvyId
this.vvyName = this.opinionRow.vvyName
2023-11-01 18:40:05 +08:00
this.importExportFlagName = this.opinionRow.importExportFlagName
2023-07-20 17:16:08 +08:00
this.bthId = this.opinionRow.bthId
this.bthIdName = this.opinionRow.bthIdName
2023-09-23 20:16:54 +08:00
this.handlingType = this.opinionRow.handlingType
2023-11-01 18:40:05 +08:00
this.handlingName = this.opinionRow.handlingName
2024-03-06 10:22:11 +08:00
this.vvyInfo[0].vehiclesNumber0 = this.opinionRow.vehiclesNumber
this.vvyInfo[0].spareNumber0 = this.opinionRow.spareNumber
if(this.vvyInfo.length > 1) {
this.vvyInfo[1].vehiclesNumber1 = this.opinionRow.vehiclesNumberDe
this.vvyInfo[1].spareNumber1 = this.opinionRow.spareNumberDe
}
2023-09-23 20:16:54 +08:00
this.operationDate = this.opinionRow.operationDate
2024-01-16 10:04:27 +08:00
this.vvyInfo.forEach(v => {
if (this.vvyId == v.vvyId) {
this.spmTradeName = v.tradeTypeName
}
})
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
2024-01-16 10:04:27 +08:00
if (this.importExportFlagName = "进口") {
this.handlingName = "卸货"
this.handlingType = "2"
} else {
this.handlingName = "装货"
this.handlingType = "1"
}
2023-11-01 18:40:05 +08:00
}
})
2023-07-12 17:46:47 +08:00
},
// 泊位下拉
bwChange(e) {
2023-07-20 17:16:08 +08:00
this.bthId = e;
this.bwList.forEach(v => {
if (v.value == e) {
this.bthIdName = v.text
}
})
2023-07-12 17:46:47 +08:00
},
// 装卸类型下拉
zxChange(e) {
2024-01-16 10:04:27 +08:00
console.log(e)
2023-11-01 18:40:05 +08:00
this.handlingType = e;
2023-07-20 17:16:08 +08:00
this.zxList.forEach(v => {
if (v.value == e) {
2023-11-01 18:40:05 +08:00
this.handlingName = v.text
2023-07-20 17:16:08 +08:00
}
})
},
// 作业时间
changeLog(e) {
2023-09-23 20:16:54 +08:00
this.operationDate = e
2023-07-12 17:46:47 +08:00
},
// 取消
cancel() {
2024-04-19 16:21:28 +08:00
uni.showModal({
title: '提示',
content: '将退出编辑,所有内容不保留',
success: function (res) {
if (res.confirm) {
uni.navigateTo({
url: '/pages/shipWork/opinion'
})
} else if (res.cancel) {
console.log('用户点击取消');
}
}
});
2023-07-12 17:46:47 +08:00
},
// 弹框删除
delConfirm() {
2023-11-01 18:40:05 +08:00
let sql = `DELETE FROM shipmentQualityConsultationRespList WHERE vqcId = '${this.opinionRow.vqcId}';`
2023-08-01 09:32:45 +08:00
this.executeSql(sql)
2023-11-28 17:52:09 +08:00
let reg = RegExp(/-/)
2023-12-08 17:42:10 +08:00
if (reg.test(this.opinionRow.vqcId) == false) {
2023-11-28 17:52:09 +08:00
this.delCsIds.push(this.opinionRow.vqcId)
uni.setStorageSync('delCsIds', this.delCsIds);
}
2023-07-20 17:16:08 +08:00
uni.navigateTo({
url: '/pages/shipWork/opinion'
})
},
// 删除
del() {
this.$refs.popup.open()
},
2023-07-12 17:46:47 +08:00
// 保存
save() {
2024-04-19 16:21:28 +08:00
if (this.bthId == "") {
uni.showModal({
title: '提示',
showCancel: false,
content: '请输入泊位!'
})
return
}
if (this.operationDate == "") {
uni.showModal({
title: '提示',
showCancel: false,
content: '请输入作业日期!'
})
return
}
2023-08-01 09:32:45 +08:00
let date = new Date().getTime()
2023-11-01 18:40:05 +08:00
let vqcId = uuidv4()
2023-08-01 09:32:45 +08:00
let webStatus = 0
2023-08-01 16:32:50 +08:00
let webDate = api.getDate(date)
2023-07-20 17:16:08 +08:00
if (this.obj.state == "edit") {
2024-03-06 10:22:11 +08:00
if(this.vvyInfo.length == 1) {
2023-08-01 09:32:45 +08:00
let sql =
2024-03-06 10:22:11 +08:00
`UPDATE shipmentQualityConsultationRespList SET vvyId = '${this.vvyInfo[0].vvyId}',vvyName = '${this.vvyInfo[0].vvyName}',importExportFlagName = '${this.vvyInfo[0].importExportFlagName}',
bthId = '${this.bthId}',bthIdName = '${this.bthIdName}',handlingType = '${this.vvyInfo[0].importExportFlagName == '进口' ? '2' : '1'}',handlingName = '${this.vvyInfo[0].importExportFlagName == '进口' ? '卸货' : '装货'}',
vehiclesNumber = '${this.vvyInfo[0].vehiclesNumber0}',spareNumber = '${this.vvyInfo[0].spareNumber0}',operationDate = '${this.operationDate}',webStatus = '${webStatus}',webDate = '${webDate}',vehiclesNumberDe='null',spareNumberDe='null' WHERE vqcId = '${this.opinionRow.vqcId}';`
2023-08-01 09:32:45 +08:00
this.executeSql(sql)
2024-03-06 10:22:11 +08:00
}
if(this.vvyInfo.length > 1) {
let vvyId = this.vvyInfo[0].vvyId+'/'+this.vvyInfo[1].vvyId
let vvyName = this.vvyInfo[0].vvyName+'/'+this.vvyInfo[1].vvyName
let importExportFlagName = this.vvyInfo[0].importExportFlagName+'/'+this.vvyInfo[1].importExportFlagName
let handlingType0 = this.vvyInfo[0].importExportFlagName == '进口' ? '2' : '1'
let handlingType1 = this.vvyInfo[1].importExportFlagName == '进口' ? '2' : '1'
let handlingType = handlingType0+'/'+handlingType1
let handlingName0 = this.vvyInfo[0].importExportFlagName == '进口' ? '卸货' : '装货'
let handlingName1 = this.vvyInfo[1].importExportFlagName == '进口' ? '卸货' : '装货'
let handlingName = handlingName0+'/'+handlingName1
let sql =
`UPDATE shipmentQualityConsultationRespList SET vvyId = '${vvyId}',vvyName = '${vvyName}',importExportFlagName = '${importExportFlagName}',
bthId = '${this.bthId}',bthIdName = '${this.bthIdName}',handlingType = '${handlingType}',handlingName = '${handlingName}',
vehiclesNumber = '${this.vvyInfo[0].vehiclesNumber0}',spareNumber = '${this.vvyInfo[0].spareNumber0}',operationDate = '${this.operationDate}',webStatus = '${webStatus}',webDate = '${webDate}',vehiclesNumberDe='${this.vvyInfo[1].vehiclesNumber1}',spareNumberDe='${this.vvyInfo[1].spareNumber1}' WHERE vqcId = '${this.opinionRow.vqcId}';`
this.executeSql(sql)
}
2023-07-20 17:16:08 +08:00
} else if (this.obj.state == "add") {
2024-03-06 10:22:11 +08:00
if(this.vvyInfo.length == 1) {
let sql = `insert into shipmentQualityConsultationRespList values('${vqcId}','${this.vvyInfo[0].vtpId}','${this.vvyInfo[0].vvyId}','${this.vvyInfo[0].vvyName}','${this.vvyInfo[0].importExportFlagName}',
'${this.bthId}','${this.bthIdName}','${this.vvyInfo[0].importExportFlagName == '进口' ? '2' : '1'}','${this.vvyInfo[0].importExportFlagName == '进口' ? '卸货' : '装货'}','${this.vvyInfo[0].vehiclesNumber0}',
'${this.vvyInfo[0].spareNumber0}','${this.operationDate}','${webStatus}','${webDate}','null','null')`
this.executeSql(sql)
}
if(this.vvyInfo.length > 1) {
let vtpId = this.vvyInfo[0].vtpId
let vvyId = this.vvyInfo[0].vvyId+'/'+this.vvyInfo[1].vvyId
let vvyName = this.vvyInfo[0].vvyName+'/'+this.vvyInfo[1].vvyName
let importExportFlagName = this.vvyInfo[0].importExportFlagName+'/'+this.vvyInfo[1].importExportFlagName
let handlingType0 = this.vvyInfo[0].importExportFlagName == '进口' ? '2' : '1'
let handlingType1 = this.vvyInfo[1].importExportFlagName == '进口' ? '2' : '1'
let handlingType = handlingType0+'/'+handlingType1
let handlingName0 = this.vvyInfo[0].importExportFlagName == '进口' ? '卸货' : '装货'
let handlingName1 = this.vvyInfo[1].importExportFlagName == '进口' ? '卸货' : '装货'
let handlingName = handlingName0+'/'+handlingName1
let sql = `insert into shipmentQualityConsultationRespList values('${vqcId}','${vtpId}','${vvyId}','${vvyName}','${importExportFlagName}',
'${this.bthId}','${this.bthIdName}','${handlingType}','${handlingName}','${this.vvyInfo[0].vehiclesNumber0}',
'${this.vvyInfo[0].spareNumber0}','${this.operationDate}','${webStatus}','${webDate}','${this.vvyInfo[1].vehiclesNumber1}','${this.vvyInfo[1].spareNumber1}')`
2023-08-01 09:32:45 +08:00
this.executeSql(sql)
2024-03-06 10:22:11 +08:00
}
2023-07-20 17:16:08 +08:00
}
2023-07-12 17:46:47 +08:00
uni.navigateTo({
url: '/pages/shipWork/opinion'
})
},
// 编辑
toGo(state) {
this.obj.state = state;
const params = encodeURIComponent(JSON.stringify(this.obj));
uni.navigateTo({
url: `/pages/shipWork/opinionAdd?params=${params}`
})
2023-08-01 09:32:45 +08:00
},
executeSql(sql) {
sqlite.executeSqlCeshi(sql).then((value) => {
// 在resolve时执行的回调函数
}).catch((error) => {
// 在reject时执行的回调函数
console.error(error);
});
},
2023-07-12 17:46:47 +08:00
}
}
</script>
<style lang="less" scoped>
.opinionAdd {
.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-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-01 18:40:05 +08:00
/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 {
2023-12-08 17:42:10 +08:00
position: fixed;
bottom: 0;
left: 0;
right: 0;
height: 80px;
background-color: #fff;
2023-07-12 17:46:47 +08:00
display: flex;
justify-content: center;
2023-12-22 17:48:52 +08:00
box-shadow: 0 -3px 7px 0 rgba(0, 0, 0, 0.10);
2023-07-12 17:46:47 +08:00
2023-12-22 17:48:52 +08:00
.btn {
margin: 15.5px 17px;
width: 200px;
height: 49px;
border-radius: 2px;
font-size: 18px;
text-align: center;
line-height: 49px;
}
.qx {
background-color: #eee;
}
.sc {
background-color: #E50101;
color: #fff;
}
.bc {
color: #fff;
background: #0067CF;
2023-07-12 17:46:47 +08:00
}
}
}
}
</style>