<template>
	<view class="list-body">
		<uni-nav-bar @clickLeft="goBack()" class="nav-bar" height="110rpx" leftWidth="400rpx" leftText="添加作业许可证"
			leftIcon="left" border backgroundColor="#2cade8" color="#fff" fixed statusBar shadow></uni-nav-bar>
		<view class="oplCate-info">
			<view class="oplCate-info-title">已添加许可证：</view>
			<view class="uni-list-cell uni-list-cell-pd" v-for="item in oplList" :key="item.id"  @click="addCate(item,'edit')">
				<view>
					<view class="name">{{item.name}}</view>
					<view class="name">{{item.cate_name}}</view>
					<view class="name">{{item.level}}</view>
				</view>
				<view>
					<view class="oplEditImg"></view>
					<!-- <image class="oplEditImg" :src="require('@/static/workSpace/new_apply/update.png')" mode="widthFix"></image> -->
				</view>
			</view>
		</view>
		<view class="oplCate-info">
			<view class="oplCate-info-title">添加新许可证：</view>
			<view class="uni-list-cell uni-list-cell-pd" v-for="row in oplCateList" :key="row.id" @click="addCate(row,'add')">
				<view>
					<view class="name">{{row.name}}</view>
				</view>
				<image class="oplAddImg" :src="require('@/static/common/addIcon.png')" mode="widthFix">
				</image>
			</view>
			<!-- <checkbox-group @change="checkboxChange">
				<label class="uni-list-cell uni-list-cell-pd" v-for="row in oplCateList" :key="row.id">
					<view>
						<checkbox :value="row.value" :checked="row.checked" />
					</view>
					<view>
						<view class="name">{{row.name}}</view>
					</view>
				</label>
			</checkbox-group> -->
		</view>
		<!-- <view class="add">
			<view class="btn">
				<button type="primary" class="save-btn" @click="add">添加许可证</button>
			</view>
		</view> -->
	</view>
</template>

<script>
	export default {
		name: "oplCate",
		data() {
			return {
				formData: {
					name: '',
				},
				oplCateList: [],
				oplList: [],
			}
		},
		onLoad(params) {
			debugger;
			console.log(params)
			this.operationId = params.operationId;
		},
		onShow() {
			this.getOplCate();
			this.getOplLists();
		},
		methods: {
			//获取许可证类型
			getOplCate() {
				this.$u.api.oplCate({
					page: 0
				}).then(res => {
					debugger;
					console.log(res)
					this.oplCateList = res;
				})
			},
			//获取已添加许可证
			getOplLists() {
				this.$u.api.oplLists({
					operation: this.operationId
				}).then(res => {
					debugger;
					console.log(res)
					this.oplList = res.results;
				})
			},
			addCate(row,type) {
				let params=null,oplCate = '';
				if(type==='edit'){
					oplCate = row.cate_name;
					params = `?oplId=${row.id}&oplcateId=${row.cate_.id}&operationId=${this.operationId}&type=${type}`;
				}else{
					oplCate = row.name;
					params = `?oplcateId=${row.id}&operationId=${this.operationId}&type=${type}`;
				}
				 if(oplCate==='动火'){
					uni.navigateTo({
						url: '../opls/fire' + params
					})
				 }
				
			},
			select(row) {},
			goBack() {
				uni.navigateBack({
					delta: 1
				})
			},

			add() {
				uni.navigateTo({
					url: '../opls/fire'
				})
			},
			edit(row) {},
		}
	}
</script>

<style>
	>>>.uni-navbar__header,
	>>>.uni-status-bar {
		background-image: linear-gradient(90deg, #164cc3 0%, #2c6fd9 100%), linear-gradient(#e60012, #e60012) !important;
	}

	.list-body {
		background-color: #f3fbff;
		padding-bottom: 113px;
	}

	.oplCate-info {
		width: 360px;
		margin: 0 auto;
		background-color: #FFFFFF;
		border-radius: 5px;
		padding: 12px 16px;
		box-sizing: border-box;
		margin-top: 12px;
	}

	.oplCate-info-title {
		font-size: 32upx;
		color: #333333;
		font-weight: bold;
		border-bottom: 1upx solid #eeeeee;
		height: 70upx;
	}

	.row {
		padding: 10upx;
		margin-bottom: 20upx;
		border-bottom: 1upx solid #eeeeee;
	}

	.uni-list-cell {
		display: flex;
		padding: 10upx;
		padding: 30upx 0;
		justify-content: space-between;
		border-bottom: 1upx solid #eeeeee;
	}

	.uni-list-cell:last-child {
		border-bottom: 0;
	}

	.oplEditImg {
		width: 40rpx;
		height: 40upx;
		background-size: cover;
		background-image: url('@/static/workSpace/new_apply/update.png');
	}
	.oplAddImg {
		width: 40rpx;
		height: 40upx;
	}

	.add {
		position: fixed;
		bottom: 0;
		width: 100%;
		height: 120upx;
		justify-content: center;
		align-items: center;
	}

	.btn {
		margin: auto;
		box-shadow: 0upx 5upx 10upx rgba(0, 0, 0, 0.4);
		width: 70%;
	}

	.save-btn {
		height: 80rpx;
		color: #fff;
		font-size: 30upx;
		justify-content: center;
		align-items: center;
	}
</style>
