<template>
	<view class="content">
		<view class="param">
			<view class="proMiao">任务名称</view>
			<input class="proINname" placeholder="请输入任务名称"/>
			<view class="proMiao">任务描述</view>
			<textarea class="proINname proIMi" placeholder="请输入评分标准"/>
			<view class="proMiao">附件</view>
			<view class="upload-img">
				<uni-file-picker limit="3" 
					@select='selectUpload' 
					:auto-upload='false' 
					file-extname='pdf,docx,xlsx,' 
					file-mediatype="all" 
					@success='uploadSuccess'	
					@fail='uploadFail' 
					:list-styles='listStyles' 
					v-model='fileList'
				></uni-file-picker>
			</view>
			<span style="margin: 20rpx 0 0 20rpx;">支持pdf/word/xlsx格式，单个文件大小不超过5MB</span>
			<view class="proMiao">评分上限</view>
			<input class="proINname" placeholder="请输入评分上限"/>
			<view class="proMiao">权重</view>
			<input class="proINname" placeholder="请输入权重"/>
			<view class="proMiao">任务负责人</view>
			<view @click="toggle()">
				<uni-data-select class="proINname" :disabled="true"
					placeholder="请选择任务负责人"
				></uni-data-select>
			</view>
			
			<view class="proMiao">提醒时间</view>
			<uni-datetime-picker class="proINname" type="datetime" v-model="datetimesingle" @change="changeLog" />
			<view class="proMiao">预警时间</view>
			<uni-datetime-picker class="proINname" type="datetime" v-model="datetimesingle" @change="changeLog" />
			<view class="proMiao">任务周期</view>
			<uni-datetime-picker class="proINname" v-model="datetimerange" type="datetimerange" rangeSeparator="至" />
			<!-- 操作键 -->
			<view class="project">
				<view class="butt quxiao">取消</view>
				<view class="butt queren">确认创建</view>
			</view>
			<view style="width: 100%;height: 60rpx;"></view>
			
			<!-- 任务负责人弹出框-->
			<uni-popup ref="popup" background-color="#fff">
				<view class="popup-content">
					<view class="popup-title">
						<view @click="quPopup">取消</view>
						<view>选择任务负责人</view>
						<view style="color: rgba(0, 97, 255, 1);">确定</view>
					</view>
					<view class="popup-list" v-for="(item,index) in people" :key="index">
						<view class="l-line"></view>
						<view class="l-kuang">
							<view class="l-circle"></view>
							<view style="margin-left: 20rpx;">
								<view style="font-size: 28rpx;">{{item.name}}</view>
								<view style="font-size: 24rpx;">{{item.danwei}}</view>
							</view>
							<label class="l-label">
								<view>
									<radio :id="item.name" :value="item.name" :checked="item.checked"></radio>
								</view>
							</label>
						</view>
					</view>
				</view>
			</uni-popup>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				datetimesingle: '',
				datetimerange: [],
				people:[
					{name:'张三',danwei:'校办'},
					{name:'张三',danwei:'校办'},
					{name:'张三',danwei:'校办',checked:'true'},
				],
				// 附件
				fileList: [],
				listStyles: {
					"borderStyle": {
						"width": "0", // 边框宽度
					},
					"border": false, // 是否显示边框
					"dividline": false
				},
			}
		},
		onLoad() {
	
		},
		methods: {
			// 任务负责人弹框
			toggle() {
				console.log('dd')
				// open 方法传入参数 等同在 uni-popup 组件上绑定 type属性
				this.$refs.popup.open('bottom')
			},
			//取消弹框
			quPopup(){
				this.$refs.popup.close()
			},
			// 选择负责人
			checkboxChange: function(e) {
				console.log(e)
				var checked = e.target.value
				var changed = {}
				for (var i = 0; i < this.people.length; i++) {
					if (checked.indexOf(this.people[i].name) !== -1) {
						changed['people[' + i + '].checked'] = true
					} else {
						changed['people[' + i + '].checked'] = false
					}
				}
			},
			// 上传附件
			uploadSuccess(e) {
			console.log('上传成功', e)
			},
			uploadFail(e) {
				console.log('上传失败：', e)
			},
			selectUpload(e) {
				console.log('上传：', e)
			
				uni.uploadFile({
					url: 'url', //仅为示例，非真实的接口地址
					filePath: e.tempFilePaths[0],
					name: 'file',
					// formData: {
					// 	'file': ''
					// },
					success: (uploadFileRes) => {
						console.log(uploadFileRes.data);
					},
					fail: (err) => {
						console.log(err);
					}
				})
			},
		}
	}
</script>

<style>
	.content {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
	}
	.param{
		margin: 20rpx 0 0 0;
		width: 100%;
		background-color: rgba(255, 255, 255, 1);
		font-size: 28rpx;
		font-weight: 400;
		line-height: 41rpx;
		color: rgba(0, 0, 0, 1);
	}
	.proMiao{
		margin: 31rpx 0 0 20rpx;
	}
	/* 上传附件 */
	.upload-img{
		margin: 25rpx 0 0 21rpx;
		width: 200rpx;
		height: 80rpx;
		opacity: 1;
		border-radius: 13rpx;
		background: rgba(0, 97, 255, 0.1);
		
		border: 1rpx solid rgba(0, 97, 255, 1);
	}
	.proINname{
		margin: 25rpx 0 0 21rpx;
		width: 709rpx;
		height: 90rpx;
		border-radius: 13rpx;
		background: rgba(245, 248, 252, 1);
		border: 1rpx solid rgba(229, 229, 229, 1);
		font-size: 28rpx;
		line-height: 90rpx;
		color: rgba(179, 179, 179, 1);
	}
	.proIMi{
		height: 315rpx;
	}
	/* 操作键 */
	.project{
		display: flex;
		margin: 61rpx 0 0 0;
		justify-content: space-evenly;
	}
	.butt{
		width: 330rpx;
		height: 90rpx;
		border-radius: 117rpx;
		font-size: 32rpx;
		line-height: 90rpx;
		text-align: center;
	}
	.quxiao{
		border: 1rpx solid rgba(0, 97, 255, 1);
		color: rgba(0, 97, 255, 1);
	}
	.queren{
		background: rgba(0, 97, 255, 1);
		color: rgba(255, 255, 255, 1);
	}
	/* 任务负责人弹出框 */
	.popup-title{
		display: flex;
		width: 100%;
		height: 104rpx;
		font-size: 32rpx;
		line-height: 104rpx;
		justify-content: space-around;
		color: rgba(0, 0, 0, 1);
	}
	.l-line{
		width: 100%;
		border: 1rpx solid rgba(230, 230, 230, 1);
	}
	.l-kuang{
		margin: 40rpx 0 0 20rpx;
		display: flex;
	}
	.l-circle{
		width: 80rpx;
		height: 80rpx;
		border-radius: 50%;
		background-color:rgba(204, 204, 204, 1);
	}
	.l-label{
		margin-left: 504rpx;
	}
</style>