123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282 |
- BemsWebApplication.AnyCheckSchedule = function (params, viewInfo, executionPlanOptions) {
- "use strict";
- var businessFieldDataSource = BemsWebApplication.db.createDataSource('CmBusinessField', true, true, true),
- workTypeDataSource = BemsWebApplication.db.createDataSource('FmsWorkCodeType'),
- progressDataSource = BemsWebApplication.db.createDataSource('FmsWorkCodeProgress'),
- FmsWorkRequestDataSource = BemsWebApplication.db.createDataSource('FmsWorkRequest'),
- businessFields = ko.observableArray(),
- workTypes = ko.observableArray(),
- progresses = ko.observableArray();
- var workrequest = ko.observableArray();
- var RowName;
- var deferredForSearch = new $.Deferred();
- var workTypesForSearch = ko.observableArray(),
- businessFieldsForSearch = ko.observableArray(),
- progressesForSearch = ko.observableArray();
- var popup;
- var eq = BWA.DataUtil.constructEqualFilter,
- and = BWA.DataUtil.andFilter,
- noteq = BWA.DataUtil.constructNotEqualFilter;
- var workTypeId = $Code.WorkType.INNER_CHECK;
- var executionPlanViewOptions = undefined,
- executionPlanPopupOptions = undefined;
- if (executionPlanOptions) {
- executionPlanViewOptions = executionPlanOptions.viewOptions;
- executionPlanPopupOptions = executionPlanOptions.popupOptions;
- }
- var selectedFacilityData = ko.observable(),
- selectedUserData = params.selectedUserData || ko.observable();
- var dataSourceOptions = {
- select: [
- 'SiteId', 'WorkRequestId', 'WorkTypeId', 'Title', 'RequestDate', 'WorkProgressId', 'StartWorkDate',
- 'CmUser/Name', // 신청자
- 'CmUser1/Name', // 반려자
- 'FmsWorkCodeType/Name', 'CmBusinessField/Name', 'FmsWorkCodeProgress/Name'
- ],
- expand: ['FmsWorkCodeType', 'CmBusinessField', 'FmsWorkCodeProgress', 'CmUser', 'CmUser1'],
- extendOptions: {
- forceOriginalField: true
- }
- };
- if (_.isUndefined(executionPlanViewOptions)) {
- dataSourceOptions.filter = [
- eq('SiteId', BWA.UserInfo.SiteId()),
- and,
- eq('WorkTypeId', $Code.WorkType.INNER_CHECK),
- and,
- eq('WorkProgressId', $Code.WorkProgress.WORK_PLAN)
- ];
- }
- else {
- // 시설관리 > 실행계획조회 화면에서는 작업계획 상태만 가져옴
- dataSourceOptions.filter = [
- eq('SiteId', BWA.UserInfo.SiteId()),
- and,
- [
- eq('WorkProgressId', $Code.WorkProgress.WORK_PLAN)
- ]
- ];
- }
- var viewModel = BWA.DataGrid.createViewWithDataGrid(params, viewInfo, 'FmsWorkRequest', {
- popupWidth: 1200,
- dataSourceOptions: dataSourceOptions,
- columns: [
- { dataField: 'WorkRequestId', caption: $G('number'), width: '8%', alignment: 'center', sortOrder: 'desc', },
- { dataField: 'FmsWorkCodeProgress/Name', caption: $G('workProgressName'), width: '10%', alignment: 'center', visible: false },
- { dataField: 'FmsWorkCodeType/Name', caption: $G('workTypeName'), width: '10%', alignment: 'center', visible: false },
- { dataField: 'CmBusinessField/Name', caption: $G('businessFieldName'), width: '10%', alignment: 'center' },
- { dataField: 'Title', caption: '작업명', width: '55%', alignment: 'center' },
- {
- dataField: 'StartWorkDate', caption: '작업예정일', width: '12%', alignment: 'center',
- customizeText: function (cellInfo) {
- return $G.date(cellInfo.value);
- }
- },
- { dataField: 'CmUser/Name', caption: $G('requesterName'), width: '15%', alignment: 'center' }
- ],
- promiseDataInSearchView: deferredForSearch.promise(),
- searchViewItems: _.compact([
- { id: 'WorkProgressId', ignoreValue: 0, defaultValue: 0, dataSource: progressesForSearch },
- { id: 'WorkTypeId', ignoreValue: 0, defaultValue: 0, dataSource: workTypesForSearch },
- { id: 'Title' },
- { id: 'CmUser/Name' },
- { id: 'BusinessFieldId', ignoreValue: 0, defaultValue: 0, dataSource: businessFieldsForSearch },
- { id: 'StartWorkDate', type: 'dateRange', isOnlyDate: true}
- ]),
- paging: {
- enabled: true,
- pageSize: 20
- },
- handleDataGridRowClick: function (id, dataGrid, clickRow, popupVisible) {
- dataGrid.clearSelection();
- var data = clickRow.data;
- var dataModel = viewModel.dataModel;
- RowName = data.Title;
- // 정기, 법정인 경우는 반려가 안보이게 2016 06 16 hcLee
- if (!_.isUndefined(viewModel.executionPlanPopupOptions)) {
- if (data.WorkTypeId() < 3)
- viewModel.executionPlanPopupOptions.isVisibleRejectButtons(false);
- else
- viewModel.executionPlanPopupOptions.isVisibleRejectButtons(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) {
- popup.handlePopupShowing.apply(this, arguments);
- }
- FmsWorkRequestDataSource.filter([
- ["SiteId", "=", BWA.UserInfo.SiteId()],
- 'and',
- ["WorkTypeId", "=", 5]
- ]);
- FmsWorkRequestDataSource.load().done(function (result) {
- workrequest(result);
- });
- },
- handlePopupShown: function (editMode, isNewInPopup, dataModel) {
- if (popup && popup.handlePopupShown) {
- 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);
- }
- },
- getAddedToolbarItemsInPopup: function (e) {
- var isEditModeInPopup = e.isEditModeInPopup;
- var addedTooolbarItems = [
- {
- 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(); }
- }
- }
- }];
- // 실행계획조회 인 경우 툴바아이템 추가
- if (!_.isUndefined(executionPlanPopupOptions)) {
- var executionToolbarItems = executionPlanPopupOptions.getAddedToolbarItemsInPopup(e);
- var resultToolbarItems = addedTooolbarItems.concat(executionToolbarItems);
- return resultToolbarItems;
- }
- return addedTooolbarItems;
- },
- beforeInsertingDataViewModel: function (dataModel, dbModelId) {
- var dfd = $.Deferred();
- var isDuplicated = false;
- for (var i = 0; i < workrequest().length; i++) {
- if (dataModel.Title() == workrequest()[i].Title() && dataModel.BusinessFieldId() == workrequest()[i].BusinessFieldId()) {
- isDuplicated = true;
- }
- }
- if (!BWA.DataUtil.isValidInputValue(dataModel.Title()))
- return dfd.resolve(false, '저장 혹은 수정 반드시 필수 입력 정보를 모두 입력하셔야 합니다 (앞뒤공백 허용안함)');
- else {
- if (isDuplicated)
- return dfd.resolve(false, '이미 동일 정보가 존재합니다.');
- else
- return dfd.resolve(true);
- }
- },
- beforeUpdateDataViewModel: function () {
- var isDuplicated = false;
- for (var i = 0; i < workrequest().length; i++) {
- if (viewModel.dataModel.Title() == workrequest()[i].Title() && viewModel.dataModel.BusinessFieldId() == workrequest()[i].BusinessFieldId()
- && (RowName() != workrequest()[i].Title())) {
- isDuplicated = true;
- }
- }
- if (!BWA.DataUtil.isValidInputValue(viewModel.dataModel.Title())) {
- utils.toast.show('저장 혹은 수정 반드시 필수 입력 정보를 모두 입력하셔야 합니다 (앞뒤공백 허용안함)', 'error');
- return 0;
- }
- else {
- if (isDuplicated) {
- utils.toast.show('이미 동일 정보가 존재합니다.', 'error');
- return 0;
- }
- else
- return 2;
- }
- },
- handleViewShowing: function (dataModel) {
- var useBusinessFiltering = BWA.UserInfo.isDependBusinessField(viewInfo.viewName)
- if (useBusinessFiltering) {
- dataSourceOptions.filter.push('and');
- dataSourceOptions.filter.push([eq('BusinessFieldId', BWA.UserInfo.BusinessFieldId()), 'or', eq('BusinessFieldId', 1)]);
- 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;
- viewModel.executionPlanViewOptions = executionPlanViewOptions;
- viewModel.executionPlanPopupOptions = executionPlanPopupOptions; // hcLee 2016 06 16
- popup = viewModel.popup = BWA.Popup.AnyCheckSchedule.create(viewInfo, viewModel, executionPlanPopupOptions);
- return viewModel;
- };
|