转帖:其它入库单据保存

其他入库 extjs 3
阅读(47) 评论(0) 发表时间:2008年12月08日 17:51

本文地址:http://qzone.qq.com/blog/23400601-1228729869

** *************1.变量声明******************* */
// 页面传参的值
var ishanId = (requestDecode("ishanId") == "" ? "" : requestDecode("ishanId"));
var ishanCode = (requestDecode("ishanCode") == "" ? "" : requestDecode("ishanCode"));
var storeroomCode = (requestDecode("storeroomCode") == ""
        ? ""
        : requestDecode("storeroomCode"));
var storeroomName = (requestDecode("storeroomName") == ""
        ? ""
        : requestDecode("storeroomName"));
var empCode = (requestDecode("empCode") == "" ? "" : requestDecode("empCode"));
var empName = (requestDecode("empName") == "" ? "" : requestDecode("empName"));
var inDate = (requestDecode("inDate") == ""
        ? (new Date().format('Ymd'))
        : changeDateFormate(requestDecode("inDate")));
var srCode = (requestDecode("srCode") == "" ? "LB002" : requestDecode("srCode"));
var srName = (requestDecode("srName") == "" ? "生产完工入库" : requestDecode("srName"));
var sourceBillCode = (requestDecode("sourceBillCode") == ""
        ? ""
        : requestDecode("sourceBillCode"));
var remark = (requestDecode("remark") == "" ? "" : requestDecode("remark"));
var status = (requestDecode("status") == "" ? "" : requestDecode("status"));
var createPerson = (requestDecode("createPerson") == ""
        ? ""
        : requestDecode("createPerson"));
var createDate = (requestDecode("createDate") == ""
        ? (new Date().format('Ymd'))
        : requestDecode("createDate"));
// 凭证相关的字段
var voucherId = (requestDecode("voucherId") == "" ? "" :requestDecode("voucherId"));
Ext.ns('Ufida', 'Ufida.data', 'Ufida.excel');
/** *************2.组件初始化************************* */
// 货品编码
var goodsNum = new Ext.form.ComboBox({
    store : new Ext.data.SimpleStore({
        fields : ['code', 'val'],
        data : [[1, '11111'], [2, '22222']]
    }),
    displayField : 'val',
    typeAhead : true,
    mode : 'local',
    triggerAction : 'all',
    allowBlank : false,
    selectOnFocus : true,
    readOnly : true,
    tpl : new Ext.XTemplate('<div class="add-item"><a href="javascript:addSub();" style="text-decoration:underline;">增加货品......</a></div><div class="add-item"><a href="javascript:selectSub();" style="text-decoration:underline;">选择货品......</a></div>'
            + '</tpl>'),
    anchor : '90%'
});
var hid_ishanId = new Ext.form.Hidden({
    value : ishanId,
    id : 'hid_ishanId'
});
// 凭证id
var hid_voucherId = new Ext.form.Hidden({
    id : 'hid_voucherId',
    value : voucherId
});
// 单据编号
var txt_code = new Ext.form.TextField({
    id : 'txt_code',
    fieldLabel : '单据编号',
    anchor : '85%',
    allowBlank : true,
    readOnly : true,
    value : ishanCode,
    fieldClass : 'textReadOnly'
});
// 仓库Code
var hid_storeroom = new Ext.form.Hidden({
    id : 'hid_storeroom',
    value : storeroomCode
});
// 仓库Name
var txt_storeroom = new NewAddTriggerField({
    id : 'txt_storeroom',
    anchor : '80%',
    readOnly : true,
    cls : 'MandatoryCmp',
    value : storeroomName,
    fieldLabel : '仓库<font color=red>*</font>',
    onTrigger1Click : function() {
        popAddStoreroom(hid_storeroom, txt_storeroom);
    },
    onTrigger2Click : function() {
        popSelectStoreroom([['1', 'hid_storeroom'], ['2', 'txt_storeroom']]);
    }
});
// 经手人Code
var hid_emp = new Ext.form.Hidden({
    id : 'hid_emp',
    value : empCode
})

