Forráskód Böngészése

Merge branch 'master' of http://192.168.57.38:3000/wenhongquan/VisualInspection

# Conflicts:
#	VisualInspection_server/src/main/resources/application.properties
温红权 9 éve
szülő
commit
1d52a8c7e5

+ 4 - 4
VisualInspection/js/config.js

@@ -1,6 +1,6 @@
-// var base_ui_url = "http://localhost:8080/";
-// var base_server_url = "http://localhost:8089/";
+var base_ui_url = "http://localhost:8080/";
+var base_server_url = "http://localhost:8089/";
 
 
-var base_ui_url = "http://192.168.31.233:8080/";
-var base_server_url = "http://192.168.31.233:8089/";
+// var base_ui_url = "http://192.168.31.233:8080/";
+// var base_server_url = "http://192.168.31.233:8089/";

+ 120 - 0
VisualInspection/js/constant/constant.js

@@ -0,0 +1,120 @@
+var page_size=10;
+var p_cur = 1; //页号
+var p_pages; //总页码
+var p_totalRecords;
+function queryConstant(){
+    p_cur = 1;
+    getConstant();
+}
+function getConstant(){
+    var data = {
+        "flag_name": $("#keywords").val()
+    }
+    getConstantList("/constant/getConstantByName/"+p_cur+"/"+page_size, data, function(data) {
+        p_pages=data.pages;
+        p_totalRecords=data.total;
+        updateTable(data.list);
+        pager();
+    }, function(error) {
+        alert(error);
+    });
+}
+
+function updateTable(tableData){
+    var cols = [
+                {width: 80, text: '序号', type: 'number', flex: false, field: 'num'},
+                {width: 80, text: '代码编号', type: 'date', flex: false, field: 'code_flag'},
+                {width: 80, text: '代码名称', type: 'string', flex: true, field: 'code_name'},
+                {width: 80, text: '有效标志', type: 'date', flex: false, field: 'valid'},
+                {width: 80, text: '代码标识', type: 'string', flex: true, field: 'code_flag'},
+                {width: 160, text: '标识名称', type: 'date', flex: false, field: 'flag_name'},
+                {width: 80, text: '备注', type: 'string', flex: true, field: 'remark'},
+                {width: 160, text: '操作', type: 'string', flex: true, field: 'id'}
+            ];
+    var rowData = formatTableData(tableData, cols);
+    clearTable(cols);
+    // 使用data参数更新数据:
+    $('.datatable').datatable('load',  {
+            cols: cols,
+            rows:rowData
+            // [
+            //     {checked: false, data: [1, '1','上行','1','DIRECTION','方向','未稽查','<a href="#" data-toggle="modal" data-target="#myModal"><i class="icon icon-edit"></i> 修改</a><a href="#"><i class="icon icon-remove-circle"></i> 删除</a>']},
+            //     {checked: false, data: [2, '2','下行','1','DIRECTION','方向','未稽查','<a href="#" data-toggle="modal" data-target="#myModal"><i class="icon icon-edit"></i> 修改</a><a href="#"><i class="icon icon-remove-circle"></i> 删除</a>']},
+            //     // 更多数据
+            // ]
+        }
+    );
+}
+function clearTable(cols){
+     $('.datatable').datatable( {
+        checkable:false,
+        sortable:false,
+        data: {
+            cols: cols,
+            rows:[]
+        }
+    });
+}
+function formatTableData(data,cols){
+    var rows = [];
+    // rows.push({checked: false, data: [1, '1','上行','1','DIRECTION','方向','未稽查','<a href="#" data-toggle="modal" data-target="#myModal"><i class="icon icon-edit"></i> 修改</a><a href="#"><i class="icon icon-remove-circle"></i> 删除</a>']});
+    for(var i=0;i<data.length;i++){
+        data[i].num=(p_cur-1)*10+i+1;
+        rows.push(genRow(data[i],cols));
+    }
+    return rows;
+}
+
+function genRow(obj,cols){
+    var row = {checked: false, data:null};
+    var dArr=[];
+    for(var i=0;i<cols.length;i++){
+        if(cols[i].text=='操作') {
+            var str='<a href="#" data-toggle="modal" onclick="editConstant('+obj[cols[i].field]+')"><i class="icon icon-edit"></i> 修改</a><a href="#" onclick="deleteConstant('+obj[cols[i].field]+')"><i class="icon icon-remove-circle"></i> 删除</a>';
+            dArr.push(str);
+        }else{
+            dArr.push(obj[cols[i].field]);
+        }
+    }
+    row.data=dArr;
+    return row;
+}
+function pager(){
+  
+    kkpager.generPageHtml({
+        pno : p_cur,
+        total : p_pages,
+        totalRecords : p_totalRecords,
+        mode : 'click',
+        click : function(n){
+            p_cur = n;
+            this.selectPage(p_cur);
+            getConstant();//调用获取数据方法
+            return false;
+        }
+    },true);
+}   
+
+function addConstant(){
+    var valid=1;
+    if(!$("#valid").is(':checked')) valid=0;
+    var param ={
+        'code_flag':$('#code_flag').val(),
+        'flag_name':$('#flag_name').val(),
+        'code_value':Number($('#code_value').val()),
+        'code_name':$('#code_name').val(),
+        'sort_no':Number($('#sort_no').val()),
+        'remark':$('#remark').val(),
+        'valid':valid
+    };
+    addConstant_service("/constant/add/", param, function(data) {
+        alert(data);
+        $('#addModal').modal('toggle');
+    }, function(error) {
+        alert(error);
+    });
+}
+
+function editConstant(id){
+
+}

