实现过程:
.head-tbl
),第二个就是完整的数据表(.data-tbl
)。.head-tbl
表固定在顶部.head-tbl
表默认隐藏z-index
样式,且数值要比.data-tbl
的z-index
样式的数值大, 否则滚动时.head-tbl
表将会被.data-tbl
覆盖.
<style>
.head-tbl {
display: none;
/* 相对于浏览器窗口定位 */
position: fixed;
/* 可能是body元素的padding-top没有置为0, 所以需要微调距离顶部的距离为-10px才能贴住浏览器上方 */
top: -10px;
z-index: 2;
}
</style>
编写<body>
元素的onload
和onresize
事件的处理脚本, 在加载页面/页面大小发生变化时, 调整.head-tbl
表的整体宽度和列宽度
.head-tbl
表后, 它的宽度和列宽都会发生变化(可能是脱离了原文档流). 所以需要触发事件调整其宽度.padding-left
和padding-right
就能得到.head-tbl
可布局的宽度.css()
方法设置width
样式即可.
/* 加载完成/窗口大小变化时, 调整表格的宽度 */
function resizeWidth() {
$ = layui.jquery;
console.log('redizing');
/* 获取body元素的宽度(不包含纵向滚动条), 20是父容器左右内边距之和 */
var width = document.body.clientWidth - 20 + "";
$('table:first-of-type').css('width', width );
// 调整固定表头列宽度
resizeThWidth();
}
.head-tbl
表的列宽, 每列列宽等于.data-tbl
表tbody
中第一行数据的对应列宽..data-tble
表的列宽, 务必要用td
元素的offsetWidth
属性获取, td.style.width
是获取不到的!.head-tble
表的列宽, 无比要给td
元素的width
属性赋值, 给td.style.width
赋值是无效的!td.offsetWidth
的值的是”内容区宽度+左右内边距+边框[不确定]”的和; 而td.width
属性是设置内容区宽度
的值. 所以td2.width = td1.offsetWidth - 左右边距 - 左右边框宽度
.
/* 根据表格中的数据, 调整固定表头的列宽度 */
function resizeThWidth() {
$ = layui.jquery;
// 表头表中的<tr>元素列表
var thHead = $('table:first-of-type > thead > tr');
// 数据表的内容区第一行的<td>列表, 因为本实例中是两层表头, 所以有两个<tr>元素
var thData = $('table:last-of-type > tbody > tr:first-of-type > td');
// 遍历数据表的内容区第一行的<td>列表
for(var i = 0; i < thData.length; i++) {
$(thData[i]).css('padding');
// 前7个td宽度设置给表头表的第一个tr对应的th的宽度
if(i < 7) {
ths = thHead[0].querySelectorAll('th');
// 30为padding-left和padding-right, 1是找平的, 不懂为啥会多处1
ths[i].width = thData[i].offsetWidth - 30 - 1;
} else if(i >=7 && i < 16) { // 生于的td宽度设置给表头表的第二个tr对应的th的宽度
ths = thHead[1].querySelectorAll('th');
// 30为padding-left和padding-right, 1是找平的, 不懂为啥会多处1
ths[i - 7].width = thData[i].offsetWidth - 30 - 1;
}
}
}
scrollTop
大于.data-tbl
表的offsetTop
属性值(即.data-tbl
表相对于窗口顶部的偏移量)时, 把.head-tbl
表的display
样式属性值设置为table
; 否则设置为hidden
.
window.addEventListener("scroll", function(e) {
/* console.log($('table:last-of-type')[0].offsetTop);
console.log($('table:last-of-type')[0].scrollTop);
console.log(document.documentElement.scrollTop);
console.log('---'); */
if(document.documentElement.scrollTop > $('table:last-of-type')[0].offsetTop) {
console.log('show!');
$('.head-tbl').css('display', 'table');
// resizeThWidth();
} else {
console.log('hide!');
$('.head-tbl').css('display', 'none');
}
}, false);
实现思路:
maxlength
属性, 限制文本域能输入的字符数上限.onpast="return false;"
来屏蔽文本框粘贴功能. 避免通过粘贴向文本框中输入非数字字符.style="ime-mode:disabled"
样式来屏蔽中文输入, 但貌似并没有成功屏蔽.
<input type="text" class="layui-input" name="zhipinshuhao" id="zhipinshuhao" placeholder="4位书号" maxlength="4" style="ime-mode:disabled" onpaste="return false;" onkeyup="this.value = check(this.value)" value="{{$book['zhipinshuhao']}}">
keypress
事件的处理脚本, 当发生按键点按事件时, 判断此次点按输入的字符是否是数字, 是则返回此次输入的字符; 否则不返回输入的字符(主要是过滤非中文的非法字符).
<script>
// 判断按键的编码是不是数字,如果不是,则不返回这个按键值(对中文无效)
$('#zhipinshuhao').on('keypress', function() {
// 本次点按的按键是回车
if(event.keyCode == 13) {
layer.msg(event.keyCode);
}
var val = event.target.value.toString();
// 0的ascii码值是48; 9的ascii码值是57
if(event.keyCode < 48 || event.keyCode > 57) {
// 本次点按的按键对应的字符不是数字, 则不反悔输入的字符
event.returnValue = false;
} else {
// 本次点按的按键对应的字符是数字, 返回输入的字符
event.returnValue = true;
}
});
</script>
onkeyup="this.value = check(this.value)"
, 实现在按键抬起时, 再验证一次输入的文本是否有非数字字符(主要是中文字符).
<script>
// 只能输入整数的双保险, 不做这个check,则可以输入中文字符
function check(str) {
var temp=""
for(var i=0;i<str.length;i++)
if(str.charCodeAt(i)>=48&&str.charCodeAt(i)<=57)
temp+=str.charAt(i)
return temp;
}
</script>
1- 滚动固定表头
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>图书校对进度表</title>
<link rel="stylesheet" href="/static/plugin/layui/css/layui.css">
<script src="/static/plugin/layui/layui.js"></script>
<style>
body {
padding: 0 10px 10px 10px;
}
h2 {
margin-bottom: 20px;
}
tr, th {
text-align: end;
}
.head-tbl {
display: none;
position: fixed;
top: -10px;
z-index: 2;
}
.data-tbl{
z-index: 1;
}
.data-tbl td{
padding: 5px;
}
.fun-area {
width: 100%;
display: flex;
flex-flow: row wrap;
justify-content: flex-end;
}
</style>
</head>
<body onload="resizeWidth()" onresize="resizeWidth()">
<div style="text-align: center; color: #666;">
<h2>图书校对进度表</h2>
</div>
<div class="layui-form">
<div class="layui-form-item">
<div class="layui-inline">
<label for="search_words" class="layui-form-label">关键字</label>
<div class="layui-input-inline">
<input type="text" class="layui-input" name="search_words" id="search_words" value="{{$searchwords}}">
</div>
</div>
<div class="layui-inline">
<label for="status_0" class="layui-form-label">校对状态</label>
<div class="layui-input-inline" style="width: 280px">
<input type="radio" name="status" id="status_0" value= "0" title="未完成" {{$status=='0' ? 'checked' : ''}}>
<input type="radio" name="status" id="status_1" value= "1" title="已完成" {{$status=='1' ? 'checked' : ''}}>
<input type="radio" name="status" id="status_2" value= "2" title="全部" {{$status=='2' ? 'checked' : ''}}>
</div>
</div>
<div class="layui-inline">
<div class="layui-input-block">
<button type="button" onclick="doQuery()" class="layui-btn layui-btn-success">搜索</button>
</div>
</div>
</div>
</div>
<div class="fun-area">
<button type="button" onclick="add()" class="layui-btn layui-btn-success">新增</button>
</div>
<table class="layui-table head-tbl">
<thead style="text-align: center;">
<tr>
<th rowspan="2">序号</th>
<th rowspan="2">丛书名</th>
<th rowspan="2">书名</th>
<th rowspan="2">书号</th>
<th rowspan="2">版印次</th>
<th rowspan="2">字数</th>
<th rowspan="2">责任校对</th>
<th colspan="3">一校</th>
<th colspan="3">二校</th>
<th colspan="3">三校</th>
<th rowspan="2">操作</th>
</tr>
<tr>
<th>校对员</th>
<th>开始时间</th>
<th>完成时间</th>
<th>校对员</th>
<th>开始时间</th>
<th>完成时间</th>
<th>校对员</th>
<th>开始时间</th>
<th>完成时间</th>
</tr>
</thead>
</table>
<table class="layui-table data-tbl">
<thead style="text-align: center;">
<tr>
<th rowspan="2">序号</th>
<th rowspan="2">丛书名</th>
<th rowspan="2">书名</th>
<th rowspan="2">书号</th>
<th rowspan="2">版印次</th>
<th rowspan="2">字数</th>
<th rowspan="2">责任校对</th>
<th colspan="3">一校</th>
<th colspan="3">二校</th>
<th colspan="3">三校</th>
<th rowspan="2">操作</th>
</tr>
<tr>
<th>校对员</th>
<th>开始时间</th>
<th>完成时间</th>
<th>校对员</th>
<th>开始时间</th>
<th>完成时间</th>
<th>校对员</th>
<th>开始时间</th>
<th>完成时间</th>
</tr>
</thead>
<tbody>
@if(!empty($books))
@for($index = 0; $index < count($books); $index++)
<tr>
<td>{{$index + 1}}</td>
<td>{{$books[$index]['congshuming']}}</td>
<td>{{$books[$index]['zhipinmingcheng']}}</td>
<td>{{$books[$index]['zhipinshuhao']}}</td>
<td>{{$books[$index]['zhipinbanci'] . '/' . $books[$index]['zhipinyinci']}}</td>
<td>{{$books[$index]['qianzishu']}}</td>
<td>{{$admins[$books[$index]['zerenjiaodui']] ?? ''}}</td>
<td>{{$admins[$books[$index]['yijiaorenyuan']] ?? ''}}</td>
<td>{{$books[$index]['yijiaokaishishijian'] == 0 ? '' : Date('Y-m-d', $books[$index]['yijiaokaishishijian'])}}</td>
<td>{{$books[$index]['yijiaowanchengshijian'] == 0 ? '' : Date('Y-m-d', $books[$index]['yijiaowanchengshijian'])}}</td>
<td>{{$admins[$books[$index]['erjiaorenyuan']] ?? ''}}</td>
<td>{{$books[$index]['erjiaokaishishijian'] == 0 ? '' : Date('Y-m-d', $books[$index]['erjiaokaishishijian'])}}</td>
<td>{{$books[$index]['erjiaowanchengshijian'] == 0 ? '' : Date('Y-m-d', $books[$index]['erjiaowanchengshijian'])}}</td>
<td>{{$admins[$books[$index]['sanjiaorenyuan']] ?? ''}}</td>
<td>{{$books[$index]['sanjiaokaishishijian'] == 0 ? '' : Date('Y-m-d', $books[$index]['sanjiaokaishishijian'])}}</td>
<td>{{$books[$index]['sanjiaowanchengshijian'] == 0 ? '' : Date('Y-m-d', $books[$index]['sanjiaowanchengshijian'])}}</td>
<td>
<button type="button" onclick="edit({{$books[$index]['id']}})" class="layui-btn layui-btn-success layui-btn-xs">修改</button>
<button type="button" onclick="del({{$books[$index]['id']}})" class="layui-btn layui-btn-warm layui-btn-xs">删除</button>
</td>
</tr>
@endfor
@endif
<!-- @for($index = 0; $index < 100; $index++)
<tr>
<td>row1</td>
<td>row2</td>
<td>row3</td>
<td>row4</td>
<td>row5</td>
<td>row6</td>
<td>row7</td>
<td>row8</td>
<td>row9</td>
<td>row10</td>
<td>row11</td>
<td>row12</td>
<td>row13</td>
<td>row14</td>
<td>row15</td>
<td>row16</td>
<td>row17</td>
</tr>
@endfor -->
</tbody>
</table>
</body>
<script>
layui.use(['layer', 'form'], function() {
layer = layui.layer;
form = layui.form;
$ = layui.jquery;
$('input[name="search_words"]').on('keyup', function(e) {
// 按下回车
if(e.keyCode == 13 && $.trim(e.target.value) != '') {
var status = $('input[type="radio"]:checked').val();
window.location.href = '?searchWords=' + $.trim(e.target.value) + '&status=' + status;
}
});
// 调整固定顶部的列宽大小
resizeThWidth();
window.addEventListener("scroll", function(e) {
/* console.log($('table:last-of-type')[0].offsetTop);
console.log($('table:last-of-type')[0].scrollTop);
console.log(document.documentElement.scrollTop);
console.log('---'); */
if(document.documentElement.scrollTop > $('table:last-of-type')[0].offsetTop) {
console.log('show!');
$('.head-tbl').css('display', 'table');
// resizeThWidth();
} else {
console.log('hide!');
$('.head-tbl').css('display', 'none');
}
}, false);
$('td, th').css('text-align', 'center');
});
function edit(id) {
layer.open({
type: 2,
title: '修改图书',
shadeClose: false,
shade: 0.8,
area: ['1048px', '680px'],
content: '/reviser/revision/edit?id=' + id,
btn: ['保存'],
yes: function(index, layero) {
var body = layer.getChildFrame('body', index);
// 得到iframe页的窗口对象
var iframeWin = window[layero.find('iframe')[0]['name']];
// 执行iframe页的方法: iframeWin.要调用的方法名();
iframeWin.save();
}
});
}
function add() {
layer.open({
type: 2,
title: '新增图书',
shadeClose: false,
shade: 0.8,
area: ['1048px', '680px'],
content: '/reviser/revision/add',
btn: ['保存'],
yes: function(index, layero) {
var body = layer.getChildFrame('body', index);
// 得到iframe页的窗口对象
var iframeWin = window[layero.find('iframe')[0]['name']];
// 执行iframe页的方法: iframeWin.要调用的方法名();
iframeWin.save();
}
});
}
function del(id) {
layer.confirm('确定要删除该图书吗?', {icon: 3, title:'提示'}, function(index){
$.get(
'/reviser/revision/del?id=' + id
, function(res) {
if(res.status != undefined && res.status == 0) {
layer.msg(res.message, {icon: 1});
setTimeout(() => {
window.location.reload();
}, 1000);
} else if(res.status != undefined) {
return layer.alert(res.message, {icon: 2});
} else {
return layer.alert('提交保存失败', {icon: 2});
}
}
, 'json'
);
layer.close(index);
});
}
function doQuery() {
var status = $('input[type="radio"]:checked').val();
var searchWords = $.trim($('#search_words').val());
window.location.href = '?searchWords=' + searchWords + '&status=' + status;//+ $.trim(event.target.value + '&status=' + status);
}
/* 根据表格中的数据, 调整固定表头的列宽度 */
function resizeThWidth() {
$ = layui.jquery;
// 表头表中的<tr>元素列表
var thHead = $('table:first-of-type > thead > tr');
// 数据表的内容区第一行的<td>列表, 因为本实例中是两层表头, 所以有两个<tr>元素
var thData = $('table:last-of-type > tbody > tr:first-of-type > td');
// 遍历数据表的内容区第一行的<td>列表
for(var i = 0; i < thData.length; i++) {
$(thData[i]).css('padding');
// 前7个td宽度设置给表头表的第一个tr对应的th的宽度
if(i < 7) {
ths = thHead[0].querySelectorAll('th');
// 30为padding-left和padding-right, 1是找平的, 不懂为啥会多处1
ths[i].width = thData[i].offsetWidth - 30 - 1;
} else if(i >=7 && i < 16) { // 生于的td宽度设置给表头表的第二个tr对应的th的宽度
ths = thHead[1].querySelectorAll('th');
// 30为padding-left和padding-right, 1是找平的, 不懂为啥会多处1
ths[i - 7].width = thData[i].offsetWidth - 30 - 1;
}
}
}
/* 加载完成/窗口大小变化时, 调整表格的宽度 */
function resizeWidth() {
$ = layui.jquery;
console.log('redizing');
var width = document.body.clientWidth - 20 + "";
$('table:first-of-type').css('width', width );
// 调整固定表头列宽度
resizeThWidth();
}
</script>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>新增图书</title>
<link rel="stylesheet" href="/static/plugin/layui/css/layui.css">
<script src="/static/plugin/layui/layui.js"></script>
<style>
body {
padding: 10px;
}
</style>
</head>
<body>
<div class="layui-form">
@csrf
<div class="layui-form-item">
<label for="zhipinmingcheng" class="layui-form-label">图书名称:</label>
<div class="layui-input-block">
<input type="text" class="layui-input" name="zhipinmingcheng" id="zhipinmingcheng">
</div>
</div>
<div class="layui-form-item">
<label for="congshuming" class="layui-form-label">丛书名:</label>
<div class="layui-input-block">
<input type="text" class="layui-input" name="congshuming" id="congshuming">
</div>
</div>
<div class="layui-form-item">
<label for="zhipinshuhao" class="layui-form-label">书号:</label>
<div class="layui-input-inline">
<input type="text" class="layui-input" name="zhipinshuhao" id="zhipinshuhao" placeholder="4位书号" maxlength="4" style="ime-mode:disabled" onpaste="return false;" onkeyup="this.value = check(this.value)">
</div>
</div>
<div class="layui-form-item">
<label for="zhipinbanci" class="layui-form-label">版次:</label>
<div class="layui-input-inline">
<input type="number" class="layui-input" name="zhipinbanci" id="zhipinbanci" value="1" min="1">
</div>
</div>
<div class="layui-form-item">
<label for="zhipinyinci" class="layui-form-label">印次:</label>
<div class="layui-input-inline">
<input type="number" class="layui-input" name="zhipinyinci" id="zhipinyinci" value="1" min="1">
</div>
</div>
<div class="layui-form-item">
<label for="qianzishu" class="layui-form-label">千字数:</label>
<div class="layui-input-inline">
<input type="number" class="layui-input" name="qianzishu" id="qianzishu" min="0">
</div>
</div>
<div class="layui-form-item">
<label for="zerenjiaodui" class="layui-form-label">责任校对:</label>
<div class="layui-input-inline">
<select name="zerenjiaodui" id="zerenjiaodui" class="layui-input">
<option value=""></option>
@if(!empty($admins))
@foreach($admins as $admin)
<option value="{{$admin['id']}}">{{$admin['real_name']}}</option>
@endforeach
@endif
</select>
</div>
</div>
<hr/>
<div class="layui-form-item">
<div class="layui-inline">
<label for="yijiaorenyuan" class="layui-form-label">一校人员</label>
<div class="layui-input-inline">
<select name="yijiaorenyuan" id="yijiaorenyuan" class="layui-input">
<option value=""></option>
@if(!empty($admins))
@foreach($admins as $admin)
<option value="{{$admin['id']}}">{{$admin['real_name']}}</option>
@endforeach
@endif
</select>
</div>
</div>
<div class="layui-inline">
<label for="yijiaokaishishijian" class="layui-form-label" style="width: 100px;">一校开始时间</label>
<div class="layui-input-inline">
<input type="text" class="layui-input" name="yijiaokaishishijian" id="yijiaokaishishijian">
</div>
</div>
<div class="layui-inline">
<label for="yijiaowanchengshijian" class="layui-form-label" style="width: 100px;">一校完成时间</label>
<div class="layui-input-inline">
<input type="text" class="layui-input" name="yijiaowanchengshijian" id="yijiaowanchengshijian">
</div>
</div>
</div>
<div class="layui-form-item">
<div class="layui-inline">
<label for="erjiaorenyuan" class="layui-form-label">二校人员</label>
<div class="layui-input-inline">
<select name="erjiaorenyuan" id="erjiaorenyuan" class="layui-input">
<option value=""></option>
@if(!empty($admins))
@foreach($admins as $admin)
<option value="{{$admin['id']}}">{{$admin['real_name']}}</option>
@endforeach
@endif
</select>
</div>
</div>
<div class="layui-inline">
<label for="erjiaokaishishijian" class="layui-form-label" style="width: 100px;">二校开始时间</label>
<div class="layui-input-inline">
<input type="text" class="layui-input" name="erjiaokaishishijian" id="erjiaokaishishijian">
</div>
</div>
<div class="layui-inline">
<label for="erjiaowanchengshijian" class="layui-form-label" style="width: 100px;">二校完成时间</label>
<div class="layui-input-inline">
<input type="text" class="layui-input" name="erjiaowanchengshijian" id="erjiaowanchengshijian">
</div>
</div>
</div>
<div class="layui-form-item">
<div class="layui-inline">
<label for="sanjiaorenyuan" class="layui-form-label">三校人员</label>
<div class="layui-input-inline">
<select name="sanjiaorenyuan" id="sanjiaorenyuan" class="layui-input">
<option value=""></option>
@if(!empty($admins))
@foreach($admins as $admin)
<option value="{{$admin['id']}}">{{$admin['real_name']}}</option>
@endforeach
@endif
</select>
</div>
</div>
<div class="layui-inline">
<label for="sanjiaokaishishijian" class="layui-form-label" style="width: 100px;">三校开始时间</label>
<div class="layui-input-inline">
<input type="text" class="layui-input" name="sanjiaokaishishijian" id="sanjiaokaishishijian">
</div>
</div>
<div class="layui-inline">
<label for="sanjiaowanchengshijian" class="layui-form-label" style="width: 100px;">三校完成时间</label>
<div class="layui-input-inline">
<input type="text" class="layui-input" name="sanjiaowanchengshijian" id="sanjiaowanchengshijian">
</div>
</div>
</div>
</div>
</body>
<script>
layui.use(['layer', 'form', 'laydate'], function() {
layer = layui.layer;
form = layui.form;
$ = layui.jquery;
var laydate = layui.laydate;
//执行laydate实例
var dateItem = ['#yijiaokaishishijian', '#erjiaokaishishijian', '#sanjiaokaishishijian', '#yijiaowanchengshijian', '#erjiaowanchengshijian', '#sanjiaowanchengshijian'];
dateItem.forEach(function(item, index) {
laydate.render({
elem: item //指定元素
});
});
// 判断按键的编码是不是数字,如果不是,则不返回这个按键值(对中文无效)
$('#zhipinshuhao').on('keypress', function() {
if(event.keyCode == 13) {
layer.msg(event.keyCode);
}
var val = event.target.value.toString();
if(event.keyCode < 48 || event.keyCode > 57) {
event.returnValue = false;
} else {
event.returnValue = true;
}
});
});
// 只能输入整数的双保险, 不做这个check,则可以输入中文字符
function check(str) {
var temp=""
for(var i=0;i<str.length;i++)
if(str.charCodeAt(i)>=48&&str.charCodeAt(i)<=57)
temp+=str.charAt(i)
return temp;
}
function save() {
var data = {};
// token
data._token = $('input[name="_token"]').val();
// 制品名称
data.zhipinmingcheng = $.trim($('#zhipinmingcheng').val());
// 丛书名
data.congshuming = $.trim($('#congshuming').val());
// 书号
data.zhipinshuhao = $.trim($('#zhipinshuhao').val());
// 版次
data.zhipinbanci = $.trim($('#zhipinbanci').val());
// 印次
data.zhipinyinci = $.trim($('#zhipinyinci').val());
// 千字数
data.qianzishu = $.trim($('#qianzishu').val());
// 责任校对
data.zerenjiaodui = $.trim($('#zerenjiaodui').val());
// 一校人员
data.yijiaorenyuan = $.trim($('#yijiaorenyuan').val());
// 一校开始时间
data.yijiaokaishishijian = $.trim($('#yijiaokaishishijian').val());
// 一校完成时间
data.yijiaowanchengshijian = $.trim($('#yijiaowanchengshijian').val());
// 二校人员
data.erjiaorenyuan = $.trim($('#erjiaorenyuan').val());
// 二校开始时间
data.erjiaokaishishijian = $.trim($('#erjiaokaishishijian').val());
// 二校完成时间
data.erjiaowanchengshijian = $.trim($('#erjiaowanchengshijian').val());
// 三校人员
data.sanjiaorenyuan = $.trim($('#sanjiaorenyuan').val());
// 三校开始时间
data.sanjiaokaishishijian = $.trim($('#sanjiaokaishishijian').val());
// 三校完成时间
data.sanjiaowanchengshijian = $.trim($('#sanjiaowanchengshijian').val());
var checkRes = dataCheck(data);
if(checkRes.status > 0) {
return layer.alert(checkRes.message);
}
$.post(
'/reviser/revision/save'
, data
, function(res) {
if(res.status != undefined && res.status == 0) {
layer.msg(res.message, {icon: 1});
setTimeout(() => {
parent.window.location.reload();
}, 1000);
} else if(res.status != undefined) {
return layer.alert(res.message, {icon: 2});
} else {
return layer.alert('提交保存失败', {icon: 2});
}
}
, 'json'
);
}
function dataCheck(data) {
var res = {
status: 1
};
if(data.zhipinmingcheng == undefined || data.zhipinmingcheng == '') {
res.message = '图书名称不能为空';
return res;
}
if(data.zhipinshuhao == undefined || data.zhipinshuhao == '') {
res.message = '书号不能为空';
return res;
}
if(data.zhipinbanci == undefined || data.zhipinbanci == '') {
res.message = '版次不能为空';
return res;
}
if(data.zhipinbanci <= 0) {
res.message = '版次不能小于1';
return res;
}
if(data.zhipinyinci == undefined || data.zhipinyinci == '') {
res.message = '印次不能为空';
return res;
}
if(data.zhipinyinci <= 0) {
res.message = '印次不能小于1';
return res;
}
if(data.qianzishu == undefined || data.qianzishu == '') {
res.message = '千字数不能为空';
return res;
}
if(data.qianzishu <= 0) {
res.message = '千字数必须大于0';
return res;
}
if(data.zerenjiaodui == undefined || data.zerenjiaodui == '') {
res.message = '责任校对不能为空';
return res;
}
res.status = 0;
return res;
}
</script>
</html>