// 经手人Name
var txt_emp = new NewAddTriggerField({
    id : 'txt_emp',
    anchor : '80%',
    readOnly : true,
    value : empName,
    fieldLabel : '经手人',
    onTrigger1Click : function() {
        popAddEmployee(hid_emp, txt_emp);
    },
    onTrigger2Click : function() {
        popSelectEmployee([['1', 'hid_emp'], ['2', 'txt_emp']]);
    }
});
// 出入库类别code
var hid_sr = new Ext.form.Hidden({
    id : 'hid_sr',
    value : srCode
});
// 出入库类别Name
var txt_sr = new NewAddTriggerField({
    id : 'txt_sr',
    anchor : '85%',
    readOnly : true,
    value : srName,
    trigger1Class : 'hideTrigger',
    fieldLabel : '出入库类别',
    onTrigger2Click : function() {
        popSelectSR([['1', 'hid_sr'], ['2', 'txt_sr']], null, null, 'R');
    }
});
// 入库日期
var dt_inDate = new Ext.form.DateField({
    id : 'dt_inDate',
    fieldLabel : '入库日期<font color=red>*</font>',
    anchor : '85%',
    cls : 'MandatoryCmp',
    format : 'Ymd',
    value : inDate
});
// 备注
var txt_remark = new Ext.form.TextArea({
    id : 'txt_remark',
    fieldLabel : '备注',
    allowBlank : true,
    height : 45,
    anchor : '98%',
    maxLength : 50,
    value : remark,
    enableKeyEvents : true,
    listeners : {
        'keypress' : function(field) {
            validate_ControlLength(field, 50)
        }
    }
});
// 制单人
var txt_createPerson = new Ext.form.TextField({
    anchor : '95%',
    id : 'txt_createPerson',
    allowBlank : true,
    value : createPerson,
    readOnly : true,
    style    : statusBarStyle,
    fieldClass : 'textReadOnly'
});
// 制单时间
var txt_createDate = new Ext.form.TextField({
    id : 'txt_createDate',
    anchor : '95%',
    allowBlank : true,
    value : createDate,
    readOnly : true,
    style    : statusBarStyle,
    fieldClass : 'textReadOnly'
});
// 数量合计
var txt_totQty = new Ext.form.TextField({
    id : 'txt_totQty',
    anchor : '95%',
    allowBlank : true,
    value : 0,
    readOnly : true,
    style : bkStyle,
    fieldClass : 'textReadOnly'
});
// 金额合计
var txt_totAmt = new Ext.form.TextField({
    id : 'txt_totAmt',
    anchor : '95%',
    allowBlank : true,
    value : 0,
    readOnly : true,
    style : bkStyle,
    fieldClass : 'textReadOnly'
});
var hid_autoVoucher = new Ext.form.Hidden({
    id : 'hid_autoVoucher'
});
// 是否生成自动凭证
var ckb_voucher = new Ext.form.Checkbox({
    id : 'ckb_voucher',
    labelSeparator : '',
    boxLabel : '生成自动凭证',
    checked : true,
    listeners : {
        'check' : function(checkbox, checked) {
            if (checked) {
                hid_autoVoucher.setValue('Y');
            } else {
                hid_autoVoucher.setValue('N');
            }
        }
    }
});

// 入库单明细模板
var Item = Ext.data.Record.create([{
    name : 'itemId'
}, {
    name : 'stockCode'
}, {
    name : 'stockName'
}, {
    name : 'spec'
}, {
    name : 'basePer'
}, {
    name : 'changePer'
}, {
    name : 'changeRate',
    type : 'float'
}, {
    name : 'qty',
    type : 'float'
}, {
    name : 'price',
    type : 'float'
}, {
    name : 'amt',
    type : 'float'
}, {
    name : 'stockMacAccId'
}]);

