|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706 |
- /**
- * Created by luocj on 2016/9/29.
- */
- var tbodyHTML = '';
- var order_detail;
- var tr = $('.tr_str').prop('outerHTML');
- var hotel_name = getPar('hotel_name');
- var product_name = getPar('product_name');
- var hotel_id = getPar('hotel_id');
- var room_type = getPar('room_type');
- var parent_room_type = getPar('parent_room_type'); //基础房型
- var start_date = '';
- var end_date = '';
- var org_id = getPar('org_id');
- var org_list = '';
- var order_list = '';
- var order_id = getPar('order_id');
- var org_name = getPar('org_name');
- var all_order_detail = '';
- var all_money_sum = '';
- var benefit_sum = '';
- //总佣金,总结算,总利润
- var all_yongj = 0;
- var all_jiesuan = 0;
- var all_profit = 0;
- var _old_data = {
- org_id: '',
- org_num: '',
- contact: '',
- mobile: '',
- start_date: '',
- // end_date: '',
- total: '',
- memo: '',
- amount: 0
- };
- //原订单日期对应库存类型及其数量
- var _old_stock = [];
- var load_detail_finished = false,
- load_finished = false;
- window.onload = function () {
- tbodyHTML = $('#make_order_list').html();
- start_date = $('#start_date').val();
- end_date = $('#end_date').val();
- getOrgList();
- getOrderDetail();
- //可选库存具体数量,需要等待原订单库存的数据,再加上
- getOrderStatus();
- };
- // 获取渠道
- function getOrgList() {
- var url = base_api + "?type=order_MakeHTOrder&op=org_list";
- ZZLog(url);
- load_finished = false;
- $.getJSON(url, function (data) {
- ZZLog(data);
-
- if (data['code'] != "0") {
- alert(data['info']);
- } else {
- var outHTML = '<option id=0 value="-1" style=font-size: 12px;>请选择</option>';
- org_list = data['org_list'];
- for (var i = 0; i < org_list.length; i++) {
- var HTML = '<option id=0>请选择</option>';
- var dict = org_list[i];
- HTML = HTML.replace('请选择', dict['org_name']);
- if (dict['org_id'] == org_id) {
- HTML = HTML.replace("id=0", "id=" + dict['org_id'] + " value=" + dict['org_id'] + " selected=selected");
- } else {
- HTML = HTML.replace("id=0", "id=" + dict['org_id'] + " value=" + dict['org_id']);
- }
-
- outHTML += HTML
- }
- $('#org_id').html(outHTML);
- $('.select_line').comboSelect();
- }
- load_finished = true;
- })
- }
- var refuse_flag = '';
- //获取订单详情
- function getOrderDetail() {
-
- load_detail_finished = false;
- start_date = $('#start_date').val();
- end_date = $('#end_date').val();
- var url = base_api + "?type=order_ModifyHTOrder&op=order_list&start_date=" + start_date + "&end_date=" + end_date + "&hotel_id=" + hotel_id + "&room_type=" + room_type + "&org_id=" + org_id + "&order_id=" + order_id;
- ZZLog(url);
- $.getJSON(url, function (data) {
- ZZLog(data);
- all_order_detail = data;
- order_detail = data;
- initOldData(data);
- //对
-
- $.each(data['hotel_child_order_detail'], function (key, item) {
- _old_stock.push({'date': item['run_date'], 'stock_type': item['stock_type'], 'stock_count': item['total']})
- })
- var main_order = data['hotel_order_detail'][0];
- var hotel_name = main_order['hotel_name'];
- refuse_flag = main_order['refuse_flag'];
- var product_name = main_order['product_name'];
- var order_status = main_order['order_status'];
- var customer_name = main_order['customer_name'];
- var customer_mobile = main_order['customer_mobile'];
- var customer_memo = main_order['customer_memo'];
- var checkin_time = data['hotel_child_order_detail'][0]['checkin_time'];
- var org_id = getPar('org_id');
- var start_date = data['hotel_child_order_detail'][0]['run_date'];
- var end_date = getDateByDay(1, data['hotel_child_order_detail'][data['hotel_child_order_detail'].length - 1]['run_date']);
- $('#start_date').val(start_date);
- $('#end_date').val(end_date);
- $('#hotel_name').html(hotel_name);
- $('#product_name').html(product_name);
- $('#org_name').html('订单渠道: ' + org_name);
- $('#order_id').html('订 单 号: ' + order_id);
- if (order_status == 145) {
- $('#order_status').html('待支付');
- } else if (order_status == 313) {
- $('#order_status').html('待发单');
- } else if (order_status == 198) {
- $('#order_status').html('待确认');
- } else if (order_status == 314) {
- $('#order_status').html('已安排');
- } else if (order_status == 147) {
- $('#order_status').html('已完成');
- } else if (order_status == 148) {
- $('#order_status').html('已取消');
- } else if (order_status == 382) {
- $('#order_status').html('异常处理待发单');
- }
-
- //下方
- $('#org_num').val(main_order['outside_order_no']);
- $('#org_id').val(org_id);
- $('#contacts').val(customer_name);
- $('#phone').val(customer_mobile);
- var notes = customer_memo.split('||');
- var user_org_id = getCookie('user_org_id');
- $.each(notes, function (key, item) {
- if (item != '') {
- var tmp = item.split('|');
- var note = '<div style="margin-top: 20px" class="note"><span style="width: 80px;display: inline-block"></span>';
- //不同用户登录,显示不同内容
- var display = 'none';
- if (user_org_id == 0) {
- display = 'inline-block';
- }
- var selected = '';
- if (tmp[2] == 1)
- selected = 'selected';
- note += ' <select disabled name="note[type][]" style="display: ' + display + ';"><option value="0">公共备注</option><option ' + selected + ' value="1">内部备注</option></select>';
- // }
-
- note += ' <input name="note[text][]" type="text" style="width: 300px;height: 30px;font-size: 13px;color: inherit" placeholder="填写备注" disabled value="' + tmp[3] +
- '"/><input type="hidden" name="edit_user_id" value="' + tmp[0] + '" /><input type="hidden" name="edit_time" value="' + tmp[1] + '" /> ';
-
- var user_id = getCookie('user_id');
- if ($.inArray(parseInt(user_id), [1, 35, 160]) >= 0)
- note += ' <a href="javascript:;" onclick="removeNote(this, true)" >删除</a>';
-
- note += '</div>';
- if (user_org_id == 0 || tmp[2] == 0)
- $(".note:last").after(note);
- }
- })
- $('#more').val(customer_memo);
- lastchecktime();
- $('#time').val(checkin_time);
- timeDiff();
- //获取订单列表
- //getOrderList()
- load_detail_finished = true;
- })
- }
-
- //获取可下库存
- function getRoomStock() {
- var url = base_api + "?type=order_ModifyHTOrder&op=stock_list&hotel_id=" + hotel_id + "&parent_room_type=" + parent_room_type + "&room_type=" + room_type
- + "&org_id=" + org_id + "&start_date=" + start_date + "&end_date=" + end_date;
- // ZZLog(url);
- $.getJSON(url, function (data) {
- ZZLog(data);
- if (data['code'] != 0) {
- ZZAlertInfo(data['info'], function () {
- return;
- });
- } else {
- setDataHTML(data)
- updateStock();
- }
- }).error(function (data) {
-
- })
- }
-
- //页面数据替换
- function setDataHTML(data) {
- var sumHTML = '';
- for (var i = 0; i < data['order_list'][0].length; i++) {
- var dict = data['order_list'][0][i];
- var HTML = tr;
- //替换入住日期
- HTML = HTML.replace('[入住日期]', dict['run_date']);
- //end 替换入住日期
-
- //替换数量
- //得到替换数量,逻辑:先判断超售oversell_flag,1为可以超售,如果可以超售则取data['order_list'][1]中的该天所有库存,超了不能下单。
- var count = 0;
- if (dict['oversell_flag'] == 1 && dict['remaining_count'] != -1) {
- for (var j = 0; j < data['order_list'][1].length; j++) {
- var dict1 = data['order_list'][1][j];
- if (dict['run_date'] == dict1['run_date']) {
- count += parseInt(dict1['remaining_count']);
- // ZZLog(dict1);
- //将调用超售库存的信息放入data-json-baoliu,maiduan,xianxun
- if (dict1['stock_type'] == '228') {//买断
- HTML = HTML.replace('[data-json-maiduan]', setJsonHtml(dict1))
- } else if (dict1['stock_type'] == '229') {//现询
- HTML = HTML.replace('[data-json-xianxun]', setJsonHtml(dict1))
- } else if (dict1['stock_type'] == '230') {//保留
- HTML = HTML.replace('[data-json-baoliu]', setJsonHtml(dict1))
- } else {
- ZZAlertInfo('没有该库存类型');
- }
- }
- }
- } else {
- for (var j = 0; j < data['order_list'][1].length; j++) {
- var dict1 = data['order_list'][1][j];
- if (dict['run_date'] == dict1['run_date']) {
- // ZZLog(dict1);
- //将调用超售库存的信息放入data-json-baoliu,maiduan,xianxun
- if (dict1['stock_type'] == '228') {//买断
- count += parseInt(dict1['remaining_count']);
- HTML = HTML.replace('[data-json-maiduan]', setJsonHtml(dict1))
- } else if (dict1['stock_type'] == '229') {//现询
- HTML = HTML.replace('[data-json-xianxun]', setJsonHtml(dict1))
- } else if (dict1['stock_type'] == '230') {//保留
- count += parseInt(dict1['remaining_count']);
- HTML = HTML.replace('[data-json-baoliu]', setJsonHtml(dict1))
- } else {
- ZZAlertInfo('没有该库存类型');
- }
- }
- }
- count = parseInt(dict['remaining_count'] == -1 ? 0 : dict['remaining_count'])
- }
- // ZZLog(count);
- //end 得到替换数量
- //循环替换数量
- var selHTML = '<select onchange="changeCount(this)" class="prod_count" style="width: 40px">';
- for (var m = 0; m <= count; m++) {
- if (m > 20) {
- break;
- }
- var temp = "<option value='" + m + "'>" + m + "</option>";
- selHTML += temp;
- }
- selHTML += '</select>';
- HTML = HTML.replace('[数量]', selHTML);
- //end 替换数量
- //结算价替换
- HTML = HTML.replace('[结算价]', '<input type="text" oninput="changeCount(this)" class="prod_price" style="width: 60px" value="' + dict['price'] + '">')
- //end 结算价替换
- //佣金规则
- var ling = 0;
- var ling1 = ling.toFixed(2);
- if (dict['commision_flag'] == 0) {//为0不返佣,为1返佣
- HTML = HTML.replace('[佣金]', '-');
- } else {
- HTML = HTML.replace('[佣金]', ling1);
- }
- //end 佣金规则
- HTML = HTML.replace('[结算价总额]', ling1);
- HTML = HTML.replace('[销售利润]', ling1);
- //将非超卖库存存入data-json
- HTML = HTML.replace('[data-json]', setJsonHtml(dict));
- sumHTML += HTML
- }
- $('#make_order_list').html(sumHTML);
- if (sumHTML) {
- $('#make_table').show();
- } else {
- $('#make_table').hide();
- }
- var data_detail = order_detail;
- $.each($("#make_order_list tr"), function (key, tr) {
- for (var n = 0; n < data_detail['hotel_child_order_detail'].length; n++) {
- if (data_detail['hotel_child_order_detail'][n]['run_date'] == $(tr).find("td:first").text()) {
- $(tr).find(".prod_price").val(data_detail['hotel_child_order_detail'][n]['order_price']);
- }
- }
- });
- //刷新总计
- all_sum();
- }
-
- //获取时差并获取相应时间的订单
- function timeDiff() {
- var start = $("#start_date").val();
- var end = $("#end_date").val();
- start = start.replace(/-/g, "/");
- var startdate = new Date(start);
- end = end.replace(/-/g, "/");
- var enddate = new Date(end);
- var time = enddate.getTime() - startdate.getTime();
- var days = parseInt(time / (1000 * 60 * 60 * 24));
- $('#datediff').html('共 ' + days + ' 晚');
- // alert(days);
- start_date = $('#start_date').val();
- end_date = $('#end_date').val();
- org_id = $('#org_id').val();
- getRoomStock();
-
- }
- var yongj = '';
- //改变产品数量与结算价
- function changeCount(obj) {
- // 房间数量
- var room_count = $(obj).closest('tr').find('.prod_count').val();
- // 结算单价
- var room_price = $(obj).closest('tr').find('.prod_price').val();
- // 佣金规则
- var dict = getJsonHtml($(obj).closest('tr').attr('data-json'));
- var dict_maiduan = getJsonHtml($(obj).closest('tr').attr('data-json-maiduan'));
- var dict_baoliu = getJsonHtml($(obj).closest('tr').attr('data-json-baoliu'));
- var dict_xianxun = getJsonHtml($(obj).closest('tr').attr('data-json-xianxun'));
- var commision_price = 0;
- if (dict['commision_flag'] == '1') {//有佣金规则
- if (dict['back_commision_method'] == '309') {//308 按销售金额309 按结算金额
- commision_price = dict['back_value']
- } else if (dict['back_commision_method'] == '308') {
- commision_price = room_count * room_price * parseFloat(dict['back_percent']) / 100;
- }
- } else {//无佣金规则
- commision_price = 0;
- }
- //end 佣金规则
- //结算总价
- var jiesuan_price = room_count * room_price;
- //end 结算总价
- //库存类型与成本
- var maiduan_count = dict_maiduan['remaining_count'] == undefined ? 0 : dict_maiduan['remaining_count'];
- var baoliu_count = dict_baoliu['remaining_count'] == undefined ? 0 : dict_baoliu['remaining_count'];
- var xianxun_count = dict_xianxun['remaining_count'] == undefined ? 0 : dict_xianxun['remaining_count'];
- var maiduan_price = dict_maiduan['cost_price'] == undefined ? 0 : dict_maiduan['cost_price'];
- var baoliu_price = dict_baoliu['cost_price'] == undefined ? 0 : dict_baoliu['cost_price'];
- var xianxun_price = dict_xianxun['cost_price'] == undefined ? 0 : dict_xianxun['cost_price'];
- //end 库存类型与成本
- //销售利润
- var profit = 0;
- if (parseInt(room_count) <= parseInt(maiduan_count)) {//所选房间数小于等于买断数
- profit = jiesuan_price - commision_price - maiduan_price * room_count
- } else if (parseInt(room_count) > parseInt(maiduan_count) && parseInt(room_count) <= (parseInt(maiduan_count) + parseInt(baoliu_count))) { //所选房间数大于买断数,小于等于保留数+买断数
- profit = jiesuan_price - commision_price - maiduan_price * maiduan_count - baoliu_price * (room_count - maiduan_count)
- } else if (parseInt(room_count) > (parseInt(maiduan_count) + parseInt(baoliu_count)) && parseInt(room_count) <= (parseInt(maiduan_count) + parseInt(baoliu_count) + parseInt(xianxun_count))) {
- profit = jiesuan_price - commision_price - maiduan_price * maiduan_count - baoliu_price * baoliu_count - xianxun_price * (room_count - maiduan_count - baoliu_count)
- }
- //end 销售利润
- //佣金显示
- var commision_price1 = parseFloat(commision_price).toFixed(2);
- if (dict['commision_flag'] == 1) {
- $(obj).closest('tr').find('.yongj_sum').text(commision_price1);
- } else {
- $(obj).closest('tr').find('.yongj_sum').text('-');
- }
- //结算总价显示
- var jiesuan_price1 = parseFloat(jiesuan_price).toFixed(2);
- if (jiesuan_price1) {
- $(obj).closest('tr').children().eq(4).text(jiesuan_price1);
- }
- //销售利润显示
- var profit1 = parseFloat(profit).toFixed(2);
- if (profit1) {
- $(obj).closest('tr').children().eq(5).text(profit1);
- }
- //总计
- all_sum();
- }
- //获取最晚到店时间
- function lastchecktime() {
- var sumHTML = '';
- for (var i = 1; i <= 23; i++) {
- var HTML = '<option>24:00</option>';
- HTML = HTML.replace('<option>24:00</option>', '<option value="' + i + ':00">' + i + ':00</option>')
- sumHTML += HTML;
- }
- $('#time').html(sumHTML);
- }
- //获取上方状态栏
- function getOrderStatus() {
- var url = base_api;
- var param = {
- type: "order_ModifyHTOrder",
- op: "order_status",
- order_id: order_id
- }
- $.ajax({
- url: url,
- type: "post",
- dataType: "json",
- data: param,
- success: function (res_data) {
- ZZLog(res_data);
- for (var i = 0; i < res_data['order_status'].length; i++) {
- var dict = res_data['order_status'][i];
- var temp_date = dict['create_time'].split(" ");
- var date = temp_date[0];
- var time = temp_date[1];
- if (dict['order_status_name'] == "待支付") {
- $('li[data-target="#step1"]').addClass('active');
- $('li[data-target="#step2"]').addClass('active');
- $('#create_date').text(date);
- $('#create_time').text(time);
- $('#pay_date').text(date);
- $('#pay_time').text(time);
- } else if (dict['order_status_name'] == "待发单") {
- $('li[data-target="#step1"]').addClass('active');
- $('li[data-target="#step2"]').addClass('active');
- $('#create_date').text(date);
- $('#create_time').text(time);
- $('#pay_date').text(date);
- $('#pay_time').text(time);
- } else if (dict['order_status_name'] == "待确认") {
- $('li[data-target="#step3"]').addClass('active');
- $('#send_date').text(date);
- $('#send_time').text(time);
- } else if (dict['order_status_name'] == "已安排") {
- $('li[data-target="#step4"]').addClass('active');
- $('#arr_date').text(date);
- $('#arr_time').text(time);
- } else if (dict['order_status_name'] == "已完成") {
- $('li[data-target="#step5"]').addClass('active');
- $('#finish_date').text(date);
- $('#finish_time').text(time);
- } else {
- }
- }
- }
-
- })
- }
- //提交
- function commit() {
- if ($('#button').text() == '保存中') {
- return;
- }
- $('#button').text('保存中');
- $('#button').css('background', 'darkgray');
- //获取联系人,联系方式,备注
- var contacts = $('#contacts').val().replace(/\,/g, ' ').trim();
- var phone = $('#phone').val();
- var more = '',
- total = 0;
- //拒单标识0为不能拒单,1为可以拒单
- var if_cancel = 0;
- //备注要拼接字符串
- $.each($("[name^='note[type]']"), function (key, item) {
- var text = $(item).next().val().replace(/[\|,]/g, ' ').trim();
- if (text != '') {
- if (more != '')
- more += '||';
- var user_id = $(item).closest('div').find('input[name="edit_user_id"]');
-
- more += (user_id.length > 0 ? user_id.val() : getCookie('user_id')) + '|' + parseInt(Date.now() / 1000) + '|' + item.value + '|' + text;
- }
- });
- //end 备注要拼接字符串
- var cus_list = "{" + contacts + "," + phone + "," + more + "}";
- //end 获取联系人,联系方式,备注
- //获取最晚到店时间
- var checkin_time = $('#time').val().toString();
- //渠道订单号
- var org_num = $('#org_num').val();
- //渠道id
- var org_id = $('#org_id').val();
- //获取房型列表
- var room_list = '';
- $('.tr_str').each(function () {
- var start_date = $(this).find('td').eq(0).text();
- var all_count = $(this).find('.prod_count').val();
- if (all_count == 0) {
- /*$('#button').text("保存");
- $('#button').attr('disabled',"false");*/
- ZZAlertInfo('请选择库存', function () {
- return;
- })
- }
- var dan_jiesuan = $(this).find('.prod_price').val();
- if ($(this).find('.yongj_sum').text() == '-') {
- var dan_yongj = 0
- } else {
- var dan_yongj = parseFloat($(this).find('.yongj_sum').text()) / parseInt(all_count);
- }
- //获得买断,保留,现询的价格与库存
- var dict_maiduan = getJsonHtml($(this).attr('data-json-maiduan'));
- var dict_baoliu = getJsonHtml($(this).attr('data-json-baoliu'));
- var dict_xianxun = getJsonHtml($(this).attr('data-json-xianxun'));
- //库存类型与成本
- var maiduan_count = dict_maiduan == 0 ? 0 : dict_maiduan['remaining_count'];
- var baoliu_count = dict_baoliu == 0 ? 0 : dict_baoliu['remaining_count'];
- var xianxun_count = dict_xianxun == 0 ? 0 : dict_xianxun['remaining_count'];
- var maiduan_price = dict_maiduan == 0 ? 0 : dict_maiduan['cost_price'];
- var baoliu_price = dict_baoliu == 0 ? 0 : dict_baoliu['cost_price'];
- var xianxun_price = dict_xianxun == 0 ? 0 : dict_xianxun['cost_price'];
- if (maiduan_price == 0 && baoliu_price == 0 && xianxun_price == 0) {
- /* $('#button').text("保存");
- $('#button').attr('disabled',"false");*/
- ZZAlertInfo('存在成本价为零,请至对应房型列表确认', function () {
- return;
- })
- }
- //end 库存类型与成本
- //end 获得买断,保留,现询的价格与库存
- //判断库存
- var maiduan_field = '';
- var baoliu_field = '';
- var xianxun_field = '';
- var sum_field = '';
- if (parseInt(all_count) <= parseInt(maiduan_count)) {//小于等于买断库存228
- sum_field = '228' + ',' + all_count + ',' + maiduan_price
- } else if (parseInt(all_count) > parseInt(maiduan_count) && parseInt(all_count) <= (parseInt(maiduan_count) + parseInt(baoliu_count))) {
- maiduan_field = '228' + ',' + maiduan_count + ',' + maiduan_price;
- baoliu_field = '230' + ',' + (all_count - maiduan_count) + ',' + baoliu_price;
- sum_field = maiduan_field + '|' + baoliu_field
- } else if (parseInt(all_count) > (parseInt(maiduan_count) + parseInt(baoliu_count)) && parseInt(all_count) <= (parseInt(maiduan_count) + parseInt(baoliu_count) + parseInt(xianxun_count))) {
- if_cancel = 1;
- maiduan_field = '228' + ',' + maiduan_count + ',' + maiduan_price;
- baoliu_field = '230' + ',' + baoliu_count + ',' + baoliu_price;
- xianxun_field = '229' + ',' + (all_count - baoliu_count - maiduan_count) + ',' + xianxun_price;
- sum_field = maiduan_field + '|' + baoliu_field + '|' + xianxun_field
- } else {
- // alert('出错了,不可能!!');
- return;
- }
- // ZZLog(sum_field);
- room_list += '{\'\'' + start_date + '\'\',' + all_count + ',' + dan_jiesuan + ',' + dan_yongj + '}';
- total += all_count;
- //end 判断库存
- });
- //end 获取房型列表
- var param = {
- type: "order_ModifyHTOrder",
- op: "modify_order",
- hotel_id: hotel_id,
- room_type: room_type,
- org_id: org_id,
- org_num: org_num,
- room_list: room_list,
- cus_list: cus_list,
- contact: contacts,
- mobile: phone,
- start_date: start_date,
- memo: more,
- total: total,
- checkin_time: checkin_time,
- if_cancel: if_cancel,
- order_id: order_id,
- total_commission: all_yongj,
- benefit: all_profit,
-
- };
- param.logList = compareOldData(param);
-
- //最晚到店不为空,联系人不为空,订单渠道不为空,渠道订单号不为空,入住日期得连续,库存不问空
- if (hotel_id == '' || room_type == '' || org_id == '' || room_list == '' || checkin_time == '' || if_cancel === '' || contacts === '') {
-
- $('#button').text('保存');
- $('#button').css('background', '#428bca!important');
- ZZAlertInfo('请完整填写数据', function () {
- })
- return false;
- } else {
- loading();
- $.ajax({
- url: base_api,
- type: 'post',
- dataTye: 'json',
- data: param,
- success: function (res_data) {
- closeLoading();
- res_data = JSON.parse(res_data);
- if (res_data['code'] != "0") {
- $('#button').text('保存');
- $('#button').css('background', '#428bca!important');
- ZZAlertInfo('修改失败', function () {
- })
- } else {
- $('#button').text('保存');
- $('#button').css('background', '#428bca!important');
- ZZAlertInfo('修改成功!', function () {
- window.location.href = "./hotel_order_list.html";
- });
- }
- },
- error: function (msg) {
- closeLoading();
- }
-
- })
- }
- }
-
-
- //添加备注
- function addNote(e) {
- ZZConfirm('确认添加备注?', function () {
- var note = '<div style="margin-top: 20px" class="note"><span style="width: 80px;display: inline-block"></span>';
- //不同用户登录,显示不同内容
- var display = 'none';
- var user_org_id = getCookie('user_org_id');
- if (user_org_id == 0) {
- display = 'inline-block';
- }
- note += ' <select name="note[type][]" style="display: ' + display + ';"><option value="0">公共备注</option><option value="1">内部备注</option></select>';
- // }
-
- note += ' <input name="note[text][]" type="text" style="width: 300px;height: 30px;font-size: 13px;color: inherit" placeholder="填写备注" /> ';
-
- note += ' <a href="javascript:;" onclick="removeNote(this, false)" >删除</a>';
-
- note += '</div>';
- $(".note:last").after(note);
- })
-
- }
-
- //更新库存
- function updateStock() {
- if (load_detail_finished && load_finished) {
- var trList = $("#make_order_list tr td.checkin_date").closest('tr');
- $.each(_old_stock, function (key, item) {
- $.each(trList, function (key, tr) {
- if ($($(tr).find('td')[0]).html() == item['date']) {
- //根据不同类型,选择不同库存
- var json_type = '';
- if (item['stock_type'] == '228') {//买断
- json_type = 'data-json-maiduan';
- } else if (item['stock_type'] == '229') {//现询
- json_type = 'data-json-xianxun';
- } else if (item['stock_type'] == '230') {//保留
- json_type = 'data-json-baoliu';
- } else {
- }
- var tr_json_data = $(tr).attr(json_type);
- if (tr_json_data != '' && tr_json_data.indexOf('[data-json') == -1) {
- var tmp_data = JSON.parse(tr_json_data);
- tmp_data['remaining_count'] = parseInt(tmp_data['remaining_count']) + parseInt(item['stock_count']);
- var json_str = JSON.stringify(tmp_data);
- $(tr).attr(json_type, json_str);
-
- }
- var count = parseInt($(tr).find('.prod_count option:last').html());
- var new_count = count + parseInt(item['stock_count'])
- for (var i = count + 1; i <= new_count && i < 20; i++) {
- $(tr).find('.prod_count option:last').after('<option value="' + i + '">' + i + '</option>');
- }
- $(tr).find('.prod_count').val(item['stock_count']).change();
- }
- })
- })
-
- }
-
-
- }
- //获取总计
- function all_sum() {
- all_yongj = 0;
- all_jiesuan = 0;
- all_profit = 0;
- var all_yongj1 = 0;
- var all_jiesuan1 = 0;
- var all_profit1 = 0;
- $('.yongj_sum').each(function () {
- all_yongj += parseFloat($(this).text())
- });
- if (isNaN(all_yongj)) {
- all_yongj = 0
- }
- $('.jiesuan_sum').each(function () {
- all_jiesuan += parseFloat($(this).text())
- });
- if (isNaN(all_jiesuan)) {
- all_jiesuan = 0
- }
- $('.benefit_sum').each(function () {
- all_profit += parseFloat($(this).text())
- });
- if (isNaN(all_profit)) {
- all_profit = 0
- }
- all_yongj1 = all_yongj.toFixed(2);
- all_jiesuan1 = all_jiesuan.toFixed(2);
- all_profit1 = all_profit.toFixed(2);
- $('#all_yongj').text(all_yongj1 + '元');
- $('#all_jiesuan').text(all_jiesuan1 + '元');
- $('#all_profit').text(all_profit1 + '元');
- }
-
-
-
-
-
|