123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841 |
- $(function () {
- 'use strict';
- // viewModel 을 가져오지 못해서 임의로 객체 선언후 할당
- var fmsmaterialsDataSource = BemsWebApplication.db.createDataSource('FmsMaterial', true, true, true);
- var eq = BWA.DataUtil.constructEqualFilter, and = BWA.DataUtil.andFilter, noteq = BWA.DataUtil.constructNotEqualFilter;
- var endpointSelector = "";
- if (BemsWebApplication.config.mode == "production") {
- endpointSelector = new DevExpress.EndpointSelector(BemsWebApplication.config.endpoints).config.db.production;
- } else {
- endpointSelector = new DevExpress.EndpointSelector(BemsWebApplication.config.endpoints).config.db.local;
- }
- BemsWebApplication.Popup.AddWorkResultCheckItem = {
- create: function (viewInfo, viewModel, refreshListData) {
- var dataModel = null;
- var IsWorkDone = ko.observable(false);
- var IsWorkHold = ko.observable(false);
- var tempViewModel = viewModel;
- var materials = ko.observableArray();
- var materialsEx = ko.observableArray();
- var materialFactory = BWA.Factory.Material;
- var materialGridView;
- var materialColumns = materialFactory.getColumns([
- { dataField: 'MaterialCode', width: '30%' },
- { dataField: 'Name', width: '40%' },
- { dataField: 'Standard', width: '40%' }
- ]);
- var usedMaterialsDataSource = BemsWebApplication.db.createDataSource('FmsWorkResultCheckItemMaterial', true, true, true);
- var facilityTypeDataSource = BemsWebApplication.db.createDataSource('BemsFacilityType'),
- facilityTypes = ko.observableArray(),
- isNew = ko.observable(false),
- MaterialExdataSource = ko.observableArray(),
- popupVisible = ko.observable(),
- isEditMode = ko.observable(false),
- isViewMode = ko.observable(true),
- cancelButtonVisible = ko.observable(true),
- // facilityDataModel = new BWA.CmFacilityViewModel(),
- workCheckItemViewModel = new BemsWebApplication.FmsWorkResultCheckItemViewModel();
- workCheckItemViewModel.IsWorkDone = ko.observable(false);
- workCheckItemViewModel.IsWorkHold = ko.observable(false);
- workCheckItemViewModel.IsdateboxCheckDate = ko.observable();
- workCheckItemViewModel.AttachmentFileName1 = ko.observable();
- workCheckItemViewModel.AttachmentFileName2 = ko.observable();
- // 2018 01 29 -->
- var FileEdit = ko.observable(false);
- var FileView = ko.observable(false);
- // <-- 2018 01 29
- var popupOptions = {
- width: '998px',
- height: 'auto',
- //shading: false,
- shadingColor: 'rgba(0,0,0,0.0)',
- visible: popupVisible,
- closeOnOutsideClick: false,
- animation: utils.popup.createAnimation(),
- shownAction: handleViewShown,
- showingAction: handlePopupShowing,
- hiddenAction: handlePopuphidden,
- },
- toolbarItems = [
- { location: 'before', text: $G('detailInfo') },
- // hcLee 2018 01 29 -->
- {
- location: 'after', widget: 'button',
- options: {
- text: '사진수정', icon: 'edit', visible: FileEdit,
- clickAction: function () {
- if (viewModel.isAddHistoryButton() == false) {
- FileView(false);
- FileEdit(false);
- }
- else {
- FileView(true);
- FileEdit(false);
- isEditMode(!isEditMode());
- }
- }
- }
- },
- {
- location: 'after', widget: 'button',
- options: {
- //text: '사진보기', icon: 'edit', visible: isEditMode() ? true : false,
- text: '사진보기', icon: 'edit', visible: FileView,
- clickAction: function () {
- if (viewModel.isAddHistoryButton() == false) {
- FileView(false);
- FileEdit(false);
- }
- else {
- FileView(false);
- FileEdit(true);
- isEditMode(!isEditMode());
- setdownLoadUrl();
- }
- }
- }
- },
- // <-- hcLee 2018 01 29
- {
- location: 'after', widget: 'button',
- options: {
- text: $G('materialInsertion'), icon: 'search', visible: viewModel.isAddHistoryButton,
- clickAction: function () {
- viewModel.isAddPopup(true);
- viewModel.materialSearchPopup.show();
- }
- }
- },
- {
- location: 'after', widget: 'button',
- options: {
- text: $G('materialDeletion'), icon: 'remove', type: 'danger', visible: viewModel.isAddHistoryButton,
- clickAction: function () { handleDeleteSelectedMaterials(); }
- }
- },
- {
- location: 'after', widget: 'button',
- options: {
- text: $G('edit'), icon: 'edit', visible: viewModel.isEditHistoryButton,
- clickAction: handlePopupButtonEdit
- }
- },
- {
- location: 'after', widget: 'button',
- options: {
- text: $G('save'), icon: 'save', visible: viewModel.isAddHistoryButton,
- clickAction: handlePopupButtonSave
- }
- },
- { location: 'after', widget: 'button', options: { text: $G('close'), icon: 'close', clickAction: handlePopupButtonClose } }
- ],
- modifiableMaterialDataGridOptions = utils.datagrid.defaultOptions({
- width: 500,
- pager: {
- showPageSizeSelector: false,
- allowedPageSizes: []
- },
- dataSource: materials,
- selection: { mode: 'multiple', allowSelectAll: true },
- columns: materialColumns.concat([{
- dataField: 'MaterialCount', width: '20%', type: 'number',
- caption: $G('materialCount'), alignment: 'center',
- cellTemplate: utils.datagrid.getNumberBoxDataGridTemplateFunc({
- min: 0,
- max: 1000000,
- dataField: 'MaterialCount',
- convertValueWhenValueChanged: function (value) {
- return Math.max(1, value);
- }
- })
- }]),
- cellClick: function (e) {
- utils.datagrid.cellClickEventForDataGridTemplate(e, 'MaterialCount');
- },
- contentReadyAction: function (e) {
- materialGridView = e.component;
- },
- });
- isEditMode.subscribe(function (isEdit) {
- isViewMode(!isEdit);
- });
- popupVisible.subscribe(function (value) {
- if (!value) {
- materials([]);
- }
- });
- viewModel.materialSearchPopup = BWA.Popup.Material.create(viewModel, {
- // TODO : 입고수량이 0 이상인 것을 필터링할 필요는 없는지 확인필요
- isMultipleSelect: true,
- onSelectedMaterials: function (selectedMaterials) {
- if (viewModel.isAddPopup()) {
- _.each(selectedMaterials, function (sm) {
- // 어차피 SiteId와 BusinessField는 동일 할 수 밖에 없으므로 비교하지 않는다.
- var found = _.some(materials(), function (m) {
- return (typeof (m.MaterialId) == "function" ? m.MaterialId() : m.MaterialId) === (typeof (sm.MaterialId) == "function" ? sm.MaterialId() : sm.MaterialId);
- });
- if (found) return;
- if ((typeof (sm.StockCount) == "function" ? sm.StockCount() : sm.StockCount) > 0) {
- materials.push({
- SiteId: sm.SiteId,
- MaterialId: sm.MaterialId,
- Name: sm.Name,
- MaterialCode: sm.MaterialCode,
- MaterialCount: ko.observable(1),
- FinalPrice: sm.FinalPrice,
- MaxMaterialCount: sm.StockCount,
- Standard: sm.Standard
- });
- } else {
- utils.toast.show('재고가 없는 항목은 선택할 수 없습니다.', 'warning');
- }
- });
- materialGridView.refresh();
- }
- else if (viewModel.isApprovalMode()) {
- _.each(selectedMaterials, function (sm) {
- // 어차피 SiteId와 BusinessField는 동일 할 수 밖에 없으므로 비교하지 않는다.
- var found = _.some(viewModel.workResultCheckItemMaterialPopup.materials2(), function (m) {
- return (typeof (m.MaterialId) == "function" ? m.MaterialId() : m.MaterialId) === (typeof (sm.MaterialId) == "function" ? sm.MaterialId() : sm.MaterialId);
- });
- if (found) return;
- viewModel.workResultCheckItemMaterialPopup.materials2.push({
- SiteId: sm.SiteId,
- MaterialId: sm.MaterialId,
- Name: sm.Name,
- MaterialCode: sm.MaterialCode,
- MaterialCount: ko.observable(1),
- FinalPrice: sm.FinalPrice,
- MaxMaterialCount: sm.StockCount,
- Standard: sm.Standard
- });
- });
- viewModel.workResultCheckItemMaterialPopup.materialGridView2().refresh();
- }
- }
- });
- function handleDeleteSelectedMaterials() {
- var rows = materialGridView.getSelectedRowsData();
- if (_.isEmpty(rows)) {
- utils.toast.show('선택된 자재가 없습니다.', 'error');
- return;
- }
- _.each(rows, function (row) {
- var array = materials();
- var length = array.length;
- var id = row.MaterialId();
- for (var i = 0 ; i < length ; i++) {
- if (id === array[i].MaterialId()) {
- materials().splice(i, 1);
- break;
- }
- }
- });
- materialGridView.refresh();
- }
- function handlePopupButtonEdit() {
- viewModel.isEditHistoryButton(!viewModel.isEditHistoryButton);
- viewModel.isAddHistoryButton(true);
- FileView(true);
- isEditMode(true);
- }
- function handlePopupButtonClose() {
- isEditMode(false); // hcLee 2018 01 29
- viewModel.isAddHistoryButton(true);
- //viewModel.isAddHistoryButton(true);//2019.08.26
- popupVisible(false);
- }
- function refreshList() {
- }
- function getDoneFunc(messageId) {
- return function () {
- refreshList();
- popupVisible(false);
- utils.toast.show($G(messageId));
- };
- }
- function handlePopupButtonSave() {
- viewModel.isAddHistoryButton(true);
- if (workCheckItemViewModel.TextResult() === "") {
- utils.toast.show('작업내용을 입력하세요.', 'error');
- return;
- }
- workCheckItemViewModel.SiteId(tempViewModel.dataModel.SiteId());
- workCheckItemViewModel.WorkRequestId(tempViewModel.dataModel.WorkRequestId());
- if (isNew()) {
- BWA.db.FmsWorkResultCheckItem.insert({
- SiteId: workCheckItemViewModel.SiteId(),
- WorkRequestId: workCheckItemViewModel.WorkRequestId(),
- FacilityCode: workCheckItemViewModel.FacilityCode(),
- CheckItemId: workCheckItemViewModel.CheckItemId(),
- BoolResult: workCheckItemViewModel.BoolResult(),
- TextResult: workCheckItemViewModel.TextResult(),
- CheckDate: workCheckItemViewModel.CheckDate(),
- FileId1: workCheckItemViewModel.FileId1(),
- FileId2: workCheckItemViewModel.FileId2(),
- }
- ).done(function (response, responseKey) {
- ///////////////////////2019-11-19 변경
- if (responseKey.CheckItemId != null)
- workCheckItemViewModel.CheckItemId(responseKey.CheckItemId);
- if (_.isNull(viewModel.dropZone1) === false) { //추가
- if (workCheckItemViewModel.FileId1() == null) {
- viewModel.dropZone1.processQueue();
- refreshListData();
- }
- }
- if (_.isNull(viewModel.dropZone2) === false) { //추가
- if (workCheckItemViewModel.FileId2() == null) {
- viewModel.dropZone2.processQueue();
- refreshListData();
- }
- }
- ///////////////////////2019-11-19 변경
- // 작업을 완료처리 할 경우
- if (workCheckItemViewModel.IsWorkDone()) {
- var parameters = {
- SiteId: workCheckItemViewModel.SiteId(),
- WorkRequestId: workCheckItemViewModel.WorkRequestId(),
- WorkProgressId: $Code.WorkProgress.WORK_COMPLETE,
- UserId: BWA.UserInfo.UserId()
- };
- //fmsreesult enddate 변경
- var store = new DevExpress.data.ODataStore({
- url: endpointSelector + "/FmsWorkResult",
- key: ["SiteId", "WorkRequestId"],
- keyType: { SiteId: "Int32", WorkRequestId: "Int32" }
- });
- store.update({ SiteId: workCheckItemViewModel.SiteId(), WorkRequestId: workCheckItemViewModel.WorkRequestId() },
- {
- EndDate: workCheckItemViewModel.IsdateboxCheckDate()
- }).done(function (values, key) {
- // FmsWorkRequest 업데이트: WorkProgressId(5)
- BWA.api.post('FmsWorkRequest', null, parameters).done(function () {
- tempViewModel.dataModel.WorkProgressName('작업완료');
- var array = materials();
- if (array.length != 0) {
- var postData;
- var parameters2 = {
- SiteId: workCheckItemViewModel.SiteId(),
- BusinessFieldId: tempViewModel.dataModel.BusinessFieldId(),
- WorkRequestId: workCheckItemViewModel.WorkRequestId(),
- CheckItemId: responseKey.CheckItemId
- };
- postData = _.map(array, function (m) {
- return {
- SiteId: workCheckItemViewModel.SiteId(),
- WorkRequestId: workCheckItemViewModel.WorkRequestId(),
- MaterialId: m.MaterialId(),
- MaterialCount: m.MaterialCount(),
- CheckItemId: responseKey.CheckItemId,
- MaterialCode: m.MaterialCode(),
- Name: m.Name()
- };
- });
- // FmsWorkResultCheckItemMaterial 에 저장해야 함
- BWA.api.post('FmsWorkResultCheckItemMaterial/Update', postData, parameters2).done(function () {
- utils.toast.show($G('successDatabaseInsertionMsg'));
- materials([]);
- isEditMode(false);
- popupVisible(false);
- refreshListData(); // hcLee 2018 01 29
- // hcLee 2016 05 30
- viewModel.workResultCheckItemMaterialPopup.refreshMaterialGrid();
- // 작업이력버튼 표시 안함
- viewModel.isAddHistoryButton(false);
- viewModel.popupVisible(false); // 작업완료는 화면 닫음
- });
- }
- else {
- utils.toast.show($G('successDatabaseInsertionMsg'));
- isEditMode(false);
- refreshListData(); // hcLee 2018 01 29
- popupVisible(false);
- // 작업이력버튼 표시 안함
- viewModel.isAddHistoryButton(false);
- viewModel.popupVisible(false); // 작업완료는 화면 닫음
- }
- utils.toast.show($G('successDatabaseUpdateMsg'));
- workCheckItemViewModel.CheckDate('');
- workCheckItemViewModel.TextResult('');
- workCheckItemViewModel.IsWorkDone(false);
- refreshListData(); // hcLee 2018 01 29
- viewModel.popupVisible(false); // 작업완료는 화면 닫음
- });
- })
- .fail(function (error) {
- utils.toast.show(error);
- });
- }
- else if (workCheckItemViewModel.IsWorkHold()) {
- var parameters = {
- SiteId: workCheckItemViewModel.SiteId(),
- WorkRequestId: workCheckItemViewModel.WorkRequestId(),
- WorkProgressId: $Code.WorkProgress.WORK_HOLD,
- UserId: BWA.UserInfo.UserId()
- };
- // FmsWorkRequest 업데이트: WorkProgressId(5)
- BWA.api.post('FmsWorkRequest', null, parameters).done(function () {
- tempViewModel.dataModel.WorkProgressName('작업보류');
- var array = materials();
- if (array.length != 0) {
- var postData;
- var parameters2 = {
- SiteId: workCheckItemViewModel.SiteId(),
- BusinessFieldId: tempViewModel.dataModel.BusinessFieldId(),
- WorkRequestId: workCheckItemViewModel.WorkRequestId(),
- CheckItemId: responseKey.CheckItemId
- };
- postData = _.map(array, function (m) {
- return {
- SiteId: workCheckItemViewModel.SiteId(),
- WorkRequestId: workCheckItemViewModel.WorkRequestId(),
- MaterialId: m.MaterialId(),
- MaterialCount: m.MaterialCount(),
- CheckItemId: responseKey.CheckItemId,
- MaterialCode: m.MaterialCode(),
- Name: m.Name()
- };
- });
- // FmsWorkResultCheckItemMaterial 에 저장해야 함
- BWA.api.post('FmsWorkResultCheckItemMaterial/Update', postData, parameters2).done(function () {
- utils.toast.show($G('successDatabaseInsertionMsg'));
- isEditMode(false);
- materials([]);
- refreshListData(); // hcLee 2018 01 29
- popupVisible(false);
- // hcLee 2016 05 30
- viewModel.workResultCheckItemMaterialPopup.refreshMaterialGrid();
- });
- }
- else {
- utils.toast.show($G('successDatabaseInsertionMsg'));
- isEditMode(false);
- refreshListData(); // hcLee 2018 01 29
- popupVisible(false);
- }
- viewModel.popupVisible(false);
- });
- }
- else {
- var array = materials();
- if (array.length != 0) {
- var postData;
- var parameters2 = {
- SiteId: workCheckItemViewModel.SiteId(),
- BusinessFieldId: tempViewModel.dataModel.BusinessFieldId(),
- WorkRequestId: workCheckItemViewModel.WorkRequestId(),
- CheckItemId: responseKey.CheckItemId
- };
- postData = _.map(array, function (m) {
- return {
- SiteId: workCheckItemViewModel.SiteId(),
- WorkRequestId: workCheckItemViewModel.WorkRequestId(),
- MaterialId: (typeof (m.MaterialId) == "function" ? m.MaterialId() : m.MaterialId),
- MaterialCount: m.MaterialCount(),
- CheckItemId: responseKey.CheckItemId,
- MaterialCode: (typeof (m.MaterialCode) == "function" ? m.MaterialCode() : m.MaterialCode),
- Name: (typeof (m.Name) == "function" ? m.Name() : m.Name)
- };
- });
- // FmsWorkResultCheckItemMaterial 에 저장해야 함
- BWA.api.post('FmsWorkResultCheckItemMaterial/Update', postData, parameters2).done(function () {
- utils.toast.show($G('successDatabaseInsertionMsg'));
- isEditMode(false);
- materials([]);
- refreshListData(); // hcLee 2018 01 29
- popupVisible(false);
- viewModel.workResultCheckItemMaterialPopup.refreshMaterialGrid();
- });
- }
- else {
- utils.toast.show($G('successDatabaseInsertionMsg'));
- isEditMode(false);
- refreshListData(); // hcLee 2018 01 29
- popupVisible(false);
- }
- }
- });
- }
- else { // 수정? hcLee 2015 12 28
- var keys = BWA.db.extractKeysObject('FmsWorkResultCheckItem', workCheckItemViewModel);
- BWA.db.FmsWorkResultCheckItem.update(keys,
- {
- SiteId: workCheckItemViewModel.SiteId(),
- WorkRequestId: workCheckItemViewModel.WorkRequestId(),
- FacilityCode: workCheckItemViewModel.FacilityCode(),
- CheckItemId: workCheckItemViewModel.CheckItemId(),
- BoolResult: workCheckItemViewModel.BoolResult(),
- TextResult: workCheckItemViewModel.TextResult(),
- CheckDate: workCheckItemViewModel.CheckDate(),
- FileId1: workCheckItemViewModel.FileId1(),
- FileId2: workCheckItemViewModel.FileId2(),
- }).done(function (res) {
- ///////////////////////2019-11-19 변경
- if (res.CheckItemId != null)
- workCheckItemViewModel.CheckItemId(res.CheckItemId);
- if (_.isNull(viewModel.dropZone1) === false) {
- if (workCheckItemViewModel.FileId1() != null) { //변경 - 그림삭제
- var temp = {
- SiteId: BWA.UserInfo.SiteId(),
- FileId: workCheckItemViewModel.FileId1()
- }
- BWA.db.CmFile.byKey(temp).done(function (data) {
- viewModel.dropZone1.removeFile(data);
- viewModel.dropZone1.processQueue();
- refreshListData();
- });
- }
- else {
- viewModel.dropZone1.processQueue();//변경 - 그림 삭제 필요없음
- refreshListData();
- }
- }
- if (_.isNull(viewModel.dropZone2) === false) {
- if (workCheckItemViewModel.FileId2() != null) { //변경 - 그림삭제
- var temp = {
- SiteId: BWA.UserInfo.SiteId(),
- FileId: workCheckItemViewModel.FileId2()
- }
- BWA.db.CmFile.byKey(temp).done(function (data) {
- viewModel.dropZone2.removeFile(data);
- viewModel.dropZone2.processQueue();
- refreshListData();
- });
- }
- else {
- viewModel.dropZone2.processQueue();//변경 - 그림 삭제 필요없음
- refreshListData();
- }
- }
- ///////////////////////2019-11-19 변경
- // 작업을 완료처리 할 경우
- if (workCheckItemViewModel.IsWorkDone()) {
- var parameters = {
- SiteId: workCheckItemViewModel.SiteId(),
- WorkRequestId: workCheckItemViewModel.WorkRequestId(),
- WorkProgressId: $Code.WorkProgress.WORK_COMPLETE,
- UserId: BWA.UserInfo.UserId()
- };
- // FmsWorkRequest 업데이트: WorkProgressId(5)
- BWA.api.post('FmsWorkRequest', null, parameters).done(function () {
- var array = materials();
- //if (array.length != 0) {
- var postData;
- var parameters2 = {
- SiteId: workCheckItemViewModel.SiteId(),
- BusinessFieldId: tempViewModel.dataModel.BusinessFieldId(),
- WorkRequestId: workCheckItemViewModel.WorkRequestId(),
- CheckItemId: workCheckItemViewModel.CheckItemId()
- };
- postData = _.map(array, function (m) {
- return {
- SiteId: workCheckItemViewModel.SiteId(),
- WorkRequestId: workCheckItemViewModel.WorkRequestId(),
- MaterialId: (typeof (m.MaterialId) == "function" ? m.MaterialId() : m.MaterialId),
- MaterialCount: m.MaterialCount(),
- CheckItemId: workCheckItemViewModel.CheckItemId(),
- MaterialCode: (typeof (m.MaterialCode) == "function" ? m.MaterialCode() : m.MaterialCode),
- Name: (typeof (m.Name) == "function" ? m.Name() : m.Name)
- };
- });
- // FmsWorkResultCheckItemMaterial 에 저장해야 함
- BWA.api.post('FmsWorkResultCheckItemMaterial/Update', postData, parameters2).done(function () {
- utils.toast.show($G('successDatabaseInsertionMsg'));
- isEditMode(false);
- materials([]);
- refreshListData(); // hcLee 2018 01 29
- popupVisible(false);
- // 작업이력버튼 표시 안함
- viewModel.isAddHistoryButton(false);
- // hcLee 2016 05 30
- viewModel.workResultCheckItemMaterialPopup.refreshMaterialGrid();
- });
- //}
- //else {
- // utils.toast.show($G('successDatabaseInsertionMsg'));
- // refreshListData(); // hcLee 2018 01 29
- // popupVisible(false);
- // // 작업이력버튼 표시 안함
- // viewModel.isAddHistoryButton(false);
- //}
- utils.toast.show($G('successDatabaseUpdateMsg'));
- workCheckItemViewModel.CheckDate('');
- workCheckItemViewModel.TextResult('');
- workCheckItemViewModel.IsWorkDone(false);
- });
- }
- else {
- var array = materials();
- var postData;
- var parameters2 = {
- SiteId: workCheckItemViewModel.SiteId(),
- BusinessFieldId: tempViewModel.dataModel.BusinessFieldId(),
- WorkRequestId: workCheckItemViewModel.WorkRequestId(),
- CheckItemId: workCheckItemViewModel.CheckItemId()
- };
- postData = _.map(array, function (m) {
- return {
- SiteId: workCheckItemViewModel.SiteId(),
- WorkRequestId: workCheckItemViewModel.WorkRequestId(),
- MaterialId: m.MaterialId(),
- MaterialCount: m.MaterialCount(),
- CheckItemId: workCheckItemViewModel.CheckItemId(),
- MaterialCode: m.MaterialCode(),
- Name: m.Name()
- };
- });
- // FmsWorkResultCheckItemMaterial 에 저장해야 함
- BWA.api.post('FmsWorkResultCheckItemMaterial/Update', postData, parameters2).done(function () {
- isEditMode(false);
- utils.toast.show($G('successDatabaseInsertionMsg'));
- materials([]);
- refreshListData(); // hcLee 2018 01 29
- popupVisible(false);
- // hcLee 2016 05 30
- viewModel.workResultCheckItemMaterialPopup.refreshMaterialGrid();
- });
- }
- });
- }
- }
- function handleViewShowing() {
- viewModel.imagefileUrl1(null);
- viewModel.imagefileUrl2(null);
- }
- function handleViewShown() {
- if (!isNew()) {
- // hcLee 2018 01 29 -->
- if (viewModel.isAddHistoryButton() == false) {
- FileView(false);
- FileEdit(false);
- }
- else {
- FileView(false);
- FileEdit(true);
- }
- isEditMode(false);
- // <-- hcLee 2018 01 29
- // 중요 !!! hcLee 2015 12 29
- usedMaterialsDataSource.filter([
- eq('SiteId', workCheckItemViewModel.SiteId()),
- and,
- eq('WorkRequestId', workCheckItemViewModel.WorkRequestId()),
- and,
- eq('CheckItemId', workCheckItemViewModel.CheckItemId())
- ]);
- //////////////
- fmsmaterialsDataSource.filter([
- eq('SiteId', viewModel.dataModel.SiteId())
- ]);
- var fmsMaterialsdata;
- fmsmaterialsDataSource.load().done(function (fmsMaterials) {
- fmsMaterialsdata = fmsMaterials;
- usedMaterialsDataSource.load().done(function (dbMaterials) {
- _.each(dbMaterials, function (sm) {
- var standard = "";
- var StockCount = null;
- for (var i = 0; i < fmsMaterialsdata.length ; i++) {
- if (sm.MaterialId() == fmsMaterialsdata[i].MaterialId()) {
- standard = fmsMaterialsdata[i].Standard();
- if (standard == null)
- standard = ""
- break;
- }
- }
- if (viewModel.dataModel.MaterialExdataSource() != null)
- MaterialExdataSource(viewModel.dataModel.MaterialExdataSource())
- if (MaterialExdataSource() !== null) {
- for (var i = 0; i < MaterialExdataSource().length; i++) {
- if (sm.MaterialId() == MaterialExdataSource()[i].MaterialId) {
- StockCount = MaterialExdataSource()[i].StockCount;
- break;
- }
- }
- }
- if (StockCount == null) {
- materials.push({
- SiteId: sm.SiteId,
- MaterialId: sm.MaterialId,
- Name: sm.Name,
- MaterialCode: sm.MaterialCode,
- MaterialCount: sm.MaterialCount,
- Standard: standard,
- });
- } else {
- materials.push({
- SiteId: sm.SiteId,
- MaterialId: sm.MaterialId,
- Name: sm.Name,
- MaterialCode: sm.MaterialCode,
- MaterialCount: sm.MaterialCount,
- MaxMaterialCount: StockCount,
- Standard: standard,
- });
- }
- });
- materialGridView.refresh();
- //viewModel.workResultCheckItemMaterialPopup.materialGridView2().refresh();
- });
- setdownLoadUrl();
- });
- }// hcLee 2018 01 29 -->
- else { // 새이력
- viewModel.imagefileUrl1(null);
- viewModel.imagefileUrl2(null);
- if (viewModel.isAddHistoryButton() == false) {
- FileView(false);
- FileEdit(false);
- isEditMode(false);
- }
- else {
- FileView(true);
- FileEdit(false);
- isEditMode(true);
- }
- }
- // <-- hcLee 2018 01 29
- }
- function handlePopupShowing() {
- $("#gridContainer3").dxDataGrid({
- paging: {
- pageSize: 7,
- enabled: true
- }
- });
- }
- function handlePopuphidden() {
- //viewModel.isAddHistoryButton(true);//2019.08.26
- }
- // hcLee 2018 01 29 -->
- function setdownLoadUrl() {
- if (_.isNull(viewModel.workCheckItemViewModel.FileId1()) === false) {
- viewModel.imagefileUrl1('{0}/CmFile(SiteId={1},FileId={2})/$value'.formati(BWA.db._url, BWA.UserInfo.SiteId(), viewModel.workCheckItemViewModel.FileId1()));
- }
- else {
- viewModel.imagefileUrl1(undefined);
- }
- if (_.isNull(viewModel.workCheckItemViewModel.FileId2()) === false) {
- viewModel.imagefileUrl2('{0}/CmFile(SiteId={1},FileId={2})/$value'.formati(BWA.db._url, BWA.UserInfo.SiteId(), viewModel.workCheckItemViewModel.FileId2()));
- }
- else {
- viewModel.imagefileUrl2(undefined);
- }
- }
- // <-- hcLee 2018 01 29
- viewModel.workCheckItemViewModel = workCheckItemViewModel;
- return {
- IsWorkDone: IsWorkDone,
- IsWorkHold: IsWorkHold,
- modifiableMaterialDataGridOptions: modifiableMaterialDataGridOptions,
- workCheckItemViewModel: workCheckItemViewModel,
- popupVisible: popupVisible,
- isNew: isNew,
- MaterialExdataSource: MaterialExdataSource,
- isEditMode: isEditMode,
- // hcLee 2018 01 29 -->
- FileEdit: FileEdit,
- FileView: FileView,
- setdownLoadUrl: setdownLoadUrl,
- // <-- hcLee 2018 01 29
- options: popupOptions,
- toolbarItems: toolbarItems,
- handlePopupButtonSave: handlePopupButtonSave,
- handleViewShown: handleViewShown,
- handleViewShowing: handleViewShowing,
- handlePopupShowing: handlePopupShowing,
- dataModel: dataModel,
- switchWorkDone: function (e) {
- if (workCheckItemViewModel.IsWorkDone()) {
- workCheckItemViewModel.IsWorkHold(false);
- }
- },
- switchWorkHold: function (e) {
- if (workCheckItemViewModel.IsWorkDone()) {
- workCheckItemViewModel.IsWorkHold(false);
- }
- },
- dateboxCheckDate: function (e) {
- if (e.value == "")
- var time = e.previousValue;
- else
- var time = e.value;
- workCheckItemViewModel.IsdateboxCheckDate(new Date(time.getFullYear(), time.getMonth(), time.getDate()));
- },
- show: function () {
- popupVisible(true);
- }
- };
- }
- }
- });
|