123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292 |
- BemsWebApplication.WorkExecution = function (params, viewInfo) {
- "use strict";
- //권한설정
- var hasnotModificationPermission = ko.observable(true);
- var useBusinessFiltering = BWA.UserInfo.isDependBusinessField(viewInfo.viewName);
- var businessFieldDataSource = BemsWebApplication.db.createDataSource('CmBusinessField', true, true, true),
- workTypeDataSource = BemsWebApplication.db.createDataSource('FmsWorkCodeType'),
- progressDataSource = BemsWebApplication.db.createDataSource('FmsWorkCodeProgress'),
- businessFields = ko.observableArray(),
- workTypes = ko.observableArray(),
- progresses = ko.observableArray();
- var isVisibleExecutionButton = ko.observable(true);
- var popup, workExecutionRegisterPopup = null;
- var deferredForSearch = new $.Deferred();
- var workTypesForSearch = ko.observableArray(),
- businessFieldsForSearch = ko.observableArray(),
- progressesForSearch = ko.observableArray();
- var eq = BWA.DataUtil.constructEqualFilter,
- and = BWA.DataUtil.andFilter,
- noteq = BWA.DataUtil.constructNotEqualFilter;
- var selectedFacilityData = ko.observable(),
- selectedUserData = params.selectedUserData || ko.observable();
- var dataSourceOptions = {
- select: [
- 'SiteId', 'WorkRequestId',
- 'FmsWorkRequest/WorkTypeId', 'Title', 'OrderDate', 'FmsWorkRequest/WorkProgressId',
- 'CmUser/Name', // 작업지시자
- //'CmUser1/Name', // 반려자
- 'FmsWorkRequest/FmsWorkCodeType/Name',
- 'FmsWorkRequest/CmBusinessField/Name',
- 'FmsWorkRequest/FmsWorkCodeProgress/Name',
- 'FmsWorkResult/CmUser/Name', 'BusinessFieldId',
- 'FmsWorkRequest/Content',
- 'FmsWorkRequest/StartWorkDate',
- 'StartWorkDate', // 2016 03 11 추가 hcLee
- 'FmsWorkResult/StartDate', // 2016 03 11 추가 hcLee
- 'FmsWorkRequest/BusinessFieldId'
- ],
- expand: [
- 'FmsWorkRequest',
- 'FmsWorkResult',
- 'FmsWorkResult/CmUser',
- 'FmsWorkRequest/FmsWorkCodeType',
- 'FmsWorkRequest/CmBusinessField',
- 'FmsWorkRequest/FmsWorkCodeProgress',
- 'CmBusinessField', 'CmUser'],
- //expand: ['FmsWorkCodeType', 'CmBusinessField', 'FmsWorkCodeProgress', 'CmUser', 'CmUser1'],
- extendOptions: {
- forceOriginalField: true
- }
- };
- if (!useBusinessFiltering) {
- dataSourceOptions.filter = [
- eq('SiteId', BWA.UserInfo.SiteId()),
- and,
- [
- eq('FmsWorkRequest/WorkProgressId', 3),
- 'or',
- eq('FmsWorkRequest/WorkProgressId', 7)
- ]
- ];
- }
- else {
- dataSourceOptions.filter = [
- eq('SiteId', BWA.UserInfo.SiteId()),
- and,
- [
- eq('FmsWorkRequest/WorkProgressId', 3),
- 'or',
- eq('FmsWorkRequest/WorkProgressId', 7)
- ],
- and,
- [
- eq('FmsWorkRequest/BusinessFieldId', BWA.UserInfo.BusinessFieldId()),
- 'or',
- eq('FmsWorkRequest/BusinessFieldId', 1)
- ]
- ];
- }
- var viewModel = BWA.DataGrid.createViewWithDataGrid(params, viewInfo, 'FmsWorkOrder', {
- popupWidth: 1200,
- dataSourceOptions: dataSourceOptions,
- columns: [
- { dataField: 'WorkRequestId', caption: $G('number'), width: '8%', alignment: 'center' },
- { dataField: 'FmsWorkRequest/CmBusinessField/Name', caption: $G('businessFieldName'), width: '10%', alignment: 'center' },
- { dataField: 'FmsWorkRequest/FmsWorkCodeType/Name', caption: $G('workTypeName'), width: '10%', alignment: 'center' },
- {
- dataField: 'OrderDate', caption: $G('orderedDate'), width: '12%', alignment: 'center', sortOrder: 'desc', visible: false,
- customizeText: function (cellInfo) {
- return $G.date(cellInfo.value);
- }
- },
- //{ dataField: 'FmsWorkRequest/FmsWorkCodeType/Name', caption: $G('workTypeName'), width: '10%', alignment: 'center' },
- {
- dataField: 'StartWorkDate', caption: '시작일', width: '12%', alignment: 'center', sortOrder: 'desc',
- customizeText: function (cellInfo) {
- return $G.date(cellInfo.value);
- }
- },
- /* {
- //dataField: 'StartWorkDate', caption: '작업시작일', width: '12%', alignment: 'center', sortOrder: 'desc',
- dataField: 'FmsWorkResult/StartDate', caption: '작업시작일', width: '12%', alignment: 'center', sortOrder: 'desc',
- customizeText: function (cellInfo) {
- return $G.date(cellInfo.value);
- } // 만일 이게 문제가 발생되면 Order의 StartDate를 업데이트가 필요하다. hcLee 2016 03 11
- }, */
- { dataField: 'Title', caption: '작업명', width: '35%', alignment: 'center' },
- { dataField: 'FmsWorkRequest/FmsWorkCodeProgress/Name', caption: $G('workProgressName'), width: '10%', alignment: 'center' },
- { dataField: 'CmUser/Name', caption: '작업지시자', width: '15%', alignment: 'center' },
- { dataField: 'FmsWorkResult/CmUser/Name', caption: '작업자', width: '15%', alignment: 'center', visible: false },
- { dataField: 'FmsWorkRequest/Content', caption: '신청내용', width: '0%', alignment: 'center' },
- ],
- rowPrepared: function (rowElement, rowInfo) {
- if (rowInfo.rowType == 'data') {
- var now = new Date();
- var data = rowInfo.data;
- if (data['FmsWorkRequest/WorkProgressId']() == 3) {
- if (data['StartWorkDate']() <= now) {
- rowElement.css('background-color', 'rgba(255,0,0,0.1)');
- }
- }
- }
- },
- promiseDataInSearchView: deferredForSearch.promise(),
- searchViewItems: _.compact([
- { id: 'FmsWorkRequest/BusinessFieldId', ignoreValue: 0, defaultValue: 0, dataSource: businessFieldsForSearch },
- //{ id: 'WorkTypeId', ignoreValue: 0, defaultValue: 0, dataSource: workTypesForSearch },
- { id: 'CmUser/Name' },
- { id: 'Title' },
- { id: 'WorkProgressId', ignoreValue: 0, defaultValue: 0, dataSource: progressesForSearch },
- { id: 'StartWorkDate', type: 'dateRange', isOnlyDate: true }
- ]),
- getAddedToolbarItemsInPopup: function (e) {
- var isEditModeInPopup = e.isEditModeInPopup;
- return [
- {
- location: 'after', widget: 'button', options: {
- text: '작업수행', icon: 'add', type: 'success', visible: isVisibleExecutionButton, disabled: hasnotModificationPermission,
- clickAction: saveWorkResult
- }
- },
- {
- location: 'after', widget: 'button', options: {
- text: $G('facilityInsertion'), icon: 'search', visible: isEditModeInPopup,
- clickAction: function () {
- popup.facilitySearchPopup.show();
- }
- }
- },
- {
- location: 'after', widget: 'button', options: {
- text: $G('facilityDeletion'), icon: 'remove', type: 'danger', visible: isEditModeInPopup,
- clickAction: function () {
- if (popup && popup.handleDeleteSelectedFacilities) {
- popup.handleDeleteSelectedFacilities();
- }
- }
- }
- }];
- },
- beforeInsertingDataViewModel: function (dataModel) {
- return true;
- },
- handleDataGridRowClick: function (id, dataGrid, clickRow, popupVisible) {
- dataGrid.clearSelection();
- var data = clickRow.data;
- var dataModel = viewModel.dataModel;
- if (data['FmsWorkRequest/WorkProgressId']() >= $Code.WorkProgress.WORKING) {
- isVisibleExecutionButton(false);
- }
- else {
- isVisibleExecutionButton(true);
- }
- if (popup && popup.handleBeforeShowingPopupForEdit) {
- popup.handleBeforeShowingPopupForEdit(data, dataModel);
- }
- popupVisible(true);
- },
- handleBeforePopupShowingPromise: function () {
- if (popup && popup.handleBeforePopupShowingPromise) {
- popup.handleBeforePopupShowingPromise.apply(popup, arguments);
- }
- },
- handleAfterLoadingModelByKey: function () {
- if (popup && popup.handleAfterLoadingModelByKey) {
- popup.handleAfterLoadingModelByKey.apply(popup, arguments);
- }
- },
- handlePopupShowing: function () {
- if (popup && popup.handlePopupShowing) {
- //viewModel.toolbarItems[4].options.visible = false;
- popup.handlePopupShowing.apply(this, arguments);
- }
- },
- handlePopupShown: function (editMode, isNewInPopup, dataModel) {
- if (popup && popup.handlePopupShowing) {
- popup.handlePopupShown.apply(this, arguments);
- }
- },
- handleSaveButtonInPopup: function (isInsert) {
- if (isInsert === false) {
- if (popup && popup.handleAfterSave) {
- popup.handleAfterSave(undefined);
- }
- }
- },
- handleAfterSaveInPopup: function (responseKey, response) {
- if (popup && popup.handleAfterSave) {
- popup.handleAfterSave(responseKey, response);
- }
- },
- handleViewShowing: function (dataModel) {
- //권한설정
- hasnotModificationPermission(!BWA.UserInfo.hasPermissionOfModification(viewInfo.viewName));
- if (useBusinessFiltering) {
- businessFieldDataSource.filter([
- eq('SiteId', BWA.UserInfo.SiteId()),
- and,
- [eq('BusinessFieldId', BWA.UserInfo.BusinessFieldId()), 'or', eq('BusinessFieldId', 1)]
- ]);
- }
- $.when(
- businessFieldDataSource.load(),
- workTypeDataSource.load(),
- progressDataSource.load()
- ).done(function (businessFieldResult, workTypeResult, progressResult) {
- businessFields(businessFieldResult[0]);
- workTypes(workTypeResult[0]);
- progresses(progressResult[0]);
- businessFieldsForSearch($SearchView.createArrayOfSelectBox('BusinessFieldId', businessFields()));
- workTypesForSearch($SearchView.createArrayOfSelectBox('WorkTypeId', workTypes()));
- progressesForSearch($SearchView.createArrayOfSelectBox('ProgressId', progresses()));
- deferredForSearch.resolve();
- });
- },
- handleViewShown: function () {
- }
- });
- viewModel.businessFields = businessFields;
- viewModel.workTypes = workTypes;
- popup = viewModel.popup = BWA.Popup.WorkExecution.create(viewInfo, viewModel);
- workExecutionRegisterPopup = viewModel.workExecutionRegisterPopup = BWA.Popup.WorkExecutionRegister.create(viewInfo, viewModel);
- function saveWorkResult() {
- workExecutionRegisterPopup.popupVisible(true);
- }
- return viewModel;
- };
|