/*
String: obj[excelData] 表格数据
Array:type[check] 校验规则,可以自定义,
Fn:type[format] 格式话对应的列,一般为生成select
String:bgColor 默认错误提示颜色
Fn:validateRules["isTel"] 为自定义的校验规则
*/
/*调用方法*/
new excelBuild({
excelData:str,
type:{
0:{
check:['require'],
format:function(v){
var $sel=$("<span><select><option value='1'>1</option><option value='1'>1</option><option value='1'>1</option><select></span>");
v.append($sel);
ret=$sel.find("select").val();
}
},
1:{
check:['require'],
},
2:{
check:['require'],
},
3:{
check:['require','isPhone'],
},
4:{
check:[],
},
5:{
check:[],
}
},
bgColor:"#f4afafd4",
validateRules:{
"isTel":function(v){
var re=/(\d{3,4}\-)?\d{7,8}/;
if(re.test(v)){
return true
}else{
return false
}
}
}
})
}
//如果存在异步情况可以使用
$.when($.ajax({
url:api_url+"/shop/find",
success:function(res){
shopData=res;
}
})).done(function(){
new excelBuild({
excelData:str,
type:{
0:{
check:['require'],
format:function (obj,v){
var $sel=$("<span><select><select></span>");
for(var i=0;i<shopData.data.length;i++){
$sel.find("select").append("<option value="+shopData.data[i].name+">"+shopData.data[i].name+"</option>")
}
obj.append($sel);
for(var a in shopData.data){
if(shopData.data[a].name==v){
obj.find("select").val(v)
}
}
}
},
1:{
check:['require'],
},
2:{
check:['require'],
},
3:{
check:['require','isPhone'],
},
4:{
check:[],
},
5:{
check:[],
}
},
bgColor:"#f4afafd4",
validateRules:{
"isTel":function(v){
var re=/(\d{3,4}\-)?\d{7,8}/;
if(re.test(v)){
return true
}else{
return false
}
}
}
})
}).fail(function(){
})
-
Notifications
You must be signed in to change notification settings - Fork 0
xcsweb/ImportExcelFormat
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
About
导入excel,格式化,做校验规则,允许自定义表格
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published