4.3.1 删除行的实现
实现思路:在每一行将索引值传递给集合,在集合中删除。修改 specificationController.js 新增以下代码
[AppleScript] 纯文本查看 复制代码
?
1
2
3
4
5
6
7
|
/ / 批量选项删除
$scope.deleTableRow = function ( index ) {
$scope.entity.specificationOptionList.splice ( index , 1 ) ; / / 删除
}
|
修改每行的删除按钮
[AppleScript] 纯文本查看 复制代码
?
1
|
< button type = "button" class = "btn btn-default" title = "删除"
|
[AppleScript] 纯文本查看 复制代码
?
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
* @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] 纯文本查看 复制代码
?
1
2
3
4
5
6
|
/ * *
* 增 加
* /
public void add ( Specification specification ) ;
|
(4)修改 pinyougou-sellergoods-service 的 SpecificationServiceImpl.java
[AppleScript] 纯文本查看 复制代码
?
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
|
/ * *
* 增 加
* / @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] 纯文本查看 复制代码
?
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
/ * *
* 增加
* @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] 纯文本查看 复制代码
?
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
|
< 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] 纯文本查看 复制代码
?
1
|
< button class = "btn btn-success" data - dismiss = "modal" aria - hidden = "true" ng - click = "save()" > 保
|