Commit 282cce2c authored by zhengke's avatar zhengke

修改

parent 787a3940
...@@ -47,7 +47,7 @@ ...@@ -47,7 +47,7 @@
<div class="app-image" :style="{backgroundImage:'url(' + item.CoverImage + ')',backgroundSize:'cover'}"> <div class="app-image" :style="{backgroundImage:'url(' + item.CoverImage + ')',backgroundSize:'cover'}">
</div> </div>
<i class="el-icon-error" style="position: absolute;right: -5px;top:-5px;color: #F56C6C;font-size: 20px" <i class="el-icon-error" style="position: absolute;right: -5px;top:-5px;color: #F56C6C;font-size: 20px"
@click="deletecommod(index,1)"></i> @click="deletecommod(item,index)"></i>
</div> </div>
</div> </div>
</el-form-item> </el-form-item>
...@@ -96,7 +96,7 @@ ...@@ -96,7 +96,7 @@
<!--已指定商品类别选择--> <!--已指定商品类别选择-->
<el-dialog title="已指定商品类别" :visible.sync="category" width="714px"> <el-dialog title="已指定商品类别" :visible.sync="category" width="714px">
<div style="height:400px;overflow:auto;"> <div style="height:400px;overflow:auto;">
<el-tree :data="ProductCategoryTreeList" show-checkbox :check-on-click-node="true" default-expand-all <el-tree :data="ProductCategoryTreeList" show-checkbox :check-strictly="true" :check-on-click-node="true" default-expand-all
node-key="Id" ref="tree" :default-checked-keys="checkedkeys" @check="TreeList" :props="defaultProps"> node-key="Id" ref="tree" :default-checked-keys="checkedkeys" @check="TreeList" :props="defaultProps">
</el-tree> </el-tree>
</div> </div>
...@@ -105,32 +105,6 @@ ...@@ -105,32 +105,6 @@
<el-button type="primary" @click="getProductList" size="small">确 定</el-button> <el-button type="primary" @click="getProductList" size="small">确 定</el-button>
</div> </div>
</el-dialog> </el-dialog>
<!--已指定商品选择-->
<el-dialog title="已指定商品" :visible.sync="commodity" width="1024px">
<template>
<button class="el-button el-button--primary el-button--small" style="float: right;"
@click="addcommoditybtn">新增</button>
<el-table :data="commoditylist" style="width: 984px">
<el-table-column prop="Id" label="ID" width="80">
</el-table-column>
<el-table-column label="商品图" width="80">
<template slot-scope="scope">
<img style="width:50px;height:50px;margin-right:1px" :src="scope.row.CoverImage" alt="">
</template>
</el-table-column>
<el-table-column prop="Name" label="商品名称" width="604">
</el-table-column>
<el-table-column prop="address" label="操作">
<template slot-scope="scope">
<div class="cell">
<button type="button" class="el-button el-button--danger el-button--mini is-plain"
@click="deletecommod(scope,2)"><span>删除</span></button>
</div>
</template>
</el-table-column>
</el-table>
</template>
</el-dialog>
<!--选择的商品列表--> <!--选择的商品列表-->
<el-dialog title="添加商品" :visible.sync="addcommodity" width="1024px"> <el-dialog title="添加商品" :visible.sync="addcommodity" width="1024px">
<template> <template>
...@@ -146,8 +120,8 @@ ...@@ -146,8 +120,8 @@
@click="batchAdd">批量添加</button> @click="batchAdd">批量添加</button>
</div> </div>
</div> </div>
<el-table v-loading="loading_t" :data="tableData" @selection-change="handleSelectionChange" <el-table v-loading="loading_t" :data="tableData" ref="dataTable" @selection-change="handleSelectionChange"
style="width: 984px"> style="width: 984px;height:400px;overflow:auto;">
<el-table-column type="selection" width="55"> <el-table-column type="selection" width="55">
</el-table-column> </el-table-column>
<el-table-column prop="Id" label="ID" width="80"> <el-table-column prop="Id" label="ID" width="80">
...@@ -232,7 +206,6 @@ ...@@ -232,7 +206,6 @@
}, },
ProductCategoryTreeList: [], ProductCategoryTreeList: [],
checkedkeys: [], //默认选中的 checkedkeys: [], //默认选中的
commodity: false,
AppointList: [], //指定商品分类 AppointList: [], //指定商品分类
addcommodity: false, addcommodity: false,
commoditylist: [], //商品的list commoditylist: [], //商品的list
...@@ -312,7 +285,7 @@ ...@@ -312,7 +285,7 @@
}); });
} else if (val == 2) { } else if (val == 2) {
this.checkedkeys = [] this.checkedkeys = []
this.commodity = true this.addcommodity = true
} }
}, },
TreeList(val, e) { TreeList(val, e) {
...@@ -328,16 +301,21 @@ ...@@ -328,16 +301,21 @@
let ProductList = [] let ProductList = []
this.checkedkeys = e.checkedKeys; this.checkedkeys = e.checkedKeys;
if (e.checkedNodes.length > 0) { if (e.checkedNodes.length > 0) {
for (let i = 0; i < e.checkedNodes.length; i++) { this.checkedkeys.forEach(x=>{
if (e.checkedNodes[i].ChildList.length == 0) { var objList = this.getObjById(this.ProductCategoryTreeList,x);
ProductList.push({ if(objList){
'ProductId': e.checkedNodes[i].Id, for(var i=0;i<this.AppointList.length;i++){
'Name': e.checkedNodes[i].Name if(this.AppointList[i].ProductId==objList.Id){
return;
}
}
this.AppointList.push({
ProductId: objList.Id,
Name: objList.Name
}) })
} }
} })
} }
this.AppointList = ProductList
}, },
//删除对应商品类型 //删除对应商品类型
deleteProduct(item, index) { deleteProduct(item, index) {
...@@ -348,24 +326,13 @@ ...@@ -348,24 +326,13 @@
} }
} }
}, },
addcommoditybtn() { deletecommod(data, index) {
this.addcommodity = true; this.tableData.forEach(x=>{
for (let i = 0; i < this.tableData.length; i++) { if(data.Id==x.Id){
this.tableData[i].disabled = false; x.disabled=false
for (let j = 0; j < this.commoditylist.length; j++) { this.commoditylist.splice(index, 1)
if (this.commoditylist[j].Id == this.tableData[i].Id) {
this.tableData[i].disabled = true
}
} }
} })
},
deletecommod(data, type) {
if (type == 1) {
this.commoditylist.splice(data, 1)
} else {
this.commoditylist.splice(data.$index, 1)
}
}, },
getProductGoodsPageList() { getProductGoodsPageList() {
this.loading_t = true this.loading_t = true
...@@ -427,6 +394,7 @@ ...@@ -427,6 +394,7 @@
this.Success('添加成功'); this.Success('添加成功');
} }
this.commoditylist = this.unique(this.commoditylist.concat(newdata)) this.commoditylist = this.unique(this.commoditylist.concat(newdata))
this.$refs.dataTable.clearSelection()
}, },
// 数组去重 // 数组去重
unique(arr) { unique(arr) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment