1. 程式人生 > >11.8 1.5.1開發結束

11.8 1.5.1開發結束

account blog 如果 alert show studio put row 默認

1.5.1合並了訂單和充值單。

最大的變化時創建/編輯充值單,不再關聯訂單,而是關聯合同,也不再從訂單取相關信息,改為用戶自行選擇。這邊最讓我糾結的是下單產品和下單賬戶的聯動。

在這塊研究了三四天,尤其是編輯時,帶出代理商或者直客時,取到當前下單賬戶,並且渲染出來,而創建時是選擇客戶後進行聯動取數據,其實沒有差別,

但是編輯時獲取下單賬戶總是慢於渲染下單賬戶,因此下單賬戶一直為空。

於是想把渲染下單賬戶這個函數放在獲取下單賬戶方法裏面進行,但是這樣一旦選擇代理商/直客就會渲染下單賬戶。

可是實際上,除了編輯時進入頁面這一情況,只有在選擇下單產品時才需要渲染下單賬戶。

試了好幾次,最終選擇給【getProductList】獲取下單賬戶這一函數多傳兩個參數pCode(下單產品code),pId(該充值單產品賬戶id,用於默認選中該條數據),標識這是編輯,當有這個參數時,在getProductList方法中調用【showAccounts】渲染下單賬戶方法,對頁面進行渲染。否則只是給productList這一全局變量進行賦值。

//取客戶賬戶列表
getProductList: function(code,pCode,pId) {
    MJJS.http.post(API.productList, {customerCode: code}, function(o) {
         productList = o;
         if(pCode && pId) {
              prepaidEdit.showAccounts(pCode,pId);
         }
    }, function(err) {
         MJJS.page.dialog.alert(err.msg);
    });
},

而【showAccounts】這一函數也多加了個參數id,代表當前充值單的產品賬戶id,用於傳遞給函數dom,動態生成html時,選中該條數據。

showAccounts: function(code,id) {
    if(code) {
        var pList = [];//存放當前code的所有產品賬戶
        $.each(productList, function(i,v) {
            if(code === v.productCode) {
               pList.push(v);
            }
        });
        var _html = ‘‘;//存放生成的html
        //如果當前code的產品賬戶為0
        if(pList.length>0) {
            _html = prepaidEdit.dom(code,pList,1,id);
        }else{
            _html = ‘‘;
        }
        $(‘.accounts‘).html(_html);
     }else{
        $(‘.accounts‘).html(‘‘);
     }
},

    //動態生成下單賬戶
        dom: function(code,pList,type,id) {
            //code 當前下單產品code
            //pList 當前下單產品的產品賬戶
            //type 1-切換下單產品時渲染 2-添加下單賬戶後更新賬戶
            //id productCustId type為1 編輯選中當前下單產品
            var pLen = pList.length;
            var _pLen = _productList.length;
            var str = ‘‘;
            var _name,custName,custId;
            for(var k=0;k<_pLen;++k){
                if(code == _productList[k].val){
                    _name = _productList[k].name;
                    custName =_productList[k].custName;
                    custId =_productList[k].custId;
                }
            }
            for(var i = 0;i<pLen;i++) {
                str += ‘<div class="row"><div class="col-md-3"><label class="radio-inline">‘;
                if(type === 2){
                    str += ‘<input type="radio" name="finalProduct" value="‘+pList[i].orderProductCode+‘" checked>‘+_name+‘</label>‘;
                }else if(type == 1 && id && id == pList[i].productCustId){
                    str += ‘<input type="radio" name="finalProduct" value="‘+pList[i].orderProductCode+‘" checked>‘+_name+‘</label>‘;
                }else{
                    str += ‘<input type="radio" name="finalProduct" value="‘+pList[i].orderProductCode+‘">‘+_name+‘</label>‘;
                }
                if(code == ‘1001‘ || code == ‘1002‘ || code == ‘1003‘) {
                    str += ‘</div><div class="col-md-4 pt7">‘+custName+‘<span>‘+pList[i].productCustName+‘</span>‘+
                           ‘</div><div class="col-md-5 pt7">‘+custId+‘<span>‘+pList[i].productCustId+‘</span></div></div>‘;

                }else{
                    str += ‘</div><div class="col-md-9 pt7">‘+custName+‘<span>‘+pList[i].productCustId+‘</span></div></div>‘;
                }
            }
            return str;            
        },

歷時一周,充值單創建&編輯終於做好了。撒花!

第二個部分就是充值單列表,主要功能是自定義顯示列,和上個版本的延期核銷墊款客戶標紅類似,對列表進行操作。不同的是,標紅針對某一行,而自定義顯示列的操作維度是列。第一次接觸自定義顯示,本來沒有思路,jf給我說了一下大概,我又想了一下,就是首先給表中的每一列加class,td-value,選中自定義的復選框時,保存選中的value,將列表中列的類名與選中的value的列hide,就可以了。充值單列表只用了半天。

基本所有時間都花在創建和編輯的頁面聯動上。

心累。希望充值單徹底翻篇吧,充值單一次次優化,直到此次合並,已經面目全非了QAQ

關於編輯器,我一直用的sublime text,jf用的webstorm,wd用的visio studio code,他倆都吐槽過我的編輯器Orz

現在是聯調階段,明天測試開始提測,所以這兩天邊修bug邊看一下編輯器,webstorm比較大,對比一下,vc code更易上手。

準備換vs code啦!加油!!

11.8 1.5.1開發結束