add.html 15.2 KB
1 2 3 4 5 6 7 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 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448
<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
	<th:block th:include="include :: header('新增前端用户')" />
	<th:block th:include="include :: select2-css" />
</head>
<body >
    <div class="form-content">
        <form class="form-horizontal m" id="form-frontUser-add">
			<input name="openId" type="hidden" th:value="${openId}"   />
			<input name="orgId" type="hidden" id="treeId"/>
			<h4 class="form-header h4">基本信息</h4>
			<div class="row">
				<dev class="col-sm-6">
					<div class="form-group">
						<label class="col-sm-4 control-label"><span style="color: red; ">*</span>用户名称:</label>
						<div class="col-sm-8">
							<input id="userName" name="userName" placeholder="请输入用户名称" class="form-control" type="text" maxlength="30" required>
						</div>
					</div>
				</dev>
				<div class="col-sm-6">
					<div class="form-group">
						<label class="col-sm-4 control-label"><span style="color: red; ">*</span>归属部门:</label>
						<div class="col-sm-8">
							<div class="input-group">
								<input name="deptName" onclick="selectDeptTree()" id="treeName" type="text" placeholder="请选择归属部门" class="form-control" required>
								<span class="input-group-addon"><i class="fa fa-search"></i></span>
							</div>
						</div>
					</div>
				</div>
			</div>
			<div class="row">
				<div class="col-sm-6">
					<div class="form-group">
						<label class="col-sm-4 control-label"><span style="color: red; ">*</span>手机号码:</label>
						<div class="col-sm-8">
							<input name="phone" placeholder="请输入手机号码" class="form-control" type="text" maxlength="11" required>
						</div>
					</div>
				</div>
				<div class="col-sm-6">
					<div class="form-group">
						<label class="col-sm-4 control-label"><span style="color: red; ">*</span>邮箱:</label>
						<div class="col-sm-8">
							<input name="mail" class="form-control email" type="text" maxlength="50" placeholder="请输入邮箱" required>
						</div>
					</div>
				</div>
			</div>
			<div class="row">
				<div class="col-sm-6">
					<div class="form-group">
						<label class="col-sm-4 control-label"><span style="color: red; ">*</span>登录账号:</label>
						<div class="col-sm-8">
							<input name="loginName" placeholder="请输入登录账号" class="form-control required" type="text" maxlength="30" required>
						</div>
					</div>
				</div>
				<div class="col-sm-6">
					<div class="form-group">
						<label class="col-sm-4 control-label"><span style="color: red; ">*</span>登录密码:</label>
						<div class="col-sm-8">
							<input name="password" placeholder="请输入登录密码" class="form-control" type="password" th:value="${@config.getKey('sys.user.initPassword')}" required>
						</div>
					</div>
				</div>
			</div>
			<!--<div class="row">
				<div class="col-sm-6">
					<div class="form-group">
						<label class="col-sm-4 control-label">报告上限:</label>
						<div class="col-sm-8">
							<input class="form-control" type="text" name="reportNum" id="reportNum" required>
						</div>
					</div>
				</div>
				<div class="col-sm-6">
					<div class="form-group">
							<label class="col-sm-4 control-label">财务上限:</label>
							<div class="col-sm-8">
								<input class="form-control" type="text" name="financeNum" id="financeNum" required>
							</div>
					</div>
				</div>
			</div>-->
			<div class="row">
				<!--<div class="col-sm-6">
					<div class="form-group">
						<label class="col-sm-4 control-label">监控上限:</label>
						<div class="col-sm-8">
							<input class="form-control" type="text" name="upNum" id="upNum" required>
						</div>
					</div>
				</div>-->
				<div class="col-sm-6">
					<div class="form-group">
						<label class="col-sm-4 control-label">用户状态:</label>
						<div class="col-sm-8">
							<label class="toggle-switch switch-solid">
								<input type="checkbox" id="dataStatus" checked>
								<span></span>
							</label>
						</div>
					</div>
				</div>
				<div class="col-sm-6">
					<div class="form-group">
						<label class="col-sm-4 control-label">下单审核:</label>
						<div class="col-sm-8">
							<label class="radio-box"> <input type="radio" name="needaudit" value="Y" /></label>
							<label class="radio-box"> <input type="radio" name="needaudit" value="N" /></label>
						</div>
					</div>
				</div>
			</div>
			<div class="row">
				<div class="col-sm-6">
					<div class="form-group">
						<label class="col-sm-4 control-label">备注:</label>
						<div class="col-sm-8">
							<input id="ramark" name="ramark" class="form-control" type="text">
						</div>
					</div>
				</div>
			</div>
			<div class="row">
				<div class="col-sm-12">
					<div class="form-group">
						<label class="col-xs-2 control-label">角色:</label>
						<div class="col-xs-10">
							<label th:each="role:${roles}" class="check-box">
								<input name="role" type="checkbox" th:value="${role.roleId}" th:text="${role.roleName}" th:disabled="${role.status == '1'}">
							</label>
						</div>
					</div>
				</div>
			</div>
			<div class="row">
				<!--<div class="col-sm-6">
					<div class="form-group">
						<label class="col-sm-4 control-label">通知邮箱:</label>
						<div class="col-sm-8">
							<input class="form-control" type="text" name="noticeEmail" id="noticeEmail">   需要把附件信息拼装在emailAttachmentInfo传给后端
						</div>
					</div>
				</div>-->
			</div>
			<div class="row">
				<div class="col-sm-12">
					<div class="form-group">
						<label class="col-xs-2 control-label">下单限制:</label>
						<div class="col-xs-10">
							<div class="row" id="reportTypeList">
							</div>
						</div>
					</div>
				</div>
			</div>
			<div class="row">
				<div class="col-sm-6">
					<div class="form-group">
						<label class="col-sm-4 control-label">邮箱通知:</label>
						<div class="col-sm-8">
							<label class="radio-box"> <input type="radio"  name="email" value="Y"/></label>
							<label class="radio-box"> <input type="radio"  name="email" value="N"/></label>
						</div>
					</div>
				</div>
			</div>
			<div class="row">
				<div class="col-sm-6">
					<div class="form-group">
						<label class="col-sm-4 control-label">通知邮箱:</label>
						<div class="col-sm-8">
							<input class="form-control" type="text" name="noticeEmail" id="noticeEmail">
						</div>
					</div>
				</div>
			</div>
			<div class="row">
				<div class="col-sm-12">
					<div class="form-group">
						<label class="col-sm-2 control-label">其它邮箱:</label>
						<div class="col-sm-6">
							<input class="form-control" type="text" name="otherEmail" id="otherEmail"> <!--原型中可以添加多个其它邮箱,需要拼装在otherEmailInfo里传后端-->
						</div>
						<div class="col-sm-4">
							<button type="button" class="btn btn-sm btn-primary" onclick="addEmail()"><i class="fa fa-plus"></i>添加</button>
						</div>
					</div>
					<div id="otherEmailList"></div>
				</div>
			</div>
			<div class="row">
				<div class="col-sm-6">
					<div class="form-group">
						<label class="col-sm-4 control-label">是否发送附件:</label>
						<div class="col-sm-8">
							<label class="radio-box"> <input type="radio"  name="emailAttachment" value="Y"/></label>
							<label class="radio-box"> <input type="radio"  name="emailAttachment" value="N"/></label>
						</div>
					</div>
				</div>
			</div>
			<div class="row">
				<div class="col-sm-12">
					<div class="form-group">
						<label class="col-xs-2 control-label">邮箱附件:</label>
						<div class="col-xs-10">
							<div class="row" id="emailFileList">
							</div>
						</div>
					</div>
				</div>
			</div>

		</form>
	</div>
