<template>
	<view class="workAssignSign">
		<head-view :title="title" url="/pages/shipWork/workAssign"></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>
								</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>船名:</p><text>{{shipInfo.vslEnname}}</text>
								</view>
								<view class="li">
									<p>航次:</p><text>{{tableInfo.vvyName}}</text>
								</view>
								<view class="li">
									<p>泊位:</p><text>{{tableInfo.bthIdName}}</text>
								</view>
								<view class="li">
									<p>人数:</p><text>{{tableInfo.personNumber}}</text>
								</view>
								<view class="li">
									<p>装/卸货辆/件:</p>
									<text v-if="tableInfo.loaderTypeName == '卸货'">discharge{{tableInfo.vehicleSize}}+{{tableInfo.sparePart}}</text>
									<text v-else>load{{tableInfo.vehicleSize}}+{{tableInfo.sparePart}}</text>
								</view>
								<view class="li">
									<p>工班:</p><text>{{tableInfo.pwcTypeName}}</text>
								</view>
								<view class="li">
									<p>作业日期:</p><text>{{tableInfo.startTime}} - {{tableInfo.endTime}}</text>
								</view>
								<view class="li">
									<p>作业开始时间:</p><text>{{tableInfo.startTime}}</text>
								</view>
								<view class="li">
									<p>作业结束时间:</p><text>{{tableInfo.endTime}}</text>
								</view>
							</view>
							<view class="listTitle">
								<p>确认项目</p>
							</view>
							<table id="t-main">
								<tbody v-for="(item,index) in items" :key="index">
									<tr class="trTitle">
										<td class="td1h">{{item.itemTitle}}</td>
										<td class="center" v-show="index == 0">YES</td>
										<td class="td3" v-show="index == 0">NO</td>
									</tr>
									<tr class="content" v-for="(item2,index2) in item.list" :key="index2">
										<td class="td1">
											<p>{{item2.listTitle}}</p>
										</td>
										<td class="center">
											<radio :value="item2.yesValue" :checked="item2.yesRadio" :disabled="true" />
										</td>
										<td class="center">
											<radio :value="item2.noValue" :checked="item2.noRadio" :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.signFile == ''" @click="togoSign('0')">
								去签名
							</view>
							<view class="signImg" v-else @click="togoSign('0')">
								<image :src="zdySign.signFile"></image>
							</view>
						</view>
					</view>
				</custom-tab-pane>
			</custom-tabs>
		</view>
		<uni-popup ref="delPopup" type="dialog">
			<uni-popup-dialog type="error" confirmText="确定" title="通知" content="是否删除此条数据"
				@confirm="delConfirm"></uni-popup-dialog>
		</uni-popup>
	</view>
</template>

