123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316 |
- BemsWebApplication.ControlValueSet = function (params, viewInfo) {
- "use strict";
- var deferredForSearch = new $.Deferred();
- var eq = BWA.DataUtil.constructEqualFilter,
- and = BWA.DataUtil.andFilter;
- var visiblePopup = ko.observable(false);
- var CurrentValueGet = new BWA.Chart.PointHistory_CurrentValueGet(BWA.UserInfo.SiteId());
-
-
-
-
- var fName = ko.observable();
- var Name = ko.observable();
- var Energy = ko.observable();
- var Type = ko.observable();
- var getValue = ko.observable(0);
- var setValue = ko.observable(0);
- var selData;
-
-
-
-
-
- var searchDeferred = new $.Deferred();
-
-
-
-
- var searchViewOptions = {
- searchViewItems: [
-
- { id: 'CmFacility/Name' },
- { id: 'Name' },
- ],
- promiseDataInSearchView: searchDeferred.promise()
- };
- var works = ko.observableArray();
-
- var workDataSource = BWA.DataUtil.createDataSource({
-
- dataSourceOptions: {
- select: ['SiteId', 'FacilityCode', 'CmFacility/Name', 'Name', 'BemsFuelType/Name', 'BemsServiceType/Name', 'FacilityTypeId', 'PropertyId'],
- expand: ['CmFacility', 'BemsFuelType', 'BemsServiceType'],
- extendOptions: {
- forceOriginalField: true,
- },
- filter: [
- ['FacilityCode', "<>", 0],
- ]
- },
- }, 'BemsMonitoringPoint');
- function handleSearchInSearchView(filter, searchViewItems) {
- var filterA = [];
- filterA.push(['FacilityCode', "<>", 0]);
-
- filterA.push([['ValueType', "=", 1], 'or', ['ValueType', "=", 3]]);
- _.each(filter, function (x) {
- filterA.push(x);
- });
- workDataSource.filter(filterA);
-
-
- workDataSource.load().done(function (workResult) {
-
- var param = {
- SiteId: BWA.UserInfo.SiteId(),
- };
- var promises = [];
- promises.push(CurrentValueGet.apiGet(_.extend(param, { ValueType: 0 })));
- $.when.apply(this, promises).done(function (c) {
- var i = 0;
- _.each(workResult, function (x) {
- x[6] = 'CV';
- x.CV = (c[i][0].Value == -9999) ? '' : c[i][0].Value;
- x[7] = 'SV';
- x.SV = (c[i][1].Value == -9999) ? '' : c[i][1].Value;
- i++;
-
-
- });
- works(workResult);
- }).fail(function (error) {
-
-
- });
-
-
-
- });
-
-
- }
- function handleViewShown () {
-
- handleSearchInSearchView();
- }
- function handleSearchViewInitializeUpdate() {
- }
- function refreshList() {
-
-
- }
- function handleViewShowing() {
-
-
- }
- function handleViewHidden() {
- $SearchView.visibleObservable(false);
-
- }
-
- var paramDate = new Date(2015,8,17, 15,0, 0);
-
-
-
- var viewModel = $.extend(BWA.CommonView.create(params, viewInfo, searchViewOptions, ko.observable(null), handleViewShown, null,
- handleSearchInSearchView, handleSearchViewInitializeUpdate), {
- refreshList: refreshList,
- viewShowing: handleViewShowing,
- viewHidden: handleViewHidden,
-
-
- workDataGridOptions: utils.datagrid.defaultOptions({
-
- rowClick: function (row) {
-
- selData = row.data;
-
-
-
-
-
- fName(row.values[1]);
- Name(row.values[2]);
- Energy(row.values[3]);
- Type(row.values[4]);
- getValue(row.values[5]);
- setValue(row.values[6]);
-
-
- visiblePopup(true);
- },
- rowAlternationEnabled: true,
-
- dataSource: works,
- columns: [
- { dataField: 'FacilityCode', caption: $G('number'), width: '4%', alignment: 'center' },
- { dataField: 'CmFacility/Name', caption: '설비명칭', width: '25%', alignment: 'center', allowEditing: false },
- { dataField: 'Name', caption: '관제점명', width: '25%', alignment: 'center', allowEditing: false },
- { dataField: 'BemsFuelType/Name', caption: '에너지원', width: '10%', alignment: 'center', allowEditing: false, },
- { dataField: 'BemsServiceType/Name', caption: '용도', width: '10%', alignment: 'center', allowEditing: false },
- { dataField: 'CV', caption: '현재값', width: '8%', alignment: 'center', },
- { dataField: 'SV', caption: '설정값', width: '8%', alignment: 'center', },
- ],
- }),
-
- setValue: function () {
-
- selData.SV = setValue();
- visiblePopup(false);
- var param;
- var promises = [];
- param = {
- SiteId: BWA.UserInfo.SiteId(),
- FacilityTypeId: selData.FacilityTypeId(),
- FacilityCode: selData.FacilityCode(),
- PropertyId: selData.PropertyId(),
- ControlValue: setValue(),
- };
- promises.push(BWA.api.post('BemsMonitoringPointHistory/ControlPoint', null, param));
- $.when.apply(this, promises).done(function () {
- utils.toast.show(Name() + ' 설정 완료');
- $('#gridContainer').dxDataGrid('instance').refresh();
- })
- },
- closePopUp: function () {
-
- visiblePopup(false);
- },
- });
- viewModel.popupOptions = {
- width: 420,
- height: 'auto',
- visible: visiblePopup,
- dragEnabled: false,
- shading: false,
- fName : fName,
- Name : Name,
- Energy : Energy,
- Type : Type,
- getValue: getValue,
- setValue: setValue,
-
- closeOnOutsideClick: false
- };
- return viewModel;
- };
|