123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235 |
- 'use strict';
- var app = angular.module('app', [
- ]);
- app.controller("formeditCtrl", ["$scope", "$http", "$timeout", '$sce', function ($scope, $http, $timeout, $sce) {
- var self = this;
- var s4 = new SM4Util();
- self.userId = $.cookie("GlWorkPlatform-userid");
- self.userName = $.cookie("GlWorkPlatform-chineseName");
- self.userCName = $.cookie("GlWorkPlatform-chineseName");
- self.get_AccessToken = localStorage.getItem("GlWorkPlatform-AccessToken");
- self.routeinfoid = sp.getUrlName("routeinfoid");
- self.type = sp.getUrlName("type");
- self.get_lastReturn = sp.getUrlName("lastReturn");
- self.get_lastReturnPageno = sp.getUrlName("lastReturnPageno");
- self.return = self.get_lastReturn + ".html?lastReturnPageno=" + self.get_lastReturnPageno + "&type=" + self.type
- var postCfg = {
- headers: {
- 'Content-Type': 'application/json',
- 'Authorization': "Bearer " + self.get_AccessToken
- }
- };
- self.SwenList = [{
- VNAME: "文件详情",
- TEMPFORM: "formedt.html?routeinfoid=" + self.routeinfoid + "&lastReturn=" + self.get_lastReturn + "&lastReturnPageno=" + self.get_lastReturnPageno + "&type=" + self.type
- }, {
- VNAME: "附件列表",
- TEMPFORM: "attachlist.html?routeinfoid=" + self.routeinfoid + "&lastReturn=" + self.get_lastReturn + "&lastReturnPageno=" + self.get_lastReturnPageno + "&type=" + self.type
- }]
- self.Title = "文件详情";
- self.showReturn = false;
- self.getSelect = function () {
- self.select = { list: [] }
- var data = { tablename: "CODE_AGENCIES" }
- $http.post(apiurljs.login + "g2app/DangAn/queryCodeData", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
- .success(function (obj) {
- var res = strToJson(s4.decryptData_CBC(obj.data));
- self.select.list = res.data;
- self.getMIJI();
- })
- }
- self.getMIJI = function () {
- var data = { tablename: "CODE_SECRET" }
- $http.post(apiurljs.login + "g2app/DangAn/queryCodeData", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
- .success(function (obj) {
- var res = strToJson(s4.decryptData_CBC(obj.data));
- self.select.miji = res.data;
- self.getJINJI();
- })
- }
- self.getJINJI = function () {
- var data = { tablename: "CODE_EMERGENCY" }
- $http.post(apiurljs.login + "g2app/DangAn/queryCodeData", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
- .success(function (obj) {
- var res = strToJson(s4.decryptData_CBC(obj.data));
- self.select.jinji = res.data;
- self.getData(0);
- })
- }
- self.getData = function (n) {
- var data = {
- routeinfoid: self.routeinfoid,
- tablename: ""
- }
- if (self.get_lastReturn == "list") {
- if (self.type == 1) {
- data.tablename = "DOCELEMENT";
- } else {
- data.tablename = "DOCELEMENT_ZL";
- }
- }else{
- data.tablename = "DOCELEMENT_ZL"
- }
- $http.post(apiurljs.login + "g2app/DangAn/queryDataByTablename", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
- .success(function (obj) {
- var res = strToJson(s4.decryptData_CBC(obj.data));
- self.data = {
- ID: res.data.ID ? res.data.ID : "",
- ARCHCODE: res.data.ARCHCODE ? res.data.ARCHCODE : "",
- ARCHYEAR: res.data.ARCHYEAR ? sp.currentYear() : sp.formatGetYear(res.data.DOCISSUEDDATE),
- ORGANIZATIONMA: res.data.ORGANIZATIONMA ? res.data.ORGANIZATIONMA : self.select.list[0].CODE,
- DOCUMENTID: res.data.DOCUMENTID ? res.data.DOCUMENTID : "",
- DOCUMENTTYPE: res.data.DOCUMENTTYPE ? res.data.DOCUMENTTYPE : "",
- SERIALNUM: res.data.SERIALNUM ? res.data.SERIALNUM : "",
- MIJIQIXIAN: res.data.MIJIQIXIAN ? res.data.MIJIQIXIAN : "",
- EMERGENCYDEGREE: res.data.EMERGENCYDEGREE ? res.data.EMERGENCYDEGREE : "",
- DOCISSUERID: res.data.DOCISSUERID ? res.data.DOCISSUERID : "",
- DOCISSUEDNUM: res.data.DOCISSUEDNUM ? res.data.DOCISSUEDNUM : "",
- SIGNER: res.data.SIGNER ? res.data.SIGNER : "",
- DOCTITLE: res.data.DOCTITLE ? res.data.DOCTITLE : "",
- MAINDPT: res.data.MAINDPT ? res.data.MAINDPT : "",
- DOCISSUEDDATE: res.data.DOCISSUEDDATE ? sp.format(res.data.DOCISSUEDDATE) : "",
- ATTACHMENT: res.data.ATTACHMENT ? res.data.ATTACHMENT : "",
- ISSUINGAGENCY: res.data.ISSUINGAGENCY ? res.data.ISSUINGAGENCY : "",
- ANNOTATION: res.data.ANNOTATION ? res.data.ANNOTATION : "",
- CCDPT: res.data.CCDPT ? res.data.CCDPT : "",
- PRINTSENDDPT: res.data.PRINTSENDDPT ? res.data.PRINTSENDDPT : "",
- PRINTDATE: res.data.PRINTDATE ? sp.format(res.data.PRINTDATE) : "",
- RELEASELEVEL: res.data.RELEASELEVEL ? res.data.RELEASELEVEL : "",
- }
- $.each(self.select.miji, function (index, item) {
- if (item.CODE == self.data.MIJIQIXIAN) {
- self.MIJIQIXIAN1 = item.CNAME;
- }
- })
- $.each(self.select.jinji, function (index, item) {
- if (item.CODE == self.data.EMERGENCYDEGREE) {
- self.EMERGENCYDEGREE1 = item.CNAME;
- }
- })
- self.getReturnList()
- })
- }
- self.getSelect();
- self.getReturnList = function () {
- var data = {
- routeinfoid: self.routeinfoid,
- tablename: "DOCELEMENT_01"
- }
- $http.post(apiurljs.login + "g2app/DangAn/GetDataListForPid", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
- .success(function (obj) {
- var res = strToJson(s4.decryptData_CBC(obj.data));
- self.returnList = res.data;
- self.returnListShow = false;
- self.selectReturn = self.returnList[0];
- $.each(self.returnList, function (index, item) {
- item.BACKDATE1 = sp.format(item.BACKDATE);
- item.BACKDATE = sp.formatMinute(item.BACKDATE);
- item.BACKOPINION1 = item.BACKOPINION.length > 12 ? item.BACKOPINION.slice(0, 12) + "..." : item.BACKOPINION;
- })
- })
- }
- self.btnSubmit = function (n) {
- if (n == 0) {
- self.btnSave(1)
- } else {
- var dialogHead = "<span class=\"sp-dialog-head\"><span class=\"sp-dialog-tip\">温馨提示</span><span class=\"sp-dialog-close sp-closeDialog\" title=\"关闭\">×</span></span>";
- var dialogBody = "<div class=\"sp-dialog-body\">您确认要提交这些内容吗?</div>";
- var dialogFoot = "<div class=\"sp-dialog-foot\"><input id='upDataTrue' type='button' value='确 认' class='sp-dialog-btnTrue' /><input type='button' value='取 消' class='sp-dialog-btnCancle sp-closeDialog' /></div>";
- $('.sp-dialog').html(dialogHead + dialogBody + dialogFoot);
- sp.openCenter(".sp-dialog");
- $('.sp-closeDialog').click(function (event) {
- sp.dialoghide();
- event.preventDefault();
- event.stopPropagation();
- });
- $("#upDataTrue").click(function () {
- sp.dialoghide();
- if (self.type == 1) {
- var data = {
- data: self.routeinfoid,
- userid: self.userId,
- username: self.userName
- }
- $http.post(apiurljs.login + "g2app/DangAn/SendData", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
- .success(function (obj) {
- var res = strToJson(s4.decryptData_CBC(obj.data));
- if (res.success) {
- sp.dialog("提交成功,即将跳转至文件收集!");
- $timeout(function () {
- window.location.href = self.return
- }, 1500)
- } else {
- sp.dialog(res.message)
- }
- })
- } else {
- var data = {
- data: self.routeinfoid,
- }
- $http.post(apiurljs.login + "g2app/DangAn/SendBackData", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
- .success(function (obj) {
- var res = strToJson(s4.decryptData_CBC(obj.data));
- if (res.success) {
- sp.dialog("提交成功,即将跳转至文件收集!");
- $timeout(function () {
- window.location.href = self.return
- }, 1500)
- } else {
- sp.dialog(res.message)
- }
- })
- }
- })
- }
- }
- self.btnSave = function (n) {
- var data = {
- routeinfoid: self.routeinfoid,
- data: JSON.stringify(self.data),
- tablename: ""
- }
- if (self.get_lastReturn == "list") {
- if (self.type == 1) {
- data.tablename = "DOCELEMENT";
- } else {
- data.tablename = "DOCELEMENT_ZL";
- }
- } else {
- data.tablename = "DOCELEMENT_ZL"
- }
- $http.post(apiurljs.login + "g2app/abase/saveFormData", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
- .success(function (obj) {
- var res = strToJson(s4.decryptData_CBC(obj.data));
- if (res.code == 0) {
- self.routeinfoid = res.data.id;
- if (n == 0) {
- self.getData(1);
- sp.dialog("保存成功!");
- $timeout(function () {
- sp.dialoghide()
- }, 1500)
- } else {
- self.btnSubmit(1)
- }
- } else {
- sp.dialog(res.message)
- }
- })
- }
- }])
- app.filter('trustHtml', function ($sce) {
- return function (input) {
- return $sce.trustAsHtml(input.replace(/\n/g, '<br/>').replace(/\s/g, ' '));
- };
- });
|