浏览代码

添加商品编号

pangqijun 1 年之前
父节点
当前提交
cbbcb306e2
共有 1 个文件被更改,包括 53 次插入43 次删除
  1. 53 43
      src/views/groupon/groupon.vue

+ 53 - 43
src/views/groupon/groupon.vue

@@ -56,48 +56,18 @@
       <!--  添加商品插槽    -->
       <template slot="goodsForm">
         <el-button type="primary" size="mini" @click="addGoodsBox = true">添 加</el-button>
-        <el-table
-            :data="tableData"
-            style="width: 100%">
-          <el-table-column label="商品" width="280">
-            <template slot-scope="scope">
-              <el-row>
-                <el-col :span="4">
-                  <el-avatar shape="square" :size="45" fit="fit" :src="scope.row.goodsCover"></el-avatar>
-                </el-col>
-                <el-col :span="20">
-                  <span style="line-height: 40px; margin-left: 10px">{{ scope.row.goodsName }}</span>
-                </el-col>
-              </el-row>
-            </template>
-          </el-table-column>
-          <el-table-column label="规格" width="180">
-            <template slot-scope="scope">
-              <el-row>
-                <el-col :span="24">
-                  <span style="line-height: 40px;">{{ scope.row.goodsSpec }}</span>
-                </el-col>
-              </el-row>
-            </template>
-          </el-table-column>
-          <el-table-column label="供应商">
-            <template slot-scope="scope">
-              <el-row>
-                <el-col :span="24">
-                  <span style="line-height: 40px;">{{ scope.row.supplierName }}</span>
-                </el-col>
-              </el-row>
-            </template>
-          </el-table-column>
-          <el-table-column label="操作">
-            <template slot-scope="scope">
-              <el-button
-                  size="mini"
-                  type="danger"
-                  @click="handleDeleteGood(scope.$index, scope.row)">删除</el-button>
-            </template>
-          </el-table-column>
-        </el-table>
+        <avue-crud :option="optionTable"
+                   :data="tableData"
+                   ref="crudGoods">
+          <template #menu="{row,index,size}">
+            <el-button type="danger"
+                       size="mini"
+                       @click="rowDelGoods(row,index)">删除</el-button>
+          </template>
+          <template slot="grouponPrice" slot-scope="scope" >
+            <avue-input-number precision="2" v-model="scope.row.grouponPrice"></avue-input-number>
+          </template>
+        </avue-crud>
       </template>
 
 
@@ -192,7 +162,40 @@ export default {
         remark: ''
       },
       selectionList: [],
+      optionTable: {
+        // rowSort: true,
+        menuWidth: 90,
+        refreshBtn: false,
+        columnBtn: false,
+        addBtn: false,
+        viewBtn: false,
+        editBtn: false,
+        delBtn: false,
+        sortable: true,
+        // keyId: 'goodsId',
+        column: [{
+          label: '商品图片',
+          prop: 'goodsCover',
+          type: 'img',
+          width: 70,
+        }, {
+          label: '商品名称',
+          prop: 'goodsName',
+        }, {
+          label: '规格',
+          prop: 'goodsSpec',
+        }, {
+          label: '供应商',
+          prop: 'supplierName',
+        }, {
+          label: '团购价',
+          prop: 'grouponPrice',
+          slot:true
+        }]
+      },
       option: {
+        // dialogType: 'drawer',
+        // dialogDirection: 'rtl',
         height: 'auto',
         calcHeight: 30,
         tip: false,
@@ -664,17 +667,24 @@ export default {
         let g = map.get(e.id);
         if (!g) {
           let goods = {
+            id: e.id,
             goodsId: e.id,
             goodsName: e.goodsName,
             goodsCover: e.goodsCover,
             goodsSpec: e.goodsSpec,
-            supplierName: e.supplierName
+            supplierName: e.supplierName,
+            grouponPrice: 0.00
           }
           this.tableData.push(goods);
         }
       })
 
       this.addGoodsBox = false;
+      this.grouponSelectionClear();
+    },
+    rowDelGoods(row, index) {
+      console.log(row, index);
+      this.tableData.splice(index, 1);
     }
   }
 };