123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226 |
- '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.get_id = sp.getUrlName("id")
- 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?id=" + self.get_id + "&routeinfoid=" + self.routeinfoid + "&lastReturn=" + self.get_lastReturn + "&lastReturnPageno=" + self.get_lastReturnPageno + "&type=" + self.type
- }, {
- VNAME: "附件列表",
- TEMPFORM: "attachlist.html?id=" + self.get_id + "&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();
- //})
- var data = {
- tablename: "SYS_SECT",
- colums: "*",
- order: "SORTID",
- sqlwhere: "",
- sqlorwhere: "",
- sqlinwhere: "",
- sqllikewhere: ""
- }
- $http.post(apiurljs.login + "g2app/dataabase/queryDataByCol", { 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.getData();
- })
- }
- self.getData = function () {
- var data = {
- routeinfoid: self.routeinfoid,
- 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 : "",
- ARCHYEAR: res.data.ARCHYEAR ? res.data.ARCHYEAR : sp.formatGetYear(res.data.CREATDATE),
- ORGANIZATIONMA: res.data.ORGANIZATIONMA ? res.data.ORGANIZATIONMA : self.select.list[0].CODE,
- WENHAO: res.data.WENHAO ? res.data.WENHAO : "",
- MIJIQIXIAN: res.data.MIJIQIXIAN ? res.data.MIJIQIXIAN : "10年",
- DANGANML: res.data.DANGANML ? res.data.DANGANML : "文书",
- DOCUMENTTYPE: res.data.DOCUMENTTYPE ? res.data.DOCUMENTTYPE : "",
- DOCTITLE: res.data.DOCTITLE ? res.data.DOCTITLE : "",
- ZRZ: res.data.ZRZ ? res.data.ZRZ : "",
- DOCISSUEDDATE: res.data.DOCISSUEDDATE ? sp.format(res.data.DOCISSUEDDATE) : sp.format(res.data.CREATDATE),
- JIANHAO: res.data.JIANHAO ? res.data.JIANHAO : "",
- YESHU: res.data.YESHU ? res.data.YESHU : "",
- BEIZHU: res.data.BEIZHU ? res.data.BEIZHU : "",
- ARCHCODE: res.data.ARCHCODE ? res.data.ARCHCODE : ""
- }
- self.getReturnList()
- })
- }
- self.getSelect();
- self.returnList = [];
- 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 MIJIQIXIAN = self.data.MIJIQIXIAN == "10年" ? "D10" : self.data.MIJIQIXIAN == "30年" ? "D30" : "Y";
- var ORGANIZATIONMA = ""
- self.select.list.forEach(function (item) {
- if (item.CODE == self.data.ORGANIZATIONMA) {
- ORGANIZATIONMA = item.INSTCODE;
- }
- })
- self.data.ARCHCODE = "X154-WS・" + self.data.ARCHYEAR + "-" + MIJIQIXIAN + "-" + ORGANIZATIONMA + "-" + JIANHAO(self.data.JIANHAO)
- var data = {
- routeinfoid: self.routeinfoid,
- data: JSON.stringify(self.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();
- 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, ' '));
- };
- });
- function JIANHAO(n) {
- if (n < 10) {
- return "000" + n;
- } else if (n > 10 &&n < 100) {
- return "00" + n;
- } else if (n > 100 && n < 1000) {
- return "0" + n;
- } else {
- return n
- }
- }
|