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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
$(function () {
    var ref = window.location.href;
    var key = ref.substring(ref.lastIndexOf('=') + 1, ref.length);
    $("#jqGrid").jqGrid({
        url: restServerBaseURL + 'sys/fieldvalue/list?fkey=' + key,
        datatype: "json",
        colModel: [
            { label: 'valueid', name: 'valueid', index: 'VALUEID', width: 50, key: true, hidden: true },
            { label: '应用字段key', name: 'fkey', index: 'FKEY', width: 80,align:'center' },
            { label: '代码', name: 'vcode', index: 'VCODE', width: 80,align:'center' },
            { label: '字段值', name: 'vtext', index: 'VTEXT', width: 80,align:'center' },
            { label: '字段说明', name: 'remark', index: 'REMARK', width: 80,align:'center',sortable:false },
            { label: '操作', width: 50,sortable:false,align:'center',
                formatter: function (value, grid, rows, state) {
                    var valueid = rows.valueid;
                    var html = '';
                    if (hasPermission('sys:field:edit')) {
                        html += '<a class="btn btn-warning" style="padding:2px;" onclick="vm.update(\'' + valueid + '\')">&nbsp;编辑&nbsp;</a>';
                        html += '<a style="padding:2px;margin-left:5px;" class="btn btn-danger" onclick="vm.del(\'' + valueid + '\')">&nbsp;删除&nbsp;</a>';
                    }
                    return html;
                }
            }
        ],
        viewrecords: true,
        height: "auto",
        rowNum: 10,
        //rowList: [10, 30, 50],
        rownumbers: true,
        rownumWidth: 50,
        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"
            });
        },
        onSortCol:function(index,colindex,sortorder){
            jQuery("#jqGrid").jqGrid('setGridParam',{
                page:$(".ui-pg-input").val()
            });
        }
    });
    $("#jqGrid").jqGrid('setLabel','rn','序号',{'text-align':'center'},'');
});
 
var local = window.location.href;
var fkey = local.substring(local.lastIndexOf('=') + 1, local.length);
 
var vm = new Vue({
    el: '#rapp',
    data: {
        showList: true,
        title: null,
        fieldvalue: {
            fkey: fkey,
            vcode: null
        }
    },
    methods: {
        query: function () {
            vm.reload();
        },
        add: function () {
            window.open("fieldvalueedit.html?fkey=" + vm.fieldvalue.fkey + "&valueid=", "_blank");
        },
        update: function (valueid) {
            window.open("fieldvalueedit.html?fkey=" + vm.fieldvalue.fkey + "&valueid=" + valueid, "_blank");
        },
        saveOrUpdate: function () {
            if (vm.title == "新增") {
                var url = "sys/fieldvalue/save";
            }
            if (vm.title == "修改") {
                var url = "sys/fieldvalue/update";
            }
            $.ajax({
                type: "POST",
                url: restServerBaseURL + url,
                contentType: "application/json",
                data: JSON.stringify(vm.fieldvalue),
                success: function (r) {
                    if (r.code === 0) {
                        alert('操作成功', function () {
                            vm.reload();
                        });
                    } else {
                        alert(r.msg);
                    }
                }
            });
        },
        back: function () {
            window.location.href = baseURL + "/admin/modules/sys/field.html";
        },
        del: function (valueids) {
            if (valueids == null) {
                return;
            }
            confirm('确定要删除选中的记录?', function () {
                $.ajax({
                    type: "POST",
                    url: restServerBaseURL + "sys/fieldvalue/delete",
                    contentType: "application/json",
                    data: "[" + valueids + "]",
                    success: function (r) {
                        if (r.code == 0) {
                            alert('操作成功', function () {
                                vm.reload();
                            });
                        } else {
                            alert(r.msg);
                        }
                    }
                });
            });
        },
        getInfo: function (valueid) {
            $.get(restServerBaseURL + "sys/fieldvalue/info/" + valueid, function (r) {
                vm.fieldvalue = r.fieldvalue;
            });
        },
        reload: function () {
            vm.showList = true;
            var page = $("#jqGrid").jqGrid('getGridParam', 'page');
            $("#jqGrid").jqGrid('setGridParam', {
                page: page
            }).trigger("reloadGrid");
        },
        refresh: function () {
            vm.showList = true;
            window.location.reload();
        },
        sort:function(){
            initSortList();
        }
    }
});
 
function initSortList(){
    $.ajax({
        type: "POST",
        url: restServerBaseURL + 'sys/fieldvalue/queryAllListByFkey?fkey=' + fkey,
        contentType: "application/json",
        success: function (r) {
            if (r.code == 0) {
                var list = r.fieldvalueList;
                var html = "";
                for (var i = 0; i < list.length; i++) {
                    html+="<option onclick='setNoMultipe(\""+list[i].valueid+"\")' rorder='"+list[i].rorder+"' value='"+list[i].valueid+"'>"+
                        list[i].vtext
                    +"</option>";
                }
                $("#fieldTexts").empty().append(html);
                $("#fieldTexts").attr("size",15);
            } else {
                alert(r.msg);
            }
        }
    });
}
 
//设置排序
function setSort(type){
    // var valueids="";
    // var sorts = "";
    if ($("#fieldTexts option:selected").length == 0) {
        alert("请选择节点!");
        return false;
    }
    // valueids = $("#fieldTexts option:selected").attr("value") +",";
    if (type == 'up') {//升序
        if ($("#fieldTexts option:selected").prev().length == 0) {
            alert("已经是最上了!");
            return false;
        }else{
            // valueids += $("#fieldTexts option:selected").prev().attr("value");
            // sorts = $("#fieldTexts option:selected").prev().attr("rorder")+",";
            $('#fieldTexts option:selected').insertBefore($('#fieldTexts option:selected').prev());
        }
    }else if(type == 'down'){//降序
        if ($("#fieldTexts option:selected").next().length == 0) {
            alert("已经是最下了!");
            return false;
        }else{
            // valueids += $("#fieldTexts option:selected").next().attr("value");
            // sorts = $("#fieldTexts option:selected").next().attr("rorder")+",";
            $('#fieldTexts option:selected').insertAfter($('#fieldTexts option:selected').next());
        }
    }
    else if(type == 'allup') {
        if ($("#fieldTexts option:selected").prev().length == 0) {
            alert("已经是最上了!");
            return false;
        }else{
            $('#fieldTexts option:selected').insertBefore($('#fieldTexts option').first());
        }
    }
    else if(type == 'alldown') {
        if ($("#fieldTexts option:selected").next().length == 0) {
            alert("已经是最下了!");
            return false;
        }else {
            $('#fieldTexts option:selected').insertAfter($('#fieldTexts option').last());
        }
    }
    // sorts+=$("#fieldTexts option:selected").attr("rorder");
 
}
 
function submitOrder() {
    var valueids="";
    $("#fieldTexts option").each(function () {
        if(valueids != "") valueids+=",";
        valueids += $(this).attr("value");
    });
    $.ajax({
        type: "POST",
        url: restServerBaseURL + "sys/fieldvalue/updateRorder",
        contentType: "application/json",
        data: JSON.stringify({valueids:valueids}),
        success: function (r) {
            if (r.code === 0) {
                alert('保存成功!');
                initSortList();
                vm.reload();  //保存排序后刷新列表  alert YKM
            } else {
                alert(r.msg);
            }
        }
    });
}
 
//下拉列表框不能多选
function setNoMultipe(id){
    $("#fieldTexts option").each(function(){
        if ($(this).attr("value") != id) {
            $(this).removeAttr("selected");
        }
    });
 
}