// 列表ds
var dsList = new Ext.data.Store({
    url : '../ishan.do?method=findItemsByIShanId',
    baseParams : {
        ishanId : hid_ishanId.getValue()
    },
    autoLoad : false,
    reader : new Ext.data.JsonReader({
        totalProperty : 'result.totalCount',
        root : 'result.result'
    }, Item),
    listeners : {
        'load' : sumFields,
        'add' : sumFields,
        'remove' : sumFields,
        'update' : sumFields
    }
});
// 列表cm
var cmList = new Ext.grid.ColumnModel([{
    header : '操作<font color=red>*</font>',
    align : 'center',
    renderer : function(value, cellmeta, record, rowIndex, columnIndex, store) {
        var id = record.id;
        return '<a href="javascript:void(0)" onClick=removeItem("' + id + '","'
                + hid_ishanId.getValue() + '")><u>删除</u></a>';
    }
}, {
    header : '货品编码<font color=red>*</font>',
    dataIndex : 'stockCode',
    align : 'left',
    width : 150,
    sortable : true,
    editor : goodsNum
}, {
    header : '货品名称<font color=red>*</font>',// + addHelpIconHtml('tip_name'),
    dataIndex : 'stockName',
    align : 'left',
    sortable : true
}, {
    header : '规格',
    dataIndex : 'spec',
    align : 'left',
    sortable : true
}, {
    header : '计量单位',
    dataIndex : 'changePer',
    align : 'left',
    sortable : true
}, {
    header : '数量<font color=red>*</font>',
    dataIndex : 'qty',
    align : 'right',
    sortable : true,
    renderer : money,
    editor : new Ext.form.NumberField({
        allowBlank : false,
        allowNegative : false,
        decimalPercision : 4,
        style : 'text-align:left'
    })
}, {
    header : '单价',
    dataIndex : 'price',
    align : 'right',
    sortable : true,
    renderer : money,
    editor : new Ext.form.NumberField({
        allowBlank : false,
        allowNegative : false,
        allowDecimals : true,
        decimalPercision : 4,
        style : 'text-align:right'
    })
}, {
    header : '金额',
    dataIndex : 'amt',
    align : 'right',
    sortable : true,
    renderer : function(value, cellmeta, record, rowIndex, columnIndex, store) {
        var price = record.get('price');
        var qty = record.get('qty');
        record.set('amt', price * qty);
        return money(record.get('amt'));
    }
}]);
// 列表Panel
var listPanel = new Ext.grid.EditorGridPanel({
    id : "destPanel",
    height : 300,
    width : 970,
    // titleCollapse : true,
    cm : cmList,
    ds : dsList,
    clicksToEdit : 1,
    stripeRows : true, // 让基数行和偶数行的颜色不一样
    // bodyStyle : 'border-bottom: 0px', // customized the grid
    // autoScroll : true,
    viewConfig : {
        forceFit : true
    },
    border : true,
    iconCls : 'icon-grid',
    tbar : new Ext.Toolbar({
        cls : 'u-toolbar-t',
        style : 'background:#E7E7E8',
        items : [{
            cls : 'u-btn',
            text : "[ <a onClick='addItem(listPanel, dsList, Item)' class='u-btn' href='javascript:void(0)'>新增行</a> ]",
            xtype : 'tbtext'
        }, ' ', {
            cls : 'u-btn',
            text : "[ <a onClick='removeAllLines()' class='u-btn' href='javascript:void(0)'>删除所有行</a> ]",
            xtype : 'tbtext'
        }, ' ', {
            cls : 'u-btn',
            text : "[ <a οnclick=batchAddNew() class='u-btn' href='javascript:void(0)'>批量新增</a> ]",
            xtype : 'tbtext'
        }]
    }),
    bbar : new Ext.Toolbar({
        cls : 'u-toolbar-b',
        style : bkStyle,
        items : ['合计:', '->', '数量:', txt_totQty, '金额:', txt_totAmt]
    })
});
/** *************3.布局定位**************************** */
// 底层panel
var newPanel = new Ext.form.FormPanel({
    border : false,
    width : 980,
    height : 420,
    labelAlign : 'right',
    labelWidth : 80,
    maskDisabled : false,
    bodyStyle : 'padding:10px',
    bbar : new Ext.Toolbar({
        style    : statusBarStyle,
        items : ['制单人:', txt_createPerson, '制单时间:', txt_createDate]
    }),
    items : [{
        width : 980,
        border : false,
        items : [{
            layout : 'column',
            border : false,
            bodyStyle : 'padding:5px 0px 10px 0px',
            items : [{
                columnWidth : .3,
                border : false,
                layout : 'form',
                items : [txt_code, txt_storeroom, txt_emp]
            }, {
                columnWidth : .3,
                border : false,
                layout : 'form',
                items : [{
                    border : false,
                    layout : 'form',
                    items : [ckb_voucher]
                }, dt_inDate, txt_sr]
            }, {
                columnWidth : .4,
                border : false,
                layout : 'form',
                items : [{
                    border : false,
                    height : 25
                }, txt_remark]
            }]
        }]
    }, listPanel]
});

