1
13693261870
2022-09-16 762f2fb45db004618ba099aa3c0bd89dba1eb843
1
2
3
4
5
6
7
8
9
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
//作废
//$(function () {
//    $("#jqGrid").jqGrid({
//        url: restServerBaseURL + 'org/userunit/list',
//        datatype: "json",
//        colModel: [            
//            { label: 'userid', name: 'userid', index: 'USERID', width: 50, key: true },
//            { label: '单位ID', name: 'unitid', index: 'UNITID', width: 80 },             
//            { label: '记录排序', name: 'rorder', index: 'RORDER', width: 80 },             
//            { label: '职务名称', name: 'posname', index: 'POSNAME', width: 80 },             
//            { label: '从事本职工作时间', name: 'workseasdate', index: 'WORKSEASDATE', width: 80 },             
//            { label: '在职情况1 表示在职、3 表示借调、5 表示离职', name: 'worktype', index: 'WORKTYPE', width: 80 },             
//            { label: '到职日期', name: 'workstartdate', index: 'WORKSTARTDATE', width: 80 },             
//            { label: '离职日期', name: 'workenddate', index: 'WORKENDDATE', width: 80 },             
//            { label: '记录添加人中文名', name: 'rcreateuser', index: 'RCREATEUSER', width: 80 },             
//            { label: '记录添加时间', name: 'rcreatedate', index: 'RCREATEDATE', width: 80 },             
//            { label: '记录修改时间戳', name: 'rlasteditdate', index: 'RLASTEDITDATE', width: 80 }            
//        ],
//        viewrecords: true,
//        height: "100%",
//        rowNum: 10,
//        rowList : [10,30,50],
//        rownumbers: true, 
//        rownumWidth: 25, 
//        autowidth:true,
//        multiselect: true,
//        pager: "#jqGridPager",
//        jsonReader : {
//            root: "page.list",
//            page: "page.currPage",
//            total: "page.totalPage",
//            records: "page.totalCount"
//        },
//        prmNames : {
//            page:"page", 
//            rows:"limit", 
//            order: "order"
//        },
//        gridComplete:function(){
//            //隐藏grid底部滚动条
//            $("#jqGrid").closest(".ui-jqgrid-bdiv").css({ "overflow-x" : "hidden" }); 
//        }
//    });
//});
 
var local = window.location.href;
var userid = local.substring(local.lastIndexOf('=')+1,local.length);
 
var vm = new Vue({
    el:'#rapp',
    data:{
        showList: false,
        title: null,
        userunit: {userid:userid}
    },
    methods: {
        query: function () {
            vm.reload();
        },
        add: function(){
            vm.showList = false;
            vm.title = "新增";
            vm.userunit = {};
        },
        update: function () {
            var userid = getSelectedRow();
            if(userid == null){
                return ;
            }
            vm.showList = true;
            vm.title = "修改";
            
            vm.getInfo(userid)
        },
        saveOrUpdate: function () {
            //var url = vm.title == "新增" ? "org/userunit/save" : "org/userunit/update";
            vm.userunit.unitid = $("#unitid").val();
            var url = "org/userunit/save";
            $.ajax({
                type: "POST",
                url: restServerBaseURL + url,
                contentType: "application/json",
                data: JSON.stringify(vm.userunit),
                success: function(r){
                    if(r.code === 0){
                        alert('操作成功', function(){
                            //vm.reload();
                            window.location.href='user.html';
                        });
                    }else{
                        alert(r.msg);
                    }
                }
            });
        },
        del: function () {
            var userids = getSelectedRows();
            if(userids == null){
                return ;
            }
            
            confirm('确定要删除选中的记录?', function(){
                $.ajax({
                    type: "POST",
                    url: restServerBaseURL + "org/userunit/delete",
                    contentType: "application/json",
                    data: JSON.stringify(userids),
                    success: function(r){
                        if(r.code == 0){
                            alert('操作成功', function(){
                                vm.reload();
                            });
                        }else{
                            alert(r.msg);
                        }
                    }
                });
            });
        },
        getInfo: function(userid){
            $.get(restServerBaseURL + "org/userunit/info/"+userid, function(r){
                vm.userunit = r.userunit;
            });
        },
        reload: function () {
            vm.showList = true;
            var page = $("#jqGrid").jqGrid('getGridParam','page');
            $("#jqGrid").jqGrid('setGridParam',{
                postData:{'unitid':vm.userunit.unitid},
                page:page
            }).trigger("reloadGrid");
        },
        refresh: function () {
            vm.showList = true;
            window.location.reload();
        }
    }
    
});
function findUnitNamesByKeyWord(){
    var unitNames = $("#unitNames").val();
    
    $("#unitNames").autocomplete({
        source:function(request,response){
//            var url= restServerBaseURL + 'org/userunit/findUnitNamesByKeyWord?keyWord='+unitNames;  //请求的url
            $.ajax({
                type:"GET",
                url:restServerBaseURL + 'org/userunit/findUnitNamesByKeyWord/'+unitNames,
//                dataType:'json',
                success:function(data){
                    response($.map(data,function(item){
                        return {label:item.name,
                            value:item.name,
                            id:item.id
                        } 
                    }))
                }
            });
        },
        select:function(event,ui){
            $(this).val(ui.item.value);
            $("#unitid").val(ui.item.id);
            event.preventDefault();
        },
 
        minLength: 1,
    });
}