|
- //一个页面的线路条数
- var pagesize = 10;
-
- //当前页数
- var currpage = 1;
-
- //线路id
- var line_id ="";
-
- //列表HTML
- var listHTML = '';
-
-
- var select_page = "1";
-
- //填坑
- var tiankeng = "";
-
- //从地址栏获取票种id(ticket_id)
- var ticket_id = getPar("ticket_id");
- var line_type = getPar("line_type");
-
-
- $(document).ready(function(){
- listHTML = $('#list').html();
- selectOnePage(1);
- });
-
-
- //根据票种id加载渠道商列表
-
- function selectOnePage(page){
-
- $.ajax({
- url:base_api+'lineManager/index.php', //请求地址
- data:{
- tp:"saleRule_getRuleList",
- ticket_id:ticket_id,
- line_type:line_type,
- current_page:page,
- page_size:pagesize
- },
- type: "post", //请求方式
- dataType: "json",
- async:false,
- success: function (data) {
- console.log(data);
- if(data.code == 0){
- totalpage = data.page.total_page;
- line_id = data.ticket_info.line_id;
- reloadData(data.station,data.ticket_info);
- if (totalpage == 0) {
- $('.pageDiv').hide();
- } else{
- createPage(currpage,totalpage);
- $('.pageDiv').show();
- }
- }else{
- ZZAlertInfo(data.info);
- }
-
- }
- });
- }
- function http_data(){
-
- $.ajax({
- url:base_api+'lineManager/index.php', //请求地址
- data:{
- tp:"saleRule_getRuleList",
- ticket_id:ticket_id,
- line_type:line_type,
- current_page:select_page,
- page_size:pagesize
- },
- type: "post", //请求方式
- dataType: "json",
- success: function (data) {
- console.log(data);
- if(data.code == 0){
- reloadData(data.station,data.ticket_info);
-
- }else{
- ZZAlertInfo(data.info);
- }
-
- }
- });
- }
-
- //替换列表数据
-
- function reloadData(data,index){
- var list = data;
- var newHTML = '';
-
-
- var temp = '<span>座位等级:</span>'
- + '<span style="margin-right: 40px;">'+index.seat_type_name+'</span>'
- + '<span>人群:</span>'
- + '<span style="margin-right: 40px;">'+index.human_type_name+'</span>'
- + '<span>零售价:</span>'
- + '<span style="margin-right: 40px;">'+index.cus_price+'</span>'
- + '<span>分销价:</span>'
- + '<span>'+index.prod_price+'</span>'
- $('#ticket_info').html(temp);
-
- for(var i=0;i<list.length;i++){
- var authority = "";
- var show_prod_price = "";
- var commision_flag = "";
- var font_color = "";
- if(list[i].sale_type=="177"){
- show_prod_price = list[i].prod_price;
- }else{
- show_prod_price = "-";
- }
- if(list[i].commision_flag=="1"){
- commision_flag = list[i].sale_rule;
- }else{
- commision_flag = "-";
- }
- if(list[i].authority_status=="0"){
- authority = "images/off.png";
- font_color = "#cccccc";
- }else{
- authority = "images/on.png";
- font_color = "#000000";
- }
- var tempHTML=listHTML;
- tempHTML=tempHTML.replace('[渠道商]',list[i].supplier_name);
- tempHTML=tempHTML.replace('#000000',font_color);
- tempHTML=tempHTML.replace('[销售方式]',list[i].sale_name);
- tempHTML=tempHTML.replace('[零售价]',list[i].cus_price);
- tempHTML=tempHTML.replace('[分销价]',show_prod_price);
- tempHTML=tempHTML.replace('[佣金规则]',commision_flag);
- tempHTML=tempHTML.replace('[oneCheckName]',list[i].supplier_id);
- tempHTML=tempHTML.replace('[supplier_id]',list[i].supplier_id);
- tempHTML=tempHTML.replace('images/off.png',authority);
- newHTML+=tempHTML;
- }
-
- $('#list').html(newHTML);
- }
-
-
- //创建分页控件
- function createPage(currpage,totalpage){
- $(".pageDiv").createPage({
- pageCount:totalpage,//总页数
- current:currpage,//当前页
- turndown:'true',//是否显示跳转框,显示为true,不现实为false,一定记得加上引号...
- backFn:function(p){
- select_page = p;
- $.ajax({
- url:base_api+'lineManager/index.php', //请求地址
- data:{
- tp:"saleRule_getRuleList",
- line_type:line_type,
- page_size:pagesize,
- current_page:p,
- ticket_id:ticket_id
- },
- type: "post",
- dataType: "json",
- async:false,
- success: function (data) {
- if(data.code == "0"){
- console.log(data);
- totalpage = data.page.total_page;
- reloadData(data.station,data.ticket_info);
- }else{
- ZZAlertInfo(data.info);
- }
- }
- });
- }
- });
- }
-
- //修改规则
- //function amend_regular(index){
- //
- // $.ajax({
- // url:base_api+'lineManager/index.php', //请求地址
- // data:{
- // tp:"saleRule_getRuleType"
- // },
- // type: "post", //请求方式
- // dataType: "json",
- //// async:false,
- // success: function (data) {
- // console.log(data);
- // if(data.code == 0){
- //
- // load_amend_base(data.saleType,data.define_type,data.back_commision_type,data.back_commision_method);
- //
- //
- // }else{
- // ZZAlertInfo(data.info);
- // }
- //
- // }
- // });
- //}
-
- //取消修改
- function cannel_amend(index){
- $(".amend_ticket_type").hide();
- }
-
- //复选框判断
- function select_checked(index) {
- //index=0最上面的全选 index=1表示的是下面所有的
- var cur_check = $('.ace_check')[0];
- var checkList = $('.ace_check');
- var checkCount = checkList.length - 1;
- var true_count = 0;
- for (var i = 1; i < checkList.length; i++) {
- if (index == '0') {
- checkList[i].checked = cur_check.checked;
- } else {
- if (checkList[i].checked == false) {
- cur_check.checked = false
- } else {
- true_count = true_count + 1;
- }
- }
- }
- //判断下面是否选中完
- if (checkCount == true_count) {
- cur_check.checked = true;
- }
- }
-
- //取复选框ticket_id
- function amend_regular(index){
- var ary = new Array();
- $('.ace_check').each(function(index, item) {
- if(this.checked && index != 0) {
- ary.push($(this).attr('name'));
- }
-
- });
- if(ary.length <= 0) {
- ZZAlertInfo('请勾选!!!');
- return;
- }
- var pro_str = ary.join(',');
- var data = {
- tp: "saleRule_getRuleBaseInfo",
- supplier_id: pro_str,
- ticket_id:ticket_id
- }
-
- $.ajax({
- url: base_api+'lineManager/index.php', //请求地址
- type: "post", //请求方式
- data: data,
- dataType: "json",
- success: function(data) {
- console.log(data);
- if(data.code == 0) {
- load_amend_base(data.saleType,data.define_type,data.back_commision_type,data.back_commision_method,data.base_info);
-
- }
- }
- });
- }
-
- //加载修改销售规则的基本信息
- function load_amend_base(data1,data2,data3,data4,data5){
- var saleType = "";
- var define_type = "";
- var back_commision_type = "";
- var back_commision_method = "";
- var authority_status = "";
- var choose_unit = "";
- if(data5.back_commision_method=="308"){
- choose_unit = "%";
- }else if(data5.back_commision_method=="335"){
- choose_unit = "元";
- }
- if(data5.authority_status=="0"){
- authority_status = "images/off.png";
- }else{
- authority_status = "images/on.png";
- }
- for(var i=0;i<data1.length;i++){
- saleType += '<option value="'+data1[i].type_id+'">'+data1[i].type_name+'</option>'
- }
- for(var i=0;i<data2.length;i++){
- define_type += '<option value="'+data2[i].type_id+'">'+data2[i].type_name+'</option>'
- }
- for(var i=0;i<data3.length;i++){
- back_commision_type += '<option value="'+data3[i].type_id+'">'+data3[i].type_name+'</option>'
- }
- for(var i=0;i<data4.length;i++){
- if(data4[i].type_id != 309){
- back_commision_method += '<option value="'+data4[i].type_id+'">'+data4[i].type_name+'</option>'
- }
- }
- $("#sale_type").html(saleType);
- $("#define_type").html(define_type);
- $("#back_commision_type").html(back_commision_type);
- $("#back_commision_method").html(back_commision_method);
- $("#sale_type").val(data5.sale_type);
- $("#is_rule").val(data5.commision_flag);
- $("#define_type").val(data5.commision_type);
- $("#authority_status").attr("src",authority_status);
- $("#back_commision_type").val(data5.back_commision_type);
- $("#back_commision_method").val(data5.back_commision_method);
- $("#unit").text(choose_unit);
- $("#sup_defind").text(data5.sale_rule);
- $("#prod_price").val(data5.prod_price);
- $("#back_commision_value").val(data5.back_commision_value);
- if(data5.sale_type=="177"){
- $("#prod").show();
- }else{
- $("#prod").hide();
- }
- if(data5.commision_flag=="1"){
- $("#define_type").show();
- $(".regulation").show();
- }else{
- $("#define_type").hide();
- $(".regulation").hide();
- }
- if(data5.commision_type=="304"){
- tiankeng = "chanping";
- $(".regulation").show();
- $(".regulation2").hide();
- }else{
- tiankeng = "qudao";
- $(".regulation").hide();
- $(".regulation2").show();
- }
- $(".amend_ticket_type").show();
- }
-
- //根据有无佣金规则显示、隐藏佣金规则
- function brokerage_type(index){
- if(tiankeng == "chanping"){
- if($(index).val()=="1"){
- $("#define_type").show();
- $(".regulation").show();
-
- }else{
- $("#define_type").hide();
- $(".regulation").hide();
-
- }
- }else{
- if($(index).val()=="1"){
- $("#define_type").show();
- $(".regulation2").show();
-
- }else{
- $("#define_type").hide();
- $(".regulation2").hide();
-
- }
- }
-
- }
-
- //根据销售规则显示、隐藏分销价
- function sell_type(index){
- if($(index).val()=="177"){
- $("#prod").show();
- }else{
- $("#prod").hide();
- }
- }
-
- //根据产品定义、渠道定义
-
- function definition(index){
- if($(index).val()=="304"){
- tiankeng = "chanping";
- $(".regulation").show();
- $(".regulation2").hide();
- }else{
- tiankeng = "qudao";
- $(".regulation").hide();
- $(".regulation2").show();
- }
-
- }
-
-
- //改变授权状态
- function choose_state(index){
- var supplier_id = $(index).attr("supplier_id");
- var status = "";
- var status_img = $(index).attr("src");
- if(status_img=="images/off.png"){
- status = "1";
- }else{
- status = "0";
- }
- $.ajax({
- url:base_api+'lineManager/index.php', //请求地址
- data:{
- tp:"saleRule_updateAuthorize",
- ticket_list:ticket_id,
- supplier_id:supplier_id,
- line_id:line_id,
- authority_status:status
- },
- type: "post", //请求方式
- dataType: "json",
- success: function (data) {
- console.log(data);
- if(data.code == 0){
-
- http_data();
-
- }else{
- ZZAlertInfo(data.info);
- }
-
- }
- });
- }
-
-
- //根据结算金额、销售金额改变单位
- function choose_unit(index){
- if($(index).val()=="308"){
- $("#unit").text("%");
- }else if($(index).val()=="335"){
- $("#unit").text("元");
- }
- }
-
-
- //保存修改
- function submit_amend(){
- var ary = new Array();
- $('.ace_check').each(function(index, item) {
- if(this.checked && index != 0) {
- ary.push($(this).attr('name'));
- }
-
- });
- if(ary.length <= 0) {
- ZZAlertInfo('请勾选!!!');
- return;
- }
- var pro_str = ary.join(',');
- var _sale_type = $("#sale_type").val();
- var _prod_price = "";
- var _cut_img = "";
- if($("#authority_status").attr("src")=="images/on.png"){
- _cut_img = "1";
- }else{
- _cut_img = "0";
- }
-
- if(_sale_type=="177"){
- _prod_price = $("#prod_price").val();
- }else{
- _prod_price = "0";
- }
- var _is_rule = $("#is_rule").val();
- var _define_type = $("#define_type").val();
- var _commision_type = $("#back_commision_type").val();
- var _commision_methed = $("#back_commision_method").val();
- var _back_value = $("#back_commision_value").val();
-
- var data = {
- tp: "saleRule_updateRule",
- supplier_list: pro_str,
- ticket_list: ticket_id,
- line_id: line_id,
- sale_type: _sale_type, //销售方式
- prod_price: _prod_price, //(分销价)
- is_rule: _is_rule, //是否有佣金规则 1:有,0:无
- authority_status: _cut_img, //授权开关 0:关 1:开
- define_type: _define_type, //佣金规则类型
- commision_type: _commision_type, //返佣类别
- commision_methed: _commision_methed, //返佣方式
- back_value: _back_value //值
- }
-
- $.ajax({
- url: base_api+'lineManager/index.php', //请求地址
- type: "post", //请求方式
- data: data,
- dataType: "json",
- success: function(data) {
- console.log(data);
- if(data.code == 0) {
- ZZAlertInfo("修改成功!");
-
- http_data();
-
- $(".amend_ticket_type").hide();
-
- }else{
- ZZAlertInfo(data.info);
- }
- }
- });
-
- }
-
- function cut_img(index){
- if($(index).attr("src")=="images/on.png"){
- $(index).attr("src","images/off.png")
- }else{
- $(index).attr("src","images/on.png")
- }
- }
|