效果图
< title> 主页 title>
< div class = " layui-card layadmin-header" >
< div class = " layui-breadcrumb" lay-filter = " breadcrumb" >
< a lay-href = " " > 发单 a>
< a> < cite> 新建 cite> a>
< a> < cite> 采购 cite> a>
div>
div>
< div class = " layui-fluid" >
< style>
.layui-table-cell {
overflow : visible;
}
.layui-table-box {
overflow : visible;
}
.layui-table-body {
overflow : visible;
}
td .layui-form-select {
margin-top : -10px;
margin-left : -15px;
margin-right : -15px;
}
style>
< div class = " layui-card" >
< div class = " layui-card-body" style =" padding : 15px; " >
< form class = " layui-form" id = " fromId" action = " #" >
< fieldset class = " layui-elem-field" >
< div style =" padding-top : 25px; " class = " layui-field-box" >
< div class = " layui-form-item" >
< label class = " layui-form-label" > 入库单编号 label>
< div class = " layui-input-inline" style =" width : 13%" >
< input type = " text" name = " order" placeholder = " 请输入" class = " layui-input" lay-verify = " required" >
div>
< label class = " layui-form-label" > 客户姓名 label>
< div class = " layui-input-inline" style =" width : 13%" >
< input type = " text" name = " username" placeholder = " 请输入" class = " layui-input" lay-verify = " required" >
div>
< label class = " layui-form-label" > 地址 label>
< div class = " layui-input-inline" style =" width : 13%" >
< input type = " text" name = " projectadd" placeholder = " 请输入" class = " layui-input" lay-verify = " required" >
div>
< label class = " layui-form-label" > 设计师 label>
< div class = " layui-input-inline" style =" width : 13%" >
< input type = " text" name = " stylist" placeholder = " 请输入" class = " layui-input" lay-verify = " required" >
div>
div>
< div class = " layui-form-item" >
< label class = " layui-form-label" > 客户要求发货日期 label>
< div class = " layui-input-inline" style =" width : 13%" >
< input type = " text" name = " goods_time" placeholder = " 请选择" class = " layui-input" id = " date" lay-verify = " required" >
div>
< label class = " layui-form-label" > 下单日期 label>
< div class = " layui-input-inline" style =" width : 13%" >
< input type = " text" name = " place_order_time" placeholder = " 请选择" class = " layui-input" id = " place_order_time" lay-verify = " required" >
div>
< label class = " layui-form-label" > 产品系列 label>
< div class = " layui-input-inline" style =" width : 13%" >
< input type = " text" name = " Product_Line" placeholder = " 请输入" class = " layui-input" lay-verify = " required" >
div>
div>
div>
fieldset>
< script type = " text/html" id = " selectTool" >
< select name= "selectDemo" lay- filter= "selectDemo" lay- search>
< option value= "请选择或输入" > 请选择或输入< / option>
< / select>
script>
< script type = " text/html" id = " toolbarDemo" >
< div align= "right" class = "layui-btn-container" >
< button id= "addTable" class = "layui-btn layui-btn-sm layui-btn-normal" lay- event= "add" > 添加行< / button>
< / div>
script>
< script type = " text/html" id = " bar" >
< a class = "layui-btn layui-btn-danger layui-btn-xs" lay- event= "del" > 删除< / a>
< ! -- < a class = "layui-btn layui-btn-danger layui-btn-xs" lay- event= "del" > 删除< / a> -- >
script>
< table id = " demo" lay-filter = " tableFilter" > table>
< div class = " layui-form-item" style =" margin-top : 30px; text-align : center; " >
< button class = " layui-btn" lay-submit = " " lay-filter = " *" > 保存 button>
div>
form>
div>
div>
div>
< script>
layui. use ( [ 'jquery' , 'table' , 'layer' , 'laydate' , 'form' ] , function ( ) {
var $ = layui. jquery,
table = layui. table,
form = layui. form,
layer = layui. layer,
laydate = layui. laydate;
laydate. render ( {
elem: '#date'
} ) ;
var tableIns = table. render ( {
elem: '#demo'
, toolbar: '#toolbarDemo'
, defaultToolbar: [ ]
, limit: 100
, cols: [ [
{ field: 'ordername' , title: '物料名称' , edit: 'text' , templet: "#selecta" }
, { field: 'hz_factoryname' , title: '供应商' , edit: 'text' }
, { field: 'Scheduled_purchase_time' , title: '计划采购日期' , edit: 'text' , event: 'dateti' , data_field: "dBeginDate" }
, { field: 'parameter_Add' , title: '采购人' , edit: 'text' }
, { field: 'Required_time' , title: '要求送达时间' , edit: 'text' , event: 'Required_time' }
, { field: 'Required_place' , title: '要求送达地点' , edit: 'text' }
, { field: 'Shipping' , title: '送货方式' , edit: 'text' , event: 'selecta' }
, { title: '操作' , align: 'center' , toolbar: '#bar' }
] ]
, data: [ {
"ordername" : ""
, "hz_factoryname" : ""
, "Scheduled_purchase_time" : ""
, "parameter_Add" : ""
, "Required_time" : ""
, "Required_place" : ""
, "Shipping" : ""
} ]
, done: function ( res, curr, count) {
tabledata = res. data;
$ ( ".layui-table-body, .layui-table-box, .layui-table-cell" ) . css ( 'overflow' , 'visible' ) ;
}
} ) ;
var tabledata;
table. on ( 'tool(tableFilter)' , function ( obj) {
console. log ( "a" )
if ( obj. event === 'del' ) {
obj. del ( ) ;
} ;
}
) ;
table. on ( 'toolbar(tableFilter)' , function ( obj) {
if ( obj. event === 'add' ) {
tabledata. push ( {
"ordername" : ""
, "hz_factoryname" : ""
, "Scheduled_purchase_time" : ""
, "parameter_Add" : ""
, "Required_time" : ""
, "Required_place" : ""
, "Shipping" : ""
} )
table. reload ( 'demo' , {
data: tabledata
} ) ;
} ;
} ) ;
table. on ( 'tool(tableFilter)' , function ( obj) {
var data = obj. data,
event = obj. event,
tr = obj. tr;
switch ( event) {
case "dateti" :
console. log ( "a" ) ;
var newdata = { } ;
var field = $ ( this ) . data ( 'field' ) ;
laydate. render ( {
elem: this . firstChild
, show: true
, closeStop: this
, type: 'datetime'
, format: "yyyy-MM-dd"
, done: function ( value, date) {
newdata[ field] = value;
obj. update ( newdata) ;
}
} ) ;
break ;
case "Required_time" :
var newdata = { } ;
var field = $ ( this ) . data ( 'field' ) ;
laydate. render ( {
elem: this . firstChild
, show: true
, closeStop: this
, type: 'datetime'
, format: "yyyy-MM-dd"
, done: function ( value, date) {
newdata[ field] = value;
obj. update ( newdata) ;
}
} ) ;
break ;
case "selecta" :
console. log ( "a" ) ;
$ ( function ( ) {
$. post ( '/sys/ashx/Dichandler.ashx?action=defaultlayui&CategoryId=12' , { } , function ( data) {
var a = JSON . parse ( data) ;
var aa = a. data;
for ( var k in aa) {
$ ( "#selecta" ) . append ( "" + aa[ k] . Title + "" )
}
layui. use ( 'form' , function ( ) {
var form = layui. form;
form. render ( ) ;
} )
} ) ;
} ) ;
break ;
}
} )
form. on ( 'submit(*)' , function ( data) {
$. ajax ( {
url: "/ashx/ajax.ashx?action=order" ,
async : true ,
type: "post" ,
data: $ ( data. form) . serialize ( ) + '&tabledata=' + JSON . stringify ( tabledata) ,
success: function ( data) {
if ( typeof ( data) == 'string' ) {
data = JSON . parse ( data)
}
if ( data. code == 0 ) {
layer. msg ( data. msg) ;
} else {
layer. msg ( data. msg) ;
}
}
} ) ;
return false ;
} ) ;
} )
script>
< script src = " ../src/views/order/jquery.min.js" > script>