<template>
<div class="bbb">
<el-checkbox :indeterminate="isIndeterminate" v-model="checkAll" @change="handleAllChange">全选</el-checkbox>
<div style="margin: 15px 0;"></div>
<el-checkbox-group v-model="checkedGoods" @change="handleOneChange" class="aaa">
<el-checkbox v-for="good in goods" :label="good.name" :key="good.id">
<span style="width:150px;display:inline-block">商品名称: {{good.name}}</span>
<span style="width:150px;display:inline-block;margin-left:100px;margin-right:100px">商品价格: {{good.price}} 元</span>
<span> 商品数量:<el-input-number v-model="good.num" @change="handleChangeNum(good.id)" label="描述文字" size="small"></el-input-number></span>
<span style="width:150px;display:inline-block;margin-left:100px;margin-right:100px">小计: {{good.OnePrice}}元</span>
</el-checkbox>
</el-checkbox-group>
<div style="margin-top:40px;margin-left:450px;text-align:left">
<span style="margin-right:20px;display:inline-block">总价:{{allPrice}}元</span>
<el-button type="primary" size="small" @click="submitBtn">去结算<i class="el-icon-upload el-icon--right"></i></el-button>
</div> </div>
</template>
<script>
const goodOptions = ["哇哈哈", "辣条", "矿泉水", "西瓜", "苹果"];
export default {
data() {
return {
goods: [
{
id: ,
name: "哇哈哈",
price:
},
{
id: ,
name: "辣条",
price:
},
{
id: ,
name: "矿泉水",
price:
},
{
id: ,
name: "西瓜",
price:
},
{
id: ,
name: "苹果",
price:
}
],
checkAll: false,
isIndeterminate: true,
checkedGoods: [],
allPrice:
};
},
methods: {
handleAllChange(val) {
console.log(val, "");
this.checkedGoods = val ? goodOptions : [];
this.isIndeterminate = false;
if (val) {
this.getAllPrice();
} else {
this.allPrice = ;
}
},
handleOneChange(value) {
let a = ;
let checkedCount = value.length;
this.checkAll = checkedCount === this.checkedGoods.length;
this.isIndeterminate = checkedCount > && checkedCount < this.checkedGoods.length;
value.filter((it, id) => {
if (it == this.goods[id].name) {
if (this.goods[id].OnePrice) {
a += this.goods[id].OnePrice;
}
}
});
this.allPrice = a;
},
handleChangeNum(val) {
this.goods.filter((it, id) => {
if (it.id == val) {
it.OnePrice = it.num * it.price;
}
});
this.getAllPrice();
},
getAllPrice() {
//获取总价方法封装
let money = ;
this.goods.filter((it, id) => {
if (it.OnePrice) {
money += it.OnePrice;
}
});
this.allPrice = money;
},
submitBtn() {
this.$alert( this.allPrice+"元", "所有商品总计",{
confirmButtonText: "确定",
callback: action => {
this.$message({
type: "info",
message: "哈哈哈"
});
}
});
}
}
};
</script>
<style lang="postcss" scoped>
.bbb {
margin-left: 40px;
margin-top: 80px;
}
.aaa > label {
display: block;
text-align: left;
margin-top: 20px;
}
.el-checkbox {
display: block;
text-align: left;
}
</style>

最新文章

  1. flex(兼容写法)
  2. Java 元注解
  3. Canvas是什么
  4. ubuntu 获取root权限
  5. CodeForces 173A Rock-Paper-Scissors 数学
  6. 外部表查询时出现ORA-29913和ORA-29400错误
  7. 用APK Downloader直接从Google Play上下载apk
  8. 【转】AngularJs $location获取url参数
  9. C# 使用XmlDocument类对XML文档进行操作
  10. 跟着刚哥梳理java知识点——HelloWorld和常见问题(一)
  11. linux 安装MySql 5.7.21 操作步骤
  12. JVM学习六:JVM之类加载器之双亲委派机制
  13. Exchange-重建见证服务器和目录
  14. Error:Failed to resolve: com.android.support.constraint:constraint-layout:1.0.2
  15. elasticsearch简单实现
  16. idea用到的快捷键
  17. Spring Boot SSL
  18. 一次linux服务器黑客入侵后处理
  19. str
  20. HDU3488 Tour KM

热门文章

  1. c++命名空间namespace
  2. dede 调取二级三级菜单栏目
  3. 删除文件中的 ^M 字符
  4. luogu 3241 [HNOI2015]开店 动态点分治+二分+vector
  5. 51 Nod 1086 多重背包问题(单调队列优化)
  6. HGOI20190710 题解
  7. 试用saucelabs进行浏览器兼容性测试
  8. 安装python第三方模块
  9. OPTS参数设置
  10. php正则表达式的学习