$("#basicCostTab").edatagrid({
rownumbers: true,
fitColumns: true,
singleSelect: true,
scrollbarSize: 10,
autoSave: true,
onSave: function () {
if (basicCostTabIndex == undefined) {
return true;
}
if ($("#basicCostTab").datagrid("validateRow", basicCostTabIndex)) {
if ($("#basicCostTab").datagrid("getRows").length > 0) {
priceChange();
$("#basicCostTab").datagrid("endEdit", basicCostTabIndex);
basicCostTabIndex = undefined;
}
getAllAmount();
getSumAmount();
return true;
} else {
return false;
}
},
columns: [
[
{
field: "id",
title: "商品名称",
width: 350,
fixed: true,
formatter: function (v, r, index) {
return '<abbr title="' + r.name + '">' + v + "</abbr>";
},
formatter: function (v, r) {
return r.name;
},
editor: {
type: "combogrid",
options: {
required: true,
panelWidth: 600,
prompt: "商品名称",
url: "",
idField: "id",
textField: "name",
mode: "remote",
reversed: true,
multiple: true,
editable: true,
title: "",
checkOnSelect: true, // 选择时自动勾选复选框
onShowPanel: function () {
/// 阻止默认的焦点丢失行为
$(this) .combogrid("panel").bind("mousedown", function (e) {
e.stopPropagation();
});
var panel = $(this).combogrid("panel");
if (!panel.find(".combogrid-toolbar").length) {
var toolbar = $('<div class="combogrid-toolbar"></div>').appendTo(panel);
var button = $('<a href="javascript:;" class="easyui-linkbutton" iconCls="icon-add">确认</a>').appendTo(toolbar);
button.click(function () {
alert("Add button clicked!");
});
}
},
columns: [
[
{ field: "id", title: "id", width: 240, hidden: true },
{ field: "name", title: "商品名称", width: 240, fixed: true, resizable: false },
{ field: "brandName", title: "品牌", width: 130, fixed: true, resizable: false },
{ field: "totalAmount", title: "可用库存", width: 130, fixed: true, resizable: false },
],
],
onBeforeLoad: function (param) {
// 在加载数据前可以修改param参数
if (param.q) {
param["_search.name"] = '{"t":"string","v":"' + param["q"] + '"}';
}
},
onLoadSuccess: function (data) {},
onChange(index, selectRow) {
var g = $(this).combogrid("grid");
var r = g.datagrid("getChecked");
console.log("r:", r);
if (r && r.length > 0) {
// 选第一条直接进行chooseProduct,剩下的代码创建append行
var firstData = r[0];
var otherData = r.splice(1, r.length - 1);
chooseProduct(firstData);
}
},
},
},
},
{ field: "smallUnitCode", title: "小单位条码", editor: { type: "textbox", options: { readonly: true } }, fixed: true, width: 120 },
{ field: "brandName", title: "品牌", editor: { type: "textbox", options: { readonly: true } }, fixed: true, width: 120 },
{ field: "largeUnitRatio", editor: { type: "textbox", options: { readonly: true } }, hidden: true },
{ field: "middleUnitRatio", editor: { type: "textbox", options: { readonly: true } }, hidden: true },
{ field: "specs", title: "规格", editor: { type: "textbox", options: { readonly: true } }, fixed: true, width: 80 },
{
field: "salesUnitVolume",
title: "体积",
editor: { type: "textbox", options: { readonly: true } },
fixed: true,
width: 80,
formatter: function (v, r) {
return $.mothin.util.formatNum(Number(v).toFixed(4));
},
},
{
field: "salesUnitWeight",
title: "重量",
editor: { type: "textbox", options: { readonly: true } },
fixed: true,
width: 80,
formatter: function (v, r) {
return $.mothin.util.formatNum(Number(v).toFixed(4));
},
},
{
field: "productUnit",
title: "订购单位",
editor: { type: "textbox", options: { readonly: true } },
fixed: true,
width: 100,
formatter: function (v, row) {
return row.unitName;
},
editor: {
type: "combobox",
options: {
valueField: "id",
textField: "name",
editable: false,
required: true,
missingMessage: "该输入项为必填项",
onSelect(data) {
getPrice(data);
},
},
},
},
{
field: "totalAmount",
title: "库存数量",
editor: { type: "textbox", options: { readonly: true } },
fixed: true,
width: 100,
formatter: function (v, r, index) {
var html = "",
isOut = "";
if (v) {
if (r.isOut) {
isOut = '<span class="label label-danger" style="position:relative;margin-left:6px;"> 超期</span>';
} else {
isOut = "";
}
html = "<span onclick=\"showBatchDialog('" + index + '\')" style="display:flex; align-items: center"> <a class=" btn-link " href="javascript:;">' + v + "</a> " + isOut + "</span>";
} else {
html = "";
}
return html;
},
},
{ field: "unitTypeName", title: "单位类型", editor: { type: "textbox", options: { readonly: true } }, fixed: true, width: 80 },
{
field: "price",
title: "订购单价",
align: "right",
fixed: true,
width: 100,
styler: function () {
return { class: "editableNumber" };
},
editor: {
type: "numberbox",
options: {
min: 0,
precision: 4,
onChange: makePrice,
},
},
formatter: function (v, r) {
return $.mothin.util.formatNum(Number(v).toFixed(4));
},
},
{
field: "cutPrice",
title: "下次不跟随",
align: "center",
fixed: true,
width: 70,
formatter: function (value) {
if (value == 1) {
return "是";
} else {
return "";
}
},
editor: {
type: "checkbox",
options: {
on: 1,
off: 0,
},
},
},
{
field: "amount",
title: "订购数量",
align: "right",
fixed: true,
width: 100,
styler: function () {
return { class: "amount" };
},
editor: {
type: "numberbox",
options: {
min: 1,
required: true,
missingMessage: "该输入项为必填项",
onChange: makeAmount,
},
},
formatter: function (v, r) {
return v ? $.mothin.util.formatNum(Number(v)) : "";
},
},
{
field: "total",
title: "金额",
align: "right",
fixed: true,
width: 100,
editor: {
type: "numberbox",
options: {
min: 0,
onChange: makeTotal,
parser: function (v) {
return floor4(v);
},
},
},
},
{
field: "memo",
title: "备注",
align: "right",
fixed: true,
width: 100,
editor: {
type: "text",
},
},
{
field: "rem",
title: "操作",
width: 118,
fixed: true,
align: "center",
formatter: function (v, r, i) {
return "<button class='btn btn-link abtn' onclick='removeRow(" + i + ")' >删除</button>" + "<button class='btn btn-link abtn' onclick='copy(" + i + ")' >复制</button>";
},
},
],
],
onClickCell: function (index, field, value) {
if (field == "rem") {
} else {
if (field !== "totalAmount") {
onClickRow(index);
}
}
},
onBeforeEdit: function (index, row) {},
onAfterEdit: function (index, row, changes) {},
});
easyui datagrid表格中设置combogrid 下拉框在编辑状态中点击失去焦点的解决方法
于 2025-02-28 15:37:25 首次发布

1698

被折叠的 条评论
为什么被折叠?



