|
@@ -2869,26 +2869,51 @@
|
|
|
// 精准筛选规则-新增精准匹配规则保存按钮点击事件
|
|
|
function add_exactRule_save(){
|
|
|
// 获取值
|
|
|
- let ruleArr = []
|
|
|
- let formList = $("#insertexactRule .insertexactRule-form")
|
|
|
- for (let i = 0; i < formList.length; i++) {
|
|
|
- let groupName = formList[i].querySelector('[name=groupSelect]').value
|
|
|
- let count = formList[i].querySelector('[name=count]').value
|
|
|
- // 这是因为现在新增的表单是写死的两个
|
|
|
- let tmp = '#insertexactRule .exact-rule-'+(i+1)+' select[name=matchWay]'
|
|
|
- let matchWay = $(tmp).val();
|
|
|
- if (groupName==""||matchWay.length==0||count==""){
|
|
|
+ let ruleArr = [];
|
|
|
+ let checkObj = {};
|
|
|
+ let formList = $("#insertexactRule .insertexactRule-form");
|
|
|
+ formList.each(function() {
|
|
|
+ var groupName = $(this).find('select[name="groupSelect"]').val();
|
|
|
+ var count = $(this).find('input[name="count"]').val();
|
|
|
+ var matchWayValue = $(this).find('select[name="matchWay"]').val();
|
|
|
+ if (groupName===""||matchWayValue.length===0||count===""){
|
|
|
// todo
|
|
|
- showMsg("必填项缺失")
|
|
|
- return
|
|
|
+ return true;
|
|
|
}
|
|
|
- for (let j = 0; j < matchWay.length; j++) {
|
|
|
+ for (let j = 0; j < matchWayValue.length; j++) {
|
|
|
let rule = {
|
|
|
- "group":groupName,"match_way":matchWay[j],"count":count
|
|
|
+ "group":groupName,"match_way":matchWayValue[j],"count":count
|
|
|
+ }
|
|
|
+ if(checkObj[groupName+"_"+count+"_"+matchWayValue[j]]){
|
|
|
+ return true
|
|
|
}
|
|
|
+ checkObj[groupName+"_"+count+"_"+matchWayValue[j]] = matchWayValue[j]
|
|
|
ruleArr.push(rule)
|
|
|
}
|
|
|
+ console.log(matchWayValue);
|
|
|
+ });
|
|
|
+ if (ruleArr.length===0){
|
|
|
+ showMsg("规则已存在!")
|
|
|
+ return
|
|
|
}
|
|
|
+ // for (let i = 0; i < formList.length; i++) {
|
|
|
+ // let groupName = formList[i].querySelector('[name=groupSelect]').value
|
|
|
+ // let count = formList[i].querySelector('[name=count]').value
|
|
|
+ // // 这是因为现在新增的表单是写死的两个
|
|
|
+ // let tmp = '#insertexactRule .exact-rule-'+(i+1)+' select[name=matchWay]'
|
|
|
+ // let matchWay = $(tmp).val();
|
|
|
+ // if (groupName==""||matchWay.length==0||count==""){
|
|
|
+ // // todo
|
|
|
+ // showMsg("必填项缺失")
|
|
|
+ // return
|
|
|
+ // }
|
|
|
+ // for (let j = 0; j < matchWay.length; j++) {
|
|
|
+ // let rule = {
|
|
|
+ // "group":groupName,"match_way":matchWay[j],"count":count
|
|
|
+ // }
|
|
|
+ // ruleArr.push(rule)
|
|
|
+ // }
|
|
|
+ // }
|
|
|
// 保存到exactRuleTableArr 临时数组
|
|
|
exactRuleTableArr.push(ruleArr)
|
|
|
$('#exactRuleTable').dataTable().fnClearTable();
|