var pageBarbbar = function() {
    return new Ext.Toolbar({
        style : 'background:#ffffff;padding-top:5px;',
        items : [{
            text : '保存',
            cls : 'Mod',// 编辑时可用
            pressed : true,
            handler : function() {
                saveItem(dsList);
            }
        }, {
            text : '保存并新增',
            pressed : true,
            cls : 'Mod',// 编辑时可用
            handler : function() {
                saveItem(dsList, true);
                // prepareload('scmMng/store/IShan.html');
            }
        }, {
            text : '修改',
            cls : 'Ret',// 查看时可用
            pressed : true,
            handler : function() {
                changeBtnStatus('Modify', '其他入库-编辑-C01', newPanel);
                dsList.baseParams.ishanId = hid_ishanId.getValue();
                dsList.load();
            }
        }, {
            text : '撤销',
            cls : 'Mod',
            pressed : true,
            handler : function() {
                loadBack()
            }
        }, {
            text : '删除',
            cls : 'Ret',
            pressed : true,
            handler : function() {
                removeIShan();
            }
        }, {
            text : '其他入库单列表',
            pressed : true,
            handler : function() {
                prepareload('scmMng/store/IShanList.html');
            }
        }, {
            text : '上一页',
            cls : 'pageUp',
            pressed : true,
            handler : findPrePage
        }, {
            text : '下一页',
            cls : 'pageDown',
            pressed : true,
            handler : findAftPage
        }]
    });
}
var pageBar = function() {
    return new Ext.Toolbar({
        style : 'background:#ffffff url(../../images/0602_07.gif) no-repeat left;padding-bottom:5px;',
        items : [{
            text : '保存',
            cls : 'Mod',// 编辑时可用
            pressed : true,
            handler : function() {
                saveItem(dsList);
            }
        }, {
            text : '保存并新增',
            pressed : true,
            cls : 'Mod',// 编辑时可用
            handler : function() {
                saveItem(dsList, true);
                // prepareload('scmMng/store/IShan.html');
            }
        }, {
            text : '修改',
            cls : 'Ret',// 查看时可用
            pressed : true,
            handler : function() {
                changeBtnStatus('Modify', '其他入库-编辑-C01', newPanel);
                dsList.baseParams.ishanId = hid_ishanId.getValue();
                dsList.load();
            }
        }, {
            text : '撤销',
            cls : 'Mod',
            pressed : true,
            handler : function() {
                loadBack()
            }
        }, {
            text : '删除',
            cls : 'Ret',
            pressed : true,
            handler : function() {
                removeIShan();
            }
        }, {
            text : '其他入库单列表',
            pressed : true,
            handler : function() {
                prepareload('scmMng/store/IShanList.html');
            }
        }, {
            text : '上一页',
            cls : 'pageUp',
            pressed : true,
            handler : findPrePage
        }, {
            text : '下一页',
            cls : 'pageDown',
            pressed : true,
            handler : findAftPage
        }]
    });
}


/** ***************5.主函数*********************** */
Ext.onReady(function() {
    var basePanel = new Ext.Panel({
        border : true,
        // autoWidth:true,
        // autoHeight:true,
        width : 999,
        height : 490,
        applyTo : 'div_basePanel',
        tbar : pageBar(),
        bbar : pageBarbbar(),
        items : [newPanel]
    });
    dsList.load();
    changeBtnStatus('Modify', '其他入库-编辑-C01', newPanel);

    // 判断当前用户的服务列表,是否板块账务模块
    haveFinanceService('../../', ['txt_sr', 'ckb_voucher']);
    validatePageUpDownStatus(txt_code.getValue());

    showHelpTip('1', '提示',
            '其他入库单主要用于处理采购入库以外的杂项入库业务,例如制造业的产成品入库、生产报废入库、受赠入库等等。', 69,
            'scmmngHelp/_68.htm');

});
/** *************4.函数**************************** */
var currentRecord;
var stockArray = new Array([1, "stockCode"], [2, "stockName"], [4, 'spec'], [9,
        'changePer'], [10, 'basePer'], [15, 'changeRate']);
