123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243 |
- var allCustomerId = "";
- /**
- * 打开商品列表
- */
- function add_product() {
- layer_show("商品列表",url_path + "/admin/salesOrder/to_add_product","1000","500");
- }
- /**
- * 打开客诉列表
- */
- function add_customer() {
- layer_show("客诉列表",url_path + "/admin/customer/to_add_customer_list","1000","500");
- }
- $(function(){
- $("#salesOrderStatus").change(function(){
- var status = $(this).val();
- if(status == 1){ //正常订单
- $("#selectCustomer").hide();
- $("#salesCustomer").hide();
- $("#salesCustomerIdHtml").html("");
- $("#salesCustomerId").val("");
- }else{
- $("#selectCustomer").show();
- $("#salesCustomer").show();
- $("#salesCustomerIdHtml").html("未选择客诉编号!");
- }
- })
- });
- $(function(){
- var loadIndex = 0;
- $("#form-order-add").Validform({
- tiptype: function (msg, o, cssctl) {
- if (o.type == 3) {//失败
- layer.msg(msg, {icon: 5, time: 3000});
- $(window).scrollTop(o.obj.offset().top - 40);
- }
- },
- datatype: {//自定义验证类型
- },
- ignoreHidden: true,
- tipSweep: true, //若为true,则只在表单提交时验证
- ajaxPost: true, //异步提交
- beforeCheck: function (curform) { //验证通过之前执行的函数
- var flag = false;
- },
- beforeSubmit: function (curform) { //验证通过之后执行的函数
- if(!isNameCorrect){
- var falg = ulc.getIsNameCorrect();
- if(!falg){
- vailErrorMsg_5($("#addressDesc"),"地址信息匹配错误,请检查地址信息!");
- isNameCorrect = true;
- $("#addrssMsg").css("color","#c00");
- return false;
- }
- }
- var addressProvince = $("#addressProvince").find("option:selected").text();
- var addressCity = $("#addressCity").find("option:selected").text();
- var addressCountry = $("#addressCountry").find("option:selected").text();
- var addressDesc = $("#addressDesc").val();
- var salesAddressInfo = addressProvince + " " + addressCity + " " + addressCountry + " " + addressDesc
- $("#salesAddressInfo").val(salesAddressInfo);
- var flag = false;
- /*封装订单项*/
- var orderItemArray = new Array();
- $("#add_product").find("tr").each(function(){
- var orderItem = new Object();
- orderItem.itemColorId = $(this).find(".color_id").val();
- orderItem.itemNum = $(this).find(".item-num").val();
- orderItemArray.push(orderItem);
- flag = true;
- });
- if(!flag){
- vailErrorMsg($(".add-order-button"),"必须要有一个产品");
- return false;
- }
- $("#orderItemString").val(JSON.stringify(orderItemArray));
- loadIndex = layer.load(1, {
- shade: [0.5,'#fff'] //0.1透明度的白色背景
- });
- },
- callback: function (data) {//异步回调函数
- if (data) {
- var index = layer.alert(data.resultMsg, function (index) {
- if (data.resultCode == 200) {
- location.href = url_path + "/admin/salesOrder/list_order_page";
- }else {
- layer.close(index);
- }
- });
- if(loadIndex != 0 ){
- layer.close(loadIndex);
- }
- }
- return false;
- }
- });
- });
- /**
- * 客诉回调
- * @param colorIds
- */
- function setSelectCustomer(customerId){
- var index = layer.load(1, {
- shade: [0.5,'#fff'] //0.1透明度的白色背景
- });
- $.ajax({
- type: "POST",
- data: { customerId : customerId},
- url: url_path +"/admin/customer/get_customer_info",
- success: function(data){
- if (data.returnCode == 200 && data.returnMsg.customer != null ) {
- var customer = data.returnMsg.customer;
- $("#salesOrderStatus").val(2);
- $("#salesCustomerIdHtml").html("已经选择客诉记录:"+customer.customerId);
- $("#salesCustomerId").val(customer.customerId);
- sc.setCompanyId(customer.companyId);
- sc.setStoreId(customer.storeId);
- /*设置用户姓名、电话*/
- $("#salesAddressName").val(customer.customerName);
- $("#salesAddressTel").val(customer.customerTel);
- /* 售后订单的支付时间、支付方式默认 */
- $("#salesPayTime").val(customer.salesTime+" 08:00:00");
- // sc.setUlcById(0,1,11);
- ulc.setUlcById(0,customer.customerProvinceId,customer.customerCityId,customer.customerDistrictId);
- }else{
- }
- $("#salesCustomer").show();
- }
- });
- layer.close(index);
- }
- /**
- * 选择商品回调
- * @param colorIds
- */
- function setSelectProduct(colorIds){
- var index = layer.load(1, {
- shade: [0.5,'#fff'] //0.1透明度的白色背景
- });
- $("#all_add_product").show();
- var colorIdArray = colorIds.split("_");
- for(var i=0;i<colorIdArray.length;i++){
- var colorId = colorIdArray[i];
- if(colorId == ""){
- break;
- }
- var flag = true;
- $("#add_product").find("tr").each(function (){
- var colId = $(this).find(".color_id").eq(0).val();
- if(colId == colorId){
- flag = false;
- }
- })
- if(!flag){
- continue;
- }
- $.ajax({
- type: "POST",
- data: { colorId : colorId},
- url: url_path +"/admin/product/get_product",
- success: function(data){
- var html = "";
- if (data.returnCode == 200 && data.returnMsg.productColorList.length > 0 ) {
- for(var i=0;i<data.returnMsg.productColorList.length;i++){
- var productColor = data.returnMsg.productColorList[i];
- html += '<tr class="text-c">' +
- '<input type="hidden" class="color_id" id="" value="'+ productColor.colorId +'" >' +
- '<input type="hidden" class="color_price" id="" value="'+ productColor.colorPrice +'" >' +
- '<input type="hidden" class="color_discount" id="" value="'+ productColor.colorDiscount +'" >' +
- ' <td>'+ cufte(productColor.productName) +'</td>' +
- ' <td>'+ cufte(productColor.colorName) +'</td>' +
- ' <td>'+ cufte(productColor.colorPrice)/100 +'</td>' +
- ' <td>'+ cufte(productColor.colorBar) +'</td>' +
- ' <td><input type="text" class="input-text input-number item-num" value="1" style="width: 100%;border: none;text-align: center;" name="" id="" placeholder="产品数量" onkeyup="keyFun($(this),999,1)" onpaste="keyFun($(this),999,1)"></td>' +
- ' <td><a href="javascript:void(0)" class="del_product all_down" onclick="delProduct($(this))" >删除</a></td>' +
- ' </tr>';
- }
- }else{
- html = '<tr class="text-c"><td colspan="12">没有搜索到商品,请重试!</td></tr>';
- }
- $("#add_product").append(html);
- /*计算价格*/
- calculatePrice();
- }
- });
- }
- layer.close(index);
- }
- /**
- * 删除商品
- */
- function delProduct($this){
- $this.parents("tr").remove();
- }
- /**
- * 计算价格
- */
- function calculatePrice(){
- /*总价,折扣价,优惠金额*/
- var colorDiscountAll = 0,colorPriceAll = 0,salesPayMoneyAll=0;
- $("#add_product").find("tr").each(function(){
- var colorDiscount = 0,colorPrice = 0,salesPayMoney=0,itemNum=0;
- colorDiscount = parseInt($(this).find(".color_discount").val())/100;
- colorPrice = parseInt($(this).find(".color_price").val())/100;
- itemNum = $(this).find(".item-num").val();
- if(!isEmpty(itemNum)){
- return;
- }
- itemNum = parseInt(itemNum);
- salesPayMoney = colorPrice -colorDiscount;
- if(salesPayMoney < 0){
- salesPayMoney = 0;
- }
- colorDiscountAll += colorDiscount*itemNum;
- colorPriceAll += colorPrice*itemNum;
- salesPayMoneyAll += salesPayMoney*itemNum;
- })
- $("#salesAmount").val(colorPriceAll);
- $("#salesPayMoney").val(colorDiscountAll);
- $("#salesDiscountMoney").val(salesPayMoneyAll);
- $("#salesLastMoney").val(colorDiscountAll);
- }
|