2023-07-12 17:46:47 +08:00
|
|
|
|
<template>
|
|
|
|
|
<view class="patrolAdd">
|
2023-08-24 17:06:35 +08:00
|
|
|
|
<head-view :title="title" url="/pages/shipWork/patrol"></head-view>
|
2023-11-01 18:40:05 +08:00
|
|
|
|
<view class="container contentFixed">
|
2023-07-20 17:16:08 +08:00
|
|
|
|
<view class="ul">
|
|
|
|
|
<view class="li">
|
2023-07-12 17:46:47 +08:00
|
|
|
|
<p>船名:</p>
|
2023-08-23 17:42:44 +08:00
|
|
|
|
<text>{{shipInfo.vslCnname}}</text>
|
2023-07-20 17:16:08 +08:00
|
|
|
|
</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"
|
2023-07-12 17:46:47 +08:00
|
|
|
|
v-if="obj.state != 'look'"></uni-data-select>
|
2023-07-20 17:16:08 +08:00
|
|
|
|
<text v-else>{{vvyName}}</text>
|
|
|
|
|
</view>
|
|
|
|
|
<view class="li">
|
2023-07-12 17:46:47 +08:00
|
|
|
|
<p>进出口:</p>
|
2023-08-23 17:42:44 +08:00
|
|
|
|
<text>{{shipInfo.importExportFlagName}}</text>
|
2023-07-20 17:16:08 +08:00
|
|
|
|
</view>
|
|
|
|
|
<view class="li">
|
2023-07-12 17:46:47 +08:00
|
|
|
|
<p>贸易类型:</p>
|
2023-11-01 18:40:05 +08:00
|
|
|
|
<text>{{shipInfo.spmTradeName}}</text>
|
2023-07-20 17:16:08 +08:00
|
|
|
|
</view>
|
|
|
|
|
<view class="li">
|
|
|
|
|
<p><text class="required" v-if="obj.state != 'look'">*</text>类型:</p>
|
|
|
|
|
<uni-easyinput v-if="obj.state != 'look'" v-model="type" placeholder="请输入"></uni-easyinput>
|
|
|
|
|
<text v-else>{{type}}</text>
|
|
|
|
|
</view>
|
|
|
|
|
<view class="li tpLi">
|
|
|
|
|
<p><text class="required" v-if="obj.state != 'look'">*</text>图片上传:</p>
|
2023-07-12 17:46:47 +08:00
|
|
|
|
<template v-if="obj.state != 'look'">
|
|
|
|
|
<view class="picture">
|
2023-09-23 20:16:54 +08:00
|
|
|
|
<uni-file-picker limit="9" v-model="urlList" fileMediatype="image" @select="select"
|
|
|
|
|
@delete="delUrl" title="最多选择9张图片"></uni-file-picker>
|
2023-07-12 17:46:47 +08:00
|
|
|
|
</view>
|
|
|
|
|
</template>
|
|
|
|
|
<view class="pictureLook" v-else>
|
2023-09-23 20:16:54 +08:00
|
|
|
|
<view v-for="(item,index) in urlList" :key="index">
|
|
|
|
|
<image :src="item.url" mode="widthFix">
|
2023-07-20 17:16:08 +08:00
|
|
|
|
</view>
|
2023-07-12 17:46:47 +08:00
|
|
|
|
</view>
|
2023-07-20 17:16:08 +08:00
|
|
|
|
</view>
|
|
|
|
|
<view class="li wLi">
|
|
|
|
|
<p><text class="required" v-if="obj.state != 'look'">*</text>描述:</p>
|
|
|
|
|
<uni-easyinput type="textarea" autoHeight v-model="remark" placeholder="请输入任务描述(200字以内)"
|
2023-07-12 17:46:47 +08:00
|
|
|
|
maxlength="200" v-if="obj.state != 'look'"></uni-easyinput>
|
2023-07-20 17:16:08 +08:00
|
|
|
|
<text v-else>{{remark}}</text>
|
|
|
|
|
</view>
|
|
|
|
|
</view>
|
2023-07-24 16:56:46 +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-12 17:46:47 +08:00
|
|
|
|
<view class="btnList">
|
|
|
|
|
<van-button type="default" @click="cancel">取消</van-button>
|
2023-07-20 17:16:08 +08:00
|
|
|
|
<van-button type="danger" v-if="obj.state == 'look'" @click="del">删除</van-button>
|
2023-07-12 17:46:47 +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>
|
|
|
|
|
</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-09-23 20:16:54 +08:00
|
|
|
|
import {
|
|
|
|
|
pathToBase64,
|
|
|
|
|
base64ToPath
|
|
|
|
|
} from '../../js_sdk/mmmm-image-tools/index.js'
|
|
|
|
|
import {
|
|
|
|
|
compressImgBySize
|
|
|
|
|
} from '@/common/compressImg'
|
2023-08-01 16:50:18 +08:00
|
|
|
|
import {
|
|
|
|
|
v4 as uuidv4
|
|
|
|
|
} from 'uuid';
|
2023-09-23 20:16:54 +08:00
|
|
|
|
let that;
|
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-07-20 17:16:08 +08:00
|
|
|
|
patrolRow: {},
|
|
|
|
|
patrolRowIndex: {},
|
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
|
|
|
|
type: "",
|
|
|
|
|
// 图片
|
2023-09-23 20:16:54 +08:00
|
|
|
|
urlList: [],
|
2023-08-18 17:28:11 +08:00
|
|
|
|
ysUrl: [],
|
2023-09-23 20:16:54 +08:00
|
|
|
|
delUrlList: [],
|
2023-07-12 17:46:47 +08:00
|
|
|
|
// 描述
|
2023-07-20 17:16:08 +08:00
|
|
|
|
remark: "",
|
2023-08-18 17:28:11 +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() {
|
2023-09-23 20:16:54 +08:00
|
|
|
|
that = this
|
2023-07-20 17:16:08 +08:00
|
|
|
|
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 = "编辑安全巡检"
|
|
|
|
|
} else if (this.obj.state == "look") {
|
|
|
|
|
this.title = "查看安全巡检"
|
|
|
|
|
} else {
|
|
|
|
|
this.title = "新增安全巡检"
|
|
|
|
|
}
|
2023-08-03 15:36:23 +08:00
|
|
|
|
this.executeSql1('shipOption')
|
2023-08-23 17:42:44 +08:00
|
|
|
|
this.executeSql1("shipInfoTable")
|
2023-09-23 20:16:54 +08:00
|
|
|
|
|
2023-07-12 17:46:47 +08:00
|
|
|
|
},
|
|
|
|
|
methods: {
|
2023-08-03 15:36:23 +08:00
|
|
|
|
// 查
|
|
|
|
|
executeSql1(tableName) {
|
|
|
|
|
let sql = `select * from ${tableName}`
|
|
|
|
|
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]
|
|
|
|
|
}
|
2023-08-03 15:36:23 +08:00
|
|
|
|
}).catch((error) => {
|
|
|
|
|
// 在reject时执行的回调函数
|
|
|
|
|
console.error(error);
|
|
|
|
|
});
|
|
|
|
|
},
|
2023-08-18 17:28:11 +08:00
|
|
|
|
executeSql2(tableName) {
|
|
|
|
|
let sql = `select * from ${tableName} WHERE contactId = '${this.patrolRow.webId}'`
|
|
|
|
|
sqlite.executeSqlCeshi(sql).then((value) => {
|
|
|
|
|
// 在resolve时执行的回调函数
|
2023-09-23 20:16:54 +08:00
|
|
|
|
this.urlList = value
|
2023-08-18 17:28:11 +08:00
|
|
|
|
}).catch((error) => {
|
|
|
|
|
// 在reject时执行的回调函数
|
|
|
|
|
console.error(error);
|
|
|
|
|
});
|
|
|
|
|
},
|
2023-07-20 17:16:08 +08:00
|
|
|
|
// 获取船只信息
|
|
|
|
|
getShip() {
|
2023-08-23 17:42:44 +08:00
|
|
|
|
// this.shipInfo = uni.getStorageSync('shipInfo')
|
2023-08-03 15:36:23 +08:00
|
|
|
|
// 航次下拉数据
|
|
|
|
|
let hcOption = []
|
|
|
|
|
this.optionData.forEach((v, index) => {
|
|
|
|
|
if (v.dictionariesName == 'vvyList') {
|
|
|
|
|
hcOption.push(v)
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
hcOption.forEach((v, index) => {
|
2023-07-20 17:16:08 +08:00
|
|
|
|
this.hcList.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.patrolRow = uni.getStorageSync('patrolRow');
|
|
|
|
|
this.patrolRowIndex = uni.getStorageSync('patrolRowIndex');
|
2023-09-23 20:16:54 +08:00
|
|
|
|
this.executeSql2('safetyInspectionRespUrlList')
|
2023-07-20 17:16:08 +08:00
|
|
|
|
this.vvyId = this.patrolRow.vvyId
|
|
|
|
|
this.vvyName = this.patrolRow.vvyName
|
|
|
|
|
this.type = this.patrolRow.type
|
|
|
|
|
this.remark = this.patrolRow.remark
|
|
|
|
|
},
|
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
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
// 图片上传
|
|
|
|
|
select(e) {
|
2023-09-23 20:16:54 +08:00
|
|
|
|
pathToBase64(e.tempFiles[0].path)
|
|
|
|
|
.then(base64 => {
|
|
|
|
|
compressImgBySize(base64, 1200).then(baseImg => {
|
|
|
|
|
// 输出图片base64
|
|
|
|
|
that.ysUrl.push(baseImg)
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
.catch(error => {
|
|
|
|
|
console.error(error)
|
|
|
|
|
})
|
2023-08-18 17:28:11 +08:00
|
|
|
|
},
|
2023-09-23 20:16:54 +08:00
|
|
|
|
// 移除图片
|
|
|
|
|
delUrl(e) {
|
|
|
|
|
if (this.obj.state == 'edit') {
|
|
|
|
|
this.delUrlList.push(e.tempFile.webId)
|
|
|
|
|
}
|
|
|
|
|
pathToBase64(e.tempFile.path)
|
|
|
|
|
.then(base64 => {
|
|
|
|
|
compressImgBySize(base64, 1200).then(baseImg => {
|
|
|
|
|
// 输出图片base64
|
|
|
|
|
this.ysUrl.forEach((v, index) => {
|
|
|
|
|
if (v == base64) {
|
|
|
|
|
this.ysUrl.splice(index, 1)
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
.catch(error => {
|
|
|
|
|
console.error(error)
|
|
|
|
|
})
|
2023-07-12 17:46:47 +08:00
|
|
|
|
},
|
|
|
|
|
// 取消
|
|
|
|
|
cancel() {
|
|
|
|
|
uni.navigateTo({
|
|
|
|
|
url: '/pages/shipWork/patrol'
|
|
|
|
|
})
|
|
|
|
|
},
|
2023-07-24 16:56:46 +08:00
|
|
|
|
// 弹框删除
|
|
|
|
|
delConfirm() {
|
2023-09-23 20:16:54 +08:00
|
|
|
|
for (var i = 0; i < this.urlList.length; i++) {
|
|
|
|
|
let delSql = `DELETE FROM safetyInspectionRespUrlList WHERE webId = '${this.urlList[i].webId}';`
|
|
|
|
|
this.executeSql(delSql)
|
|
|
|
|
}
|
2023-08-01 17:26:06 +08:00
|
|
|
|
let sql = `DELETE FROM safetyInspectionRespList WHERE webId = '${this.patrolRow.webId}';`
|
2023-08-01 09:32:45 +08:00
|
|
|
|
this.executeSql(sql)
|
2023-07-20 17:16:08 +08:00
|
|
|
|
uni.navigateTo({
|
|
|
|
|
url: '/pages/shipWork/patrol'
|
|
|
|
|
})
|
|
|
|
|
},
|
2023-07-24 16:56:46 +08:00
|
|
|
|
// 删除
|
|
|
|
|
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-08-01 16:50:18 +08:00
|
|
|
|
let webId = 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 =
|
|
|
|
|
`UPDATE safetyInspectionRespList SET vvyId = '${this.vvyId}', vvyName = '${this.vvyName}',
|
|
|
|
|
type = '${this.type}',remark = '${this.remark}', webStatus = '${webStatus}',
|
|
|
|
|
webDate = '${webDate}' WHERE webId = '${this.patrolRow.webId}';`
|
|
|
|
|
this.executeSql(sql)
|
2023-09-23 20:16:54 +08:00
|
|
|
|
if (this.delUrlList.length > 0) {
|
|
|
|
|
for (var i = 0; i < this.delUrlList.length; i++) {
|
|
|
|
|
let delSql = `DELETE FROM safetyInspectionRespUrlList WHERE webId = '${this.delUrlList[i]}';`
|
|
|
|
|
this.executeSql(delSql)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
for (var i = 0; i < this.ysUrl.length; i++) {
|
|
|
|
|
let webId2 = uuidv4()
|
|
|
|
|
let sql2 = `insert into safetyInspectionRespUrlList values('${webId2}','${this.patrolRow.webId}','${this.ysUrl[i]}',
|
|
|
|
|
'${webStatus}','${webDate}')`
|
|
|
|
|
this.executeSql(sql2)
|
|
|
|
|
}
|
2023-07-20 17:16:08 +08:00
|
|
|
|
} else if (this.obj.state == "add") {
|
2023-08-01 09:32:45 +08:00
|
|
|
|
let sql = `insert into safetyInspectionRespList values('${webId}','${this.vvyId}','${this.vvyName}',
|
2023-08-23 17:42:44 +08:00
|
|
|
|
'${this.type}','${this.remark}','${this.shipInfo.tradeTypeName}','${this.shipInfo.importExportFlagName}',
|
|
|
|
|
'${this.shipInfo.spmName}','${webStatus}','${webDate}')`
|
2023-08-01 09:32:45 +08:00
|
|
|
|
this.executeSql(sql)
|
2023-08-18 17:28:11 +08:00
|
|
|
|
for (var i = 0; i < this.ysUrl.length; i++) {
|
|
|
|
|
let webId2 = uuidv4()
|
|
|
|
|
let sql2 = `insert into safetyInspectionRespUrlList values('${webId2}','${webId}','${this.ysUrl[i]}',
|
|
|
|
|
'${webStatus}','${webDate}')`
|
|
|
|
|
this.executeSql(sql2)
|
|
|
|
|
}
|
2023-07-20 17:16:08 +08:00
|
|
|
|
}
|
2023-07-12 17:46:47 +08:00
|
|
|
|
uni.navigateTo({
|
|
|
|
|
url: '/pages/shipWork/patrol'
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
// 编辑
|
|
|
|
|
toGo(state) {
|
|
|
|
|
this.obj.state = state;
|
|
|
|
|
const params = encodeURIComponent(JSON.stringify(this.obj));
|
|
|
|
|
uni.navigateTo({
|
|
|
|
|
url: `/pages/shipWork/patrolAdd?params=${params}`
|
|
|
|
|
})
|
2023-08-01 09:32:45 +08:00
|
|
|
|
},
|
|
|
|
|
executeSql(sql) {
|
|
|
|
|
sqlite.executeSqlCeshi(sql).then((value) => {
|
|
|
|
|
// 在resolve时执行的回调函数
|
2023-08-18 17:28:11 +08:00
|
|
|
|
// console.log(value);
|
2023-08-01 09:32:45 +08:00
|
|
|
|
}).catch((error) => {
|
|
|
|
|
// 在reject时执行的回调函数
|
|
|
|
|
console.error(error);
|
|
|
|
|
});
|
|
|
|
|
},
|
2023-07-12 17:46:47 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style lang="less" scoped>
|
|
|
|
|
.patrolAdd {
|
|
|
|
|
.container {
|
|
|
|
|
padding: 30px 20px;
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
|
.wLi {
|
2023-07-20 17:16:08 +08:00
|
|
|
|
width: 100% !important;
|
2023-07-12 17:46:47 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.tpLi {
|
2023-07-20 17:16:08 +08:00
|
|
|
|
width: 100% !important;
|
|
|
|
|
display: block !important;
|
2023-07-12 17:46:47 +08:00
|
|
|
|
|
|
|
|
|
p {
|
2023-07-20 17:16:08 +08:00
|
|
|
|
text-align: left !important;
|
2023-07-12 17:46:47 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-07-20 17:16:08 +08:00
|
|
|
|
.li {
|
2023-07-12 17:46:47 +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;
|
|
|
|
|
|
|
|
|
|
.required {
|
|
|
|
|
color: red;
|
|
|
|
|
margin-right: 5px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
p {
|
|
|
|
|
min-width: 85px;
|
|
|
|
|
text-align: right;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.picture {
|
|
|
|
|
/deep/.file-picker__box {
|
|
|
|
|
width: 120px !important;
|
|
|
|
|
height: 120px !important;
|
|
|
|
|
padding-top: 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.pictureLook {
|
|
|
|
|
display: flex;
|
|
|
|
|
flex-wrap: wrap;
|
|
|
|
|
|
2023-07-20 17:16:08 +08:00
|
|
|
|
image {
|
2023-07-12 17:46:47 +08:00
|
|
|
|
width: 120px;
|
|
|
|
|
height: 120px;
|
|
|
|
|
margin: 10px;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.btnList {
|
|
|
|
|
display: flex;
|
|
|
|
|
justify-content: center;
|
|
|
|
|
|
|
|
|
|
/deep/ .van-button {
|
|
|
|
|
margin: 30px 20px;
|
|
|
|
|
width: 120px;
|
|
|
|
|
height: 50px;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</style>
|