苍穹KDE遍历分录原创
1人赞赏了该文章
1,015次浏览
编辑于2022年02月11日 09:19:39
常用写法:
this.getView().getModel().getEntryRowCount('taxentry') //获取分录taxentry行数
var o = this.getView().getModel().getValue('taxentry_content', i) //获取分录
var q = new QFilter("billno", "=", c); //数据库获取分录数据 var filters = [q]; var dynamicObject = BusinessDataServiceHelper.load("recon_chgcfmbill", "deducentry_amount", filters); for (var i = 0; i < dynamicObject.length; i++) { var tripentry = dynamicObject[i].getDynamicObjectCollection("chgcfmdeductionentry") for (var j = 0; j < tripentry.size(); j++) { var t = tripentry.get(j) result += t.get('deducentry_amount') } }
整体代码:
afterAddRow: function(e) { var b = this.getView().getModel().getEntryRowCount('taxentry') //获取分录taxentry行数 var result = 0; for (var i = 0; i < b; i++) { //循环遍历 var o = this.getView().getModel().getValue('taxentry_content', i) if (toString(o).indexOf('变更结算') != -1) { var a = toString(o).indexOf('变更结算') + 5 var b = o.length var c = toString(o).substring(a, b) var q = new QFilter("billno", "=", c); var filters = [q]; var dynamicObject = BusinessDataServiceHelper.load("recon_chgcfmbill", "deducentry_amount", filters); for (var i = 0; i < dynamicObject.length; i++) { var tripentry = dynamicObject[i].getDynamicObjectCollection("chgcfmdeductionentry") for (var j = 0; j < tripentry.size(); j++) { var t = tripentry.get(j) result += t.get('deducentry_amount') } } } //this.getView().showMessage(result) this.getModel().setValue('nzsw_liabilitydeduction',result,i) } this.camount() },
推荐阅读