<div class="layui-fluid">
	<div class="layui-row layui-col-space15">
		<div class="layui-col-md12">
			<div class="layui-card">
				<div class="layui-card-header">普通招聘</div>
				<div class="layui-card-body" pad15>

					<div class="layui-form layui-form-pane" lay-filter="LAY-comjobs-comjobsform-edit">
						<input type="hidden" name="id" value="{$comjobs.id}">
						<div class="layui-form-item">
							<label class="layui-form-label">劳务公司</label>
							<div class="layui-input-block">
								<input type="text" name="workertitle" value="{$worker.title}" readonly placeholder="请输入..."
									   autocomplete="off" class="layui-input layui-disabled">
							</div>
						</div>
						<div class="layui-form-item">
							<label class="layui-form-label"><span style="color:#f90c05;">*</span>招聘标题</label>
							<div class="layui-input-block">
								<input type="text" name="title" value="{$comjobs.title}" lay-verify="required" placeholder="请输入..."
									   autocomplete="off" class="layui-input">
							</div>
						</div>

						<div class="layui-form-item" id="video-box">
							<input type="hidden" id="old_video" value="{$comjobs.video}" name="old_video"/>
							<input type="hidden" id="new_video" value="" name="new_video"/>

							<label class="layui-form-label">小视频</label>
							<div class="layui-input-inline">
								<button type="submit" class="layui-btn"  id="add_video" ><i class="layui-icon"></i>选择视频</button>
							</div>
							<video id="videoid" width="320" height="240" controls="controls" >

								<source id="show_video"  src="{$comjobs.video}" type="video/mp4" />
							</video>

						</div>

						<div class="layui-form-item">
							<label class="layui-form-label"><span style="color:#f90c05;">*</span>岗位类型</label>
							<div class="layui-input-block">
								<select name="cateid" lay-search lay-verify="required">
									<option value="">请选择岗位类型（可搜索）...</option>
									{volist name="catelist" id="vo"}
									<option value="{$vo.id}" {$comjobs.cateid==$vo.id ? 'selected' : '' }>{$vo.title}</option>
									{/volist}
								</select>
							</div>
						</div>
						<div class="layui-form-item" id="LAY-comjobs-comjobsform-edit-areapicker">
							<label class="layui-form-label"><span style="color:#f90c05;">*</span>工作地点</label>
							<div class="layui-input-inline">
								<select name="province" class="province-selector" data-value="{$comjobs.province}" lay-filter="province-2"
										lay-verify="required">
									<option value="">请选择省</option>
								</select>
							</div>
							<div class="layui-input-inline">
								<select name="city" class="city-selector" data-value="{$comjobs.city}" lay-filter="city-2" lay-verify="required">
									<option value="">请选择市</option>
								</select>
							</div>
							<div class="layui-input-inline">
								<select name="district" class="district-selector" data-value="{$comjobs.district}" lay-filter="district-2"
										lay-verify="required">
									<option value="">请选择区</option>
								</select>
							</div>
						</div>
						<div class="layui-form-item">
							<label class="layui-form-label"><span style="color:#f90c05;">*</span>招工年龄</label>
							<div class="layui-input-block">
								<input type="text" name="agegroup" value="{$comjobs.agegroup}" lay-verify="required" placeholder="请输入..."
									   autocomplete="off" class="layui-input">
							</div>
						</div>
						<div class="layui-form-item">
							<label class="layui-form-label">招聘标签</label>
							<div class="layui-input-block">
								<div class="tags" id="tags">
									<input type="text" name="" id="inputTags" placeholder="回车生成标签" autocomplete="off">
								</div>
							</div>
						</div>
						<div class="layui-form-item">
							<label class="layui-form-label"><span style="color:#f90c05;">*</span>截止日期</label>
							<div class="layui-input-block">
								<input type="text" name="enddate" id="enddate" value="{$comjobs.enddate}" lay-verify="required" placeholder="请选择..."
									   autocomplete="off" class="layui-input">
							</div>
						</div>
						<div class="layui-form-item">
							<label class="layui-form-label">岗位要求</label>
							<div class="layui-input-block">
								<textarea name="requirement" placeholder="请输入..." rows="6" class="layui-textarea">{$comjobs.requirement}</textarea>
							</div>
						</div>
						<div class="layui-form-item">
							<label class="layui-form-label">环境照片</label>
							<div class="layui-input-block">
								<div class="layui-upload">
									<button type="button" class="layui-btn attachment-upload-images" data-input="picall" data-amount="9">上传图片</button>
									<div class="layui-inline layui-word-aux"> 最佳尺寸：750px*375px </div>
									<div class="layui-upload-list echo-attachment-image-list" id="picall">
										{volist name="comjobs.picall" id="vo"}
										<div>
											<input type="hidden" name="picall[]" value="{$vo}">
											<img src="{$vo}"> <button type="button" class="attachmentdel layui-btn layui-btn-primary layui-btn-xs layui-btn-fluid">删除</button>
										</div>
										{/volist}
									</div>
								</div>
							</div>
						</div>
						<div class="layui-form-item">
							<label class="layui-form-label">企业简介</label>
							<div class="layui-input-block">
								<textarea name="comdetails" placeholder="请输入..." rows="6" class="layui-textarea">{$comjobs.comdetails}</textarea>
							</div>
						</div>
						<div class="layui-form-item">
							<label class="layui-form-label">企业介绍</label>
							<div class="layui-input-block">
								<textarea name="companydetails" placeholder="请输入..." rows="6" class="layui-textarea">{$comjobs.companydetails}</textarea>
							</div>
						</div>
						<div class="layui-form-item">
							<label class="layui-form-label">返佣金额</label>
							<div class="layui-input-block">
								<input type="text" name="retmoney" value="{$comjobs.retmoney}" placeholder="请输入...."
									   autocomplete="off" class="layui-input">
							</div>
						</div>
						<div class="layui-form-item" pane>
							<label class="layui-form-label">薪资类型</label>
							<div class="layui-input-block">
								<input type="radio" name="wtype" value="1" title="月薪" {eq name="comjobs.wtype|default=1" value="1"}checked{/eq}>
								<input type="radio" name="wtype" value="2" title="日薪" {eq name="comjobs.wtype" value="2"}checked{/eq}>
								<input type="radio" name="wtype" value="3" title="时薪" {eq name="comjobs.wtype" value="3"}checked{/eq}>
								<input type="radio" name="wtype" value="4" title="面议" {eq name="comjobs.wtype" value="4"}checked{/eq}>
							</div>
						</div>
						<div class="layui-form-item">
							<label class="layui-form-label">基本工资</label>
							<div class="layui-input-block">
								<input type="text" name="bwagall" value="{$comjobs.bwagall}" placeholder="请输入...."
									   autocomplete="off" class="layui-input">
							</div>
						</div>
						<div class="layui-form-item">
							<label class="layui-form-label">综合月薪</label>
							<div class="layui-input-block">
								<input type="text" name="zwagall" value="{$comjobs.zwagall}" placeholder="请输入...."
									   autocomplete="off" class="layui-input">
							</div>
						</div>
						<div class="layui-form-item">
							<label class="layui-form-label">返费政策</label>
							<div class="layui-input-block">

								<?php if(!empty($id)):?>
									<input type="text" name="fwagall" value="{$comjobs.fwagall}" readonly  autocomplete="off" class="layui-input layui-disabled">
								<?php else:?>
									<input type="text" name="fwagall" value="{$comjobs.fwagall}"  placeholder="请输入...." autocomplete="off" class="layui-input" >
								<?php endif;?>

								<div class="layui-form-mid layui-word-aux">为空表示没有返费</div>
							</div>
						</div>
						<?php if(!empty($comjobs['status'])):?>
							<div class="layui-form-item" pane>
								<label class="layui-form-label">状态</label>
								<div class="layui-input-block">
									<input type="radio" name="status" value="2" title="待审核" <?php if($comjobs['status'] == 2):?>checked<?php endif;?>>
									<?php if($comjobs['status'] == 3):?>
									<input type="radio" name="status" value="3" title="已上架" checked>
									<?php endif;?>

									<input type="radio" name="status" value="4" title="已停招" <?php if($comjobs['status'] == 4):?>checked<?php endif;?>>
									<input type="radio" name="status" value="5" title="已下架" <?php if($comjobs['status'] == 5):?>checked<?php endif;?>>
								</div>
							</div>
						<?php endif;?>
						<div class="layui-form-item">
							<label class="layui-form-label"><span style="color:#f90c05;">*</span>咨询电话</label>
							<div class="layui-input-block">
								<input type="text" name="telephone" value="{$comjobs.telephone}" lay-verify="required" placeholder="请输入..." autocomplete="off" class="layui-input">
							</div>
						</div>
						<div class="layui-form-item">
							<label class="layui-form-label">补充说明</label>
							<div class="layui-input-block">
								<textarea name="remark" placeholder="请输入..." class="layui-textarea">{$comjobs.remark}</textarea>
							</div>
						</div>

						<div class="layui-form-item">
							<div class="layui-input-block">
								<input type="button" lay-submit lay-filter="LAY-comjobs-comjobsform-edit-submit" value="确认提交" class="layui-btn">
							</div>
						</div>
					</div>

				</div>
			</div>
		</div>
	</div>
