提交 9e491027 编写于 作者: doc_wei's avatar doc_wei

【公共】 新增移除集合中指定name的元素,验证成功

上级 b391d966
......@@ -103,15 +103,7 @@ layui.config({
placeholder: '请选择企业',
editorTag: false,
beforeTagDelete: function(field, editor, tags, val) {
var inArray = -1;
$.each(companyList, function(i, item) {
if(val == item.name) {
inArray = i;
}
});
if(inArray != -1) { //如果该元素在集合中存在
companyList.splice(inArray, 1);
}
companyList = [].concat(arrayUtil.removeArrayPointName(companyList, val));
}
});
$("body").on("click", "#companySel", function(){
......@@ -143,15 +135,7 @@ layui.config({
placeholder: '请选择部门',
editorTag: false,
beforeTagDelete: function(field, editor, tags, val) {
var inArray = -1;
$.each(departmentList, function(i, item) {
if(val == item.name) {
inArray = i;
}
});
if(inArray != -1) {
departmentList.splice(inArray, 1);
}
departmentList = [].concat(arrayUtil.removeArrayPointName(departmentList, val));
}
});
$("body").on("click", "#departmentSel", function(){
......@@ -183,15 +167,7 @@ layui.config({
placeholder: '请选择员工',
editorTag: false,
beforeTagDelete: function(field, editor, tags, val) {
var inArray = -1;
$.each(checkStaffList, function(i, item) {
if(val == item.name) {
inArray = i;
}
});
if(inArray != -1) { //如果该元素在集合中存在
checkStaffList.splice(inArray, 1);
}
checkStaffList = [].concat(arrayUtil.removeArrayPointName(checkStaffList, val));
}
});
$("body").on("click", "#userStaffSel", function(){
......
......@@ -44,15 +44,7 @@ layui.config({
placeholder: '请选择企业',
editorTag: false,
beforeTagDelete: function(field, editor, tags, val) {
var inArray = -1;
$.each(companyList, function(i, item) {
if(val == item.name) {
inArray = i;
}
});
if(inArray != -1) { //如果该元素在集合中存在
companyList.splice(inArray, 1);
}
companyList = [].concat(arrayUtil.removeArrayPointName(companyList, val));
}
});
......@@ -64,15 +56,7 @@ layui.config({
placeholder: '请选择部门',
editorTag: false,
beforeTagDelete: function(field, editor, tags, val) {
var inArray = -1;
$.each(departmentList, function(i, item) {
if(val == item.name) {
inArray = i;
}
});
if(inArray != -1) {
departmentList.splice(inArray, 1);
}
departmentList = [].concat(arrayUtil.removeArrayPointName(departmentList, val));
}
});
......@@ -84,15 +68,7 @@ layui.config({
placeholder: '请选择员工',
editorTag: false,
beforeTagDelete: function(field, editor, tags, val) {
var inArray = -1;
$.each(checkStaffList, function(i, item) {
if(val == item.name) {
inArray = i;
}
});
if(inArray != -1) { //如果该元素在集合中存在
checkStaffList.splice(inArray, 1);
}
checkStaffList = [].concat(arrayUtil.removeArrayPointName(checkStaffList, val));
}
});
......
......@@ -34,6 +34,7 @@ var customerJS = {
"reportModelTypeUtil": "../../assets/lib/layui/customer/reportModelTypeUtil.js", // 模型分类工具类
"schoolUtil": "../../assets/lib/layui/customer/schoolUtil.js", // 学校模块工具类
"checkWorkUtil": "../../assets/lib/layui/customer/checkWorkUtil.js", // 考勤模块工具类
"arrayUtil": "../../assets/lib/layui/customer/arrayUtil.js", // 集合工具类
};
//系统基础信息
......
// 集合工具类函数
var arrayUtil = {
/**
* 移除集合中指定name的元素
*
* @param list 集合
* @param name 指定name
*/
removeArrayPointName: function (list, name) {
var inArray = -1;
$.each(list, function(i, item) {
if(name == item.name) {
inArray = i;
}
});
if(inArray != -1) {
list.splice(inArray, 1);
}
return list;
}
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册