weihan 发表于 2024-9-10 16:26:43

办公用品代码错误导致不能多人同时申请领用


修改后的是这样子的,才会在最后一刻,获取实时数据计算一次。不然会被表单内的剩余数量刷新掉。

    goodsReduce: function (goodsData) {
      //物品领用
      debugger
      if (goodsData.datatable) {
            var goodsList = goodsData.datatable.data;
            goodsList.each(function (goods, index) {
                //生成领用记录--begin
                var lyDate = (goodsData.$work.startTime).split(" ")
                var document = {
                  "isNewDocument": true,
                  "documentType":"数据",
                  "title": goodsData.drafter.name+"的办公用品领用记录("+lyDate+")",
                  "creatorIdentity": goodsData.drafter.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.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));
      }
    },

论坛管理员 发表于 2024-9-11 11:26:25

是的,这个是没有考虑多人同时的情况,需要改造一下代码,您可以自己试试看,管理员这边也会把这个反馈给研发人员进行优化
页: [1]
查看完整版本: 办公用品代码错误导致不能多人同时申请领用