天津投入产出系统后端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

98 lines
2.8 KiB

//自动补全用 jquery-ui-autocomplete
function _setAutoComplete(url, valueID, labelID, callBackfun) {
$("#" + valueID).autocomplete(
{
source: url,
minLength: 1,
dataType: "jsonp",
search: function (event, ui) {
return true;
},
focus: function (event, ui) {
$("#" + valueID).val(ui.item.code);
return true;
},
select: function (event, ui) {
$("#" + valueID).val(ui.item.code);
if (labelID != "")
$("#" + labelID).val(ui.item.text);
callBackfun(ui.item);
return false;
}
}).data("ui-autocomplete")._renderItem = function (ul, item) {
return $("<li style='font-size:12px;width:150px'>").append("<a>" + item.label + "</a>").appendTo(ul);
};
}
//输入后校验
function _isAutoComplete(url, valueID, labelID, callBackfun) {
if ($("#" + valueID).attr("readonly") == "readonly") {
return;
}
var term = $("#" + valueID).val();
if (term == "") {
$("#" + valueID).val("");
if (labelID != "")
$("#" + labelID).val("");
callBackfun(null);
return;
}
var response = $.ajax({ url: url + "&term=" + term + "&mode=is", async: false });
var r = response.responseText;
var list = JSON.parse(r);
if (list.length == 0) {
$("#" + valueID).val("");
if (labelID != "")
$("#" + labelID).val("");
callBackfun(null);
}
else {
$("#" + valueID).val(list[0].code);
if (labelID != "")
$("#" + labelID).val(list[0].text);
callBackfun(list[0]);
}
}
var _acValueID;
var _acLabelID;
var _callBackfun;
//显示自动完成窗口
function _showAutoComplete(url, valueID, labelID, callBackfun) {
if ($("#" + valueID).attr("readonly") == "readonly") {
return;
}
_acValueID = valueID;
_acLabelID = labelID;
_callBackfun = callBackfun;
openAppWindow1("请选择", url, 460, 300)
// var returnValue = window.showModalDialog(url, '', 'dialogWidth:400px; dialogheight:300px;resizable:no;status:no;scroll:no;');
// if (returnValue != null) {
// _setValueAutoComplete(returnValue);
// }
}
// TODO:待于阳修改
function _showAutoComplete1(url, valueID, labelID, callBackfun) {
if ($("#" + valueID).attr("readonly") == "readonly") {
return;
}
_acValueID = valueID;
_acLabelID = labelID;
_callBackfun = callBackfun;
openAppWindow1('请选择', url, '440', '400');
}
//设置值
function _setValueAutoComplete(data) {
$("#" + _acValueID).val(data.code);
if (_acLabelID != "")
$("#" + _acLabelID).val(data.text);
document.getElementById(_acValueID).focus();
_callBackfun(data);
}