|
@@ -20,46 +20,30 @@
|
|
|
height: 28px;
|
|
|
margin-top: 6px;
|
|
|
}
|
|
|
- /*.layui-input{*/
|
|
|
- /*height: 28px;*/
|
|
|
- /*margin-top: 5px;*/
|
|
|
- /*width: 260px;*/
|
|
|
- /*}*/
|
|
|
- .input-meself-time{
|
|
|
- font-size: 13px;
|
|
|
- width: 140px;
|
|
|
- }
|
|
|
- .btn_out{
|
|
|
- width: 100px;
|
|
|
- margin: 0;
|
|
|
- float: right;
|
|
|
- margin-right:2%;
|
|
|
- }
|
|
|
- .div_main_form{
|
|
|
- width: 50%;
|
|
|
- margin-left: 10px;
|
|
|
- }
|
|
|
- .layui-icon-layer{
|
|
|
- display: none;
|
|
|
- }
|
|
|
- .layui-icon-file{
|
|
|
- display: none;
|
|
|
- }
|
|
|
.layui-table-view .layui-table {width:100%}
|
|
|
.myselect{
|
|
|
border: none;
|
|
|
padding: 5px 7px;
|
|
|
min-height: 20px;
|
|
|
+ color: #666666;
|
|
|
}
|
|
|
.mydiv1{
|
|
|
padding: 5px 7px;
|
|
|
min-height: 20px;
|
|
|
+ border: whitesmoke;
|
|
|
+ }
|
|
|
+ .layui-btn-mysele{
|
|
|
+ width: 70px;
|
|
|
}
|
|
|
+ .mydiv1:empty:before{
|
|
|
+ content: attr(placeholder); /* element attribute*/
|
|
|
+ /*content: 'this is content';*/
|
|
|
+ color:#999999;
|
|
|
+ }
|
|
|
+ .mydiv1:focus:before{content:none}
|
|
|
</style>
|
|
|
</head>
|
|
|
<body>
|
|
|
-
|
|
|
-
|
|
|
<div style="padding: 10px; background-color: #F2F2F2;">
|
|
|
<div class="layui-main-bgc">
|
|
|
<%--<sys:message content="${message}"/>--%>
|
|
@@ -69,26 +53,22 @@
|
|
|
<div class="layui-card-header layui-card-header-add">工程管理</div>
|
|
|
<div class="layui-card-body" style="margin-top: 2px;">
|
|
|
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
|
|
|
- <legend style="font-size: 15px;">选择工程</legend>
|
|
|
+ <legend style="font-size: 15px;">添加工程</legend>
|
|
|
</fieldset>
|
|
|
<div class="layui-form-item">
|
|
|
<div class="layui-inline">
|
|
|
<label class="layui-form-label" >*工程名称</label>
|
|
|
<div class="layui-input-inline">
|
|
|
- <input type="text" id="myinput" class="layui-input">
|
|
|
+ <input type="text" id="myinput" autocomplete="off" placeholder="请输入工程名称" class="layui-input">
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
|
|
|
- <legend style="font-size: 15px;">选择项目</legend>
|
|
|
+ <legend style="font-size: 15px;">添加项目</legend>
|
|
|
</fieldset>
|
|
|
<div class="layui-upload">
|
|
|
<button type="button" class="layui-btn layui-btn-normal" id="testList">添加文件</button>
|
|
|
<div class="layui-upload-list">
|
|
|
- <%--<form id="myform" action="${ctx}/project/tem/import" method="post" enctype="multipart/form-data">--%>
|
|
|
- <%--<input type="text" name="projectName" value="" style="display: none" id="id1">--%>
|
|
|
- <%--<input type="text" name="itemNames" value="" style="display: none" id="id2">--%>
|
|
|
- <%--<input type="text" name="itemTypes" value="" style="display: none" id="id3">--%>
|
|
|
<table class="layui-table" id="mytable">
|
|
|
<thead>
|
|
|
<tr>
|
|
@@ -101,9 +81,8 @@
|
|
|
|
|
|
</tbody>
|
|
|
</table>
|
|
|
- <button type="button" class="layui-btn" onclick="okSubmit()">确定</button>
|
|
|
- <%--</form>--%>
|
|
|
</div>
|
|
|
+ <button type="button" class="layui-btn layui-btn-mysele" onclick="okSubmit()">确定</button>
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
@@ -111,22 +90,6 @@
|
|
|
</div>
|
|
|
|
|
|
</body>
|
|
|
-<%--<script>--%>
|
|
|
- <%--function add() {--%>
|
|
|
- <%--var tr = $(['<tr>'--%>
|
|
|
- <%--,'<td><input type="file" name="file"></td>'--%>
|
|
|
- <%--,'<td><div contenteditable="true" class="mydiv1">请输入项目名称</div></td>'--%>
|
|
|
- <%--,'<td>'--%>
|
|
|
- <%--,' <select name="type" class="myselect"><option value="">请选择项目类型(必选)</option><option value="1">架空线路工程</option><option value="2">电缆工程</option></select>'--%>
|
|
|
- <%--,'</td>'--%>
|
|
|
- <%--,'<td>'--%>
|
|
|
- <%--,'<button class="layui-btn layui-btn-xs layui-btn-danger demo-delete">删除</button>'--%>
|
|
|
- <%--,'</td>'--%>
|
|
|
- <%--,'</tr>'].join(''));--%>
|
|
|
- <%--$("#demoList").append(tr);--%>
|
|
|
- <%--}--%>
|
|
|
-<%--</script>--%>
|
|
|
-
|
|
|
<script>
|
|
|
var formdata = new FormData();
|
|
|
layui.use('upload', function(){
|
|
@@ -138,21 +101,22 @@
|
|
|
elem: '#testList'
|
|
|
// ,url: '/upload/'
|
|
|
,accept: 'file'
|
|
|
+ ,exts:'xls|xlsx'
|
|
|
,multiple: true
|
|
|
,auto: false
|
|
|
// ,bindAction: '#testListAction'
|
|
|
,choose: function(obj){
|
|
|
var files = this.files = obj.pushFile(); //将每次选择的文件追加到文件队列
|
|
|
+
|
|
|
//读取本地文件
|
|
|
obj.preview(function(index, file, result){
|
|
|
formdata.append("file",file);
|
|
|
var tr = $(['<tr id="upload-'+ index +'">'
|
|
|
,'<td>'+ file.name +'</td>'
|
|
|
- ,'<td><div contenteditable="true" class="mydiv1">请输入项目名称</div></td>'
|
|
|
+ ,'<td><div contenteditable="true" class="mydiv1" placeholder="请输入项目名称"></div></td>'
|
|
|
,'<td>'
|
|
|
- ,' <select name="type" class="myselect"><option value="">请选择项目类型(必选)</option><option value="1">架空线路工程</option><option value="2">电缆工程</option></select>'
|
|
|
+ ,' <select name="type" class="myselect"><option value="">请选择项目类型</option><option value="1">架空线路工程</option><option value="2">电缆工程</option></select>'
|
|
|
,'<td>'
|
|
|
- // ,'<button class="layui-btn layui-btn-xs demo-reload layui-hide">重传</button>'
|
|
|
,'<button class="layui-btn layui-btn-xs layui-btn-danger demo-delete">删除</button>'
|
|
|
,'</td>'
|
|
|
,'</tr>'].join(''));
|
|
@@ -166,33 +130,20 @@
|
|
|
tr.find('.demo-delete').on('click', function(){
|
|
|
delete files[index]; //删除对应的文件
|
|
|
tr.remove();
|
|
|
- uploadListIns.config.elem.next()[0].value = ''; //清空 input file 值,以免删除后出现同名文件不可选
|
|
|
+ uploadListIns.config.elem.next()[0].value = '';
|
|
|
});
|
|
|
|
|
|
demoListView.append(tr);
|
|
|
});
|
|
|
}
|
|
|
- ,done: function(res, index, upload){
|
|
|
- if(res.code == 0){ //上传成功
|
|
|
- var tr = demoListView.find('tr#upload-'+ index)
|
|
|
- ,tds = tr.children();
|
|
|
- tds.eq(2).html('<span style="color: #5FB878;">上传成功</span>');
|
|
|
- tds.eq(3).html(''); //清空操作
|
|
|
- return delete this.files[index]; //删除文件队列已经上传成功的文件
|
|
|
- }
|
|
|
- this.error(index, upload);
|
|
|
- }
|
|
|
- ,error: function(index, upload){
|
|
|
- var tr = demoListView.find('tr#upload-'+ index)
|
|
|
- ,tds = tr.children();
|
|
|
- tds.eq(2).html('<span style="color: #FF5722;">上传失败</span>');
|
|
|
- tds.eq(3).find('.demo-reload').removeClass('layui-hide'); //显示重传
|
|
|
- }
|
|
|
});
|
|
|
});
|
|
|
function okSubmit() {
|
|
|
var inputval = $("#myinput").val();
|
|
|
- // $("#id1").val(inputval);
|
|
|
+ if(inputval==null||inputval==""){
|
|
|
+ layer.msg("请输入工程名称");
|
|
|
+ return false;
|
|
|
+ }
|
|
|
formdata.append("projectName",inputval);
|
|
|
|
|
|
var div1 = document.getElementsByClassName("mydiv1");
|
|
@@ -200,16 +151,33 @@
|
|
|
for (var i = 0; i < div1.length; i++) {
|
|
|
divvalue[i]=div1[i].innerHTML;
|
|
|
}
|
|
|
+ if (divvalue.length<=0){
|
|
|
+ layer.msg("请输入项目名称");
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ for (var i = 0; i < divvalue.length; i++) {
|
|
|
+ if (divvalue[i]=="请输入项目名称"){
|
|
|
+ layer.msg("请输入项目名称");
|
|
|
+ throw SyntaxError;
|
|
|
+ }
|
|
|
+ }
|
|
|
formdata.append("itemNames",divvalue);
|
|
|
- // $("#id2").val(divvalue);
|
|
|
|
|
|
var select1=document.getElementsByClassName("myselect");
|
|
|
var selectval=[];
|
|
|
for (var i = 0; i < select1.length; i++) {
|
|
|
selectval[i]=select1[i].value;
|
|
|
}
|
|
|
- // var selectJson = JSON.stringify(selectval);
|
|
|
- // $("#id3").val(selectval);
|
|
|
+ if (selectval.length<=0){
|
|
|
+ layer.msg("请输入项目名称");
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ for (var i = 0; i < selectval.length; i++) {
|
|
|
+ if (selectval[i]==""||selectval[i]==null){
|
|
|
+ layer.msg("请选择项目类型");
|
|
|
+ throw SyntaxError;
|
|
|
+ }
|
|
|
+ }
|
|
|
formdata.append("itemTypes",selectval);
|
|
|
|
|
|
$.ajax({
|
|
@@ -220,12 +188,12 @@
|
|
|
cache: false, // 不缓存数据
|
|
|
processData: false, // 不处理数据
|
|
|
contentType: false, // 不设置内容类型
|
|
|
- success:function (data) {
|
|
|
+ success:function (data) {
|
|
|
if(data.code == 1){
|
|
|
layer.msg(data.msg);
|
|
|
window.location.href="${ctx}/project/tem/list?projectId="+data.id;
|
|
|
}else {
|
|
|
- lay.msg(data.msg);
|
|
|
+ layer.msg(data.msg);
|
|
|
}
|
|
|
}
|
|
|
});
|