listPanel.on('rowclick', function(listPanel, rowIndex) {
    currentRecord = dsList.getAt(rowIndex);
});

function addSub() {
    goodsNum.collapse();
    stockFormWin(CallbackFn, currentRecord);
};
function CallbackFn(ReturnedObj, currentRecord) {
    currentRecord.set('stockCode', ReturnedObj.stockCode)
    currentRecord.set('stockName', ReturnedObj.stockName)
    currentRecord.set('spec', ReturnedObj.spec)
    currentRecord.set('changePer', ReturnedObj.storePerName)
    currentRecord.set('basePer', ReturnedObj.basePerName)
    currentRecord.set('changeRate', ReturnedObj.storeChangeRate)
}
function selectSub() {
    goodsNum.collapse();
    popSelectStock('stockCode', dsList, stockArray, 800, 300);
}

// 删除列表grid中所选的明细
function removeItem(id, ishanId) {
    var record = dsList.getById(id);
    //var itemId = record.data.itemId;
    displayMessageBox('提示', '确实要删除所有记录?', Ext.MessageBox.YESNOCANCEL, function(
            btn) {
            if (btn == 'yes')
                dsList.remove(record);
    });
    /*if ('' == itemId) {
        dsList.remove(record);
        return;
    }*/
  
    /*if (Ext.MessageBox.confirm('提示', '删除本条记录,是否确认?', function(btn) {
        if (btn == 'yes') {
            msgRun('单据明细删除及相关单据自动修改中,请稍候...', '提示');
            Ext.Ajax.request({
                url : '../ishan.do?method=removeItemByIdTA',
                params : {
                    itemId : itemId,
                    ishanId : ishanId,
                    autoVoucher : hid_autoVoucher.getValue()
                },
                success : function(result, request) {
                    msgStop();
                    var jsonData = Ext.util.JSON.decode(result.responseText);
                    if (!jsonData.success) {
                        return displayMessageBox("提示", jsonData.message);
                    }
                    dsList.load();
                    messageloaded('删除成功');
                    txt_createPerson.setValue(jsonData.result.createPerson);
                    hid_voucherId.setValue(jsonData.result.voucherId);
                },
                failure : function(result, request) {
                    msgStop();
                    displayMessageBox("提示", "未知的原因造成此次删除没有成功,请重试");
                }
            });
        }
    }));*/
};
// 增加一条记录
function addItem(grid, ds, Plant) {
    var p = new Plant({
        itemId : '',
        stockCode : '',
        stockName : '',
        spec : '',
        basePer : '',
        changePer : '',
        changeRate : 1,
        qty : 0,
        price : 0,
        amt : 0,
        stockMacAccId : ''
    });
    ds.insert(ds.getCount(), p);
    grid.startEditing(ds.getCount(), 0); // 光标停留在第几行几列
};


var viewMaskBounds = [0,10,970,122];    // mask区域 [top,left,width,height]
var scrollBarBounds = [967,40,15,43] ;    // 滚动条区域 [left,top,width,height]


