123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242 |
- BemsWebApplication.SetChart = function (params, viewInfo) {
- "use strict";
- var facilityTypeDataSource = BemsWebApplication.db.createDataSource('BemsFacilityType', true);
- var ChartInfoDataSource = BemsWebApplication.db.createDataSource('BemsChartInfo', true);
- var facilityTypes = ko.observableArray();
- var ChartInfo = ko.observableArray();
- var searchfacilityTypes = ko.observableArray();
- var facilityTypeDeferred = new $.Deferred();
- var BemsFormulaBaseDataSource = BemsWebApplication.db.createDataSource('BemsFormulaBase', true, true);
- var formulaListByFacilityType = ko.observableArray();
- var palettes = ['Default', 'Soft Pastel', 'Harmony Light', 'Pastel', 'Bright', 'Soft', 'Ocean', 'Vintage', 'Violet'];
- var chartTypes = ['bar', 'line', 'spline', 'area', 'scatter', 'splinearea', 'stepline', 'steparea'];
- var dataSourceOptions = {
- select: [
- 'SiteId', 'FacilityTypeId', 'BemsFacilityType/Name',
- 'ChartId', 'Palette', 'Title',
- 'LAxTitle', 'UseLAxMinMax', 'LAxMin', 'LAxMax',
- 'RAxTitle', 'UseRAxMinMax', 'RAxMin', 'RAxMax',
- 'UseX', 'XAxTitle', 'XSFmId', 'XSType', 'UseXAxMinMax', 'XAxMin', 'XAxMax',
- 'LSFmId1', 'LSName1', 'LSType1',
- 'LSFmId2', 'LSName2', 'LSType2',
- 'LSFmId3', 'LSName3', 'LSType3',
- 'LSFmId4', 'LSName4', 'LSType4',
- 'RSFmId1', 'RSName1', 'RSType1',
- 'RSFmId2', 'RSName2', 'RSType2',
- 'RSFmId3', 'RSName3', 'RSType3',
- 'RSFmId4', 'RSName4', 'RSType4',
- 'UseChart',
- 'UseLCTLine', 'LCTLineTitle', 'LCTLineValue',
- 'UseRCTLine', 'RCTLineTitle', 'RCTLineValue',
- ],
- filter: [
- ['SiteId', '=', BWA.UserInfo.SiteId()]
- ],
- expand: [
- 'BemsFacilityType',
- ],
- extendOptions: {
- forceOriginalField: true
- },
- };
- var viewModel = BWA.DataGrid.createViewWithDataGrid(params, viewInfo, 'BemsChartInfo', {
- dataSourceOptions: dataSourceOptions,
- columns: [
- { dataField: 'SiteId', caption: '번호', width: '8%', alignment: 'center', sortOder: 'desc' },
- { dataField: 'BemsFacilityType/Name', caption: '설비타입', width: '15%', alignment: 'center' },
- { dataField: 'ChartId', caption: '차트ID', width: '10%', alignment: 'center' },
- { dataField: 'Title', caption: '차트타이틀', width: '15%', alignment: 'center' },
- { dataField: 'Palette', caption: '차트 색상', width: '15%', alignment: 'center' },
- { dataField: 'LAxTitle', caption: '좌Y축 타이틀', width: '20%', alignment: 'center' },
- { dataField: 'LSName1', caption: '좌Y축 항목1 타이틀', width: '20%', alignment: 'center' },
-
- { dataField: 'RAxTitle', caption: '우Y축 타이틀', width: '20%', alignment: 'center' },
-
- { dataField: 'RSName1', caption: '우Y축 항목1 타이틀', width: '20%', alignment: 'center' },
-
-
- {
- dataField: 'UseChart', caption: '차트 사용', width: '15%', alignment: 'center',
- customizeText: function (cellInfo) {
- return $G.isUse(cellInfo.value);
-
- }
- }
-
- ],
-
- "export": {
- enabled: true,
- fileName: '성능분석 차트 설정 내용'
- },
- onExporting: function (e) {
- e.component.columnOption("SiteId", "visible", false);
- },
- onExported: function (e) {
- e.component.columnOption("SiteId", "visible", true);
- },
-
- paging: {
- pageSize: 18,
- enabled: true
- },
- pager: {
-
-
-
- },
- promiseDataInSearchView: facilityTypeDeferred.promise(),
- searchViewItems: [{ id: 'FacilityTypeId', ignoreValue: 0, defaultValue: 0, dataSource: searchfacilityTypes }, { id: 'Name' }],
- handleDataGridRowClick: function (id, dataGrid, clickRow, popupVisible) {
- dataGrid.clearSelection();
- viewModel.isNewInPopup(false);
- var data = clickRow.data;
- viewModel.handleSelectBoxChangeFacilityType({ value: data.FacilityTypeId() });
-
-
- popupVisible(true);
- },
- handleViewShowing: function () {
- facilityTypeDataSource.filter([
- ['FacilityTypeId', '<', 50]
- ]);
- facilityTypeDataSource.load().done(function (result) {
- facilityTypes(result);
-
- searchfacilityTypes(result);
- facilityTypeDeferred.resolve();
- });
- ChartInfoDataSource.load().done(function (result) {
- ChartInfo(result);
- });
- },
- handlePopupShowing: function (isNewInPopup, dataViewModel) {
- if (isNewInPopup()) {
- dataViewModel.ChartId(1);
- dataViewModel.UseChart(true);
- dataViewModel.UseX(false);
- dataViewModel.UseXAxMinMax(false);
- dataViewModel.UseLAxMinMax(false);
- dataViewModel.UseRAxMinMax(false);
- dataViewModel.Palette('Default');
- dataViewModel.UseLCTLine(false);
- dataViewModel.UseRCTLine(false);
- }
- },
- popupWidth: 1000,
- handleViewShown: function () {
- },
-
- isUseSiteId: (BWA.UserInfo.isAdmin() == false) ? true : false,
- beforeInsertingDataViewModel: function (dataModel, dbModelId) {
- var dfd = $.Deferred();
- var result;
- for (var i = 0; i < ChartInfo().length; i++) {
- if (viewModel.dataModel.ChartId() == ChartInfo()[i].ChartId()) {
- result = false;
- break;
- }
- else {
- result = true;
- }
- }
- if (result) {
- dfd.resolve(true);
- } else {
- dfd.resolve(false, '차트 ID가 중복되었습니다.');
- }
- return dfd.promise();
- },
-
- handleAfterLoadingModelByKey: function (data, dataViewModel, isNewInPopup) {
-
- viewModel.visibleDeleteButton(true);
- }
- });
- viewModel.isEditModeInPopup.subscribe(function (value) {
- viewModel.visibleDeleteButton(true);
- });
- {
- viewModel.popupInsertButtonOptions.visible = true;
- }
- viewModel.facilityTypes = facilityTypes;
- viewModel.palettes = palettes;
- viewModel.chartTypes = chartTypes;
- viewModel.formulaListByFacilityType = formulaListByFacilityType;
- viewModel.handleSelectBoxChangeFacilityType = function (e) {
-
-
-
-
- BWA.DataUtil.setArrayDataSourceFilterForChartSet(BemsFormulaBaseDataSource, 'FacilityTypeId', e.value, formulaListByFacilityType);
- var i = 0;
- }
- return viewModel;
- };
|