<template>
	<view class="wrap">
		<page-nav :desc="desc" :title="title"></page-nav>
		<view class="container">
			<uni-list>
				<uni-list-item v-for="(item, index) in list" :key="index">
					<!-- 自定义 body -->
					<template v-slot:body>
						<!-- 		<uni-swipe-action ref="swipeAction">
							<uni-swipe-action-item :right-options="options" 
								@change="swipeChange($event, index)" @click="swipeClick($event, index)">
								<view class="content-box"> -->
						<view style="height: 200px;width: 100%;display: flex;flex-direction: column;">
							<view style="display: flex;flex-direction: row;width: 100%;justify-content: flex-start;">
								<view style="font-size: 18px;font-weight: bold;width: 88%;">问题编号:{{item.failureCheckNo}}
								</view>
								<view style="width: 10%;" @click="delRecord(item.id)">
									<uni-icons type="trash" size="30"></uni-icons>
								</view>
							</view>
							<view>
								<text
									style="margin-right: 10px;font-weight: bolder;">检查点位:</text><text>{{item.failureCheckPointDesc}}</text>
							</view>
							<view>
								<text style="margin-right: 10px;font-weight: bolder;">问题描述:</text>
								<view style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis;">
									{{item.failureHiddenDangerDesc}}
								</view>
							</view>
							<view style="display: flex;flex-direction: row;min-height: 30px;">
								<view style="width: 200px;">{{item.createTime}}</view>
								<view style="color: #18B566;">{{item.checkUserName}}</view>
							</view>
							<view style="margin-top: 5px;padding-left: 0px;padding-right: 0px;">
								<button type="default" @click="openPage(item.id)">编辑</button>
							</view>
						</view>
						<!-- 							</view>
							</uni-swipe-action-item>
						</uni-swipe-action> -->


					</template>
				</uni-list-item>

			</uni-list>
		</view>
		<!-- 		<view class="list-wrap">
			<u-cell-item :titleStyle="{fontWeight: 500}" @click="openPage(item.id)" :title="getTitle(item.failureCheckNo)"
				v-for="(item, index) in list" :key="index" >
				<view>fff</view>
			</u-cell-item>
		</view> -->
		<u-gap height="70"></u-gap>
	</view>
</template>

<script>
	import pageNav from '@/components/page-nav/page-nav.vue';

	import http from '@/http/api.js';
	export default {
		components: {
			pageNav
		},
		onLoad(option) {
			this.loadList();
		},
		data() {
			return {
				list: [],
				title: '问题列表管理',
				desc: '',
				options: [{
						text: '置顶'
					},
					{
						text: '删除',
						style: {
							backgroundColor: 'rgb(255,58,49)'
						}
					}
				],
			}
		},
		computed: {
			getIcon() {
				return path => {
					return 'https://cdn.uviewui.com/uview/example/' + path + '.png';
				}
			},
		},
		onShow() {
			uni.setNavigationBarTitle({
				title: ""
			});
		},
		created() {

		},
		methods: {
			loadList() {
				const current = 1;
				const size = 1000;
				const isSubmit = '0';

				var reportList = [];
				http.request({
					url: '/blade-business/report/failure/queryPage',
					method: 'GET',
					params: {
						current,
						size,
						isSubmit
					}
				}).then(res => {
					if (res.data.records != null) {
						const listSize = res.data.records['length'];
						for (var i = 0; i < listSize; i++) {
							let report = res.data.records['' + i];
							reportList.push(report);
						}
					}

				}).catch(err => {
					console.log(err)
				})

				this.list = reportList;
			},
			openPage(id) {
				this.$u.route({
					url: '/pages/checkReport/editCheckReport?id=' + id
				})
			},
			getTitle(checkNo) {
				return "问题编号：" + checkNo;
			},
			swipeChange(e, index) {
				console.log('返回：', e);
				console.log('当前索引：', index);
			},
			swipeClick(e, index) {

			},
			delRecord(id) {
				const that = this;
				uni.showModal({
					content: '确定删除记录？',
					showCancel: true,
					success(res) {
						if (res.confirm) {
							var ids = id;

							http.request({
								url: '/blade-business/report/failure/remove',
								method: 'POST',
								params: {
									ids
								}
							}).then(res => {
								console.log(JSON.stringify(res.data))
								if (res.success) {
									uni.showModal({
										content: '删除已成功',
										showCancel: false,
										success(res) {
											if (res.confirm) {
												that.loadList();
											}
										}
									});
								}
							}).catch(err => {
								console.log(err)
							})
						}
					}
				});
			}
		}
	}
</script>

<style>
	/* page {
		background-color: rgb(240, 242, 244);
	} */
</style>

<style lang="scss" scoped>
	.u-cell-icon {
		width: 36rpx;
		height: 36rpx;
		margin-right: 8rpx;
	}

	.slot-box {
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		flex-direction: row;
		align-items: center;
	}

	.slot-image {
		/* #ifndef APP-NVUE */
		display: block;
		/* #endif */
		margin-right: 10px;
		width: 30px;
		height: 30px;
	}

	.slot-text {
		flex: 1;
		font-size: 14px;
		color: #4cd964;
		margin-right: 10px;
	}

	.content-box {
		flex: 1;
		/* #ifdef APP-NVUE */
		justify-content: center;
		/* #endif */
		height: 100%;
		line-height: 44px;
		padding: 0 15px;
		position: relative;
		background-color: #fff;
		border-bottom-color: #f5f5f5;
		border-bottom-width: 1px;
		border-bottom-style: solid;
	}

	.content-text {
		font-size: 15px;
	}

	.example-body {
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		flex-direction: row;
		justify-content: center;
		padding: 10px 0;
		background-color: #fff;
	}

	.button {
		border-color: #e5e5e5;
		border-style: solid;
		border-width: 1px;
		padding: 4px 8px;
		border-radius: 4px;
	}

	.button-text {
		font-size: 15px;
	}

	.slot-button {
		/* #ifndef APP-NVUE */
		display: flex;
		height: 100%;
		/* #endif */
		flex: 1;
		flex-direction: row;
		justify-content: center;
		align-items: center;
		padding: 0 20px;
		background-color: #ff5a5f;
	}

	.slot-button-text {
		color: #ffffff;
		font-size: 14px;
	}
</style>
