//页面初始化加载 判断表格行里面审核状态 等按钮是否显示 dataLoaded(viewModel) { const gridModel = viewModel.getGridModel(); viewModel.getGridModel()._set_data("rowKeyField", "id"); gridModel.on("afterSetDataSource", () => { const rows = gridModel.getRows(); const actions = gridModel.getCache("actions"); const actionsStates = []; rows.forEach((data) => { const actionState = {}; const { state } = data; actions.forEach((action) => { actionState[action.cItemName] = { visible: true }; if (data.state == "1") { //审批通过1 隐藏或显示条件 actionState["button100od"] = { visible: false }; actionState["btnEdit"] = { visible: false }; actionState["btnCopy"] = { visible: false }; actionState["btnDelete"] = { visible: false }; if (data.isNoRept == "1") { // 有认证报告 actionState["button139gg"] = { visible: true }; } else { // 无认证报告 actionState["button139gg"] = { visible: false }; } } else { //开立0 // actionState["button100od"] = { visible: true }; actionState["button119kg"] = { visible: false }; actionState["button139gg"] = { visible: false }; actionState["btnCopy"] = { visible: false }; } }); actionsStates.push(actionState); }); setTimeout(() => { gridModel.setActionsState(actionsStates); }, 200); }); }
// 调用方法 cb.define(process.env.__DOMAINKEY__, [], function () { let mlssrmkk_f830e38fList_VM_Extend = { doAction: function (name, viewModel) { if (this[name]) this[name](viewModel); }, init: function (viewModel) { this.dataLoaded(viewModel); }, }; try { module.exports = mlssrmkk_f830e38fList_VM_Extend; } catch (error) {} return mlssrmkk_f830e38fList_VM_Extend; });
标签:状态,false,gridModel,表格,控制,viewModel,visible,const,actionState From: https://www.cnblogs.com/LFxanla/p/17162782.html