/** * date: * author: neeler */ //test data start // var data_getList = Mock.mock('/business/getItem.htm', { "item": { "td_shrq": "YYYY-MM-DD", "td_bmbh": "0601", "td_bmmc": null, "td_djrq": "20170626", "td_khmc": "巩义市贝思特贸易有限公司", "td_bz": "发上海 不开票 不带清单", "td_ywrq": "20170626", "td_zdr": "王雅", "td_tdbh": "TD-17060001", "td_tdls": "43" }, "code": 0, "list|3-50": [{"tdmx_wlbh": "D8F001","tdmx_wlmc": "8系热轧箔","tdmx_tdfl": "0000000001","tdmx_tdls": "43","tdmx_hjzt": null,"tdmx_dwmx": "吨","tdmx_fdcph": "GFC1706N80075-1","tdmx_bhse": 15372.56,"tdmx_mz": 0.764,"tdmx_pz": 0,"tdmx_jz": 0.679,"tdmx_shdw": "巩义市贝思特贸易有限公司","tdmx_fhdw": "河南眀泰","tdmx_tdlx": "欠款提货","tdmx_sl": 17,"tdmx_ggxh": "0.04*500*C","tdmx_sfzc": "0.0","tdmx_fdcph": "豫C555555", "tdmx_bz": "tdmx_bz", "tdmx_hw": "tdmx_hw"}]}) // var data_getVehicleList = Mock.mock('/business/getVehicleList.htm', {code: 0, 'list|5-30': [{vehicleId: 'vehicleId', feature: 'feature', note: 'note', fdnum: 'fdnum', fdweight: '4.551', vehicleweight: 'vehicleweight', loadweight: '51.111', driver: 'driver', phone: 'phone'}]}) // var data_validVehicle = Mock.mock('/business/validVehicle.htm', {code: 0, errmsg: '车牌号不能使用!'}) // var data_doUnbind = Mock.mock('/business/doUnbind.htm', {code: 0, }) // var data_doBind = Mock.mock('/business/doBind.htm', {code: 0, }) // var data_getallList = Mock.mock('/vehicle/getallList.htm', {"rowCount":0,"pagesize":0,"pages":0,"page":0,"items":null,"list":[{"note":null,"companyNo":"009","driver":"九阳神功","loadweight":15.0,"phone":"13007607721","companyName":"运输部","rownumber":1,"id|+1": 1,"state":1,"vehicleId":"豫A11111","vehicleweight":10.0}],"hint":null,"errmsg":null,"code":0}) // var data_saveItem = Mock.mock('/business/saveItem.htm', {code: 0, }) // var data_doDel = Mock.mock('/transport/yscompany/del.htm', {code: 0, errmsg: 'errmsg'}) // var data_doSave = Mock.mock('/transport/yscompany/save.htm', {code: 0, errmsg: 'errmsg'}) //test data end /* * 配车成功 ---- 需要添加随行人员 ---- 是否立即添加 随行人员 ----- 确定 --- 跳转到添加页面(绑定车辆、业务单、人员关系) ---车辆任务页面也可以添加或修改(绑定车辆、业务单、人员关系) */ var SORT = [ {key: '批次号', value: 'tdmx_fdcph', visible: ko.observable(true)}, {key: '规格型号', value: 'tdmx_ggxh', visible: ko.observable(true)}, {key: '包装', value: 'tdmx_zpbz', visible: ko.observable(true)}, {key: '货位', value: 'tdmx_hwbh', visible: ko.observable(true)}, {key: '毛重', value: 'tdmx_mz', visible: ko.observable(true)}, {key: '净重', value: 'tdmx_jz', visible: ko.observable(true)} ] window.I = { _lastIndex: 0, nowVehicle: null, no: $('#no').val(), allNumBtn: $('#allNumBtn'), bindNumBtn: $('#bindNumBtn'), unbindNumBtn: $('#unbindNumBtn'), vehicleKeyword: $('#vehicleKeyword'), searchVehicleBtn: $('#searchVehicleBtn'), refreshVehicleBtn: $('#refreshVehicleBtn'), tempVehicleModal: $('#tempVehicleModal'), addTempVehicle: $('#addTempVehicle'), tempVehicleSaveBtn: $('#tempVehicleSaveBtn'), selectAllBtn: $('#selectAllBtn'), selectNoBtn: $('#selectNoBtn'), clearSelectBtn: $('#clearSelectBtn'), bindBtn: $('#bindBtn'), unbindBtn: $('#unbindBtn'), piciKeyword:$('#piciKeyword'), searchpiciBtn:$('#searchpiciBtn'), SortBtn:$('#SortBtn'), modal: $('#modal'), clearSortBtn: $('#clearSortBtn'), ssortBtn:$('#searchSortBtn'), sxBtn:$('#sxBtn'), personModal:$("#personModal"), addPerson: $("#addPerson") } var Obj = { vehicleId: '豫A', driver: '', phone: '', IDNum: '', vehicleweight: '', loadweight: '', note: '', feature: '' } var TD = { td_bmbh: '', td_bmmc: '', td_bz: '', td_djrq: '', td_khmc: '', td_tdbh: '', td_tdls: '', td_ywrq: '', td_zdr: '', td_shrq: '', td_shsj: '', td_fpbh:'' } var ViewModel = function() { var self = this; self.o = ko.observable(ko.mapping.fromJS(Obj)); self.td = ko.observable(TD); self.vList = ko.observableArray(); self.list = ko.observableArray(); self.isAdmin = ko.observable(typeof(parent.G) != 'undefined' ? parent.G.isAdmin : false); self.isSelectAll = ko.observable(false); self.allNum = ko.observable(0); self.bindNum = ko.observable(0); self.unbindNum = ko.observable(0); self.selectedNum = ko.observable(0); self.selectedMZ = ko.observable(0); self.selectedJZ = ko.observable(0); self.select = function (item) { I.nowVehicle = {}; for(attr in item) { I.nowVehicle[attr] = item[attr]; } $('#_vhicleId').text(item.vehicleId); $('#_lastweight').text(item.lastweight); $('#_fdweight').text(item.fdweight); $('#_fdnum').text(item.fdnum); $('#_loadweight').text(item.loadweight); $('#vehicleMessage').show(); } self.check = function (item) { self.list.removeAll(); $.each(I._MDB, function (index, value) { if (value.tdmx_fdcph() === item.vehicleId) { self.list.push(value); } }); setMaterialTableEvent(); computedSelect(); } self.vehicleTasks = function (item) { gotoVehicleDetails(item); } self.oList = ko.observableArray(SORT); self.soList = ko.observableArray(); self.addSort = function (item) { addSort(item); } self.removeSort = function (item) { removeSort(item); } } $(function () { window.vm = new ViewModel(); ko.applyBindings(vm); autoHeight(); getVehicleList(); if (!!I.no) { getList(I.no); } pageInit(); }); function pageInit() { I.unbindBtn.click(function (e) { e.preventDefault(); if ($('.mitem.info').length) { validMessage('确定要取消配车吗?', doUnbind) } else { parent.showErrmsg('请选择一个提单物资!'); } }); I.bindBtn.click(function (e) { e.preventDefault(); if ($('.mitem.info').length) { doBind(); } else { parent.showErrmsg('请选择一个提单物资!'); } }); I.tempVehicleSaveBtn.click(function (e) { e.preventDefault(); if (valid()) { validVehicle(); } }); I.addTempVehicle.click(function (e) { e.preventDefault(); vm.o(ko.mapping.fromJS(Obj)); I.tempVehicleModal.modal('show'); }); // I.addPerson.click(function (e) { // e.preventDefault(); // // vm.o(ko.mapping.fromJS(Obj)); // // I.personModal.modal('show'); // var item = {businessNo:'XS202203060079',vehicleId: '沪EJ3876'} // addPersonTab(item); // }); I.tempVehicleModal.on('hidden.bs.modal', function (e) { clearError(); }); I.vehicleKeyword.keyup(function (e) { // updateVList(); getVehicleList(); }); I.searchVehicleBtn.click(function (e) { e.preventDefault(); // updateVList(); getVehicleList(); }); I.refreshVehicleBtn.click(function (e) { e.preventDefault(); getVehicleList(); }); I.allNumBtn.click(function (e) { e.preventDefault(); $('.mStatus').removeClass('btn-info'); $(this).addClass('btn-info'); vm.list.removeAll(); $.each(I._MDB, function (index, value) { vm.list.push(value); if(value.chooseCli){ $('.mitem:last').addClass("info"); } }); setMaterialTableEvent(); computedSelect(); }); I.bindNumBtn.click(function (e) { e.preventDefault(); $('.mStatus').removeClass('btn-info'); $(this).addClass('btn-info'); vm.list.removeAll(); $.each(I._MDB, function (index, value) { if (value.tdmx_fdcph() !== '') { if($('#piciKeyword').val()=='' || value.tdmx_fdcph.indexOf($('#piciKeyword').val())>0){ vm.list.push(value); if(value.chooseCli){ $('.mitem:last').addClass("info"); } } } }); setMaterialTableEvent(); computedSelect(); }); I.unbindNumBtn.click(function (e) { e.preventDefault(); $('.mStatus').removeClass('btn-info'); $(this).addClass('btn-info'); vm.list.removeAll(); $.each(I._MDB, function (index, value) { if (value.tdmx_fdcph() == '') { if($('#piciKeyword').val()=='' || value.tdmx_fdcph.indexOf($('#piciKeyword').val())>0){ vm.list.push(value); if(value.chooseCli){ $('.mitem:last').addClass("info"); } } } }); setMaterialTableEvent(); computedSelect(); }); I.selectAllBtn.click(function (e) { e.preventDefault(); for(var i=0;i0){ I._MDB[i].chooseCli=true; } } }else if(I.unbindNumBtn.hasClass('btn-info')){ if (I._MDB[i].tdmx_fdcph() == '') { if($('#piciKeyword').val()=='' || I._MDB[i].tdmx_fdcph.indexOf($('#piciKeyword').val())>0){ I._MDB[i].chooseCli=true; } } }else{ if($('#piciKeyword').val()=='' || I._MDB[i].tdmx_fdcph.indexOf($('#piciKeyword').val())>0){ I._MDB[i].chooseCli=true; } } } $('.mitem').addClass('info'); computedSelect(); }); I.selectNoBtn.click(function (e) { e.preventDefault(); for(var i=0;i0){ I._MDB[i].chooseCli=false; } } }else if(I.unbindNumBtn.hasClass('btn-info')){ if (I._MDB[i].tdmx_fdcph() == '') { if($('#piciKeyword').val()=='' || I._MDB[i].tdmx_fdcph.indexOf($('#piciKeyword').val())>0){ I._MDB[i].chooseCli=false; } } }else{ if($('#piciKeyword').val()=='' || I._MDB[i].tdmx_fdcph.indexOf($('#piciKeyword').val())>0){ I._MDB[i].chooseCli=false; } } } $('.mitem').removeClass('info'); computedSelect(); }); I.searchpiciBtn.click(function (e) { e.preventDefault(); if($('#piciKeyword').val()!=''){ vm.list.removeAll(); $.each(I._MDB, function (index, value) { if(value.tdmx_fdcph.indexOf($('#piciKeyword').val())>0){ if(I.bindNumBtn.hasClass('btn-info')){ if (value.tdmx_fdcph() !== '') { vm.list.push(value); if(value.chooseCli){ $('.mitem:last').addClass("info"); } } }else if(I.unbindNumBtn.hasClass('btn-info')){ if (value.tdmx_fdcph() == '') { vm.list.push(value); if(value.chooseCli){ $('.mitem:last').addClass("info"); } } }else{ vm.list.push(value); if(value.chooseCli){ $('.mitem:last').addClass("info"); } } } }); setMaterialTableEvent(); computedSelect(); }else{ vm.list.removeAll(); $('.mStatus').removeClass('btn-info'); I.unbindNumBtn.addClass('btn-info'); $.each(I._MDB, function (index, value) { if (value.tdmx_fdcph()== '') { vm.list.push(value); if(value.chooseCli){ $('.mitem:last').addClass("info"); } } }); setMaterialTableEvent(); computedSelect(); } }); I.clearSelectBtn.click(function (e) { e.preventDefault(); for(var i=0;i0){ vm.list.push(value); if(value.chooseCli){ $('.mitem:last').addClass("info"); } } } }else if(I.unbindNumBtn.hasClass('btn-info')){ if (value.tdmx_fdcph() == '') { if($('#piciKeyword').val()=='' || value.tdmx_fdcph.indexOf($('#piciKeyword').val())>0){ vm.list.push(value); if(value.chooseCli){ $('.mitem:last').addClass("info"); } } } }else{ if($('#piciKeyword').val()=='' || value.tdmx_fdcph.indexOf($('#piciKeyword').val())>0){ vm.list.push(value); if(value.chooseCli){ $('.mitem:last').addClass("info"); } } } }); setMaterialTableEvent(); computedSelect(); }); I.sxBtn.click(function(e){ e.preventDefault(); I.piciKeyword.val(''); getList(I.no); $('.mStatus').removeClass('btn-info'); I.allNumBtn.addClass('btn-info'); }); } function doBind() { if (!!I.AjaxdoBind) { return; } var list = []; var vehicle = I.nowVehicle; if (!vehicle) { parent.showErrmsg('请选择一个车辆!'); return; } // var result = true; $.each(I._MDB,function(index,value){ if(value.chooseCli){ if($.trim(value.tdmx_fdcph())!=''){ swal({title:'',text:'选择的配车物资' + value.tdmx_wlmc + '已经配过车!',type:'error',confirmButtonText:'确定'}); // result = false; return false; }else{ list.push({ tdls: value.tdmx_tdls, tdfl: value.tdmx_tdfl }) }; } }); if(!list.length){ swal({title:'',text:'请选择配车物资!',type:'error',confirmButtonText:'确定'}); return ; } // $.each($('.mitem.info'), function (index, value) { // var indx = $(this).attr('data-indx'); // $.each(vm.list(), function (index, value) { // if (indx === value.indx) { // if (value.tdmx_fdcph() != '') { // swal({title:'',text:'选择的配车物资' + value.tdmx_wlmc + '已经配过车!',type:'error',confirmButtonText:'确定'}); // result = false; // return false; // } else { // list.push({ // tdls: value.tdmx_tdls, // tdfl: value.tdmx_tdfl // }) // } // } // }); // if (!result) { // return false; // } // }); // if (!result) { // return; // } I.AjaxdoBind = true; I.bindBtn.prop('disabled', true); $.post("/business/doBind.htm", {list: $.toJSON(list), vehicle: $.toJSON(vehicle), tdbh: I.no}, function (data, textStatus, jqXHR) { I.AjaxdoBind = false; I.bindBtn.prop('disabled', false); if (data.code >= 1) { swal({title:'',text:data.errmsg,type:'error',confirmButtonText:'确定'}); return; } if (data.code == 0) { showErrmsg('配车成功!'); $.each(I._MDB, function (index, value) { if(value.chooseCli){ value.tdmx_fdcph(I.nowVehicle.vehicleId); console.log("::dd::"+value); $.each(vm.list(), function (index, vv) { if (value.tdmx_fdcph === vv.tdmx_fdcph) { vv.tdmx_fdcph(I.nowVehicle.vehicleId); } }); } }); // $.each($('.mitem.info'), function (index, value) { // var indx = $(this).attr('data-indx'); // $.each(I._MDB, function (index, value) { // if (indx === value.indx) { // value.tdmx_fdcph(I.nowVehicle.vehicleId); // } // }); // $.each(vm.list(), function (index, value) { // if (indx === value.indx) { // value.tdmx_fdcph(I.nowVehicle.vehicleId); // } // }); // }); // 配车 updateNum(); var item = {businessNo: data.item.businessNo, vehicleId: vehicle.vehicleId} confirmAddCarPersonTab(item); getVehicleList(); return; } }, "json" ); } function confirmAddCarPersonTab(item) { swal({ title: "是否需要添加随车人员?", text: "如果不添加或需要修改,请到车辆任务详情处操作。", type: "warning", showCancelButton: true, confirmButtonColor: "#1c84c6", confirmButtonText: "确定", cancelButtonText: "取消", closeOnConfirm: true, closeOnCancel: true, }, function (isConfirm) { if (isConfirm) { addPersonTab(item) } }); } function addPersonTab(item){ var businessNo = item.businessNo var vehicleId = item.vehicleId parent.closableTab.addTab({ 'id': "carPersons-" + businessNo + "-" + vehicleId, 'name': '添加随行人员', 'url': '/basic/carPersons.jsf?businessNo=' + businessNo + '&vehicleId=' + vehicleId, 'closable': true }); } function doUnbind() { if (!!I.AjaxdoUnbind) { return; } var list = []; var arrIndx = []; var result = true; $.each(I._MDB, function (index, value){ if(value.chooseCli){ if($.trim(value.tdmx_fdcph()) === ''){ swal({title:'',text:'选择的配车物资' + value.tdmx_wlmc + '还未配车!',type:'error',confirmButtonText:'确定'}); // result = false; return false; // return ture; }else{ list.push({ tdls: value.tdmx_tdls, tdfl: value.tdmx_tdfl, vehicleId: value.tdmx_fdcph() }) arrIndx.push(value.tdmx_fdcph); } } }); if (!list.length) { swal({title:'',text:'请选择取消配车物资!',type:'error',confirmButtonText:'确定'}); return; } // $.each($('.mitem.info'), function (index, value) { // var indx = $(this).attr('data-indx'); // $.each(vm.list(), function (index, value) { // if (indx === value.indx) { // if (value.tdmx_fdcph() === '') { // return true; // } else { // list.push({ // tdls: value.tdmx_tdls, // tdfl: value.tdmx_tdfl, // vehicleId: value.tdmx_fdcph() // }) // arrIndx.push(value.indx); // } // } // }); // }); // if (!list.length) { // return; // } I.AjaxdoUnbind = true; I.unbindBtn.prop('disabled', true); $.post("/business/doUnbind.htm", {list: $.toJSON(list), tdbh: I.no}, function (data, textStatus, jqXHR) { I.AjaxdoUnbind = false; I.unbindBtn.prop('disabled', false); if (data.code >= 1) { swal({title:'',text:data.errmsg,type:'error',confirmButtonText:'确定'}); return; } if (data.code == 0) { showErrmsg('取消配车成功!'); $.each(arrIndx, function (index, iv) { $.each(I._MDB, function (index, value) { if (iv === value.tdmx_fdcph) { value.tdmx_fdcph(''); } }); $.each(vm.list(), function (index, value) { if (iv === value.tdmx_fdcph) { value.tdmx_fdcph(''); } }); }); updateNum(); getVehicleList(); return; } }, "json" ); } function getList(keyword) { $.post('/business/getItem.htm', { keyword: keyword }, function(data, textStatus, xhr) { vm.list.removeAll(); if (data.code >= 1) { //parent.showErrmsg(data.errmsg); swal({title:'',text:data.errmsg,type:'error',confirmButtonText:'确定'}); return; } if (data.code == 0) { I._MDB = []; data.item.td_shsj = data.item.td_shsj;//.slice(0, 19); vm.td(data.item); if (isList(data.list)) { $.each(data.list, function (index, value) { value.tdmx_fdcph = ko.observable(value.tdmx_fdcph); value.indx = index + ''; vm.list.push(value); value.chooseCli=false; I._MDB.push(value); }); } setMaterialTableEvent(); computedSelect(); updateNum(); return; } }, 'json'); } function updateNum() { var allNum = I._MDB.length; var unbindNum = 0; $.each(I._MDB, function (index, value) { value.tdmx_fdcph() === '' && unbindNum++; }); vm.allNum(allNum); vm.bindNum(allNum - unbindNum); vm.unbindNum(unbindNum); } function setMaterialTableEvent() { $('.mitem').unbind('click').click(function (e) { var index = $('.mitem').index($(this)); e.preventDefault(); if (e.shiftKey) { setMaterialTrSelected(Math.min(index, I._lastIndex), Math.max(index, I._lastIndex)) } else { I._lastIndex = index; var pchcc=vm.list()[index].tdmx_fdcph; for(var mdblg=0;mdblg= start && index <= end) { var pchcc=vm.list()[index].tdmx_fdcph; for(var mdblg=0;mdblg0){ serlectBoo+=1; } } }else if(I.unbindNumBtn.hasClass('btn-info')){ if (I._MDB[vv].tdmx_fdcph() == '') { if($('#piciKeyword').val()=='' || I._MDB[vv].tdmx_fdcph.indexOf($('#piciKeyword').val())>0){ serlectBoo+=1; } } }else{ if($('#piciKeyword').val()=='' || I._MDB[vv].tdmx_fdcph.indexOf($('#piciKeyword').val())>0){ serlectBoo+=1; } } } } // $.each($('.mitem.info'), function (index, value) { // var indx = $(this).attr('data-indx'); // $.each(I._MDB, function (j, jv) { // if (jv.indx === indx) { // selectedMZ += jv.tdmx_mz; // selectedJZ += jv.tdmx_jz; // } // }); // }); vm.selectedNum(selectedNum); vm.selectedMZ(selectedMZ.toFixed(3)); vm.selectedJZ(selectedJZ.toFixed(3)); if(serlectBoo==0){ vm.isSelectAll(false); }else{ vm.isSelectAll( serlectBoo===vm.list().length); } // if($('.mitem').length==0){ // vm.isSelectAll(false); // }else{ // vm.isSelectAll($('.mitem').length === $('.mitem.info').length); // } } function getVehicleList() { $.post("/business/getVehicleList.htm", { companyNo: vm.isAdmin() ? '' : (typeof(parent.G) != 'undefined' ? parent.G.loginCompanyNo : 'ABCDEFG'), vehicleId:I.vehicleKeyword.val()==undefined?'':I.vehicleKeyword.val() }, function (data, textStatus, jqXHR) { I.VDB = []; if (data.code >= 1) { swal({title:'',text:data.errmsg,type:'error',confirmButtonText:'确定'}); return; } if (data.code == 0) { if (isList(data.list)) { $.each(data.list, function (index, value) { value.indx = index + ''; value.lastweight = ''; if ($.isNumeric(value.loadweight) && $.isNumeric(value.fdweight)) { value.lastweight = (parseFloat(value.loadweight) - parseFloat(value.fdweight)).toFixed(3); } I.VDB.push(value); }); } updateVList(); return; } }, "json" ); } function updateVList() { // var str = I.vehicleKeyword.val(); vm.vList.removeAll(); // if (!!str) { // var reg = new RegExp(str); // $.each(I.VDB, function (index, value) { // if (reg.test(value.vehicleId)) { // vm.vList.push(value); // } // }); // } else { if(I.VDB!=undefined&&I.VDB!=null && I.VDB.length>0){ $.each(I.VDB, function (index, value) { vm.vList.push(value); }); } // } } function valid(){ var isValid = false; var iF = $('#form'); iF.validate({ rules: { 'vehicleId': { required: true, isPlateNumber: true }, 'driver': { required: true, }, 'phone': { required: true, isPhone: true }, 'IDNum': { required: true, } }, messages: { 'vehicleId': { required: '不能为空!', isPlateNumber: '车牌号不正确!' }, 'driver': { required: '不能为空!', }, 'phone': { required: '不能为空!', isPhone: '手机号不正确!' }, 'IDNum': { required: '不能为空!', } }, errorPlacement: function (err, element) { var p = element.parents('.form-group').eq(0); var d = p.find('.text-error').eq(0); d.css('color', '#D9534F'); err.appendTo(d); } }) isValid = iF.valid(); return isValid; } function validVehicle() { $.post("/business/validVehicle.htm", {vehicleId: ko.mapping.toJS(vm.o()).vehicleId.toUpperCase()}, function (data, textStatus, jqXHR) { if (data.code >= 1) { swal({title:'',text:data.errmsg,type:'error',confirmButtonText:'确定'}); return; } if (data.code == 0) { I.nowVehicle = {}; var obj = ko.mapping.toJS(vm.o()); for(attr in obj) { I.nowVehicle[attr] = obj[attr]; } $('#_vhicleId').text(I.nowVehicle.vehicleId); $('#_lastweight').text(I.nowVehicle.lastweight); $('#_fdweight').text(I.nowVehicle.fdweight); $('#_fdnum').text(I.nowVehicle.fdnum); $('#_loadweight').text(I.nowVehicle.loadweight); $('#vehicleMessage').show(); I.tempVehicleModal.modal('hide'); return; } }, "json" ); } function clearError() { $('#form input').removeClass('error'); $('#form .text-error').html(''); } function autoHeight() { $('.page-content').css('min-height', $(parent.window).height() - 117); $('.table-responsive').css('height', $(parent.window).height() - 275); $('.split').css('left', $('.table-vehicle').width() + 12); } function validMessage(message, cb, cbparams) { $("#modalContent").html(message); $("#dialog-confirm").removeClass('hide').dialog({ resizable: false, width: '320', modal: true, title: "

