123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123 |
- '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.get_id = sp.getUrlName("id");
- self.get_lastReturnPageno = sp.getUrlName("lastReturnPageno");
- self.get_lastReturnPage = sp.getUrlName("lastReturnPage");
- self.return = "../list.html?lastReturnPageno=" + self.get_lastReturnPageno + "&type=2"
- self.deviceType = localStorage.getItem("tjJxtGoldenlinkWork-deviceType");
- var postCfg = {
- headers: {
- 'Content-Type': 'application/json',
- 'Authorization': "Bearer " + self.get_AccessToken
- }
- };
- self.FormTitle = $.cookie("GlWorkPlatform-SYSNAME");
- self.getEditData = function () {
- if (self.get_id != 0) {
- var data = {
- tablename: "SX_HYSGLB",
- colums: "*",
- order: "ID",
- sqlwhere: { ID: self.get_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.data = {
- ID: self.get_id,
- HYSMC: res.data[0].HYSMC,
- KRNRS: res.data[0].KRNRS,
- SB: res.data[0].SB,
- WZ: res.data[0].WZ,
- GLY: res.data[0].GLY,
- ZT: res.data[0].ZT,
- BZ: res.data[0].BZ
- }
- })
- } else {
- self.data = {
- ID: 0,
- HYSMC: "",
- KRNRS: "",
- SB: "",
- WZ: "",
- GLY: "",
- ZT: "正常",
- BZ: ""
- }
- }
- }
- self.getEditData()
- self.btnSave = function () {
- if (self.get_id == 0) {
- var data = {
- tablename: "SX_HYSGLB",
- data: {
- HYSMC: self.data.HYSMC,
- KRNRS: self.data.KRNRS,
- SB: self.data.SB,
- WZ: self.data.WZ,
- GLY: self.data.GLY,
- ZT: self.data.ZT,
- BZ: self.data.BZ
- }
- }
- $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.getEditData();
- $timeout(function () {
- sp.dialoghide();
- }, 1000)
- } else {
- sp.dialog(res.message);
- }
- })
- } else {
- var data = {
- id: self.get_id,
- tablename: "SX_HYSGLB",
- data: {
- HYSMC: self.data.HYSMC,
- KRNRS: self.data.KRNRS,
- SB: self.data.SB,
- WZ: self.data.WZ,
- GLY: self.data.GLY,
- ZT: self.data.ZT,
- BZ: self.data.BZ
- }
- }
- $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.getEditData();
- $timeout(function () {
- sp.dialoghide();
- }, 1000)
- } else {
- sp.dialog(res.message);
- }
- })
- }
- }
- }])
|