131 lines
2.7 KiB
JavaScript
131 lines
2.7 KiB
JavaScript
function showDictSelect(id, type, all) {
|
|
var data = getDict(type);
|
|
var select = $("#" + id);
|
|
select.empty();
|
|
|
|
if (all != undefined && all) {
|
|
select.append("<option value=''>全部</option>");
|
|
}
|
|
|
|
$.each(data, function(dictValue, dictName) {
|
|
select.append("<option value ='" + dictValue + "'>" + dictName + "</option>");
|
|
});
|
|
|
|
return data;
|
|
}
|
|
|
|
function showDictSelectByReference(id, type, all) {
|
|
var data = getDict(type);
|
|
var select = $("#" + id);
|
|
select.empty();
|
|
|
|
if (all != undefined && all) {
|
|
select.append("<option value=''>请选择排序参照</option>");
|
|
}
|
|
|
|
$.each(data, function(dictValue, dictName) {
|
|
select.append("<option value ='" + dictValue + "'>" + dictName + "</option>");
|
|
});
|
|
|
|
return data;
|
|
}
|
|
|
|
function showDictSelectBySort(id, type, all) {
|
|
var data = getDict(type);
|
|
var select = $("#" + id);
|
|
select.empty();
|
|
|
|
if (all != undefined && all) {
|
|
select.append("<option value=''>请选择排序规则</option>");
|
|
}
|
|
|
|
$.each(data, function(dictValue, dictName) {
|
|
select.append("<option value ='" + dictValue + "'>" + dictName + "</option>");
|
|
});
|
|
|
|
return data;
|
|
}
|
|
|
|
function getDict(type) {
|
|
let params = {
|
|
type: type
|
|
}
|
|
params={
|
|
encryptedData:encryptCBC(JSON.stringify(params))
|
|
}
|
|
$.ajax({
|
|
type : 'post',
|
|
url : ctxPath + '/dicts/type',
|
|
data: params,
|
|
headers: {
|
|
"token": tokens
|
|
},
|
|
async : false,
|
|
success : function(result) {
|
|
if (result.status === 200) {
|
|
v = {};
|
|
$.each(result.data, function(i, d) {
|
|
v[d.dictValue] = d.dictName;
|
|
});
|
|
sessionStorage[type] = JSON.stringify(v);
|
|
} else if (result.status === 500) {
|
|
layer.alert(result.msg, {icon: 2})
|
|
}
|
|
}
|
|
});
|
|
|
|
return JSON.parse(sessionStorage[type]);
|
|
}
|
|
|
|
|
|
function showDictSelect2(id, type, all) {
|
|
var data = getDict(type);
|
|
var select = $("#" + id);
|
|
select.empty();
|
|
|
|
if (all != undefined && all) {
|
|
select.append("<option value=''>全部</option>");
|
|
}
|
|
|
|
$.each(data, function(dictValue, dictName) {
|
|
select.append("<option value ='" + dictName + "'>" + dictName + "</option>");
|
|
});
|
|
|
|
return data;
|
|
}
|
|
|
|
function showDictSelect3(id, type, all) {
|
|
var data = getDict(type);
|
|
var select = $("#" + id);
|
|
select.empty();
|
|
|
|
if (all != undefined && all) {
|
|
select.append("<option value=''>全部</option>");
|
|
}
|
|
|
|
$.each(data, function(dictValue, dictName) {
|
|
select.append("<option value ='" + dictValue + "'>" + dictValue + "</option>");
|
|
});
|
|
|
|
return data;
|
|
}
|
|
|
|
function getDict2(type) {
|
|
$.ajax({
|
|
type : 'get',
|
|
url : ctxPath + '/dicts?type=' + type,
|
|
headers: {
|
|
"token": tokens
|
|
},
|
|
async : false,
|
|
success : function(data) {
|
|
v = {};
|
|
$.each(data, function(i, d) {
|
|
v[d.dictValue] = d.dictName;
|
|
});
|
|
sessionStorage[type] = JSON.stringify(v);
|
|
}
|
|
});
|
|
|
|
return JSON.parse(sessionStorage[type]);
|
|
} |