123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112 |
- 'use strict';
- var app = angular.module('app', []);
- app.controller("GLJCtrl", ["$scope", "$http", "$timeout", function ($scope, $http, $timeout) {
- 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.routeid = sp.getUrlName("routeid");
- self.routeinfoid = sp.getUrlName("routeinfoid");
- self.copyrightid = sp.getUrlName("copyrightid");
- self.directionid = sp.getUrlName("directionid");
- self.formeditid = sp.getUrlName("formeditid");
- var postCfg = {
- headers: {
- 'Content-Type': 'application/json',
- 'Authorization': "Bearer " + self.get_AccessToken
- }
- };
- var uploadformat = strToJson(s4.decryptData_CBC(apiurljs.uploadformat)).data.map(function (item) {
- return item.CNAME
- })
- self.getGLJ1 = function () {
- var data = {
- userid: ""
- }
- $http.post(apiurljs.login + "g2work/routeinfo/queryDataRelatedDocfileType", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
- .success(function (obj) {
- var res = strToJson(s4.decryptData_CBC(obj.data));
- self.gljList = res.data;
- })
- }
- self.getGLJ1()
- self.newMoBan1 = function (GWZL) {
- var data = {
- dockind: "D01",
- routeinfoid: self.routeinfoid,
- gwtype: GWZL,
- filekind: "DOCFILE"
- }
- $http.post(apiurljs.login + "g2app/fawenfilesrelate/newDataFile", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
- .success(function (obj) {
- var res = strToJson(s4.decryptData_CBC(obj.data));
- if (res.success) {
- window.parent.refreshGLJ(1)
- window.parent.sp.layerhide()
- } else {
- window.top.sp.dialog("创建失败,请联系管理员!")
- }
- })
- }
- self.newMoBan2 = function (GWZL) {
- var data = {
- dockind: "D01",
- routeinfoid: self.routeinfoid,
- gwtype: GWZL,
- filekind: "REDFILE"
- }
- $http.post(apiurljs.login + "g2app/fawenfilesrelate/newDataFile", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
- .success(function (obj) {
- var res = strToJson(s4.decryptData_CBC(obj.data));
- if (res.success) {
- window.parent.refreshGLJ(1)
- window.parent.sp.layerhide()
- } else {
- window.top.sp.dialog("创建失败,请联系管理员!");
- }
- })
- }
- self.newMoBan3 = function (GWZL) {
- $('#fileupload-zw').fileupload({
- url: apiurljs.login + 'g2app/fawenfilesrelate/uploadFileWithForm',
- dataType: 'json',
- beforeSend: function (xhr, data) {
- xhr.setRequestHeader("Authorization", "Bearer " + self.get_AccessToken);
- xhr.setRequestHeader("File-Argument", s4.encryptData_CBC("tablename=FAWEN_FILES_RELATE,routeinfoid=" + self.routeinfoid + ",gwtype=" + GWZL + ",dockind=D01"));
- },
- add: function (e, data) {
- var num = 0;
- var acceptFileTypes = eval('/(' + uploadformat.join("|") + ')$/i')
- //文件类型判断
- $.each(data.originalFiles, function (index, item) {
- if (item['type'].length > 0 && !acceptFileTypes.test(item['name'])) {
- sp.dialog("您好,请上传" + uploadformat.join("/") + "格式的文件!");
- return;
- } else {
- num++
- }
- })
- if (num == data.originalFiles.length) {
- data.submit();
- $scope.$apply();
- }
- },
- // 上传完成后的执行逻辑
- done: function (e, data) {
- window.parent.refreshGLJ(1)
- window.parent.sp.layerhide()
- }
- })
- $timeout(function () {
- $("#fileupload-zw").trigger("click")
- }, 1)
- }
- }])
|