<template>
	<view class="noticeSign">
		<head-view :title="title" url="/pages/shipWork/notice"></head-view>
		<view class="contentFixed">
			<custom-tabs type="c1" :value="tabsValue" @change="tabsChange">
				<custom-tab-pane :label="item.name" v-for="(item,index) in tabsList" :name="'c1_'+index" :key="index">
					<view></view>
					<view style="padding: 16px; padding-bottom: 0;">
						<view class="container">
							<view class="head">
								<view class="leftHead">
									<image id="HT-logo" src="../../static/images/theme/logo.png" mode="widthFix" />
								</view>
								<view class="rightHead">
									<p>上海海通国际汽车码头有限公司</p>
									<text>SHANGHAI HAITONG INTERNATIONAL AUTOMOTIVE TERMINAL CO. LTD.</text>
								</view>
							</view>
							<view class="headTItle">
								<view class="titleLeft"></view>
								<view class="title">
									<p>海通码头船舶装/卸货通知单</p>
									<text>Vessel Operation Notic</text>
								</view>
								<view class="titleRight">
									<view>
										<text>编号/N0:</text>
										<text>QR-7.5.1-01-05-M</text>
									</view>
								</view>
							</view>
							<view class="ul">
								<view class="li">
									<p>船名(M/V):</p><text>{{shipInfo.vslEnname}}</text>
								</view>
								<view class="li">
									<p>航次(Voy):</p><text>{{tableInfo.vvyName}}</text>
								</view>
								<view class="li">
									<p>日期Date:</p><text>{{tableInfo.workDate}}</text>
								</view>
							</view>
							<view class="listTitle">
								<p>检查项目(Check List)</p>
							</view>
							<table id="t-main">
								<tbody>
									<tr class="trTitle">
										<td class="td1h">靠泊前/后准备及安全措施的落实</td>
										<td class="center">YES</td>
										<td class="td3">NO</td>
									</tr>
									<tr class="content">
										<td class="td1">
											<p> 1.Was the effective cushion put under ramp?</p>
											<p>有效衬垫物已放在跳板下？</p>
										</td>
										<td class="td2">
											<radio :checked="true" :disabled="true" />
										</td>
										<td class="td3">
											<radio :checked="false" :disabled="true" />
										</td>
									</tr>
									<tr class="content">
										<td class="td1">
											<p> 2.The ship's height and with of deck、slope、passage、route way ete.should
												be
												accorded with
												the loading/unloading?</p>
											<p>船舶装卸货物的甲板高度、宽度、通道等入口应当符合此次装/卸货物的安全要求？</p>
										</td>
										<td class="td2">
											<radio :checked="true" :disabled="true" />
										</td>
										<td class="td3">
											<radio :checked="false" :disabled="true" />
										</td>
									</tr>
									<tr class="content">
										<td class="td1">
											<p> 3.Has the following equipments been propared and checked?</p>
											<p>下列设备已备好并检查？</p>
										</td>
										<td class="td2"></td>
										<td class="td3"></td>
									</tr>
									<tr class="content">
										<td class="td1">
											<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;1）Ship's ramp,including
												stem-ramp、side-ramp、and
												inner-ramp.</p>
											<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;船舶所有跳板处于有效、可用的工作状态</p>
										</td>
										<td class="td2">
											<radio :checked="true" :disabled="true" />
										</td>
										<td class="td3">
											<radio :checked="false" :disabled="true" />
										</td>
									</tr>
									<tr class="content">
										<td class="td1">
											<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;2）The deck of loaded cargo has been
												using in
												condition.</p>
											<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;装卸货的甲板处于良好、可用的状态</p>
										</td>
										<td class="td2">
											<radio :checked="true" :disabled="true" />
										</td>
										<td class="td3">
											<radio :checked="false" :disabled="true" />
										</td>
									</tr>
									<tr class="content">
										<td class="td1">
											<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;3）All of the rout way is clear and
												effective
												in
												loaded cargo deck.</p>
											<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;所有通道保持有效的畅通</p>
										</td>
										<td class="td2">
											<radio :checked="true" :disabled="true" />
										</td>
										<td class="td3">
											<radio :checked="false" :disabled="true" />
										</td>
									</tr>
									<tr class="content">
										<td class="td1">
											<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;4）Ventilation equipment are
												guarantced and
												keep
												ready.</p>
											<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;通风设备已经开启并且设备良好</p>
										</td>
										<td class="td2">
											<radio :checked="true" :disabled="true" />
										</td>
										<td class="td3">
											<radio :checked="false" :disabled="true" />
										</td>
									</tr>
									<tr class="content">
										<td class="td1">
											<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;5）The illuminative equipment are in
												good
												condition.
											</p>
											<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;创仓内照明设备良好</p>
										</td>
										<td class="td2">
											<radio :checked="true" :disabled="true" />
										</td>
										<td class="td3">
											<radio :checked="false" :disabled="true" />
										</td>
									</tr>
									<tr class="content">
										<td class="td1">
											<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;6）Claspers、chain、cloth mat、rubber mat
												and
												wooden
												place are enough and effective.</p>
											<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;绑扎帯、绑扎链条等绑扎材料、垫衬和垫料是足够且可用</p>
										</td>
										<td class="td2">
											<radio :checked="true" :disabled="true" />
										</td>
										<td class="td3">
											<radio :checked="false" :disabled="true" />
										</td>
									</tr>
									<tr class="content">
										<td class="td1">
											<p>4.Are the safe working load of stern ramp/side ramp safety and effective
												for this
												cargo
												operation.</p>
											<p>尾跳和中跳的安全符合此次的装货的要求</p>
										</td>
										<td class="td2">
											<radio :checked="true" :disabled="true" />
										</td>
										<td class="td3">
											<radio :checked="false" :disabled="true" />
										</td>
									</tr>
									<tr class="content">
										<td class="td1">
											<p>5.Pay attention to stevedores working area.</p>
											<p>船员在工人作业区域要高度注意安全</p>
										</td>
										<td class="td2">
											<radio :checked="true" :disabled="true" />
										</td>
										<td class="td3">
											<radio :checked="false" :disabled="true" />
										</td>
									</tr>
								</tbody>
							</table>
						</view>
					</view>
					<view class="signBox">
						<view class="signContent">
							<view class="signTitle">
								<p>单船指导员签名:</p>
								<p>Signature of Foreman:</p>
							</view>
							<view class="signInfo" v-if="zdySign.url == ''" @click="togoSign('0')">
								去签名
							</view>
							<view class="signImg" v-else @click="togoSign('0')">
								<image :src="zdySign.url"></image>
							</view>
						</view>
						<view class="row"></view>
						<view class="signContent">
							<view class="signTitle">
								<p>大副:</p>
								<p>Captain/Chief officer:</p>
							</view>
							<view class="signInfo" v-if="czSign.url == ''" @click="togoSign('1')">
								去签名
							</view>
							<view class="signImg" v-else @click="togoSign('1')">
								<image :src="czSign.url"></image>
							</view>
						</view>
					</view>
				</custom-tab-pane>
			</custom-tabs>
			<uni-popup ref="delPopup" type="dialog">
				<uni-popup-dialog type="error" confirmText="确定" title="通知" content="是否删除此条数据"
					@confirm="delConfirm"></uni-popup-dialog>
			</uni-popup>
		</view>
	</view>
