最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

詳解Python odoo中嵌入html簡(jiǎn)單的分頁功能

 更新時(shí)間:2019年05月29日 10:30:09   作者:上帝的中腿  
在odoo中,通過iframe嵌入 html,頁面數(shù)據(jù)則通過controllers獲取,使用jinja2模板傳值渲染。這篇文章主要介紹了Python odoo中嵌入html簡(jiǎn)單的分頁功能 ,需要的朋友可以參考下

在odoo中,通過iframe嵌入 html,頁面數(shù)據(jù)則通過controllers獲取,使用jinja2模板傳值渲染

html頁面分頁內(nèi)容,這里寫了判斷邏輯

<!-- 分頁 -->
<ul id="ty_paging">
  <li class="home" id="home"><a href="/car/budget/report/1" rel="external nofollow" ></a>首頁</li>
  {% if current_page == 1 %}
  <li class="prev" id="prev"><</li>
  {% else %}
  <li class="prev" id="prev"><a href="/car/budget/report/{{current_page - 1}}" rel="external nofollow" ><</a></li>
  {% endif %}
  {% if current_page == total_page %}
  <li class="next" id="next">></li>
  {% else %}
  <li class="next" id="next"><a href="/car/budget/report/{{current_page + 1}}" rel="external nofollow" >></a></li>
  {% endif %}
  <li class="max">共{{total_page}}頁</li>
  <li class="max">第{{current_page}}頁</li>
  <input type="number" min="1" value="1" class="inputPage" id="inputPage"/>
  <li class="jump" id="jump"><a id="add" href="javascript:void(0)" rel="external nofollow" onclick="subNmbr()">跳轉(zhuǎn)</a></li>

</ul>

在,odoo的controllers中的邏輯

class CarBudgetReport(http.Controller):
  @http.route('/car/budget/report/<int:page>', auth='public')
  def index(self, page=1, **kw):
    data1 = request.env['lims.car.scheme'].get_first_budget()
    total_page = int(len(data1) / 10) + 1
    if page > total_page:
      data = []
    else:
      data = data1[(page - 1) * 10: page * 10]
    return env.get_template(HTML_FIEL_NAME).render({'data': data, 'current_page': page, 'total_page': total_page})

 CSS文件:

/* 分頁功能的通用樣式 */
#ty_paging {
 overflow: hidden;
 display: block;
 width: 100%;
 margin-top: 20px;
 text-align: center;
 user-select: none;
 -webkit-user-select: none;
 -moz-user-select: none;
 -ms-user-select: none;
 font-size: 14px;
 color: #000000;
 background-color: #FFFFFF;
}
#ty_paging li {
 display: inline-block;
 height: 32px;
 width: 32px;
 line-height: 32px;
 margin: 0px 5px;
 padding: 0px;
 border: 1px solid #ddd;
 border-radius: 2px;
 cursor: pointer;
 vertical-align: top;
 text-align: center;
}
#ty_paging .home,#ty_paging .jump {
 width: 56px;
 height: 32px;
}
#ty_paging .max {
 width: 60px;
 border: none;
}
#ty_paging .inputPage {
 height: 32px;
 width: 56px;
 border: 1px solid #ddd;
 border-radius: 2px;
 text-align: center;
 color: #000000;
}

 在后臺(tái)xml中需要將路由設(shè)置默認(rèn)為1

<?xml version="1.0" encoding="UTF-8"?>
<templates id="template" xml:space="preserve">
    <t t-name="BudgettIframe">
      <iframe src="car/budget/report/1" marginheight="0" marginwidth="0" width="100%" height="100%" />
    </t>
</templates>

html 分頁js代碼

<script>
  // 懸浮樣式
  $('#home, #jump').mouseover(function () {
    // if ($(this).val() == ty_currentPage) return;
    $(this).css({
      'border-color': '#2db71a',
      'color': '#000000',
      // 'background-color': '#337ab7',
    });
  });
  $('#home, #prev, #next, #jump').mouseout(function () {
    // if ($(this).val() == ty_currentPage) return;
    $(this).css({
      'border-color': "#ddd",
      'color': '#666',
      // 'background-color': '#ffffff',
    });
  });
  $('#up, #down').mouseover(function () {
    // if ($(this).val() == ty_currentPage) return;
    $(this).css({
      'border-color': '#337ab7',
      'color': '#ffffff',
      'background-color': '#2db71a',
    });
  });
  $('#up, #down').mouseout(function () {
    // if ($(this).val() == ty_currentPage) return;
    $(this).css({
      'border-color': "#000000",
      'color': '#000000',
      'background-color': '#ffffff',
    });
  });
  // 點(diǎn)擊跳轉(zhuǎn)頁面需要用到方法
  function subNmbr() {
    // 先獲取到頁面上input輸入框中的值
    var subNmbr = document.getElementById('inputPage').value;
    // console.log(subNmbr);
    // 在獲取li的id,在點(diǎn)擊時(shí)做一個(gè)動(dòng)作
    document.getElementById("jump").onclick = function () {
      //根據(jù)a標(biāo)簽的id獲取鏈接,設(shè)置href屬性
      var aObj = document.getElementById("add");
      // 把要跳轉(zhuǎn)的頁面連接傳入href
      aObj.href = "/car/budget/report/" + subNmbr;
      //根據(jù)id獲取超鏈接,設(shè)置文字內(nèi)容
      aObj.innerText = "跳轉(zhuǎn)";
    };
  }