<script>
	import sqlite from "../../common/sqlite.js"
	export default {
		data() {
			return {
				title: "指导员作业布置表签名",
				items: [{
						itemTitle: "1.靠泊前/后准备及安全措施的落实。",
						list: [{
								listTitle: "（1）码头前沿泊位清爽，无影响靠泊船舶/障碍物，靠泊旗/灯位置摆放准确。",
								yesValue: "yes",
								yesRadio: true,
								noValye: "no",
								noRadio: false,
							},
							{
								listTitle: "（2）检查手提式对讲机和靠泊对讲机有效使用并保持和船舶引水联系畅通。",
								yesValue: "yes",
								yesRadio: true,
								noValye: "no",
								noRadio: false,
							}, {
								listTitle: "（3）船舶带缆缆桩大概位置清楚，缆桩上无障碍物。",
								yesValue: "yes",
								yesRadio: true,
								noValye: "no",
								noRadio: false,
							}, {
								listTitle: "（4）带缆工人提前到码头，并检查劳保用品和救生衣穿戴整齐、规范、有效。",
								yesValue: "yes",
								yesRadio: true,
								noValye: "no",
								noRadio: false,
							}, {
								listTitle: "（5）带缆工人根据公司规定配员合理。",
								yesValue: "yes",
								yesRadio: true,
								noValye: "no",
								noRadio: false,
							}, {
								listTitle: "（6）靠泊期间潮汐情况已经了解并做好相应的记录。",
								yesValue: "yes",
								yesRadio: true,
								noValye: "no",
								noRadio: false,
							}, {
								listTitle: "（7）带缆期间集中注意力，面向船舶，严肃、认真，与相关协助靠泊人员保持有效沟通。",
								yesValue: "yes",
								yesRadio: true,
								noValye: "no",
								noRadio: false,
							}, {
								listTitle: "（8）带缆期间提醒带缆工人注意站位并在缆绳绞紧期间站在安全距离外。",
								yesValue: "yes",
								yesRadio: true,
								noValye: "no",
								noRadio: false,
							}, {
								listTitle: "（9）靠泊期间码头前沿无关人员远离。",
								yesValue: "yes",
								yesRadio: true,
								noValye: "no",
								noRadio: false,
							}, {
								listTitle: "（10）缆绳全部上桩并绞紧后单船指导员才能离开现场。",
								yesValue: "yes",
								yesRadio: true,
								noValye: "no",
								noRadio: false,
							}, {
								listTitle: "（11）靠泊后如有人员从舷梯上下，督促船方放妥安全网。",
								yesValue: "yes",
								yesRadio: true,
								noValye: "no",
								noRadio: false,
							}
						]
					},
					{
						itemTitle: "2.装/卸货物前的准备。",
						list: [{
								listTitle: "（1）装/卸船货物已经实地查看并对装船高度差较小的车辆进行核实高度。",
								yesValue: "yes",
								yesRadio: true,
								noValye: "no",
								noRadio: false,
							},
							{
								listTitle: "（2）核对装/卸船货物的唛头，确认装/卸船货物的准确性。",
								yesValue: "yes",
								yesRadio: true,
								noValye: "no",
								noRadio: false,
							}, {
								listTitle: "（3）大型工程车辆装/卸船前已经根据船方要求舱内做好相应的铺垫工作。",
								yesValue: "yes",
								yesRadio: true,
								noValye: "no",
								noRadio: false,
							}, {
								listTitle: "（4）船舱内、码头、引桥、场地等限速场所按照规定速度行驶。",
								yesValue: "yes",
								yesRadio: true,
								noValye: "no",
								noRadio: false,
							}, {
								listTitle: "（5）装/卸船时对有高低舱的甲板已经做好明显的标识，并告知作业相关人员。",
								yesValue: "yes",
								yesRadio: true,
								noValye: "no",
								noRadio: false,
							}, {
								listTitle: "（6）船上实际查看作业层面并对作业路线做了必要的安全标识和有效的路线安排。",
								yesValue: "yes",
								yesRadio: true,
								noValye: "no",
								noRadio: false,
							}, {
								listTitle: "（7）作业前与船舶大副签署《通知书》并告知实际的作业路线安排和相关注意事项。",
								yesValue: "yes",
								yesRadio: true,
								noValye: "no",
								noRadio: false,
							}, {
								listTitle: "（8）重点舱、重点货物装船已经安排好专人操作/指挥。",
								yesValue: "yes",
								yesRadio: true,
								noValye: "no",
								noRadio: false,
							}, {
								listTitle: "（9）根据跳板的实际情况对超长货物/重点货物提前预判装船顺序。",
								yesValue: "yes",
								yesRadio: true,
								noValye: "no",
								noRadio: false,
							}
						]
					}, {
						itemTitle: "3.装/卸作业安全措施的布置和落实。",
						list: [{
								listTitle: "（1）船图、东雷作业计划书、场位图、堆场计划、堆场装/卸作业计划书等相关资料齐全。",
								yesValue: "yes",
								yesRadio: true,
								noValye: "no",
								noRadio: false,
							},
							{
								listTitle: "（2）与堆场相关负责人核对装/卸货物的场地。",
								yesValue: "yes",
								yesRadio: true,
								noValye: "no",
								noRadio: false,
							}, {
								listTitle: "（3）根据实际情况会同相关人员制定作业路线图，并在交叉路口安排信号员。",
								yesValue: "yes",
								yesRadio: true,
								noValye: "no",
								noRadio: false,
							}, {
								listTitle: "（4）已经实地查看将要装/卸船的货物并对重点货物采取了必要的安全措施。",
								yesValue: "yes",
								yesRadio: true,
								noValye: "no",
								noRadio: false,
							}, {
								listTitle: "（5）装/卸大型机械做好相关的铺垫工作并在作业过程中根据实际情况及时调整。",
								yesValue: "yes",
								yesRadio: true,
								noValye: "no",
								noRadio: false,
							}, {
								listTitle: "（6）通知船舶大副装/卸作业期间船员禁止进入作业区域。",
								yesValue: "yes",
								yesRadio: true,
								noValye: "no",
								noRadio: false,
							}, {
								listTitle: "（7）作业过程中发现违章、违规现象及时制止并纠正必要时予以现场整改。",
								yesValue: "yes",
								yesRadio: true,
								noValye: "no",
								noRadio: false,
							}, {
								listTitle: "（8）装/卸重点舱、重点货物时候单船指导员在现场指挥。",
								yesValue: "yes",
								yesRadio: true,
								noValye: "no",
								noRadio: false,
							}, {
								listTitle: "（9）货物的绑扎按照操作规范执行并的到船方确认。",
								yesValue: "yes",
								yesRadio: true,
								noValye: "no",
								noRadio: false,
							}, {
								listTitle: "（10）重大件货物的绑扎安全、有效并得到船方确认。",
								yesValue: "yes",
								yesRadio: true,
								noValye: "no",
								noRadio: false,
							}
						]
					}
				],
				tabsValue: 0,
				tabsList: [],
				// 船舶信息
				shipInfo: {},
				// 表内数据
				tableInfo: {},
				// 签名信息
				zdySign: {},
				delId: "",
				vtpId: "",
				bthList:[]
			}
		},
		onLoad(option) {
			if ('params' in option) {
				this.tabsValue = JSON.parse(decodeURIComponent(option.params)).tabsValue
			}
		},
		mounted() {
			this.vtpId = uni.getStorageSync('vtpId')
			this.executeSql('shipInfoTable')
			this.executeSql('shipOption')
		},
		methods: {
			// 查船舶信息
			executeSql(tableName) {
				let sql = `select * from ${tableName} WHERE vtpId='${this.vtpId}'`
				sqlite.executeSqlCeshi(sql).then((value) => {
					if(tableName == 'shipInfoTable') {
					// 在resolve时执行的回调函数
					this.shipInfo = value[0]
					this.executeSql1('shipmentAdviserLayoutRespList', this.tabsValue)
					}else if(tableName == 'shipOption'){
						value.forEach(item => {
						if(item.dictionariesName == 'bthList') {
							this.bthList.push(item)
						}
					   })
					}
				}).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.bthList.forEach(item => {
			        	if(item.ptrDesc == this.tableInfo.bthIdName) {
			        		this.tableInfo.bthIdName = item.ptrEnDesc
			        	}
			        })
					this.executeSql2()
				}).catch((error) => {
					// 在reject时执行的回调函数
					console.error(error);
				});
			},
			// 查单证签字表
			executeSql2() {
				let sql = `select * from workSignTable WHERE bizId = '${this.tableInfo.altId}';`
				sqlite.executeSqlCeshi(sql).then((value) => {
					// 在resolve时执行的回调函数
					if (value.length > 0) {
						this.zdySign = value[0]
					} else {
						this.zdySign = {
							signFile: ""
						}
					}
				}).catch((error) => {
					// 在reject时执行的回调函数
					console.error(error);
				});
			},
			// 标签切换
			tabsChange(e) {
				this.tabsValue = e.value
				this.executeSql1('shipmentAdviserLayoutRespList', e.value)
			},
			// 点击签名
			togoSign(signType) {
				let obj = {
					id: this.tableInfo.altId,
					url: "workAssignSign",
					signType: Number(signType), // 0 指导员  1 船长/大副
					signTable: "6",
					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>
	@import "../../style/css/main-dz.css";

	.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 {
		font-size: 16px;
		border-collapse: collapse;
		border-spacing: 0px;

		.trTitle {
			background: #FAFAFA;
		}

		.content {
			font-size: 16px;
		}

		.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>