// 保存入库单
function saveItem(dsItems, flag) {
    if(dsItems.getCount()==0) return displayMessageBox("提示", "单据无明细记录");
    var newPageFlag = (flag == null ? false : flag);
  
    if ((validateMandatoryCmp() == false) || (validateItem(dsList) == false))
        return; // 逻辑验证,失败则终止方法
  
    var itemParams = "";// 存放明细记录的参数
    var i;
    for (i = 0; i < dsItems.getCount(); i++) {
        var record = dsItems.getAt(i);
        if (record.get('stockCode') == '' || record.get('stockCode') == null)// 空行跳过
            continue;
        /*if (i != 0)
            itemParams += '&';// 从第一个记录后为每条记录添加一条'&'
        itemParams += 'itemId=' + record.get('itemId');
        itemParams += '&stockCode=' + record.get('stockCode');
        itemParams += '&stockName=' + record.get('stockName');
        itemParams += '&spec=' + record.get('spec');
        itemParams += '&basePer=' + record.get('basePer');
        itemParams += '&changePer=' + record.get('changePer');
        itemParams += '&changeRate=' + record.get('changeRate');
        itemParams += '&qty=' + record.get('qty');
        itemParams += '&price=' + record.get('price');
        itemParams += '&amt=' + record.get('amt');
        itemParams += '&stockMacAccId=' + record.get('stockMacAccId');*/
      
        itemParams += getDataFromRecord( record );
    }
    // alert(itemParams);
    msgRun('数据保存及相关单据自动生成中,请稍候...', '提示');
    Ext.Ajax.request({
        url : '../ishan.do?method=saveTA',
        method : 'post',
        params : {
            ishanId : hid_ishanId.getValue(),
            ishanCode : txt_code.getValue(),
            storeroomCode : hid_storeroom.getValue(),
            storeroomName : Ext.get('txt_storeroom').getValue(),
            srCode : hid_sr.getValue(),
            srName : Ext.getCmp('txt_sr').getValue(),
            empCode : hid_emp.getValue(),
            empName : Ext.get('txt_emp').getValue(),
            inDate : dt_inDate.getValue().format('Ymd'),
            remark : txt_remark.getValue(),
            voucherId : hid_voucherId.getValue(),
            itemParams : itemParams,
            autoVoucher : hid_autoVoucher.getValue()
        },
        failure : function(result, request) {
            msgStop();
            displayMessageBox("提示", "保存失败");
            changeBtnStatus('Modify', '其他入库-编辑-C01', newPanel);// 保存失败页面变为编辑状态
        },
        success : function(result, request) {
            msgStop();
            var jsonData = Ext.util.JSON.decode(result.responseText);
            if (!jsonData.success) {
                return displayMessageBox('提示', jsonData.message);
            }
            messageloaded("保存成功");
            hid_ishanId.setValue(jsonData.result.ishanId);
            txt_code.setValue(jsonData.result.ishanCode);
            if (newPageFlag == true)
                return prepareload('scmMng/store/IShan.html');
            txt_createPerson.setValue(jsonData.result.createPerson);
            hid_voucherId.setValue(jsonData.result.voucherId);
            dsItems.baseParams.ishanId = hid_ishanId.getValue();
            dsItems.load();
            changeBtnStatus('Retrieve', '其他入库-查看-C01', newPanel,viewMaskBounds,scrollBarBounds,listPanel,txt_remark,txt_code);// 保存成功后页面变为查看状态

            validatePageUpDownStatus(txt_code.getValue());
        }
    });
}


// 查上页
function findPrePage(flag) {
    Ext.Ajax.request({
        url : '../ishan.do?method=findPreviousIShan',
        method : 'post',
        params : {
            curCode : txt_code.getValue()
        },
        failure : function(result, request) {
            displayMessageBox("提示", "查询失败");
        },
        success : function(result, request) {
            var jsonData = Ext.util.JSON.decode(result.responseText);
            validatePageUpDownStatus(jsonData.result.ishanCode, 'head');
            if (jsonData.result.ishanCode == '') {
                messageloaded('本页是最上页');
                if (flag != null && flag == 'del') {
                    prepareload('scmMng/store/IShan.html');
                }
                return;
            }

            hid_ishanId.setValue(jsonData.result.ishanId);
            txt_code.setValue(jsonData.result.ishanCode);
            hid_emp.setValue(jsonData.result.empCode);
            txt_emp.setValue(jsonData.result.empName);
            hid_storeroom.setValue(jsonData.result.storeroomCode);
            txt_storeroom.setValue(jsonData.result.storeroomName);
            hid_sr.setValue(jsonData.result.srCode);
            txt_sr.setValue(jsonData.result.srName);
            dt_inDate.setValue(jsonData.result.inDate);
            txt_remark.setValue(jsonData.result.remark);
            txt_createPerson.setValue(jsonData.result.createPerson);
            txt_createDate
                    .setValue(changeDateFormate2(jsonData.result.createDate));
            hid_voucherId.setValue(jsonData.result.voucherId);
            dsList.baseParams.ishanId = hid_ishanId.getValue();
            dsList.load();
            changeBtnStatus('Retrieve', '其他入库-查看-C01', newPanel,viewMaskBounds,scrollBarBounds,listPanel,txt_remark,txt_code);// 翻上页为查看状态
        }
    });
}

