addSchedule.js 5.3 KB
Newer Older
doc_wei's avatar
doc_wei 已提交
1 2 3 4 5
layui.config({
	base: basePath, 
	version: skyeyeVersion
}).extend({
    window: 'js/winui.window'
doc_wei's avatar
doc_wei 已提交
6
}).define(['window', 'jquery', 'winui', 'laydate', 'form'], function (exports) {
doc_wei's avatar
doc_wei 已提交
7
	winui.renderColor();
doc_wei's avatar
doc_wei 已提交
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166
	var index = parent.layer.getFrameIndex(window.name);
	var $ = layui.$,
		form = layui.form,
		laydate = layui.laydate;

	var startTime = laydate.render({
		elem: '#startTime', //指定元素
		format: 'yyyy-MM-dd',
		min: minDate(),
		theme: 'grid',
		done:function(value, date){
			endTime.config.min = {
				year: date.year,
				month: date.month - 1,//关键
				date: date.date,
				hours: date.hours,
				minutes: date.minutes,
				seconds: date.seconds
			};
		}
	});

	var endTime = laydate.render({
		elem: '#endTime', //指定元素
		format: 'yyyy-MM-dd',
		min: minDate(),
		theme: 'grid',
		done:function(value, date){
			startTime.config.max = {
				year: date.year,
				month: date.month - 1,//关键
				date: date.date,
				hours: date.hours,
				minutes: date.minutes,
				seconds: date.seconds
			}
		}
	});

	var scheduleDayTime = laydate.render({
		elem: '#scheduleDayTime', //指定元素
		format: 'yyyy-MM-dd',
		min: minDate(),
		theme: 'grid',
	});

	var scheduleDayStartTime = laydate.render({
		elem: '#scheduleDayStartTime', //指定元素
		format: 'HH:mm',
		min: minHourDate(),
		type: 'timeminuteCompare',
		minutesinterval: 30,
		done:function(value, date){
			scheduleDayEndTime.config.min = {
				year: date.year,
				month: date.month - 1,//关键
				date: date.date,
				hours: date.hours,
				minutes: date.minutes,
				seconds: date.seconds
			};
		}
	});

	var scheduleDayEndTime = laydate.render({
		elem: '#scheduleDayEndTime', //指定元素
		format: 'HH:mm',
		min: minHourDate(),
		type: 'timeminuteCompare',
		minutesinterval: 30,
		done:function(value, date){
			scheduleDayStartTime.config.max = {
				year: date.year,
				month: date.month - 1,//关键
				date: date.date,
				hours: date.hours,
				minutes: date.minutes,
				seconds: date.seconds
			};
		}
	});

	//选中日程日历进行添加日程
	if (!isNull(parent.childParams)) {
		let allDay = 1;
		if (!parent.childParams.allDay) {//不是全天
			allDay = 0;
			$(".allDayIsTrue").hide();
			$(".allDayIsFalse").show();
			$("#scheduleDayTime").val(parent.childParams.start.format("yyyy-MM-dd"));
			$("#scheduleDayStartTime").val(parent.childParams.start.format("hh:mm"));
			$("#scheduleDayEndTime").val(parent.childParams.end.format("hh:mm"));
		} else {//是全天
			$("#startTime").val(parent.childParams.start.format("yyyy-MM-dd"));
			$("#endTime").val(parent.childParams.end.format("yyyy-MM-dd"));
		}
		skyeyeClassEnumUtil.showEnumDataListByClassName("whetherEnum", 'radio', "allDay", allDay, form);
	} else {
		skyeyeClassEnumUtil.showEnumDataListByClassName("whetherEnum", 'radio', "allDay", '', form);
	}

	skyeyeClassEnumUtil.showEnumDataListByClassName("scheduleImported", 'radio', "imported", '', form);
	skyeyeClassEnumUtil.showEnumDataListByClassName("scheduleRemindType", 'select', "remindType", '', form);
	skyeyeClassEnumUtil.showEnumDataListByClassName("checkDayType", 'select', "type", '', form);

	matchingLanguage();
	form.render();

	// 日程是否全天
	form.on('radio(allDayFilter)', function (data) {
		if (data.value == 0) {//不是全天
			$(".allDayIsTrue").hide();
			$(".allDayIsFalse").show();
		} else {//是全天
			$(".allDayIsTrue").show();
			$(".allDayIsFalse").hide();
		}
	});

	form.on('submit(formAddBean)', function (data) {
		if (winui.verifyForm(data.elem)) {
			var params = {
				name: $("#name").val(),
				remark: $("#remark").val(),
				allDay: dataShowType.getData('allDay'),
				remindType: dataShowType.getData('remindType'),
				type: dataShowType.getData('type'),
				imported: dataShowType.getData('imported'),
			};
			if (params.allDay == 1) {//全天
				if (isNull($("#startTime").val())) {
					layer.msg("请选择开始时间", {icon: 5, shift: 6});
					return false;
				}
				if (isNull($("#endTime").val())) {
					layer.msg('请选择结束时间', {icon: 5, shift: 6});
					return false;
				}
				params.startTime = $("#startTime").val() + " 00:00:00";
				params.endTime = $("#endTime").val() + " 23:59:59";
			} else {
				if (isNull($("#scheduleDayTime").val())) {
					layer.msg('请填写日程日期', {icon: 5, shift: 6});
					return false;
				}
				if (isNull($("#scheduleDayStartTime").val())) {
					layer.msg('请填写日程开始时间', {icon: 5, shift: 6});
					return false;
				}
				if (isNull($("#scheduleDayEndTime").val())) {
					layer.msg('请填写日程结束时间', {icon: 5, shift: 6});
					return false;
				}
				params.startTime = $("#scheduleDayTime").val() + " " + $("#scheduleDayStartTime").val() + ":00";
				params.endTime = $("#scheduleDayTime").val() + " " + $("#scheduleDayEndTime").val() + ":00";
			}
			AjaxPostUtil.request({url: sysMainMation.scheduleBasePath + "insertScheduleDay", params: params, type: 'json', method: "POST", callback: function (json) {
				AjaxPostUtil.request({url: sysMainMation.scheduleBasePath + "syseveschedule006", params: {id: json.bean.id}, type: 'json', method: "GET", callback: function (result) {
					parent.childParams = result.bean;
167 168
					parent.layer.close(index);
					parent.refreshCode = '0';
doc_wei's avatar
doc_wei 已提交
169 170 171 172 173 174 175 176 177
				}});
			}});
		}
		return false;
	});

	// 取消
	$("body").on("click", "#cancle", function() {
		parent.layer.close(index);
doc_wei's avatar
doc_wei 已提交
178 179
	});
});