sysEveUserAdd.js 4.5 KB
Newer Older
doc_wei's avatar
doc_wei 已提交
1 2 3 4 5 6 7 8 9 10
var staffId = "";

// 员工详情id
var rowId = "";

layui.config({
	base: basePath, 
	version: skyeyeVersion
}).extend({
    window: 'js/winui.window'
doc_wei's avatar
doc_wei 已提交
11
}).define(['window', 'table', 'jquery', 'winui', 'tableSelect', 'laydate'], function (exports) {
doc_wei's avatar
doc_wei 已提交
12 13 14 15
	winui.renderColor();
	layui.use(['form'], function (form) {
		var index = parent.layer.getFrameIndex(window.name);
	    var $ = layui.$,
doc_wei's avatar
doc_wei 已提交
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
	    	tableSelect = layui.tableSelect,
			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
				}
			}
		});
		// 设置最小可选的日期
		function minDate(){
			var now = new Date();
			return now.getFullYear() + "-" + (now.getMonth() + 1) + "-" + now.getDate();
		}
		skyeyeClassEnumUtil.showEnumDataListByClassName("userIsTermOfValidity", 'radio', "isTermOfValidity", '', form);

		$(".effectiveDate").hide();
		form.on('radio(isTermOfValidityFilter)', function (data) {
			let val = data.value;
			if (val == 1) {
				$(".effectiveDate").hide();
			} else if (val == 2) {
				$(".effectiveDate").show();
			}
		});

doc_wei's avatar
doc_wei 已提交
69
 		form.verify({
W
weizhiqiang 已提交
70
 			password : function(value, item) {
doc_wei's avatar
doc_wei 已提交
71 72 73 74
	            if(value.length < 6){
	                return "密码长度不能小于6位";
	            }
	        },
W
weizhiqiang 已提交
75
	        confirmPwd : function(value, item) {
doc_wei's avatar
doc_wei 已提交
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94
	            if($("#password").val() != value){
	                return "两次输入密码不一致,请重新输入!";
	            }
	        }
	    });
 		
 		tableSelect.render({
 	    	elem: '#userName',	//定义输入框input对象
 	    	checkedKey: 'id', //表格的唯一键值,非常重要,影响到选中状态 必填
 	    	searchKey: 'userName',	//搜索输入框的name值 默认keyword
 	    	searchPlaceholder: '员工姓名搜索',	//搜索输入框的提示文字 默认关键词搜索
 	    	table: {	//定义表格参数,与LAYUI的TABLE模块一致,只是无需再定义表格elem
 	    		url: reqBasePath + 'sys034',
 	    		method: 'post',
 	    		page: true,
 	    	    limits: [8, 16, 24, 32, 40, 48, 56],
 	    	    limit: 8,
 	    		cols: [[
 	    		    { type: 'radio'},
95
 					{ title: systemLanguage["com.skyeye.serialNumber"][languageType], type: 'numbers' },
W
weizhiqiang 已提交
96
					{ field: 'jobNumber', title: '员工工号', width: 100, templet: function (d) {
doc_wei's avatar
doc_wei 已提交
97 98 99
						return '<a rowId="' + d.id + '" class="notice-title-click">' + d.jobNumber + '</a>';
					}},
 					{ field: 'userName', title: '员工姓名', width: 100 },
doc_wei's avatar
doc_wei 已提交
100 101 102
					{ field: 'userSex', title: '性别', width: 60, rowspan: '2', templet: function (d) {
						return skyeyeClassEnumUtil.getEnumDataNameByCodeAndKey("sexEnum", 'id', d.userSex, 'name');
					}},
doc_wei's avatar
doc_wei 已提交
103 104 105 106 107 108 109 110 111 112 113 114
 				]]
 	    	},
 	    	done: function (elem, data) {
 	    		var newJson = data.data[0].userName;
 	    		var ids = data.data[0].id;
 	    		elem.val(newJson);
 	    		elem.attr('ts-selected', ids);
				staffId = ids;
 	    	}
 	    });

		// 员工详情
doc_wei's avatar
doc_wei 已提交
115
		$("body").on("click", ".notice-title-click", function() {
doc_wei's avatar
doc_wei 已提交
116 117
			rowId = $(this).attr("rowId");
			_openNewWindows({
118
				url: "../../tpl/sysEveUserStaff/sysEveUserStaffDetails.html",
119
				title: systemLanguage["com.skyeye.detailsPageTitle"][languageType],
doc_wei's avatar
doc_wei 已提交
120
				pageId: "sysEveUserStaffDetails",
doc_wei's avatar
doc_wei 已提交
121
				area: ['90vw', '90vh'],
W
weizhiqiang 已提交
122
				callBack: function (refreshCode) {
doc_wei's avatar
doc_wei 已提交
123 124 125 126 127
				}});
		});
 	    
	    matchingLanguage();
 		form.render();
W
weizhiqiang 已提交
128
 		form.on('submit(formAddBean)', function(data) {
doc_wei's avatar
doc_wei 已提交
129 130
			if (winui.verifyForm(data.elem)) {
				var params = {
doc_wei's avatar
doc_wei 已提交
131
					staffId: staffId,
doc_wei's avatar
doc_wei 已提交
132 133
					userCode: $("#userCode").val(),
					password: $("#password").val(),
doc_wei's avatar
doc_wei 已提交
134
					isTermOfValidity: dataShowType.getData('isTermOfValidity')
doc_wei's avatar
doc_wei 已提交
135
				}
W
weizhiqiang 已提交
136
				AjaxPostUtil.request({url: reqBasePath + "sysAdd005", params: params, type: 'json', method: "POST", callback: function (json) {
137 138
					parent.layer.close(index);
					parent.refreshCode = '0';
doc_wei's avatar
doc_wei 已提交
139 140 141 142
				}});
			}
			return false;
 		});
doc_wei's avatar
doc_wei 已提交
143
	    $("body").on("click", "#cancle", function() {
doc_wei's avatar
doc_wei 已提交
144 145 146 147
	    	parent.layer.close(index);
	    });
	});
});