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

VUE3中Element table表頭動(dòng)態(tài)展示合計(jì)信息

 更新時(shí)間:2024年11月12日 09:05:23   作者:十方天士  
本文主要介紹了在Vue中實(shí)現(xiàn)動(dòng)態(tài)合計(jì)兩個(gè)字段并輸出摘要信息的方法,通過使用監(jiān)聽器和深度監(jiān)聽,確保當(dāng)數(shù)據(jù)變化時(shí)能正確更新合計(jì)結(jié)果,具有一定的參考價(jià)值,感興趣的可以了解一下

一、背景 

原型上需要對兩個(gè)字段動(dòng)態(tài)合計(jì),輸出摘要信息

原先想到是的Element的 :summary-method,發(fā)現(xiàn)不是動(dòng)態(tài),所以換監(jiān)聽來實(shí)現(xiàn)

二、vue代碼

   <el-table v-model="loading" :data="itemList">
          <el-table-column label="藥品名稱" prop="drugName" fixed min-width="100px" :show-overflow-tooltip="true"/>
          <el-table-column label="規(guī)格" prop="drugSpec" :show-overflow-tooltip="true"/>
          <el-table-column label="批號" prop="batchNo" :show-overflow-tooltip="true"/>
          <el-table-column label="賬面數(shù)" prop="batchStockDesc" min-width="90px"/>
          <el-table-column label="盤存數(shù)" align="center">
            <el-table-column prop="stocktakeQty" min-width="150px">
              <template v-slot="scope">
                <el-input-number :disabled="!canEdit"
                                 v-model="scope.row.stocktakeQty"
                                 :min="0"
                                 controls-position="right"
                                 size="small"/>
              </template>
            </el-table-column>
            <el-table-column label="單位" prop="unit" min-width="90px">
              <template #default="scope">
                <dict-tag :options="bd_plat_drug_unit" :value="scope.row.unit" :showValue="false"/>
              </template>
            </el-table-column>
            <el-table-column prop="stocktakeTinyqty" min-width="150px">
              <template v-slot="scope">
                <el-input-number :disabled="!canEdit"
                                 v-model="scope.row.stocktakeTinyqty"
                                 :min="0"
                                 controls-position="right"
                                 size="small"/>
              </template>
            </el-table-column>
            <el-table-column label="小單位" prop="tinyUnit" min-width="90px">
              <template #default="scope">
                <dict-tag :options="bd_plat_drug_unit" :value="scope.row.tinyUnit" :showValue="false"/>
              </template>
            </el-table-column>
          </el-table-column>
          <el-table-column label="零售" align="center">
            <el-table-column label="零售價(jià)" prop="retailPrice" min-width="100px" :show-overflow-tooltip="true"
                             align="right"/>
            <el-table-column label="盤前金額" prop="totalRetail" min-width="100px" :show-overflow-tooltip="true"
                             align="right"/>
            <el-table-column label="盤后金額" prop="afterTotalRetail" min-width="100px" :show-overflow-tooltip="true"
                             align="right">
              <template v-slot="scope">
                {{
                  scope.row.afterTotalRetail = computeTotalMoney(scope.row.stocktakeQty, scope.row.stocktakeTinyqty, scope.row.packageQty, scope.row.retailPrice)
                }}
              </template>
            </el-table-column>
            <el-table-column label="成本損溢金額" prop="totalLossoverRetail" min-width="120px" align="right">
              <template v-slot="scope">
                {{
                  scope.row.totalLossoverRetail = computeDifferenceMoney(scope.row.stocktakeQty, scope.row.stocktakeTinyqty, scope.row.packageQty, scope.row.retailPrice, scope.row.totalRetail)
                }}
              </template>
            </el-table-column>
          </el-table-column>
          <el-table-column label="成本" align="center">
            <el-table-column label="采購價(jià)" prop="purchasePrice" min-width="100px" :show-overflow-tooltip="true"
                             align="right"/>
            <el-table-column label="盤前金額" prop="totalPurchase" min-width="100px" :show-overflow-tooltip="true"
                             align="right"/>
            <el-table-column label="盤后金額" prop="afterTotalPurchase" min-width="100px" :show-overflow-tooltip="true"
                             align="right">
              <template v-slot="scope">
                {{
                  scope.row.afterTotalPurchase = computeTotalMoney(scope.row.stocktakeQty, scope.row.stocktakeTinyqty, scope.row.packageQty, scope.row.purchasePrice)
                }}
              </template>
            </el-table-column>
            <el-table-column label="成本損溢金額" prop="totalLossoverPurchase" min-width="120px"
                             :show-overflow-tooltip="true" align="right">
              <template v-slot="scope">
                {{
                  scope.row.totalLossoverPurchase = computeDifferenceMoney(scope.row.stocktakeQty, scope.row.stocktakeTinyqty, scope.row.packageQty, scope.row.purchasePrice, scope.row.totalPurchase)
                }}
              </template>
            </el-table-column>
          </el-table-column>
          <el-table-column label="生產(chǎn)企業(yè)" prop="firmName" min-width="80px" :show-overflow-tooltip="true"/>
          <el-table-column label="產(chǎn)地" prop="producerName" min-width="80px" :show-overflow-tooltip="true"/>
          <el-table-column label="庫位碼" prop="locationCode" min-width="100px" :show-overflow-tooltip="true"/>
          <el-table-column label="操作" fixed="right" min-width="60px" align="center" v-if="canEdit"
                           class-name="small-padding fixed-width">
            <template #default="scope">
              <el-button link type="primary" icon="Delete" title="刪除" @click="handleDelete(scope.row)"/>
            </template>
          </el-table-column>
        </el-table>

  其中代碼,賦值給totalLossoverRetail 才能保證,后期監(jiān)聽時(shí)數(shù)據(jù)有發(fā)生變化

                {{
                  scope.row.totalLossoverRetail = computeDifferenceMoney(scope.row.stocktakeQty, scope.row.stocktakeTinyqty, scope.row.packageQty, scope.row.retailPrice, scope.row.totalRetail)
                }}

