123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290 |
- 'use strict';
- var app = angular.module('app', [
- 'angularUtils.directives.dirPagination'
- ]);
- app.controller("taizhangCtrl", ["$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.get_lastReturnPageno = sp.getUrlName("lastReturnPageno");
- var postCfg = {
- headers: {
- 'Content-Type': 'application/json',
- 'Authorization': "Bearer " + self.get_AccessToken
- }
- }
- self.search = {
- DATE1: "",
- DATE2: ""
- }
- self.info = {
- CPH: "",
- CX: "",
- CX1: "",
- CLYS: "",
- XH: ""
- }
- //获取车型,分类,状态代码表
- self.cxList = [];
- self.getCxList = function () {
- var postData = {
- tablename: "CODE_CXDMB"
- }
- $http.post(apiurljs.login + "g2app/DangAn/queryCodeData", { data: s4.encryptData_CBC(JSON.stringify(postData)) }, postCfg)
- .success(function (obj) {
- var res = strToJson(s4.decryptData_CBC(obj.data));
- self.cxList = angular.copy(res.data);
- self.getCPH()
- })
- .error(function (XMLHttpRequest, textStatus, errorThrown) {
- })
- }
- self.getCxList();
- self.getCPH = function () {
- var data = {
- tablename: "SX_CLGLB",
- colums: "*",
- order: "ID",
- sqlwhere: "",
- 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.CPHlist = res.data;
- console.log(res.data)
- self.CPHlist.forEach(function (item) {
- self.cxList.forEach(function (item1) {
- if (item.CX == item1.CODE) {
- item.CX1 = item1.CNAME;
- }
- })
- })
- self.info = {
- CPH: self.CPHlist[0].CPH,
- CX: self.CPHlist[0].CX,
- CX1: self.CPHlist[0].CX1,
- CLYS: self.CPHlist[0].CLYS,
- XH: self.CPHlist[0].XH
- }
- self.getData()
- })
- }
- self.getData = function () {
- var data = {
- tablename: "SX_CLJYJLB",
- colums: "*",
- order: "ID",
- sqlwhere: " and CPH = '" + self.info.CPH + "'" + (self.search.DATE1 != "" ? " and CTIME BETWEEN '" + self.search.DATE1 + " 00:00:00' AND '" + (self.search.DATE2 != "" ? self.search.DATE2 : self.search.DATE1) + " 23:59:59'" : "")
- }
- $http.post(apiurljs.login + "g2app/dataabase/queryDataByColStr", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
- .success(function (obj) {
- var res = strToJson(s4.decryptData_CBC(obj.data));
- self.list = res.data;
- self.addFlag = false;
- self.editFlag = false;
- self.list.forEach(function (item) {
- item.editFlag = false;
- item.CTIME1 = item.CTIME;
- item.JYADDR1 = item.JYADDR;
- item.ZLCS1 = item.ZLCS;
- item.JYSL1 = item.JYSL;
- item.JYDJ1 = item.JYDJ;
- item.JYRXM1 = item.JYRXM;
- item.REMARK1 = item.REMARK;
- })
- })
- }
- self.insertData = [];
- self.addItemData = function () {
- self.addFlag = true;
- self.insertData.push({
- CPH: self.info.CPH,
- CX: self.info.CX,
- CLYS: self.info.CLYS,
- XH: self.info.XH,
- CTIME: sp.getLocalDate(),
- JYADDR: "",
- ZLCS: "",
- JYSL: "",
- JYRXM: "",
- REMARK: "",
- JYDJ: ""
- });
- }
- self.editItem = function (obj) {
- self.editFlag = true;
- obj.editFlag = true;
- }
- self.delItem = function (item) {
- 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='delDataTrue' 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.closeCenter(".sp-dialog");
- event.preventDefault();
- event.stopPropagation();
- });
- //post消息的id
- $("#delDataTrue").click(function () {
- var data = {
- tablename: "SX_CLJYJLB",
- id: item.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));
- sp.dialoghide();
- if (res.success) {
- self.getData();
- } else {
- sp.dialog("删除失败,请联系管理员!");
- }
- });
- });
- }
- self.saveData = function () {
- var n1 = true, n2 = true;
- if (self.insertData.length > 0) {
- n1 = false;
- var addData = {
- tablename: "SX_CLJYJLB",
- data: []
- }
- self.insertData.forEach(function (item) {
- addData.data.push({
- CPH: item.CPH,
- CLYS: item.CLYS,
- XH: item.XH,
- CX: item.CX,
- CTIME: item.CTIME,
- JYADDR: item.JYADDR,
- ZLCS: item.ZLCS,
- JYSL: item.JYSL,
- JYRXM: item.JYRXM,
- REMARK: item.REMARK,
- JYDJ: item.JYDJ,
- USERID: self.userId,
- CDATE: sp.getLocalDate()
- });
- });
- $http.post(apiurljs.login + "g2app/dataabase/insertDataList", { data: s4.encryptData_CBC(JSON.stringify(addData)) }, postCfg)
- .success(function (obj) {
- sp.closeCenter('.sp-layer');
- var res = strToJson(s4.decryptData_CBC(obj.data));
- if (res.success) {
- n1 = true;
- var editData = {
- entity: "SX_CLJYJLB",
- data: [],
- setwhere: []
- }
- self.list.forEach(function (item) {
- if (item.editFlag == true) {
- editData.data.push({
- CTIME: item.CTIME1,
- JYADDR: item.JYADDR1,
- ZLCS: item.ZLCS1,
- JYSL: item.JYSL1,
- JYRXM: item.JYRXM1,
- REMARK: item.REMARK1,
- JYDJ: item.JYDJ1
- })
- editData.setwhere.push({ ID: item.ID })
- }
- })
- if (editData.data.length > 0) {
- n2 = false;
- $http.post(apiurljs.login + "g2app/Data/UpdataByWhereList", { data: s4.encryptData_CBC(JSON.stringify(editData)) }, postCfg)
- .success(function (obj) {
- var res = strToJson(s4.decryptData_CBC(obj.data));
- if (res.success == true) {
- self.childSaveFlag = false;
- n2 = true;
- if (n1 == true && n2 == true) {
- self.getData();
- }
- } else {
- sp.dialog(res.message)
- }
- })
- } else {
- if (n1 == true && n2 == true) {
- self.getData();
- }
- }
- } else {
- sp.dialog(res.message);
- }
- })
- } else {
- n2 = false;
- var editData = {
- entity: "SX_CLJYJLB",
- data: [],
- setwhere: []
- }
- self.list.forEach(function (item) {
- if (item.editFlag == true) {
- editData.data.push({
- CTIME: item.CTIME1,
- JYADDR: item.JYADDR1,
- ZLCS: item.ZLCS1,
- JYSL: item.JYSL1,
- JYRXM: item.JYRXM1,
- REMARK: item.REMARK1,
- JYDJ: item.JYDJ1
- })
- editData.setwhere.push({ ID: item.ID })
- }
- })
- $http.post(apiurljs.login + "g2app/Data/UpdataByWhereList", { data: s4.encryptData_CBC(JSON.stringify(editData)) }, postCfg)
- .success(function (obj) {
- var res = strToJson(s4.decryptData_CBC(obj.data));
- if (res.success == true) {
- n2 = true;
- if (n1 == true && n2 == true) {
- self.getData();
- }
- } else {
- sp.dialog(res.message)
- }
- })
- }
- }
- self.cancal = function () {
- self.addFlag = false;
- self.editFlag = false
- self.list.forEach(function (item) {
- item.editFlag = false;
- })
- }
- self.openLayer = function () {
- sp.layer("#Search")
- }
- self.doSearch = function () {
- self.getData();
- sp.layerhide()
- }
- }])
|