add.html 5.27 KB
<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
	<th:block th:include="include :: header('新增模版配置')" />
</head>
<body class="white-bg">
	<div class="wrapper wrapper-content animated fadeInRight ibox-content">
		<form class="form-horizontal m" id="form-templateConfiguration-add" th:object="${frontDept}">
			<input id="orgId" name="orgId" th:value="*{id}"  type="hidden">
			<div class="form-group">
				<label class="col-sm-3 control-label">合作机构名称:</label>
				<div class="col-sm-8">
					<input id="deptName" name="deptName" class="form-control" type="text" th:field="*{deptName}">
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">所属集团名称:</label>
				<div class="col-sm-8">
					<input id="prentDeptName" name="prentDeptName" class="form-control"
							 type="text" th:value ="${prentDeptName}" />
				</div>
			</div>

			<div class="form-group">
				<label class="col-sm-3 control-label">关联合同名称:</label>
				<div class="col-sm-8">
					<input id="contractName"  name="contractName" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">报告业务形式:</label>
				<div class="col-sm-8">
					<label class="radio-inline">
						<input type="radio" id="reportForm" name="reportForm" value="1" checked> 正式报告
					</label>
					<label class="radio-inline">
						<input type="radio" name="reportForm" value="0"> 试用报告
					</label>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">报告业务类型:</label>
				<div class="col-sm-8">
					<!-- 使用Thymeleaf模板引擎遍历传递的background_report_type数据 -->
					<div th:each="item : ${backgroundReportType}">
						<label class="checkbox-inline">
							<!-- 动态生成checkbox,根据dictLabel和dictValue填充 -->
							<input type="checkbox" name="typeId" th:value="${item.dictValue}" onclick="handleChoiceReportType()"/>
							<span th:text="${item.dictLabel}">报告业务类型</span>
						</label>
					</div>
				</div>
			</div>

			<div class="form-group">
				<label class="col-sm-3 control-label">定制模板类型:</label>
				<div class="col-sm-8">
					<div th:each="item : ${customReportType}">
						<label class="checkbox-inline">
							<!-- 动态生成checkbox,根据dictLabel和dictValue填充 -->
							<input type="checkbox" name="clientId" th:value="${item.id}" />
							<span th:text="${item.tName}">报告业务类型</span>
						</label>
					</div>
				</div>
			</div>

			<div id="bizTypesDiv">

			</div>

		</form>
	</div>
	<div th:include="include::footer"></div>
	<script type="text/javascript">
		var prefix = ctx + "business/templateConfiguration"
		$("#form-templateConfiguration-add").validate({
			rules:{
				xxxx:{
					required:true,
				},
			},
			focusCleanup: true
		});

		function handleChoiceReportType() {
			var checkboxes = document.querySelectorAll('input[name="typeId"]:checked');
			var selectedValues = Array.from(checkboxes).map(checkbox => checkbox.value);
			var selectedLabels = Array.from(checkboxes).map(checkbox => checkbox.nextElementSibling.textContent);
			$("#bizTypesDiv").empty();
			let tempDiv = ""
			checkboxes.forEach(checkbox => {
				if (checkbox.checked) {
					// 选中的checkbox
					// 在这里可以执行相应的操作
					console.log('选中的checkbox值:', checkbox.value);
					console.log('选中的checkbox标签:', checkbox.nextElementSibling.textContent);
					tempDiv += `
						<div class="form-group">
							<label class="col-sm-3 control-label">${checkbox.nextElementSibling.textContent}</label>
							<div class="col-sm-8">
								<div class="col-sm-6">
									<input name="array.${checkbox.value}.entryType" type="checkbox" value="1"> 立即制作
								</div>
								<div class="col-sm-3">
									业务单价
								</div>
								<div class="col-sm-3">
									<input name="array.${checkbox.value}.price" class="form-control">
								</div>
								<div class="col-sm-6">
									<input name="array.${checkbox.value}.entryType" type="checkbox" value="2"> 普通
								</div>
								<div class="col-sm-3">
									业务单价
								</div>
								<div class="col-sm-3">
									<input name="array.${checkbox.value}.price" class="form-control">
								</div>
								<div class="col-sm-6">
									报告翻译 <select name="array.${checkbox.value}.trans">
									<option value="0">翻译成中文</option>
									</select>
								</div>
								<div class="col-sm-3">
									业务单价
								</div>
								<div class="col-sm-3">
									<input name="array.${checkbox.value}.price" class="form-control">
								</div>
							</div>
						</div>
					`
				}
			})
			$("#bizTypesDiv").append(tempDiv)
		}

		function submitHandler() {
			if ($.validate.form()) {
				fetch(prefix + "/add", {
					method: "POST",
					headers: {
						'Content-Type': 'application/json;charset=utf-8'
					},
					body: JSON.stringify($("#form-templateConfiguration-add").serializeArray())
				}).then(response => response.json()).then(data => {
					// 处理响应数据
					console.log(data);
				})
				// $.operate.save(prefix + "/add", $('#form-templateConfiguration-add').serialize());
			}
		}
	</script>
</body>
</html>