2 次代码提交 ee77f21068 ... d6aef36383

作者 SHA1 备注 提交日期
  temp01 d6aef36383 Merge remote-tracking branch 'origin/master' 1 周之前
  temp01 4208cf3490 业务查询 1 周之前

+ 5 - 1
src/main/java/com/zjt/entity/ProductionVarietyDetail.java

@@ -7,6 +7,8 @@ import lombok.Data;
7 7
 import lombok.EqualsAndHashCode;
8 8
 import lombok.experimental.Accessors;
9 9
 
10
+import javax.persistence.Column;
11
+
10 12
 /**
11 13
  * <p>
12 14
  * 
@@ -23,11 +25,13 @@ public class ProductionVarietyDetail implements Serializable {
23 25
 
24 26
     private static final long serialVersionUID = 1L;
25 27
     private Float id;
26
-
28
+    @Column(name = "variety_id")
27 29
     private Float varietyId;
28 30
 
31
+    @Column(name = "variety")
29 32
     private String variety;
30 33
 
34
+    @Column(name = "variety_details")
31 35
     private String varietyDetails;
32 36
 
33 37
 

+ 4 - 2
src/main/java/com/zjt/entity/ProductionVarietyDetailColour.java

@@ -7,6 +7,8 @@ import lombok.Data;
7 7
 import lombok.EqualsAndHashCode;
8 8
 import lombok.experimental.Accessors;
9 9
 
10
+import javax.persistence.Column;
11
+
10 12
 /**
11 13
  * <p>
12 14
  * 
@@ -22,9 +24,9 @@ import lombok.experimental.Accessors;
22 24
 public class ProductionVarietyDetailColour implements Serializable {
23 25
 
24 26
     private static final long serialVersionUID = 1L;
25
-
27
+    @Column(name = "variety_details_id")
26 28
     private Float varietyDetailsId;
27
-
29
+    @Column(name = "colour")
28 30
     private String colour;
29 31
 
30 32
 

+ 37 - 4
src/main/java/com/zjt/entity/Productionheader.java

@@ -10,6 +10,8 @@ import lombok.Data;
10 10
 import lombok.EqualsAndHashCode;
11 11
 import lombok.experimental.Accessors;
12 12
 
13
+import javax.persistence.Column;
14
+
13 15
 /**
14 16
  * <p>
15 17
  * 
@@ -26,6 +28,12 @@ public class Productionheader implements Serializable {
26 28
 
27 29
     private static final long serialVersionUID = 1L;
28 30
 
31
+    @Column(name = "variety_detail_id")
32
+    private Float varietyDetailId;
33
+
34
+    @Column(name = "variety_id")
35
+    private Float varietyId;
36
+
29 37
     @ApiModelProperty(value = "关联订单ID")
30 38
     private Long orderId;
31 39
 
@@ -33,92 +41,117 @@ public class Productionheader implements Serializable {
33 41
     private Long customerId;
34 42
 
35 43
     @ApiModelProperty(value = "系列")
44
+    @Column(name = "series")
36 45
     private String series;
37 46
 
38 47
     @ApiModelProperty(value = "商品1")
48
+    @Column(name = "product1")
39 49
     private String product1;
40 50
 
41 51
     @ApiModelProperty(value = "产品")
52
+    @Column(name = "product")
42 53
     private String product;
43 54
 
44 55
     @ApiModelProperty(value = "设计")
56
+    @Column(name = "design")
45 57
     private String design;
46 58
 
47 59
     @ApiModelProperty(value = "折射率")
60
+    @Column(name = "refractive_index")
48 61
     private String refractiveIndex;
49 62
 
50 63
     @ApiModelProperty(value = "膜层")
64
+    @Column(name = "coating")
51 65
     private String coating;
52 66
 
53 67
     @ApiModelProperty(value = "颜色")
68
+    @Column(name = "color")
54 69
     private String color;
55 70
 
56 71
     @ApiModelProperty(value = "属性")
72
+    @Column(name = "attribute")
57 73
     private String attribute;
58 74
 
59 75
     @ApiModelProperty(value = "光度范围")
76
+    @Column(name = "diopter_range")
60 77
     private String diopterRange;
61 78
 
62 79
     @ApiModelProperty(value = "范围说明")
80
+    @Column(name = "range_description")
63 81
     private String rangeDescription;
64 82
 
65 83
     @ApiModelProperty(value = "售价")
84
+    @Column(name = "retail_price")
66 85
     private BigDecimal retailPrice;
67 86
 
68 87
     @ApiModelProperty(value = "单眼瞳高")
88
+    @Column(name = "pupillary_height")
69 89
     private String pupillaryHeight;
70 90
 
71 91
     @ApiModelProperty(value = "单眼瞳距(右)")
72
-    private String singleEyePupillaryDistanceRight;
73
-
74
-    @ApiModelProperty(value = "单眼瞳距(左)")
75
-    private String singleEyePupillaryDistanceLeft;
92
+    @Column(name = "single_eye_pupillary_distance")
93
+    private String singleEyePupillaryDistance;
76 94
 
77 95
     @ApiModelProperty(value = "镜眼距")
96
+    @Column(name = "lens_edge_distance")
78 97
     private String lensEdgeDistance;
79 98
 
80 99
     @ApiModelProperty(value = "前倾角")
100
+    @Column(name = "front_angle")
81 101
     private String frontAngle;
82 102
 
83 103
     @ApiModelProperty(value = "镜架面")
104
+    @Column(name = "frame_surface")
84 105
     private String frameSurface;
85 106
 
86 107
     @ApiModelProperty(value = "习惯阅读距离")
108
+    @Column(name = "habit_reading_distance")
87 109
     private String habitReadingDistance;
88 110
 
89 111
     @ApiModelProperty(value = "近用瞳距")
112
+    @Column(name = "near_use_pupillary_distance")
90 113
     private String nearUsePupillaryDistance;
91 114
 
92 115
     @ApiModelProperty(value = "NVB")
116
+    @Column(name = "nvb")
93 117
     private String nvb;
94 118
 
95 119
     @ApiModelProperty(value = "主视眼")
120
+    @Column(name = "main_vision")
96 121
     private String mainVision;
97 122
 
98 123
     @ApiModelProperty(value = "ERCD")
124
+    @Column(name = "ercd")
99 125
     private String ercd;
100 126
 
101 127
     @ApiModelProperty(value = "年龄")
128
+    @Column(name = "age")
102 129
     private String age;
103 130
 
104 131
     @ApiModelProperty(value = "商品编码")
132
+    @Column(name = "product_code")
105 133
     private String productCode;
106 134
 
107 135
     @ApiModelProperty(value = "商品名称")
136
+    @Column(name = "product_name")
108 137
     private String productName;
109 138
 
110 139
     @ApiModelProperty(value = "状态:0-禁用,1-启用")
111 140
     @TableField("STATUS")
112 141
     private Integer status;
113 142
 
143
+    @Column(name = "create_Time")
114 144
     private LocalDateTime createTime;
115 145
 
146
+    @Column(name = "update_Time")
116 147
     private LocalDateTime updateTime;
117 148
 
118 149
     @ApiModelProperty(value = "创建人")
150
+    @Column(name = "create_By")
119 151
     private String createBy;
120 152
 
121 153
     @ApiModelProperty(value = "更新人")
154
+    @Column(name = "update_By")
122 155
     private String updateBy;
123 156
 
124 157
 

+ 2 - 0
src/main/java/com/zjt/mapper/ProductionVarietyDetailColourMapper.java

@@ -15,4 +15,6 @@ import java.util.List;
15 15
  */
16 16
 public interface ProductionVarietyDetailColourMapper extends BaseMapper<ProductionVarietyDetailColour> {
17 17
     public List<ProductionVarietyDetailColour> selectvarietyDetailsColour(long varietyId);
18
+
19
+    List<ProductionVarietyDetailColour> selectColour(long varietyDetailId);
18 20
 }

+ 1 - 1
src/main/java/com/zjt/mapper/ProductionVarietyDetailMapper.java

@@ -14,7 +14,7 @@ import java.util.List;
14 14
  * @since 2025-09-25
15 15
  */
16 16
 public interface ProductionVarietyDetailMapper extends BaseMapper<ProductionVarietyDetail> {
17
-    public List<ProductionVarietyDetail> selectvarietyDetails(long varietyId);
17
+    public List<ProductionVarietyDetail> selectvarietyDetails(String variety);
18 18
     public List<ProductionVarietyDetail> selectvarietyList();
19 19
 
20 20
 }

+ 4 - 0
src/main/java/com/zjt/mapper/ProductionheaderMapper.java

@@ -1,8 +1,11 @@
1 1
 package com.zjt.mapper;
2 2
 
3
+import com.zjt.entity.ProductionVarietyDetail;
3 4
 import com.zjt.entity.Productionheader;
4 5
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
5 6
 
7
+import java.util.List;
8
+
6 9
 /**
7 10
  * <p>
8 11
  *  Mapper 接口
@@ -13,4 +16,5 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
13 16
  */
14 17
 public interface ProductionheaderMapper extends BaseMapper<Productionheader> {
15 18
 
19
+    List<Productionheader> selectProductionheader(long varietyDetailId);
16 20
 }

+ 7 - 1
src/main/java/com/zjt/service/IProductionVarietyDetailService.java

@@ -2,6 +2,8 @@ package com.zjt.service;
2 2
 
3 3
 import com.zjt.entity.ProductionVarietyDetail;
4 4
 import com.baomidou.mybatisplus.extension.service.IService;
5
+import com.zjt.entity.ProductionVarietyDetailColour;
6
+import com.zjt.entity.Productionheader;
5 7
 
6 8
 import java.util.List;
7 9
 
@@ -15,5 +17,9 @@ import java.util.List;
15 17
  */
16 18
 public interface IProductionVarietyDetailService extends IService<ProductionVarietyDetail> {
17 19
     List<ProductionVarietyDetail> selectvarietyList();
18
-    List<ProductionVarietyDetail> selectvarietyDetails(long varietyId);
20
+    List<ProductionVarietyDetail> selectvarietyDetails(String variety);
21
+
22
+    List<Productionheader> selectProductionheader(long varietyDetailId);
23
+
24
+    List<ProductionVarietyDetailColour> selectColour(long varietyDetailId);
19 25
 }

+ 24 - 3
src/main/java/com/zjt/service/impl/ProductionVarietyDetailServiceImpl.java

@@ -1,12 +1,15 @@
1 1
 package com.zjt.service.impl;
2 2
 
3 3
 import com.zjt.entity.ProductionVarietyDetail;
4
+import com.zjt.entity.ProductionVarietyDetailColour;
5
+import com.zjt.entity.Productionheader;
6
+import com.zjt.mapper.ProductionVarietyDetailColourMapper;
4 7
 import com.zjt.mapper.ProductionVarietyDetailMapper;
5 8
 import com.zjt.mapper.ProductionVarietyMapper;
9
+import com.zjt.mapper.ProductionheaderMapper;
6 10
 import com.zjt.service.IProductionVarietyDetailService;
7 11
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
8 12
 import org.springframework.stereotype.Service;
9
-
10 13
 import javax.annotation.Resource;
11 14
 import java.util.Collections;
12 15
 import java.util.List;
@@ -24,6 +27,10 @@ public class ProductionVarietyDetailServiceImpl extends ServiceImpl<ProductionVa
24 27
 
25 28
     @Resource
26 29
     ProductionVarietyDetailMapper ProductionVarietyDetailMapper;
30
+    @Resource
31
+    ProductionheaderMapper ProductionheaderMapper;
32
+    @Resource
33
+    com.zjt.mapper.ProductionVarietyDetailColourMapper ProductionVarietyDetailColourMapper;
27 34
     @Override
28 35
     public List<ProductionVarietyDetail> selectvarietyList() {
29 36
         List<ProductionVarietyDetail> productionVarietyDetails = ProductionVarietyDetailMapper.selectvarietyList();
@@ -31,8 +38,22 @@ public class ProductionVarietyDetailServiceImpl extends ServiceImpl<ProductionVa
31 38
     }
32 39
 
33 40
     @Override
34
-    public List<ProductionVarietyDetail> selectvarietyDetails(long  varietyId) {
35
-        List<ProductionVarietyDetail> productionVarietyDetails = ProductionVarietyDetailMapper.selectvarietyDetails(varietyId);
41
+    public List<ProductionVarietyDetail> selectvarietyDetails(String  variety) {
42
+        List<ProductionVarietyDetail> productionVarietyDetails = ProductionVarietyDetailMapper.selectvarietyDetails(variety);
36 43
         return productionVarietyDetails;
37 44
     }
45
+
46
+    @Override
47
+    public List<Productionheader> selectProductionheader(long varietyDetailId) {
48
+        List<Productionheader>productionheaderDetails = ProductionheaderMapper.selectProductionheader(varietyDetailId);
49
+        return productionheaderDetails;
50
+    }
51
+
52
+    @Override
53
+    public List<ProductionVarietyDetailColour> selectColour(long varietyDetailId) {
54
+        List<ProductionVarietyDetailColour>ProductionVarietyDetailColour = ProductionVarietyDetailColourMapper.selectColour(varietyDetailId);
55
+        return ProductionVarietyDetailColour;
56
+    }
57
+
58
+
38 59
 }