<!--	<div class="row">-->
<!--		<div class="col-sm-offset-5 col-sm-10">-->
<!--			<button type="button" class="btn btn-sm btn-primary" onclick="submitHandler()"><i class="fa fa-check"></i>保 存</button>&nbsp;-->
<!--			<button type="button" class="btn btn-sm btn-danger" onclick="closeItem()"><i class="fa fa-reply-all"></i>关 闭 </button>-->
<!--		</div>-->
<!--	</div>-->
	<th:block th:include="include :: footer" />
	<th:block th:include="include :: select2-js" />
    <script type="text/javascript">
		var prefix = ctx + "business/frontUser";

		$("#form-frontUser-add").validate({
			onkeyup: false,
			rules:{
				loginName:{
					minlength: 2,
					maxlength: 20,
					remote: {
						url: prefix + "/checkLoginNameUnique",
						type: "post",
						dataType: "json",
						data: {
							name : function() {
								return $.common.trim($("#loginName").val());
							}
						},
						dataFilter: function(data, type) {
							return $.validate.unique(data);
						}
					}
				},
				password:{
					minlength: 5,
					maxlength: 20
				},
				phone:{
					isPhone:true,
					remote: {
						url: prefix + "/checkPhoneUnique",
						type: "post",
						dataType: "json",
						data: {
							name: function () {
								return $.common.trim($("#phone").val());
							}
						},
						dataFilter: function (data, type) {
							return $.validate.unique(data);
						}
					}
				},
			},
			messages: {
				"loginName": {
					remote: "用户已经存在"
				},
				"phone":{
					remote: "手机号码已经存在"
				}
			},
			focusCleanup: true
		});



		function submitHandler() {
			if ($.validate.form()) {
				var data = $("#form-frontUser-add").serializeArray();
				var status = $("input[id='dataStatus']").is(':checked') == true ? 0 : 1;
				var roleIds = $.form.selectCheckeds("role");
				// var postIds = $.form.selectSelects("post");
				data.push({"name": "status", "value": status});
				data.push({"name": "roleIds", "value": roleIds});
				// data.push({"name": "postIds", "value": postIds});

				// 拼装其他邮箱
				let otherEmailArray = []
				$("input[name='otherEmail']").each(function (index, item) {
					if ($(item).val() != "" && $(item).val() != undefined) {
						otherEmailArray.push($(item).val())
					}
				})
				data.push({"name": "otherEmailInfo", "value": otherEmailArray.join(",")})

				// 拼装报告类型
				let tempJsonArray = []
				$.each($("#reportTypeList").children(), function (index, item) {
					if ($(item).find("input[name='orgId']").val() != "" && $(item).find("input[name='orgId']").val() != undefined) {
						let tempJson = {orgId: $(item).find("input[name='orgId']").val(),
							name: $(item).find("input[name='name']").val(),
							value: $(item).find("input[name='value']").val(),
							num: $(item).find("input[name='num']").val(),
							tempType: $(item).find("input[name='tempType']").val()
						}
						tempJsonArray.push(tempJson)
					}
				})
				// 拼装邮箱附件
				let emailJsonArray = []
				$.each($("#emailFileList").children(), function (index, item) {
					if ($(item).find("input[name='name']").val()!= "" && $(item).find("input[name='name']").val()!= undefined) {
						let checkboxTypes = $(item).find("input[name='attachmentType']:checked");
						let attachmentTypeArr = []
						checkboxTypes.each(function (index, item) {
							attachmentTypeArr.push($(item).val())
						})
						let tempJson = {orgId: $(item).find("input[name='orgId']").val(),
							name: $(item).find("input[name='name']").val(),
							value: $(item).find("input[name='value']").val(),
							tempType: $(item).find("input[name='tempType']").val(),
							attachmentType: attachmentTypeArr.join(",")
						}
						emailJsonArray.push(tempJson)
					}
				})
				data.push({"name":"reports","value": JSON.stringify(tempJsonArray)})
				data.push({"name":"emailAttachmentInfo","value": JSON.stringify(emailJsonArray)})
				console.log(data)
				$.operate.save(prefix + "/addNew", data);
				// $.operate.saveTab(prefix + "/add", data);
			}
		}

		function addEmail () {
			let otherEmailList =  $("#otherEmailList")
			let emailHtml = `
							<div class="form-group">
								<label class="col-sm-2 control-label">
									其他邮箱:
								</label>
								<div class="col-sm-6" style="margin-bottom: 10px">
									<input name="otherEmail" type="text" class="form-control">
								</div>
								<div class="col-sm-4" style="margin-bottom: 10px">
									<button type="button" class="btn btn-sm btn-danger deleteEmail"><i class="fa fa-rebel"></i>删除</button>
								</div>
							</div>
							`
			otherEmailList.append(emailHtml)
		}

		$(function (){
			$("body").on("click", ".deleteEmail", function () {
				$(this).parent().parent().remove()
			})
		})

		/*用户管理-新增-选择部门树*/
		function selectDeptTree() {
			var treeId = $("#treeId").val();
			var deptId = $.common.isEmpty(treeId) ?"0" : $("#treeId").val();
			var url = ctx + "business/frontDept/selectDeptTree/" + deptId;
			console.log(url)
			var options = {
				title: '选择部门',
				width: "380",
				url: url,
				expandLevel: 2,
				callBack: doSubmit
			};
			$.modal.openOptions(options);
		}

		function doSubmit(index, layero){
			var body = layer.getChildFrame('body', index);
			$("#treeId").val(body.find('#treeId').val());
			$("#treeName").val(body.find('#treeName').val());
			getReportTypeList();
			layer.close(index);
		}

		function getReportTypeList () {
			fetch(prefix + "/getTempConfByOrgId?orgId=" + $("#treeId").val(), {
				method: 'GET',
			}).then(function (response) {
				return response.json();
			}).then(function (response) {
				var data = response.data.tempConfList;
				var reportTypeList = $("#reportTypeList");
				var emailFileList = $("#emailFileList");
				reportTypeList.empty();
				emailFileList.empty();
				let tempHtml = ""
				let emailHtml = ""
				$.each(data, function (index, item) {
					tempHtml += `<div class="col-sm-4">
													<span>${item.name}</span>
												</div>
												<div class="col-sm-8" style="margin-bottom: 10px">
												<input name="num" type="text" class="form-control">
													<input name="orgId" type="hidden" value="${item.orgId}">
													<input name="name" type="hidden" value="${item.name}">
													<input name="value" type="hidden" value="${item.value}">
													<input name="tempType" type="hidden" value="${item.tempType}">
												</div>
												`
					if (parseInt(item.tempType) !== 3) {
							emailHtml += `<div class="col-sm-4">
													<span>${item.name}</span>
												</div>
												<div class="col-sm-8" style="margin-bottom: 10px">
													<input name="name" type="hidden" value="${item.name}">
													<input name="value" type="hidden" value="${item.value}">
													<input name="tempType" type="hidden" value="${item.tempType}">
													<label class="check-box">
														<input type="checkbox" name="attachmentType" value="1"> 司法数据Excel</input>
													</label>
													<label class="check-box">
														<input type="checkbox" name="attachmentType" value="2"> 报告PDF</input>
													</label>
													<label class="check-box">
														<input type="checkbox" name="attachmentType" value="3"> 报告Word</input>
													</label>
													<label class="check-box">
														<input type="checkbox" name="attachmentType" value="4"> 翻译PDF</input>
													</label>
												</div>
												`
					}
				})
				reportTypeList.append(tempHtml);
				emailFileList.append(emailHtml);
				console.log(data)
			})
		}
	</script>
</body>
</html>