C:\inetpub\wwwroot\OpcenterRDnL\wwwroot\Scripts\Custom\Shared\utilities.js
1、在这个文件中引用自定义的js文件
在方法中 $.ajaxSetup

2、另一个文件Actionbar.js
C:\inetpub\wwwroot\OpcenterRDnL\wwwroot\Scripts\Custom\Shared\ActionBar\Actionbar.js
在此方法中 function computeVisibility(lButton)

/* globals ko, utils, Enumerable, DraggableMenuModule */
(function (actionBar, $, workspaceModule, CustomSlider) {
/**
* @property (Object) defaultParamsValues The default settings applied for a button from the action bar
* @private
*/
var defaultParamsValues = {
action: function () { },
visible: true,
options: []
};
const CreateShortcut = 'CreateShortcut';
const CreateNewVersionSpecification = 'CreateNewVersionSpecification';
const AddNewItems = 'Add new items';
const CreateFrameRefresh = 'CreateFrameRefresh';
const CommonStatusChange = 'CommonStatusChange';
const DeleteSpecifications = 'DeleteSpecifications';
const ChangeMaterialStatus = 'ChangeMaterialStatus';
const CreateSPecification = 'CreateSPecification';
const Copy = 'Copy';
const AssignDocuments = 'AssignDocuments';
const assignbuttons = 'assignbuttons';
const AddRequestSamplesToPlate = 'AddRequestSamplesToPlate';
const Reanalysis = 'Reanalysis';
const OpenRequestAssignSample = 'OpenRequestAssignSample';
const OpenSampleOfARequestConfirmComplete = 'OpenSampleOfARequestConfirmComplete';
const withSameSampleType = 'withSameSampleType';
const copySample = 'copySample';
const AssignFullTestPlan = 'AssignFullTestPlan';
const SendSelectedPlates = 'SendSelectedPlates';
const SendSelectedWells = 'SendSelectedWells';
const FirstButton = 'FirstButton';
const Attribute = 'Attribute';
const RemoveAttributeButton = 'RemoveAttributeButton';
const UpdateAttributeButton = 'UpdateAttributeButton';
const SendWorkMailButton = 'SendWorkMailButton';
const SaveDocument = 'SaveDocument';
const CreateNewVersion = 'CreateNewVersion';
const UpdateDocument = 'UpdateDocument';
const CreateDocument = 'CreateDocument';
const ConfigCreateVersion = 'ConfigCreateVersion';
const ConfigCopy = 'ConfigCopy';
const ConfigStatusChange = 'ConfigStatusChange';
const ConfigCreateInfoFields = 'ConfigCreateInfoFields';
const CreateRequestCreate = 'CreateRequestCreate';
const CreatedItemsButton = 'CreatedItems-button';
const CreateNewBuilder = 'CreateNewBuilder';
const AddMaterial = 'AddMaterial';
const AddChildMaterial = 'AddChildMaterial';
const RemoveMaterial = 'RemoveMaterial';
const AddFormulaWorkbench = 'AddFormulaWorkbench';
const AddEmptyFormulation = 'AddEmptyFormulation';
const LoadFormulationBuilder = 'LoadFormulationBuilder';
const CreatePrice = 'CreatePrice';
const CreateAndOpen = 'CreateAndOpen';
const unavailableForConsumerUser = [CreateShortcut, CreateNewVersionSpecification, AddNewItems, CreateFrameRefresh, CommonStatusChange, DeleteSpecifications, ChangeMaterialStatus,
CreateSPecification, Copy, AssignDocuments, assignbuttons, AddRequestSamplesToPlate, Reanalysis, OpenRequestAssignSample,
OpenSampleOfARequestConfirmComplete, withSameSampleType, copySample, AssignFullTestPlan, SendSelectedPlates, SendSelectedWells, FirstButton, Attribute,
RemoveAttributeButton, UpdateAttributeButton, SendWorkMailButton, SaveDocument, CreateNewVersion, UpdateDocument, CreateDocument, ConfigCreateVersion,
ConfigCopy, ConfigStatusChange, ConfigCreateInfoFields, CreateRequestCreate, CreatedItemsButton, CreateNewBuilder, AddMaterial, AddChildMaterial,
RemoveMaterial, AddFormulaWorkbench, AddEmptyFormulation, LoadFormulationBuilder, CreatePrice, CreateAndOpen];
/**
* @property (Observable array) The buttons displayed in the scrollable area
* @public
*/
actionBar.dynamicButtons = ko.observableArray();
actionBar.isMenuAvailable = ko.observable(false);
actionBar.buttonIds = {
AddChildMaterial: 'AddChildMaterial',
AddEmptyFormulation: 'AddEmptyFormulation',
AddFormulaWorkbench: 'AddFormulaWorkbench',
AddMaterial: 'AddMaterial',
AddMethodsToWorksheet: 'AddMethodsToWorksheet',
AddSamplesToPlate: 'AddSamplesToPlate',
AddSamplesToPlateInOpenPlate:'AddSamplesToPlateInOpenPlate',
AddRequestSamplesToPlate: 'AddRequestSamplesToPlate',
AddWorklistSamplesToPlate: 'AddWorklistSamplesToPlate',
AddRequestsToPlate: 'AddRequestToPlate',
AssignPlatesToRequest: 'AssignPlatesToRequest',
AddNewDocument: 'AddNewDocument',
AssignDocuments: 'AssignDocuments',
AssignedCharts: 'AssignedCharts',
AssignFullTestPlan: 'AssignFullTestPlan',
AssignTestPlan: 'AssignTestPlan',
BomAddNewItems: 'Add new items',
BomChangeLayout: 'Change Layout',
BomExplosion: 'BomExplosion',
BomExplosionSimple: 'BomExplosionSimple',
CancelSolverCalculation: 'CancelSolverCalculation',
ChangeMaterialStatus: 'ChangeMaterialStatus',
CloseSelector: 'CloseSelector',
ConfigAttribute: 'ConfigAttribute',
ConfigChart: 'ConfigChart',
ConfigCreateObject: 'ConfigCreateObject',
ConfigLayout: 'ConfigLayout',
ConfigLocations: 'ConfigLocations',
ConfigLocationTypes: 'ConfigLocationTypes',
ConfigSetActiveFlag: 'ConfigSetActiveFlag',
ConfigSpecType: 'ConfigSpecType',
ConfigTask: 'ConfigTask',
Copy: 'Copy',
CopySpec: 'CopySpec',
Create: 'Create',
CreateAndContinue: 'CreateAndContinue',
CreateAndOpen: 'CreateAndOpen',
CreateDocument: 'CreateDocument',
CreateNewBuilder: 'CreateNewBuilder',
CreatedStudies: 'CreatedStudies',
CreatedWorksheets: 'CreatedWorksheets',
CreateNewScheduler: 'CreateNewScheduler',
CreateNewVersion: 'CreateNewVersion',
CreateNewVersionAndOpen: 'CreateNewVersionAndOpen',
CreateNewVersionSpecification: 'CreateNewVersionSpecification',
CreatePrice: 'CreatePrice',
CreateRequestCreate: 'CreateRequestCreate',
CreateSampleCreate: 'CreateSampleCreate',
CreatePlateCreate: 'CreatePlateCreate',
DeleteSpecifications: 'DeleteSpecifications',
DownloadDocument: 'DownloadDocument',
FormulationFavorites: 'Favorites',
Filter: 'Filter',
LaunchpadAssign: 'LaunchpadAssign',
LaunchpadChooseDefault: 'LaunchpadChooseDefault',
LaunchpadDiscardCustom: 'LaunchpadDiscardCustom',
LaunchpadDiscardGlobal: 'LaunchpadDiscardGlobal',
LaunchpadEdit: 'LaunchpadEdit',
LaunchpadExitEdit: 'LaunchpadExitEdit',
LaunchpadRefreshShortcuts: 'LaunchpadRefreshShortcuts',
LaunchpadSave: 'LaunchpadSave',
LaunchpadSaveAs: 'LaunchpadSaveAs',
LaunchpadSaveOptions: 'LaunchpadSaveOptions',
LoadFormulationBuilder: 'LoadFormulationBuilder',
LoadSpecIntoFormulation: 'LoadSpecification',
Open: 'Open',
OpenFormulationComponentList: 'Components',
OpenFormulationRolledupComponentList: 'Rolledup Components',
OpenMaterialGrid: 'Materials',
OpenPlateRemoveButton: 'OpenPlateRemoveButton',
OpenPlateWorkList: 'OpenPlateWorkList',
OpenSOPDocument: 'OpenSOPDocument',
OpenSOPDocumentEquipment: 'OpenSopDocumentEquipment',
OpenSOPDocumentMethod: 'OpenSopDocumentMethod',
OpenSOPDocumentSample: 'OpenSopDocumentSample',
OpenStepContent: 'OpenStepContent',
OpenWorkspace: 'OpenWorkspace',
Print: 'Print',
Reanalysis: 'Reanalysis',
Refresh: 'Refresh',
RemoveMaterial: 'RemoveMaterial',
RemoveSample:'RemoveSample',
SaveDocument: 'SaveDocument',
SaveToSpec: 'Save to Specification',
SelectEquipment: 'SelectEquipment',
StartIntervention: 'StartIntervention',
UpdateDocument: 'UpdateDocument',
XceleratorShare: 'XceleratorShare'
};
const hideButtonClass = 'hideActionbarButtonIcon',
defaultIconClass = 'icon-cmdAction24';
actionBar.functionalities = {
CreateNewObjectConfigModule: ['ConfigCreateObject', 'ConfigCreateInfoFields'],
Save: ['CommonSave', 'ConfigSave']
};
actionBar.commonButtonIds = [
actionBar.buttonIds.Refresh,
'Save'
];
actionBar.GetActionBarFAR = function () {
var getFarPromise = $.Deferred();
window.dataServices.GetFar('General', 'ContextualCommandBar')
.done(function (results) {
actionBar.isMenuAvailable(results.CCBMenu);
getFarPromise.resolve();
})
.fail(function (exception) {
utils.showException('', exception);
});
return getFarPromise;
};
function getMenuSettings() {
var menuSettings = {
menuId: '#actionBarMenu',
parentContainer: '#actionBar',
dynamicPart: '#dynamicActionBar',
buttonIdsList: actionBar.buttonIds,
actionBarButtons: actionBar.dynamicButtons,
actionBarFunctionalities: actionBar.functionalities,
actionBarCommonButtons: actionBar.commonButtonIds
};
return menuSettings;
}
function Button(settings) {
var self = this;
var isCustomDropdownButton = false;
if (settings.options.length > 1) {
if (settings.options[0].isCustomButton === true) {
isCustomDropdownButton = true;
}
}
//if (settings.dropDownContent || settings.dropdownElements || settings.iconPath || settings.text) {
// console.error('obsolete button: ', settings);
//}
//if (settings.id == undefined) {
// console.info('define a unique ID for the actionbar button for proper functionality: ', settings);
//}
function safePropertyAssigner(property, def) {
var value;
if (typeof property === 'undefined') {
property = def;
}
value = property;
if (!ko.isObservable(property)) {
value = ko.observable(property);
}
return value;
}
function loadDefaultOption() {
const elems = elements.peek(), id = localStorage[ko.peek(self.id)];
let saved = elems[0];
const sameSample = 'withSameSampleType';
const copySample = 'copySample';
if (id !== undefined) {
for (let i = 0; i < elems.length; i++) {
const el = elems[i];
if (el.id.peek() === id) {
saved = el;
break;
}
}
}
for (let i = 0; i < elems.length; i++) {
const el = elems[i];
if (elems[i].isSelected) {
saved = el;
break;
}
}
if (ko.peek(self.id) == actionBar.buttonIds.CreateRequestCreate && !actionbarHelper.create.notInManualAssignment() ) {
for (let i = 0; i < elems.length; i++) {
const el = elems[i];
if (el.id.peek() === actionBar.buttonIds.CreateAndContinue) {
saved = el;
break;
}
}
}
if (ko.peek(self.id) == sameSample) {
for (let i = 0; i < elems.length; i++) {
const el = elems[i];
if (el.id() == sameSample && ko.unwrap(window.VM.wizardVM.underlyingVM.ScStNewFar) === true) {
saved = el;
break;
}
else if (el.id() == copySample && ko.unwrap(window.VM.wizardVM.underlyingVM.ScCopy) === true) {
saved = el;
break;
}
}
}
self.defaultOption(saved);
}
function setDefaultOptionInLocalStorage(option) {
//the default option
if (self == option) {
return;
}
var id = ko.utils.unwrapObservable(option.id);
var selfId = ko.utils.unwrapObservable(self.id);
if (selfId && id && id != strings.actionBar.Open) {
localStorage[selfId] = id;
self.defaultOption(option);
}
}
function setDefaultOption(option) {
//the default option
if (self == option)
return;
var prevDefaultOption = self.defaultOption();
if (prevDefaultOption != undefined)
prevDefaultOption.isSelected = false;
option.isSelected = true;
self.defaultOption(option);
}
self.id = settings.id == null ? settings.options[0] != null ? settings.options[0].id : null : settings.id;
self.iconClassGroup = settings.iconClassGroup;
self.waitingForCallbacks = safePropertyAssigner(settings.waitingForCallbacks, false);
self.visible = ((ko.isObservable(settings.visible)) ? settings.visible : ko.observable(settings.visible));
//all elements
var elements = ko.isObservable(settings.options) ? settings.options : ko.observableArray(settings.options || []);
elements.subscribe(function (options) {
for (var index in options) {
options[index].id = safePropertyAssigner(options[index].id, undefined);
options[index].text = safePropertyAssigner(options[index].text, strings.actionBar.UploadDocument);
options[index].textColor = safePropertyAssigner(options[index].textColor, '');
options[index].icon = safePropertyAssigner(options[index].icon, '3');
options[index].iconClass = safePropertyAssigner(options[index].iconClass, hideButtonClass);
options[index].visible = safePropertyAssigner(options[index].visible, true);
options[index].isEnabled = safePropertyAssigner(options[index].isEnabled, true);
options[index].isSelected = options[index].isSelected != undefined ? options[index].isSelected : false;
options[index].waitingForCallbacks = safePropertyAssigner(options[index].waitingForCallbacks, false);
if (typeof options[index].action === 'function') {
self.action = options[index].action;
}
options[index].task = function (option, aElement) {
actionBar.menu.isOpened(false);
if (!option.isEnabled() || options[index].waitingForCallbacks())
return;
var dropDownList = (aElement != undefined && aElement.target != undefined) ? aElement.target.closest(".dropdown-list") : undefined;
if (isCustomDropdownButton === false)
setDefaultOptionInLocalStorage(option);
if (option.shouldPutLastSelectionToTop)
setDefaultOption(option);
this.action(option);
if (dropDownList != undefined && dropDownList.classList.contains('on') && dropDownList.classList.contains('dropdown-list')) {
dropDownList.classList.remove('on');
}
};
}
});
elements.notifySubscribers(elements());
self.defaultOption = ko.observable();
self.hasElements = ko.computed({
read: function () {
return elements() != undefined && elements().length > 0;
},
deferEvaluation: true
});
self.hasVisibleElements = ko.computed({
read: function () {
var visible = false;
if (self.hasElements()) {
var options = elements();
for (var index = 0; index < options.length && !visible; ++index) {
visible = visible || options[index].visible();
}
}
return visible;
},
deferEvaluation: true
});
self.releaseResources = function (parentClass) {
var dropdownClass = parentClass;
var dropdownSelector = '.{dropdownClass}[boundTo="{parentId}"]';
dropdownSelector = dropdownSelector.replace('{dropdownClass}', dropdownClass).replace('{parentId}', self.id);
$(dropdownSelector).remove();
}
self.isEnabled = safePropertyAssigner(settings.isEnabled, true);
self.isDisplayedInActionBar = settings.isDisplayedInActionBar != undefined ? ko.observable(settings.isDisplayedInActionBar) : ko.observable(true);
self.isDisplayedInActionBar.subscribe(function () {
setTimeout(function () {
if (actionBar.Slider != undefined)
actionBar.Slider.checkIfScrollIsNeeded();
}, 10);
});
//default element
var selected = ko.computed({
read: function () {
return (self.hasElements())
? self.defaultOption()
: undefined;
},
deferEvaluation: true
});
self.clear = function () {
if (ko.isObservable(elements) || (ko.isComputed(elements) && elements.hasWriteFunction)) {
elements([]);
}
};
//all elements - default
self.options = ko.computed({
read: function () {
loadDefaultOption();
const options = elements().slice(), sel = selected();
if (self.hasElements()) {
var index = options.indexOf(sel);
if (index >= 0) {
options.splice(index, 1);
}
}
return options;
},
deferEvaluation: false
});
self.hasOptions = ko.computed({
read: function () {
return self.hasElements() && self.options().length > 0;
},
deferEvaluation: true
});
self.hasVisibleOptions = ko.computed({
read: function () {
var visible = false;
if (self.hasOptions()) {
var options = self.options();
for (var index = 0; index < options.length && !visible; ++index) {
visible = visible || options[index].visible();
}
}
return visible;
},
deferEvaluation: true
});
self.isDropdownDisabled = ko.computed({
read: function () {
return self.hasOptions() && VM.wizardVM && VM.wizardVM.underlyingVM.DropDownIsDisabled && VM.wizardVM.underlyingVM.DropDownIsDisabled();
},
deferEvaluation: true
});
self.isVisible = ko.computed({
read: function () {
if (isCustomDropdownButton) {
var hadVisibleButtons = false;
for (var i = 0; i < self.options().length; i++) {
if (self.options()[i].visible())
hadVisibleButtons = true;
}
if (hadVisibleButtons === true) return self.hasVisibleElements();
}
else {
return self.visible() && self.hasElements() && self.hasVisibleElements();
}
},
deferEvaluation: true
});
self.isVisible.subscribe(function () {
setTimeout(function () {
if (actionBar.Slider != undefined)
actionBar.Slider.checkIfScrollIsNeeded();
}, 10);
});
self.text = ko.computed({
read: function () {
if (selected()) {
return self.hasElements() ? selected().text() : '';
} else {
return '';
}
},
deferEvaluation: true
});
self.icon = ko.computed({
read: function () {
return self.hasElements() ? selected().icon() : undefined;
},
deferEvaluation: true
});
self.iconClass = ko.computed({
read: function () {
if (selected()) {
return self.hasElements() ? selected().iconClass() : undefined;
} else {
return undefined;
}
},
deferEvaluation: true
});
self.task = function (option) {
actionBar.menu.isOpened(false);
removeFocusFromSelectedInputIfNeeded();
if (ko.unwrap(option.id) == actionBar.buttonIds.SelectEquipment || self.waitingForCallbacks())
return;
return self.hasElements() ? selected().task(option) : undefined;
};
self.templateName = ko.pureComputed({
read: function () {
var buttonId = self.id;
var isCreateButtonOption =
buttonId == actionBar.buttonIds.CreateSampleCreate
|| buttonId == actionBar.buttonIds.CreateRequestCreate
|| buttonId == actionBar.buttonIds.CreatePlateCreate
|| buttonId == actionBar.buttonIds.CreateAndContinue
|| buttonId == actionBar.buttonIds.Create
|| buttonId == actionBar.buttonIds.Open
|| buttonId == actionBar.buttonIds.CreateAndOpen;
var isCreateWithCounterButton = isCreateButtonOption && VM.wizardVM != undefined
&& VM.wizardVM.currentStep != undefined && window.VM.wizardVM.currentStep() === 2
&& (window.VM.wizardVM.taskType === "sccreate" || window.VM.wizardVM.taskType === "plcreate" || window.taskKeyUtils.taskKeyTypesOfRequest().indexOf(window.VM.wizardVM.taskType) > -1);
var isOpenWorkspaceButton = buttonId == actionBar.buttonIds.OpenWorkspace;
var templateName = isCreateWithCounterButton || isOpenWorkspaceButton ?
'buttonWithNotificationCounter' : 'simpleButton';
return templateName;
},
deferEvaluation: true
});
}
function removeFocusFromSelectedInputIfNeeded() {
if (utils.isEditField(document.activeElement))
$(document.activeElement).blur();
}
var dropDowns = [];
actionBar.afterRender = function (item) {
var element = $(item[1]);
dropDowns.push(element.find('.dropdown-list'));
if (actionBar.Slider != undefined)
actionBar.Slider.checkIfScrollIsNeeded();
};
function sortByPosition(firstButton, secondButton) {
return ((firstButton.Position < secondButton.Position) ? -1 : ((firstButton.Position > secondButton.Position) ? 1 : 0));
}
function computeVisibility(lButton) {
var isVisible = ko.pureComputed({
read: function () {
var filterCriteriaStep = 1;
var pivotTableStep = 3;
if (window.VM.wizardVM.currentStep() === filterCriteriaStep) {
return false;
}
//debugger;
//hxlmsg 自定义按钮隐藏
$("#btnCopyRequest").hide();//自定义复制
$("#btnExportTestPlan").hide(); //导出及预览
$("#btnSamplePleaseCheck").hide();//样品请检
$("#btnTheBestProduct").hide();//最优品选择
$("#btnDeleteRQ").hide();//删除
$("#btnExportDatabaseExcel").hide(); //试验计划数据库导出
if (window.VM.wizardVM.currentStep() === pivotTableStep) {
var visibleInPivotTable = this.IsVisibleWhen.indexOf('PivotTable') > -1
if (this.CustomFunction == "Reanalysis") {
var isSingleItemSelected = selection.activeControl() && selection.activeControl().singleItemSelected()
return (isSingleItemSelected ? visibleInPivotTable && controls.parameterGroups.reanalysisVisible() : false);
}
else {
return visibleInPivotTable
}
}
if (this.IsVisibleWhen.indexOf('Everywhere') > -1) {
return true;
}
var selectedItemType;
var selectedItems = selection.selectedItemsForCustomButtons();
if (selectedItems && selectedItems.length > 0) {
selectedItemType = utils.getVal(selectedItems[0].TypeName);
} else {
return false;
}
switch (selectedItemType) {
case 'SampleFullDTO':
return this.IsVisibleWhen.indexOf('Sample') > -1;
case 'RequestFullDTO':
return this.IsVisibleWhen.indexOf('Request') > -1;
case 'ParameterGroupFullDTO':
return this.IsVisibleWhen.indexOf('ParameterGroup') > -1;
case 'ParameterFullDTO':
return this.IsVisibleWhen.indexOf('Parameter') > -1;
case 'MethodFullDTO':
case 'MethodHeaderDTO':
return this.IsVisibleWhen.indexOf('Method') > -1;
case 'MethodCellHeaderDTO':
return this.IsVisibleWhen.indexOf('MethodCell') > -1;
case 'WorksheetHeaderDTO':
case 'WorksheetFullDTO':
return this.IsVisibleWhen.indexOf('Worksheet') > -1;
case 'SpecificationFullDTO':
return this.IsVisibleWhen.indexOf('Specification') > -1;
case 'PlateFullDTO':
return this.IsVisibleWhen.indexOf('Plate') > -1;
case 'PlateWellDto':
return this.IsVisibleWhen.indexOf('PlateDetails') > -1;
default:
return false;
}
},
owner: lButton
});
return isVisible;
}
function getButtonObject(lButton, isVisible, hasAction) {
if (lButton.IconClass === '' || lButton.IconClass == null) {
lButton.IconClass = defaultIconClass;
}
return {
text: lButton.Description,
iconClass: lButton.IconClass,
id: lButton.CustomFunction,
customFunction: utils.getVal(lButton.CustomFunction),
action: hasAction === undefined ? function () {
executeCustomFunction(this.customFunction);
} : function () {
return;
},
visible: isVisible,
position: lButton.Position,
isCustomButton: true
};
}
function addSingleButton(lButton, isVisible) {
var customBtn = { options: [getButtonObject(lButton, isVisible)] };
actionBar.createButtonInDynamicArea(customBtn);
}
function getEmptyButtonObject(aButtonId, aIconClass) {
return getButtonObject({
Description: aButtonId,
IconClass: aIconClass != undefined ? aIconClass : defaultIconClass,
CustomFunction: aButtonId,
Position: 0
}, ko.observable(true), true);
}
actionBar.loadDropdownCustomButtons = function () {
//debugger //hxlmsg 这个方法读取客户端自定义的button按钮
$.ajax({
url: utils.baseURL + 'ActionBar/GetCustomActionBarButtons',
contentType: 'application/json; charset=utf-8',
type: 'GET',
dataType: 'json',
success: function (result) {
result.sort(sortByPosition);
var lGroupedElements = Enumerable.from(result).groupBy(function (x) { return x.DropdownIdentifier; }).toArray();
for (var j = 0; j < lGroupedElements.length; j++) {
var dropdownList = new Array();
for (var i = 0; i < lGroupedElements[j].getSource().length; i++) {
var lButton = lGroupedElements[j].getSource()[i];
var isVisible = computeVisibility(lButton);
// add single button
if (lButton.DropdownIdentifier === '') {
addSingleButton(lButton, isVisible);
continue;
} else {
// add dropdown
if (dropdownList.length === 0) {
dropdownList.push(getEmptyButtonObject(lButton.DropdownIdentifier, lButton.DropdownIconClass));
}
dropdownList.push(getButtonObject(lButton, isVisible));
}
}
if (dropdownList.length) {
actionBar.createDropdown(dropdownList);
}
}
},
error: function (exception) {
utils.showException('', exception);
}
});
};
actionBar.createDropdown = function (params) {
actionBar.createButtonInDynamicArea({
options: params,
visible: ko.computed(function () {
var isVisible = false;
if (window.VM.wizardVM.selectedItems().length > 0) {
isVisible = true;
}
return isVisible;
})
});
};
actionBar.clearList = function () {
removeAllButtons();
restoreListDefaultButtons();
};
function restoreListDefaultButtons() {
actionBar.loadDropdownCustomButtons();
}
function removeAllButtons() {
var buttons = actionBar.dynamicButtons();
for (var i = 0; i < buttons.length; i++) {
if (buttons[i].hasOptions()) {
buttons[i].clear();
var dropdownClass = 'isActionBarButtonDropdown';
var dropdownSelector = '.{dropdownClass}[boundTo="{parentId}"]';
dropdownSelector = dropdownSelector.replace('{dropdownClass}', dropdownClass).replace('{parentId}', buttons[i].id);
$(dropdownSelector).remove();
}
}
actionBar.dynamicButtons.removeAll();
actionBar.menu.items.removeAll();
}
actionBar.createButtonInDynamicArea = function (params) {
//debugger;//hxlmsg 这里隐藏原生复制功能
if(params==undefined)
return;
if(params.id=="Copy")
return;
if(params.options!=null && params.options.length>0 && params.options[0].id=="CreateWorkflow")
return;
if(params.id=="AddRequestSamplesToPlate")
return;
///以上是自己写的
if (configuration.isConsumerCurrentUser()) {
if (!params) {
return;
}
if (unavailableForConsumerUser.includes(params.id) ||
(params.options && params.options.some(option => unavailableForConsumerUser.includes(ko.unwrap(option.id))))) {
return;
} else if (params.id === 'ConfigCreateObject') {
VM.wizardVM.createRequestClass = null;
return;
}
}
if (actionBar.isMenuAvailable() && params && actionBar.menu.isButtonIdAddedToActionBarMenu(params.id, params.options)) {
params.isDisplayedInActionBar = false;
var createdButton = createButton(actionBar.dynamicButtons, params);
if (createdButton != undefined)
actionBar.menu.items.push(createdButton);
}
else
createButton(actionBar.dynamicButtons, params);
};
function executeCustomFunction(aCustomFunction) {
var selectedItems = selection.selectedItemsForCustomButtons();
if (selectedItems == null || selectedItems.length === 0) {
utils.showException(strings.notifiers.NoItemsSelected);
}
var dataToSend = ko.toJSON(selectedItems);
$.ajax({
url: utils.baseURL + 'ActionBar/ExecuteActionBarCustomFunction' + '?aCustomFunctionShortDescription=' + aCustomFunction,
contentType: 'application/json; charset=utf-8',
type: 'POST',
data: dataToSend,
dataType: 'json',
success: function (result) {
if (!result) {
return;
}
var lCustomFunctionResult = result.Result;
if (lCustomFunctionResult) {
if (lCustomFunctionResult.Message && lCustomFunctionResult.MessageType) {
utils.showMessage(lCustomFunctionResult.Message, lCustomFunctionResult.MessageType, undefined, true);
}
eval(lCustomFunctionResult.JsFunction);
if (lCustomFunctionResult.Refresh && window.VM.wizardVM != null && window.VM.wizardVM.underlyingVM != null) {
//perform some operation if Refresh flag is true
window.VM.wizardVM.underlyingVM.refreshViewModel();
}
} else {
utils.alwaysShowInformation(utils.stringFormat(strings.notifiers.CustomFunctionInvocation, aCustomFunction));
}
},
error: function (result) {
utils.showException(strings.notifiers.CustomFunctionActionBar, result);
}
});
};
actionBar.getSelectedItemForDropdown = function (id) {
id = actionBar.menu.isButtonIdAddedToActionBarMenu(id) ?
$('.isMenuActionBarButton.dropdown[boundto="' + id + '"]') : '#' + id;
if ($(id).length <= 0)
return;
var button = ko.dataFor($(id)[0]);
if (button != undefined && button.defaultOption && button.defaultOption() != undefined) {
return button.defaultOption().attachedObject;
}
}
function isExistingButtonById(list, id) {
if (id == undefined) {
return false;
}
var button = Enumerable.from(list).where(function (x) { return x.id == id; }).firstOrDefault();
return button != undefined;
}
function createButton(list, params) {
var settings = $.extend({}, defaultParamsValues, params);
var settingsOptionsId = settings.options[0] != undefined ? (ko.unwrap(settings.options[0].id) != undefined ? ko.unwrap(settings.options[0].id) : "") : "";
var settingsId = settings.id != undefined ? settings.id : settingsOptionsId;
if (!isExistingButtonById(list(), settingsId)) {
var createdButton = new Button(settings);
list.push(createdButton);
return createdButton;
}
}
actionBar.afterRenderItems = function () {
actionBar.Slider = new CustomSlider('#dynamicActionBar', actionBar.dynamicButtons);
actionBar.menu.initDragableArea();
};
actionBar.getItemById = function (id) {
var items = actionBar.dynamicButtons();
for (var i = 0; i < items.length; i++) {
var itemId = ko.unwrap(items[i].id);
if (itemId == id)
return items[i];
var options = ko.unwrap(items[i].options);
for (var j = 0; j < options.length; j++)
if (ko.unwrap(options[j].id) == id)
return items[i];
}
return undefined;
}
actionBar.deleteButtonFromActionBar = function (id) {
var button = actionBar.getItemById(id);
if (button == undefined)
return;
button.releaseResources('isActionBarButtonDropdown');
actionBar.menu.removeButton(id);
actionBar.dynamicButtons.remove(button);
}
function init() {
var menuSettings = getMenuSettings();
actionBar.menu = new DraggableMenuModule.DraggableMenu(menuSettings);
//TO DO REIMPLEMENT - workspace button visibility
if (window.configuration.selectedDatabase()) {
var getActionBarFarPromise = actionBar.GetActionBarFAR();
getActionBarFarPromise.done(function () {
//addGlobalButtons();
});
}
}
init();
}(window.actionBar = window.actionBar || {}, jQuery, workspaceModule, CustomSlider));
3、自定义js文件 hxlcustom.js
C:\inetpub\wwwroot\OpcenterRDnL\wwwroot\Scripts\Extensions\hxlcustom.js
(function (extensions, $) {
var assignWindow;
var indexDelete=0;
extensions.hxlActionFunction = function (data) {
console.log("data:", data);
$('#btnCopyRequest').on('click', function() {
//处理中。。。
$("#LoadingOverlay").show();
console.log("btnCopyRequest was clicked!-------------------222222222222");
});
try {
if (data.indexOf("ChildObjectListGets") > -1) {
$("#btnExportTestPlan").hide();
return;
}
let JsonObject = JSON.parse(JSON.parse(data).Objects);
if (JsonObject == null || JsonObject.RequestTemplateType == null) {
return;
}
if (data.indexOf("工艺方案模板") > -1 || JsonObject.RequestTemplateType == "SJ" || JsonObject.RequestTemplateType == "BF" || JsonObject.RequestTemplateType == "PP" || JsonObject.RequestTemplateType == "PH") {
$("#btnOrderStatusRetrieval").show();//工单状态获取
$("#btnSamplePleaseCheck").show(); //样品请检
$("#btnCopyRequest").show();//自定义复制
$("#btnTheBestProduct").hide();//选择最优品
$("#btnExportBestProduct").hide();//最优品预览及导出按钮
$("#btnPushBOMtoTC").hide();//发送TC按钮
$("#btnRndtRqPullandMove").hide();//分配按钮
//工艺方案变更
if (JsonObject.StatusDescription == "已发布") {
$("#btnDeleteRQ").hide();
}
else {
$("#btnDeleteRQ").show(); //删除
}
return;
}
//项目
if (JsonObject.RequestTemplateType == "PR") {
$("#btnDeleteRQ").hide();
$("#btnOrderStatusRetrieval").hide();//工单状态获取
$("#btnTheBestProduct").hide();//选择最优品
$("#btnExportBestProduct").hide();//最优品预览及导出按钮
$("#btnPushBOMtoTC").hide();//发送TC按钮
$("#btnRndtRqPullandMove").hide();//分配按钮
}
//试验任务
if (JsonObject.RequestTemplateType == "EX") {
$("#btnDeleteRQ").hide();
$("#btnOrderStatusRetrieval").hide();//工单状态获取
$("#btnTheBestProduct").hide();//选择最优品
$("#btnTheBestProduct").hide();//选择最优品
$("#btnExportBestProduct").show();//最优品预览及导出按钮
$("#btnPushBOMtoTC").show();//发送TC按钮
$("#btnRndtRqPullandMove").show();//分配按钮
}
//试验计划
if (JsonObject.RequestTemplateType == "EP") {
$("#btnExportTestPlan").show();//导出及预览
$("#btnCopyRequest").show();//自定义复制
$("#btnDeleteRQ").show(); //删除
$("#btnOrderStatusRetrieval").show();//工单状态获取
$("#btnTheBestProduct").hide();//选择最优品
$("#btnExportBestProduct").hide();//最优品预览及导出按钮
$("#btnPushBOMtoTC").hide();//发送TC按钮
$("#btnRndtRqPullandMove").hide();//分配按钮
}
//试验计划
if (JsonObject.RequestTemplateType == "EP" && JsonObject.StatusDescription == "Approved") {
$("#btnDeleteRQ").hide();
}
//工序段
if (JsonObject.RequestTemplateType == "PS") {
$("#btnDeleteRQ").show();
$("#btnOrderStatusRetrieval").show();//工单状态获取
$("#btnTheBestProduct").show();//最优品
$("#btnExportBestProduct").hide();//最优品预览及导出按钮
$("#btnPushBOMtoTC").hide();//发送TC按钮
$("#btnRndtRqPullandMove").show();//分配按钮
//$("#btnCopyRequest").show();//自定义复制//试验计划下的工序段要唯一,不能复制
}
//工序段
if (JsonObject.RequestTemplateType == "PS" && JsonObject.StatusDescription == "Approved") {
$("#btnDeleteRQ").hide();
}
} catch (ex) { }
};
})(window.extensions = window.extensions || {}, jQuery);
219

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



