202 lines
7.9 KiB
HTML
202 lines
7.9 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
|
|
|
|
<style>
|
|
.downloadTemplate{
|
|
display: inline-block;
|
|
padding: 4px 14px;
|
|
height: 18px;
|
|
line-height: 18px;
|
|
font-size: 12px;
|
|
border: 1px solid #DBE2E6;
|
|
border-radius: 3px;
|
|
cursor: pointer;
|
|
}
|
|
</style>
|
|
<form id="addForm" action="product/save.html" th:returnUrl="|product/list.html?type=${type}|" method="post" style="height: 100%;">
|
|
<div class="appPage addPage" style="height: 100%;">
|
|
<div class="head">
|
|
<h1 class="page-title">设备专业导入</h1>
|
|
<!-- <div class="btnGroup">-->
|
|
<!-- <a class="btn" th:href="|javascript:Nav.return('product/list.html?type=${type}')|">返回</a>-->
|
|
<!-- <a class="form-setting" href="javascript:Dialog.functionDialog(null, null, '/admin/common/formSetting.html?name=product');">表单设置</a>-->
|
|
<!-- </div>-->
|
|
</div>
|
|
<div class="submitBody" data-id="addDevice" style="position:absolute;top: 40px;">
|
|
<style>
|
|
.input-wrapper {
|
|
float: left;
|
|
/*margin-right: 10%;*/
|
|
}
|
|
</style>
|
|
<div class="submitBody-row">
|
|
<!-- <div class="submitBody-row-position" style="margin-left: 400px;">-->
|
|
<div class="submitBody-row-position" >
|
|
<div class="input-wrapper">
|
|
<label>导入文件</label>
|
|
<input id="excel_file" type="file" name="excel_file" accept="xlsx" size="80"
|
|
class="searchBarBtn iBtn"/>
|
|
<input hidden id="adminId" th:value="${adminId}"/>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="submitBody-row">
|
|
<div class="submitBody-row-position">
|
|
<div class="input-wrapper" style="width: 400px;">
|
|
<label>前缀</label>
|
|
<input class="text" type="text" id="preTitle" name="preTitle" >
|
|
</div>
|
|
<div class="input-wrapper" style="width: 400px;">
|
|
<label>流水号长度</label>
|
|
<input class="text" type="number" id="flowNum" name="flowNum">
|
|
</div>
|
|
<!-- <div class="input-wrapper required" style="width: 400px">-->
|
|
<!-- <label>阶段</label>-->
|
|
<!-- <select id="stage" name="stage" data-not-select="">-->
|
|
<!-- <option th:each="item : ${stageList}" th:value="${item.id}" th:text="${item.name}"></option>-->
|
|
<!-- </select>-->
|
|
<!-- </div>-->
|
|
</div>
|
|
</div>
|
|
<div class="submitBody-row">
|
|
<div class="submitBody-row-position">
|
|
|
|
<div class="input-wrapper required" style="width: 400px">
|
|
<label>阶段</label>
|
|
<select id="stage" name="stage" data-not-select="">
|
|
<option th:each="item : ${stageList}" th:value="${item.id}" th:text="${item.name}"></option>
|
|
</select>
|
|
</div>
|
|
<div class="input-wrapper" style="width: 400px;">
|
|
<label>料单名称</label>
|
|
<input class="text" type="text" id="name" name="name">
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="submitBody-row">
|
|
<div class="submitBody-row-position">
|
|
<!-- <div class="input-wrapper" style="margin-left: 400px">-->
|
|
<div class="input-wrapper" >
|
|
<label>综合材料明细表编号</label>
|
|
<input class="text" readonly style="width: 500px;" type="text" id="showCode" >
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="formBtns formBtnsExtra">
|
|
<!-- <a th:href="|javascript:Nav.return('product/list.html?type=${type}')|" class="btn">取消</a>-->
|
|
<a class="btn" onclick="downloadTemplate()">下载模板</a>
|
|
<input type="submit" class="btn submit" value="保存"/>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</form>
|
|
|
|
<script>
|
|
$(".submitBody").formSetting();
|
|
|
|
var flag = true;
|
|
|
|
var $addForm = $("#addForm");
|
|
$addForm.validate({
|
|
rules: {},
|
|
messages: {},
|
|
submitHandler: function (form) {
|
|
Dialog.waiting();
|
|
if (!check()) {
|
|
Dialog.error("请选择Excel文件");
|
|
} else {
|
|
if (flag){
|
|
flag = false;
|
|
var File = $("#excel_file")[0].files;
|
|
var fromData = new FormData();
|
|
fromData.append("file", File[0]);
|
|
fromData.append("adminId", $("#adminId").val());
|
|
fromData.append("preTitle", $("#preTitle").val());
|
|
fromData.append("flowNum", $("#flowNum").val());
|
|
// fromData.append("code", $("#code").val());
|
|
fromData.append("stage", $("#stage").val());
|
|
fromData.append("name", $("#name").val());
|
|
$.ajax({
|
|
type: "POST",
|
|
cache: false,
|
|
processData: false,
|
|
contentType: false,
|
|
url: 'materialOrder/uploadDeviceExcel',
|
|
dataType: 'json',
|
|
data: fromData,
|
|
success: function (res) {
|
|
if (res.errorCode === "0") {
|
|
Dialog.success('导入成功');
|
|
Nav.refresh();
|
|
flag = true;
|
|
} else {
|
|
flag = true;
|
|
Dialog.error(res.errorInfo);
|
|
}
|
|
},
|
|
error: function () {
|
|
flag = true;
|
|
console.log('ajax error');
|
|
}
|
|
});
|
|
}else {
|
|
Dialog.error("正在上传");
|
|
}
|
|
|
|
}
|
|
}
|
|
});
|
|
|
|
function check() {
|
|
var excel_file = $("#excel_file").val();
|
|
if (excel_file === "" || excel_file.length === 0) {
|
|
//alert("请选择文件路径!");
|
|
return false;
|
|
} else return /.(xls|xlsx)$/.test(excel_file);
|
|
}
|
|
|
|
function downloadTemplate() {
|
|
window.open("../../../resources/template/综合材料明细模板.xlsx")
|
|
}
|
|
$("#preTitle").on("change",function () {
|
|
showCode()
|
|
})
|
|
$("#flowNum").on("change",function () {
|
|
showCode()
|
|
})
|
|
$("#stage").on("change",function () {
|
|
showCode()
|
|
})
|
|
|
|
function showCode() {
|
|
var preTitle =$("#preTitle").val();
|
|
var flowNum =$("#flowNum").val();
|
|
var stage =$("#stage").val();
|
|
if (preTitle == null || flowNum == null || stage == null || preTitle == "" || flowNum == "" || stage == ""){
|
|
return;
|
|
}
|
|
$.ajax({
|
|
type: "POST",
|
|
url: 'materialOrder/getCode',
|
|
dataType: 'json',
|
|
data: {
|
|
preTitle:preTitle,
|
|
flowNum:flowNum,
|
|
stage:stage,
|
|
},
|
|
success: function (res) {
|
|
if (res.errorCode === "0") {
|
|
$("#showCode").val(res.data);
|
|
} else {
|
|
Dialog.error(res.errorInfo);
|
|
}
|
|
},
|
|
error: function () {
|
|
console.log('ajax error');
|
|
}
|
|
});
|
|
}
|
|
</script>
|
|
</html>
|