123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508 |
- '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.routeinfoid = sp.getUrlName("routeinfoid");
- self.id = sp.getUrlName("id");
- self.deviceType = localStorage.getItem("tjJxtGoldenlinkWork-deviceType");
- self.info = JSON.parse($.cookie("GlWorkPlatform-gdsp"))
- self.guidangList = []
- var postCfg = {
- headers: {
- 'Content-Type': 'application/json',
- 'Authorization': "Bearer " + self.get_AccessToken
- }
- };
- self.FormTitle = $.cookie("GlWorkPlatform-SYSNAME");
- //初始化右上角按钮
- self.buttonList = []
- self.readonly = {
- LC: false,
- BT: false,
- WH: false,
- GDCS: false,
- GDRY: false,
- CSYJ: false,
- BZ: false
- }
- self.getDpList = function () {
- var data = {
- unitid: "AA"
- }
- $http.post(apiurljs.login + "g2app/dataabase/querySectByCode", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
- .success(function (obj) {
- var res = strToJson(s4.decryptData_CBC(obj.data));
- self.dpList = [];
- res.data.forEach(function (item) {
- if (item.CHILD_DATA.length == 0) {
- self.dpList.push(item)
- } else {
- item.CHILD_DATA.forEach(function (item1) {
- if (item1.CHILD_DATA.length == 0) {
- self.dpList.push(item1)
- } else {
- item1.CHILD_DATA.forEach(function (item2) {
- if (item2.CHILD_DATA.length == 0) {
- self.dpList.push(item2)
- }
- })
- }
- })
- }
- })
- self.dpList.forEach(function (item) {
- item.checked = false;
- })
- self.DpList = {
- GDCS: JSON.parse(JSON.stringify(self.dpList))
- }
- self.AllCheckedDp = {};
- self.DpLength = {};
- self.selectDpList = {};
- self.getUserList()
- })
- }
- self.getDpList()
- self.getUserList = function () {
- $http.post(apiurljs.login + "g2app/dataabase/getDpList", { data: s4.encryptData_CBC("") }, postCfg)
- .success(function (obj) {
- var res = strToJson(s4.decryptData_CBC(obj.data));
- self.userList = res.data;
- self.userList.forEach(function (item) {
- item.checked = false;
- item.USER.forEach(function (item1) {
- item1.checked = false;
- item1.USHOWNAME1 = item1.USHOWNAME.length > 3 ? item1.USHOWNAME.slice(0, 3) + "..." : item1.USHOWNAME;
- item1.USHOWNAME2 = item1.USHOWNAME.length > 10 ? item1.USHOWNAME.slice(0, 10) + "..." : item1.USHOWNAME
- })
- })
- self.UserList = {
- GDRY: JSON.parse(JSON.stringify(self.userList))
- };
- self.AllChecked = {};
- self.UserLength = {};
- self.selectList = {};
- self.getDP()
- })
- }
- 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.getGDBM();
- })
- }
- self.getGDBM = function () {
- var data = {
- unitid: "AA"
- }
- $http.post(apiurljs.login + "g2app/dataabase/queryDanganSectByCode", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
- .success(function (obj) {
- var res = strToJson(s4.decryptData_CBC(obj.data));
- self.GDBM = res.data;
- if (self.routeinfoid == 0) {
- self.getWENHAO();
- } else {
- self.getData();
- }
- })
- }
- self.getWENHAO = function () {
- var data = {
- routeinfoid: self.info.ROUTEINFOID,
- flowid:self.info.FLOWID
- }
- $http.post(apiurljs.login + "g2app/DangAn/queryDataByRouteinfoid", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
- .success(function (obj) {
- var res = strToJson(s4.decryptData_CBC(obj.data));
- if (res.data.length > 0) {
- self.WENHAO = res.data[0].WENHAO;
- } else {
- self.WENHAO = "";
- }
- self.getData();
- })
- }
- //获取数据
- self.getData = function () {
- var data = {
- tablename: "DA_DAYUGUIDANG",
- colums: "*",
- order: "ID",
- sqlwhere: { ID: self.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));
- if (res.data[0]) {
- self.data = {
- ID: res.data[0].ID,
- LC: res.data[0].LC,
- BT: res.data[0].BT,
- WH: res.data[0].WH,
- GDCS: res.data[0].GDCS,
- GDRY: res.data[0].GDRY,
- BZ: res.data[0].BZ,
- ARCHYEAR: res.data[0].ARCHYEAR,
- ORGANIZATIONMA: res.data[0].ORGANIZATIONMA,
- WENHAO: res.data[0].WENHAO,
- MIJIQIXIAN: res.data[0].MIJIQIXIAN,
- DANGANML: res.data[0].DANGANML,
- DOCUMENTTYPE: res.data[0].DOCUMENTTYPE,
- DOCTITLE: res.data[0].DOCTITLE,
- ZRZ: res.data[0].ZRZ,
- DOCISSUEDDATE: sp.format(res.data[0].DOCISSUEDDATE),
- JIANHAO: res.data[0].JIANHAO,
- YESHU: res.data[0].YESHU,
- BEIZHU: res.data[0].BEIZHU,
- ARCHCODE: res.data[0].ARCHCODE,
- DAROUTEINFOID: res.data[0].DAROUTEINFOID,
- DPNAME: res.data[0].DPNAME,
- DPCODE: res.data[0].DPCODE,
- MOBANNAME: res.data[0].MOBANNAME,
- TABLENAME: res.data[0].TABLENAME
- }
- } else {
- self.data = {
- ID: 0,
- LC: self.info.FLOWNAME,
- BT: self.info.TITLE,
- WH: self.WENHAO,
- GDCS: self.userDpName,
- GDRY: self.userName,
- BZ: "",
- ARCHYEAR: sp.currentYear(),
- ORGANIZATIONMA: self.userDpCode,
- WENHAO: self.WENHAO,
- MIJIQIXIAN: "10年",
- DANGANML: "文书",
- DOCUMENTTYPE: self.info.FLOWNAME,
- DOCTITLE: self.info.TITLE,
- ZRZ: "",
- DOCISSUEDDATE: sp.format(sp.getLocalDate()),
- JIANHAO: 1,
- YESHU: "",
- BEIZHU: "",
- ARCHCODE: "",
- DAROUTEINFOID: self.info.ROUTEINFOID,
- DPNAME: self.userDpName,
- DPCODE: self.userDpCode,
- MOBANNAME: self.info.MOBANNAME,
- TABLENAME: self.info.TABLENAME
- }
- }
- $scope.data = self.data;
- var n = {}, all = {};
- for (var i in self.UserList) {
- self.AllChecked[i] = false;
- self.UserLength[i] = 0;
- self.selectList[i] = []
- n[i] = [];
- all[i] = 0;
- $.each(self.UserList[i], function (index, item) {
- n[i].push(0)
- $.each(item.USER, function (index1, item1) {
- self.UserLength[i]++
- if (self.data.GDRY.indexOf(item1.USHOWNAME) != -1 && i == "GDRY") {
- n[i][index]++;
- item1.checked = true;
- self.selectList[i].push(item1);
- }
- })
- if (n[i][index] == item.USER.length && n[i][index] != 0) {
- item.checked = true;
- all[i]++;
- } else {
- item.checked == false;
- }
- })
- if (all[i] == self.UserList[i].length) {
- self.AllChecked[i] = true;
- } else {
- self.AllChecked[i] = false;
- }
- }
- for (var i in self.DpList) {
- self.AllCheckedDp[i] = false;
- self.DpLength[i] = 0;
- self.selectDpList[i] = []
- all[i] = 0;
- $.each(self.DpList[i], function (index, item) {
- self.DpLength[i]++
- if (self.data.GDCS.indexOf(item.SECTION) != -1 && i == "GDCS") {
- all[i]++;
- item.checked = true;
- self.selectDpList[i].push(item);
- }
- })
- if (all[i] == self.DpList[i].length) {
- self.AllCheckedDp[i] = true;
- } else {
- self.AllCheckedDp[i] = false;
- }
- }
- })
- }
- self.openDpList = function (str) {
- self.filed = str;
- sp.layer("#DpList")
- $("#DpList .sp-page").eq(0).scrollTop(0);
- }
- self.checkAllDp = function () {
- self.AllCheckedDp[self.filed] = !self.AllCheckedDp[self.filed];
- $.each(self.DpList[self.filed], function (index, item) {
- item.checked = self.AllCheckedDp[self.filed];
- })
- self.submitDpList(1)
- }
- self.checkDpItem = function (item) {
- item.checked = !item.checked;
- var n = 0;
- $.each(self.DpList[self.filed], function (index, item) {
- if (item.checked == true) {
- n++
- }
- })
- if (n == self.DpList[self.filed].length) {
- self.AllCheckedDp[self.filed] = true;
- } else {
- self.AllCheckedDp[self.filed] = false;
- }
- self.submitDpList(1)
- }
- self.submitDpList = function (n) {
- var AllCheckedLength1 = 0;
- self.selectDpList[self.filed] = [];
- $.each(self.DpList[self.filed], function (index, item) {
- if (item.checked == true) {
- AllCheckedLength1++;
- self.selectDpList[self.filed].push(item)
- }
- })
- self.data[self.filed] = self.selectDpList[self.filed].map(function (item) {
- return item.SECTION
- }).join(",")
- self.AllCheckedDp[self.filed] = AllCheckedLength1 == self.DpLength[self.filed];
- if (n == 0) {
- sp.layerhide();
- }
- }
- self.openUserList = function (str) {
- self.filed = str;
- sp.layer("#userList")
- $("#userList .sp-page").eq(0).scrollTop(0);
- }
- self.checkAllUser = function () {
- self.AllChecked[self.filed] = !self.AllChecked[self.filed];
- $.each(self.UserList[self.filed], function (index, item) {
- item.checked = self.AllChecked[self.filed];
- $.each(item.USER, function (index1, item1) {
- item1.checked = self.AllChecked[self.filed];
- })
- })
- self.submitUserList(1)
- }
- self.checkUserItem = function (item) {
- item.checked = !item.checked;
- $.each(item.USER, function (index, item1) {
- item1.checked = item.checked;
- })
- var n = 0;
- $.each(self.UserList[self.filed], function (index, item) {
- if (item.checked == true) {
- n++
- }
- })
- if (n == self.UserList[self.filed].length) {
- self.AllChecked[self.filed] = true;
- } else {
- self.AllChecked[self.filed] = false;
- }
- self.submitUserList(1)
- }
- self.checkUser = function (item) {
- item.checked = !item.checked;
- var n = [], all = 0;
- $.each(self.UserList[self.filed], function (x, y) {
- n.push(0);
- $.each(y.USER, function (x1, y1) {
- if (y1.checked == true) {
- n[x]++
- }
- })
- if (n[x] == y.USER.length && n[x] != 0) {
- y.checked = true;
- all++
- } else {
- y.checked = false;
- }
- })
- if (all == self.UserList[self.filed].length) {
- self.AllChecked[self.filed] = true;
- } else {
- self.AllChecked[self.filed] = false;
- }
- self.submitUserList(1)
- }
- self.submitUserList = function (n) {
- var AllCheckedLength = 0;
- self.selectList[self.filed] = [];
- $.each(self.UserList[self.filed], function (index, item) {
- $.each(item.USER, function (index1, item1) {
- if (item1.checked == true) {
- AllCheckedLength++;
- self.selectList[self.filed].push(item1)
- }
- })
- })
- self.data[self.filed] = self.selectList[self.filed].map(function (item) {
- return item.USHOWNAME
- }).join(",")
- if (self.data[self.filed + "ID"] != undefined) {
- self.data[self.filed + "ID"] = self.selectList[self.filed].map(function (item) {
- return item.USERID
- }).join(",")
- }
- self.AllChecked[self.filed] = AllCheckedLength == self.UserLength[self.filed];
- if (n == 0) {
- sp.layerhide();
- }
- }
-
- //保存提交
- self.btnSave = function (n) {
- var data = {
- tablename: "DA_DAYUGUIDANG",
- id: self.data.ID,
- data: {
- LC: self.data.LC,
- BT: self.data.BT,
- WH: self.data.WH,
- GDCS: self.data.GDCS,
- GDRY: self.data.GDRY,
- BZ: self.data.BZ,
- ARCHYEAR: self.data.ARCHYEAR,
- ORGANIZATIONMA: self.data.ORGANIZATIONMA,
- WENHAO: self.data.WENHAO,
- MIJIQIXIAN: self.data.MIJIQIXIAN,
- DANGANML: self.data.DANGANML,
- DOCUMENTTYPE: self.data.DOCUMENTTYPE,
- DOCTITLE: self.data.DOCTITLE,
- ZRZ: self.data.ZRZ,
- DOCISSUEDDATE: self.data.DOCISSUEDDATE,
- JIANHAO: self.data.JIANHAO,
- YESHU: self.data.YESHU,
- BEIZHU: self.data.BEIZHU,
- ARCHCODE: self.data.ARCHCODE,
- DAROUTEINFOID: self.data.DAROUTEINFOID,
- DPNAME: self.data.DPNAME,
- DPCODE: self.data.DPCODE,
- MOBANNAME: self.data.MOBANNAME,
- TABLENAME: self.data.TABLENAME
- }
- }
- $http.post(apiurljs.login + "g2app/dataabase/saveChildData", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
- .success(function (obj) {
- var res = strToJson(s4.decryptData_CBC(obj.data));
- if (res.code == 0) {
- self.id = res.data.ID;
- self.getData()
- } else {
- sp.dialog(res.message)
- }
- })
- }
- // 更新数据
- self.updateBtn=function(){
- console.log("更新---")
- }
- // 生成归档目录
- self.createGuidang = function () {
- var data = {
- routeinfoid: self.routeinfoid,
- }
- $http.post(apiurljs.login + "g2app/DangAn/YJYGDMULU", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
- .success(function (obj) {
- var res = strToJson(s4.decryptData_CBC(obj.data));
- if (res.code == 0) {
- self.guidangList = res.data;
- } else {
- sp.dialog(res.message)
- }
- })
- }
- // 查看文件
- self.searchFiles = function (obj) {
- var set_convertType = 0;
- if (obj.PREFIX == "doc") {
- set_convertType = 0;
- } else if (obj.PREFIX == "pdf") {
- set_convertType = 20;
- } else if (obj.PREFIX == "ofd") {
- set_convertType = 570;
- } else {
- set_convertType = 0;
- }
- let postData = {
- convertType: set_convertType,
- isSignature: 1,
- fileUrl: apiurljs.login + "g2work/files2/inline/" + obj.URL.slice(7)
- };
- var postCfg_transfer = {
- headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
- transformRequest: function (data) {
- return $.param(data);
- }
- };
- $http.post(apiurljs.login.split("glwork/")[0] + "fcscloud/composite/httpfile", postData, postCfg_transfer)
- .success(function (res) {
- if (res.errorcode === 0) {
- $("#filesId").attr("src", res.data.viewUrl)
- } else {
- sp.dialog(res.message);
- }
- });
- }
- //头部下滚冻结
- $(function () {
- $(".sp-page-center").css("max-height", $(window).height() - 58).css("height", $(window).height() - 58)
- //页面高度撑满
- setTimeout(function () {
- if ($(".ibox-content").height() < $(window).height() - 31) {
- $(".ibox-content").css("height", $(window).height() - 31)
- }
- }, 1)
- })
- }])
- var parentData = {}
- function getData() {
- parentData = angular.element(document.getElementById("app")).scope().data
- return parentData
- }
|