</div>


<script>
	layui.config({
		base: '/static/echoui/' //静态资源所在路径
	}).extend({
		index: 'lib/index' //主入口模块
	}).use(['index', 'form', 'set', 'layedit', 'laydate', 'upload', 'inputTags', 'layarea','upload'], function() {
		var $ = layui.$,
				setter = layui.setter,
				admin = layui.admin,
				layedit = layui.layedit,
				laydate = layui.laydate,
				form = layui.form,
				inputTags = layui.inputTags,
				upload = layui.upload,
				layarea = layui.layarea;

		var video_time;

		form.render();

		inputTags.render({
			elem: '#inputTags',
			content: {:json_encode($comjobs.tags)} == null ? [] : {:json_encode($comjobs.tags)},
		aldaBtn: true,
				count: 6,
				done: function(value) {}
	});

		layarea.render({
			elem: '#LAY-comjobs-comjobsform-edit-areapicker',
			// data: {
			// 	province: '河南省',
			// 	city: '郑州市',
			// 	district: '金水区',
			// }
		});

		laydate.render({
			elem: '#enddate',
			type: 'date',
			format: 'yyyy-MM-dd'
		});
		laydate.render({
			elem: '#updatetime',
			type: 'datetime'
		});
		laydate.render({
			elem: '#createtime',
			type: 'datetime'
		});


		upload.render({
			elem: '#add_video'
			,url: setter.baseWorkerUrl + 'comjobs/upload_video'  //改成您自己的上传接口
			,accept: 'video' //视频
			,done: function(res){
				var src = res.data.src;
				sourceDom = $("<source src=\""+ src +"\">");
				// $("#video-box video").append(sourceDom);
				document.getElementById("videoid").src=src ;
				document.getElementById("videoid").play();

				var timer = setTimeout(function(){
					video_time = document.getElementById("videoid").duration;//视频时长
								if(Math.ceil(video_time) > 15){
									layer.msg('上传视频不能超过15秒', {icon: 2});
									$("#add_video").css('cssText','background-color:#e81313');
								}else{
									layer.msg('上传成功');
									$("#add_video").css('cssText','background-color:#009688');
									$("#new_video").val(src);

								}
								clearTimeout(timer);
							},1000);

			}
		});

		$('.echo-attachment-image-list').on('click', '.attachmentdel', function() {
			$(this).parent().remove();
		});
		upload.render({
			elem: '.attachment-upload-images',
			url: setter.baseAdminUrl + 'attachment/tplfieldimage',
			accept: 'images',
			exits: 'jpg|png|jpeg',
			acceptMime: 'image/*',
			size: 2048,
			number: 1,
			method: 'post',
			before: function(obj) {
				var item = this.item;
				upload_input = $(item).data('input');
				upload_amount = $(item).data('amount');
				layer.load();
			},
			done: function(res, index, upload) {
				layer.closeAll('loading');
				var html = "";
				if (upload_amount == 1) {
					html += '<div> <input type="hidden" name="' + upload_input + '" value="' + res.data.src + '"> ';
					html += '<img src="' + res.data.src + '"></div>';
					$("#" + upload_input).html(html);
				} else {
					html += '<div> <input type="hidden" name="' + upload_input + '[]" value="' + res.data.src + '"> ';
					html += '<img src="' + res.data.src +
							'"> <button type="button" class="attachmentdel layui-btn layui-btn-primary layui-btn-xs layui-btn-fluid">删除</button></div>';
					$("#" + upload_input).append(html);
				}
			},
			error: function(index, upload) {
				layer.closeAll('loading');
			}
		});

		form.on('submit(LAY-comjobs-comjobsform-edit-submit)', function(obj) {
			if(video_time)
			{
				if(Math.ceil(video_time) >15)
				{
					layer.msg('视频不能超过15秒');
					return false;
				}
			}
			var index = parent.layer.getFrameIndex(window.name);
			admin.req({
				url: setter.baseWorkerUrl + 'comjobs/editcomjobs',
				data: obj.field,
				type: 'post',
				done: function(res) {
					layer.msg("提交成功", {
						icon: 1
					});
					parent.layui.table.reload('LAY-comjobs-comjobslist-table'); //重载表格
					parent.layer.close(index);
				}
			});
		});
	});
</script>
