查看: 841|回复: 1

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

升级   1.41%

7

主题

5

回帖

141

积分

注册会员

Rank: 2

积分
141
发表于 2024-9-10 16:26:43 | 显示全部楼层 |阅读模式

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

[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));
        }
    },

回复

使用道具 举报

升级   100%

139

主题

1万

回帖

4万

积分

超级版主

Rank: 8Rank: 8

积分
41458
发表于 2024-9-11 11:26:25 | 显示全部楼层
是的,这个是没有考虑多人同时的情况,需要改造一下代码,您可以自己试试看,管理员这边也会把这个反馈给研发人员进行优化
回复

使用道具 举报

发表回复

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

联系客服 关注微信 下载APP 返回顶部 返回列表
viewthread