123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470 |
- '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.get_AccessToken = localStorage.getItem("GlWorkPlatform-AccessToken");
- self.routeinfoid = sp.getUrlName("routeinfoid");
- self.id = sp.getUrlName("id");
- self.deviceType = localStorage.getItem("tjJxtGoldenlinkWork-deviceType");
- self.lastReturn = sp.getUrlName("lastReturn")
- self.info = JSON.parse($.cookie("GlWorkPlatform-gdsp"))
- self.guidangList = []
- self.show = 1;
- var postCfg = {
- headers: {
- 'Content-Type': 'application/json',
- 'Authorization': "Bearer " + self.get_AccessToken
- }
- };
- self.goBack = function () {
- window.location.href = "ygdlist.html?lastReturnPageno=" + sp.getUrlName("lastReturnPageno")
- }
- //初始化右上角按钮
- self.buttonList = []
- self.readonly = {
- LC: false,
- BT: false,
- WH: false,
- GDCS: false,
- GDRY: false,
- CSYJ: false,
- BZ: false
- }
-
- self.getDP = function () {
- var data = {
- userid: self.userId
- }
- $http.post(apiurljs.login + "g2app/richang/queryDpInfo", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
- .success(function (obj) {
- var res = strToJson(s4.decryptData_CBC(obj.data));
- self.userDpName = res.data.length == 0 ? "" : res.data[0].SECTION;
- self.userDpCode = res.data.length == 0 ? "" : res.data[0].CODE;
- self.getGDBM();
- })
- }
- self.getDP()
- self.getGDBM = function () {
- var data = {
- unitid: "AA"
- }
- $http.post(apiurljs.login + "g2app/dataabase/queryDanganSectByCode", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
- .success(function (obj) {
- var res = strToJson(s4.decryptData_CBC(obj.data));
- self.GDBM = res.data;
- if (self.routeinfoid == 0) {
- self.getWENHAO();
- } else {
- self.getWENHAO();
- }
- })
- }
- self.getWENHAO = function () {
- var data = {
- routeinfoid: self.routeinfoid,
- flowid:self.info.FLOWID
- }
- $http.post(apiurljs.login + "g2app/DangAn/queryDataByRouteinfoid", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
- .success(function (obj) {
- var res = strToJson(s4.decryptData_CBC(obj.data));
- if (res.data.length > 0) {
- self.WENHAO = res.data[0].WENHAO;
- } else {
- self.WENHAO = "";
- }
- self.getData();
- })
- }
- //获取数据
- self.getData = function () {
- var data = {
- tablename: "DA_YGD",
- colums: "*",
- order: "ID",
- sqlwhere: { GLROUTEINFOID: self.routeinfoid },
- sqlinwhere: "",
- sqllikewhere: ""
- }
- if (self.lastReturn == "list") {
- data.sqlwhere = { ID: sp.getUrlName("ID") }
- }
- $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));
- console.log(res.data)
- if (res.data[0]) {
- self.data = {
- ID: res.data[0].ID,
- FONDS_CODE: res.data[0].FONDS_CODE,
- SERIES_CODE: res.data[0].SERIES_CODE,
- FILE_CODE: res.data[0].FILE_CODE,
- TITLE_PROPER: res.data[0].TITLE_PROPER,
- DATE_OF_CREATION: sp.format(res.data[0].DATE_OF_CREATION),
- OA_ID: res.data[0].OA_ID,
- OFFICE_ARCHIVAL_CODE: res.data[0].OFFICE_ARCHIVAL_CODE,
- AUTHOR: res.data[0].AUTHOR,
- AMOUNT_OF_PAGES: res.data[0].AMOUNT_OF_PAGES,
- YEAR_CODE: res.data[0].YEAR_CODE,
- ITEM_NO: res.data[0].ITEM_NO,
- ITEM_COUNT: res.data[0].ITEM_COUNT,
- RETENTION_PERIOD: res.data[0].RETENTION_PERIOD,
- FILING_DEPT: res.data[0].FILING_DEPT,
- FILENAME: res.data[0].FILENAME,
- ZHANGTOP: res.data[0].ZHANGTOP,
- ZHANGLEFT: res.data[0].ZHANGLEFT
- }
- } else {
- self.data = {
- ID: 0,
- FONDS_CODE: "X154",
- SERIES_CODE: "WS",
- FILE_CODE: self.WENHAO,
- TITLE_PROPER: self.info.TITLE,
- DATE_OF_CREATION: "",
- OA_ID: "",
- OFFICE_ARCHIVAL_CODE:"",
- AUTHOR:"",
- AMOUNT_OF_PAGES:"",
- YEAR_CODE: sp.currentYear(),
- ITEM_NO: "",
- ITEM_COUNT:"",
- RETENTION_PERIOD:"D10",
- FILING_DEPT: self.userDpName,
- FILENAME:"",
- ZHANGTOP: "",
- ZHANGLEFT: "",
- GLROUTEINFOID: self.routeinfoid,
- CDATE: sp.getLocalDate(),
- STATUS:0
- }
- }
- self.getYGD()
- })
- }
- self.getYGD = function () {
- var data = {
- routeinfoid: self.routeinfoid,
- converttype: "3"
- }
- $http.post(apiurljs.login + "g2app/DangAn/queryYJYGDWenJianList",{ data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
- .success(function (obj) {
- var res = strToJson(s4.decryptData_CBC(obj.data));
- self.fileList = res.data[0].DATA;
- self.getGDFile();
- })
- }
- self.getGDFile = function () {
- var data = {
- tablename: "DA_YJYGDFILEATTACH",
- colums: "*",
- order: "SORTID",
- sqlwhere: { ROUTEINFOID: self.data.ID },
- 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.guidangList = res.data.filter(function (item) { return item.ATTACHTYPE == "" });
- self.fileList.forEach(function (item) {
- var n = 0;
- self.guidangList.forEach(function (item1) {
- if (item.WENJIANMING == item1.FILENAMES) {
- item.show = false;
- n++
- }
- })
- if (n == 0) {
- item.show = true;
- }
- })
- $("#table_tbody").sortable({
- cursor: "move",
- stop: function (event, ui) {
- var index = 1;
- $("#table_tbody").children().each(function (x) {
- $(this).attr("index", index)
- $(this).children().eq(0).html(index)
- index++
- })
- }
- }).disableSelection();
- })
- }
-
- //保存提交
- self.btnSave = function () {
- if (spngvld.submit(".formedit")) {
- var data = {
- tablename: "DA_YGD",
- id: self.data.ID,
- data: {
- FONDS_CODE: self.data.FONDS_CODE,
- SERIES_CODE: self.data.SERIES_CODE,
- FILE_CODE: self.data.FILE_CODE,
- TITLE_PROPER: self.data.TITLE_PROPER,
- DATE_OF_CREATION: self.data.DATE_OF_CREATION,
- OA_ID: self.data.OA_ID,
- OFFICE_ARCHIVAL_CODE: self.data.OFFICE_ARCHIVAL_CODE,
- AUTHOR: self.data.AUTHOR,
- AMOUNT_OF_PAGES: self.data.AMOUNT_OF_PAGES,
- YEAR_CODE: self.data.YEAR_CODE,
- ITEM_NO: self.data.ITEM_NO,
- ITEM_COUNT: self.data.ITEM_COUNT,
- RETENTION_PERIOD: self.data.RETENTION_PERIOD,
- FILING_DEPT: self.data.FILING_DEPT,
- FILENAME: self.data.FILENAME,
- ZHANGTOP: self.data.ZHANGTOP,
- ZHANGLEFT: self.data.ZHANGLEFT,
- GLROUTEINFOID: self.data.GLROUTEINFOID,
- CDATE: self.data.CDATE,
- STATUS: self.data.STATUS
- }
- }
- $http.post(apiurljs.login + "g2app/dataabase/saveChildData", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
- .success(function (obj) {
- var res = strToJson(s4.decryptData_CBC(obj.data));
- if (res.code == 0) {
- self.id = res.data.ID;
- self.getData()
- self.show = 2;
- } else {
- sp.dialog(res.message)
- }
- })
- }
- }
- self.addFile = function (obj) {
- var data = {
- tablename: "DA_YJYGDFILEATTACH",
- data: {
- FILENAMES: obj.WENJIANMING,
- FILEOLDNAME: obj.WENJIANMING,
- FILEEXT: obj.PREFIX,
- FILESIZE: "",
- FILEDATE: obj.RIQI,
- FILEID: "",
- FILEURL: obj.URL,
- FILETBURL: "",
- ATTACHTYPE: "",
- FILECDATE: "",
- CONVERTID: "",
- FILEPAGE: obj.YESHU,
- ROUTEINFOID: self.data.ID
- }
- }
- $http.post(apiurljs.login + "g2app/dataabase/insertFormData", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
- .success(function (obj) {
- var res = strToJson(s4.decryptData_CBC(obj.data));
- if (res.success) {
- self.getYGD();
- } else {
- sp.dialog(res.message);
- }
- })
- }
- self.delFile = function (obj) {
- var data = {
- tablename: "DA_YJYGDFILEATTACH",
- id: obj.ID
- };
- $http.post(apiurljs.login + "g2app/dataabase/delDataById", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
- .success(function (obj) {
- var res = strToJson(s4.decryptData_CBC(obj.data));
- if (res.success) {
- self.getYGD();
- } else {
- sp.dialog(res.message);
- }
- });
- }
- self.sortUp = function (num) {
- var IDS = [{ ID: self.guidangList[num].ID }, { ID: self.guidangList[num - 1].ID }]
- var SORTIDS = [{ SORTID: self.guidangList[num - 1].SORTID }, { SORTID: self.guidangList[num].SORTID }]
- var data = {
- entity: "DA_YJYGDFILEATTACH",
- data: SORTIDS,
- setwhere: IDS
- }
- $http.post(apiurljs.login + "g2app/Data/UpdataByWhereList", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
- .success(function (obj) {
- var res = strToJson(s4.decryptData_CBC(obj.data));
- if (res.success) {
- self.getGDFile();
- } else {
- sp.dialog(res.message);
- }
- })
- }
- self.sortDown = function (num) {
- var IDS = [{ ID: self.guidangList[num].ID }, { ID: self.guidangList[num + 1].ID }]
- var SORTIDS = [{ SORTID: self.guidangList[num + 1].SORTID }, { SORTID: self.guidangList[num].SORTID }]
- var data = {
- entity: "DA_YJYGDFILEATTACH",
- data: SORTIDS,
- setwhere: IDS
- }
- $http.post(apiurljs.login + "g2app/Data/UpdataByWhereList", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
- .success(function (obj) {
- var res = strToJson(s4.decryptData_CBC(obj.data));
- if (res.success) {
- self.getGDFile();
- } else {
- sp.dialog(res.message);
- }
- })
- }
- self.uploading = false;
- self.upload = function () {
- //var uploadformat = strToJson(s4.decryptData_CBC(apiurljs.uploadformat)).data.map(function (item) {
- // return item.CNAME
- //})
- $('#fileupload').fileupload({
- url: apiurljs.login + 'g2app/abase/uploadFileWithForm',
- dataType: 'json',
- beforeSend: function (xhr, data) {
- xhr.setRequestHeader("Authorization", "Bearer " + self.get_AccessToken);
- xhr.setRequestHeader("File-Argument", s4.encryptData_CBC("tablename=DA_YJYGDFILEATTACH,routeinfoid=" + self.data.ID));
- },
- add: function (e, data) {
- var num = 0;
- //var acceptFileTypes = eval('/(' + uploadformat.join("|") + ')$/i')
- var acceptFileTypes = eval('/(pdf)$/i')
- //文件类型判断
- $.each(data.originalFiles, function (index, item) {
- if (item['type'].length > 0 && !acceptFileTypes.test(item['name'])) {
- //sp.dialog("您好,请上传" + uploadformat.join("/") + "格式的文件!");
- sp.dialog("您好,请上传pdf格式的文件!");
- return;
- } else {
- num++
- }
- })
- if (num == data.originalFiles.length) {
- self.uploading = true;
- data.submit();
- $scope.$apply();
- }
- },
- // 上传完成后的执行逻辑
- done: function (e, data) {
- self.uploading = false;
- self.getGDFile()
- }
- })
- }
- self.btnSaveFiles = function () {
- var IDS = [], SORTIDS = [];
- self.guidangList.forEach(function (item) {
- $("#table_tbody").children().each(function (index) {
- if ($(this).attr("data-col") == item.ID) {
- IDS.push({ ID: item.ID })
- SORTIDS.push({ SORTID: self.guidangList[$(this).attr("index") - 1].SORTID })
- }
- })
- })
- var data = {
- entity: "DA_YJYGDFILEATTACH",
- data: SORTIDS,
- setwhere: IDS
- }
- $http.post(apiurljs.login + "g2app/Data/UpdataByWhereList", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
- .success(function (obj) {
- var res = strToJson(s4.decryptData_CBC(obj.data));
- if (res.success) {
- self.getGDFile();
- } else {
- sp.dialog(res.message);
- }
- })
- }
- self.MergeByFile = function () {
- var data = {
- files: [],
- converttype: 3,
- routeinfoid: self.data.ID,
- gdzdata: ['全宗号', '年度', '件号', "X154", self.data.YEAR_CODE, self.data.ITEM_NO, '机构', '保管期限', '页数', self.data.FILING_DEPT, self.data.RETENTION_PERIOD, self.data.AMOUNT_OF_PAGES],
- marginLeft: 755,//self.data.ZHANGLEFT,
- marginBottom: 440//self.data.ZHANGTOP
- }
- self.guidangList.forEach(function (item) {
- data.files.push({ fileurl: item.FILEURL })
- })
- $http.post(apiurljs.login + "g2app/DangAn/queryYJYGDMergeByFile", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
- .success(function (obj) {
- var res = strToJson(s4.decryptData_CBC(obj.data));
- self.seeFiles(res.data.DATA,1)
- self.show = 3;
- })
- }
- // 查看文件
- self.seeFiles = function (obj,n) {
- var set_convertType = 0;
- if (n == 3) {
- obj.FILEURL = obj.URL;
- obj.FILEEXT = obj.PREFIX;
- }
- if (obj.FILEEXT == "doc") {
- set_convertType = 0;
- } else if (obj.FILEEXT == "pdf") {
- set_convertType = 20;
- } else if (obj.FILEEXT == "ofd") {
- set_convertType = 570;
- } else {
- set_convertType = 0;
- }
- let postData = {
- convertType: set_convertType,
- isSignature: 1,
- fileUrl: apiurljs.login + "g2work/files2/inline/" + obj.FILEURL.slice(7)
- };
- var postCfg_transfer = {
- headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
- transformRequest: function (data) {
- return $.param(data);
- }
- };
- $http.post(apiurljs.login.split("glwork/")[0] + "fcscloud/composite/httpfile", postData, postCfg_transfer)
- .success(function (res) {
- if (res.errorcode === 0) {
- if (n == 1) {
- $("#filesId").attr("src", res.data.viewUrl)
- } else {
- window.open(res.data.viewUrl)
- }
- } else {
- sp.dialog(res.message);
- }
- });
- }
- //头部下滚冻结
- $(function () {
- $(".sp-page-center").css("max-height", $(window).height() - 58).css("height", $(window).height() - 58)
- //页面高度撑满
- setTimeout(function () {
- if ($(".ibox-content").height() < $(window).height() - 31) {
- $(".ibox-content").css("height", $(window).height() - 31)
- }
- }, 1)
- })
- }])
|