改成常用输入框
field: 'fuelTypeName',
title: '油品名称及牌号',
align: 'center',
valign: 'middle',
formatter: function (value, row, index, field) {
var html;
if (DlUtil.isEmpty(value)) {
html = '<input id="fuelTypeName' + index + '" type="text" class="form-control" name="fuelTypeName" autocomplete="off" px="' + index + '">';
} else {
html = '<input id="fuelTypeName' + index + '" type="text" class="form-control" name="fuelTypeName" value="' + value + '" autocomplete="off" px="' + index + '">'
}
return html;
},
改成下拉框:
field: 'oilCabinManagerId',
title: '油舱名称',
align: 'center',
width: '120',
valign: 'middle',
visible: false,
formatter: function (value, row, index, field) {
var html = "<select type=\"text\" class=\"form-control select\" style='text-align-last:center;' id=\"oilCabinManagerId\" name=\"oilCabinManagerId\" οnchange=\"FuelApply.selectyc(this,'" + index + "')\" px='" + index + "'>";
html += "<option value=\"\">请选择</option>";
$.ajax({
url: "/api/sms/safemanagement/special/fuelmanage/oilcabinmanager/list/all",
type: "post",
dataType: "json",
async: false,
success: function (result) {
if (result.status === 1) {
$.each(result.data, function (i, v) {
if (v.oilCabinManagerId === value) {
html += "<option value=" + v.oilCabinManagerId + " selected>" + v.oilCabinManagerName + "</option>";
} else {
html += "<option value=" + v.oilCabinManagerId + ">" + v.oilCabinManagerName + "</option>";
}
});
} else if (result.errMsg) {
DlUtil.alertError(result.errMsg);
} else {
DlUtil.alertError("初始化方式列表错误!");
}
}, error: function () {
DlUtil.alertError("发送初始化方式列表错误!");
}
});
html += "</select>";
return html
}
设置行隐藏字段
field: 'maxCapacity',
title: '最大舱容(M)',
align: 'center',
width: '100',
valign: 'middle',
visible: false,
formatter: function (value, row, index, field) {
var html;
if (DlUtil.isEmpty(value)) {
html = '<input id="maxCapacity' + index + '" type="text" class="form-control" name="maxCapacity" autocomplete="off" px="' + index + '" readonly>';
} else {
html = '<input id="maxCapacity' + index + '" type="text" class="form-control" name="maxCapacity" value="' + value + '" autocomplete="off" px="' + index + '" readonly>'
}
html += '<input id="oilCabinTypeId' + index + '" type="hidden" class="form-control" name="oilCabinTypeId" autocomplete="off" px="' + index + '" readonly>';
html += '<input id="oilCabinManagerName' + index + '" type="hidden" name="oilCabinManagerName" value="' + row.oilCabinManagerName + '" px="' + index + '" readonly>';
html += '<input id="fuelName' + index + '" type="hidden" name="fuelName" value="' + row.fuelName + '" px="' + index + '" readonly>';
html += '<input id="fuelSortName' + index + '" type="hidden" class="form-control" name="fuelSortName" autocomplete="off" px="' + index + '" readonly>';
return html;
}
获取下拉框的value,name值,并赋值给同行其他列的方式:
var selectyc = function (dom, index) {
var value = $(dom).val();
$("dShip option:selected")
var oilCabinManagerName = $(dom).find("option:selected").text();
var id = $(dom).attr("id");
var cdata = {};
cdata[id] = value;
if (value.length > 0) {
$.ajax({
url: "/api/sms/safemanagement/special/fuelmanage/oilcabinmanager/" + value,
type: 'get',
dataType: 'json',
success: function (result) {
var data = result.data;
$.each($("#fuelApply_detal_table"), function (i, v) {
v['maxCapacity' + index] = data.maxCapacity;
$("#maxCapacity" + index).val(data.maxCapacity);
v['safetyCapacity' + index] = data.safetyCapacity;
$("#safetyCapacity" + index).val(data.safetyCapacity);
v['oilCabinTypeId' + index] = data.oilCabinTypeId;
$("#oilCabinTypeId" + index).val(data.oilCabinTypeId);
v['oilCabinManagerName' + index] = oilCabinManagerName;
$("#oilCabinManagerName" + index).val(oilCabinManagerName);
});
}
, error: function () {
layer.close(index);
DlUtil.alertError("发送请求失败!");
}
});
}
};
|