+ 28 - 0
VisualInspection/js/util/service.js

@@ -42,4 +42,32 @@ function DeptGetAll(success, fail) {
     }, function(error) {
         fail("网络错误");
     });
+}
+
+function getConstantList(url, param, success, fail) {   
+    var url = base_server_url + url;
+    ajaxPost(url, param, function(response) {
+        var data = response;
+        if (data.result_code == 0) {
+            success(data.result_data)
+        } else {
+            fail(data.result_desc);
+        }
+    }, function(error) {
+        fail("网络错误");
+    });
+}
+
+function addConstant_service(url, param, success, fail) {   
+    var url = base_server_url + url;
+    ajaxPost(url, param, function(response) {
+        var data = response;
+        if (data.result_code == 0) {
+            success(data.result_desc)
+        } else {
+            fail(data.result_desc);
+        }
+    }, function(error) {
+        fail("网络错误");
+    });
 }

+ 2 - 1
VisualInspection/view/common/commoncsslink.html

@@ -3,4 +3,5 @@
 <link href="/node_modules/sweetalert/dist/sweetalert.css" rel="stylesheet">
 <link rel="stylesheet" href="/node_modules/ztree/css/zTreeStyle/zTreeStyle.css" type="text/css">
 <link rel="stylesheet" type="text/css" href="/css/common/header.css">
-<link rel="stylesheet" type="text/css" href="/css/common/foot.css">
+<link rel="stylesheet" type="text/css" href="/css/common/foot.css">
+<link rel="stylesheet" type="text/css" href="/js/lib/kkpager_green.css">

+ 2 - 0
VisualInspection/view/common/commonscriptlink.html

@@ -11,8 +11,10 @@
 <script src="/node_modules/hashmap/hashmap.js"></script>
 <script src="/node_modules/sweetalert/dist/sweetalert.min.js"></script>
 <script src="/node_modules/ztree/js/jquery.ztree.all.min.js"></script>
+<script src="/js/lib/kkpager.min.js"></script>
 <script src="/js/util/util.js"></script>
 <script src="/js/util/service.js"></script>
+<script src="/js/constant/constant.js"></script>  
 
 
 <script type="text/javascript">

+ 8 - 8
VisualInspection/view/constant/add.html

@@ -3,51 +3,51 @@
             <div class="form-group">
                 <label for="exampleInputAccount4" class="col-sm-2">字典标识</label>
                 <div class="col-md-6 col-sm-10">
-                <input type="text" class="form-control" id="flag_name" placeholder="字典标识">
+                <input type="text" class="form-control" id="code_flag" placeholder="字典标识">
                 </div>
             </div>
             <div class="form-group">
                 <label for="exampleInputPassword4" class="col-sm-2">标识名称</label>
                 <div class="col-md-6 col-sm-10">
-                <input type="text" class="form-control" id="exampleInputPassword4" placeholder="标识名称">
+                <input type="text" class="form-control" id="flag_name" placeholder="标识名称">
                 </div>
             </div>
             <div class="form-group">
                 <label for="exampleInputPassword4" class="col-sm-2">字典值</label>
                 <div class="col-md-6 col-sm-10">
-                <input type="text" class="form-control" id="exampleInputPassword4" placeholder="字典值">
+                <input type="text" class="form-control" id="code_value" placeholder="字典值">
                 </div>
             </div>
             <div class="form-group">
                 <label for="exampleInputPassword4" class="col-sm-2">字典名称</label>
                 <div class="col-md-6 col-sm-10">