</script>

之后便可以進(jìn)行數(shù)據(jù)的簡(jiǎn)單分頁

總結(jié)

以上所述是小編給大家介紹的Python odoo中嵌入html簡(jiǎn)單的分頁功能,希望對(duì)大家有所幫助,如果大家有任何疑問請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)腳本之家網(wǎng)站的支持!
如果你覺得本文對(duì)你有幫助,歡迎轉(zhuǎn)載,煩請(qǐng)注明出處,謝謝!

相關(guān)文章

  • Python基于Serializer實(shí)現(xiàn)字段驗(yàn)證及序列化

    Python基于Serializer實(shí)現(xiàn)字段驗(yàn)證及序列化

    這篇文章主要介紹了Python基于Serializer實(shí)現(xiàn)字段驗(yàn)證及序列化,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下
    2020-11-11
  • PyInstaller打包selenium-wire過程中常見問題和解決指南

    PyInstaller打包selenium-wire過程中常見問題和解決指南

    常用的打包工具 PyInstaller 能將 Python 項(xiàng)目打包成單個(gè)可執(zhí)行文件,但也會(huì)因?yàn)榧嫒菪詥栴}和路徑管理而出現(xiàn)各種運(yùn)行錯(cuò)誤,本指南總結(jié)了打包過程中常見問題和解決方案,大家可以根據(jù)需要進(jìn)行選擇
    2025-04-04
  • Python?shapely庫的具體使用

    Python?shapely庫的具體使用

    本文主要介紹了Python?shapely庫的具體使用,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2023-06-06
  • python字符串與url編碼的轉(zhuǎn)換實(shí)例

    python字符串與url編碼的轉(zhuǎn)換實(shí)例

    今天小編就為大家分享一篇python字符串與url編碼的轉(zhuǎn)換實(shí)例,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧
    2018-05-05
  • python join方法使用詳解

    python join方法使用詳解

    這篇文章主要介紹了python join方法使用詳解,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下
    2019-07-07
  • 使用python寫的opencv實(shí)時(shí)監(jiān)測(cè)和解析二維碼和條形碼

    使用python寫的opencv實(shí)時(shí)監(jiān)測(cè)和解析二維碼和條形碼

    這篇文章主要介紹了使用python寫的opencv實(shí)時(shí)監(jiān)測(cè)和解析二維碼和條形碼,本文給大家介紹的非常詳細(xì),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2019-08-08
  • OpenCV霍夫圓變換cv2.HoughCircles()

    OpenCV霍夫圓變換cv2.HoughCircles()

    這篇博客將學(xué)習(xí)如何使用霍夫圓變換在圖像中找到圓圈,OpenCV使用cv2.HoughCircles()實(shí)現(xiàn)霍夫圓變換,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2021-07-07
  • Pytorch使用visdom可視化問題

    Pytorch使用visdom可視化問題

    這篇文章主要介紹了Pytorch使用visdom可視化問題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2024-06-06
  • Python selenium抓取虎牙短視頻代碼實(shí)例

    Python selenium抓取虎牙短視頻代碼實(shí)例

    這篇文章主要介紹了Python selenium抓取虎牙短視頻代碼實(shí)例,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下
    2020-03-03
  • 使用python查找windows系統(tǒng)中所有程序的安裝信息

    使用python查找windows系統(tǒng)中所有程序的安裝信息

    這篇文章主要為大家介紹了使用python查找windows系統(tǒng)中所有程序的安裝信息示例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2023-07-07

最新評(píng)論

玉溪市| 双流县| 大宁县| 恭城| 灵川县| 三原县| 江陵县| 九江市| 衡山县| 商都县| 赫章县| 阿拉善右旗| 隆德县| 安义县| 石狮市| 南通市| 宕昌县| 兴文县| 米脂县| 新津县| 新乐市| 长乐市| 陵川县| 玉山县| 小金县| 江孜县| 石柱| 镇雄县| 绿春县| 安国市| 东乡族自治县| 永昌县| 金塔县| 伊吾县| 黔江区| 扎赉特旗| 河南省| 镇赉县| 广平县| 察隅县| 长治县|