123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958 |
- BemsWebApplication.ReportJob = function (params, viewInfo) {
- var visiblePopup = ko.observable(false);
- var change = false;
- var newReport;
- var seq = 0;
- var beforeReportFormatId;
- var beforeFormatName;
- var beforeSeq;
- var beforeDateTime;
- var editor;
- var rowClick = false;
- var contentsUnit = 10000;
- var filePath = "/App_Data/files/report2/";
- var popupInit = false;
- var SiteId = BWA.UserInfo.SiteId();
- //권한설정
- var hasnotModificationPermission = ko.observable(true);
- 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;
- }
- var tempcontent = "";
- function getFormatData() {
- var dataSource = new DevExpress.data.DataSource({
- store: {
- type: "odata",
- url: endpointSelector + "/BemsReportFormat",
- },
- requireTotalCount: true,
- pageSize: 1000
- });
- dataSource.filter([
- ["parts", "=", 0]
- ]);
- dataSource.sort({ getter: "FormatName", asc: true });
- dataSource.load()
- .done(function (result) {
- $("#formatSelect").dxSelectBox("instance").option('dataSource', result);
- $("#formatSelect").dxSelectBox("instance").option('displayExpr', 'FormatName');
- $("#formatSelect").dxSelectBox("instance").option('valueExpr', "ReportFormatId");
- })
- .fail(function (error) {
- utils.toast.show(error);
- });
- }
- function getFormatContent() {
- rowClick = false;
- var dataSource = new DevExpress.data.DataSource({
- store: {
- type: "odata",
- url: endpointSelector + "/BemsReportFormat",
- },
- requireTotalCount: true,
- pageSize: 1000
- });
- dataSource.filter([
- ["ReportFormatId", "=", $("#formatSelect").dxSelectBox("instance").option('value')]
- ]);
- dataSource.load()
- .done(function (result) {
- var content = "";
- for (var i = 0; i < result.length; i++) {
- content = content + result[i].Content;
- }
- editor.doCmd('NewDocument', '1');
- if (result.length > 0) {
- editor.insertContents(content);
- } else {
- editor.insertContents("");
- }
- })
- .fail(function (error) {
- utils.toast.show(error);
- });
- }
- function saveReport() {
- $("#saveBtn").dxButton("instance").option('disabled', true);
- $("#delBtn").dxButton("instance").option('disabled', true);
- $("#confirmBtn").dxButton("instance").option('disabled', true);
- var dataSource = new DevExpress.data.DataSource({
- store: {
- type: "odata",
- url: endpointSelector + "/BemsReportHistory",
- },
- requireTotalCount: true,
- pageSize: 1000
- });
- dataSource.filter([
- ["SiteId", "=", BWA.UserInfo.SiteId()],
- "and",
- ["parts", "=", 0]
- ]);
- dataSource.sort({ getter: "Seq", desc: true });
- dataSource.load()
- .done(function (result) {
- if (result.length > 0) {
- seq = result[0].Seq;
- } else {
- seq = 0;
- }
- var store = new DevExpress.data.ODataStore({
- url: endpointSelector + "/BemsReportHistory",
- key: ["DateTime", "Seq", "ReportFormatId", "parts"],
- keyType: {
- DateTime: "DateTime",
- Seq: "Int32",
- ReportFormatId: "Int32",
- parts: "Int32"
- }
- });
- if ($("#formatSelect").dxSelectBox("instance").option('value') == null) {
- utils.toast.show('일지 양식을 선택 해 주세요.', 'error');
- $("#saveBtn").dxButton("instance").option('disabled', false);
- $("#delBtn").dxButton("instance").option('disabled', false);
- $("#confirmBtn").dxButton("instance").option('disabled', false);
- return;
- }
- if ($("#reportName").dxTextBox("instance").option('value') == "") {
- utils.toast.show('일지 이름을 입력 해 주세요.', 'error');
- $("#saveBtn").dxButton("instance").option('disabled', false);
- $("#delBtn").dxButton("instance").option('disabled', false);
- $("#confirmBtn").dxButton("instance").option('disabled', false);
- return;
- }
- var contentData = editor.outputBodyHTML();
- if (contentData.substring(7, 14) == "<p></p>") {
- var temp1 = contentData.substring(0, 6);
- var temp2 = contentData.substring(18, contentData.length);
- contentData = temp1 + temp2;
- }
- var partCnt = 1;
- if (contentData.length > contentsUnit) {
- partCnt = parseInt(contentData.length / contentsUnit) + 1;
- }
- var contentsArray = new Array(partCnt);
- var contentLength = contentData.length;
- for (var i = 0; i < partCnt; i++) {
- if (contentLength <= contentsUnit) {
- contentsArray[i] = contentData;
- } else {
- if (contentLength <= contentsUnit) {
- contentsArray[i] = contentData.substr(i * contentsUnit, contentLength - i * contentsUnit);
- } else {
- contentsArray[i] = contentData.substr(i * contentsUnit, contentsUnit);
- }
- }
- var tmpDate = new Date();
- var fileValue = $("#FILE_TAG").val().split("\\");
- var fileName = fileValue[fileValue.length - 1]; // 파일명
- var tmpDateFormat = new Date(tmpDate.getFullYear(), tmpDate.getMonth(), tmpDate.getDate(), tmpDate.getHours(), tmpDate.getMinutes(), tmpDate.getSeconds(), 0);
- var insertData = { SiteId: BWA.UserInfo.SiteId(), Seq: seq + 1, DateTime: tmpDateFormat, ReportName: $("#reportName").dxTextBox("instance").option('value'), ReportFormatId: $("#formatSelect").dxSelectBox("instance").option('value'), FormatName: $("#formatSelect").dxSelectBox("instance").option('text'), Content: contentsArray[i], Writer: BWA.UserInfo.Name(), Confirm1: '', Confirm2: '', parts: i, FileName: fileName };
- store.insert(insertData)
- .done(function (values, key) {
- utils.toast.show("일지를 작성하였습니다.");
- })
- .fail(function (error) {
- utils.toast.show("일지 작성이 실패하였습니다.", "error");
- });
- }
- uploadFile();
- if ((window.navigator.appName == 'Netscape' && window.navigator.userAgent.search('Trident') != -1) || (window.navigator.userAgent.indexOf("msie") != -1)) {
- $("#FILE_TAG").replaceWith($("#FILE_TAG").clone(true));
- $("#FILE_TAG").val("");
- } else {
- $("#FILE_TAG").val("");
- }
- setTimeout(function () {
- $("#saveBtn").dxButton("instance").option('disabled', false);
- $("#delBtn").dxButton("instance").option('disabled', false);
- $("#confirmBtn").dxButton("instance").option('disabled', false);
- visiblePopup(false);
- change = true;
- loadGridReportDate();
- }, 100);
- })
- .fail(function (error) {
- $("#saveBtn").dxButton("instance").option('disabled', false);
- $("#delBtn").dxButton("instance").option('disabled', false);
- $("#confirmBtn").dxButton("instance").option('disabled', false);
- utils.toast.show(error);
- });
- }
- function modifyReport() {
- var partsCnt = 0;
- var id;
- var formatName = '';
- var name = $("#reportName").dxTextBox("instance").option('value');
- var Writer = '';
- var confirm1 = '';
- var confirm2 = '';
- var removecnt = 0;
- var tmpDateFormat = new Date(beforeDateTime.getFullYear(), beforeDateTime.getMonth(), beforeDateTime.getDate(), beforeDateTime.getHours(), beforeDateTime.getMinutes(), beforeDateTime.getSeconds(), 0);
- var dataSource = new DevExpress.data.DataSource({
- store: {
- type: "odata",
- url: endpointSelector + "/BemsReportHistory",
- },
- requireTotalCount: true,
- pageSize: 100
- });
- dataSource.filter([
- ["SiteId", "=", BWA.UserInfo.SiteId()],
- "and",
- ["Seq", "=", beforeSeq],
- "and",
- ["DateTime", "=", beforeDateTime]
- ]);
- dataSource.load()
- .done(function (result) {
- partsCnt = result.length;
- Writer = result[0].Writer;
- confirm1 = result[0].Confirm1;
- confirm2 = result[0].Confirm2;
- id = result[0].ReportFormatId;
- formatName = result[0].FormatName;
- var store = new DevExpress.data.ODataStore({
- url: endpointSelector + "/BemsReportHistory",
- key: ["DateTime", "Seq", "ReportFormatId", "parts"],
- keyType: {
- DateTime: "DateTime",
- Seq: "Int32",
- ReportFormatId: "Int32",
- parts: "Int32"
- }
- });
- for (var i = 0; i < partsCnt; i++) {
- var removeData = { Seq: beforeSeq, DateTime: tmpDateFormat, ReportFormatId: id, parts: i };
- store.remove(removeData)
- .done(function (values, key) {
- removecnt++;
- if (removecnt == partsCnt) {
- var store = new DevExpress.data.ODataStore({
- url: endpointSelector + "/BemsReportHistory",
- key: ["DateTime", "Seq", "ReportFormatId", "parts"],
- keyType: {
- DateTime: "DateTime",
- Seq: "Int32",
- ReportFormatId: "Int32",
- parts: "Int32"
- }
- });
- var contentData = editor.outputBodyHTML();
- if (contentData.substring(7, 14) == "<p></p>") {
- var temp1 = contentData.substring(0, 6);
- var temp2 = contentData.substring(18, contentData.length);
- contentData = temp1 + temp2;
- }
- var partCnt = 1;
- if (contentData.length > contentsUnit) {
- partCnt = parseInt(contentData.length / contentsUnit) + 1;
- }
- var contentsArray = new Array(partCnt);
- var contentLength = contentData.length;
- var addcnt = 0;
- for (var i = 0; i < partCnt; i++) {
- if (contentLength <= contentsUnit) {
- contentsArray[i] = contentData;
- } else {
- if (contentLength <= contentsUnit) {
- contentsArray[i] = contentData.substr(i * contentsUnit, contentLength - i * contentsUnit);
- } else {
- contentsArray[i] = contentData.substr(i * contentsUnit, contentsUnit);
- }
- }
- var fileValue = $("#FILE_TAG").val().split("\\");
- var fileName = fileValue[fileValue.length - 1]; // 파일명
- if (fileName == "") {
- fileName = $("#FILE_DOWN").text();
- }
- var insertData = { SiteId: BWA.UserInfo.SiteId(), Seq: beforeSeq, DateTime: tmpDateFormat, ReportName: name, ReportFormatId: id, FormatName: formatName, Content: contentsArray[i], Writer: Writer, Confirm1: confirm1, Confirm2: confirm2, parts: i, FileName: fileName };
- store.insert(insertData)
- .done(function (values, key) {
- addcnt++;
- if (addcnt == partCnt) {
- utils.toast.show("일지를 수정하였습니다.");
- $("#saveBtn").dxButton("instance").option('disabled', false);
- $("#delBtn").dxButton("instance").option('disabled', false);
- $("#confirmBtn").dxButton("instance").option('disabled', false);
- visiblePopup(false);
- change = true;
- loadGridReportDate();
- }
- })
- .fail(function (error) {
- utils.toast.show("일지 수정이 실패하였습니다.", "error");
- $("#saveBtn").dxButton("instance").option('disabled', false);
- $("#delBtn").dxButton("instance").option('disabled', false);
- $("#confirmBtn").dxButton("instance").option('disabled', false);
- visiblePopup(false);
- });
- }
- uploadFile();
- if ((window.navigator.appName == 'Netscape' && window.navigator.userAgent.search('Trident') != -1) || (window.navigator.userAgent.indexOf("msie") != -1)) {
- $("#FILE_TAG").replaceWith($("#FILE_TAG").clone(true));
- $("#FILE_TAG").val("");
- } else {
- $("#FILE_TAG").val("");
- }
- }
- })
- .fail(function (error) {
- utils.toast.show("일지 수정이 실패하였습니다.", "error");
- });
- }
- }).fail(function (error) {
- utils.toast.show(error);
- });
- $("#saveBtn").dxButton("instance").option('disabled', true);
- $("#delBtn").dxButton("instance").option('disabled', true);
- $("#confirmBtn").dxButton("instance").option('disabled', true);
- }
- function loadGridReportDate() {
- var dataSource = new DevExpress.data.DataSource({
- store: {
- type: "odata",
- url: endpointSelector + "/BemsReportHistory",
- },
- requireTotalCount: true,
- pageSize: 1000
- });
- dataSource.filter([
- ["SiteId", "=", BWA.UserInfo.SiteId()]
- , "and",
- ["parts", "=", 0]
- ]);
- dataSource.sort({ getter: "Seq", desc: true });
- console.log('ds', dataSource);
- dataSource.load()
- .done(function (result) {
- if (result.length > 0) {
- seq = result[0].Seq;
- } else {
- seq = 0;
- }
- if (change) {
- //$("#gridContainer").dxDataGrid("instance").option('dataSource', result);
- //$("#gridContainer").dxDataGrid({
- // scrolling: {
- // showScrollbar: "never"
- // },
- // paging: {
- // pageSize: 20,
- // enabled: true
- // },
- //});
- $("#gridContainer").dxDataGrid("instance").refresh();
- change = false;
- }
- })
- .fail(function (error) {
- utils.toast.show(error);
- });
- }
- function deleteReport() {
- var partsCnt = 0;
- if (seq == 0) {
- utils.toast.show('삭제할 일지가 없습니다.', "error");
- } else {
- var dataSource = new DevExpress.data.DataSource({
- store: {
- type: "odata",
- url: endpointSelector + "/BemsReportHistory",
- },
- requireTotalCount: true,
- pageSize: 100
- });
- dataSource.filter([
- ["SiteId", "=", BWA.UserInfo.SiteId()],
- "and",
- ["Seq", "=", beforeSeq]
- , "and",
- ["DateTime", "=", beforeDateTime],
- ]);
- dataSource.load()
- .done(function (result) {
- var id = result[0].ReportFormatId;
- partsCnt = result.length;
- var store = new DevExpress.data.ODataStore({
- url: endpointSelector + "/BemsReportHistory",
- key: ["DateTime", "Seq", "ReportFormatId", "parts"],
- keyType: {
- DateTime: "DateTime",
- Seq: "Int32",
- ReportFormatId: "Int32",
- parts: "Int32"
- }
- });
- var tmpDateFormat = new Date(beforeDateTime.getFullYear(), beforeDateTime.getMonth(), beforeDateTime.getDate(), beforeDateTime.getHours(), beforeDateTime.getMinutes(), beforeDateTime.getSeconds(), 0);
- for (var i = 0; i < partsCnt; i++) {
- var removeData = { SiteId: BWA.UserInfo.SiteId(), Seq: beforeSeq, DateTime: tmpDateFormat, ReportFormatId: id, parts: i };
- store.remove(removeData)
- .done(function (values, key) {
- utils.toast.show("일지를 삭제하였습니다.");
- })
- .fail(function (error) {
- utils.toast.show("일지 삭제를 실패하였습니다.", "error");
- });
- }
- })
- .fail(function (error) {
- utils.toast.show(error);
- });
- $("#saveBtn").dxButton("instance").option('disabled', true);
- $("#delBtn").dxButton("instance").option('disabled', true);
- $("#confirmBtn").dxButton("instance").option('disabled', true);
- setTimeout(function () {
- $("#saveBtn").dxButton("instance").option('disabled', false);
- $("#delBtn").dxButton("instance").option('disabled', false);
- $("#confirmBtn").dxButton("instance").option('disabled', false);
- visiblePopup(false);
- change = true;
- loadGridReportDate();
- }, 100);
- }
- }
- function confirmReport() {
- var confirm1;
- var partsCnt = 0;
- if (seq == 0) {
- utils.toast.show('결재할 일지가 없습니다.', 'error');
- } else {
- var confimcnt = 0;
- var confimcnt1 = 0;
- var id = $("#formatSelect").dxSelectBox("instance").option('value');
- var dataSource = new DevExpress.data.DataSource({
- store: {
- type: "odata",
- url: endpointSelector + "/BemsReportHistory",
- },
- requireTotalCount: true,
- pageSize: 100
- });
- dataSource.filter([
- ["SiteId", "=", BWA.UserInfo.SiteId()],
- "and",
- ["Seq", "=", beforeSeq],
- "and",
- ["DateTime", "=", beforeDateTime]
- ]);
- dataSource.load()
- .done(function (result) {
- partsCnt = result.length;
- var store = new DevExpress.data.ODataStore({
- url: endpointSelector + "/BemsReportHistory",
- key: ["DateTime", "Seq", "ReportFormatId", "parts"],
- keyType: {
- DateTime: "DateTime",
- Seq: "Int32",
- ReportFormatId: "Int32",
- parts: "Int32"
- }
- });
- for (var i = 0; i < partsCnt; i++) {
- if (BWA.UserInfo.UserGroupName().indexOf('팀장') > -1) {
- store.update({
- DateTime: new Date(beforeDateTime.getFullYear(), beforeDateTime.getMonth(), beforeDateTime.getDate(), beforeDateTime.getHours(), beforeDateTime.getMinutes(), beforeDateTime.getSeconds(), 0),
- Seq: beforeSeq,
- ReportFormatId: beforeReportFormatId,
- parts: i
- }, { Confirm1: BWA.UserInfo.Name() })
- .done(function (values, key) {
- confimcnt++;
- if (confimcnt == partsCnt) {
- utils.toast.show("결재가 진행되었습니다.");
- confimcnt = 0;
- }
- })
- .fail(function (error) {
- utils.toast.show("결재가 실패하였습니다.", "error");
- });
- } else if (BWA.UserInfo.UserGroupName().indexOf('소장') > -1) {
- var dataSource = new DevExpress.data.DataSource({
- store: {
- type: "odata",
- url: endpointSelector + "/BemsReportHistory",
- },
- requireTotalCount: true,
- pageSize: 1
- });
- dataSource.filter([
- ["SiteId", "=", BWA.UserInfo.SiteId()],
- "and",
- ["Seq", "=", beforeSeq],
- "and",
- ["DateTime", "=", beforeDateTime]
- ]);
- dataSource.load()
- .done(function (result) {
- if (result[0].Confirm1 == "") {
- confirm1 = false;
- } else {
- confirm1 = true;
- }
- if (confirm1) {
- for (var i = 0; i < partsCnt; i++) {
- store.update({
- DateTime: new Date(beforeDateTime.getFullYear(), beforeDateTime.getMonth(), beforeDateTime.getDate(), beforeDateTime.getHours(), beforeDateTime.getMinutes(), beforeDateTime.getSeconds(), 0),
- Seq: beforeSeq,
- ReportFormatId: beforeReportFormatId,
- parts: i
- }, { Confirm2: BWA.UserInfo.Name() })
- .done(function (values, key) {
- confimcnt1++;
- if (confimcnt1 == partsCnt) {
- utils.toast.show("결재가 진행되었습니다.");
- confimcnt1 = 0;
- }
- })
- .fail(function (error) {
- utils.toast.show("결재가 실패하였습니다.", "error");
- });
- }
- } else {
- utils.toast.show("팀장 결재가 진행되지 않습니다.", "error");
- }
- })
- .fail(function (error) {
- utils.toast.show(error);
- });
- } else {
- utils.toast.show("결재자 정보가 명확하지 않습니다.", "error");
- }
- }
- })
- .fail(function (error) {
- utils.toast.show(error);
- });
- $("#saveBtn").dxButton("instance").option('disabled', true);
- $("#delBtn").dxButton("instance").option('disabled', true);
- $("#confirmBtn").dxButton("instance").option('disabled', true);
- setTimeout(function () {
- $("#saveBtn").dxButton("instance").option('disabled', false);
- $("#delBtn").dxButton("instance").option('disabled', false);
- $("#confirmBtn").dxButton("instance").option('disabled', false);
- visiblePopup(false);
- change = true;
- loadGridReportDate();
- }, 100);
- }
- }
- function HideConfirm() {
- var dataSource = new DevExpress.data.DataSource({
- store: {
- type: "odata",
- url: endpointSelector + "/BemsReportHistory",
- },
- requireTotalCount: true,
- pageSize: 1
- });
- dataSource.filter([
- ["SiteId", "=", BWA.UserInfo.SiteId()],
- "and",
- ["Seq", "=", beforeSeq],
- "and",
- ["DateTime", "=", beforeDateTime]
- ]);
- dataSource.load()
- .done(function (result) {
- if (BWA.UserInfo.UserGroupName().indexOf('팀장') > -1) {
- if (result[0].Confirm1 == "") {
- $("#confirmBtn").dxButton("instance").option("visible", true);
- } else {
- $("#confirmBtn").dxButton("instance").option("visible", false);
- }
- }
- if (BWA.UserInfo.UserGroupName().indexOf('소장') > -1) {
- if (result[0].Confirm2 == "") {
- $("#confirmBtn").dxButton("instance").option("visible", true);
- } else {
- $("#confirmBtn").dxButton("instance").option("visible", false);
- }
- }
- })
- .fail(function (error) {
- utils.toast.show(error);
- });
- }
- function uploadFile() {
- if ($("#FILE_TAG")[0].files[0] != null) {
- var form = $('#FILE_FORM')[0];
- var formData = new FormData(form);
- formData.append("fileObj", $("#FILE_TAG")[0].files[0]);
- var urlHeader = BemsWebApplication.config.endpoints.api[BemsWebApplication.config.mode];
- var url = urlHeader + '/DailyReport/FileUpload?&SiteId=' + SiteId;
- $.ajax({
- url: url,
- processData: false,
- contentType: false,
- data: formData,
- type: 'POST',
- success: function (result) {
- },
- error: function (error) {
- }
- });
- }
- }
- var searchViewOptions = {
- };
- var dataSourceOptions = {
- select: [
- 'SiteId',
- 'Seq',
- 'DateTime',
- 'ReportName',
- 'ReportFormatId',
- 'FormatName',
- 'Content',
- 'Writer',
- 'Confirm1',
- 'Confirm2',
- 'parts',
- 'FileName'
- ],
- filter: [[
- ["SiteId", "=", BWA.UserInfo.SiteId()],
- "and",
- ["parts", "=", 0]
- ]]
- };
- var viewModel = BWA.DataGrid.createViewWithDataGrid(params, viewInfo, 'BemsReportHistory',
- {
- dataSourceOptions: dataSourceOptions,
- isUseSiteId: false,
- columns: [
- {
- dataField: 'Index',
- width: 100,
- caption: "번호",
- alignment: 'center'
- },
- {
- dataField: 'FormatName',
- width: 260,
- caption: "양식",
- alignment: 'center',
- cellTemplate: function (element, info) {
- element.append("<div>" + info.text + "</div>")
- .css("text-align", "left")
- }
- },
- {
- dataField: 'DateTime',
- width: 150,
- caption: "등록일",
- alignment: 'center'
- },
- {
- dataField: 'ReportName',
- width: 390,
- caption: "제목",
- alignment: 'center',
- cellTemplate: function (element, info) {
- element.append("<div>" + info.text + "</div>")
- .css("text-align", "left")
- }
- },
- {
- dataField: 'FileName',
- width: 100,
- caption: "첨부파일",
- alignment: 'center',
- cellTemplate: function (element, info) {
- if (info.text != null && info.text != "")
- element.append("<div> O </div>")
- else {
- element.append("<div> </div>")
- }
- }
- },
- {
- dataField: 'Writer',
- width: 120,
- caption: "등록자",
- alignment: 'center'
- },
- {
- dataField: 'Confirm1',
- width: 120,
- caption: "팀장확인",
- alignment: 'center'
- },
- {
- dataField: 'Confirm2',
- width: 120,
- caption: "소장확인",
- alignment: 'center'
- },
- {
- dataField: 'Seq',
- width: 50,
- caption: "시퀀스",
- alignment: 'center',
- visible: false,
- sortOrder: 'desc'
- }
- ],
- paging: {
- enabled: true,
- pageSize: 18
- },
- pager: {
- },
- handleDataGridRowClick: function (id, dataGrid, clickRow, popupVisible) {
- rowClick = true;
- newReport = false;
- visiblePopup(true);
- var $EditorCommon = $('#EditorCommon');
- $('#EditorCommon').empty();
- $('<form><textarea name="editorjob" id="editorjob"></textarea></form>')
- .appendTo($EditorCommon)
- editor = new cheditor(); // 에디터 개체를 생성합니다.
- editor.config.editorHeight = '570px'; // 에디터 세로폭입니다.
- editor.config.editorWidth = '1296px'; // 에디터 가로폭입니다.
- editor.inputForm = 'editorjob'; // 위에 있는 textarea의 id입니다. 주의: name 속성 이름이 아닙니다.
- editor.run();
- $('#formatSelect').dxSelectBox("instance").option('value', clickRow.data.ReportFormatId());
- if (clickRow.data.ReportName().indexOf('<img src=')) {
- var tmp = clickRow.data.ReportName().split('<img src=');
- clickRow.data.ReportName(tmp[0]);
- }
- $('#reportName').dxTextBox("instance").option('value', clickRow.data.ReportName());
- $("#saveBtn").dxButton("instance").option("visible", true);
- beforeReportFormatId = clickRow.data.ReportFormatId();
- beforeFormatName = clickRow.data.FormatName();
- beforeSeq = clickRow.data.Seq();
- beforeDateTime = clickRow.data.DateTime();
- $("#saveBtn").dxButton("instance").option("text", "수정");
- $("#FILE_FORM").show();
- if (hasnotModificationPermission() || (BWA.UserInfo.UserId() == 'admin')) {
- $("#FILE_TAG").attr('disabled', false);
- } else {
- $("#FILE_TAG").attr('disabled', true);
- }
- $("#FILE_DOWN").show();
- $("#FILE_ADD").show();
- var dataSource = new DevExpress.data.DataSource({
- store: {
- type: "odata",
- url: endpointSelector + "/BemsReportHistory",
- },
- requireTotalCount: true,
- pageSize: 100
- });
- dataSource.filter([
- ["SiteId", "=", BWA.UserInfo.SiteId()],
- "and",
- ["Seq", "=", clickRow.data.Seq()],
- "and",
- ["DateTime", "=", clickRow.data.DateTime()]
- , "and",
- ["ReportName", "=", clickRow.data.ReportName()]
- , "and",
- ["ReportFormatId", "=", clickRow.data.ReportFormatId()]
- ]);
- dataSource.sort({ getter: "parts", asc: true });
- dataSource.load()
- .done(function (result) {
- var content = "";
- for (var i = 0; i < result.length; i++) {
- content = content + result[i].Content;
- }
- if (result.length > 0) {
- tempcontent = content;
- $("#FILE_DOWN").text(result[0].FileName);
- if (BemsWebApplication.config.mode == "production") {
- $("#FILE_DOWN").attr("href", BemsWebApplication.config.endpoints.service.production + filePath + result[0].FileName);
- } else {
- $("#FILE_DOWN").attr("href", BemsWebApplication.config.endpoints.service.local + filePath + result[0].FileName);
- }
- } else {
- tempcontent = "";
- }
- })
- .fail(function (error) {
- utils.toast.show(error);
- });
- },
- searchViewItems: [
- { id: 'FormatName' },
- { id: 'DateTime', type: 'dateRange', isOnlyDate: true },
- { id: 'ReportName' },
- { id: 'Writer' }
- ],
- handleViewShown: function () {
- },
- handleViewShowing: function () {
- //권한설정
- hasnotModificationPermission(!BWA.UserInfo.hasPermissionOfModification(viewInfo.viewName));
- loadGridReportDate();
- $SideMenu.showSideMenuIfWill(params.view);
- },
- hasnotModificationPermission: hasnotModificationPermission //권한설정
- });
- var reportName = {
- placeholder: "일지 제목을 작성해주세요."
- }
- var formatSelect = {
- placeholder: "불러올 일지 양식을 선택해주세요.",
- onValueChanged: function () {
- var test = $("#formatSelect").dxSelectBox("instance").option('value');
- if (rowClick == false) {
- if ($("#formatSelect").dxSelectBox("instance").option('value') != null) {
- getFormatContent();
- }
- }
- }
- }
- function saveButtonClicked() {
- if ($("#saveBtn").dxButton("instance").option("text") == "작성") {
- saveReport();
- } else if ($("#saveBtn").dxButton("instance").option("text") == "수정") {
- DevExpress.ui.dialog.confirm("수정 하시겠습니까?", "수정").done(function (dialogResult) {
- if (dialogResult)
- modifyReport();
- });
- }
- }
- function delButtonClicked() {
- DevExpress.ui.dialog.confirm("삭제 하시겠습니까?", "삭제").done(function (dialogResult) {
- if (dialogResult)
- deleteReport();
- });
- }
- function confirmButtonClicked() {
- DevExpress.ui.dialog.confirm("결재 하시겠습니까?", "결재").done(function (dialogResult) {
- if (dialogResult)
- confirmReport();
- });
- }
- function newButtonClicked() {
- newReport = true;
- rowClick = false;
- visiblePopup(true);
- var $EditorCommon = $('#EditorCommon');
- $('#EditorCommon').empty();
- $('<form><textarea name="editorjob" id="editorjob"></textarea></form>')
- .appendTo($EditorCommon)
- editor = new cheditor(); // 에디터 개체를 생성합니다.
- editor.config.editorHeight = '570px'; // 에디터 세로폭입니다.
- editor.config.editorWidth = '1296px'; // 에디터 가로폭입니다.
- editor.inputForm = 'editorjob'; // 위에 있는 textarea의 id입니다. 주의: name 속성 이름이 아닙니다.
- editor.run();
- $("#FILE_FORM").show();
- if (hasnotModificationPermission() || (BWA.UserInfo.UserId() == 'admin')) {
- $("#FILE_TAG").attr('disabled', false);
- } else {
- $("#FILE_TAG").attr('disabled', true);
- }
- $("#FILE_DOWN").hide();
- $("#FILE_ADD").hide();
- $("#formatSelect").dxSelectBox("instance").option('value', null);
- $("#reportName").dxTextBox("instance").option('value', '');
- }
- viewModel.popupOptions = {
- width: 1300,
- height: 900,
- visible: visiblePopup,
- dragEnabled: false,
- shading: true,
- shadingColor: 'transparent',
- showTitle: true,
- title: "일지 상세",
- showCloseButton: true,
- onShown: function (t, tt) {
- popupInit = true;
- $("#FILE_TAG").val("");
- if (newReport) {
- $("#saveBtn").dxButton("instance").option("text", "작성");
- $("#delBtn").dxButton("instance").option("visible", false);
- $("#confirmBtn").dxButton("instance").option("visible", false);
- $("#formatSelect").dxSelectBox("instance").option("visible", true);
- $("#formatTxt").show();
- getFormatData();
- $("#formatSelect").dxSelectBox("instance").open();
- $("#formatSelect").dxSelectBox("instance").close();
- editor.doCmd('NewDocument', '1');
- editor.insertContents("");
- } else {
- $("#saveBtn").dxButton("instance").option("text", "수정");
- $("#delBtn").dxButton("instance").option("visible", true);
- $("#formatSelect").dxSelectBox("instance").option("visible", false);
- $("#formatTxt").hide();
- if (BWA.UserInfo.UserGroupName().indexOf('소장') > -1 || BWA.UserInfo.UserGroupName().indexOf('팀장') > -1) {
- HideConfirm();
- } else {
- $("#confirmBtn").dxButton("instance").option("visible", false);
- }
- getFormatData();
- $("#formatSelect").dxSelectBox("instance").open();
- $("#formatSelect").dxSelectBox("instance").close();
- editor.doCmd('NewDocument', '1');
- editor.insertContents(tempcontent);
- }
- },
- onHiding: function () {
- editor.doCmd('NewDocument', '1');
- }
- };
- viewModel.newButtonClicked = newButtonClicked;
- viewModel.saveButtonClicked = saveButtonClicked;
- viewModel.confirmButtonClicked = confirmButtonClicked;
- viewModel.delButtonClicked = delButtonClicked;
- viewModel.formatSelect = formatSelect;
- viewModel.reportName = reportName;
- return viewModel;
- };
|