<template>
	<view class="kd-check-card">
		<view class="title">
			<text class="label">{{ index + 1 }}</text>
			<text>{{ item.name }}</text>
		</view>
		<view class="card-cell">
			<text class="label">内容</text>
			<text class="cell-content">{{ item.content }}</text>
		</view>
		<view class="card-cell">
			<text class="label">标准</text>
			<text class="cell-content">{{ item.norm }}</text>
		</view>
		<view class="card-cell">
			<text class="label">工具</text>
			<view class="cell-content" v-if="item.operationGuide && item.operationGuide.toolList.length > 0">
				<view v-for="(item, index) in item.operationGuide.toolList">{{ index + 1 }}、{{ item.categoryLevelName }}</view>
			</view>
			<view class="cell-content" v-else>无</view>
		</view>
		<view class="card-cell">
			<text class="label">指导</text>
			<view class="cell-content" v-if="item.operationGuide && item.operationGuide.procedureList.length > 0">
				<view v-for="(item, index) in item.operationGuide.procedureList">{{ index + 1 }}、{{ item.content }}</view>
			</view>
			<view class="cell-content" v-else>无</view>
		</view>
		<view class="card-cell">
			<text class="label">结果</text>
			<view class="cell-content">
				<view class="content-status" v-if="type == 'view'">
					<!-- {{ item.isNormal?'正常':'缺陷' }} -->
					<div v-if="item.status === 0" style="color: green">正常</div>
					<div v-else-if="item.status === -1" style="color: red">缺陷</div>
				</view>
				<textarea v-if="type !== 'view'" placeholder="请输入" v-model="item.result" />
				<view class="result-text" v-else>{{ item.result }}</view>
				<view class="radio-wrapper" v-if="type !== 'view'">
					<div
						v-for="(it, ind) in statusList"
						:key="ind"
						class="wrapper-box"
						@click="changeStatus(item, it)"
						:style="item.status == it.status && item.status == -1 ? 'color:red;border: 1rpx solid red' : item.status == it.status && item.status == 0 ? 'color:green;border: 1rpx solid green' : ''">
						{{ it.label }}
					</div>
					<!-- <u-radio-group
            v-model="item.isNormal"
            placement="row"
            v-if="type !== 'view'"
            :size="28"
          >
            <u-radio
              :customStyle="{ marginRight: '20px' }"
              :labelSize="30"
              label="正常"
              :name="1"
            >
            </u-radio>
            <u-radio :customStyle="{}" :labelSize="30" label="缺陷" :name="0">
            </u-radio>
          </u-radio-group>
          <view
            :class="item.isNormal === 0 ? 'text-danger' : ''"
            v-else
            style="min-height: 1em"
          >
            {{ ['缺陷', '正常'][item.isNormal] }}
          </view> -->
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		props: {
			item: {
				type: Object,
				default: () => ({})
			},
			index: Number,
			type: {
				type: String,
				default: 'edit'
			}
		},
		data() {
			return {
				statusList: [
					{ label: '正常', status: 0 },
					{ label: '缺陷', status: -1 }
				]
			}
		},
		methods: {
			changeStatus(item, it) {
				item.status = it.status
			}
		}
	}
</script>

<style lang="scss" scoped>
	$border-color: #f2f2f2;
	.kd-check-card {
		font-size: 28rpx;
		border: 1rpx solid $border-color;
		.label {
			display: inline-block;
			width: 80rpx;
			text-align: center;
			border-right: 1px solid $border-color;
			justify-content: center;
		}
		.title {
			line-height: 72rpx;
			font-weight: bold;
			background-color: #f2f2f2;
		}
		.card-cell {
			min-height: 72rpx;
			display: flex;
			align-items: stretch;
			border: 1px solid $border-color;
			text {
				display: flex;
				align-items: center;
			}
		}
		.cell-content {
			flex: 1;
			.content-status {
				width: 100%;
				height: 50rpx;
				line-height: 50rpx;
				text-indent: 10rpx;
				border-bottom: 1rpx solid #f2f2f2;
			}
		}
		.radio-wrapper {
			padding: 10rpx 20rpx;
			border-bottom: 1px solid $border-color;
			margin-left: -8rpx;
		}
		/deep/uni-textarea {
			width: 100%;
			box-sizing: border-box;
		}
		.result-text {
			min-height: 100rpx;
			padding: 10rpx;
		}
		.cell-content {
			padding-left: 8rpx;
		}
		.radio-wrapper {
			display: flex;
			align-items: center;
			justify-content: space-around;
		}
		.wrapper-box {
			width: 45%;
			height: 80rpx;
			line-height: 80rpx;
			text-align: center;
			border: 1rpx solid #000;
			color: #000;
			border-radius: 15rpx;
		}
	}
</style>
