zoukankan      html  css  js  c++  java
  • 【QuotationTool】Model的实现(三),导航页

    本篇主要介绍Summary页如何得到

    下图为Summary页的样子
    image.png

    主要有三个功能要实现:

    • 链接到明细清单页

    • 与明细清单页进行价格联动

    • 占比

    代码位于summaryModelClass.py

    总体思想

    其实Summary页就是对价格清单页的一个精简而已,只是把site行的数据保留下来。

    所以总体思想是将价格清单页的list传递进来,然后进行再处理。

    把list传递进来

    所以可以先使用assign把价格明细清单传递进来,依旧是与Excel的列标组成dict

    def assign(self,lists,fields,outputKeys,sheetName):
        self.lists = lists;
        self.fields = fields;
        self.sheetName = sheetName;
        self.outputKeys = outputKeys;
        colOrdinal = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',
                      'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'];
        # 先组合成为dict
        self.dCol = dict(zip(self.outputKeys, colOrdinal));    
        self.getSubtotalIndex();
    
    

    然后获得site、小计、总计的索引

    
    def getSubtotalIndex (self):
        self.aSite = [];
        self.aSubtotal = [];
        self.aTotal = 0;
        for i , arr in enumerate (self.lists):
            if arr['colorTag'] == 'site':
                self.aSite.append(i);
            elif arr['colorTag'] == 'subtotal':
    
                self.aSubtotal.append(i);
            elif arr['colorTag'] == 'total':
                self.aTotal = i;
            else:
                continue;
    
        self.aHeader = 0;
    

    添加跳转URL

    要实现一个链接,我们需要两个东西

    • 要跳转的位置

    • 显示的文字

    要跳转的位置可以使用
    image.png
    这样的链接地址得到。

    而显示的文本则等于明细清单页的site的discription

    map = {};
    map['url'] = 'internal:' + self.sheetName + "!" + self.dCol['description'] + str(s + 1 + 1);
    diff = [i for i in ['BOM','typeID'] if i in self.outputKeys];
    tag = diff[0];            
    map['description'] = self.lists[s][tag];
    
    

    添加公式

    总数量、目录价等单元格只需要从相应的位置取即可。

    # quantity
    if 'quantity' in self.outputKeys:
        map['quantity'] = '=' + self.sheetName + "!" + self.dCol['quantity'] + str(s + 1);
    elif 'totalQuantity' in self.outputKeys:
        map['quantity'] = '=' + self.sheetName + "!" + self.dCol['totalQuantity'] + str(s + 1 + 1);
    else:
        map['quantity'] = 0;
    # unitsNetListPrice
    map["unitsNetPrice"] = '=F' + str (i+2) + '/D' + str(i + 2);
    # totalPrice
    map['totalPrice'] = '=' + self.sheetName + '!' + self.dCol['totalPrice'] + str(self.aSubtotal[i] + 1);
    map['ID'] = i + 1;
    

    调用

    获得SummaryList

    iSummaryModel = M('summary');
    
    summaryFields =  getattr(inputvar,"summaryFields");
    iSummaryModel.assign(lists,summaryFields,list(outputParam.keys()),sheetName);
    summaryList = iSummaryModel.getSummaryLists();    
    

    image.png

  • 相关阅读:
    C++中的回调函数(callback)
    C++ Primer5 练习5.12:编程统计含有两个连续字符(ff、fl、fi)的字符序列的数量
    范围for循环过程中用&修改元素
    C++资料整理(持续更新)
    问题解决:VS报错:The build tools for v140 (Platform Toolset = 'v140') cannot be found
    上传新文件至个人hexo博客的步骤
    【Ubuntu】同时安装了python2和python3,使用pip安装软件时注意
    python解析xml文件 修改xml指定标签中的内容
    实操:main(int argc,char ** argv) 输出main函数的参数
    Saga-Python笔记
  • 原文地址:https://www.cnblogs.com/dy2903/p/8466967.html
Copyright © 2011-2022 走看看