Explorar o código

购物车删除

skyblued %!s(int64=3) %!d(string=hai) anos
pai
achega
088f7607c8
Modificáronse 1 ficheiros con 11 adicións e 2 borrados
  1. 11 2
      src/views/cart/index.tsx

+ 11 - 2
src/views/cart/index.tsx

@@ -160,7 +160,16 @@ export default defineComponent({
         {this.dataShow ? (
           <div>
             <ColHeader
-              onClickRight={() => (this.isManage = !this.isManage)}
+              onClickRight={() => {
+                this.isManage = !this.isManage
+                if (!this.isManage){
+                  this.cartList.forEach((n:any) => {
+                    if (n.stock <= 0){
+                      this.selectItems = this.selectItems.filter((item: any) => item != n.id)
+                    }
+                  })
+                }
+              }}
               v-slots={{
                 right: () => (
                   <span style={{ color: '#333', fontSize: '14px' }}>
@@ -174,7 +183,7 @@ export default defineComponent({
                 <CheckboxGroup v-model={this.selectItems}>
                   {this.cartList.map((item: any) => (
                     <div class={styles.cartItem}>
-                      <Checkbox name={item.id} disabled={item.stock <= 0}>
+                      <Checkbox name={item.id} disabled={item.stock <= 0 && !this.isManage}>
                         <Card
                           price={moneyFormat(item.price)}
                           desc={formateAttr(item.productAttr)}