|
- var order_id = $('#hidden_order_id').attr('value');
- var docking_type = $('#hidden_order_id').attr('docking-type');
- var payment_status = $('#hidden_order_id').attr('payment_status');
- var gathering_status = $('#hidden_order_id').attr('gathering_status');
- var hotel_id = $('#hidden_order_id').attr('hotel_id');
- var room_type = $('#hidden_order_id').attr('room_type');
- var room_id = $('#hidden_order_id').attr('room-id');
- var create_user_id = $('#hidden_order_id').attr('create_user_id');
- var parent_room_type = $('#hidden_order_id').attr('base_room_type');
- var channel_id = $('#hidden_order_id').attr('channel_id');
- var customer_memo = $('#hidden_order_id').attr('customer-memo');
- var channel_order_id = $('#hidden_order_id').attr('outside-order');
- var hotel_room_id = $('#hotel_room_id').val();
- var checkin_date = $('#hidden_order_id').attr('checkin-date');
- var checkout_date = $('#hidden_order_id').attr('checkout-date');
- var old_num = $('#total_room_count').html();
- var delayTs = 800;
- var save_info = '保存';
- var save_update_info = '保存并生成修改单';
- var infoApiError = "服务器开小差了,请联系技术部相关人员";
- var temp_docking_type = '';
- var temp_order_status = $('#hidden_order_id').attr('order-status');
- var temp_channel_order_status = $('#hidden_order_id').attr('channel_order_status');
- var checkin_copy = '';
-
- var status_arr1 = ['313']; //待发单
- var status_arr2 = ["198", "382"]; //待安排 退改中
- var status_arr3 = ['313', '198', '382']; //待发单 待安排 退改中
-
- //渠道状态为已拒绝,取消被拒
- var channel_status_arr1 = ['552', '554'];
-
- var delay = (function () {
- var timer = 0;
- return function (callback, time) {
- clearTimeout(timer);
- timer = setTimeout(callback, time);
- };
- })();
-
- $(document).ready(function () {
- showThreeButton();
- })
-
- // 修改按钮的显示
- function showThreeButton() {
- if ('556' == docking_type) {
- $('#btn-rz-update-xsj').addClass('hide_f');
- $('#btn-rz-update-xq').addClass('hide_f');
- if (payment_status > 1)
- $('#btn-rz-update-cgj').addClass('hide_f');
- if ($.inArray(temp_order_status, status_arr3) == -1 || ($.inArray(temp_channel_order_status, channel_status_arr1) >= 0)) {
- $('#btn-rz-update-xq').addClass('hide_f');
- $('#btn-rz-update-cgj').addClass('hide_f');
- $('#btn-rz-update-cancel').addClass('hide_f');
- //客人信息
- $('#update-customer-info').addClass('hide_f');
- $('.comment-type1').addClass('hide_f');
- }
- }
- if ("557" == docking_type) {
- //1.5.2
- //录入的订单 应收:gathering_status > 1 则不显示销售价,应付:payment_status > 1 则不显示采购价
- if (gathering_status > 1) {
- $('#btn-rz-update-xsj').addClass('hide_f');
- }
- if (payment_status > 1) {
- $('#btn-rz-update-cgj').addClass('hide_f');
- }
-
- if ($.inArray(temp_order_status, status_arr3) == -1) {
- //三个按钮
- $('#btn-rz-update-xq').addClass('hide_f');
- $('#btn-rz-update-xsj').addClass('hide_f');
- $('#btn-rz-update-cgj').addClass('hide_f');
- $('#btn-rz-update-cancel').addClass('hide_f');
- //客人信息
- $('#update-customer-info').addClass('hide_f');
- $('.comment-type1').addClass('hide_f');
- }
- }
- }
-
- // 修改订单入口
- function updateOrderInfo() {
- var room_count = $('#min_room_count').val();
- var org_num = $('#ordermain-outside_order_no').val();
- var org_id = $('#ordermain-outside_sale_org_id').val();
- var customer_name = $('#ordermain-customer_name').val();
- var customer_mobile = $('#ordermain-customer_mobile').val();
- var room_list = '';
- var start_date = $('#start_date_txt').html();
- var end_date = $('#end_date_txt').html();
- $('.tr_line').each(function (index, dom) {
- var run_date = $(this).find('.room_run_date').html();
- var sale_single_price_txt = $(this).find('.sale_single_price').html();
- room_list += '{\'' + run_date + '\',' + sale_single_price_txt + '}';
- });
-
- // 修改订单参数
- var param = {
- "order_id": order_id,
- "user_id": create_user_id,
- "hotel_id": hotel_id,
- "room_id": room_id,
- "room_count": room_count,
- "org_id": org_id,
- "org_num": org_num,
- "room_list": room_list,
- "start_date": start_date,
- "end_date": end_date,
- "customer_name": customer_name,
- "customer_mobile": customer_mobile,
- "customer_memo": customer_memo
- };
- $.ajax({
- type: "post",
- url: '/hotel/ordermain/update-check-in',
- data: param,
- async: false,
- dataType: "json",
- success: function (res_data) {
- // ZZLog(res_data);
- if (res_data['code'] != "0") {
- ZZAlertInfo(res_data['info'], function () {
- closeLoading();
- });
- } else {
- ZZAlertInfo('修改成功', function () {
- document.location.reload();
- closeLoading();
- });
- }
- },
- error: function () {
- ZZAlertInfo(infoApiError, function () {
- closeLoading();
- });
- }
- });
-
- }
-
- // 顶部tab
- function searchOrderTab($order_id, $type) {
-
- }
-
- //入住间数改变不改变入住日期和销售单价
- $('#min_room_count').change(function () {
- changeStartEndDate(channel_id);
- });
-
- //修改取消按钮
- $('#btn-rz-cancel').on('click', function () {
- //data-main-status 1:修改入住需求 2:修改销售价 3:修改采购价
- var btn_main_status = $(this).attr('data-main-status') ? $(this).attr('data-main-status') : "1";
-
- if ('1' == btn_main_status) {
- //修改入住需求
- // ZZLog('入住需求取消-修改入住需求');
- $('#btn-rz-update-xq').html('修改入住需求');
- $('#btn-rz-update-xq').attr('data-btn-status', '1');
- }
- if ('2' == btn_main_status) {
- //修改销售价
- // ZZLog('入住需求取消-修改销售价');
- $('#btn-rz-update-xsj').html('修改销售价');
- $('#btn-rz-update-xsj').attr('data-btn-status', '1');
- }
- if ('3' == btn_main_status) {
- //修改采购价
- // ZZLog('入住需求取消-修改采购价');
- $('#btn-rz-update-cgj').html('修改采购价');
- $('#btn-rz-update-cgj').attr('data-btn-status', '1');
- }
-
- $('#stroke_tbody').html(checkin_copy);
- $(this).addClass('hide_f');
-
-
- $('#btn-rz-update-xq').removeClass('hide_f');
- $('#btn-rz-update-xsj').removeClass('hide_f');
- $('#btn-rz-update-cgj').removeClass('hide_f');
- showThreeButton();
-
- $('.update1_s').css('display', 'inherit');
- $('.update1_rz').css('display', 'none');
- $('.update2_s').removeClass('hide_f');
- $('.update2_h').addClass('hide_f');
- $('.update3_s').removeClass('hide_f');
- $('.update3_h').addClass('hide_f');
-
- // 日期修改
- $('#start_date').find('input').val(checkin_date);
- $('#end_date').find('input').val(checkout_date);
- $('#start_date_txt').html(checkin_date);
- $('#end_date_txt').html(checkout_date);
- $('#ordermain-outside_order_no').val(channel_order_id);
- $('#total_room_count').html(old_num);
- });
-
- //入住时间
- $('#start_date').on('changeDate', function (e) {
- changeStartEndDate(channel_id)
- })
- //离店时间
- $('#end_date').on('changeDate', function (e) {
- changeStartEndDate(channel_id);
- })
-
- // 订单渠道修改
- $('#ordermain-outside_sale_org_id').change(function () {
- changeStartEndDate($(this).val());
- })
-
- // 修改采购价
- $('.cai_base_price').keyup(function (event) {
- var parent = $(this).closest('tr');
- tr_change(parent);
- });
-
- // 修改销售价
- $('.tr_single_price').keyup(function () {
- var parent = $(this).closest('tr');
- var room_count = $('#total_room_count').html();
- var order_price = parent.find('.tr_single_price').val();
- var tr_base_price = parent.find('.cai_base_price_txt').html(); // 采购总价
- var dict = JSON.parse(parent.attr('data-json'));
- var all_price = room_count * order_price; // 单个总价
- var tr_mid_commission = parent.find('.tr_mid_price').html();
- // 佣金计算
- var tr_commission = getCommision(room_count, order_price, dict);
- //利润计算
- var tr_profit = all_price - tr_base_price * room_count - tr_mid_commission - tr_commission;
- parent.find('.tr_all_price').html(Number(all_price).toFixed(2));
- parent.find('.tr_all_commission').html(Number(tr_commission).toFixed(2));
- parent.find('.tr_profit_value').html(Number(tr_profit).toFixed(2));
- sum_price();
- });
-
- // 修改列,修改采购价
- function tr_change(parent) {
- var room_count = $('#total_room_count').html();
- var order_price = parent.find('.sale_single_price').html();
- var base_price = parent.find('.cai_base_price').val();
- var tr_mid_commission = parent.find('.tr_mid_price').html();
- var tr_commission = parent.find('.tr_all_commission').html();
- var all_price = parent.find('.tr_all_price').html();
- var tr_profit = all_price - base_price * room_count - tr_mid_commission - tr_commission;
- parent.find('.tr_profit_value').html(Number(tr_profit).toFixed(2));
- sum_price();
- }
-
- function keyup_price() {
- var all_1 = 0,
- all_2 = 0,
- all_3 = 0,
- all_4 = 0;
- $('.tr_all_price').each(function (index, dom) {
- var tr_all_1 = $(this).html();
- all_1 += tr_all_1 - 0;
- });
- $('.tr_mid_price').each(function (index, dom) {
- var tr_all_2 = $(this).html();
- all_2 += tr_all_2 - 0;
- });
- $('.tr_profit_value').each(function (index, dom) {
- var tr_all_3 = $(this).html();
- all_3 += tr_all_3 - 0;
- });
- $('.tr_all_commission').each(function (index, dom) {
- var tr_all_4 = $(this).html();
- all_4 += tr_all_4 - 0;
- });
-
-
- if (isNaN(all_1)) all_1 = 0;
- if (isNaN(all_2)) all_2 = 0;
- if (isNaN(all_3)) all_3 = 0;
- if (isNaN(all_4)) all_3 = 0;
-
- $('#all_price').html(all_1.toFixed(2) + '元');
- $('#all_price').attr('data-value', all_1.toFixed(2));
-
- $('#all_commission').html(all_2.toFixed(2) + '元');
- $('#all_commission').attr('data-value', all_2.toFixed(2));
-
- $('#profit_value').html(all_3.toFixed(2) + '元');
- $('#profit_value').attr('data-value', all_3.toFixed(2));
-
- $('#mid_all_commission').html(all_4.toFixed(2) + '元');
- $('#mid_all_commission').attr('data-value', all_4.toFixed(2));
- }
-
- function sum_price() {
- var all_1 = 0,
- all_2 = 0,
- all_3 = 0,
- all_4 = 0;
- $('.tr_all_price').each(function (index, dom) {
- var tr_all_1 = $(this).html();
- all_1 += tr_all_1 - 0;
- });
- $('.tr_mid_price').each(function (index, dom) {
- var tr_all_2 = $(this).html();
- all_2 += tr_all_2 - 0;
- });
- $('.tr_profit_value').each(function (index, dom) {
- var tr_all_3 = $(this).html();
- all_3 += tr_all_3 - 0;
- });
-
- $('.tr_all_commission').each(function (index, dom) {
- var tr_all_4 = $(this).html();
- all_4 += tr_all_4 - 0;
- });
-
-
- if (isNaN(all_1)) all_1 = 0;
- if (isNaN(all_2)) all_2 = 0;
- if (isNaN(all_3)) all_3 = 0;
- if (isNaN(all_4)) all_3 = 0;
-
- $('#all_price').html(all_1.toFixed(2) + '元');
- $('#all_price').attr('data-value', all_1.toFixed(2));
-
- $('#all_commission').html(all_4.toFixed(2) + '元');
- $('#all_commission').attr('data-value', all_4.toFixed(2));
-
- $('#profit_value').html(all_3.toFixed(2) + '元');
- $('#profit_value').attr('data-value', all_3.toFixed(2));
-
- $('#mid_all_commission').html(all_2.toFixed(2) + '元');
- $('#mid_all_commission').attr('data-value', all_2.toFixed(2));
- }
-
- $('.comment-type').click(function () {
- $(this).addClass('btn-default').siblings('div').removeClass('btn-default');
- });
-
- $('#btn-order-remark-save-update-d').click(function () {
- var comment_type = $('#comment-type-val').val();
- var comment_txt = $('#comment-txt').val().trim(' ');
- if (comment_txt == null || comment_txt == 0) {
- z.pjaxFinish('warning', '备注内容不能为空');
- return false;
- }
-
- $.pjax.reload({
- container: '#comment-table',
- url: '/hotel/ordermain/comment',
- data: {order_id: order_id, comment_type: comment_type, comment_txt: comment_txt},
- replace: false,
- timeout: false
- })
- });
-
- $('.remove-item').click(function () {
- var comment_id = $(this).attr('data-value');
- $.pjax.reload({
- container: '#comment-table',
- url: '/hotel/ordermain/del-comment',
- data: {order_id: order_id, comment_id: comment_id},
- replace: false,
- timeout: false
- })
- });
-
- /*修改入住需求 end*/
- $('#btn-rz-update-xq').on('click', function () {
- //1:修改入住需求 2:保存并生成修改单 3:保存
- var btn_status = $(this).attr('data-btn-status') ? $(this).attr('data-btn-status') : "1";
- if ('1' == btn_status) {
- checkin_copy = $("#stroke_tbody").children().clone();
- var room_num = $('#total_room_count').html();
- // ZZLog('修改入住需求');
- $('#btn-rz-cancel').attr('data-main-status', '1');
- $('#btn-rz-cancel').removeClass('hide_f');
- $('#btn-rz-update-xsj').addClass('hide_f');
- $('#btn-rz-update-cgj').addClass('hide_f');
- //切换编辑状态
- // $('.update1_h').removeClass('hide_f');
- $('.update1_rz').css('display', 'inherit');
- $('.update1_s').css('display', 'none');
- // $('.update1_s').addClass('hide_f');
- $(this).attr('data-btn-status', '2');
- $(this).html(save_update_info);
- // 获取库存数量
- var param = {"RoomID": hotel_room_id, "DistribID": channel_id, "CheckIn": checkin_date, "CheckOut": checkout_date};
- $.post('/hotel/api/get-stock', param, function (data) {
- var info = JSON.parse(data);
- // 处理库存返回结果
- if (info.code == 0) {
- var option = '<option value="0">0</option>';
- for (var i = 1; i <= info.data; i++) {
- option += '<option value="' + i + '">' + i + '</option>';
- }
- $('#min_room_count').html(option);
- $('#min_room_count').val(room_num);
- }
- }, 'json');
-
- }
- if ('2' == btn_status || "3" == btn_status) {
- // ZZLog('保存入住需求');
- updateOrderInfo();
- }
- })
- //修改销售价
- $('#btn-rz-update-xsj').click(function () {
- //1:修改销售价 2:保存销售价
- var btn_status = $(this).attr('data-btn-status') ? $(this).attr('data-btn-status') : "1";
- if ('1' == btn_status) {
- // ZZLog('修改销售价');
- checkin_copy = $("#stroke_tbody").children().clone();
- $('#btn-rz-cancel').attr('data-main-status', '2');
- $('#btn-rz-cancel').removeClass('hide_f');
- $('#btn-rz-update-xq').addClass('hide_f');
- $('#btn-rz-update-cgj').addClass('hide_f');
- $(this).attr('data-btn-status', '2');
- $(this).html(save_info);
- //切换编辑状态
- $('.update2_h').removeClass('hide_f');
- $('.update2_s').addClass('hide_f');
- // changeStartEndDateXSJ();
- }
- if ('2' == btn_status) {
- // ZZLog('保存销售价');
- //在这里写保存的操作
- $('#btn-rz-cancel').addClass('hide_f');
- $('#btn-rz-update-xq').removeClass('hide_f');
- $('#btn-rz-update-cgj').removeClass('hide_f');
- $(this).attr('data-btn-status', '1');
- $(this).html('修改销售价');
- //浏览状态
- $('.update2_h').addClass('hide_f');
- $('.update2_s').removeClass('hide_f');
-
- loading();
-
- var cus_list = [];
- $('.tr_line').each(function () {
- var run_date = $(this).children('td').find('.room_run_date').html();//.children().val(); //.children('input').val();
- var sale_price = $(this).children('td').find('.tr_single_price').val();
- var obj = {run_date: run_date, sale_price: sale_price};
- cus_list.push(obj);
- });
-
- var data = JSON.stringify(cus_list);
- $.post('/hotel/ordermain/update-sale-price', {data: data, order_id: order_id}, function (data) {
- if (data.code != 0) {
- ZZAlertInfo(data.info, function () {
- closeLoading();
- });
- } else {
- document.location.reload();
- }
- }, 'json');
- }
- })
- //修改采购价
- $('#btn-rz-update-cgj').click(function () {
-
- //1:修改采购价 2:保存并生成修改单 3:保存采购价
- var btn_status = $(this).attr('data-btn-status') ? $(this).attr('data-btn-status') : "1";
- if ('1' == btn_status) {
- // ZZLog('修改采购价');
- checkin_copy = $("#stroke_tbody").children().clone();
- $('#btn-rz-cancel').attr('data-main-status', '3');
- $('#btn-rz-cancel').removeClass('hide_f');
- $('#btn-rz-update-xq').addClass('hide_f');
- $('#btn-rz-update-xsj').addClass('hide_f');
- //切换编辑状态
- $('.update3_h').removeClass('hide_f');
- $('.update3_s').addClass('hide_f');
-
- $(this).attr('data-btn-status', '3');
- $(this).html(save_info);
- // click_three_btn($(this));
- }
- if ('2' == btn_status || "3" == btn_status) {
- loading();
- $('#btn-rz-cancel').addClass('hide_f');
- $('#btn-rz-update-xq').removeClass('hide_f');
- $('#btn-rz-update-xsj').removeClass('hide_f');
- $(this).attr('data-btn-status', '1');
- $(this).html('修改采购价');
- //浏览状态
- $('.update3_h').addClass('hide_f');
- $('.update3_s').removeClass('hide_f');
- var cus_list = [];
- var tr = $('.tr_line');
- tr.each(function () {
- var run_date = $(this).children('td').find('.room_run_date').html();//.children().val(); //.children('input').val();
- var base_price = $(this).children('td').find('.cai_base_price').val();
- var obj = {run_date: run_date, base_price: base_price};
- cus_list.push(obj);
- });
-
- var data = JSON.stringify(cus_list);
- $.post('/hotel/ordermain/update-purchase-price', {data: data, order_id: order_id}, function (data) {
- if (data.code == 0) {
- document.location.reload();
- closeLoading();
- } else {
- // todo 弹框提示修改失败
- console.log(data);
- closeLoading();
- }
-
- }, 'json');
- }
- })
-
- function getRoomPriceList() {
- var days = DateDiff(start_date, end_date);
- $('#datediff').html(`共${days}晚`);
- }
-
- //计算天数差的函数,通用
- function DateDiff(sDate1, sDate2) { //sDate1和sDate2是2002-12-18格式
- var aDate, oDate1, oDate2, iDays
- aDate = sDate1.split("-")
- oDate1 = new Date(aDate[1] + '-' + aDate[2] + '-' + aDate[0]) //转换为12-18-2002格式
- aDate = sDate2.split("-")
- oDate2 = new Date(aDate[1] + '-' + aDate[2] + '-' + aDate[0])
- iDays = parseInt(Math.abs(oDate1 - oDate2) / 1000 / 60 / 60 / 24) //把相差的毫秒数转换为天数
- return iDays
- }
-
- function changeStartEndDate(org_id) {
- var start_date = $('#start_date').find('input').val();
- var end_date = $('#end_date').find('input').val();
- $('#start_date_txt').html(start_date);
- $('#end_date_txt').html(end_date);
- var room_num = $('#min_room_count').val();
- if (room_num != 0) {
- $('#total_room_count').html(room_num);
- } else {
- room_num = $('#total_room_count').html();
- }
-
- var channel_num = org_id || channel_id;
- var days = DateDiff(start_date, end_date);
- $('#datediff').html("共" + days + "晚");
-
- var flag = false;
- var param = {"RoomID": hotel_room_id, "DistribID": channel_num, "CheckIn": start_date, "CheckOut": end_date};
- $.ajax({
- type: "POST",
- url: "/hotel/api/get-stock",
- data: param,
- async: false,
- dataType: 'json',
- success: function (data) {
- var info = JSON.parse(data);
- // 处理库存返回结果
- if (info.code == 0) {
- var option = '<option value="0">0</option>';
- for (var i = 1; i <= info.data; i++) {
- option += '<option value="' + i + '">' + i + '</option>';
- }
- $('#min_room_count').html(option);
- $('#min_room_count').val(room_num);
- }
- if (info.data == 0) {
- flag = true;
- }
- }
- });
-
- if (flag) return false;
- // ZZLog(JSON.stringify(data));
- // loading();
- var param = {
- "RoomNum": room_num,
- "RoomID": hotel_room_id,
- "DistribID": channel_num,
- "CheckIn": start_date,
- "CheckOut": end_date
- };
- $.ajax({
- type: "post",
- url: '/hotel/ordermain/get-price-list',
- async: true,
- data: param,
- dataType: "json",
- success: function (res_data) {
- // ZZLog(res_data);
- // data = JSON.parse(res_data);
- if (res_data.code != "0") {
- ZZAlertInfo(res_data.info, function () {
- closeLoading();
- });
- }
- else {
- loadStockHtml(res_data.data);
- closeLoading();
- }
- },
- error: function () {
- ZZAlertInfo(infoApiError, function () {
- closeLoading();
- });
- }
- });
- }
-
- function loadStockHtml(stock_list) {
-
- var room_count = $('#min_room_count').val();
- var checin_copy = $('#stroke_tbody').children().clone();
- var sumHTML = '';
- stock_list.forEach(function (v, i) {
- var HTML = `<tr class="tr_line" height="30" data-json=[data-json] data-json-maiduan=[data-json-maiduan] data-json-baoliu=[data-json-baoliu] data-json-xianxun=[data-json-xianxun]>
- <td><span class="room_run_date">[入住日期]</span></td>
- <td>
- <span class="update2_s sale_single_price">[销售单价]</span>
- <span class="hide_f update2_h">
- <input name="OrderMain[ORDER_PRICE]" data-price="[销售单价]" type="text" class="form-control tr_single_price" style="width: 80px;" value="[销售单价]">
- </span>
- </td>
- <td>
- <span class="update3_s cai_base_price_txt">[采购成本价]</span>
- <span class="hide_f update3_h">
- <input name="OrderMain[BASE_PRICE]" data-price="[采购成本价1]" type="text" class="form-control cai_base_price" style="width: 80px;" value="[采购成本价1]">
- </span>
- </td>
- <td class="tr_all_price">[销售总价]</th>
- <td class="tr_mid_price" data-commission=0.00>0.00</th>
- <td class="tr_all_commission" data-commission=[渠道佣金]>[渠道佣金]</th>
- <td class="tr_profit_value">[利润]</th>
- </tr>`;
- var order_price = (v['CUS_PRICE'] == 0) ? v['PROD_PRICE'] : v['CUS_PRICE'];
- var total_order_price = (order_price * room_count).toFixed(2);
- HTML = HTML.replace('[入住日期]', v['RUN_DATE']);
- HTML = HTML.replace('[间数1]', room_count);
- HTML = HTML.replace('[销售单价]', order_price);
- HTML = HTML.replace(/\[销售单价]/g, order_price);
- HTML = HTML.replace('[销售总价]', total_order_price);
- HTML = HTML.replace('[data-json]', v);
- //计算佣金
- var commsion_price = getCommision(room_count, order_price, v).toFixed(2);
- // HTML = HTML.replace('[渠道佣金]', commsion_price);
- HTML = HTML.replace(/\[渠道佣金]/g, commsion_price);
-
- // HTML = HTML.replace('[销售单价]', order_price * );
- //得到替换数量,逻辑:先判断超售oversell_flag,1为可以超售,如果可以超售则取data['order_list'][1]中的该天所有库存,超了不能下单。
- var base_price_str = 0;
- var base_price = 0;
- if (parseInt(room_count) <= parseInt(v['BUYOUT'])) {
- base_price = v['BASE_PRICE_BUYOUT'];
- base_price_str = room_count + '*' + v['BASE_PRICE_BUYOUT'] + '/' + room_count;
-
- } else if (parseInt(room_count) <= parseInt(v['BUYOUT']) + parseInt(v['RETAIN'])) {
- base_price = (v['BUYOUT'] * v['BASE_PRICE_BUYOUT'] + (room_count - v['BUYOUT']) * v['BASE_PRICE_RESERVE']) / room_count;
- base_price_str = '(' + v['BUYOUT'] + '*' + v['BASE_PRICE_BUYOUT'] + '+ (' + room_count + '-' + v['BUYOUT'] + ') *' + v['BASE_PRICE_RESERVE'] + ')/' + room_count;
- }
- else if (parseInt(room_count) <= parseInt(v['BUYOUT']) + parseInt(v['RETAIN']) + parseInt(v['INQUIRY'])) {
- base_price = (v['BUYOUT'] * v['BASE_PRICE_BUYOUT'] + v['RETAIN'] * v['BASE_PRICE_RESERVE'] + (room_count - v['BUYOUT'] - v['RETAIN']) * v['BASE_PRICE_INQUIRY'] ) / room_count;
- base_price_str = '(' + v['BUYOUT'] + '*' + v['BASE_PRICE_BUYOUT'] + '+' + v['RETAIN'] + '*' + v['BASE_PRICE_RESERVE'] + '+(' + room_count + '-' + v['BUYOUT'] + '-' + v['RETAIN'] + ') *' + v['BASE_PRICE_INQUIRY'] + ')/' + room_count;
- }
-
- base_price = Number(base_price).toFixed(2);
-
- // HTML = HTML.replace('[采购成本价]', base_price+'(' + base_price_str + ')');
- HTML = HTML.replace('[采购成本价]', base_price);
- HTML = HTML.replace(/\[采购成本价1]/g, base_price);
- var unit_profit = ((order_price - base_price) * room_count).toFixed(2); // 销售总利润
- HTML = HTML.replace('[利润]', unit_profit);
- sumHTML += HTML;
- });
- sumHTML += `<tr>
- <th class="" colspan="3"> 小计</th>
- <th style="text-align: right" class="th_footer"><span id="all_price"></span></th>
- <th style="text-align: right" class="th_footer"><span id="mid_all_commission"></span></th>
- <th style="text-align: right" class="th_footer"><span id="all_commission"></span></th>
- <th style="text-align: right" class="th_footer"><span id="profit_value"></span></th>
- </tr>`;
- $('#stroke_tbody').html(sumHTML);
- sum_price();
- }
-
-
- $('#update-customer-info').click(function () {
- $(this).addClass('hide_f');
- $('.border-style').css('border-width', '1');
- $('.update-customer-info').removeClass('hide_f');
- });
-
-
- $('#btn-customer-cancel').click(function () {
- $('.update-customer-info').addClass('hide_f');
- $('.border-style').css('border-width', '0');
- $('#update-customer-info').removeClass('hide_f');
- $('#customer').find('input').focus().blur();
- });
-
- // 佣金规则计算
- function getCommision(room_count, room_price, dict) {
- // 佣金规则
- var commision_price = 0;
- if (dict['COMMISION_FLAG'] == '1') { //有佣金规则
- if (dict['BACK_COMMISION_METHOD'] == '309') { //308 按销售金额309 按结算金额
- commision_price = room_count * 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;
- }
- return commision_price;
- }
-
- // getProductInfo();
- $("#datetimeStart").datetimepicker({
- format: 'yyyy-mm-dd',
- minView: 'month',
- language: 'zh-CN',
- autoclose: true,
- todayHighlight: true
- }).on("click", function () {
- $("#datetimeStart").datetimepicker("setEndDate", $("#datetimeEnd").val())
- });
- $("#datetimeEnd").datetimepicker({
- format: 'yyyy-mm-dd',
- minView: 'month',
- language: 'zh-CN',
- autoclose: true,
- todayHighlight: true
- }).on("click", function () {
- $("#datetimeEnd").datetimepicker("setStartDate", addDate($("#datetimeStart").val(), 1))
- });
-
-
- function minusDate(date, days) {
- if (days == undefined || days == '') {
- days = 1;
- }
- var date = new Date(date);
- date.setDate(date.getDate() - days);
- var month = date.getMonth() + 1;
- var day = date.getDate();
- return date.getFullYear() + '-' + getFormatDate(month) + '-' + getFormatDate(day);
- }
-
- function addDate(date, days) {
- if (days == undefined || days == '') {
- days = 1;
- }
- var date = new Date(date);
- date.setDate(date.getDate() + days);
- var month = date.getMonth() + 1;
- var day = date.getDate();
- return date.getFullYear() + '-' + getFormatDate(month) + '-' + getFormatDate(day);
- }
-
- // 日期月份/天的显示,如果是1位数,则在前面加上'0'
- function getFormatDate(arg) {
- if (arg == undefined || arg == '') {
- return '';
- }
-
- var re = arg + '';
- if (re.length < 2) {
- re = '0' + re;
- }
- return re;
- }
-
- $('.comment-type').click(function () {
- var type = $(this).attr('data-value');
- $('#comment-type-val').val(type);
- });
|