找回密码
 立即注册

QQ登录

只需一步,快速开始

陈工
初级会员   /  发表于:2021-8-26 13:47:04
11#
zyk.Zhou 发表于 2021-8-26 13:35
能说一下换算率和数量、金额之间的关系吗
需要如何变动

这个表中 可以理解成 两个分组的数据 ,两组的数据 又会通过数量的变动 影响到 金额,第一组 是 单位 互算   就是      包装数=数量/换算率       数量=包装数*换算率          第二组 是金额  互算    金额=单价*数量    单价=金额/数量        现在 其他的值变动都没问题了,唯有 改动换算率的时候    数量变动了,但是金额没有跟着动
回复 使用道具 举报
陈工
初级会员   /  发表于:2021-8-26 13:50:49
12#
陈工 发表于 2021-8-26 13:47
这个表中 可以理解成 两个分组的数据 ,两组的数据 又会通过数量的变动 影响到 金额,第一组 是 单位 互 ...

我现在就是 不能理解 ,怎么实现的  在 修改到 包装数的时候  数量变动后 联动影响到金额的变动,如果这个理解了 我就应该能知道 怎么实现  修改了换算率 后 数量变了 但是金额没变的原因
回复 使用道具 举报
zyk.Zhou活字格认证
银牌会员   /  发表于:2021-8-26 13:52:20
13#
陈工 发表于 2021-8-26 13:47
这个表中 可以理解成 两个分组的数据 ,两组的数据 又会通过数量的变动 影响到 金额,第一组 是 单位 互 ...

// JavaScript source code
Forguncy.Page.ready(function () {

    var priceColIndex = 7;    // 单价
    var countColIndex = 3;   // 数量
    var totalColIndex = 8;  //金额

    var unitsColIndex = 5;    // 单价   包装数
    var multipleColIndex = 6;   // 数量   换算率
   
    var isSettingValue = false;

    var listview = Forguncy.Page.getListView("table1");

    var updateCount = function (row) {
        var total = listview.getValue(row, totalColIndex);
        if (total == null) {
            return false
        }
        var price = listview.getValue(row, priceColIndex);
        if (price == null) {
            return false
        }

        var count = total / price;    //数量=金额/单价
        isSettingValue = true;
        listview.setValue(row, countColIndex, count);
        isSettingValue = false;

        return true;
    }

    var updatePrice = function (row) {
        var total = listview.getValue(row, totalColIndex);
        if (total == null) {
            return false
        }
        var count = listview.getValue(row, countColIndex);
        if (count == null) {
            return false
        }

        var price = total / count;   //单价=金额/数量
        isSettingValue = true;
        listview.setValue(row, priceColIndex, price);
        isSettingValue = false;

        return true;
    }

    var updateTotal = function (row) {
        var price = listview.getValue(row, priceColIndex);
        if (price == null) {
            return false
        }
        var count = listview.getValue(row, countColIndex);
        if (count == null) {
            return false
        }

        var total = price * count;   //金额=单价*数量
        isSettingValue = true;
        listview.setValue(row, totalColIndex, total);
        isSettingValue = false;

        return true;
    }

    listview.bind(Forguncy.ListViewEvents.ValueChanged, function (arg1, arg2) {
        if (isSettingValue) {
            return;
        }  //金额

        var updateunits = function (row) {
            var count = listview.getValue(row, countColIndex);
            if (count == null) {
                return false
            }
            var multiple = listview.getValue(row, multipleColIndex);
            if (multiple == null) {
                return false
            }
   
            var units = count / multiple;  //包装数=数量/换算率
            isSettingValue = true;
            listview.setValue(row, unitsColIndex, units);
            isSettingValue = false;
   
            return true;
        }
   
        var updatecount = function (row) {
            var units = listview.getValue(row, unitsColIndex);
            if (units == null) {
                return false
            }
            var multiple = listview.getValue(row, multipleColIndex);
            if (multiple == null) {
                return false
            }
   
            var count = units * multiple;  //数量=包装数*换算率
            isSettingValue = true;
            listview.setValue(row, countColIndex, count);
            isSettingValue = false;
   
            return true;
        }





        var row = arg2.CellRanges[0].Row;
       var col = arg2.CellRanges[0].Column;
       if (row >= 0 && col >= 0) {
           if (col === priceColIndex) {
                if (!updateTotal(row)) {
                    updateCount(row);
                }
            }
            else if (col === countColIndex) {
               if (updateTotal(row)) {
                  updateunits(row);
              }
           }
        else if (col === totalColIndex) {
               if (!updatePrice(row)) {
                   updateCount(row);
              }
          }

          else if (col === multipleColIndex) {
            if (updatecount(row)) {
                updateTotal(row);
            }
        }
        else if (col === countColIndex) {
            if (!updateunits(row)) {
                updatemultiple(row);
            }
        }
       else if (col === unitsColIndex) {
            if (updatecount(row)) {
               updateTotal(row);
            }
        }


        }

      
  });
});
回复 使用道具 举报
zyk.Zhou活字格认证
银牌会员   /  发表于:2021-8-26 13:53:45
14#
zyk.Zhou 发表于 2021-8-26 13:52
// JavaScript source code
Forguncy.Page.ready(function () {


本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
回复 使用道具 举报
zyk.Zhou活字格认证
银牌会员   /  发表于:2021-8-26 14:00:43
15#

这样也可以else if (col === multipleColIndex) {
                updatecount(row);
                updateTotal(row);

        }


-------------
解释
updateTotal(row);//就是函数名称调用,你想要变动那个就调用那个函数。
比如改变换算率时,数量和金额需要改变,就调用  updatecount(row);//数量 updateTotal(row);//金额这两个
回复 使用道具 举报
David.Zhong讲师达人认证 悬赏达人认证 活字格认证
论坛元老   /  发表于:2021-8-26 14:05:03
16#
感谢各位大佬的支持!!!
为了方便大佬的使用,我们在7.1新版本中有更简单的处理方式了~
大佬们可以先看看7.1新功能解密~
活字格7.0 update1新功能解密:十八,命令提升-条件命令中可以判断值变更的原因 - 活字格专区 - 专题教程 - 葡萄城产品技术社区 (grapecity.com.cn)
回复 使用道具 举报
陈工
初级会员   /  发表于:2021-8-26 14:10:07
17#
zyk.Zhou 发表于 2021-8-26 14:00
这样也可以else if (col === multipleColIndex) {
                updatecount(row);
                ...

看来我理解的思路应该是对上了,刚才我也是这么去尝试着弄的,但最终好像并没有 达到预期的结果,还是没反应
回复 使用道具 举报
陈工
初级会员   /  发表于:2021-8-26 14:13:17
19#
David.Zhong 发表于 2021-8-26 14:05
感谢各位大佬的支持!!!
为了方便大佬的使用,我们在7.1新版本中有更简单的处理方式了~
大佬们 ...

老大,这个功能现在能用了吗
回复 使用道具 举报
David.Zhong讲师达人认证 悬赏达人认证 活字格认证
论坛元老   /  发表于:2021-8-26 16:18:16
20#
陈工 发表于 2021-8-26 14:13
老大,这个功能现在能用了吗

麻烦大佬耐心等待新版本的发布哟~
8月底可能会在活字格官方交流群中分享预览版,大佬可以持续关注一下~
回复 使用道具 举报
夏雪冬阳
银牌会员   /  发表于:2022-2-2 17:33:49
21#
if判断值变动原因的demo可能上传一份学习下
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 立即注册
返回顶部