diff --git a/wages/src/main/resources/template/js/wagesSocialSecurityFund/wagesSocialSecurityFundAdd.js b/wages/src/main/resources/template/js/wagesSocialSecurityFund/wagesSocialSecurityFundAdd.js index 3a59ffe693859315e0ba3e32861639ffdffedd62..1c631f858f31cb398bbdcb39356554cddc5e390f 100644 --- a/wages/src/main/resources/template/js/wagesSocialSecurityFund/wagesSocialSecurityFundAdd.js +++ b/wages/src/main/resources/template/js/wagesSocialSecurityFund/wagesSocialSecurityFundAdd.js @@ -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(){ diff --git a/wages/src/main/resources/template/js/wagesSocialSecurityFund/wagesSocialSecurityFundEdit.js b/wages/src/main/resources/template/js/wagesSocialSecurityFund/wagesSocialSecurityFundEdit.js index 608abe79c4ebb2e4af2a55ff49c6435a716bc094..9eae6dea6efde5935bda39fd0f16aad68168e93f 100644 --- a/wages/src/main/resources/template/js/wagesSocialSecurityFund/wagesSocialSecurityFundEdit.js +++ b/wages/src/main/resources/template/js/wagesSocialSecurityFund/wagesSocialSecurityFundEdit.js @@ -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)); } }); diff --git a/web/src/main/resources/template/assets/lib/layui/custom.js b/web/src/main/resources/template/assets/lib/layui/custom.js index 626c6b7d82b11657fcc2aa071248a61789a6bfff..54a8eb2b6f67a21382684f8282d349ac6a575464 100644 --- a/web/src/main/resources/template/assets/lib/layui/custom.js +++ b/web/src/main/resources/template/assets/lib/layui/custom.js @@ -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", // 集合工具类 }; //系统基础信息 diff --git a/web/src/main/resources/template/assets/lib/layui/customer/arrayUtil.js b/web/src/main/resources/template/assets/lib/layui/customer/arrayUtil.js new file mode 100644 index 0000000000000000000000000000000000000000..2810077d5a05533e243e0407cc74f991e1ee3eba --- /dev/null +++ b/web/src/main/resources/template/assets/lib/layui/customer/arrayUtil.js @@ -0,0 +1,25 @@ + + +// 集合工具类函数 +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