// 查下页
function findAftPage() {
    Ext.Ajax.request({
        url : '../ishan.do?method=findAfterIShan',
        method : 'post',
        params : {
            curCode : txt_code.getValue()
        },
        failure : function(result, request) {
            displayMessageBox("提示", "查询失败");
        },
        success : function(result, request) {
            var jsonData = Ext.util.JSON.decode(result.responseText);
            validatePageUpDownStatus(jsonData.result.ishanCode, 'foot');
            if (jsonData.result.ishanCode == '') {
                return messageloaded('本页是最下页');
            }
            hid_ishanId.setValue(jsonData.result.ishanId);
            txt_code.setValue(jsonData.result.ishanCode);
            hid_emp.setValue(jsonData.result.empCode);
            txt_emp.setValue(jsonData.result.empName);
            hid_sr.setValue(jsonData.result.srCode);
            txt_sr.setValue(jsonData.result.srName);
            hid_storeroom.setValue(jsonData.result.storeroomCode);
            txt_storeroom.setValue(jsonData.result.storeroomName);
            dt_inDate.setValue(jsonData.result.inDate);
            txt_remark.setValue(jsonData.result.remark);
            txt_createPerson.setValue(jsonData.result.createPerson);
            txt_createDate
                    .setValue(changeDateFormate2(jsonData.result.createDate));
            hid_voucherId.setValue(jsonData.result.voucherId);
            dsList.baseParams.ishanId = hid_ishanId.getValue();
            dsList.load();
            changeBtnStatus('Retrieve', '其他入库-查看-C01', newPanel,viewMaskBounds,scrollBarBounds,listPanel,txt_remark,txt_code);// 翻下页为查看状态
        }
    });
}
// 删除整个订单
function removeIShan() {
    if (Ext.MessageBox.confirm('提示', '确认删除该入库单吗?', function(btn) {
        if (btn == 'yes') {
            msgRun('单据删除及相关单据自动修改中,请稍候...', '提示');
            Ext.Ajax.defaultHeaders = {
                'Powered-By' : 'Ext'
            };
            Ext.Ajax.request({
                url : '../ishan.do?method=removeIShanByIdTA',
                params : {
                    ishanId : hid_ishanId.getValue(),
                    autoVoucher : hid_autoVoucher.getValue()
                },
                success : function(result, request) {
                    msgStop();
                    if (result.responseText != '') {
                        jsonData = Ext.util.JSON.decode(result.responseText);
                        if (!jsonData.success) {
                            return displayMessageBox("提示", jsonData.message);
                        }
                    }
                    messageloaded('删除成功');
                    findPrePage('del');
                },
                failure : function(result, request) {
                    msgStop();
                    displayMessageBox('提示', '删除失败');
                }
            });
        }
    }))
        ;
}

function selectRecords(stockPanel, listPanel) {
    // 批量新增一批货物记录
    // alert(listPanel);
    var dsList = listPanel.getStore();
    var StockRecords = stockPanel.getSelectionModel().getSelections();
    var i;
    for (i = 0; i < StockRecords.length; i++) {
        var j;
        var flag = 'N';// 这个标志标识是否货品添加重复,如果已重复则迭代下一次循环
        for (j = 0; j < dsList.getCount(); j++) {
            sourceRecord = dsList.getAt(j);
            if (StockRecords .get('stockCode') == sourceRecord
                    .get('stockCode')) {
                flag = 'Y';
                break;
            }
        }
        if ('Y' != flag)// 只有当不重复时才能执行下面代码
        {
            addItem(listPanel, dsList, Item);
            var r = dsList.getAt(dsList.getCount() - 1);
            r.set('stockCode', StockRecords.get('stockCode'));
            r.set('stockName', StockRecords.get('stockName'));
            r.set('spec', StockRecords.get('spec'));
            r.set('basePer', StockRecords.get('basePerName'));
            r.set('changePer', StockRecords.get('storePerName'));
            r.set('changeRate', StockRecords.get('storeChangeRate'));
            // alert(StockRecords.get('storeChangeRate'));
        }
    }
    //Ext.getCmp('stockWin').close();
}

// 对ds进行汇总合计
function sumFields() {
    var i;
    var totalQty = 0;
    var totalAmt = 0;
    for (i = 0; i < dsList.getCount(); i++) {
        totalQty += dsList.getAt(i).get('qty') * 10000;
        totalAmt += dsList.getAt(i).get('amt') * 10000;
    }
    txt_totQty.setValue(money(totalQty / 10000));
    txt_totAmt.setValue(money(totalAmt / 10000));
}

