123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193 |
- $(function () {
- 'use strict';
- var eq = BWA.DataUtil.constructEqualFilter,
- and = BWA.DataUtil.andFilter;
-
- var visible = ko.observable(false),
- newInfo = ko.observable(false);
- var userDataSource = BWA.DataUtil.createDataSource({
- dataSourceOptions: {
- select: ['SiteId', 'CompanyId', 'DepartmentId', 'UserId', 'Name', 'EmploymentType', 'Email', 'MobilePhoneNo', 'EmploymentStatus', 'CmPosition/Name', 'CmDepartment/Name', 'CmCompany/Name'],
- expand: ["CmPosition", "CmDepartment", "CmCompany"],
- extendOptions: {
- alterNames: {
- 'CmPosition/Name': 'PositionName',
- 'CmDepartment/Name': 'DepartmentName',
- 'CmCompany/Name': 'CompanyName'
- }
- }
- }
- }, 'CmUser'),
- userInfo = {
- SiteId: ko.observable(),
- UserId: ko.observable(),
- Name: ko.observable(),
- CompanyName: ko.observable(),
- PositionName: ko.observable(),
- DepartmentName: ko.observable(),
- MobilePhoneNo: ko.observable(),
- Email: ko.observable()
- };
- /*
- var facilityClassDataSource = BemsWebApplication.db.createDataSource('FmsFacilityCodeClass');
- var buildingDataSource = BemsWebApplication.db.createDataSource('CmBuilding', true),
- floorDataSource = BemsWebApplication.db.createDataSource('CmFloor'),
- zoneDataSource = BemsWebApplication.db.createDataSource('CmZone');
- // 설비분류 데이터소스
- var facilityTypeDataSource = BemsWebApplication.db.createDataSource('BemsFacilityType');
- var facilityTypes = ko.observableArray();
- var facilityClasses = [ko.observableArray(), ko.observableArray(), ko.observableArray()];
- var buildings = ko.observableArray(),
- floors = ko.observableArray(),
- zones = ko.observableArray();
- */
- var workDataSource = BWA.DataUtil.createDataSource({
- dataSourceOptions: {
- select: ['SiteId', 'CmFacility/FacilityTypeId', 'FacilityCode', 'CmFacility/Name', 'T1', 'T2', 'T3', 'T4', 'T5', 'T6', 'T7', 'T8', 'T9', 'T10', 'T11', 'T12'],
- expand: ['CmFacility'],
- extendOptions: {
- forceOriginalField: true
- },
- //filter: [
- // eq('SiteId', BWA.UserInfo.SiteId()),
- // and,
- // ['FmsWorkRequest/WorkProgressId', '=', $Code.WorkProgress.WORKING] // 4
- // //, and, ['FmsWorkRequest/WorkProgressId', '<=', 5]
- //]
- }
- }, 'CmFacilityTempSet');
- var works = ko.observableArray();
- var datas;
- BWA.ControlPanel = {
- newInfo: newInfo,
- UserInfo: userInfo,
- workDataGridOptions: utils.datagrid.defaultOptions({
- dataSource: works,
- rowAlternationEnabled: true,
- handleDataGridRowClick: function (rowdata) {
- alert();
- },
- editing: {
- editMode: 'cell', // 14.1은 batch, row 두가지 밖에 없다. cell->row로 동작중이다. 2015 07 15 hcLee
- editEnabled: true,
- },
- columns: [
- //{ dataField: 'FacilityCode', caption: $G('number'), width: '14%', alignment: 'center' }, // ?
- { dataField: 'FacilityCode', caption: '설비코드', width: '14%', alignment: 'center' }, // ? 2015 07 30 왜 1,2,3 번호가 안나올까? utils.datagrid.defaultOptions 으로 생성했는데.....
- { dataField: 'CmFacility/Name', caption: '공조기명', width: '50%', alignment: 'center', allowEditing: false },
- { dataField: 'TN', caption: '이달의 설정온도', width: '18%', alignment: 'center' },
- ],
- //height: 220
- }),
- /*
- notificationDataGridOptions: utils.datagrid.defaultOptions({
- //dxDataSource: announcements,
- dataSource: announcements,
- handleDataGridRowClick: function () {
- },
- columns: [
- { dataField: 'AnnouncementId', caption: $G('number'), width: '15%', alignment: 'center', sortOrder: 'desc' },
- { dataField: 'Title', caption: '제목', width: '40%', alignment: 'center' },
- ],
- height: 220,
- }),*/
- options: {
- width: '1400',
- //height: '670',
- height: '700',
- visible: visible,
- position: { my: 'top', at: 'top', of: window },
- animation: {
- show: { type: "slide", easing: 'ease-in-out', duration: 400, from: { top: -649 }, to: { top: 0 } },
- hide: { type: "slide", easing: 'ease-in-out', duration: 400, from: { top: 1 }, to: { top: -649 } }
- },
- showingAction: function () {
- userDataSource.filter([
- eq('SiteId', BWA.UserInfo.SiteId()),
- and,
- eq('UserId', BWA.UserInfo.UserId())
- ]);
- userDataSource.load().done(function(users) {
- if (_.isEmpty(users)) {
- return; // logout 처리 필요
- }
- BWA.DataUtil.copyViewModel(users[0], userInfo);
- });
- var now = new Date();
- workDataSource.load().done(function (workResult) {
- _.each(workResult, function(x) {
- x[15] = 'TN';
- x.TN = BWA.Bems.refineGetMonthAirTempSetValue(now.getMonth(), x);
- });
- datas = workResult;
- works(workResult);
- });
- },
- contentReadyAction: function(e) {
- },
- shading: false,
- closeOnOutsideClick: true
- },
- handleControl: function () {
- var param;
- var promises = [];
- _.each(BWA.ControlPanel.workDataGridOptions.dataSource(), function (x) {
- //alert(x.TN());
- //alert(x.FacilityCode());
- //alert(x["CmFacility/Name"]());
- var v = (jQuery.isFunction(x.TN)) ? x.TN() : x.TN;
- param = {
- SiteId: BWA.UserInfo.SiteId(),
- FacilityTypeId: x["CmFacility/FacilityTypeId"](),
- FacilityCode: x.FacilityCode(),
- FormulaId: $Code.Formula[$Code.FacilityType.AIR_HANDLING].TEMP_SET,
- //ControlValue: x.TN(),
- //ControlValue: 100,
- ControlValue: (jQuery.isFunction(x.TN)) ? x.TN() : x.TN,
- };
- promises.push(BWA.api.post('BemsFormula/ControlPoint', null, param));
- //BWA.api.post('BemsFormula/ControlPoint', null, param).done(function () {
- // utils.toast.show('온도제어 완료');
- //});
- });
- $.when.apply(this, promises).done(function () {
- utils.toast.show('온도제어 완료');
- })
- },
- handleToggleOpenClose: function() {
- visible(!visible());
- },
- show: function() {
- visible(true);
- },
- hide: function() {
- visible(false);
- },
-
- };
- });
|