containerSelection.html 3.93 KB
<!DOCTYPE HTML>
<html  lang="zh" xmlns:th="http://www.thymeleaf.org">
<meta charset="utf-8">
<head th:include="include :: header"></head>

<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
		<input id="ids" name="ids" type="hidden" th:value="${ids}" >
        <form class="form-horizontal m" id="form-taskDetail-add" th:object="${container}">
<!--			<input id="companyName" name="companyName" th:field="*{companyName}"  type="hidden">-->
			<input id="code" name="code" th:field="*{code}"  type="hidden">

			<div class="form-group">
				<label class="col-sm-3 control-label">账套:</label>
				<div class="col-sm-8">
					<input id="companyCode" name="companyCode" class="form-control"  th:field="*{companyCode}" readonly="true">
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">仓库:</label>
				<div class="col-sm-8">
					<input id="warehouseCode" name="warehouseCode" class="form-control"  th:field="*{warehouseCode}" readonly="true">
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">容器:</label>
				<div class="col-sm-8">
					<select name="containerCode" id="containerCode"  class="form-control" >
						<option th:each="e : ${container}" th:text="${e['code']}" th:value="${e['code']}"></option>
					</select>
				</div>
			</div>
			<div class="form-group">
				<div class="form-control-static col-sm-offset-9">
					<button type="submit" class="btn btn-primary">提交</button>
					<button onclick="$.modal.close()" class="btn btn-danger" type="button">关闭</button>
				</div>
			</div>
		</form>
	</div>
	<th:block th:include="include :: footer" />
    <script type="text/javascript">
		var prefix = ctx + "task/lkMenuTask"
		$("#form-taskDetail-add").validate({
			rules:{
				qualifiedQty:{
					required:true,
					min:0
				},
				unqualifiedQty:{
					required:true,
					min:0
				},
			},
			submitHandler: function(form) {
				$.modal.confirm("确认要更换容器吗?", function() {
					var containerCode = $("select[id='containerCode']").val();
					if(!containerCode){
						$.modal.alertError("请选择要更换的容器!");
					}
					$.ajax({
						cache: true,
						type: "POST",
						url: prefix + "/submitComplete",
						data: {
							"ids": $("input[name='ids']").val(),
							"code":containerCode
						},
						async : false,
						error : function(request) {
							$.modal.alertError("请求失败!");
						},
						success : function(data) {
							// $.operate.saveSuccess(data);
							ajaxSuccess(data);
						}
					});
				})

			}
		});
		function ajaxSuccess(result) {
			if (result.code == web_status.SUCCESS) {
				// $.modal.msgSuccess(result.msg);
				var index = parent.layer.getFrameIndex(window.name);
				parent.layer.close(index);
				window.parent.$.table.search();
				$(parent.$("#reload")).click();
			} else {
				$.modal.alertError(result.msg);
			}
			// $.modal.msgSuccess(result.msg);
			$.modal.closeLoading();
			window.parent.reload($("select[id='containerCode']").val(),result.msg)
		}

		var headerId=$("input[name='headerId']").val();

		$(function () {
			layui.use('laydate', function() {
				var laydate = layui.laydate;
				laydate.render({ elem: '#manufactureDate', theme: 'molv', format: 'yyyy-MM-dd HH:mm:ss' });
				laydate.render({ elem: '#expirationDate', theme: 'molv', format: 'yyyy-MM-dd HH:mm:ss' });
			});
		});


		$(function () {
			let code=$("input[name='code']").val();
			$.ajax({
				url: ctx + "task/lkMenuTask/getContainerList",
				type:'post',
				data:{'code':code},
				success:function (response) {
					if(response.code===200){
						$("select[name='containerCode']").children().remove();
						for (let item of response.data) {
							let option=`<option value="${item.code}">${item.code} </option>`;
							$("select[name='containerCode']").append(option);
						}
					}
					else {$.modal.msgError(response.msg)}
				}
			})
		})
	</script>
</body>
</html>