|
- /**
- * Created by luocj on 2016/10/26.
- */
- var input_time = '';
- var baseHTML = '';
- var childHTML = '';
- var firstDate = '';
- var d1 = "";
- var d2 = "";
- var d3 = "";
- var d4 = "";
- var d5 = "";
- var d6 = "";
- var d7 = "";
- var w1 = "";
- var w2 = "";
- var w3 = "";
- var w4 = "";
- var w5 = "";
- var w6 = "";
- var w7 = "";
- var check_distrib_id = '';
- // 房型售卖状态
- var room_sale_status = "-1";
- var hotel_id = '';
- var room_type_id = '';
- var room_type_name = '';
- var parent_room_type = '';
- var hotel_name = '';
- var tr_sale_rule_str = ''; //获取需要替换的所有代码
- var page_size = '10';
- var current = '1';
- window.onload = function () {
- hotel_id = getPar('hotel_id');
- room_type_id = getPar('room_type_id');
- room_type_name = getPar('room_type_name');
- parent_room_type = getPar('parent_room_type');
- document.getElementById("room_name").innerHTML = room_type_name;
- tr_sale_rule_str = $('.base').prop('outerHTML');
- setTbTopTd();
- addEvent();
- batchAddEvent();
- showDialog();
- current = '1';
- getSaleRuleInfo();
- // 点击蒙板
- $('#mask').bind('click', function () {
- clickMask();
- })
- to_fenxiao_lingshou();
- playPermission();
- }
-
- function replace(num) {
- if (num == 0) {
-
- // tempDict
-
- tempHtml = tempHtml.replace('[分销商名称]', '');
- tempHtml = tempHtml.replace('已售[' + 1 + '00]', "");
- tempHtml = tempHtml.replace('剩余[' + 1, "]");
- tempHtml = tempHtml.replace('分销价:[' + 1 + '00]', "");
-
- }
- var array1 = null;
- var nums1 = []; //保存第一个表格按,拆分后的所有值
- if (tempDict["date" + num] == "" || tempDict["date" + num] == null) {
- tempHtml = tempHtml.replace("[is_need_delete" + num + "]", "");
- }
- if (tempDict["date" + num] != null) {
- array1 = tempDict["date" + num].split(","); //第一个表格数据
-
- for (var j = 0; j < array1.length; j++) {
- if (array1[j] != "") {
- nums1.push(array1[j]);
- }
-
- }
- }
- var status = tempDict["authority_status"];
- if (status == "0") {
- tempHtml = tempHtml.replace('isopen="1"', 'isopen="0"');
- tempHtml = tempHtml.replace('images/OnSwitch.png', 'images/OffSwitch.png');
- } else if (status == "1") {
- tempHtml = tempHtml.replace('isopen="0"', 'isopen="1"');
- tempHtml = tempHtml.replace('images/OffSwitch.png"', 'images/OnSwitch.png"');
- } else { //当没有取到的时候,默认是没有授权
- tempHtml = tempHtml.replace('isopen="1"', 'isopen="0"');
- tempHtml = tempHtml.replace('images/OnSwitch.png', 'images/OffSwitch.png');
- }
-
- tempHtml = tempHtml.replace('[room-type]', tempDict['distrib_id']);
- tempHtml = tempHtml.replace('[distrib_id]', tempDict['distrib_id']);
- tempHtml = tempHtml.replace('[distrib_type]', tempDict['sale_type']);
- tempHtml = tempHtml.replace('[分销商名称]', tempDict['distrib_name']);
- $("#table :checkbox").prop("checked", false);
- //是否超卖
- var sellStatus = '';
- if (nums1[4] == '329') {
- sellStatus = '<span class="remaining" style="float: right;">关房</span>'
- }
- // ZZLog(nums1);
- tempHtml = tempHtml.replace("已售[" + num + "00]", "已售" + nums1[0] + sellStatus);
- //是否超卖
- var overSell = '';
- if (nums1[2] == 1) {
- overSell = '<span class="overSell" style="float:right;"> </span>'
- }
- tempHtml = tempHtml.replace("剩余[" + num + "]", "剩余" + nums1[1] + overSell);
- tempHtml = tempHtml.replace("[" + num + "00]", nums1[3]);
- ZZLog(nums1[nums1.length - 1]);
- if (tempDict['sale_type'] == '312') {//312为直营 1772为分销
- tempHtml = tempHtml.replace("[分销价" + num + "]", "零售价");
- } else if (tempDict['sale_type'] == '177') {
- tempHtml = tempHtml.replace("[分销价" + num + "]", "分销价");
- }
-
- // if (tempDict['price_remark']=='2'){
- //
- // }else if(tempDict['price_remark']=='1'){
- // tempHtml = tempHtml.replace("分销价:[" + num + "00]", "零售价:" + nums1[nums1.length - 1]);
- // }
-
- // ZZLog(nums1);
- // ZZLog('当前状态值:' + nums1[0] + ' ' + nums1[1]);
- // if (nums1[0] == '326') {
- // tempHtml = tempHtml.replace('[images/img_gongxiang.png]', "images/img_baoliu.png");
- // } else if (nums1[0] == '327') {
- // tempHtml = tempHtml.replace('[images/img_gongxiang.png]', "images/img_gongxiang.png");
- // } else if (nums1[0] == '329') {
- // tempHtml = tempHtml.replace('[images/img_gongxiang.png]', "images/img_manfang.png");
- // } else if (nums1[0] == '328') {
- // tempHtml = tempHtml.replace('[images/img_gongxiang.png]', "images/229.png");
- // } else {
- // tempHtml = tempHtml.replace('[images/img_gongxiang.png]', "images/aa.png");
- // }
-
- }
- var tempDict;
-
- var tempHtml;
- var distrib_id_array = [];
- function getSaleRuleInfo() {
- var para_distrib_name = $('#div_name').val();
- var para_start_date = $('#input_time').val();
- if (para_start_date == '') {
- para_start_date = getDateTime(0);
- }
- var apiurl = base_api;
-
- var param = {
- type: "hotel_SaleRuleInfo",
- para_hotel_id: hotel_id,
- para_base_room_type: parent_room_type,
- para_room_type: room_type_id,
- para_distrib_name: para_distrib_name,
- para_start_date: para_start_date,
- op: "getSaleRule",
- current: current,
- page_size: page_size
- };
- ZZLog(param);
- $.ajaxSetup({
- async: false
- });
- loading();
- $.ajax({
- type: "post",
- url: apiurl,
- data: param,
- dataType: "json",
- success: function (res_data) {
- ZZLog(res_data);
- var areaHtml = '';
- var sale_list = res_data['result'];
- if (sale_list.length != 0) {
- $('#room_list').css('visibility', 'visible');
- }
- if (sale_list.length == 0) {
- replace(0);
- }
- for (var i = 0, m = sale_list.length; i < m; i++) {
- tempDict = sale_list[i]; //获取到每一个对象
- tempHtml = tr_sale_rule_str;
- var distrib_id = tempDict['distrib_id'];
- distrib_id_array[distrib_id_array.length] = distrib_id;
- for (var k = 1; k < 8; k++) {
- replace(k);
-
- }
- areaHtml += tempHtml;
-
- }
- $('#room_list').html(areaHtml);
- if (res_data['total'] < 1) {
- $('.pageDiv').hide();
- } else {
- $(".pageDiv").createPage({
- pageCount: res_data['total_page'],//总页数
- current: current,//当前页
- turndown: 'true',//是否显示跳转框,显示为true,不现实为false,一定记得加上引号...
- backFn: function (p) {
- current = p;
- getSaleRuleInfo();
- }
- });
- $('.pageDiv').show();
- }
- $('.change').each(function (index, domEle) {
- if ($(this).attr('is_need_delete') == "") {
- $(this).css('background', '');
- $(this).css('text-align', 'center');
- $(this).css('vertical-align', 'middle');
- $(this).html('暂无');
- }
- });
- cdayAddEvent();
- closeLoading();
- }, error: function (error) {
- ZZLog(error);
- closeLoading();
- }
- });
- $.ajaxSetup({
- async: true
- });
- }
- function showDialog() {
- $('#updateAll').unbind('click');
- $('#updateAll').bind('click', function () {
- input_time = $('#input_time').val();
- $('#start_date_update').val(input_time);
- $('#end_date_update').val(getDateByDay(6, input_time));
- if (check_distrib_id.length == 0) { //没有选中的情况,弹出提示框
- alert('请选中需要批量修改的渠道商!');
- return;
- }
- //$('#one').css('display','block');
- $('#mask').css('background', 'white');
- $('#mask').css('opacity', '0.5');
- $("#authorized_stock_num_many").val('');
- $("#distribution_price_many").val('');
- $("#retail_price_many").val('');
- showCenterView('#one');
-
- });
- }
-
- // 将目标节点居中显示
- var $tempShowView = null;
-
- function showCenterView(classOrIdName) {
- $('#mask').css('display', 'block');
- $('#mask').css('z-index', '15');
- $showView = $(classOrIdName);
- $tempShowView = $showView;
- $showView.css('display', 'block');
- $showView.css('position', 'absolute');
- $showView.css('top', '50%');
- $showView.css('left', '50%');
- $showView.css('z-index', '20');
- $showView.css('background', 'white');
- var w = $showView.css('width');
- var h = $showView.css('height');
- w = w.substr(0, w.length - 2);
- h = h.substr(0, h.length - 2);
- $showView.css('margin-top', '-' + h / 2 + 'px');
- $showView.css('margin-left', '-' + w / 2 + 'px');
- }
- // 点击蒙板
- function clickMask() {
- if ($temp_cday) {
- $('#up_base_room').css('display', 'none');
- $temp_cday.css('background', '');
- }
-
- $('#mask').css('display', 'none');
- }
-
- function doclick_close() {
- $('#one').css('display', 'none');
- clickMask();
-
- }
-
- function doclick_save() {
- var startDate = $('#start_date_update').val();
- var endDate = $('#end_date_update').val();
- var checkList = $('.checkbox_date');
- var allCheckString = ""; //para_week_day,存储过程中的参数
- var authorizedStock = $('#authorized_stock_many').val();
- var authorizedStockNum = $('#authorized_stock_num_many').val();
- var distributionPrice = $('#distribution_price_many').val();
- //alert('distributionPrice:'+distributionPrice);
- var retailPrice = $('#retail_price_many').val();
- var overSaleBatch = $("input[name='overSaleBatch']:checked").val();
-
-
- for (var i = 2; i < checkList.length + 2; i++) {
- //alert(checkList[i-2].checked);
- if (checkList[i - 2].checked) { //如果满足条件
- if (i == checkList.length + 1) {
- allCheckString += 1;
- } else {
- allCheckString += i;
- }
-
- }
- }
- if (startDate == "" || endDate == "" || allCheckString == "" || authorizedStock == "" || authorizedStockNum == "" || distributionPrice == "" || retailPrice == "") {
- alert('您还有未输入的选项!');
- // alert('startDate:'+startDate);
- // alert('endDate:'+endDate);
- // alert('allCheckString:'+allCheckString);
- // alert('authorizedStock:'+authorizedStock);
- // alert('authorizedStockNum:'+authorizedStockNum);
- // alert('distributionPrice:'+distributionPrice);
- // alert('retailPrice:'+retailPrice);
- return;
- }
-
- if (isNaN(authorizedStockNum) || isNaN(distributionPrice) || isNaN(retailPrice)) {
- ZZAlertInfo('数据格式不正确');
- return;
- }
- // in para_user_id int, in para_hotel_id int, in para_base_room_type int, in para_room_type int, in para_distrib_list varchar(2000),in para_start_date varchar(20), in para_end_date varchar(20), in para_week_day varchar(10), in para_stock_type int, in para_stock_num int, in para_prod_price decimal(10,2), in para_cus_price decimal(10,2)
- var urlapi = base_api;
- var param = {
- type: "hotel_SaleRuleInfo",
- op: "updateAuthorizeInfo",
- para_user_id: 1,
- para_hotel_id: hotel_id,
- para_base_room_type: parent_room_type,
- para_room_type: room_type_id,
- para_distrib_list: check_distrib_id,
- para_start_date: startDate,
- para_end_date: endDate,
- para_week_day: allCheckString,
- para_stock_type: authorizedStock,
- para_stock_num: authorizedStockNum,
- para_prod_price: distributionPrice,
- para_cus_price: retailPrice,
- para_over_sale: overSaleBatch
- };
- ZZLog(urlapi + JSON.stringify(param));
- $("#batch_save").html('保存中');
- $('#batch_save').css('background-color', 'darkgray');
- loading();
- $.ajax({
- url: urlapi,
- data: param,
- type: "post",
- dataType: "json",
- success: function (res_data) {
- closeLoading();
- ZZLog(res_data);
- if (res_data['code'] != "0") {
- ZZAlertInfo(res_data['info']);
- } else {
- //alert('成功了!');
- //重新加载页面
- getSaleRuleInfo();
- }
- $("#batch_save").val('保存');
- $('#batch_save').css('background', '#428bca');
- },
- error: function (msg) {
-
- $("#batch_save").val('保存');
- $('#batch_save').css('background', '#428bca');
- closeLoading();
- }
- })
- $('#one').css('display', 'none');
- clickMask();
- }
-
- var $temp_cday = null;
- var number = null;
- var distrib_id_checkd = null;
- var distrib_type = null;
- function cdayAddEvent(obj) {
- distrib_id_checkd = $(obj).parent().attr('data-distrib-id');
- distrib_type = $(obj).parent().attr('data-distrib-type');
- var num = $(obj).attr('date_num'); //当前点击的是第几天
- var stock = $(obj).children().children().children('.has_sell').text().trim();
- var sell = $(obj).children().children().children('.remaining').text().trim();
- var price = $(obj).children().children().children('.distribution_price').text().trim();
- stock = stock.substr(2);
- sell = sell.substr(2);
- var price_type = price.substr(0, 3);
- price = price.substr(4);
- $('#authorized_stock_num').val(parseInt(stock) + parseInt(sell));
- if (distrib_type == '177') {
- $('#distribution_price').val(parseFloat(price));
- $('#retail_price').val('0');
- $('#lingshou_name').hide();
- $('#lingshou_price').hide();
- $('#fenxiao_name').show();
- $('#fenxiao_price').show();
- } else if (distrib_type == '277' || distrib_type == '312') {
- $('#retail_price').val(parseFloat(price));
- $('#distribution_price').val('0');
- $('#lingshou_name').show();
- $('#lingshou_price').show();
- $('#fenxiao_name').hide();
- $('#fenxiao_price').hide();
- }
- number = num;
- $('.change').bind('click', function () {
- //需要获取最大间数提示
- var _td_date = $('.tb_title').children().eq(number).attr('f_date'); //当前点击的日期
- //alert(_td_date);return;
- var startDate = _td_date;
- var endDate = _td_date;
- var urlapi = base_api;
-
- var param = {
- type: "hotel_SaleRuleInfo",
- op: "getMaxStockNumber",
- para_hotel_id: hotel_id,
- para_base_room_type: parent_room_type,
- para_room_type: room_type_id,
- para_start_date: startDate,
- para_end_date: endDate,
- para_distrib_list: distrib_id_checkd
- };
- // alert(urlapi + JSON.stringify(param));
- ZZLog(urlapi + JSON.stringify(param));
- //alert('333');
- $.ajax({
- url: urlapi,
- data: param,
- type: "post",
- dataType: "json",
- success: function (res_data) {
- $("#max_stock").html(res_data)
- },
- error: function (msg) {
-
- }
- })
- if ($(this).attr('is_need_delete') == "") {
- return;
- }
- $('#mask').css('display', 'block');
- $('#mask').css('background', 'white');
- $('#mask').css('opacity', '0');
- if ($temp_cday != null) {
- $temp_cday.css('background', '');
- }
-
- // 得到鼠标的位置
- var mouseLeft = $(this).offset().left;
- var mouseTop = $(this).offset().top;
- var td_height = parseInt($(this).css('height').replace('px', ''));
- $(this).css('background', '#ddd');
- $('#up_base_room').css('top', mouseTop + td_height + 'px');
- $('#up_base_room').css('display', 'block');
- $('#up_base_room').attr('')
-
- //
- $temp_cday = $(this);
- })
- }
-
-
- function todayOnclick() {
-
- d1 = getDateTime(0);
- setTbTopTd();
- current = '1'
- getSaleRuleInfo();
- }
-
- function beforeOnclick() {
- d1 = getDateByDay(-7, d1);
- setTbTopTd();
- current = '1'
- getSaleRuleInfo();
- }
-
- function afterOnclick() {
- d1 = getDateByDay(7, d1);
- setTbTopTd();
- current = '1'
- getSaleRuleInfo();
- }
- // 将目标节点居中显示
- var $tempShowView = null;
-
- function showCenterView(classOrIdName) {
- $('#mask').css('display', 'block');
- $('#mask').css('z-index', '15');
- $showView = $(classOrIdName);
- $tempShowView = $showView;
- $showView.css('display', 'block');
- $showView.css('position', 'absolute');
- $showView.css('top', $(window).height() / 2.2);
- $showView.css('left', '50%');
- $showView.css('z-index', '20');
- $showView.css('background', 'white');
- var w = $showView.css('width');
- var h = $showView.css('height');
- w = w.substr(0, w.length - 2);
- h = h.substr(0, h.length - 2);
- $showView.css('margin-top', '-' + h / 2 + 'px');
- $showView.css('margin-left', '-' + w / 2 + 'px');
- }
- // 点击蒙板
- function clickMask() {
- if ($temp_cday) {
- $('#up_base_room').css('display', 'none');
- $temp_cday.css('background', '');
- }
- if ($tempShowView) {
- $('.main_style').css('display', 'none');
- $tempShowView.css('background', '');
- }
- $('#mask').css('display', 'none');
- $("#one").hide();
- }
-
- // 设置表格头部的td
- function setTbTopTd() {
- // 设置标题的日期和星期
- var today = getDateTime(0);
- if (d1 == "") {
- d1 = today;
- }
- $('#input_time').val(d1);
- d2 = after(d1);
- d3 = after(d2);
- d4 = after(d3);
- d5 = after(d4);
- d6 = after(d5);
- d7 = after(d6);
- w1 = getWeekDay(d1);
- w2 = getWeekDay(d2);
- w3 = getWeekDay(d3);
- w4 = getWeekDay(d4);
- w5 = getWeekDay(d5);
- w6 = getWeekDay(d6);
- w7 = getWeekDay(d7);
- //alert(d1+" "+d2+" "+d3+" "+d4+" "+d5+" "+d6+""+d7);
- $('#day1').attr('date_num', d1);
- $('#day2').attr('date_num', d2);
- $('#day3').attr('date_num', d3);
- $('#day4').attr('date_num', d4);
- $('#day5').attr('date_num', d5);
- $('#day6').attr('date_num', d6);
- $('#day7').attr('date_num', d7);
-
- $('#f_date1').attr('f_date', d1);
- $('#f_date2').attr('f_date', d2);
- $('#f_date3').attr('f_date', d3);
- $('#f_date4').attr('f_date', d4);
- $('#f_date5').attr('f_date', d5);
- $('#f_date6').attr('f_date', d6);
- $('#f_date7').attr('f_date', d7);
-
- var td1 = d1.substring(5);
- var td2 = d2.substring(5);
- var td3 = d3.substring(5);
- var td4 = d4.substring(5);
- var td5 = d5.substring(5);
- var td6 = d6.substring(5);
- var td7 = d7.substring(5);
-
- $('#f_date1').html(td1 + "</br>" + w1);
- $('#f_date2').html(td2 + "</br>" + w2);
- $('#f_date3').html(td3 + "</br>" + w3);
- $('#f_date4').html(td4 + "</br>" + w4);
- $('#f_date5').html(td5 + "</br>" + w5);
- $('#f_date6').html(td6 + "</br>" + w6);
- $('#f_date7').html(td7 + "</br>" + w7);
- // 将日期为今天的星期设置为今天
- $('th[f_date=' + getDateTime(0) + ']').html(getDateTime(0).substring(5) + '</br>今天');
- }
- var true_count = 0;
- // 复选框事件
- function select_checked(index, selfOBJ) {
- $selfOBJ = $(selfOBJ);
- //index=0最上面的全选 index=1表示的是下面所有的
- var cur_check = $('.ace')[0];
- var checkList = $('.ace');
- var checkCount = checkList.length - 1;
-
- if (index == '0') {
- if (selfOBJ.checked) {
- check_distrib_id.splice(0, check_distrib_id.length);
- for (var i = 0; i < distrib_id_array.length; i++) {
- check_distrib_id[check_distrib_id.length] = distrib_id_array[i];
- }
-
- true_count = checkList.length - 1;
- selfOBJ.checked = true;
- } else {
- check_distrib_id.splice(0, check_distrib_id.length);
- true_count = 0;
- selfOBJ.checked = false;
- }
- } else if (index == '1') {
-
- if (selfOBJ.checked) {
- true_count++;
- var $par_tr = $(selfOBJ).closest('tr');
- var distrib_id = $par_tr.attr('data-distrib-id');
- if (check_distrib_id.indexOf(distrib_id) == -1) {
- check_distrib_id[check_distrib_id.length] = distrib_id;
- }
-
- } else {
- // 当前的base为选中
- true_count--;
- var par_tr = $(selfOBJ).closest('tr');
- var distrib_id = par_tr.attr('data-distrib-id');
- check_distrib_id.remove(distrib_id);
- }
- //alert(true_count);
-
- }
- //alert(check_distrib_id);
- for (var i = 1, m = checkList.length; i < m; i++) {
- if (index == '0') {
- checkList[i].checked = cur_check.checked;
- }
- }
- //alert(true_count);
- if (checkCount == true_count) {
- cur_check.checked = true;
- } else {
- cur_check.checked = false;
- }
-
- }
-
- Array.prototype.indexOf = function (val) {
- for (var i = 0; i < this.length; i++) {
- if (this[i] == val) return i;
- }
- return -1;
- };
-
- Array.prototype.remove = function (val) {
- var index = this.indexOf(val);
- if (index > -1) {
- this.splice(index, 1);
- }
- };
-
- //更换图片
- function image_onclick(obj) {
- var $par_tr = $(obj).closest('tr');
- var distrib_id = $par_tr.attr('data-distrib-id');
- if ($(obj).attr('isopen') == "0") { //变成打开授权状态
- $(obj).attr('isopen', "1");
- $(obj).attr('src', "images/OnSwitch.png");
- //alert("distrib_id:"+distrib_id+" hotel_id:"+hotel_id+" parent_room_type"+parent_room_type+" room_type_id"+room_type_id);
- var apiurl = base_api + "?type=hotel_SaleRuleInfo&authorize_status=" + 1 + "&hotel_id=" + hotel_id + "&parent_room_type=" + parent_room_type + "&room_type=" + room_type_id + "&op=updateAuthorizeStatus&distrib_id_string=" + distrib_id;
- ZZLog(apiurl);
- //alert('123');
- $.getJSON(apiurl, function (res_data) {
- //alert("awefawfawefwaf");
- //console.log("数据:"+res_data);
-
- }).error(function (msg) {
-
- })
- } else {
- $(obj).attr('isopen', "0");
- $(obj).attr('src', "images/OffSwitch.png");
- var apiurl = base_api + "?type=hotel_SaleRuleInfo&authorize_status=" + 0 + "&hotel_id=" + hotel_id + "&parent_room_type=" + parent_room_type + "&room_type=" + room_type_id + "&op=updateAuthorizeStatus&distrib_id_string=" + distrib_id;
- ZZLog(apiurl);
- //alert('345');
- $.getJSON(apiurl, function (res_data) {
- //alert("awefawfawefwaf");
- ZZLog("数据:" + res_data);
-
- })
- }
-
- //
- // if(document.getElementById("image").getAttribute("src") == "images/OffSwitch.png") {
- // document.getElementById("image").src = "images/On Switch.png";
- // } else {
- // document.getElementById("image").src = "images/OffSwitch.png";
- // }
-
- }
-
- //同时更改所有选中的分销商授权状态
- function openStatus() {
- if (check_distrib_id.length == 0) { //没有选中的情况,弹出提示框
- alert('请选中需要开启授权的项!');
- return;
- }
- var distrib_id_string = unionBySeprator(check_distrib_id);
- var apiurl = base_api + "?type=hotel_SaleRuleInfo&authorize_status=" + 1 + "&hotel_id=" + hotel_id + "&parent_room_type=" + parent_room_type + "&room_type=" + room_type_id + "&op=updateAuthorizeStatus&distrib_id_string=" + distrib_id_string;
- ZZLog(apiurl);
- loading();
- $.getJSON(apiurl, function (res_data) {
- //alert("awefawfawefwaf");
- //console.log("数据:"+res_data);
- getSaleRuleInfo();
- closeLoading();
- })
- }
-
- //把数组的所有元素以逗号分隔,返回该字符串
- function unionBySeprator(check_distrib_id) {
- if (check_distrib_id.length == 0) {
- return "";
- }
- var result_string = "";
- for (var i = 0; i < check_distrib_id.length; i++) {
- result_string += ',';
- result_string += check_distrib_id[i];
- }
- return result_string.substr(1, result_string.length);
- }
-
- function closeStatus() {
- if (check_distrib_id.length == 0) { //没有选中的情况,弹出提示框
- alert('请选中需要关闭授权的项!');
- return;
- }
- var distrib_id_string = unionBySeprator(check_distrib_id);
- var apiurl = base_api + "?type=hotel_SaleRuleInfo&authorize_status=" + 0 + "&hotel_id=" + hotel_id + "&parent_room_type=" + parent_room_type + "&room_type=" + room_type_id + "&op=updateAuthorizeStatus&distrib_id_string=" + distrib_id_string;
- ZZLog(apiurl);
- loading();
- $.getJSON(apiurl, function (res_data) {
- //alert("awefawfawefwaf");
- //console.log("数据:"+res_data);
- getSaleRuleInfo();
- closeLoading();
- })
- }
-
- //以下3个方法是确保输入框只能输入数字和1个逗号
- function check(event) {
- var e = window.event || event;
- var target = e.srcElement || e.target;
- var k = e.keyCode;
- if (isFunKey(k)) {
- return true;
- }
- var c = getChar(k);
- if (target.value.length == '' && (c == '-' || c == '+')) {
- return true;
- }
- if (isNaN(target.value + getChar(k))) {
- return false;
- }
- return true;
- }
-
- function isFunKey(code) {
- // 8 --> Backspace
- // 35 --> End
- // 36 --> Home
- // 37 --> Left Arrow
- // 39 --> Right Arrow
- // 46 --> Delete
- // 112~123 --> F1~F12
- var funKeys = [8, 35, 36, 37, 39, 46];
- for (var i = 112; i <= 123; i++) {
- funKeys.push(i);
- }
- for (var i = 0; i < funKeys.length; i++) {
- if (funKeys[i] == code) {
- return true;
- }
- }
- return false;
- }
-
- function getChar(k) {
- if (k >= 48 && k <= 57) {
- return String.fromCharCode(k);
- }
- if (k >= 96 && k <= 105) {
- return String.fromCharCode(k - 48);
- }
- if (k == 110 || k == 190) {
- return ".";
- }
- if (k == 109 || k == 189) {
- return "-";
- }
- if (k == 107 || k == 187) {
- return "+";
- }
- return "#";
- }
-
- //点击搜索,重新查找匹配条件的数据
- function searchOnclick() {
- d1 = $('#input_time').val();
- setTbTopTd();
- //alert('2222');
- showDialog();
- //alert('awef');
- current = '1'
- getSaleRuleInfo();
- }
-
- function cancelUpdate() {
- clickMask();
- }
-
- //点击弹出层的提交按钮事件
- function saveUpdate() {
- //alert(new Date(d1).getDay()); //当前页面上第一天是星期几
- //当前点击的是第number个日期,可以获取到具体的日期
- //alert(number);
- var _td_date = $('.tb_title').children().eq(number).attr('f_date'); //当前点击的日期
- //alert(_td_date);return;
- var startDate = _td_date;
- var endDate = _td_date;
- var allCheckString = "2345671"; //para_week_day,存储过程中的参数
- var authorizedStock = $('#base_stock_type').val();
- var authorizedStockNum = $('#authorized_stock_num').val();
- var distributionPrice = $('#distribution_price').val() == '' ? 0 : $('#distribution_price').val();
- var retailPrice = $('#retail_price').val() == '' ? 0 : $('#retail_price').val();
- var overSaleOne = $("input[name='overSale']:checked").val();
-
- if (startDate == "" || endDate == "" || allCheckString == "" || authorizedStock == "" || authorizedStockNum == "") {
- alert('您还有未输入的选项!');
- return;
- }
- if (distributionPrice == "" && retailPrice == "") {
- alert('您还有未输入的选项!');
- // alert('startDate:'+startDate);
- // alert('endDate:'+endDate);
- // alert('allCheckString:'+allCheckString);
- // alert('authorizedStock:'+authorizedStock);
- // alert('authorizedStockNum:'+authorizedStockNum);
- // alert('distributionPrice:'+distributionPrice);
- // alert('retailPrice:'+retailPrice);
- return;
- }
- if (isNaN(retailPrice)) {
- ZZAlertInfo('金额格式不正确');
- return;
- }
-
- //alert('222');
- // in para_user_id int, in para_hotel_id int, in para_base_room_type int, in para_room_type int, in para_distrib_list varchar(2000),in para_start_date varchar(20), in para_end_date varchar(20), in para_week_day varchar(10), in para_stock_type int, in para_stock_num int, in para_prod_price decimal(10,2), in para_cus_price decimal(10,2)
-
- var urlapi = base_api;
- var param = {
- type: "hotel_SaleRuleInfo",
- op: "updateAuthorizeInfo",
- para_user_id: 1,
- para_hotel_id: hotel_id,
- para_base_room_type: parent_room_type,
- para_room_type: room_type_id,
- para_distrib_list: distrib_id_checkd,
- para_start_date: startDate,
- para_end_date: endDate,
- para_week_day: allCheckString,
- para_stock_type: authorizedStock,
- para_stock_num: authorizedStockNum,
- para_prod_price: distributionPrice,
- para_cus_price: retailPrice,
- para_over_sale: overSaleOne
- };
- // alert(urlapi + JSON.stringify(param));
- ZZLog(urlapi + JSON.stringify(param));
-
- $("#one_save").html('保存中');
- $('#one_save').css('background', 'darkgray');
- loading();
- $.ajax({
- url: urlapi,
- data: param,
- type: "post",
- dataType: "json",
- success: function (res_data) {
- closeLoading();
- ZZLog(res_data);
- if (res_data['code'] != "0") {
- ZZAlertInfo(res_data['info']);
- } else {
- //alert(res_data);
- getSaleRuleInfo();
- ZZAlertInfo('修改成功');
- }
- $("#one_save").html('保存');
- $('#one_save').css('background', '#428bca');
- },
- error: function (msg) {
- $("#one_save").html('保存');
- $('#one_save').css('background', '#428bca');
- closeLoading();
- }
- })
-
-
- $('#one').css('display', 'none');
- clickMask();
- }
-
- function cannot_input_fenxiao() {
- if ($('#distribution_price') != '') {
- $('#retail_price').val('0');
- }
- }
- function cannot_input_lingshou() {
- if ($('#retail_price') != '') {
- $('#distribution_price').val('0');
- }
- }
- function cannot_input_fenxiao_many() {
- if ($('#distribution_price_many') != '') {
- //$('#retail_price_many').val('0');
- }
- }
- function cannot_input_lingshou_many() {
- if ($('#retail_price_many') != '') {
- //$('#distribution_price_many').val('0');
- }
- }
- //选择共享库存则间数变0且不能修改
- function addEvent() {
- $('#base_stock_type').on('change', function () {
- if ($(this).val() == '327') {//共享库存
- $('#count_input').css("visibility", "hidden");
- $('#authorized_stock_num').val('0');
- } else if ($(this).val() == '328') {//人工确认
- $('#count_input').css("visibility", "hidden");
- $('#authorized_stock_num').val('999');
- } else if ($(this).val() == '329') {//人工确认
- $('#count_input').css("visibility", "hidden");
- $('#authorized_stock_num').val('0');
- } else {
- $('.authorized_stock_num').val('0');
- $('#count_input').css("visibility", "visible");
- }
- })
- }
- function batchAddEvent() {
- $('#authorized_stock_many').on('change', function () {
- if ($(this).val() == '327') {//共享库存
- $('.second_style_next_data').hide();
- $('#authorized_stock_num_many').val('0');
- } else if ($(this).val() == '328') {//人工确认
- $('.second_style_next_data').hide();
- $('#authorized_stock_num_many').val('999');
- } else if ($(this).val() == '329') {//满房
- $('.second_style_next_data').hide();
- $('#authorized_stock_num_many').val('0');
- } else {
- $('#authorized_stock_num_many').val('0');
- $('.second_style_next_data').show();
- }
- })
- }
- //提示分销价与零售价适用于哪些渠道
-
- function to_fenxiao_lingshou() {
- $('#updateAll').bind('click', function () {
- var sum_fenxiao_arr = [];
- var sum_fenxiao_str = '';
- var sum_lingshou_arr = [];
- var sum_lingshou_str = '';
- $("input[name='mybox']").each(function () {
- if ($(this).is(':checked')) {
- if ($(this).closest('tr').attr('data-distrib-type') == 177) {
- sum_fenxiao_arr.push($(this).closest('tr').find('td:first').html());
- } else {
- sum_lingshou_arr.push($(this).closest('tr').find('td:first').html());
- }
- }
- });
- sum_fenxiao_str = sum_fenxiao_arr.join(",");
- sum_lingshou_str = sum_lingshou_arr.join(",");
- ZZLog(sum_fenxiao_str, sum_lingshou_str);
- $('#to_fenxiao').text('将应用于' + sum_fenxiao_str);
- $('#to_lingshou').text('将应用于' + sum_lingshou_str);
- });
- }
- //全选或全不选
- $("#all").click(function () {
- if (this.checked) {
- var valArr = new Array;
- $("#table :checkbox").prop("checked", true);
- $('input[type="checkbox"][name="mybox"]:checked').each(function (i) {
- valArr[i] = $(this).val();
- });
- var vals = valArr.join(',');
- check_distrib_id = vals;
- } else {
- $("#table :checkbox").prop("checked", false);
- }
- });
- function selectAll() {
- var valArr = new Array;
- $('input[type="checkbox"][name="mybox"]:checked').each(function (i) {
- valArr[i] = $(this).val();
- });
- var vals = valArr.join(',');
- check_distrib_id = vals;
- }
|