+ 19 - 7
src/main/java/com/zjt/web/ProductionVarietyDetailController.java

@@ -1,8 +1,11 @@
1 1
 package com.zjt.web;
2 2
 
3 3
 
4
+import com.alibaba.fastjson.JSON;
4 5
 import com.alibaba.fastjson.JSONArray;
5 6
 import com.zjt.entity.ProductionVarietyDetail;
7
+import com.zjt.entity.ProductionVarietyDetailColour;
8
+import com.zjt.entity.Productionheader;
6 9
 import com.zjt.service.IProductionVarietyDetailService;
7 10
 import com.zjt.service.IProductionVarietyService;
8 11
 import org.springframework.beans.factory.annotation.Autowired;
@@ -33,10 +36,9 @@ public class ProductionVarietyDetailController {
33 36
         return  JSONArray.toJSON(productionVarietyDetails).toString();
34 37
     }
35 38
     @RequestMapping("varietyDetailsLists")
36
-    public String selectvarietyDetails(@RequestParam("id") String id) {
37
-        if(id!=null||id!=""){
38
-            long l = Long.parseLong(id);
39
-            List<ProductionVarietyDetail> productionVarietyDetails = productionVarietyDetailService.selectvarietyDetails(l);
39
+    public String selectvarietyDetails(String variety) {
40
+        if(variety!=null||variety!=""){
41
+            List<ProductionVarietyDetail> productionVarietyDetails = productionVarietyDetailService.selectvarietyDetails(variety);
40 42
             return  JSONArray.toJSON(productionVarietyDetails).toString();
41 43
         }else{
42 44
             return  JSONArray.toJSON("").toString();
@@ -46,11 +48,21 @@ public class ProductionVarietyDetailController {
46 48
     @RequestMapping("productionheader")
47 49
     public String group(@RequestParam("id") String id){
48 50
         if(id!=null||id!=""){
49
-            List<ProductionVarietyDetail> productionVarietyDetails1 = productionVarietyDetailService.selectvarietyDetails(Long.parseLong(id));
50
-            return  JSONArray.toJSON(productionVarietyDetails1).toString();
51
+            long l = Long.parseLong(id);
52
+            List<Productionheader> productionVarietyDetails = productionVarietyDetailService.selectProductionheader(l);
53
+            return  JSONArray.toJSON(productionVarietyDetails).toString();
54
+        }else{
55
+            return  JSONArray.toJSON("").toString();
56
+        }
57
+    }
58
+    @RequestMapping("selectColour")
59
+    public String selectColour(@RequestParam("id") String id){
60
+        if(id!=null||id!=""){
61
+            long l = Long.parseLong(id);
62
+            List<ProductionVarietyDetailColour> productionVarietyDetails = productionVarietyDetailService.selectColour(l);
63
+            return  JSONArray.toJSON(productionVarietyDetails).toString();
51 64
         }else{
52 65
             return  JSONArray.toJSON("").toString();
53 66
         }
54
-
55 67
     }
56 68
 }

+ 0 - 1
src/main/java/com/zjt/web/ProductionheaderController.java

@@ -32,7 +32,6 @@ public class ProductionheaderController {
32 32
     public String selectVarietyAll() {
33 33
         productionVarietyService.varietyList();
34 34
         productionVarietyDetailService.selectvarietyList();
35
-        productionVarietyDetailService.selectvarietyDetails(1l);
36 35
         return VIEW_VARIETY_LIST;
37 36
     }
38 37
 

+ 4 - 0
src/main/resources/mapper/ProductionVarietyDetailColourMapper.xml

@@ -12,4 +12,8 @@
12 12
         where variety_details_id=#{varietyId}
13 13
     </select>
14 14
 
15
+    <select id="selectColour" resultMap="BaseResultMap">
16
+        select * from production_variety_detail_colour
17
+        where variety_details_id=#{varietyDetailId}
18
+    </select>
15 19
 </mapper>

+ 1 - 1
src/main/resources/mapper/ProductionVarietyDetailMapper.xml

@@ -31,6 +31,6 @@
31 31
     <select id="selectvarietyDetails" resultMap="BaseResultMap">
32 32
         select <include refid="Base_Column_List" />
33 33
         from production_variety_detail
34
-        where variety_id = #{varietyId}
34
+        where variety = #{variety}
35 35
     </select>
36 36
 </mapper>

+ 13 - 1
src/main/resources/mapper/ProductionheaderMapper.xml

@@ -3,6 +3,18 @@
3 3
 <mapper namespace="com.zjt.mapper.ProductionheaderMapper">
4 4
     <!-- 通用查询结果映射 -->
5 5
     <resultMap id="BaseResultMap" type="com.zjt.entity.Productionheader">
6
-        <!-- 请根据实际实体类字段进行配置 -->
6
+        <id column="variety_detail_id" jdbcType="FLOAT" property="varietyDetailId" />
7
+        <result column="variety_id" jdbcType="VARCHAR" property="varietyId" />
8
+        <result column="product_code" jdbcType="VARCHAR" property="productCode" />
9
+        <result column="product_name" jdbcType="VARCHAR" property="productName" />
7 10
     </resultMap>
11
+    <sql id="Base_Column_List">
12
+        variety_detail_id, variety_id, product_code, product_name
13
+    </sql>
14
+
15
+    <select id="selectProductionheader"  resultMap="BaseResultMap">
16
+        select  *
17
+        from productionheader
18
+        where variety_detail_id = #{varietyDetailId}
19
+    </select>
8 20
 </mapper>

+ 227 - 286
src/main/resources/templates/mypackage/varietyList.ftl

@@ -12,164 +12,97 @@
12 12
     <link rel="icon" href="${basePath!}/static/logo.png">
13 13
     <link rel="stylesheet" href="${basePath!}/static/layui/css/layui.css" media="all" />
14 14
     <link rel="stylesheet" href="${basePath!}/static/css/public.css" media="all" />
15
-    <!-- 保留一个layui脚本引用即可 -->
15
+    <script src="${basePath!}/static/layui/layui.js" charset="utf-8"></script>
16 16
     <script src="${basePath!}/static/layui/layui.all.js" charset="utf-8"></script>
17
+    <script src="${basePath!}/static/layui/lay/modules/jquery.js"></script>
17 18
 </head>
18 19
 <body>
19 20
 <hr>
20
-
21
-<!-- 订单信息区域 -->
22 21
 <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
23 22
     <legend>订单信息</legend>
24
-
25
-    <!-- 物料选择表单 -->
26
-    <div class="layui-form material-selection-form">
27
-        <div class="form-container">
23
+    <div class="layui-form" style="width: 100%; margin-top: 20px;">
24
+        <center>
28 25
             <form class="layui-form" action="">
29 26
                 <div class="layui-form-item" id="materialchoose">
30
-                    <label class="layui-form-label">物料信息</label>
31
-
32
-                    <div class="material-selection-group">
33
-                        <div class="layui-input-inline select-item">
34
-                            <select name="materialType"
35
-                                    id="materialType"
36
-                                    class="province-selector"
37
-                                    data-value="品类"
38
-                                    lay-filter="materialType"
39
-                                    lay-search="">
40
-                                <option value="">品类</option>
41
-                            </select>
42
-                        </div>
43
-
44
-                        <div class="layui-input-inline select-item">
45
-                            <select name="brand"
46
-                                    id="brand"
47
-                                    class="city-selector"
48
-                                    data-value="品牌"
49
-                                    lay-filter="brand"
50
-                                    lay-search="">
51
-                                <option value="">品牌</option>
52
-                            </select>
53
-                        </div>
54
-
55
-                        <div class="layui-input-inline select-item">
56
-                            <select name="materialGroup"
57
-                                    id="materialGroup"
58
-                                    class="county-selector"
59
-                                    data-value="物料组"
60
-                                    lay-filter="materialGroup"
61
-                                    lay-search="">
62
-                                <option value="">物料组</option>
63
-                            </select>
64
-                        </div>
65
-
66
-                        <div class="layui-input-inline select-item">
67
-                            <select name="materialdetil"
68
-                                    id="materialdetil"
69
-                                    class="county-selector"
70
-                                    data-value="物料描述"
71
-                                    lay-filter="materialdetil">
72
-                                <option value="">物料描述</option>
73
-                            </select>
74
-                        </div>
75
-
76
-                        <div class="layui-input-inline select-item">
77
-                            <select name="materialCode"
78
-                                    id="materialCode"
79
-                                    class="county-selector"
80
-                                    data-value="物料编码"
81
-                                    lay-filter="materialCode">
82
-                                <option value="">物料编码</option>
83
-                            </select>
84
-                        </div>
85
-
86
-                        <div class="layui-input-inline action-item">
87
-                            <button type="button"
88
-                                    class="layui-btn layui-btn-primary"
89
-                                    onclick="addtable()">
90
-                                <i class="layui-icon layui-icon-add-circle"></i>添加
91
-                            </button>
92
-                        </div>
27
+                    <div class="layui-form-label">物料信息</div>
28
+                    <div class="layui-input-inline" style="width: 300px;">
29
+                        <select name="materialType" id="materialType" class="province-selector" data-value="品类" lay-filter="materialType" onclick="dele()" lay-search="">
30
+                            <option value="">品类</option>
31
+                        </select>
32
+                    </div>
33
+                    <div class="layui-input-inline" style="width: 300px;">
34
+                        <select name="brand" id ="brand" class="city-selector" data-value="品牌" lay-filter="brand" onclick="selectbrand()" lay-search="">
35
+                            <option value="">品牌</option>
36
+                        </select>
37
+                    </div>
38
+<#--                    <div class="layui-input-inline" style="width: 200px;">
39
+                        <select name="materialGroup" id ="materialGroup" class="county-selector" data-value="物料组" lay-filter="materialGroup"  lay-search="">
40
+                            <option value="">物料组</option>
41
+                        </select>
42
+                    </div>-->
43
+                    <div class="layui-input-inline" style="width: 400px;">
44
+                        <select name="productName" id ="productName" class="county-selector" data-value="物料描述" lay-filter="productName">
45
+<#--                            <option value="">物料描述</option>-->
46
+                        </select>
47
+                    </div>
48
+                    <div class="layui-input-inline" style="width: 200px;">
49
+                        <select name="productCode" id ="productCode" class="county-selector" data-value="物料编码" lay-filter="productCode">
50
+                            <option value="">物料编码</option>
51
+                        </select>
52
+                    </div>
53
+                    <div class="layui-input-inline" style="width: 100px;">
54
+                        <a class="layui-btn layui-btn add" onclick="addtable()">添加</a>
93 55
                     </div>
94 56
                 </div>
95 57
             </form>
96
-        </div>
58
+        </center>
97 59
     </div>
98 60
 
99
-    <!-- 订单数据表格 -->
100
-    <form class="layui-form order-form" method="post">
101
-        <div class="layui-form-item table-container">
102
-            <div class="table-wrapper">
103
-                <table class="layui-table order-table"
104
-                       id="table"
105
-                       lay-filter="table">
61
+    <form class="layui-form" method="post" >
62
+        <div class="layui-form-item" style="width:5000px;">
63
+            <center>
64
+                <table class="layui-table" style ="width:5000px; overflow:scroll;" id="table" lay-filter="table" border="1">
106 65
                     <colgroup>
107 66
                         <col width="150">
108 67
                         <col width="200">
109 68
                         <col>
110 69
                     </colgroup>
111
-
112
-                    <thead>
113
-                    <tr>
114
-                        <th style="width: 200px">操作</th>
115
-                        <th style="width: 200px">镜片位置</th>
116
-                        <th style="width: 200px">采购/退货</th>
117
-                        <th style="width: 200px">用户名</th>
118
-                        <th style="width: 300px">物料编码</th>
119
-                        <th style="width: 800px">物料描述</th>
120
-                        <th style="width: 300px">物料价格</th>
121
-                        <th style="width: 300px">数量</th>
122
-                        <th style="width: 300px">球镜</th>
123
-                        <th style="width: 300px">柱镜</th>
124
-                        <th style="width: 300px">轴位</th>
125
-                        <th style="width: 300px">瞳距</th>
126
-                        <th style="width: 300px">瞳高</th>
127
-                        <th style="width: 300px">下加光</th>
128
-                        <th style="width: 300px">通道</th>
129
-                        <th style="width: 300px">棱镜</th>
130
-                        <th style="width: 300px">镜片度数</th>
131
-                        <th style="width: 300px">镜片型号/基弧</th>
132
-                        <th style="width: 300px">是否染色</th>
133
-                        <th style="width: 300px">色度</th>
134
-                        <th style="width: 300px">来板染色</th>
135
-                        <th style="width: 300px">厂家色板</th>
136
-                        <th style="width: 300px">标准色号</th>
137
-                        <th style="width: 300px">美薄加工</th>
138
-                        <th style="width: 300px">丽薄加工</th>
139
-                        <th style="width: 300px">镜架框形</th>
140
-                        <th style="width: 300px">镜架高度</th>
141
-                        <th style="width: 300px">鼻梁间距</th>
142
-                        <th style="width: 300px">水平宽度</th>
143
-                        <th style="width: 300px">加工镜架框形</th>
144
-                        <th style="width: 300px">颜色</th>
145
-                        <th style="width: 300px">直径</th>
146
-                        <th style="width: 300px">片型</th>
147
-                        <th style="width: 300px">片色</th>
148
-                        <th style="width: 300px">备注</th>
70
+                    <thead style="align: center">
71
+                    <tr style="align: center">
72
+                        <th style = "width: 200px"> 操作</th>
73
+                        <th style = "width: 300px"> 物料编码</th>
74
+                        <th style = "width: 500px"> 物料描述</th>
75
+                        <th style = "width: 100px"> 颜色</th>
76
+                        <th style = "width: 200px"> 镜片位置</th>
77
+                        <th style = "width: 150px"> 球镜</th>
78
+                        <th style = "width: 150px"> 柱镜</th>
79
+                        <th style = "width: 150px"> 轴位</th>
80
+                        <th style = "width: 150px"> 通道</th>
81
+                        <th style = "width: 150px"> 下加光</th>
82
+                        <th style = "width: 300px">备注</th>
83
+                        <th style = "width: 150px"> 零售价格</th>
84
+                        <th style = "width: 300px"> 光度范围</th>
85
+                        <th style = "width: 150px"> 光度说明</th>
86
+                        <th style = "width: 150px"> 单眼瞳距</th>
87
+                        <th style = "width: 150px"> 单眼瞳高</th>
88
+                        <th style = "width: 150px"> 镜眼间距</th>
89
+                        <th style = "width: 150px"> 前倾角</th>
90
+                        <th style = "width: 150px"> 镜架面弯</th>
91
+                        <th style = "width: 150px"> 习惯阅读距离</th>
92
+                        <th style = "width: 150px"> 近用瞳距</th>
93
+                        <th style = "width: 150px"> NVB</th>
94
+                        <th style = "width: 75px"> 主视眼</th>
95
+                        <th style = "width: 150px"> ERCD</th>
149 96
                     </tr>
150 97
                     </thead>
151
-
152 98
                     <tbody style="text-align: center">
153
-                    <!-- 动态数据行将在此处添加 -->
154 99
                     </tbody>
155 100
                 </table>
156
-            </div>
157
-
158
-            <!-- 表单操作按钮 -->
159
-            <div class="layui-form-item form-actions">
101
+            </center>
102
+            <div class="layui-form-item">
160 103
                 <div class="layui-input-block">
161
-                    <button type="button"
162
-                            class="layui-btn"
163
-                            lay-submit
164
-                            lay-filter="formDemo"
165
-                            onclick="adddata(); return false;">
166
-                        <i class="layui-icon layui-icon-ok"></i>立即提交
167
-                    </button>
168
-
169
-                    <button type="reset"
170
-                            class="layui-btn layui-btn-primary">
171
-                        <i class="layui-icon layui-icon-refresh"></i>重置
172
-                    </button>
104
+                    <button class="layui-btn" lay-submit lay-filter="formDemo" onclick="adddata(); return false;">立即提交</button>
105
+                    <button type="reset" class="layui-btn layui-btn-primary">重置</button>
173 106
                 </div>
174 107
             </div>
175 108
         </div>
@@ -177,226 +110,234 @@
177 110
 </fieldset>
178 111
 
179 112
 <script>
180
-    layui.use(['form', 'table', 'layer', 'jquery'], function () {
113
+    layui.use('form', function(){
181 114
         var form = layui.form;
182
-        var table = layui.table;
183
-        var $ = layui.$;
184
-        var layer = layui.layer;
185
-
186
-        // 初始化表单
187 115
         form.render();
188
-
189
-        // 加载物料品类数据
116
+    });
117
+    layui.use(['form', 'table', "laydate", 'layer','jquery'], function () {
118
+        var productName=null;
119
+        var material=null;
120
+        var form = layui.form;
121
+        var table = layui.table;
122
+        var $ = layui.$ //重点处
123
+            ,layer = layui.layer;
190 124
         $.ajax({
191 125
             url: 'varietyLists',
192 126
             type: 'get',
193 127
             success: function (data) {
194 128
                 $("#materialType").empty();
195 129
                 $.each($.parseJSON(data), function(idx, obj) {
196
-                    $("#materialType").append("<option value=\"" + obj.varietyId + "\">" + obj.variety + "</option>");
197
-                });
198
-                form.render("select");
199
-            },
200
-            error: function (xhr, status, error) {
130
+                    $("#materialType").append("<option value=\""+obj.varietyId+"\" data-variety=\""+obj.variety+"\">"+obj.variety+"</option>");                });
131
+                layui.form.render("select");
132
+            },error:function (xhr, status, error) {
201 133
                 layer.alert('请求失败: ' + error);
202
-            }
203
-        });
204
-
205
-        // 物料品类选择事件
206
-        form.on('select(materialType)', function(data) {
134
+            }});
135
+        form.on('select(materialType)', function(data){
136
+            var variety = $(data.elem).find("option:selected").text();
207 137
             $.ajax({
208 138
                 url: 'varietyDetailsLists',
209 139
                 type: 'post',
210
-                data: {'id': data.value},
140
+                data:{'variety':variety},
211 141
                 success: function (data) {
212 142
                     $("#brand").empty();
213 143
                     $("#brand").append('<option value="">品牌</option>');
214 144
                     $.each($.parseJSON(data), function(idx, obj) {
215
-                        $("#brand").append("<option value=\"" + obj.id + "\">" + obj.varietyDetails + "</option>");
145
+                        $("#brand").append("<option value=\""+obj.id+"\">"+obj.varietyDetails+"</option>");
216 146
                     });
217
-                    form.render("select");
218
-                },
219
-                error: function (xhr, status, error) {
147
+
148
+                    layui.form.render("select");
149
+                },error:function (xhr, status, error) {
220 150
                     layer.alert('请求失败: ' + error);
221
-                }
222
-            });
151
+                }});
223 152
         });
224
-
225
-        // 品牌选择事件
226
-        form.on('select(brand)', function(data) {
153
+/*        form.on('select(brand)', function(data){
227 154
             $.ajax({
228
-                url: 'productionheader',
155
+                url: 'group',
229 156
                 type: 'post',
230
-                data: {'id': data.value},
157
+                data:{'brand':data.value},
231 158
                 success: function (data) {
232 159
                     $("#materialGroup").empty();
233 160
                     $("#materialGroup").append('<option value="">物料组</option>');
234 161
                     $.each($.parseJSON(data), function(idx, obj) {
235
-                        $("#materialGroup").append("<option value=\"" + obj.materialGroupCode + "\">" + obj.materialGroupName + "</option>");
162
+                        $("#materialGroup").append("<option value=\""+obj.materialGroupCode+"\">"+obj.materialGroupName+"</option>");
236 163
                     });
237
-                    form.render("select");
238
-                },
239
-                error: function (xhr, status, error) {
240
-                    layer.alert('请求失败: ' + error);
241
-                }
242
-            });
243
-        });
244 164
 
245
-        // 物料组选择事件
246
-        form.on('select(materialGroup)', function(data) {
165
+                    layui.form.render("select");
166
+                },error:function (xhr, status, error) {
167
+                    layer.alert('请求失败: ' + error);
168
+                }});
169
+        });*/
170
+        form.on('select(brand)', function(data){
247 171
             $.ajax({
248
-                url: 'price',
172
+                url: 'productionheader',
249 173
                 type: 'post',
250
-                data: {'group': data.value},
174
+                data:{'id':data.value},
251 175
                 success: function (data) {
252
-                    $("#materialdetil").empty();
253
-                    $("#materialdetil").append('<option value="">物料描述</option>');
176
+                    layer.alert('请求失败: ' + data);
177
+                    $("#productName").empty();$("#productCode").empty();$("#varietyDetailId").empty();
178
+
179
+                // $("#productName").append('<option value="">物料描述</option>');
254 180
                     $.each($.parseJSON(data), function(idx, obj) {
255
-                        $("#materialdetil").append("<option value=\"" + obj.materialCode + "\">" + obj.materialName + "</option>");
181
+                        $("#productName").append("<option value=\""+obj.productName+"\" data-variety-detail-id=\""+obj.varietyDetailId+"\">"+obj.productName+"</option>");
182
+                        $("#productCode").append("<option value=\""+obj.productCode+"\" data-variety-detail-id=\""+obj.varietyDetailId+"\">"+obj.productCode+"</option>");
183
+
184
+                        /*$("#productName").append("<option value=\""+obj.productName+"\">"+obj.productName+"</option>");
185
+                        $("#productCode").append("<option value=\""+obj.productCode+"\">"+obj.productCode+"</option>");*/
256 186
                     });
257
-                    form.render("select");
258
-                },
259
-                error: function (xhr, status, error) {
187
+                    layui.form.render("select");
188
+                },error:function (xhr, status, error) {
260 189
                     layer.alert('请求失败: ' + error);
261
-                }
262
-            });
190
+                }});
263 191
         });
264 192
 
265
-        // 物料描述选择事件
266
-        form.on('select(materialdetil)', function(data) {
193
+        form.on('select(materialdetil)', function(data){
267 194
             $.ajax({
268 195
                 url: 'code',
269 196
                 type: 'post',
270
-                data: {'code': data.value},
197
+                data:{'code':data.value},
271 198
                 success: function (data) {
272
-                    $("#materialCode").empty();
273
-                    // 注意:原代码中引用了不存在的 materialRealPrice 元素
199
+                    $("#materialCode").empty();$("#materialdetil").empty();
200
+                    $("#materialRealPrice").empty();
274 201
                     $.each($.parseJSON(data), function(idx, obj) {
275
-                        $("#materialCode").append("<option value=\"" + obj.materialCode + "\">" + obj.materialCode + "</option>");
202
+                        $("#materialCode").append("<option value=\""+obj.materialCode+"\">"+obj.materialCode+"</option>");
203
+                        $("#materialRealPrice").append("<option value=\""+obj.retailPrice+"\">"+obj.retailPrice+"</option>");
276 204
                     });
277
-                    form.render("select");
278
-                },
279
-                error: function (xhr, status, error) {
205
+                    layui.form.render("select");
206
+                },error:function (xhr, status, error) {
280 207
                     layer.alert('请求失败: ' + error);
281
-                }
282
-            });
208
+                }});
283 209
         });
284 210
 
285
-        // 添加表格行
286
-        window.addtable = function() {
287
-            var selectedMaterialCode = $('#materialCode option:selected').text();
288
-            var selectedMaterialDetail = $('#materialdetil option:selected').text();
211
+        //因为动态添加的元素class属性是无效的,所以不能用$('.add').click(function(){});
212
+        window.addtable= function(){
213
+            var selectedVarietyDetailId = $('#productName option:selected').data('variety-detail-id') ||
214
+                $('#productCode option:selected').data('variety-detail-id');
215
+            layer.alert(selectedVarietyDetailId);
216
+            $.ajax({
217
+                url: 'selectColour',
218
+                type: 'post',
219
+                data:{'id':selectedVarietyDetailId},
220
+                success: function (data) {
221
+                    $("#colour").empty();
222
+                    $("#colour").append('<option value="">颜色</option>');
223
+                    $.each($.parseJSON(data), function(idx, obj) {
224
+                        $("#colour").append("<option value=\""+obj.id+"\">"+obj.colour+"</option>");
225
+                    });
289 226
 
290
-            var html = '<tr>' +
291
-                '<td style="width: 100px"><button type="button" class="layui-btn layui-btn-danger layui-btn-xs" onclick="dele(this)">删除</button></td>' +
292
-                '<td style="width:200px">' +
293
-                '<select name="WZ" lay-verify="required">' +
294
-                '<option value="">--请选择--</option>' +
295
-                '<option value="L">L</option>' +
296
-                '<option value="R">R</option>' +
297
-                '</select>' +
298
-                '</td>' +
299
-                '<td style="width:300px">' +
300
-                '<select name="LY" lay-verify="required">' +
301
-                '<option value="">--请选择--</option>' +
302
-                '<option value="C">采购</option>' +
303
-                '<option value="T">退货</option>' +
304
-                '</select>' +
305
-                '</td>' +
306
-                '<td style="width: 200px"><input type="text" name="username" required lay-verify="required" placeholder="用户名字" autocomplete="off" class="layui-input" readonly="true" value="${currentUser.userName!}"/></td>' +
307
-                '<td style="width: 200px"><input type="text" name="materialCode" required lay-verify="required" placeholder="物料编码" autocomplete="off" class="layui-input" readonly="true" value="' + selectedMaterialCode + '"/></td>' +
308
-                '<td style="width: 800px"><input type="text" name="materialDetile" required lay-verify="required" placeholder="物料描述" autocomplete="off" class="layui-input" readonly="true" value="' + selectedMaterialDetail + '"/></td>' +
309
-                '<td style="width: 200px"><input type="text" name="price" required lay-verify="required" placeholder="价格" autocomplete="off" class="layui-input" readonly="true"/></td>' +
310
-                '<td style="width: 100px"><input type="text" name="NUM" required lay-verify="required" placeholder="数量" autocomplete="off" class="layui-input" value="1"/></td>' +
311
-                '<td style="width: 300px"><input type="text" name="SPH" placeholder="球镜" autocomplete="off" class="layui-input"></td>' +
312
-                '<td style="width: 300px"><input type="text" name="CYL" placeholder="柱镜" autocomplete="off" class="layui-input"></td>' +
313
-                '<td style="width: 300px"><input type="text" name="AXIS" placeholder="轴位" autocomplete="off" class="layui-input"></td>' +
314
-                '<td style="width: 300px"><input type="text" name="PDFOD" placeholder="瞳距" autocomplete="off" class="layui-input"></td>' +
315
-                '<td style="width: 300px"><input type="text" name="PH" placeholder="瞳高" autocomplete="off" class="layui-input"></td>' +
316
-                '<td style="width: 300px"><input type="text" name="XADD" placeholder="下加光" autocomplete="off" class="layui-input"></td>' +
317
-                '<td style="width: 300px"><input type="text" name="YULIU1" placeholder="通道" autocomplete="off" class="layui-input"></td>' +
318
-                '<td style="width: 300px"><input type="text" name="PRISM" placeholder="棱镜" autocomplete="off" class="layui-input"></td>' +
319
-                '<td style="width: 300px"><input type="text" name="CVA" placeholder="镜片度数" autocomplete="off" class="layui-input"></td>' +
320
-                '<td style="width: 300px"><input type="text" name="OPTICBC" placeholder="镜片型号/基弧" autocomplete="off" class="layui-input"></td>' +
321
-                '<td style="width: 300px"><input type="text" name="RS" placeholder="是否染色" autocomplete="off" class="layui-input"></td>' +
322
-                '<td style="width: 300px"><input type="text" name="SD" placeholder="色度" autocomplete="off" class="layui-input"></td>' +
323
-                '<td style="width: 300px"><input type="text" name="LRS" placeholder="来板染色" autocomplete="off" class="layui-input"></td>' +
324
-                '<td style="width: 300px"><input type="text" name="CRS" placeholder="厂家色板" autocomplete="off" class="layui-input"></td>' +
325
-                '<td style="width: 300px"><input type="text" name="BRS" placeholder="标准色号" autocomplete="off" class="layui-input"></td>' +
326
-                '<td style="width: 300px"><input type="text" name="MPRO" placeholder="美薄加工" autocomplete="off" class="layui-input"></td>' +
327
-                '<td style="width: 300px"><input type="text" name="LBPO" placeholder="丽薄加工" autocomplete="off" class="layui-input"></td>' +
328
-                '<td style="width: 300px"><input type="text" name="FRAMESHAPE" placeholder="镜架框形" autocomplete="off" class="layui-input"></td>' +
329
-                '<td style="width: 300px"><input type="text" name="FRAMEHEIGHT" placeholder="镜架高度" autocomplete="off" class="layui-input"></td>' +
330
-                '<td style="width: 300px"><input type="text" name="FRAMEBRIDGEWIDTH" placeholder="鼻梁间距" autocomplete="off" class="layui-input"></td>' +
331
-                '<td style="width: 300px"><input type="text" name="SPK" placeholder="水平宽度" autocomplete="off" class="layui-input"></td>' +
332
-                '<td style="width: 300px"><input type="text" name="JFRAMESHAPE" placeholder="加工镜架框形" autocomplete="off" class="layui-input"></td>' +
333
-                '<td style="width: 300px"><input type="text" name="COLOR" placeholder="颜色" autocomplete="off" class="layui-input"></td>' +
334
-                '<td style="width: 300px"><input type="text" name="lEN_DIAMETER" placeholder="直径" autocomplete="off" class="layui-input"></td>' +
335
-                '<td style="width: 300px"><input type="text" name="PX" placeholder="片型" autocomplete="off" class="layui-input"></td>' +
336
-                '<td style="width: 300px"><input type="text" name="PS" placeholder="片色" autocomplete="off" class="layui-input"></td>' +
337
-                '<td style="width: 300px"><input type="text" name="MARK" placeholder="备注" autocomplete="off" class="layui-input"></td>' +
338
-                '</tr>';
227
+                    layui.form.render("select");
228
+                },error:function (xhr, status, error) {
229
+                    layer.alert('请求失败: ' + error);
230
+                }});
231
+            $.ajax({
232
+                url: 'productionheader',
233
+                type: 'post',
234
+                data:{'id':selectedVarietyDetailId},
235
+                success: function (data) {
236
+                    layer.alert('请求失败: ' + data);
237
+                    $("#productName").empty();$("#productCode").empty();$("#varietyDetailId").empty();
238
+
239
+                    $.each($.parseJSON(data), function(idx, obj) {
240
+                        $("#productName").append("<option value=\""+obj.productName+"\" data-variety-detail-id=\""+obj.varietyDetailId+"\">"+obj.productName+"</option>");
241
+                        $("#productCode").append("<option value=\""+obj.productCode+"\" data-variety-detail-id=\""+obj.varietyDetailId+"\">"+obj.productCode+"</option>");
339 242
 
243
+                    });
244
+                    layui.form.render("select");
245
+                },error:function (xhr, status, error) {
246
+                    layer.alert('请求失败: ' + error);
247
+                }});
248
+            var html = '<tr>'+
249
+                '<td style = "width: 100px"><input type="button" class="layui-btn layui-btn-radius" onclick="dele(this)" value="删除" /></td>'+
250
+                '<td style = "width: 200px"> <input type="text" name="materialCode" required lay-verify="required"   placeholder="物料编码" autocomplete="off" class="layui-input"  readonly="true" value="'+ $('#productCode option:selected').text()+'"/></td>'+
251
+                '<td style = "width: 500px"> <input type="text" name="materialDetile"  required lay-verify="required"  placeholder="物料描述" autocomplete="off" class="layui-input"  readonly="true" value="'+$('#productName option:selected').text()+'"/></td>'+
252
+                '<td style = "width: 100px">' +
253
+                '<select name="colour" id ="colour" class="county-selector"  placeholder="颜色" lay-filter="productName">'+
254
+                '</select></td>'+
255
+                '<td style="width:200px">'+
256
+                '<select name="WZ" lay-verify="required">'+
257
+                '<option value="">--请选择--</option>'+
258
+                '<option value="L">L</option>'+
259
+                '<option value="R">R</option>'+
260
+                '</select></td>'+
261
+                '<td style = "width: 150px"> <input type="text" name="SPH"    placeholder="球镜" autocomplete="off" class="layui-input"></td>'+
262
+                '<td style = "width: 150px"> <input type="text" name="CYL"    placeholder="柱镜" autocomplete="off" class="layui-input"></td>'+
263
+                '<td style = "width: 150px"> <input type="text" name="AXIS"    placeholder="轴位" autocomplete="off" class="layui-input"></td>'+
264
+                '<td style = "width: 150"> <input type="text" name="YULIU1"    placeholder="通道" autocomplete="off" class="layui-input"></td>'+
265
+                '<td style = "width: 150px"> <input type="text" name="XADD"    placeholder="下加光" autocomplete="off" class="layui-input"></td>'+
266
+                '<td style = "width: 300px"> <input type="text" name="MARK"    placeholder="备注" autocomplete="off" class="layui-input"></td>'+
267
+                '<td style = "width: 150px"> <input type="text" name="NUM" required lay-verify="required"   placeholder="零售价" autocomplete="off" class="layui-input" /></td>'+
268
+                '<td style = "width: 300px"> <input type="text" name="CVA"    placeholder="光度范围" autocomplete="off" class="layui-input"></td>'+
269
+                '<td style = "width: 150px"> <input type="text" name="SD"    placeholder="光度说明" autocomplete="off" class="layui-input"></td>'+
270
+                '<td style = "width: 150px"> <input type="text" name="PDFOD"    placeholder="单眼瞳距" autocomplete="off" class="layui-input"></td>'+
271
+                '<td style = "width: 150px"> <input type="text" name="PH"    placeholder="单眼瞳高" autocomplete="off" class="layui-input"></td>'+
272
+                '<td style = "width: 150px"> <input type="text" name="FRAMEBRIDGEWIDTH"    placeholder="镜眼距离" autocomplete="off" class="layui-input"></td>'+
273
+                '<td style = "width: 150px"> <input type="text" name="OPTICBC"    placeholder="前倾角" autocomplete="off" class="layui-input"></td>'+
274
+                '<td style = "width: 150px"> <input type="text" name="FRAMESHAPE"    placeholder="镜架面弯" autocomplete="off" class="layui-input"></td>'+
275
+                '<td style = "width: 150px"> <input type="text" name="FRAMEHEIGHT"    placeholder="习惯阅读距离" autocomplete="off" class="layui-input"></td>'+
276
+                '<td style = "width: 150px"> <input type="text" name="PRISM"    placeholder="近用瞳距" autocomplete="off" class="layui-input"></td>'+
277
+                '<td style = "width: 150px"> <input type="text" name="RS"    placeholder="NVB" autocomplete="off" class="layui-input"></td>'+
278
+                '<td style = "width: 75px"> <input type="text" name="LRS"    placeholder="主视眼" autocomplete="off" class="layui-input"></td>'+
279
+                '<td style = "width: 150px"> <input type="text" name="CRS"    placeholder="ERCD" autocomplete="off" class="layui-input"></td>'+
280
+
281
+                '</tr>';
282
+            //添加到表格最后
340 283
             $(html).appendTo($('#table tbody:last'));
341 284
             form.render();
342
-        };
343
-
344
-        // 删除表格行
345
-        window.dele = function (obj) {
285
+        }
286
+        window.dele= function (obj){
287
+            debugger;
346 288
             var otr = obj.parentNode.parentNode;
347
-            var tab = otr.parentNode;
289
+//			var tab = document.getElementById("tab");
290
+//			tab.deleteRow(otr.rowIndex)
291
+            var tab =  otr.parentNode; //自己的父节点 就是table
348 292
             tab.removeChild(otr);
293
+        }
294
+        window.deltable= function() {
295
+            if ($('#table tbody tr').length === 1) {
296
+                layer.msg('只有一条不允许删除。', {
297
+                    time : 2000
298
+                });
299
+            } else {
300
+                //删除当前按钮所在的tr
301
+                $(this).closest('tr').remove();
302
+            }
349 303
         };
350
-
351
-        // 提交数据
352
-        window.adddata = function() {
353
-            var tableElement = document.getElementById("table");
354
-            var trElements = tableElement.getElementsByTagName("tr");
355
-            var dataArray = [];
356
-
357
-            for (var i = 0; i < trElements.length; i++) {
358
-                var targetElements = trElements[i].querySelectorAll("[name]");
359
-                var dataObject = {};
360
-
361
-                for (var j = 0; j < targetElements.length; j++) {
362
-                    if (targetElements[j].value) {
363
-                        dataObject[targetElements[j].getAttribute("name")] = targetElements[j].value;
364
-                    } else {
365
-                        dataObject[targetElements[j].getAttribute("name")] = targetElements[j].getAttribute("value");
304
+        window.adddata= function() {
305
+            table=document.getElementById("table");
306
+            let tr=table.getElementsByTagName("tr");
307
+            var arrayObj = new Array();
308
+            for (var i=0; i<tr.length; i++){
309
+                let target=tr[i].querySelectorAll("[name]"),obj={};
310
+                for (var j=0; j<target.length; j++){
311
+                    if(target[j].value){
312
+                        obj[target[j].getAttribute("name")]=target[j].value;
313
+                    }else{
314
+                        obj[target[j].getAttribute("name")]=target[j].getAttribute("value");
366 315
                     }
367 316
                 }
368
-
369
-                // 只有包含数据的对象才添加到数组中
370
-                if (Object.keys(dataObject).length > 0) {
371
-                    dataArray.push(dataObject);
372
-                }
317
+                arrayObj.push(obj);
373 318
             }
374
-
375
-            var jsonData = JSON.stringify(dataArray);
376
-            jsonData = jsonData.replace(/[+]/g, '+');
377
-
319
+            var json=JSON.stringify(arrayObj);
320
+            json = json.replace(/[+]/g, '+');
378 321
             $.ajax({
379 322
                 url: 'insert',
380 323
                 type: 'post',
381
-                data: "list=" + jsonData,
324
+                data: "list="+json,
382 325
                 async: false,
383 326
                 dataType: "json",
384 327
                 success: function (data) {
385 328
                     layer.msg('提交成功!', {
386
-                        time: 3000
329
+                        time : 5000
387 330
                     });
388
-                },
389
-                error: function (xhr, status, error) {
331
+                }, error: function (xhr, status, error) {
390 332
                     layer.alert('请求失败: ' + error);
391 333
                 }
392 334
             });
393
-        };
394
-
395
-        // 表单提交事件
335
+        }
396 336
         form.on('submit(login)', function (data) {
397
-            // 可以在这里处理表单提交逻辑
337
+            //alert(data.value);
398 338
         });
399 339
     });
340
+
400 341
 </script>
401 342
 
402 343
 </body>