找回密码
 立即注册

QQ登录

只需一步,快速开始

陈工

初级会员

17

主题

225

帖子

456

积分

初级会员

积分
456
陈工
初级会员   /  发表于:2021-8-26 10:36  /   查看:4534  /  回复:20
5金币
首先感谢胡老大的帖子,满足了我初步的需求后又引发了我那颗小心脏的贪心不知足     https://gcdn.grapecity.com.cn/forum.php?mod=viewthread&tid=82699&fromuid=62376        
然后 就遇到新的问题了,请原谅我不懂代码,花了1添时间 貌似看懂的的样子,然后带着是懂非懂的 样子 把胡老大的代码 给改动了下,结果,结果 功能没达到预期的效果,希望哪位大佬出来帮我解决下    .





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

最佳答案

查看完整内容

你的if那里逻辑有问题,你慢慢搞清楚就好了,不难理解

20 个回复

倒序浏览
最佳答案
最佳答案
zyk.Zhou活字格认证
银牌会员   /  发表于:2021-8-26 10:36:32
来自 7#
本帖最后由 zyk.Zhou 于 2021-8-26 11:34 编辑
陈工 发表于 2021-8-26 11:06
能 讲解更详细更简单粗暴点吗,我不懂代码

你的if那里逻辑有问题,你慢慢搞清楚就好了,不难理解


本帖子中包含更多资源

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

x

评分

参与人数 1金币 +5 收起 理由
David.Zhong + 5 很给力!

查看全部评分

回复 使用道具 举报
陈工
初级会员   /  发表于:2021-8-26 10:38:55
2#
哪位大佬出来帮助一下
回复 使用道具 举报
zyk.Zhou活字格认证
银牌会员   /  发表于:2021-8-26 11:03:35
3#

这两个上面就没有

本帖子中包含更多资源

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

x
回复 使用道具 举报
陈工
初级会员   /  发表于:2021-8-26 11:06:04
4#
zyk.Zhou 发表于 2021-8-26 11:03
这两个上面就没有

能 讲解更详细更简单粗暴点吗,我不懂代码
回复 使用道具 举报
feng2575悬赏达人认证 活字格认证
金牌服务用户   /  发表于:2021-8-26 11:26:37
5#
后面再加个公式不就好了。金额的地方= 单价* 数量
回复 使用道具 举报
zyk.Zhou活字格认证
银牌会员   /  发表于:2021-8-26 11:30:06
6#
陈工 发表于 2021-8-26 11:06
能 讲解更详细更简单粗暴点吗,我不懂代码

// 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)) {
                updateunits(row);
            }
        }
        else if (col === countColIndex) {
            if (!updateunits(row)) {
                updatemultiple(row);
            }
        }
       else if (col === unitsColIndex) {
            if (updatecount(row)) {
               updateTotal(row);
            }
        }


        }

      
  });
});

评分

参与人数 1满意度 +5 收起 理由
陈工 + 5

查看全部评分

回复 使用道具 举报
陈工
初级会员   /  发表于:2021-8-26 12:08:54
8#
zyk.Zhou 发表于 2021-8-26 11:31
你的if那里逻辑有问题,你慢慢搞清楚就好了,不难理解

谢谢你的详细讲解,少少金币不成敬意,请笑纳
回复 使用道具 举报
陈工
初级会员   /  发表于:2021-8-26 13:21:30
9#
zyk.Zhou 发表于 2021-8-26 11:30
// JavaScript source code
Forguncy.Page.ready(function () {

现在还有点小问题,就是在 修改换算率的时候,金额还是不会变动,我还是没能很好理解 代码,看下 能不能再帮讲解下
回复 使用道具 举报
zyk.Zhou活字格认证
银牌会员   /  发表于:2021-8-26 13:35:44
10#
陈工 发表于 2021-8-26 13:21
现在还有点小问题,就是在 修改换算率的时候,金额还是不会变动,我还是没能很好理解 代码,看下 能不能 ...

能说一下换算率和数量、金额之间的关系吗
需要如何变动
回复 使用道具 举报
123下一页
您需要登录后才可以回帖 登录 | 立即注册
返回顶部