欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

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è)字段并輸出摘要信息的方法,通過(guò)使用監(jiān)聽(tīng)器和深度監(jiān)聽(tīng),確保當(dāng)數(shù)據(jù)變化時(shí)能正確更新合計(jì)結(jié)果,具有一定的參考價(jià)值,感興趣的可以了解一下

一、背景 

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

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

二、vue代碼

   <el-table v-model="loading" :data="itemList">
          <el-table-column label="藥品名稱(chēng)" 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="批號(hào)" prop="batchNo" :show-overflow-tooltip="true"/>
          <el-table-column label="賬面數(shù)" prop="batchStockDesc" min-width="90px"/>
          <el-table-column label="盤(pán)存數(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="盤(pán)前金額" prop="totalRetail" min-width="100px" :show-overflow-tooltip="true"
                             align="right"/>
            <el-table-column label="盤(pán)后金額" 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="采購(gòu)價(jià)" prop="purchasePrice" min-width="100px" :show-overflow-tooltip="true"
                             align="right"/>
            <el-table-column label="盤(pán)前金額" prop="totalPurchase" min-width="100px" :show-overflow-tooltip="true"
                             align="right"/>
            <el-table-column label="盤(pán)后金額" 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="庫(kù)位碼" 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)聽(tīng)時(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});

其中開(kāi)啟深度監(jiān)聽(tīng)

四、效果

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

相關(guān)文章

  • Vue中Table組件行內(nèi)右鍵菜單實(shí)現(xiàn)方法(基于 vue + AntDesign)

    Vue中Table組件行內(nèi)右鍵菜單實(shí)現(xiàn)方法(基于 vue + AntDesign)

    這篇文章主要介紹了Vue中Table組件行內(nèi)右鍵菜單實(shí)現(xiàn)方法,該項(xiàng)目是基于 vue + AntDesign的,具體實(shí)例代碼給大家介紹的非常詳細(xì) ,需要的朋友可以參考下
    2019-11-11
  • axios對(duì)請(qǐng)求各種異常情況處理的封裝方法

    axios對(duì)請(qǐng)求各種異常情況處理的封裝方法

    今天小編就為大家分享一篇axios對(duì)請(qǐng)求各種異常情況處理的封裝方法,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧
    2018-09-09
  • 基于vue.js仿淘寶收貨地址并設(shè)置默認(rèn)地址的案例分析

    基于vue.js仿淘寶收貨地址并設(shè)置默認(rèn)地址的案例分析

    這篇文章主要介紹了基于vue.js仿淘寶收貨地址并設(shè)置默認(rèn)地址的案例分析,本文通過(guò)實(shí)例代碼給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2020-08-08
  • vant的Loading加載動(dòng)畫(huà)組件的使用(通過(guò)接口拿數(shù)據(jù)時(shí)顯示加載狀態(tài))

    vant的Loading加載動(dòng)畫(huà)組件的使用(通過(guò)接口拿數(shù)據(jù)時(shí)顯示加載狀態(tài))

    這篇文章主要介紹了vant的Loading加載動(dòng)畫(huà)組件的使用,通過(guò)接口拿數(shù)據(jù)時(shí)顯示加載狀態(tài),本文通過(guò)實(shí)例代碼給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友參考下吧
    2024-01-01
  • 一文教你如何優(yōu)雅的控制全局loading的顯示

    一文教你如何優(yōu)雅的控制全局loading的顯示

    在我們的平時(shí)的工作中,在前后端交互的時(shí)候,為了提高頁(yè)面的觀賞性和用戶的體驗(yàn),我們會(huì)在頁(yè)面上添加loading來(lái)阻止用戶操作來(lái)等待接口的返回,這篇文章主要給大家介紹了關(guān)于如何優(yōu)雅的控制全局loading顯示的相關(guān)資料,需要的朋友可以參考下
    2022-01-01
  • Vue中非父子組件通信的方法小結(jié)

    Vue中非父子組件通信的方法小結(jié)

    在Vue.js中,組件間的通信是構(gòu)建復(fù)雜應(yīng)用的關(guān)鍵,但當(dāng)涉及到非父子關(guān)系的組件通信時(shí),傳統(tǒng)的做法就顯得力不從心了,本文將深入探討幾種有效的非父子組件通信方法,并通過(guò)具體的代碼示例來(lái)幫助讀者理解和應(yīng)用這些技術(shù),需要的朋友可以參考下
    2024-09-09
  • vue生命周期實(shí)例小結(jié)

    vue生命周期實(shí)例小結(jié)

    這篇文章主要介紹了vue生命周期,結(jié)合實(shí)例形式分析了vue.js生命周期相關(guān)原理、步驟、函數(shù)與操作注意事項(xiàng),需要的朋友可以參考下
    2018-08-08
  • Vue使用pinia管理數(shù)據(jù)pinia持久化存儲(chǔ)問(wèn)題

    Vue使用pinia管理數(shù)據(jù)pinia持久化存儲(chǔ)問(wèn)題

    這篇文章主要介紹了Vue使用pinia管理數(shù)據(jù)pinia持久化存儲(chǔ)問(wèn)題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2023-03-03
  • Vue.js使用ref獲取DOM元素的方法示例

    Vue.js使用ref獲取DOM元素的方法示例

    在Vue.js中,ref屬性是組件的重要組成部分,它決定了組件如何獲取DOM元素,本文將探討ref屬性的使用方法和優(yōu)勢(shì),并通過(guò)有趣的示例展示其強(qiáng)大的功能,需要的朋友可以參考下
    2025-03-03
  • 淺談Vuex的this.$store.commit和在Vue項(xiàng)目中引用公共方法

    淺談Vuex的this.$store.commit和在Vue項(xiàng)目中引用公共方法

    這篇文章主要介紹了淺談Vuex的this.$store.commit和在Vue項(xiàng)目中引用公共方法,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧
    2020-07-07

最新評(píng)論