确认信息

", title_html: true, position: { my: "center", at: "center", of: window }, buttons: [ { html: "  确定", "class" : "btn btn-danger btn-minier", click: function() { $( this ).dialog( "close" ); cb(cbparams); } } , { html: "  取消", "class" : "btn btn-minier", click: function() { $( this ).dialog( "close" ); } } ] }); } function gotoVehicleDetails(item) { parent.closableTab.addTab({ 'id': new Date().getTime(), 'name': item.vehicleId + '的配车物资', 'url': '/basic/vehicleBindMaterials.jsf?numberplates=' + encodeURI(encodeURI(item.vehicleId)), 'closable': true }); } function SortList(Obj1,Obj2){ var reval=0; $.each(vm.soList(), function (index, value) { var ASCStr=value.result(); var fieLd=value.target; if(ASCStr==null||ASCStr==''){ ASCStr="asc"; } if(fieLd==null||fieLd==''){ reval=0; } if("asc"==ASCStr){ if(!isNaN(Obj1[fieLd])){ if(Obj1[fieLd]-Obj2[fieLd]>0){ reval=1; return false; }else if(Obj1[fieLd]-Obj2[fieLd]<0){ reval=-1; return false; }else{ reval=0; } }else{ if(Obj1[fieLd]> Obj2[fieLd]){ reval=1; return false; }else if(Obj1[fieLd]< Obj2[fieLd]){ reval=-1; return false; }else{ reval=0; } } }else{ if(!isNaN(Obj1[fieLd])){ if(Obj2[fieLd]-Obj1[fieLd]>0){ reval=1; return false; }else if(Obj2[fieLd]-Obj1[fieLd]<0){ reval=-1; return false; }else{ reval=0; } }else{ if(Obj2[fieLd]> Obj1[fieLd]){ reval=1; return false; }else if(Obj2[fieLd]< Obj1[fieLd]){ reval=-1; return false; }else{ reval=0; } } } }); return reval; } function addSort(item) { item.visible(false); var obj = { key: item.key, target: item.value, result: ko.observable('asc') } vm.soList.push(obj); } function removeSort(item) { vm.soList.remove(item); $.each(vm.oList(), function (index, value) { value.key === item.key && value.visible(true); }); }