三、方法代碼

watch(itemList, () => {
  console.log(itemList.value, 'itemList')
  let totalLossoverRetail = 0
  let totalLossoverPurchase = 0
  itemList.value.forEach(item => {
    totalLossoverRetail = Number(totalLossoverRetail) + Number(item.totalLossoverRetail);
    totalLossoverPurchase = Number(totalLossoverPurchase) + Number(item.totalLossoverPurchase);
  })
  sumDescription.value = '成本損溢金額 ' + totalLossoverPurchase + ' 零售損溢金額  ' + totalLossoverRetail
}, {deep: true});

其中開啟深度監(jiān)聽

四、效果

到此這篇關(guān)于VUE3中Element table表頭動(dòng)態(tài)展示合計(jì)信息的文章就介紹到這了,更多相關(guān)VUE3 Element table動(dòng)態(tài)表頭內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

  • VUE中的filters過濾器使用方法

    VUE中的filters過濾器使用方法

    這篇文章主要介紹了VUE中的filters過濾器使用方法,文章主要通過描述全局過濾器、全局過濾器之單一掛載、全局過濾器之批量掛載?、組件過濾器展開內(nèi)容,具有一定的參考價(jià)值組要的小伙伴可以參考一下
    2022-03-03
  • vue綁定數(shù)字類型 value為數(shù)字的實(shí)例

    vue綁定數(shù)字類型 value為數(shù)字的實(shí)例

    這篇文章主要介紹了vue綁定數(shù)字類型 value為數(shù)字的實(shí)例,具有很好的參考價(jià)值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2020-08-08
  • Vue3引入SVG圖標(biāo)的流程步驟

    Vue3引入SVG圖標(biāo)的流程步驟

    我們在開發(fā) Vue 項(xiàng)目的時(shí)候會使用一些前端組件庫,例如 Element、Ant Design 等,這些組件庫雖然方便,但是也有一些缺點(diǎn),比如內(nèi)置的圖標(biāo)太少,例如我們開發(fā)醫(yī)療、財(cái)務(wù)、工程等一些前端項(xiàng)目,內(nèi)置的圖標(biāo)不能滿足我們的需求,所以我們常常在Vue項(xiàng)目中引入SVG圖標(biāo)
    2024-09-09
  • vue-router嵌套路由方式(頁面路徑跳轉(zhuǎn)但頁面顯示空白)

    vue-router嵌套路由方式(頁面路徑跳轉(zhuǎn)但頁面顯示空白)

    這篇文章主要介紹了vue-router嵌套路由方式(頁面路徑跳轉(zhuǎn)但頁面顯示空白),具有很好的參考價(jià)值,希望對大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2022-04-04
  • Vscode關(guān)閉Eslint語法檢查的多種方式(保證有效)

    Vscode關(guān)閉Eslint語法檢查的多種方式(保證有效)

    eslint是一個(gè)JavaScript的校驗(yàn)插件,通常用來校驗(yàn)語法或代碼的書寫風(fēng)格,下面這篇文章主要給大家介紹了關(guān)于Vscode關(guān)閉Eslint語法檢查的多種方式,文章通過圖文介紹的非常詳細(xì),需要的朋友可以參考下
    2022-07-07
  • Vue組件通信的幾種實(shí)現(xiàn)方法

    Vue組件通信的幾種實(shí)現(xiàn)方法

    這篇文章主要介紹了Vue組件通信的幾種實(shí)現(xiàn)方法,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2019-04-04
  • 手寫實(shí)現(xiàn)Vue計(jì)算屬性

    手寫實(shí)現(xiàn)Vue計(jì)算屬性

    這篇文章主要介紹了手寫實(shí)現(xiàn)Vue計(jì)算屬性,本文從一個(gè)簡單的計(jì)算屬性例子開始,一步步實(shí)現(xiàn)了計(jì)算屬性。并且針對這個(gè)例子,詳細(xì)分析了頁面渲染時(shí)的整個(gè)代碼執(zhí)行邏輯,需要的小伙伴可以參考一下
    2022-08-08
  • Vue-cli創(chuàng)建項(xiàng)目從單頁面到多頁面的方法

    Vue-cli創(chuàng)建項(xiàng)目從單頁面到多頁面的方法

    本篇文章主要介紹了Vue-cli創(chuàng)建項(xiàng)目從單頁面到多頁面的方法,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧
    2017-09-09
  • 帶你熟練掌握Vue3之Pinia狀態(tài)管理

    帶你熟練掌握Vue3之Pinia狀態(tài)管理

    pinia是vue3官方的狀態(tài)管理工具,當(dāng)然vue2也可以用,vue2中的狀態(tài)管理工具是vuex,vue3中不再使用vuex,推薦使用的是pinia,和vuex差不多,但比vuex更方便、更強(qiáng)、更好,下面這篇文章主要給大家介紹了關(guān)于Vue3之Pinia狀態(tài)管理的相關(guān)資料,需要的朋友可以參考下
    2022-11-11
  • vue3.0+ts引入詳細(xì)步驟以及語法校驗(yàn)報(bào)錯(cuò)問題解決辦法

    vue3.0+ts引入詳細(xì)步驟以及語法校驗(yàn)報(bào)錯(cuò)問題解決辦法

    Vue?3.0是一個(gè)非常流行的JavaScript框架,不僅易于學(xué)習(xí)和使用,而且可以與許多UI框架集成,下面這篇文章主要給大家介紹了關(guān)于vue3.0+ts引入詳細(xì)步驟以及語法校驗(yàn)報(bào)錯(cuò)問題的解決辦法,需要的朋友可以參考下
    2024-01-01

最新評論

都江堰市| 襄垣县| 榕江县| 镇江市| 大连市| 察哈| 保山市| 隆林| 凭祥市| 定西市| 赣榆县| 台安县| 子洲县| 闸北区| 玉龙| 遂平县| 栾城县| 遂川县| 加查县| 宁国市| 温宿县| 建阳市| 青神县| 阳原县| 北碚区| 长治市| 蒙城县| 承德县| 霍林郭勒市| 青海省| 沂水县| 明光市| 当雄县| 门头沟区| 嘉鱼县| 鹰潭市| 井冈山市| 益阳市| 高阳县| 霸州市| 娄烦县|