-                <input type="text" class="form-control" id="exampleInputPassword4" placeholder="字典名称">
+                <input type="text" class="form-control" id="code_name" placeholder="字典名称">
                 </div>
             </div>
             <div class="form-group">
                 <label for="exampleInputPassword4" class="col-sm-2">排序号</label>
                 <div class="col-md-6 col-sm-10">
-                <input type="text" class="form-control" id="exampleInputPassword4" placeholder="排序号">
+                <input type="text" class="form-control" id="sort_no" placeholder="排序号">
                 </div>
             </div>
              <div class="form-group">
                 <label for="exampleInputPassword4" class="col-sm-2">备注</label>
                 <div class="col-md-6 col-sm-10">
-                <input type="text" class="form-control" id="exampleInputPassword4" placeholder="标识名称">
+                <input type="text" class="form-control" id="remark" placeholder="标识名称">
                 </div>
             </div>
             <div class="form-group">
                 <div class="col-sm-offset-2 col-sm-10">
                 <div class="checkbox">
                     <label>
-                    <input type="checkbox">有效
+                    <input type="checkbox" id="valid" checked="checked">有效
                     </label>
                 </div>
                 </div>
             </div>
             <div class="form-group">
                 <div class="col-sm-offset-2 col-sm-10">
-                <button type="submit" class="btn btn-default">保存</button>
+                <button type="button" class="btn btn-default" onclick="addConstant()">保存</button>
                 </div>
             </div>
             </form>

+ 37 - 109
VisualInspection/view/constant/constant.html

@@ -1,122 +1,50 @@
-<div class="container-fluid ">
-    <div class="row">
-        <div class="col-xs-3">
-            <div class="input-group">
-                <span class="input-group-addon">关键词</span>
-                <input class="form-control form-focus" autofocus type="text" placeholder="请输入关键词">
+ 
+<!--<script src="/js/constant/constant.js"></script>   -->
+    <div class="container-fluid ">
+        <div class="row">
+            <div class="col-xs-3">
+                <div class="input-group">
+                    <span class="input-group-addon">关键词</span>
+                    <input class="form-control form-focus" id="keywords" autofocus type="text" placeholder="请输入关键词">
+                </div>
+            </div>
+            
+            <div class="col-xs-3">
+                 <div class="input-group">
+                    <button class="btn btn-primary " type="button" onclick="queryConstant()">查询</button>
+                 </div>
+            </div>
+            <div style="float:right;">
+                <button class="btn btn-success" type="button" data-toggle="modal" data-target="#addModal"><i class="icon icon-plus-sign"></i> 添加</button>
             </div>
         </div>
+        <br>
 
-        <div class="col-xs-3">
-            <div class="input-group">
-                <button class="btn btn-primary " type="button">查询</button>
-            </div>
+        <div class="row">
+             <!-- 使用一个div来显示数据表格 -->
+            <div class="datatable" data-checkable="true" data-sortable="true"></div 
         </div>
-        <div style="float:right;">
-            <button class="btn btn-success" type="button" data-toggle="modal" data-target="#myModal"><i class="icon icon-plus-sign"></i> 添加</button>
+        <div id="kkpager" class="row" style="text-align:center">
+            
         </div>
     </div>
-    <br>
-
-    <div class="row">
-        <!-- 使用一个div来显示数据表格 -->
-        <div class="datatable" data-checkable="true" data-sortable="true"></div>
+    <!-- 对话框HTML -->
+    <div class="modal fade" id="addModal">
+    <div class="modal-dialog">
+    <div class="modal-content">
+      <div class="modal-header">
+        <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span class="sr-only">关闭</span></button>
+        <h4 class="modal-title">添加常量</h4>
+      </div>
+      <div class="modal-body">
+        <link rel="import" href="/view/constant/add.html?__inline">
+      </div>
     </div>
-    <div class="row" style="text-align:center">
-        <ul class="pager center-block">
-            <li class="previous"><a href="#">« 上一页</a></li>
-            <li><a href="#">1</a></li>
-            <li class="active"><a href="#">2</a></li>
-            <li><a href="#">3</a></li>
-            <li><a href="#">4</a></li>
-            <li><a href="#">5</a></li>
-            <li class="next"><a href="#">下一页 »</a></li>
-        </ul>
     </div>
