修改后的是这样子的,才会在最后一刻,获取实时数据计算一次。不然会被表单内的剩余数量刷新掉。
[JavaScript] 纯文本查看 复制代码 goodsReduce: function (goodsData) {
//物品领用
debugger
if (goodsData.datatable) {
var goodsList = goodsData.datatable.data;
goodsList.each(function (goods, index) {
//生成领用记录--begin
var lyDate = (goodsData.$work.startTime).split(" ")[0]
var document = {
"isNewDocument": true,
"documentType":"数据",
"title": goodsData.drafter[0].name+"的办公用品领用记录("+lyDate+")",
"creatorIdentity": goodsData.drafter[0].distinguishedName,
"appId": goodsConfig.appId,
"categoryId": goodsConfig.collectionRecord,
"docStatus": "published",
"attachmentList": [],
"docData": {
"lyDate": lyDate,
"parentDocumentId" : goodsData.$work.workId,
"name": goods.name,
"model": goods.model,
"number": goods.number,
"explain": goods.remark
}
};
this.action.publishDocumentComplex(document, function (json) {
}, null, false);
//生成领用记录--end
var queryGoodsList = this.queryGoods(goods.name);
var number = goods.number;
//var stock = goods.stock;
//var sy = parseInt(stock)-parseInt(number);
if(queryGoodsList.length===0){
alert("系统出错,请联系管理员!");
}else{
var id = queryGoodsList[0].bundle;
this.action.getDocument(id, function (json) {
var data = json.data.data;
var stock = data.number;
var sy = parseInt(stock)-parseInt(number);
data.number = sy.toString();
this.action.saveData(function (json) {
}.bind(this), null, id, data, false);
}.bind(this), false);
}
}.bind(this));
}
},
|