123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201 |
- 'use strict';
- var app = angular.module('app', [
- ]);
- app.controller("detailCtrl", ["$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_lastReturnPageno = sp.getUrlName("lastReturnPageno");
- self.get_id = sp.getUrlName("id");
- self.return = "list.html?lastReturnPageno=" + self.get_lastReturnPageno
- var postCfg = {
- headers: {
- 'Content-Type': 'application/json',
- 'Authorization': "Bearer " + self.get_AccessToken
- }
- };
-
- //上传附件
- self.beforeUpload = function () {
- if (self.data.ID == 0) {
- var data = {
- tablename: "SX_SJPSWJTZ",
- data: {
- LWDW: self.data.LWDW,
- WJMC: self.data.WJMC,
- SJPS: self.data.SJPS,
- QPSJ: self.data.QPSJ,
- BLJD: self.data.BLJD,
- DBTX: self.data.DBTX,
- DBTXTIME: self.data.DBTXTIME,
- REMARK: self.data.REMARK,
- FLOWROUTEINFOID: "",
- USERID: self.userId,
- SECTCODE: self.userDpCode,
- CDATE: sp.getLocalDate()
- }
- }
- $http.post(apiurljs.login + "g2app/DangJian/insertFormData", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
- .success(function (obj) {
- var res = strToJson(s4.decryptData_CBC(obj.data));
- if (res.code == 0) {
- self.get_id = res.data;
- self.getData();
- self.upload()
- } else {
- sp.dialog(res.message)
- }
- })
- } else {
- self.upload()
- }
- }
- self.upload = function () {
- $('#fileupload').fileupload({
- url: apiurljs.login + 'g2app/abase/saveUploadFileName',
- dataType: 'json',
- beforeSend: function (xhr, data) {
- xhr.setRequestHeader("Authorization", "Bearer " + self.get_AccessToken);
- xhr.setRequestHeader("File-Argument", s4.encryptData_CBC("tablename=SX_SJPSWJTZ,column=FILEATTACH,id=" + self.get_id + ",routeinfoid=" + self.get_id + ",loaded=" + data.loaded + ",total=" + data.total));
- },
- // 上传完成后的执行逻辑
- done: function (e, data) {
- var arrayFile = strToJson(s4.decryptData_CBC(data.result.data).slice(0, s4.decryptData_CBC(data.result.data).lastIndexOf("}") + 1))
- self.arrayFile = arrayFile.data;
- $scope.$apply();//绑定数据局部刷新
- }
- })
- $timeout(function () {
- $("#fileupload").trigger("click")
- }, 1)
- }
- 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.getData();
- })
- }
- self.getData = function () {
- if (self.get_id == 0) {
- self.data = {
- ID: 0,
- LWDW: "",
- WJMC: "",
- SJPS: "",
- QPSJ: sp.format(sp.getLocalDate()),
- BLJD: "",
- DBTX: "",
- DBTXTIME: sp.format(sp.getLocalDate()),
- REMARK: ""
- }
- self.arrayFile = [];
- } else {
- var data = {
- tablename: "SX_SJPSWJTZ",
- colums: "*",
- order: "ID",
- sqlwhere: {
- ID: self.get_id
- },
- 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.data = {
- ID: res.data[0].ID,
- LWDW: res.data[0].LWDW ? res.data[0].LWDW : "",
- WJMC: res.data[0].WJMC ? res.data[0].WJMC : "",
- SJPS: res.data[0].SJPS ? res.data[0].SJPS : "",
- QPSJ: res.data[0].QPSJ ? sp.format(res.data[0].QPSJ) : sp.format(sp.getLocalDate()),
- BLJD: res.data[0].BLJD ? res.data[0].BLJD : "",
- DBTX: res.data[0].DBTX ? res.data[0].DBTX : "",
- DBTXTIME: res.data[0].DBTXTIME ? sp.format(res.data[0].DBTXTIME) : sp.format(sp.getLocalDate()),
- REMARK: res.data[0].REMARK ? res.data[0].REMARK : ""
- }
- if (res.data[0].FILEATTACH && res.data[0].FILEATTACH != "") {
- self.arrayFile = JSON.parse(res.data[0].FILEATTACH);
- }
- })
- }
- }
- self.getDP()
- self.btnSave = function () {
- if (self.data.ID == 0) {
- var data = {
- tablename: "SX_SJPSWJTZ",
- data: {
- LWDW: self.data.LWDW,
- WJMC: self.data.WJMC,
- SJPS: self.data.SJPS,
- QPSJ: self.data.QPSJ,
- BLJD: self.data.BLJD,
- DBTX: self.data.DBTX,
- DBTXTIME: self.data.DBTXTIME,
- REMARK: self.data.REMARK,
- FLOWROUTEINFOID: "",
- USERID: self.userId,
- SECTCODE: self.userDpCode,
- CDATE: sp.getLocalDate()
- }
- }
- $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) {
- sp.dialog("保存成功!");
- self.get_id = res.data;
- self.getData();
- $timeout(function () {
- sp.dialoghide();
- }, 1000)
- } else {
- sp.dialog(res.message);
- }
- })
- } else {
- var data = {
- id: self.data.ID,
- tablename: "SX_SJPSWJTZ",
- data: {
- LWDW: self.data.LWDW,
- WJMC: self.data.WJMC,
- SJPS: self.data.SJPS,
- QPSJ: self.data.QPSJ,
- BLJD: self.data.BLJD,
- DBTX: self.data.DBTX,
- DBTXTIME: self.data.DBTXTIME,
- REMARK: self.data.REMARK,
- }
- }
- $http.post(apiurljs.login + "g2app/dataabase/upFormData", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
- .success(function (obj) {
- var res = strToJson(s4.decryptData_CBC(obj.data));
- if (res.success) {
- sp.dialog("保存成功!");
- self.getData();
- $timeout(function () {
- sp.dialoghide();
- }, 1000)
- } else {
- sp.dialog(res.message);
- }
- })
- }
- }
- }])
|