-</div>
-<!-- 对话框HTML -->
-<div class="modal fade" id="myModal">
-    <div class="modal-dialog">
-        <div class="modal-content">
-
-        </div>
-        <div class="modal-content">
-            <div class="modal-header">
-                <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span class="sr-only">关闭</span></button>
-                <h4 class="modal-title">添加常量</h4>
-            </div>
-            <div class="modal-body">
-                <link rel="import" href="/view/constant/add.html?__inline">
-            </div>
-        </div>
     </div>
-</div>
+
 <script>
     $(document).ready(function() {
-        // 使用data参数更新数据:
-        $('.datatable').datatable({
-            checkable: false,
-            sortable: false,
-            data: {
-                cols: [{
-                    width: 80,
-                    text: '序号',
-                    type: 'number',
-                    flex: false,
-                    colClass: 'text-center'
-                }, {
-                    width: 80,
-                    text: '代码编号',
-                    type: 'date',
-                    flex: false,
-                    sort: 'down'
-                }, {
-                    width: 80,
-                    text: '代码名称',
-                    type: 'string',
-                    flex: true,
-                    colClass: ''
-                }, {
-                    width: 80,
-                    text: '有效标志',
-                    type: 'date',
-                    flex: false,
-                    sort: 'down'
-                }, {
-                    width: 80,
-                    text: '代码标识',
-                    type: 'string',
-                    flex: true,
-                    colClass: ''
-                }, {
-                    width: 160,
-                    text: '标识名称',
-                    type: 'date',
-                    flex: false,
-                    sort: 'down'
-                }, {
-                    width: 80,
-                    text: '备注',
-                    type: 'string',
-                    flex: true,
-                    colClass: ''
-                }, {
-                    width: 160,
-                    text: '操作',
-                    type: 'string',
-                    flex: true,
-                    colClass: ''
-                }],
-                rows: [{
-                        checked: false,
-                        data: [1, '1', '上行', '1', 'DIRECTION', '方向', '未稽查', '<a href="#" data-toggle="modal" data-target="#myModal"><i class="icon icon-edit"></i> 修改</a><a href="#"><i class="icon icon-remove-circle"></i> 删除</a>']
-                    }, {
-                        checked: false,
-                        data: [2, '2', '下行', '1', 'DIRECTION', '方向', '未稽查', '<a href="#" data-toggle="modal" data-target="#myModal"><i class="icon icon-edit"></i> 修改</a><a href="#"><i class="icon icon-remove-circle"></i> 删除</a>']
-                    },
-                    // 更多数据
-                ]
-            }
-        });
+        getConstant();
     });
 </script>

+ 98 - 0
VisualInspection/view/constant/util.js

@@ -0,0 +1,98 @@
+function doajax(method, dataurl, data, sucessCallBack, errorCallBack) {
+    var user_key = undefined;
+    var user = $.zui.store.get("user")
+    if (typeof(user) == "undefined" || user == null) {
+
+    } else {
+        user_key = "XinTong " + (user.token);
+    }
+    if (typeof(user_key) == "undefined" || user_key == null) {
+        $.ajax({
+            type: method,
+            url: dataurl,
+            contentType: "application/json",
+            dataType: "json",
+            async: true,
+            data: JSON.stringify(data),
+            success: sucessCallBack,
+            error: function(error) {
+                if (HandleError(error)) return;
+                errorCallBack(error);
+            }
+        })
+    } else {
+
+        $.ajax({
+            type: method,
+            url: dataurl,
+            contentType: "application/json",
+            dataType: "json",
+            beforeSend: function(xhr) {
+                xhr.setRequestHeader("token", user_key);
+            },
+            headers: {
+                'token': user_key
+            },
+            async: true,
+            data: JSON.stringify(data),
+            success: sucessCallBack,
+            error: function(error) {
+                if (HandleError(error)) return;
+                errorCallBack(error);
+            }
+        })
+    }
+
+}
+
+function ajaxGet(dataurl, data, sucessCallBack, errorCallBack) {
+
+    doajax("GET", dataurl, data, sucessCallBack, errorCallBack)
+}
+
+function ajaxPost(dataurl, data, sucessCallBack, errorCallBack) {
+
+    doajax("POST", dataurl, data, sucessCallBack, errorCallBack)
+
+}
+
+function ajaxPut(dataurl, data, sucessCallBack, errorCallBack) {
+
+    doajax("PUT", dataurl, data, sucessCallBack, errorCallBack)
+}
+
+function ajaxDelete(dataurl, data, sucessCallBack, errorCallBack) {
+
+    doajax("DELETE", dataurl, data, sucessCallBack, errorCallBack)
+
+}
+
+
+function HandleError(error) {
+    if (typeof(error) != "undefined" && error != null) {
+        if (typeof(error.status) != "undefined" && error.status != null) {
+            if (error.status == 403) {
+                //未登录退出
+                swal({
+                    title: "提示",
+                    text: "登陆已经过期,将重新登陆!",
+                    timer: 3000,
+                    showConfirmButton: false
+                }, function() {
+
+                    self.location = base_ui_url + UI_USER_LOGIN
+                });
+                return true;
+            }
+        }
+    }
+    return false;
+}
+
+
+// var ViewMap = new HashMap()
+// ViewMap.set("/view/mytask/unchecked.html", __inline('/view/mytask/unchecked.html'));
+// ViewMap.set("/view/mytask/unexamined.html", __inline('/view/mytask/unexamined.html'));
+// ViewMap.set("/view/mytask/undispatched.html", __inline('/view/mytask/undispatched.html'));
+// ViewMap.set("/view/mytask/dispatched.html", __inline('/view/mytask/dispatched.html'));
+// ViewMap.set("/view/constant/constant.html", __inline('/view/constant/constant.html'));

