<!DOCTYPE html>
|
<html lang="en">
|
<head>
|
<meta charset="utf-8">
|
<title></title>
|
<meta name="renderer" content="webkit">
|
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
|
<link rel="stylesheet" href="../../static/layui/css/layui.css" media="all">
|
<link rel="stylesheet" href="../../static/css/admin.css?v=318" media="all">
|
<!-- <link rel="stylesheet" href="../../static/css/cool.css" media="all">-->
|
<!-- <link rel="stylesheet" href="../../static/css/common.css" media="all">-->
|
<!--[if lt IE 9]>
|
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
|
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
|
<![endif]-->
|
</head>
|
<body>
|
|
<!-- 正文开始 -->
|
<div class="layui-fluid">
|
<div class="layui-card">
|
<div class="layui-card-body">
|
<!-- 表格顶部工具栏 -->
|
<div class="layui-form toolbar">
|
<div class="layui-form-item">
|
<div class="layui-inline">
|
<label class="layui-form-label w-auto">单据编号:</label>
|
<div class="layui-input-inline mr0">
|
<input name="experimentTypeName" class="layui-input" type="text" placeholder="输入单据编号"/>
|
</div>
|
</div>
|
<div class="layui-inline">
|
<button class="layui-btn icon-btn" lay-filter="eCourseTbSearch" lay-submit>
|
<i class="layui-icon"></i>搜索
|
</button>
|
<button id="eCourseAddBtn" class="layui-btn icon-btn"><i class="layui-icon"></i>添加
|
</button>
|
</div>
|
</div>
|
</div>
|
<table id="waitMatin" lay-filter="waitMatin"></table>
|
</div>
|
</div>
|
</div>
|
<!-- 表格操作列 -->
|
<script type="text/html" id="operate">
|
<a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="edit">修改</a>
|
<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
|
</script>
|
<!-- 表格操作列 -->
|
<script type="text/html" id="tbLook">
|
<span class="layui-text">
|
<a href="javascript:;" lay-event="look">
|
<i class="layui-icon" style="font-size: 12px;"></i> 查看单据明细
|
</a>
|
</span>
|
</script>
|
<!-- 表单弹窗 -->
|
<script type="text/html" id="editDialog">
|
<form id="editForm" lay-filter="editForm" class="layui-form model-form">
|
<input name="experimentTypeId" type="hidden"/>
|
<div class="layui-form-item">
|
<label class="layui-form-label">单据编号:</label>
|
<div class="layui-input-block">
|
<input name="experimentTypeName" placeholder="输入单据编号" type="text" class="layui-input" maxlength="20" lay-verType="tips" lay-verify="required"/>
|
</div>
|
</div>
|
<div class="layui-form-item" style="position: relative;">
|
<label class="layui-form-label">单据明细:</label>
|
<div class="layui-input-block">
|
<table id="formSSXMTable" lay-filter="formSSXMTable"></table>
|
</div>
|
<button class="layui-btn layui-btn-sm icon-btn" id="demoEDeCourseAddBtnComment"
|
style="position: absolute; left: 20px;top: 60px;padding: 0 5px;" type="button">
|
<i class="layui-icon"></i>添加明细
|
</button>
|
</div>
|
<div class="layui-form-item text-right">
|
<button class="layui-btn layui-btn-primary" type="button" ew-event="closeDialog">取消</button>
|
<button class="layui-btn" lay-filter="eCourseEditSubmit" lay-submit>保存</button>
|
</div>
|
</form>
|
</script>
|
<!-- 表单弹窗 -->
|
<script type="text/html" id="eCourseCouEditDialog">
|
<form id="eCourseCouEditForm" lay-filter="eCourseCouEditForm" class="layui-form model-form">
|
<input name="experimentId" type="hidden"/>
|
<!-- <div class="layui-form-item">-->
|
<!-- <label class="layui-form-label">物料编码:</label>-->
|
<!-- <div class="layui-input-block">-->
|
<!-- <input name="experimentName" placeholder="请输入物料编码" type="text" class="layui-input" maxlength="20" lay-verType="tips" lay-verify="required"/>-->
|
<!-- </div>-->
|
<!-- </div>-->
|
<div class="layui-form-item">
|
<label class="layui-form-label">物料 - 多选</label>
|
<div class="layui-input-block">
|
<div id="mat" name="mat">
|
</div>
|
</div>
|
</div>
|
<div class="layui-form-item text-right">
|
<button class="layui-btn layui-btn-primary" type="button" ew-event="closeDialog">取消</button>
|
<button class="layui-btn" lay-filter="eCourseCouEditSubmit" lay-submit>保存</button>
|
</div>
|
</form>
|
</script>
|
|
<script type="text/javascript" src="../../static/js/jquery/jquery-3.3.1.min.js"></script>
|
<script type="text/javascript" src="../../static/layui/layui.js" charset="utf-8"></script>
|
<script type="text/javascript" src="../../static/js/common.js" charset="utf-8"></script>
|
<script type="text/javascript" src="../../static/js/cool.js" charset="utf-8"></script>
|
<!--<script type="text/javascript" src="../../static/js/waitMatin/waitMatin.js" charset="utf-8"></script>-->
|
<script>
|
var pageCurr;
|
layui.config({
|
base: baseUrl + "/static/layui/lay/modules/"
|
}).use(['layer', 'form', 'table', 'util', 'admin', 'xmSelect'], function () {
|
var $ = layui.jquery;
|
var layer = layui.layer;
|
var form = layui.form;
|
var table = layui.table;
|
var util = layui.util;
|
var admin = layui.admin;
|
var xmSelect = layui.xmSelect;
|
|
// 渲染表格
|
var insTb = table.render({
|
elem: '#waitMatin',
|
url: baseUrl+'/waitMatin/head/page/auth',
|
headers: {token: localStorage.getItem('token')},
|
page: true,
|
cellMinWidth: 100,
|
cols: [[
|
{type: 'numbers'},
|
{field: 'billNo', title: '单据编号', sort: true},
|
{field: 'billType$', align: 'center', title: '类型', minWidth: 140, width: 140},
|
// {align: 'center', title: '星期', templet: '#eCourseTbWeek', minWidth: 350, width: 350},
|
{align: 'center', title: '明细', toolbar: '#tbLook', minWidth: 140, width: 140},
|
{
|
field: 'appeTime$', title: '创建时间', sort: true, templet: function (d) {
|
return util.toDateString(d.createTime);
|
}, width: 180
|
},
|
{align: 'center', title: '操作', toolbar: '#operate', minWidth: 130, width: 130}
|
]],
|
request: {
|
pageName: 'curr',
|
pageSize: 'limit'
|
},
|
parseData: function (res) {
|
return {
|
'code': res.code,
|
'msg': res.msg,
|
'count': res.data.total,
|
'data': res.data.records
|
}
|
},
|
response: {
|
statusCode: 200
|
},
|
done: function (res) {
|
if (res.code === 403) {
|
top.location.href = baseUrl+"/";
|
}
|
pageCurr=curr;
|
}
|
});
|
|
// 搜索
|
form.on('submit(eCourseTbSearch)', function (data) {
|
insTb.reload({where: data.field, page: {curr: 1}});
|
});
|
|
// 添加
|
$("#eCourseAddBtn").click(function () {
|
showEditModel();
|
});
|
|
// 工具条点击事件
|
table.on('tool(waitMatin)', function (obj) {
|
var data = obj.data;
|
var layEvent = obj.event;
|
if (layEvent === 'edit') {
|
showEditModel(data);
|
} else if (layEvent === 'del') {
|
doDel(data.experimentTypeId);
|
} else if (layEvent === 'look') {
|
var $a = $(obj.tr).find('a[lay-event="look"]');
|
var offset = $a.offset();
|
var top = offset.top;
|
var left = offset.left;
|
layer.open({
|
type: 1,
|
title: false,
|
area: '630px',
|
offset: [top + 'px', (left - 530 + $a.outerWidth()) + 'px'],
|
shade: .01,
|
shadeClose: true,
|
fixed: false,
|
content: '<table id="lookSSXMTable" lay-filter="lookSSXMTable"></table>',
|
success: function (layero) {
|
table.render({
|
elem: '#lookSSXMTable',
|
headers: {token: localStorage.getItem('token')},
|
url: baseUrl+'/waitMatin/list/auth',
|
where: {
|
bill_no: data.billNo
|
},
|
page: true,
|
cellMinWidth: 100,
|
cols: [[
|
{type: 'numbers'},
|
{field: 'matNo', title: '物料编码'},
|
{field: 'matName', title: '物料名称', width: 160},
|
{field: 'qty', title: '数量'},
|
{
|
field: 'createTime$', title: '创建时间', sort: true, templet: function (d) {
|
return util.toDateString(d.createTime);
|
}, width: 180
|
}
|
]],
|
request: {
|
pageName: 'curr',
|
pageSize: 'limit'
|
},
|
parseData: function (res) {
|
return {
|
'code': res.code,
|
'msg': res.msg,
|
'count': res.data.total,
|
'data': res.data.records
|
}
|
},
|
response: {
|
statusCode: 200
|
},
|
done: function () {
|
$(layero).find('.layui-table-view').css('margin', '0');
|
},
|
size: ''
|
});
|
}
|
});
|
}
|
});
|
|
// 显示表单弹窗
|
function showEditModel(expTpe) {
|
admin.open({
|
type: 1,
|
title: (expTpe ? '修改' : '添加') + '单据',
|
content: $('#editDialog').html(),
|
area: '700px',
|
success: function (layero, dIndex) {
|
$(layero).children('.layui-layer-content').css('overflow', 'visible');
|
var url = expTpe ? '../../json/ok.json' : '../../json/ok.json';
|
var isExpAdd = expTpe ? false : true;
|
// 回显数据
|
form.val('editForm', expTpe);
|
// 表单提交事件
|
form.on('submit(eCourseEditSubmit)', function (data) {
|
if (isExpAdd) {
|
if (xxDataList.length <= 0) {
|
layer.tips('请添加实验项目', '#demoEDeCourseAddBtnComment', {tips: [1, '#ff4c4c']});
|
return false;
|
}
|
var nList = admin.util.deepClone(xxDataList);
|
for (var xi = 0; xi < nList.length; xi++) {
|
nList[xi].experimentId = undefined;
|
}
|
data.field.expListJson = JSON.stringify(nList);
|
}
|
layer.load(2);
|
$.get(url, data.field, function (res) {
|
layer.closeAll('loading');
|
if (res.code === 200) {
|
layer.close(dIndex);
|
insTb.reload({page: {curr: 1}});
|
layer.msg(res.msg, {icon: 1});
|
} else {
|
layer.msg(res.msg, {icon: 2});
|
}
|
}, 'json');
|
return false;
|
});
|
//
|
var xxDataList = [];
|
var tbOptions = {
|
elem: '#formSSXMTable',
|
data: xxDataList,
|
page: true,
|
height: '350px;',
|
cellMinWidth: 100,
|
cols: [[
|
{type: 'numbers'},
|
{field: 'matNo', title: '物料编码'},
|
{field: 'matName', title: '物料名称', width: 160},
|
{field: 'qty', title: '数量'},
|
{align: 'center', title: '操作', toolbar: '#eCourseCouTbBar', minWidth: 120, width: 120}
|
]],
|
done: function () {
|
$(layero).find('.layui-table-view').css('margin', '0');
|
},
|
size: ''
|
};
|
if (isExpAdd) {
|
|
} else {
|
tbOptions.data = undefined;
|
tbOptions.url = '../../json/e-course-tb2.json?experimentTypeId=' + expTpe.experimentTypeId;
|
}
|
var insTbSSXM = table.render(tbOptions);
|
// 工具条点击事件
|
table.on('tool(formSSXMTable)', function (obj) {
|
var data = obj.data;
|
var layEvent = obj.event;
|
if (layEvent === 'edit') {
|
showEditModel2(data);
|
} else if (layEvent === 'del') {
|
layer.confirm('确定要删除吗?', {
|
shade: .1,
|
skin: 'layui-layer-admin'
|
}, function (i) {
|
layer.close(i);
|
if (isExpAdd) { // 前端处理删除
|
for (var j = 0; j < xxDataList.length; j++) {
|
if (xxDataList[j].experimentId === data.experimentId) {
|
xxDataList.splice(j, 1);
|
}
|
}
|
insTbSSXM.reload({data: xxDataList, page: {curr: 1}});
|
} else { // 后端处理删除
|
layer.load(2);
|
$.get('../../json/ok.json', {
|
experimentId: data.experimentId
|
}, function (res) {
|
layer.closeAll('loading');
|
if (res.code === 200) {
|
layer.msg(res.msg, {icon: 1});
|
insTb.reload({page: {curr: 1}});
|
insTbSSXM.reload({page: {curr: 1}});
|
} else {
|
layer.msg(res.msg, {icon: 2});
|
}
|
}, 'json');
|
}
|
});
|
}
|
});
|
//
|
$('#demoEDeCourseAddBtnComment').click(function () {
|
showEditModel2();
|
});
|
|
// 显示添加明细表单弹窗
|
function showEditModel2(exp) {
|
admin.open({
|
type: 1,
|
offset: '150px',
|
title: (exp ? '修改' : '添加') + '明细',
|
content: $('#eCourseCouEditDialog').html(),
|
success: function (layero, dIndex) {
|
$(layero).children('.layui-layer-content').css('overflow', 'visible');
|
var url = exp ? '../../json/ok.json' : '../../json/ok.json';
|
// 回显数据
|
form.val('eCourseCouEditForm', exp);
|
// 表单提交事件
|
form.on('submit(eCourseCouEditSubmit)', function (data) {
|
if (isExpAdd) { // 前端处理添加、修改
|
if (exp) { // 前端修改
|
for (var i = 0; i < xxDataList.length; i++) {
|
if (xxDataList[i].experimentName === data.field.experimentName && xxDataList[i].experimentId !== data.field.experimentId) {
|
layer.msg('实验项目名称已存在', {icon: 2});
|
return false;
|
}
|
}
|
layer.close(dIndex);
|
for (var j = 0; j < xxDataList.length; j++) {
|
if (xxDataList[j].experimentId === data.field.experimentId) {
|
xxDataList[j].experimentName = data.field.experimentName;
|
}
|
}
|
insTbSSXM.reload({data: xxDataList, page: {curr: 1}});
|
} else { // 前端添加
|
for (var i = 0; i < xxDataList.length; i++) {
|
if (xxDataList[i].experimentName === data.field.experimentName) {
|
layer.msg('实验项目名称已存在', {icon: 2});
|
return false;
|
}
|
}
|
layer.close(dIndex);
|
data.field.experimentId = new Date().getTime();
|
xxDataList.push(data.field);
|
insTbSSXM.reload({data: xxDataList, page: {curr: 1}});
|
}
|
} else { // 后端处理添加修改
|
layer.load(2);
|
if (!exp) {
|
data.field.experimentTypeId = expTpe.experimentTypeId;
|
}
|
$.get(url, {json: JSON.stringify(data.field)}, function (res) {
|
layer.closeAll('loading');
|
if (res.code === 200) {
|
layer.close(dIndex);
|
insTbSSXM.reload({page: {curr: 1}});
|
layer.msg(res.msg, {icon: 1});
|
} else {
|
layer.msg(res.msg, {icon: 2});
|
}
|
}, 'json');
|
}
|
return false;
|
});
|
// 渲染物料选择
|
var matXmSelect = xmSelect.render({
|
el: '#mat',
|
// radio: true,
|
autoRow: true,
|
toolbar: { show: true },
|
filterable: true,
|
remoteSearch: true,
|
remoteMethod: function(val, cb, show){
|
$.ajax({
|
url: baseUrl+"/mat/all/get/kv",
|
headers: {'token': localStorage.getItem('token')},
|
data: {
|
condition: val
|
},
|
method: 'POST',
|
success: function (res) {
|
if (res.code === 200){
|
cb(res.data)
|
} else {
|
cb([]);
|
layer.msg(res.msg, {icon: 2});
|
}
|
}
|
});
|
}
|
})
|
// 弹窗不出现滚动条
|
$(layero).children('.layui-layer-content').css('overflow', 'visible');
|
layui.form.render('select');
|
}
|
});
|
}
|
|
}
|
});
|
}
|
|
// 删除
|
function doDel(experimentTypeId) {
|
layer.confirm('确定要删除吗?', {
|
shade: .1,
|
skin: 'layui-layer-admin'
|
}, function (i) {
|
layer.close(i);
|
layer.load(2);
|
$.post('../../json/ok.json', {
|
experimentTypeId: experimentTypeId
|
}, function (res) {
|
layer.closeAll('loading');
|
if (res.code === 200) {
|
layer.msg(res.msg, {icon: 1});
|
insTb.reload({page: {curr: 1}});
|
} else {
|
layer.msg(res.msg, {icon: 2});
|
}
|
}, 'json');
|
});
|
}
|
|
});
|
</script>
|
</body>
|
</html>
|