|
@@ -1,12 +1,20 @@
|
|
|
$(function () {
|
|
|
+ $(".new_suit").show(400);
|
|
|
+
|
|
|
var token=$.cookie('access_token');
|
|
|
-
|
|
|
+ var role_id=$.cookie('role_id');
|
|
|
if(token==undefined){
|
|
|
window.location.href = "login.html";
|
|
|
}
|
|
|
|
|
|
var url=http+"cku_suit/query_all";
|
|
|
var data_string = JSON.stringify({token:token});
|
|
|
+ if(role_id=="admin"){
|
|
|
+
|
|
|
+ }else{
|
|
|
+ $(".new_suit_a").hide();
|
|
|
+ }
|
|
|
+
|
|
|
// 首次获取
|
|
|
$.ajax({
|
|
|
url: url,
|
|
@@ -24,8 +32,8 @@ $(function () {
|
|
|
suit_html=suit_html + '<div class="suit_title_text">'+data.res[k].suitName+'</div>';
|
|
|
suit_html=suit_html + '<div class="suit_title_ico"><img src="img/spread.png"></div>';
|
|
|
suit_html=suit_html + '</div>';
|
|
|
-
|
|
|
- suit_html=suit_html + '<div class="add_rule" >'
|
|
|
+ if(role_id=="admin"){
|
|
|
+ suit_html=suit_html + '<div class="add_rule" >'
|
|
|
+ '<div class="add_rule_a" rid="'+data.res[k].id+'">'
|
|
|
+ '<div class="icon_img">'
|
|
|
+ '<img src="img/Add@2x.png">'
|
|
@@ -34,16 +42,29 @@ $(function () {
|
|
|
+ '</div>'
|
|
|
+ '</div>'
|
|
|
+ '</div>';
|
|
|
-
|
|
|
- suit_html=suit_html + '<div class="rule_all_list" >';
|
|
|
+ }else{
|
|
|
+ suit_html=suit_html + '<div class="add_rule" >'
|
|
|
+ + '<div class="add_rule_a" style=" border: 1px solid white;">'
|
|
|
+ + '<div class="icon_img">'
|
|
|
+ + '</div>'
|
|
|
+ + '<div class="add_rule_title"></div>'
|
|
|
+ + '</div>'
|
|
|
+ + '</div>'
|
|
|
+ + '</div>';
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ suit_html=suit_html + '<div class="rule_all_list" >';
|
|
|
let num=8;
|
|
|
for(var i=0;i<data.res[k].sr_qs.length;i++){
|
|
|
-
|
|
|
+
|
|
|
if(i==0){
|
|
|
suit_html=suit_html + '<div class="rule_one" style="border-top: 1px solid #e4e7e9;">';
|
|
|
}else{
|
|
|
suit_html=suit_html + '<div class="rule_one">';
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
|
|
|
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>';
|
|
|
//
|
|
@@ -79,12 +100,16 @@ $(function () {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- suit_html=suit_html+ '<div class="rule_" style="float: right;">'
|
|
|
+ if(role_id=="admin"){
|
|
|
+ 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>'
|
|
|
+ '<div class="rule_operate"><img style="margin-left: 10%; " src="img/delete@2x.png" class="remove" title="删除"></div>'
|
|
|
-
|
|
|
+ '<div class="rule_save_div"><div class="rule_save">保存</div></div>'
|
|
|
+ '</div>'
|
|
|
+ }else{
|
|
|
+ suit_html=suit_html + '<div class="rule_" style="float: right;">'
|
|
|
+ + '</div>'
|
|
|
+ }
|
|
|
suit_html=suit_html+'</div>';
|
|
|
}
|
|
|
|
|
@@ -136,9 +161,8 @@ $(function () {
|
|
|
data: data_string,
|
|
|
async: true,//同步
|
|
|
success: function (data)
|
|
|
- {
|
|
|
+ { console.log(data);
|
|
|
if(data.code==0){
|
|
|
- console.log(data);
|
|
|
let id = data.res[0].id;
|
|
|
var suit_html=' <div class="suit_" >';
|
|
|
suit_html=suit_html + '<div style="height: 80px;width: 100%;">';
|
|
@@ -162,6 +186,7 @@ $(function () {
|
|
|
console.log(suit_exit_value.parent());
|
|
|
suit_exit_value.parent().parent().parent().children().eq(0).append(suit_html);
|
|
|
}else{
|
|
|
+ alert("该用户没有权限!")
|
|
|
return;
|
|
|
}
|
|
|
},
|
|
@@ -179,26 +204,31 @@ $(function () {
|
|
|
var add_rule;
|
|
|
var add_i=0;
|
|
|
var suit_rid;
|
|
|
-// 添加规则和添加条件
|
|
|
+
|
|
|
+
|
|
|
+ // 添加规则和添加条件
|
|
|
$(document).on('click','.add_rule_a', function() {
|
|
|
- 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);
|
|
|
+ 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);
|
|
|
+ }
|
|
|
});
|
|
|
+
|
|
|
|
|
|
|
|
|
// 编辑
|
|
@@ -272,7 +302,6 @@ $(function () {
|
|
|
// 显示隐藏
|
|
|
$(this).parent().parent().parent().children().eq(i).children().eq(1).hide();
|
|
|
$(this).parent().parent().parent().children().eq(i).children().eq(0).show();
|
|
|
-
|
|
|
}
|
|
|
|
|
|
}
|
|
@@ -325,11 +354,84 @@ $(function () {
|
|
|
async: false,//同步
|
|
|
success: function (data)
|
|
|
{
|
|
|
-// console.log(data);
|
|
|
+ console.log(data);
|
|
|
if(data.code==0){
|
|
|
// console.log(data);
|
|
|
rule_id = data.res[0].id;
|
|
|
+ for(let i=0;i<add_i;i++){
|
|
|
+ let number = $("#condition_number_"+i).val();
|
|
|
+ if(number!="" && number!=undefined){
|
|
|
+ condition_number.push([number]);
|
|
|
+ }
|
|
|
+ let that = $("#condition_that_"+i).val();
|
|
|
+ if(that!="" && that!=undefined){
|
|
|
+ condition_that.push([that]);
|
|
|
+ }
|
|
|
+ let url=http+"sku_condition/add";
|
|
|
+ let data_string = JSON.stringify({token:token,numName:number,name:that,id:rule_id});
|
|
|
+ $.ajax({
|
|
|
+ url: url,
|
|
|
+ type: "post",
|
|
|
+ dataType:"JSON",
|
|
|
+ data: data_string,
|
|
|
+ async: false,//同步
|
|
|
+ success: function (data)
|
|
|
+ {
|
|
|
+ if(data.code==0){
|
|
|
+ // console.log(data);
|
|
|
+ condition_id.push(data.res[0].id);
|
|
|
+ }else{
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ },
|
|
|
+ error:function (XMLHttpRequest) {
|
|
|
+ console.log("失败!");
|
|
|
+
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ }
|
|
|
+ // console.log(condition_number);
|
|
|
+ // console.log(condition_that)
|
|
|
+ let suit_html='';
|
|
|
+ let num=8;
|
|
|
+ for(let i=0;i<1;i++){
|
|
|
+ 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
|
|
|
+ }
|
|
|
+ for(let j=0;j<num;j++){
|
|
|
+ if(j==9){
|
|
|
+ suit_html=suit_html+ '<div class="rule_ rule_hr"></div>';
|
|
|
+ try{
|
|
|
+ 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>';
|
|
|
+ }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{
|
|
|
+ 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>'
|
|
|
+ + '<div class="rule_operate"><img style="margin-left: 10%; " src="img/delete@2x.png" class="remove" title="删除"></div>'
|
|
|
+ + '<div class="rule_save_div"><div class="rule_save">保存</div></div>'
|
|
|
+ + '</div>'
|
|
|
+ + '</div>';
|
|
|
+ }
|
|
|
+ add_rule.append(suit_html);
|
|
|
+ add_i=0; //重置为0
|
|
|
}else{
|
|
|
+ alert("该用户没有权限!");
|
|
|
return;
|
|
|
}
|
|
|
},
|
|
@@ -339,85 +441,15 @@ $(function () {
|
|
|
}
|
|
|
});
|
|
|
|
|
|
- for(let i=0;i<add_i;i++){
|
|
|
- let number = $("#condition_number_"+i).val();
|
|
|
- if(number!="" && number!=undefined){
|
|
|
- condition_number.push([number]);
|
|
|
- }
|
|
|
- let that = $("#condition_that_"+i).val();
|
|
|
- if(that!="" && that!=undefined){
|
|
|
- condition_that.push([that]);
|
|
|
- }
|
|
|
- let url=http+"sku_condition/add";
|
|
|
- let data_string = JSON.stringify({token:token,numName:number,name:that,id:rule_id});
|
|
|
- $.ajax({
|
|
|
- url: url,
|
|
|
- type: "post",
|
|
|
- dataType:"JSON",
|
|
|
- data: data_string,
|
|
|
- async: false,//同步
|
|
|
- success: function (data)
|
|
|
- {
|
|
|
- if(data.code==0){
|
|
|
-// console.log(data);
|
|
|
- condition_id.push(data.res[0].id);
|
|
|
- }else{
|
|
|
- return;
|
|
|
- }
|
|
|
- },
|
|
|
- error:function (XMLHttpRequest) {
|
|
|
- console.log("失败!");
|
|
|
-
|
|
|
- }
|
|
|
- });
|
|
|
-
|
|
|
- }
|
|
|
-// console.log(condition_number);
|
|
|
-// console.log(condition_that)
|
|
|
- let suit_html='';
|
|
|
- let num=8;
|
|
|
- for(let i=0;i<1;i++){
|
|
|
- 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
|
|
|
- }
|
|
|
- for(let j=0;j<num;j++){
|
|
|
- if(j==9){
|
|
|
- suit_html=suit_html+ '<div class="rule_ rule_hr"></div>';
|
|
|
- try{
|
|
|
- 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>';
|
|
|
- }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{
|
|
|
- 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>'
|
|
|
- + '<div class="rule_operate"><img style="margin-left: 10%; " src="img/delete@2x.png" class="remove" title="删除"></div>'
|
|
|
- + '<div class="rule_save_div"><div class="rule_save">保存</div></div>'
|
|
|
- + '</div>'
|
|
|
- + '</div>';
|
|
|
- }
|
|
|
- add_rule.append(suit_html);
|
|
|
- add_i=0; //重置为0
|
|
|
+
|
|
|
});
|
|
|
|
|
|
// 套装的显示隐藏
|
|
|
|
|
|
$(document).on('click','.suit_title', function() {
|
|
|
// console.log($(this).parent().parent().children().eq(1).is(':hidden'))
|
|
|
- if($(this).parent().parent().children().eq(1).is(':hidden')){
|
|
|
+ if($(this).parent().children().eq(1).children().is(':hidden')){
|
|
|
+ console.log($(this).parent().children().eq(1).children().html())
|
|
|
$(this).parent().parent().children().eq(1).show();
|
|
|
$(this).parent().children().eq(1).children().show();
|
|
|
// 切换图标
|
|
@@ -474,6 +506,17 @@ $(function () {
|
|
|
$('#rule_add_id').fadeOut(100);
|
|
|
$('#rule_add').slideUp(200);
|
|
|
});
|
|
|
+
|
|
|
+
|
|
|
+// 注销登录
|
|
|
+ $("#logout").on('click',function(){
|
|
|
+ //清空cookie
|
|
|
+ $.cookie("access_token", "", {expires: -1});
|
|
|
+ $.cookie("refresh_token", "", {expires: -1});
|
|
|
+ $.cookie("role_id", "", {expires: -1});
|
|
|
+ //回到首页
|
|
|
+ window.location.href = "sku_index.html";
|
|
|
+ });
|
|
|
});
|
|
|
|
|
|
|