<template>
	<view class="workAssignSign">
		<head-view :title="title"></head-view>
		<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 class="container">
					<table>
						<tbody>
							<tr>
								<td class="h-l1r1">
									<image id="HT-logo" src="../../static/images/theme/logo.png" mode="widthFix">
									</image>
								</td>
								<td class="h-l1r2">&nbsp;</td>
								<td class="h-l1r3">
									<p>上海海通国际汽车码头有限公司</p>
									<p>Shanghai HaiTong International Automotive Terminal Co.,Ltd.</p>
								</td>
							</tr>
							<tr>
								<td colspan="3">
									<p class="bh-dz">QR-7.5.1-01-11-M</p>
								</td>
							</tr>
							<tr>
								<td colspan="3" class="h-l2r1">
									<p class="name-dz">海通码头单船指导员作业布置表</p>
									<p class="ename-dz"></p>
								</td>
							</tr>
						</tbody>
					</table>
					<table id="t-xjl">
						<tbody>
							<tr>
								<td class="td1">船名:</td>
								<td class="td2">{{shipInfo.vslCnname}}</td>
								<td class="td1">航次:</td>
								<td class="td2">{{shipInfo.vvyName}}</td>
								<td class="td1">泊位:</td>
								<td class="td2">{{tableInfo.bthIdName}}</td>
							</tr>
						</tbody>
					</table>
					<table id="t-xjl">
						<tbody>
							<tr>
								<td class="td1">人数:</td>
								<td class="td2">{{tableInfo.personNumber}}</td>
								<td class="td1">装/卸货辆/件:</td>
								<td class="td2">{{tableInfo.vehicleSize}}/{{tableInfo.sparePart}}</td>
								<td class="td1">工班:</td>
								<td class="td2">{{tableInfo.pwcType}}</td>

							</tr>
						</tbody>
					</table>
					<table id="t-xjl">
						<tbody>
							<tr>
								<td class="td1">作业日期:</td>
								<td class="td2">{{tableInfo.startTime}} - {{tableInfo.endTime}}</td>
								<td class="td1">作业开始时间:</td>
								<td class="td2">{{tableInfo.startTime}}</td>
								<td class="td1">作业结束时间:</td>
								<td class="td2">{{tableInfo.endTime}}</td>
							</tr>
						</tbody>
					</table>

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

	.container {
		padding: 10px 20px;
	}


	.text {
		padding: 20px;
	}

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

	#t-xjl .td2 {
		text-align: center;
		border-bottom: #000000 solid 1px;
	}

	.title {
		width: 100%;
		height: 50px;
		line-height: 50px;
		text-align: center;
		border: 1px solid #000000;
		border-bottom: none;

	}

	#t-main {
		border-collapse: collapse;
		border: #000000 solid 1px;
		border-spacing: 0px;
	}

	#t-main td {
		border: #000000 solid 1px;
		padding: 0px 10px;
	}

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

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

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

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

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

	.sginBox {
		width: 100%;
		display: flex;
		justify-content: flex-end;

		.box {
			display: flex;
			margin-right: 80px;

			image {
				width: 200px;
				height: 50px;
			}

			.del {
				color: red;
			}
		}

		.sign {
			color: #2979ff;
			margin-left: 10px;
		}
	}
</style>