1霎俩、layui的form
- 1)哀军、HTML部分
<form id="myform" class="layui-form">
<div class="layui-form-item">
<label class="layui-form-label">審核原因<label class="notnull">*</label></label>
<div class="layui-input-inline">
<input type="text" id="CheckingReason" name="CheckingReason" required lay-verify="required" placeholder="請輸入審核原因" autocomplete="off" class="layui-input">
</div>
<label class="layui-form-label">審核情況<label class="notnull">*</label></label>
<div class="layui-input-inline">
<input type="text" id="CheckingRemark" name="CheckingRemark" required lay-verify="required" placeholder="請輸入審核原因" autocomplete="off" class="layui-input">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">審核狀態(tài)</label>
<div class="layui-input-inline">
<input type="radio" name="CheckingState" value="0" title="未審核" checked>
<input type="radio" name="CheckingState" value="1" title="審核通過">
<input type="radio" name="CheckingState" value="2" title="審核未通過">
</div>
</div>
<div class="layui-form-item">
<div class="layui-input-block">
<button class="layui-btn" lay-submit lay-filter="formSubmit">提交</button>
<button type="reset" class="layui-btn layui-btn-primary">重置</button>
</div>
</div>
</form>
- 2)、JS部分
var layer, layform;
layui.use([ 'form', 'layer' ], function() {
layform = layui.form;
//監(jiān)聽提交
layform.on('submit(formSubmit)', function(data) {
addFormSubmit(data.field);
});
});
- 3)打却、data.field是form提交出來的數(shù)據(jù)杉适,數(shù)據(jù)格式是json的格式,鍵是每個input的name趁蕊,值是value熟嫩,Ajax提交的時候可以直接用
2素挽、layer的最小化與還原枪眉,與關(guān)閉該layer的事件
var mylayer = layer.open({
type: 2,
title: "SB",
shade: 0,
area: ['800px', '500px'],
maxmin: true,
zIndex: layer.zIndex,
content: "index.html",
end:function(){
top.removeAll(); //當(dāng)關(guān)閉該彈出層的時候蹬叭,執(zhí)行該事件
}
});
layer.min(mylayer); //最小化
layer.restore(mylayer); //還原
3藕咏、easyui的datagrid用法
$(function(){
inittable();
})
//初始化數(shù)據(jù)表格
function inittable(){
$("#dg").datagrid({
title:"demo",
rownumbers:true,
singleSelect:true,
autoRowHeight:false,
striped:true,
nowrap:false,
fit:true,
remoteSort:false,
loadMsg:"正在加載數(shù)據(jù),請稍候……",
columns:[[
{field:'op',title:'操作',width:50,align:'center',formatter:function(value,row,index){
//點(diǎn)擊時將id傳過去秽五,注意:傳不了對象過去
return '<button class="layui-btn layui-btn-danger layui-btn-xs" onclick="deleteGroup(\''+row.code+'\')">刪除</button>'
}},
{field:'ResourcesName',title:'分組名稱',width:'150',align:"center"},
]],
onSelect:function(index, row){
//選中某行的時候
console.log(row);
},
onLoadSuccess:function(data){
console.log(data);
//$("#dg").datagrid("selectRow",0); //加載第一條數(shù)據(jù)
},
//根據(jù)值去返回數(shù)據(jù)
{field:'IsShow',title:'是否顯示',width:'80',align:"center",formatter:function(value,row,index){
if(value=="1"){
return '<span style="color:blue;font-weight:bold;">是</span>';
}else{
return '<span style="color:red;font-weight:bold;">否</span>';
}
}}
});
loadDatas();
}
//加載數(shù)據(jù)
function loadDatas(){
var sendData = {
"apikey":"getDynamicGroupInfo"
}
comAjax("json/api","get",sendData,function(json){
if(json.code == 0){
console.log(json.data);
$("#dg").datagrid("loadData",json.data);
}
},'',false);
}
4孽查、layui的table前臺實(shí)現(xiàn)分頁(首次把所有的數(shù)據(jù)拿到,前臺自己做分頁)
<table id="test2"></table>
layui.use('table', function(){
var table = layui.table;
var datass = ''
$.ajax({
type:"get",
url:"json/gzzz.json",
async:true,
success:function(data){
datass = data.data
table.render({
elem: '#test2'
,data:datass
,height: 196
,cols: [[
{field: 'towerid', title: 'ID', width: 80, sort: true}
,{field: 'towerame', title: '用戶名', width: 120}
]]
,skin: 'row' //表格風(fēng)格
,even: true
,page: true //是否顯示分頁
,limits: [3]
,limit: 3 //每頁默認(rèn)顯示的數(shù)量
});
}
});
})
5坦喘、 回調(diào)函數(shù)
var person = {};
person.name = "jwl";
person.age = "20";
function say(a){
console.log(a.name)
}
say(person);
6盲再、string的replace用法
pointStr.replace(/;/g, ",");
將所有的“;”替換成“瓣铣,”
7答朋、
//獲取頁面?zhèn)魅雲(yún)?shù)
function getPageParams(){
var pageurl = window.location.href;
var param = {};
if(pageurl.indexOf("?")!=-1){
var paramstr = pageurl.split("?")[1];
var pArr = paramstr.split("&");
var tArr = null;
for(var i=0;i<pArr.length;i++){
tArr = pArr[i].split("=");
if(tArr.length==2){
param[tArr[0]]=tArr[1];
}else{
param[tArr[0]]="";
}
}
}
return param;
}
/*
* 獲取url中的參數(shù)
* name:參數(shù)名稱
*/
function getUrlParam(name) {
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //構(gòu)造一個含有目標(biāo)參數(shù)的正則表達(dá)式對象
var r = window.location.search.substr(1).match(reg); //匹配目標(biāo)參數(shù)
if (r != null) return unescape(r[2]); return null; //返回參數(shù)值
}
Layui上傳
var layui_upload;
var selectInfo = {"method":"uploadSummary","projectid":"","filefolder":"fm"};
layui.use('upload', function() {
layui_upload = layui.upload;
// 執(zhí)行實(shí)例
var uploadInst = layui_upload.render({
elem : '#fileupload' // 綁定元素
,url : '../../json/upload' // 上傳接口
,data: selectInfo
,size: 20000 //上傳文件大小,最大20M
,accept: 'file' //普通文件
,exts:'doc|docx|xls|xlsx|txt|pdf'
,before:function(obj){
}
,done : function(json) {
if(json.code=="200"){
loadProInfoList($(".selProQueryList").attr("proid"),$(".selProTabMenu").attr("jd"));
layer.msg("文件上傳成功坯沪!");
}
},
error : function() {
alert("error");
// 請求異陈逃常回調(diào)
}
});
});