|
@@ -21,6 +21,9 @@ $(function () {
|
|
|
type: "post",
|
|
|
dataType:"JSON",
|
|
|
data: data_string,
|
|
|
+ beforeSend:function() {
|
|
|
+ $("#suit_under_load").html('套装加载中 <img src="img/suit_under_load.gif">');
|
|
|
+ },
|
|
|
success: function (data)
|
|
|
{
|
|
|
console.log(data);
|
|
@@ -63,8 +66,12 @@ $(function () {
|
|
|
}
|
|
|
var no_num=9;
|
|
|
suit_html=suit_html+ '<div class="rule_ rule_hr" rid="'+data.res[k].sr_qs[i].id+'">'+data.res[k].sr_qs[i].ruleName+'</div>';
|
|
|
- let math_num = Math.ceil(data.res[k].sr_qs[i].cr_qs.length/9==1?2:data.res[k].sr_qs[i].cr_qs.length/9)*10-Math.ceil(data.res[k].sr_qs[i].cr_qs.length/9==1?2:data.res[k].sr_qs[i].cr_qs.length/9)-1;
|
|
|
-
|
|
|
+
|
|
|
+ let math_num = Math.ceil(data.res[k].sr_qs[i].cr_qs.length/9)*10-Math.ceil(data.res[k].sr_qs[i].cr_qs.length/9)-1;
|
|
|
+
|
|
|
+ if(data.res[k].sr_qs[i].cr_qs.length%9==0){
|
|
|
+ math_num = ((data.res[k].sr_qs[i].cr_qs.length/9)+1)*10-Math.ceil(data.res[k].sr_qs[i].cr_qs.length/9)-2;
|
|
|
+ }
|
|
|
|
|
|
for(let j=0;j<math_num;j++){
|
|
|
if(j.toString().indexOf(no_num)!=-1){
|
|
@@ -98,7 +105,10 @@ $(function () {
|
|
|
|
|
|
suit_html=suit_html+ '</div>';
|
|
|
$("#suit_html").append(suit_html);
|
|
|
-
|
|
|
+// $("#suit_under_load").hide("slow");
|
|
|
+ $("#suit_under_load").animate({opacity:0},1500,function(){
|
|
|
+ $(this).css({display:"none"})
|
|
|
+ })
|
|
|
}
|
|
|
for(let k=0;k<data.res.length;k++){
|
|
|
if(k>1){
|
|
@@ -116,11 +126,7 @@ $(function () {
|
|
|
console.log("失败!");
|
|
|
|
|
|
}
|
|
|
- });
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+ });
|
|
|
|
|
|
|
|
|
var suit_exit_value;
|
|
@@ -193,28 +199,26 @@ $(function () {
|
|
|
var add_i=0;
|
|
|
var suit_rid;
|
|
|
|
|
|
-
|
|
|
// 添加规则和添加条件
|
|
|
$(document).on('click','.add_rule_a', function() {
|
|
|
- if(role_id=="admin"){
|
|
|
- suit_rid = $(this).attr("rid");
|
|
|
- add_i=0;
|
|
|
- add_rule = $(this).parent().parent().parent().children().eq(1);
|
|
|
- $(".add_role_div").parent().children().eq(0).html('');
|
|
|
- var html_ = '<div>'
|
|
|
- +' <div class="condition_one">'
|
|
|
- +' <input class="ipt_condition" id="condition_number_'+add_i+'" type="text" placeholder="输入条件编号,例如:1"> :'
|
|
|
- +' </div>'
|
|
|
- +' <div class="condition_one">'
|
|
|
- +' <input class="ipt_condition" id="condition_that_'+add_i+'" type="text" placeholder="输入条件说明,例如:红色">'
|
|
|
- +' </div>'
|
|
|
- +' </div>'
|
|
|
- $(".add_role_div").parent().children().eq(0).append(html_);
|
|
|
-
|
|
|
- add_i=add_i+1;
|
|
|
- $('#rule_add_id').fadeIn(100);
|
|
|
- $('#rule_add').slideDown(200);
|
|
|
- }
|
|
|
+ suit_rid = $(this).attr("rid");
|
|
|
+ add_i=0;
|
|
|
+ add_rule = $(this).parent().parent().parent().children().eq(1);
|
|
|
+ $(".add_role_div").parent().children().eq(0).html('');
|
|
|
+ var html_ = '<div>'
|
|
|
+ +' <div class="condition_one">'
|
|
|
+ +' <input class="ipt_condition" id="condition_number_'+add_i+'" type="text" placeholder="输入条件编号,例如:1"> :'
|
|
|
+ +' </div>'
|
|
|
+ +' <div class="condition_one">'
|
|
|
+ +' <input class="ipt_condition" id="condition_that_'+add_i+'" type="text" placeholder="输入条件说明,例如:红色">'
|
|
|
+ +' </div>'
|
|
|
+ +' </div>'
|
|
|
+ $(".add_role_div").parent().children().eq(0).append(html_);
|
|
|
+
|
|
|
+ add_i=add_i+1;
|
|
|
+ $('#rule_add_id').fadeIn(100);
|
|
|
+ $('#rule_add').slideDown(200);
|
|
|
+
|
|
|
});
|
|
|
|
|
|
|
|
@@ -265,7 +269,6 @@ $(function () {
|
|
|
var length = $(this).parent().parent().parent().children().length;
|
|
|
$(this).parent().parent().parent().append(suit_html);
|
|
|
length = length+10;
|
|
|
- console.log(length);
|
|
|
|
|
|
$(this).parent().parent().parent().children().last().html(lastChild);
|
|
|
var html_='<span class="rule_term" style="display: none;">'+''+':'+''+'</span> <input class="rule_input" style="display: inline-block;" rid="default" value="'+''+':'+''+'">';
|
|
@@ -295,41 +298,78 @@ $(function () {
|
|
|
if($(this).parent().parent().parent().children().eq(i).children().eq(1).val()==undefined){
|
|
|
|
|
|
}else{
|
|
|
- let id=$(this).parent().parent().parent().children().eq(i).children().eq(1).attr("rid");
|
|
|
+ let id=$(this).parent().parent().parent().children().eq(i).children().eq(1).attr("rid"); //条件的id
|
|
|
let num_name=$(this).parent().parent().parent().children().eq(i).children().eq(1).val().split(/:/);
|
|
|
if(num_name.length!=2){
|
|
|
num_name=$(this).parent().parent().parent().children().eq(i).children().eq(1).val().split(/:/);
|
|
|
}
|
|
|
- $(this).parent().parent().parent().children().eq(i).children().eq(0).html(num_name[0]+":"+num_name[1]);
|
|
|
-// console.log(id);
|
|
|
-// console.log(num_name);
|
|
|
+ if($(this).parent().parent().parent().children().eq(i).children().eq(1).val()==""){
|
|
|
+ $(this).parent().parent().parent().children().eq(i).children().eq(0).html('');
|
|
|
+ }else{
|
|
|
+ $(this).parent().parent().parent().children().eq(i).children().eq(0).html(num_name[0]+":"+num_name[1]);
|
|
|
+ }
|
|
|
+ let that=$(this);
|
|
|
if (id!="default"){ // id不为空的时候我就走修改的请求
|
|
|
- let url=http+"sku_condition/update";
|
|
|
- let data_string = JSON.stringify({token:token,numName:num_name[0].trim(),name:num_name[1].trim(),id:id});
|
|
|
- $.ajax({
|
|
|
- url: url,
|
|
|
- type: "post",
|
|
|
- dataType:"JSON",
|
|
|
- data: data_string,
|
|
|
- async: true,//异步
|
|
|
- success: function (data)
|
|
|
- {
|
|
|
- if(data.code==0){
|
|
|
- // console.log(data);
|
|
|
- }else{
|
|
|
- return;
|
|
|
- }
|
|
|
- },
|
|
|
- error:function (XMLHttpRequest) {
|
|
|
- console.log("失败!");
|
|
|
- }
|
|
|
- });
|
|
|
+
|
|
|
+ if($(this).parent().parent().parent().children().eq(i).children().eq(1).val()==""){//值等于空就直接删除掉
|
|
|
+ let url=http+"sku_condition/delete";
|
|
|
+ let data_string = JSON.stringify({token:token,id:id});
|
|
|
+ $.ajax({
|
|
|
+ url: url,
|
|
|
+ type: "post",
|
|
|
+ dataType:"JSON",
|
|
|
+ data: data_string,
|
|
|
+ async: true,//异步
|
|
|
+ success: function (data)
|
|
|
+ {
|
|
|
+ if(data.code==0){
|
|
|
+ console.log('删除成功!');
|
|
|
+ that.parent().parent().parent().children().eq(i).html("");
|
|
|
+ }else{
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ },
|
|
|
+ error:function (XMLHttpRequest) {
|
|
|
+ console.log("失败!");
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }else{
|
|
|
+ if($(this).parent().parent().parent().children().eq(i).children().eq(1).val()==$(this).parent().parent().parent().children().eq(i).children().eq(0).html()){
|
|
|
+// console.log("没有编辑");
|
|
|
+ }else{
|
|
|
+ let url=http+"sku_condition/update";
|
|
|
+ let data_string = JSON.stringify({token:token,numName:num_name[0],name:num_name[1],id:id});
|
|
|
+ $.ajax({
|
|
|
+ url: url,
|
|
|
+ type: "post",
|
|
|
+ dataType:"JSON",
|
|
|
+ data: data_string,
|
|
|
+ async: true,//异步
|
|
|
+ success: function (data)
|
|
|
+ {
|
|
|
+ if(data.code==0){
|
|
|
+ // console.log(data);
|
|
|
+ }else{
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ },
|
|
|
+ error:function (XMLHttpRequest) {
|
|
|
+ console.log("失败!");
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
}else{
|
|
|
+// 添加
|
|
|
+ if($(this).parent().parent().parent().children().eq(i).children().eq(1).val()==""){
|
|
|
+ $(this).parent().parent().parent().children().eq(i).html('');
|
|
|
+ }
|
|
|
let url=http+"sku_condition/add";
|
|
|
var rule_id=$(this).parent().parent().parent().children().eq(0).attr("rid");
|
|
|
// console.log(rule_id);
|
|
|
- let that=$(this);
|
|
|
- let data_string = JSON.stringify({token:token,numName:num_name[0].trim(),name:num_name[1].trim(),id:rule_id});
|
|
|
+
|
|
|
+ let data_string = JSON.stringify({token:token,numName:num_name[0],name:num_name[1],id:rule_id});
|
|
|
// console.log(data_string);
|
|
|
$.ajax({
|
|
|
url: url,
|
|
@@ -342,7 +382,6 @@ $(function () {
|
|
|
if(data.code==0){
|
|
|
// console.log(i);
|
|
|
// console.log(data.res[0].id);
|
|
|
-// console.log(that.parent().parent().parent().children().eq(i).children().eq(1).attr("rid"))
|
|
|
that.parent().parent().parent().children().eq(i).children().eq(1).attr("rid",data.res[0].id);
|
|
|
}else{
|
|
|
console.log(data.msg);
|
|
@@ -406,7 +445,7 @@ $(function () {
|
|
|
type: "post",
|
|
|
dataType:"JSON",
|
|
|
data: data_string,
|
|
|
- async: false,//同步
|
|
|
+ async: false,//
|
|
|
success: function (data)
|
|
|
{
|
|
|
console.log(data);
|
|
@@ -429,7 +468,7 @@ $(function () {
|
|
|
type: "post",
|
|
|
dataType:"JSON",
|
|
|
data: data_string,
|
|
|
- async: false,//同步
|
|
|
+ async: false,//
|
|
|
success: function (data)
|
|
|
{
|
|
|
if(data.code==0){
|
|
@@ -446,7 +485,7 @@ $(function () {
|
|
|
|
|
|
}
|
|
|
let suit_html='';
|
|
|
- let num=8;
|
|
|
+
|
|
|
for(let i=0;i<1;i++){
|
|
|
if(add_rule.html()==""){
|
|
|
suit_html=suit_html + '<div class="rule_one" style="border-top: 1px solid #e4e7e9;">';
|
|
@@ -454,32 +493,24 @@ $(function () {
|
|
|
suit_html=suit_html + '<div class="rule_one">';
|
|
|
}
|
|
|
suit_html=suit_html+ '<div class="rule_ rule_hr" rid="'+rule_id+'">'+role_edit_name+'</div>';
|
|
|
- if (condition_that.length>8){
|
|
|
- num=17
|
|
|
- }
|
|
|
- if (condition_that.length>18){
|
|
|
- num=26
|
|
|
- }
|
|
|
+ let num = Math.ceil(condition_that.length/9)*10-(Math.ceil(condition_that.length/9)==1?2:Math.ceil(condition_that.length/9));
|
|
|
+ if(condition_that.length%9==0){
|
|
|
+ num =Math.ceil(condition_that.length/9+1)*10-(Math.ceil(condition_that.length/9)==1?2:Math.ceil(condition_that.length/9))
|
|
|
+ }
|
|
|
+ let no_num=9;
|
|
|
+ var i_length=0;
|
|
|
for(let j=0;j<num;j++){
|
|
|
- if(j==9){
|
|
|
- suit_html=suit_html+ '<div class="rule_ rule_hr"></div>';
|
|
|
- try{
|
|
|
- if(condition_number[j]!=undefined){
|
|
|
- suit_html=suit_html+ '<div class="rule_"><span class="rule_term">'+condition_number[j]+':'+condition_that[j]+'</span> <input class="rule_input" rid="'+condition_id[j]+'" value="'+condition_number[j]+':'+condition_that[j]+'"></div>';
|
|
|
- }else{
|
|
|
- suit_html=suit_html+ '<div class="rule_ rule_hr"></div>';
|
|
|
- }
|
|
|
- }catch(e){
|
|
|
- //TODO handle the exception
|
|
|
- suit_html=suit_html+ '<div class="rule_ rule_hr"></div>';
|
|
|
- }
|
|
|
- }else{
|
|
|
- if(j<condition_number.length){
|
|
|
- suit_html=suit_html+ '<div class="rule_"><span class="rule_term">'+condition_number[j]+':'+condition_that[j]+'</span> <input class="rule_input" rid="'+condition_id[j]+'" value="'+condition_number[j]+':'+condition_that[j]+'"></div>';
|
|
|
- }else{
|
|
|
+ if(j.toString().indexOf(no_num)!=-1){
|
|
|
+ suit_html=suit_html+ '<div class="rule_"></div>';
|
|
|
+ no_num=no_num+9;
|
|
|
+ }else{
|
|
|
+ if(i_length<condition_number.length){
|
|
|
+ suit_html=suit_html+ '<div class="rule_"><span class="rule_term">'+condition_number[i_length]+':'+condition_that[i_length]+'</span> <input class="rule_input" rid="'+condition_id[i_length]+'" value="'+condition_number[i_length]+':'+condition_that[i_length]+'"></div>';
|
|
|
+ i_length=i_length+1;
|
|
|
+ }else{
|
|
|
suit_html=suit_html+ '<div class="rule_"></div>';
|
|
|
- }
|
|
|
- }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
suit_html=suit_html+ '<div class="rule_" style="float: right;">'
|
|
|
+ '<div class="rule_operate"><img style="margin-left: 50%; "src="img/modify@2x.png" class="compile" title="编辑"></div>'
|