123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152 |
- $(function () {
- 'use strict';
- BWA.Popup.PurchaseOrderSearch = BWA.Popup.PurchaseOrderSearch || {};
- BWA.Popup.PurchaseOrderSearch.create = function (viewModel, options) {
- options = options || {};
- options.datagridId = options.datagridId ||
- 'purchaseOrderDataGridForSearch';
- var onSelectedPurchaseOrder = options.onSelectedPurchaseOrder;
- var dataViewModel = new BemsWebApplication.FmsMaterialPurchaseOrderViewModel(),
- initialized = false,
- gridView,
- popupVisible = ko.observable(false),
- purchaseOrderFactory = BemsWebApplication.Factory.PurchaseOrder,
- dataSource = BWA.DataUtil.createDataSource({
- dataSourceOptions: purchaseOrderFactory.getDataSourceForDataGrid()
- }, 'FmsMaterialPurchaseOrder');
- options.filter.push('and');
- options.filter.push(['FmsMaterialPurchaseRequest/ProgressId', '=', 3]);
- dataSource.filter(options.filter);
- var dataGridOptions = utils.datagrid.defaultOptions({
- dxDataSource: dataSource,
- selectedSourceItem: dataViewModel,
- datagridId: options.datagridId,
- dbId: 'FmsPurchaseOrder',
- handleDataGridRowClick: function () {
- },
- columns: purchaseOrderFactory.getColumns([
- { dataField: 'PurchaseOrderId', width: '15%' },
- { dataField: 'OrderDate', width: '20%' },
- { dataField: 'Title', width: '60%' },
- { dataField: 'CmUser/Name', caption: '발주자명', width: '15%' }
- ]),
- height: 560,
- paging: {
- pageSize: 15,
- enabled: true
- },
- pager: {
- allowedPageSizes: false,
- visible: true
- },
- wordWrapEnabled: true
- });
- dataGridOptions.handleDataGridRowClick = function (id, dataGrid, clickRow) {
- var data = clickRow.data;
- if (!_.isUndefined(onSelectedPurchaseOrder)) {
- onSelectedPurchaseOrder({
- SiteId: data.SiteId(),
- BusinessFieldId: data.BusinessFieldId(),
- PurchaseOrderId: data.PurchaseOrderId(),
- Title: data.Title(),
- Reason: data.Reason() // hcLee 2016 01 11
- });
- }
- popupVisible(false);
- };
- function handlePopupShown() {
- if (initialized === false) {
- gridView = $('#purchaseOrderDataGridForSearch').dxDataGrid('instance');
- initialized = true;
- }
- gridView.refresh();
- // refreshList();
- searchView.show();
- }
- function handlePopupButtonClose() {
- popupVisible(false);
- }
- var toolbarItems = [
- { location: 'before', text: '발주등록 선택' },
- { location: 'after', widget: 'button', options: { text: $G('close'), icon: 'close', clickAction: handlePopupButtonClose } }
- ];
- var popupOptions = {
- width: '680px',
- height: '600px',
- visible: popupVisible,
- closeOnOutsideClick: true,
- //showingAction: handlePopupShowing,
- shownAction: handlePopupShown,
- animation: window.utils.popup.createAnimation(),
- };
- var searchView = BWA.Popup.SearchView.create({
- parentPopupId: 'popupSearchPurchaseOrder',
- parentPopupVisible: popupVisible,
- searchItems: [
- { id: 'OrderDate', type: 'dateRange', isOnlyDate: true },
- { id: 'Title' },
- { id: 'CmUser/Name' },
- { id: 'FmsMaterial/Name', filterFormatString: 'FmsMaterialPurchaseOrderMaterial/any(c: substringof(\'{0}\', c/FmsMaterial/Name))', type: 'formatting' },
- ],
- handleInitializeUpdate: function () {
- },
- handleSearch: function (filter, searchItems) {
- var eq = BWA.DataUtil.constructEqualFilter;
- var and = BWA.DataUtil.andFilter;
- filter = [
- eq('SiteId', BWA.UserInfo.SiteId()),
- and,
- ['FmsMaterialPurchaseRequest/ProgressId', '=', 3]
- ].concat(filter);
- gridView.filter(filter);
- // console.log(filter);
- }
- });
- return {
- dataModel: dataViewModel,
- dataSource: dataSource,
- popupOptions: popupOptions,
- toolbarItems: toolbarItems,
- dataGridOptions: dataGridOptions,
- searchView: searchView,
- show: function () {
- popupVisible(true);
- }
- };
- };
- });
|