<template>
	<view>
		
		<form action=""  >
			
			<view class="form-item margin-top">
				<view class="title">
					<text class="necessary">*</text>
					上报名称：
				</view>
				<input type="text">
			</view>
			
			<view class="form-item margin-top">
				<view class="title">
					<text class="necessary">*</text>
					巡检状态：
				</view>
				<radio-group name="gender" @change="radioChange">
					<label class="margin-right-xs">
						<radio value="2" checked /><text>正常</text>
					</label>
					<label class="margin-right-xs">
						<radio value="3" /><text>异常</text>
					</label>
					<label class="margin-right-xs">
						<radio value="2" /><text>供电</text>
					</label>
					<label>
						<radio value="3" /><text>其他</text>
					</label>
				</radio-group>
				
			</view>
			
			<view class="form-item margin-top">
				<view class="title">
					<text class="necessary">*</text>
					上传图片：
				</view>
				
				<view style="width:500rpx">
					<view class="cu-form-group">
						<view class="grid col-4 grid-square flex-sub">
							<view class="bg-img" v-for="(item,index) in imgList" :key="index" @tap="ViewImage" :data-url="imgList[index]">
							 <image :src="imgList[index]" mode="aspectFill"></image>
								<view class="cu-tag bg-red" @tap.stop="DelImg" :data-index="index">
									<text class='cuIcon-close'></text>
								</view>
							</view>
							<view class="solids" @tap="ChooseImage" v-if="imgList.length<4">
								<text class='cuIcon-cameraadd'></text>
							</view>
						</view>
					</view>
				</view>
			</view>
			
			<view class="form-item margin-top">
				<view class="title">
					<text class="necessary">*</text>
					巡检描述：
				</view>
				<textarea maxlength="-1"  @input="textareaAInput" placeholder="" width="250"></textarea>
			</view>
		
			<view class="btn-area submitBottomBtn padding-lr-sm">
				<button class="bg-blue round  margin-top" @click="addSubmit">提 交 </button>
			</view>
			
		</form>

		
	</view>
</template>

<script>
	export default {
		data() {
			return {
				
				imgList: [],

			}
		},
		methods: {
			radioChange(e) {
				console.log('type:' + e.detail.value);
				this.radioOne = e.detail.value;
			},
			
			ChooseImage() {
				uni.chooseImage({
					count: 4, //默认9
					sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图，默认二者都有
					sourceType: ['album'], //从相册选择
					success: (res) => {
						if (this.imgList.length != 0) {
							this.imgList = this.imgList.concat(res.tempFilePaths)
						} else {
							this.imgList = res.tempFilePaths
						}
					}
				});
			},
			
			ViewImage(e) {
				uni.previewImage({
					urls: this.imgList,
					current: e.currentTarget.dataset.url
				});
			},
			DelImg(e) {
				uni.showModal({
					title: '删除',
					content: '确定要删除此图片吗？',
					cancelText: '取消',
					confirmText: '确定',
					success: res => {
						if (res.confirm) {
							this.imgList.splice(e.currentTarget.dataset.index, 1)
						}
					}
				})
			},
			
		}
	}
</script>

<style lang="scss">
	

	
</style>

