本帖最后由 谷粒姐姐 于 2018-8-3 11:52 编辑
4.3.1 删除行的实现 实现思路:在每一行将索引值传递给集合,在集合中删除。修改 specificationController.js 新增以下代码 [AppleScript] 纯文本查看 复制代码 //批量选项删除
$scope.deleTableRow=function(index){
$scope.entity.specificationOptionList.splice(index,1);//删除
} 修改每行的删除按钮 [AppleScript] 纯文本查看 复制代码 < button type="button" class="btn btn-default" title="删除" [AppleScript] 纯文本查看 复制代码 * @author Administrator
*
*/
public class Specification implements Serializable {
private TbSpecification specification;
private List<TbSpecificationOption> specificationOptionList;
public TbSpecification getSpecification() {
return specification;
}
public void setSpecification(TbSpecification specification) {
this.specification = specification;
}
public List<TbSpecificationOption> getSpecificationOptionList() {
return specificationOptionList;
}
public void setSpecificationOptionList(List<TbSpecificationOption> specificationOptionList) {
this.specificationOptionList = specificationOptionList;
}
} (3)修改 pinyougou-sellergoods-interface 的 SpecificationService.java [AppleScript] 纯文本查看 复制代码 /**
* 增 加
*/
public void add(Specification specification); (4)修改 pinyougou-sellergoods-service 的 SpecificationServiceImpl.java [AppleScript] 纯文本查看 复制代码 /**
* 增 加
*/ @Override
public void add(Specification specification) {
specificationMapper.insert(specification.getSpecification());//插入规格
//循环插入规格选项
for(TbSpecificationOption specificationOption:specification.getSpecificationOptionList()){
specificationOption.setSpecId(specification.getSpecification().getId());//设置规
格 ID specificationOptionMapper.insert(specificationOption);
}
} (5)修改 pinyougou-manager-web 的 SpecificationController.java [AppleScript] 纯文本查看 复制代码 /**
*增加
*@param specification
*@return
*/ @RequestMapping("/add")
public Result add(@RequestBody Specification specification){
try {
specificationService.add(specification);
return new Result(true, "增加成功");
} catch (Exception e) { e.printStackTrace();
return new Result(false, "增加失败");
}
} (6)修改页面 specification.html 绑定规格名称 [AppleScript] 纯文本查看 复制代码 <table class="table table-bordered table-striped" width="800px">
<tr>
<td>规格名称</td>
<td>
<input ng-model="entity.specification.specName" class="form-control" placeholder="规格名称" >
</td>
</tr>
</table> [AppleScript] 纯文本查看 复制代码 <button class="btn btn-success" data-dismiss="modal" aria-hidden="true" ng-click="save()">保存</button> |