</template>

<script>
	import sqlite from "../../common/sqlite.js"
	export default {
		data() {
			return {
				title: "装卸货通知单签名",
				// 船舶信息
				shipInfo: {},
				tabsValue: 0,
				tabsList: [],
				// 签名信息
				zdySign: {
					url: "",
					id: ""
				},
				czSign: {
					url: "",
					id: ""
				},
				delId: "",

				vvyId: "",
				vvyName: "",
				date: "",
				vtpId: "",

			}
		},
		onLoad(option) {
			if ('params' in option) {
				this.tabsValue = JSON.parse(decodeURIComponent(option.params)).tabsValue
			}
		},
		mounted() {
			this.vtpId = uni.getStorageSync('vtpId')
			this.executeSql('shipInfoTable')
		},
		methods: {
			// 标签切换
			tabsChange(e) {
				this.tabsValue = e.value
				this.executeSql1('shipmentLoadUnloadNoticeRespList', e.value)
			},
			// 查船舶信息
			executeSql(tableName) {
				let sql = `select * from ${tableName} WHERE vtpId = '${this.vtpId}'`
				sqlite.executeSqlCeshi(sql).then((value) => {
					// 在resolve时执行的回调函数
					this.shipInfo = value[0]
					this.executeSql1('shipmentLoadUnloadNoticeRespList', this.tabsValue)
				}).catch((error) => {
					// 在reject时执行的回调函数
					console.error(error);
				});
			},
			executeSql1(tableName, tabsValue) {
				let sql = `select * from ${tableName} WHERE vtpId='${this.vtpId}'`
				sqlite.executeSqlCeshi(sql).then((value) => {
					// 在resolve时执行的回调函数
					this.tabsList = []
					this.tableInfo = value[tabsValue]
					value.forEach((v, index) => {
						let obj = {
							name: `船舶装卸通知单${index + 1}`,
						}
						this.tabsList.push(obj)
					})
					this.executeSql2()
				}).catch((error) => {
					// 在reject时执行的回调函数
					console.error(error);
				});
			},
			// 查单证签字表
			executeSql2() {
				let that = this
				let sql = `select * from workSignTable WHERE bizId = '${this.tableInfo.sluId}';`
				sqlite.executeSqlCeshi(sql).then((value) => {
					// 在resolve时执行的回调函数
					let zdyList = []
					let czList = []
					if (value.length > 0) {
						value.forEach(v => {
							if (v.sort == '0') {
								this.zdySign = {
									url: v.signFile,
									id: v.webId
								}
								zdyList.push(v)
							} else {
								this.czSign = {
									url: v.signFile,
									id: v.webId
								}
								czList.push(v)
							}
						})
					}
					if (zdyList.length == 0) {
						this.zdySign = {
							url: "",
							id: ""
						}
					}
					if (czList.length == 0) {
						this.czSign = {
							url: "",
							id: ""
						}
					}
				}).catch((error) => {
					// 在reject时执行的回调函数
					console.error(error);
				});
			},
			// 点击签名
			togoSign(signType) {
				let obj = {
					id: this.tableInfo.sluId,
					url: "noticeSign",
					signType: Number(signType), // 0 指导员  1 船长/大副
					signTable: "5",
					tabsValue: this.tabsValue,
					vvyId: this.tableInfo.vvyId,
				}
				const params = encodeURIComponent(JSON.stringify(obj));
				uni.navigateTo({
					url: `/pages/shipWork/sign?params=${params}`
				})
			},
			// 删除当前签名
			delSign(id) {
				this.$refs.delPopup.open()
				this.delId = id
			},
			// 弹框删除
			delConfirm() {
				let sql = `DELETE FROM workSignTable WHERE webId = '${this.delId}';`
				sqlite.executeSqlCeshi(sql).then((value) => {
					// 在resolve时执行的回调函数
					this.executeSql2()
				}).catch((error) => {
					// 在reject时执行的回调函数
					console.error(error);
				});
			},
		}
	}
</script>

<style lang="less" scoped>
	.contentFixed {
		margin-top: 68px !important;

		/deep/.tab .tab-bar {
			height: 66px;
			line-height: 66px;
			position: relative;
		}

		/deep/.tab .tab-bar-item {
			height: 66px;
			line-height: 66px;
			font-size: 18px;
			color: #23262E;
			font-weight: bold;
			font-family: PingFangSC-Semibold;
			padding: 0 24px !important;
		}

		/deep/.tab .tab-bar-item.active {
			color: #0067CF
		}

		/deep/.tab .tab-bar-item .active-line {
			color: #0067CF;
			width: 54px;
			height: 4px;
		}

		/deep/.tab-pane {
			width: 100%;
		}

		/deep/.tab .tab-cont {
			padding-bottom: 0;
		}

		/deep/uni-radio .uni-radio-input.uni-radio-input-disabled {
			background-color: transparent !important;
		}

		/deep/uni-radio .uni-radio-input {
			border: none !important;
		}
	}

	.container {
		padding: 0px 16px;
		background: #FFFFFF;
		border-radius: 8px;

		.head {
			height: 85px;
			padding: 16px 0;
			margin: 0 8px;
			border-bottom: 1px solid #999;
			display: flex;
			justify-content: space-between;

			.rightHead {
				display: flex;
				flex-direction: column;
				justify-content: center;
				text-align: right;

				p {
					font-size: 22px;
					color: #0052A4;
					font-weight: bold;
				}

				text {
					font-size: 14px;
					color: #666666;
				}
			}
		}

		.headTItle {
			display: flex;
			justify-content: space-around;
			padding: 24px 0;
			margin: 0 8px;
			border-bottom: 1px solid #EEEEEE;

			.title {
				flex: 3;
				text-align: center;

				p {
					font-size: 24px;
					color: #23262E;
					font-weight: bold;
				}

				text {
					font-size: 18px;
					color: #23262E;
				}
			}

			.titleLeft {
				flex: 1;
			}

			.titleRight {
				flex: 1;
				display: flex;
				flex-direction: column;
				justify-content: flex-end;

				text:first-child {
					font-size: 14px;
					color: #666666;
				}

				text:last-child {
					font-size: 18px;
					color: #0052A4;
					font-weight: bold;
				}
			}
		}

		.ul {
			display: flex;
			justify-content: space-between;
			flex-wrap: wrap;
			padding: 15px 0;

			.li {
				width: 33%;
				display: flex;
				justify-content: center;

				text {
					color: #23262E;
					font-weight: bold;
					font-size: 14px;
					margin-left: 8px;
					margin-top: 2px;
				}
			}
		}

		.listTitle {
			width: 100%;
			padding: 7px 16px;
			background: #E9E9E9;
			font-size: 18px;
			color: #23262E;
		}

		table {
			margin-bottom: 0 !important;
		}
	}

	/deep/.uni-radio:not {
		color: transparent !important;
	}

	/deep/.uni-radio .uni-radio-input {
		border: none !important;
	}

	/deep/.uni-radio .uni-radio-input.uni-radio-input-checked:before {
		color: #999 !important;
	}

	.text {
		padding: 20px;
	}

	#t-xjl .td1 {
		width: 150px;
		text-align: right;
	}

	#t-xjl .center {
		text-align: center;
	}

	#t-main {
		border-collapse: collapse;
		border-spacing: 0px;

		.trTitle {
			background: #FAFAFA;
		}

		.content:nth-of-type(2n-1) {
			background: #FAFAFA;
		}
	}

	#t-main td {
		padding: 0px 10px;
	}

	#t-main .td1 {
		height: 50px;
	}

	#t-main .td3 {
		width: 200px;
		text-align: center;
	}

	#t-main .bn {
		border-right: none;
	}

	#t-main .td1h {
		width: 1200px;
		height: 50px;
	}

	.signBox {
		width: 100%;
		height: 66px;
		background: #FFFFFF;
		border: 1px solid #E1E5ED;
		box-shadow: 0 -1px 4px 0 rgba(0, 0, 0, 0.05);
		display: flex;
		justify-content: flex-end;
		padding: 0 70px;

		.row {
			width: 1px;
			height: 30px;
			background-color: #ccc;
			margin-top: 18px;
		}

		.signContent {
			display: flex;
			margin: 0 54px;

			.signTitle {
				display: flex;
				flex-direction: column;
				justify-content: center;
				text-align: right;
			}

			.signInfo {
				display: flex;
				flex-direction: column;
				justify-content: center;
				font-size: 18px;
				color: #0052A4;
				margin-left: 16px;
			}

			.signImg {
				width: 100px;
				height: 54px;
				margin-top: 5px;
				margin-left: 10px;
			}
		}

		.signContent:last-child {
			margin-right: 0;
		}
	}
</style>