assetManageEdit.js 6.6 KB
Newer Older
doc_wei's avatar
doc_wei 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19

var userList = new Array();//选择用户返回的集合或者进行回显的集合
var employeeuserList = new Array();//选择用户返回的集合或者进行回显的集合

// 资产信息
layui.config({
	base: basePath, 
	version: skyeyeVersion
}).extend({
    window: 'js/winui.window'
}).define(['window', 'jquery', 'winui', 'fileUpload', 'tagEditor', 'laydate'], function (exports) {
	winui.renderColor();
	layui.use(['form'], function (form) {
		var index = parent.layer.getFrameIndex(window.name);
	    var $ = layui.$,
	    	laydate = layui.laydate;

	    showGrid({
		 	id: "showForm",
doc_wei's avatar
doc_wei 已提交
20
		 	url: flowableBasePath + "asset004",
doc_wei's avatar
doc_wei 已提交
21 22 23 24 25 26 27
		 	params: {rowId:parent.rowId},
		 	pagination: false,
		 	template: getFileContent('tpl/assetManage/assetManageEditTemplate.tpl'),
		 	ajaxSendLoadBefore: function(hdb){
		 		hdb.registerHelper("compare1", function(v1, options){
					if(isNull(v1)){
						return path + "assets/img/uploadPic.png";
doc_wei's avatar
doc_wei 已提交
28
					} else {
doc_wei's avatar
doc_wei 已提交
29 30 31 32
						return basePath + v1;
					}
				});
		 	},
W
weizhiqiang 已提交
33
		 	ajaxSendAfter:function (json) {
34 35
		 		// 生产日期
		 		laydate.render({elem: '#manufacturerTime', type: 'date', max: getFormatDate(), trigger: 'click'});
doc_wei's avatar
doc_wei 已提交
36
		 		
37 38
		 		// 采购日期
		 		laydate.render({elem: '#purchaseTime', type: 'date', max: getFormatDate(), trigger: 'click'});
doc_wei's avatar
doc_wei 已提交
39
		 		
40
		 		// 资产类型
doc_wei's avatar
doc_wei 已提交
41 42
		 		showGrid({
				 	id: "typeId",
doc_wei's avatar
doc_wei 已提交
43
				 	url: flowableBasePath + "assettype006",
doc_wei's avatar
doc_wei 已提交
44 45 46 47 48 49 50 51 52 53 54 55 56 57
				 	params: {},
				 	pagination: false,
				 	template: getFileContent('tpl/template/select-option-must.tpl'),
				 	ajaxSendLoadBefore: function(hdb){
				 	},
				 	ajaxSendAfter:function(j){
				 		$("#typeId").val(json.bean.typeId);
				 		form.render('select');
				 	}
				});
		 		
		 		//资产来源
		 		showGrid({
				 	id: "fromId",
doc_wei's avatar
doc_wei 已提交
58
				 	url: flowableBasePath + "assetfrom006",
doc_wei's avatar
doc_wei 已提交
59 60 61 62 63 64 65 66 67 68
				 	params: {},
				 	pagination: false,
				 	template: getFileContent('tpl/template/select-option-must.tpl'),
				 	ajaxSendLoadBefore: function(hdb){
				 	},
				 	ajaxSendAfter:function(j){
				 		$("#fromId").val(json.bean.fromId);
				 		form.render('select');
				 	}
				});
W
weizhiqiang 已提交
69 70 71 72

				// 初始化上传
				$("#assetImg").upload(systemCommonUtil.uploadCommon003Config('assetImg', 6, json.bean.assetImg, 1));

doc_wei's avatar
doc_wei 已提交
73 74 75 76 77
		 		var userNames = [];
		 		userList = [].concat(json.bean.assetAdmin);
		 		$.each(json.bean.assetAdmin, function(i, item){
		 			userNames.push(item.name);
		 		});
78
		 		// 管理人员选择
doc_wei's avatar
doc_wei 已提交
79 80 81 82 83
				$('#assetAdmin').tagEditor({
			        initialTags: userNames,
			        placeholder: '请选择资产管理人',
					editorTag: false,
			        beforeTagDelete: function(field, editor, tags, val) {
84
						userList = [].concat(arrayUtil.removeArrayPointName(userList, val));
doc_wei's avatar
doc_wei 已提交
85 86 87 88 89 90 91 92
			        }
			    });
				
				var employeeuserNames = [];
		 		employeeuserList = [].concat(json.bean.employeeId);
		 		$.each(json.bean.employeeId, function(i, item){
		 			employeeuserNames.push(item.name);
		 		});
93
				// 领用人选择
doc_wei's avatar
doc_wei 已提交
94 95 96 97 98
				$('#employeeId').tagEditor({
			        initialTags: employeeuserNames,
			        placeholder: '请选择领用人',
					editorTag: false,
			        beforeTagDelete: function(field, editor, tags, val) {
99
						employeeuserList = [].concat(arrayUtil.removeArrayPointName(employeeuserList, val));
doc_wei's avatar
doc_wei 已提交
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123
			        }
			    });

				// 附件回显
				skyeyeEnclosure.initTypeISData({'enclosureUpload': json.bean.enclosureInfo});

    			matchingLanguage();
		 		form.render();
		 	    form.on('submit(formEditBean)', function (data) {
		 	        if (winui.verifyForm(data.elem)) {
		 	        	var params = {
	 	        			rowId: parent.rowId,
	 	        			assetName: $("#assetName").val(),
	 	        			assetNum: $("#assetNum").val(),
	 	        			specifications: $("#specifications").val(),
	 	        			unitPrice: $("#unitPrice").val(),
	 	        			manufacturer: $("#manufacturer").val(),
	 	        			manufacturerTime: $("#manufacturerTime").val(),
	 	        			supplier: $("#supplier").val(),
	 	        			purchaseTime: $("#purchaseTime").val(),
	 	        			storageArea: $("#storageArea").val(),
	 	        			roomAddDesc: $("#roomAddDesc").val(),
							typeId: $("#typeId").val(),
							fromId: $("#fromId").val(),
124 125 126 127
							enclosureInfo: skyeyeEnclosure.getEnclosureIdsByBoxId('enclosureUpload'),
							assetAdmin: systemCommonUtil.tagEditorGetItemData('assetAdmin', userList),
							employeeId: systemCommonUtil.tagEditorGetItemData('employeeId', employeeuserList),
							assetImg: $("#assetImg").find("input[type='hidden'][name='upload']").attr("oldurl")
doc_wei's avatar
doc_wei 已提交
128
	 	 	        	};
129
	 	 	        	if(isNull(params.assetImg)) {
doc_wei's avatar
doc_wei 已提交
130
	 	 	        		winui.window.msg('请上传资产图片', {icon: 2, time: 2000});
doc_wei's avatar
doc_wei 已提交
131 132
	 	 	        		return false;
	 	 	        	}
W
weizhiqiang 已提交
133
	 	 	        	AjaxPostUtil.request({url: flowableBasePath + "asset005", params: params, type: 'json', callback: function (json) {
doc_wei's avatar
doc_wei 已提交
134
	 		 	   			if (json.returnCode == 0) {
doc_wei's avatar
doc_wei 已提交
135 136
	 			 	   			parent.layer.close(index);
	 			 	        	parent.refreshCode = '0';
doc_wei's avatar
doc_wei 已提交
137
	 		 	   			} else {
doc_wei's avatar
doc_wei 已提交
138
	 		 	   				winui.window.msg(json.returnMessage, {icon: 2, time: 2000});
doc_wei's avatar
doc_wei 已提交
139 140 141 142 143 144 145 146
	 		 	   			}
	 		 	   		}});
		 	        }
		 	        return false;
		 	    });
		 	}
		});
	    
147 148 149 150 151 152 153 154 155 156
	    // 管理人员选择
		$("body").on("click", "#userNameSelPeople", function(e) {
			systemCommonUtil.userReturnList = [].concat(userList);
			systemCommonUtil.chooseOrNotMy = "1"; // 人员列表中是否包含自己--1.包含;其他参数不包含
			systemCommonUtil.chooseOrNotEmail = "2"; // 人员列表中是否必须绑定邮箱--1.必须;其他参数没必要
			systemCommonUtil.checkType = "2"; // 人员选择类型,1.多选;其他。单选
			systemCommonUtil.openSysUserStaffChoosePage(function (userReturnList) {
				// 重置数据
				userList = [].concat(systemCommonUtil.tagEditorResetData('assetAdmin', userReturnList));
			});
doc_wei's avatar
doc_wei 已提交
157 158
		});
		
159 160 161 162 163 164 165 166 167 168
		// 领用人选择
		$("body").on("click", "#employeePeople", function(e) {
			systemCommonUtil.userReturnList = [].concat(employeeuserList);
			systemCommonUtil.chooseOrNotMy = "1"; // 人员列表中是否包含自己--1.包含;其他参数不包含
			systemCommonUtil.chooseOrNotEmail = "2"; // 人员列表中是否必须绑定邮箱--1.必须;其他参数没必要
			systemCommonUtil.checkType = "2"; // 人员选择类型,1.多选;其他。单选
			systemCommonUtil.openSysUserStaffChoosePage(function (userReturnList) {
				// 重置数据
				employeeuserList = [].concat(systemCommonUtil.tagEditorResetData('employeeId', userReturnList));
			});
doc_wei's avatar
doc_wei 已提交
169 170
		});
	    
171
	    $("body").on("click", ".enclosureItem", function() {
doc_wei's avatar
doc_wei 已提交
172 173 174
	    	download(fileBasePath + $(this).attr("rowpath"), $(this).html());
	    });
	    
175
	    $("body").on("click", "#cancle", function() {
doc_wei's avatar
doc_wei 已提交
176 177 178 179
	    	parent.layer.close(index);
	    });
	});
});