'use strict'; var app = angular.module('app', [ 'angularUtils.directives.dirPagination' ]); app.controller("indexCtrl", ["$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"); self.get_type = sp.getUrlName("type"); var postCfg = { headers: { 'Content-Type': 'application/json', 'Authorization': "Bearer " + self.get_AccessToken } } //获取车型,分类,状态代码表 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.getData(1); }) .error(function (XMLHttpRequest, textStatus, errorThrown) { }) } self.getCxList(); //根据选择的底稿目录获取当前目录下的文件 self.noDataTip = 1; self.rows = []; self.pageno = 1; self.total_count = 0; self.itemsPerPage = 10; self.pageOptions = [10, 15, 20, 25, 30]; self.search = { CPH: "" } self.getData = function (pageno) { self.pageno = pageno; $scope.__default__currentPage = self.pageno; // let postData = { // "pageno": self.pageno, // "pagesize": self.itemsPerPage, // "code": self.nowNodeCode, // "data_col": "YPBH", // "tablename_code": "CODE_YPTYPE", // "tablename_data": "SX_BGYPMGR", // "order": "id", // "sqlwhere": {}, // "sqllikewhere": { // "YPMC": self.search.YPMC // } // } let postData = { tablename: "SX_CLGLB", pagesize: self.itemsPerPage, pageno: self.pageno, colums: "ID,SORTID,CPH,PP,CLYS,ZCRS,CX", order: "ID", sqlwhere: {}, sqlorwhere: "", sqlinwhere: "", sqllikewhere: { CPH: self.search.CPH, } } $http.post(apiurljs.login + "g2app/dataabase/queryDataByColWithPage", {data: s4.encryptData_CBC(JSON.stringify(postData))}, postCfg) .success(function (res) { var res = strToJson(s4.decryptData_CBC(res.data)); if (sp.isval(res.data)) { res.data.forEach(function (item) { self.cxList.forEach(function (item2) { if (item.CX == item2.CODE) { item.CXNAME = item2.CNAME; } }) }) self.noDataTip = 1; self.rows = res.data; self.total_count = res.totalCount; } else { self.rows = []; self.noDataTip = 0; } }).error(function (err) { sp.dialog(JSON.stringify(err)); }); } //弹出筛选框 self.openSearchLayer = function () { sp.layer("#layer_search"); } self.doSearch = function () { sp.closeCenter('.sp-layer'); self.pageno = 1; // 初始化 当前页为 1 self.getData(self.pageno); } //新增数据 self.insertData = []; self.opneInsertLayer = function () { self.insertData = []; sp.layer('#layer_insert'); } self.addItemData = function () { self.insertData.push({ CPH: "", PP: "", CLYS: "", ZCRS: "", CX: self.cxList[0].CODE }); } self.deleteItem = function (index) { self.insertData.splice(index, 1); } self.saveInsertData = function () { if (spngvld.submit("#layer_insert")) { var postData = { "tablename": "SX_CLGLB", "data": [] } self.insertData.forEach(function (item) { postData.data.push({ PP: item.PP, CLYS: item.CLYS, ZCRS: item.ZCRS, CX: item.CX, CUSERID: self.userId, CDATE: sp.getLocalDate() }); }); $http.post(apiurljs.login + "g2app/dataabase/insertDataList", {data: s4.encryptData_CBC(JSON.stringify(postData))}, postCfg) .success(function (obj) { sp.closeCenter('.sp-layer'); var res = strToJson(s4.decryptData_CBC(obj.data)); if (res.success) { self.getData(1); } else { sp.dialog(res.message); } }) .error(function (XMLHttpRequest, textStatus, errorThrown) { }) } } self.deleteData = function ($item) { var getDelID = $item.ID; var dialogHead = "温馨提示×"; var dialogBody = "