// 页面逻辑验证
function validateItem(dsItems) {
    /*
     * if (dsItems.getCount() == 0) { displayMessageBox('提示', '无明细记录'); return
     * false; }
     */
    if (txt_remark.getValue().length > 50) {
        displayMessageBox('提示', '备注不得超过50字');
        return false;
    }
    var i;
    for (i = 0; i < dsItems.getCount(); i++) {
        var r = dsItems.getAt(i);
        if (r.get('stockCode') == '') {
            displayMessageBox('提示', '请在第' + (i + 1) + '行输入货品编码.');
            return false;
        } else if (r.get('stockName') == '') {
            displayMessageBox('提示', '请在第' + (i + 1) + '行输入货品名称.');
            return false;
        } else if (r.get('qty') == 0) {
            displayMessageBox('提示', '请在第' + (i + 1) + '行数量不能为0');
            return false;
        }
    }
    return true;
}

function batchAddNew() {
    openStockInfoWin();
}

function removeAllLines() {
    if (dsList.getCount() == 0) {
        return messageloaded("已无记录可以删除!");;
    }
    displayMessageBox('提示', '确实要删除所有记录?', Ext.MessageBox.YESNOCANCEL, function(
            btn) {
            if (btn == 'yes')
                dsList.removeAll();
    });
    /*displayMessageBox('提示', '确实要删除所有记录?', Ext.MessageBox.YESNOCANCEL, function(
            btn) {
        if (btn == 'yes') {
            dsList.each(function(r) {
                if (r.get('itemId') == null || r.get('itemId') == '') {
                    dsList.remove(r);
                }
            });
            if(dsList.getCount()==0) return;
            var i;
            var params = '';
            for (i = 0; i < dsList.getCount(); i++) {
                var record = dsList.getAt(i);
                if (record.get('itemId') != null && record.get('itemId') != '') {
                    params += '&itemId=' + record.get('itemId');
                }
            }

            params += '&ishanId=' + hid_ishanId.getValue();
            params += '&autoVoucher=' + hid_autoVoucher.getValue();
            // alert(params);
            Ext.Ajax.request({
                url : '../ishan.do?method=removeAllItemTA',
                params : params,
                success : function(result, request) {
                    var jsonData;
                    if (result.responseText != '') {
                        jsonData = Ext.util.JSON.decode(result.responseText);
                        if (!jsonData.success) {
                            return displayMessageBox("提示", jsonData.message);
                        }
                    }
                    messageloaded('删除成功');
                    dsList.removeAll();

                },
                failure : function() {
                    return displayMessageBox('提示', '删除失败!');
                }
            });
        }
    });*/
}

// 撤销页面装载
function loadBack() {
    if (!Ext.getCmp("hid_ishanId").getValue()) {
        return prepareload('scmMng/store/IShan.html');
    }
    Ext.Ajax.request({
        url : '../ishan.do?method=findIShanByIdWithProperty',
        method : 'post',
        params : {
            id : hid_ishanId.getValue()
        },
        failure : function(result, request) {
            displayMessageBox("提示", "撤销失败");
        },
        success : function(result, request) {
            var jsonData = Ext.util.JSON.decode(result.responseText);
            hid_ishanId.setValue(jsonData.result.ishanId);
            txt_code.setValue(jsonData.result.ishanCode);
            hid_emp.setValue(jsonData.result.empCode);
            txt_emp.setValue(jsonData.result.empName);
            hid_sr.setValue(jsonData.result.srCode);
            txt_sr.setValue(jsonData.result.srName);
            hid_storeroom.setValue(jsonData.result.storeroomCode);
            txt_storeroom.setValue(jsonData.result.storeroomName);
            dt_inDate.setValue(jsonData.result.inDate);
            txt_remark.setValue(jsonData.result.remark);
            txt_createPerson.setValue(jsonData.result.createPerson);
            txt_createDate
                    .setValue(changeDateFormate2(jsonData.result.createDate));
            hid_voucherId.setValue(jsonData.result.voucherId);
            dsList.baseParams.ishanId = hid_ishanId.getValue();
            dsList.load();
        }
    });
}

 

 

 


评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值