+ 3 - 1
VisualInspection_server/src/main/java/com/xintong/visualinspection/bean/Constant.java

@@ -1,4 +1,6 @@
 package com.xintong.visualinspection.bean;
+import javax.validation.constraints.NotNull;
+
 import org.hibernate.validator.constraints.NotEmpty;
 
 import lombok.Data;
@@ -25,7 +27,7 @@ public class Constant{
 	
 	private static final long serialVersionUID = -7765958097423155178L;
 	private Long id;
-	@NotEmpty(message="字典值不能为空")
+	@NotNull(message="字典值不能为空")
 	private Integer code_value;
 	@NotEmpty(message="字典名称不能为空")
 	private String code_name;

+ 14 - 5
VisualInspection_server/src/main/java/com/xintong/visualinspection/controller/ConstantController.java

@@ -5,13 +5,17 @@ import java.util.List;
 import javax.validation.Valid;
 
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.PathVariable;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
+import com.github.pagehelper.PageHelper;
+import com.github.pagehelper.PageInfo;
 import com.mysql.jdbc.StringUtils;
 import com.xintong.system.err.BusinessException;
 import com.xintong.visualinspection.bean.Constant;
+import com.xintong.visualinspection.bean.User;
 import com.xintong.visualinspection.service.ConstantService;
 
 /**
@@ -35,6 +39,7 @@ public class ConstantController extends BaseController {
      */
     @RequestMapping(value = "/add")
     public String add(@Valid @RequestBody Constant constant){
+    	if(constant.getValid()==1) constant.setValid(1);
     	constantService.insert(constant);
     	return super.returnSuccessResult("添加成功");
     }
@@ -111,12 +116,16 @@ public class ConstantController extends BaseController {
      * @exception
      * @since  1.0.0
      */
-    @RequestMapping(value = "/getConstantByName")
-    public String getConstantByName(@RequestBody Constant constant){
+    @RequestMapping(value = "/getConstantByName/{page}/{size}")
+    public String getConstantByName(@PathVariable Integer page,@PathVariable Integer size, @RequestBody Constant constant){
+    	PageHelper.startPage(page, size); 
+    	List<Constant> constantList;
     	if(StringUtils.isNullOrEmpty(constant.getFlag_name())){
-    		throw new BusinessException(20103);
+//    		throw new BusinessException(20103);
+    		constantList = constantService.getAll();
+    	}else{
+    		constantList = constantService.getByName(constant.getFlag_name());
     	}
-    	List<Constant> constantList = constantService.getByName(constant.getFlag_name());
-    	return super.returnSuccessResult(constantList);
+    	return super.returnSuccessResult(new PageInfo(constantList));
     }
 }

+ 2 - 2
VisualInspection_server/src/main/java/com/xintong/visualinspection/mapper/master/ConstantMapper.xml

@@ -34,8 +34,8 @@
      <select id="getByName" parameterType="String" resultMap="BaseResultMap" >
         SELECT *
         FROM sys_code
-        WHERE flag_name like CONCAT('%',#{flag_name},'%') 
-          and valid!=0
+        WHERE valid!=0
+        	and flag_name like CONCAT('%',#{flag_name},'%')
     </select>
     
     <select id="getByFlagAndValue" parameterType="com.xintong.visualinspection.bean.Constant" resultMap="BaseResultMap" >