var app = angular.module('app', ["angularUtils.directives.dirPagination"]); app.controller("formlistAddCtrl", ["$scope", "$http", "$compile", "$timeout", function ($scope, $http, $compile, $timeout) { var self = this; var s4 = new SM4Util(); sp.fitHeight("#formAddPart", 190); sp.fitHeight("#formTablePart", 80); self.userId = $.cookie("GlWorkPlatform-userid"); self.userName = $.cookie("GlWorkPlatform-username"); self.get_AccessToken = localStorage.getItem("GlWorkPlatform-AccessToken"); self.get_formid = sp.getUrlName("formid"); self.get_ctype = sp.getUrlName("ctype"); self.get_leftActive = sp.getUrlName("leftActive"); self.get_leftActiveType = sp.getUrlName("leftActiveType"); self.loading = false; self.btnGoBack = function () { ///返回上一级 window.location.href = "formlist.html?leftActive=" + self.get_leftActive + "&leftActiveType=" + self.get_leftActiveType; }; var postCfg = { headers: { 'Content-Type': 'application/json', 'Authorization': "Bearer " + self.get_AccessToken } }; //列存储类型 self.columnType = [ { "cval": "varchar", "cname": "文本型", "set_cname": "文本型[varchar]", "set_length": 60, "set_deci": 0, "is_deci": false }, { "cval": "number", "cname": "整数型", "set_cname": "整数型[number]", "set_length": 10, "set_deci": 0, "is_deci": false }, { "cval": "decimal", "cname": "小数型", "set_cname": "小数型[decimal]", "set_length": 18, "set_deci": 2, "is_deci": true }, { "cval": "datetime", "cname": "日期型", "set_cname": "日期型[datetime]", "set_length": 0, "set_deci": 0, "is_deci": false }, {"cval": "image", "cname": "二进制", "set_cname": "二进制[image]", "set_length": 0, "set_deci": 0, "is_deci": false} ] ///控件类型 self.controlType = [ {"cval": "hidden", "cname": "隐藏列", "set_cname": "隐藏列[hidden]", "need_select": false}, {"cval": "edit", "cname": "单行文本", "set_cname": "单行文本[edit]", "need_select": false}, {"cval": "number", "cname": "数值控件", "set_cname": "数值控件[number]", "need_select": false}, {"cval": "datetime", "cname": "日期控件", "set_cname": "日期控件[datetime]", "need_select": false}, {"cval": "image", "cname": "图片控件", "set_cname": "图片控件[image]", "need_select": false}, {"cval": "text", "cname": "多行文本", "set_cname": "多行文本[text]", "need_select": false}, {"cval": "select", "cname": "下拉列表", "set_cname": "下拉列表[select]", "need_select": true}, {"cval": "checkbox", "cname": "多选列", "set_cname": "多选列[checkbox]", "need_select": true}, {"cval": "radiobox", "cname": "单选列", "set_cname": "单选列[radiobox]", "need_select": true}, {"cval": "popchecks", "cname": "弹出多选列", "set_cname": "弹出多选列[popchecks]", "need_select": true}, {"cval": "popradio", "cname": "弹出单选列", "set_cname": "弹出单选列[popradio]", "need_select": true}, {"cval": "attachtree", "cname": "指定分类上传", "set_cname": "指定分类上传[attachtree]", "need_select": false}, {"cval": "attachlist", "cname": "任意附件上传", "set_cname": "任意附件上传[attachlist]", "need_select": false}, {"cval": "ordpasslist", "cname": "传阅记录列", "set_cname": "传阅记录列[ordpasslist]", "need_select": false}, {"cval": "tongzhilist", "cname": "拟发通知书列", "set_cname": "拟发通知书列[tongzhilist]", "need_select": false}, {"cval": "optionbox", "cname": "签写意见列", "set_cname": "签写意见列[optionbox]", "need_select": false}, {"cval": "signabox", "cname": "留痕文本列", "set_cname": "留痕文本列[signabox]", "need_select": false}, { "cval": "departbox", "cname": "部门选择列", "set_cname": "部门选择列[departbox]", "need_select": false }, { "cval": "usersbox", "cname": "人员选择列", "set_cname": "人员选择列[usersbox]", "need_select": false }, { "cval": "iconxing", "cname": "自定义图标", "set_cname": "自定义图标[iconxing]", "need_select": false }, ] //初始值类型 self.initValType = [ {"cval": "", "cname": "[无]", "need_init": false, "need_auto": false}, {"cval": "defined", "cname": "[自定义]", "need_init": true, "need_auto": false}, {"cval": "autoadd", "cname": "自增编号", "need_init": false, "need_auto": true}, {"cval": "currentuserid", "cname": "当前用户ID", "need_init": false, "need_auto": false}, {"cval": "currentusername", "cname": "当前用户名称", "need_init": false, "need_auto": false }, {"cval": "currentsectcode", "cname": "当前用户部门编码", "need_init": false, "need_auto": false}, {"cval": "currentsectname", "cname": "当前用户部门名称", "need_init": false, "need_auto": false }, {"cval": "currentdate", "cname": "当前时间", "need_init": false, "need_auto": false} ] //自增编码前缀选项 self.autoCodeHeadArray = [ {"cval": "当前年", "cname": "当前年"} ] ////初始化左侧效果--start--***************************************** // self.leftActive=0; self.active = { STATUS: 0, TYPE: "" }; ///激活状态的设置,考虑上来就加载和从详情页面返回的两种情况 self.setMsgActive = function () { alert(self.active.STATUS); $(".sp-msg-left-bottom .sp-msg-left-lh").removeClass("sp-msg-left-active"); $(".sp-msg-left-bottom .sp-msg-left-lh:eq(" + self.active.STATUS + ")").addClass("sp-msg-left-active"); }; self.getMsgData = function (str, $item) { self.leftActive = str; self.active = { STATUS: str, TYPE: $item.BILLKEY }; $(".sp-msg-left-bottom .sp-msg-left-lh").removeClass("sp-msg-left-active"); $(".sp-msg-left-bottom .sp-msg-left-lh:eq(" + str + ")").addClass("sp-msg-left-active"); self.getFormFieldData();///加载列数据 }; ////初始化左侧效果--end--***************************************** //加载左侧子表数据--start self.subFormData = []; self.getBasicAndSubForm = function () { self.loading = true; var postData = { formid: self.get_formid } $http.post(apiurljs.login + "g2work/bill/queryData", {data: s4.encryptData_CBC(JSON.stringify(postData))}, postCfg).success(function (obj) { var res = strToJson(s4.decryptData_CBC(obj.data).slice(0, s4.decryptData_CBC(obj.data).lastIndexOf("}") + 1)); if (res.success) { if (sp.isval(res.data)) { self.subFormData = res.data; self.active.TYPE = self.subFormData[0].BILLKEY; self.getFormFieldData(); } else { self.loading = false; self.subFormData = []; } } else { self.loading = false; sp.dialog(res.message); } }); } self.getBasicAndSubForm(); //获取编辑类型的选项数据 self.optionEkind = []; //编辑类型的表选项 self.optionEkindItem = []; //编辑类型的列选项 self.getOtionEkindData = function () { $http.post(apiurljs.login + "g2work/billcol/queryDataEkind", {data: s4.encryptData_CBC("")}, postCfg).success(function (obj) { var res = strToJson(s4.decryptData_CBC(obj.data).slice(0, s4.decryptData_CBC(obj.data).lastIndexOf("}") + 1)); console.log(res.data[0]); if (res.success) { if (sp.isval(res.data)) { self.optionEkind = res.data; self.optionEkind.push({ BILLKEY:"[NEWCHILD]", CNAME:"[创建同名代码表]", COLS:[{ CKIND: "varchar", CNAME: "代码", CODE: "CODE", },{ CKIND: "varchar", CNAME: "名称", CODE: "CNAME", }] }) var newCols = []; res.data[0].COLS.forEach(function (item) { if (item.CKIND == "varchar") { newCols.push(item) } }) self.optionEkindItem = newCols; } else { self.optionEkind = []; self.optionEkindItem = []; self.optionEkind.push({ BILLKEY:"[NEWCHILD]", CNAME:"创建同名代码表", COLS:[{ CKIND: "varchar", CNAME: "代码", CODE: "CODE", },{ CKIND: "varchar", CNAME: "名称", CODE: "CNAME", }] }) } } else { sp.dialog(res.message); } }); } self.getOtionEkindData()//响应速度优化同步进行 //获取初始值的选项数据 self.optionInitval = []; //初始值的表选项 self.optionInitvalItem = []; //初始值的列选项 self.getOtionInitvalData = function () { //数据表和列分开加载 $http.post(apiurljs.login + "g2work/billcol/queryDataInitvalT", {data: s4.encryptData_CBC("")}, postCfg).success(function (obj) { var res = strToJson(s4.decryptData_CBC(obj.data)); if (res.success) { if (sp.isval(res.data)) { self.optionInitval = res.data; self.field.initable = res.data[0].BILLKEY; self.optionInitvalItem = []; self.changeOptionInitval() } else { self.optionInitval = []; self.optionInitvalItem = []; } } else { sp.dialog(res.message); } }); } self.getOtionInitvalData()//响应速度优化同步进行 //加载列数据 self.formFieldData = []; self.getFormFieldData = function () { self.loading = true; var postData = { "billkey": self.active.TYPE }; $http.post(apiurljs.login + "g2work/billcol/queryData", {data: s4.encryptData_CBC(JSON.stringify(postData))}, postCfg).success(function (obj) { var res = strToJson(s4.decryptData_CBC(obj.data).slice(0, s4.decryptData_CBC(obj.data).lastIndexOf("}") + 1)); self.loading = false; if (res.success) { if (sp.isval(res.data)) { self.formFieldData = res.data; angular.forEach(self.formFieldData, function (item) { angular.forEach(self.controlType, function (item2) { if (item.EKIND == item2.cval) { item.EKIND_set = item2.cname; } }); angular.forEach(self.initValType, function (item2) { if (item.INITVAL == item2.cval) { item.INITVAL_set = item2.cname; } }); }); } else { self.formFieldData = []; } } else { sp.dialog(res.message); } }); }; //**编辑基本表单**开始***** */ self.formsingle = {}; self.getFormSingle = function () { //检索单条表单数据 var postData = { formid: self.get_formid } $http.post(apiurljs.login + "g2work/form/queryDataItem", {data: s4.encryptData_CBC(JSON.stringify(postData))}, postCfg).success(function (obj) { var res = strToJson(s4.decryptData_CBC(obj.data).slice(0, s4.decryptData_CBC(obj.data).lastIndexOf("}") + 1)); if (res.success) { if (sp.isval(res.data)) { self.formsingle = res.data; } else { self.formsingle = {}; } } else { sp.dialog(res.message); } }); }; self.getFormSingle(); self.formTypeAray = [ {"cval": "NORMAL", "cname": "一般表"}, {"cval": "MDETAIL", "cname": "主细表"}, {"cval": "FILETBL", "cname": "附件表"}, {"cval": "CODETBL", "cname": "代码表"}, {"cval": "TREESTAL", "cname": "树状表"}, {"cval": "ENTITYTB", "cname": "实体表"} ]; self.form = { ckey: "", cname: "", ctype: self.formTypeAray[0].cval, shortname: "", explain: "", formkinds: "" }; self.editBasicForm = function () { var postData = { formid: self.get_formid } $http.post(apiurljs.login + "g2work/form/queryDataItem", {data: s4.encryptData_CBC(JSON.stringify(postData))}, postCfg).success(function (obj) { var res = strToJson(s4.decryptData_CBC(obj.data).slice(0, s4.decryptData_CBC(obj.data).lastIndexOf("}") + 1)); if (res.success) { self.formsingle = res.data; var sendData = { pkid: self.formsingle.UNITID, includechildren: true } $http.post(apiurljs.login + "g2work/formkinds/queryData", {data: s4.encryptData_CBC(JSON.stringify(sendData))}, postCfg).success(function (obj) { var res = strToJson(s4.decryptData_CBC(obj.data).slice(0, s4.decryptData_CBC(obj.data).lastIndexOf("}") + 1)); if (res.success) { if (sp.isval(res.data)) { self.optionFormkinds = res.data; } else { self.optionFormkinds = []; } // console.log(self.optionFormkinds); self.form = { ckey: self.formsingle.CKEY, cname: self.formsingle.CNAME, ctype: self.formsingle.CTYPE, shortname: self.formsingle.SHORTNAME, explain: self.formsingle.EXPLAIN, formkinds: "" }; setTimeout(function () { self.form.formkinds = self.formsingle.FORMKINDS; $scope.$apply(); sp.layer("#layer_editBasicForm"); }, 0) } else { sp.dialog(res.message); self.optionFormkinds = []; } }); } else { sp.dialog(res.message); } }); }; self.editBasicFormTrue = function () { ///编辑基本表单-提交 if (spngvld.submit("#layer_editBasicForm")) { var postData = { "formid": self.get_formid, "ckey": self.form.ckey, "cname": self.form.cname, "ctype": self.form.ctype, "explain": self.form.explain, "shortname": self.form.shortname, "formkinds": self.form.formkinds } $http.post(apiurljs.login + "g2work/form/updateDataByFormid", {data: s4.encryptData_CBC(JSON.stringify(postData))}, postCfg).success(function (obj) { var res = strToJson(s4.decryptData_CBC(obj.data).slice(0, s4.decryptData_CBC(obj.data).lastIndexOf("}") + 1)); if (res.success) { self.getFormSingle(); sp.layerhide(); } else { sp.layerhide(); sp.dialog(res.message); } }); } }; self.editBasicFormCancel = function () { ///编辑基本表单-取消 self.form = { ckey: "", cname: "", ctype: self.formTypeAray[0].cval, shortname: "", explain: "" }; sp.layerhide(); }; //**编辑基本表单**结束***** */ //*** 新建、删除子表**************************************** */ self.subForm = { edit: false, layertitle: "新建子表", billkey: "", cname: "", type: 'NORMAL' }; self.openAddSubLayer = function () { self.subForm = { edit: false, layertitle: "新建子表", billkey: "", cname: "", type: 'SHW' }; sp.layer("#layer_addSubForm"); }; self.editSubForm = function ($item) { self.subForm = { edit: true, layertitle: "更新子表", billkey: $item.BILLKEY, cname: $item.CNAME, type: $item.STYLE }; sp.layer("#layer_addSubForm"); }; self.addSubFormTrue = function () { //新建子表单-提交事件 if (spngvld.submit("#layer_addSubForm")) { if (!self.subForm.edit) { ///新建 var postData = { formid: self.get_formid, cname: self.subForm.cname, style: self.subForm.type }; $http.post(apiurljs.login + "g2work/bill/insertData", {data: s4.encryptData_CBC(JSON.stringify(postData))}, postCfg).success(function (obj) { var res = strToJson(s4.decryptData_CBC(obj.data).slice(0, s4.decryptData_CBC(obj.data).lastIndexOf("}") + 1)); if (res.success) { if (sp.isval(res.data)) { self.getBasicAndSubForm(); sp.layerhide(); } } else { sp.layerhide(); sp.dialog(res.message); } }); } else { var postData = { billkey: self.subForm.billkey, cname: self.subForm.cname, style: self.subForm.type }; $http.post(apiurljs.login + "g2work/bill/updateDataByBillKey", {data: s4.encryptData_CBC(JSON.stringify(postData))}, postCfg).success(function (obj) { var res = strToJson(s4.decryptData_CBC(obj.data).slice(0, s4.decryptData_CBC(obj.data).lastIndexOf("}") + 1)); if (res.success) { if (sp.isval(res.data)) { self.getBasicAndSubForm(); sp.layerhide(); } } else { sp.layerhide(); sp.dialog(res.message); } }); } } }; self.addSubFormCancel = function () { //新建子表单取消 spngvld.clear("#layer_addSubForm") sp.layerhide(); }; self.delSubForm = function ($item) { ///删除子表单 // var getDelID = $item.PKID; var getDelID = $item.BILLKEY; ; var dialogHead = "温馨提示×"; var dialogBody = "
删除后不可恢复,您确认要删除吗?
"; var dialogFoot = "
"; $('.sp-dialog').html(dialogHead + dialogBody + dialogFoot); sp.openCenter(".sp-dialog"); ///取消按钮 $('.sp-closeDialog').click(function (event) { sp.dialoghide(); event.preventDefault(); event.stopPropagation(); }); //post消息的id $("#delDataTrue").click(function () { var data = { billkey: getDelID///角色编码 }; $http.post(apiurljs.login + "g2work/bill/deleteByBillKey", {data: s4.encryptData_CBC(JSON.stringify(data))}, postCfg) .success(function (obj) { var res = strToJson(s4.decryptData_CBC(obj.data).slice(0, s4.decryptData_CBC(obj.data).lastIndexOf("}") + 1)); if (res.success) { self.getBasicAndSubForm(); sp.dialoghide(); } else { sp.dialog(res.message); } }); }); }; //*** 新建子表**************************************** */ //* 新建、编辑字段 **** */ self.field = { edit: false, layertitle: "新建列", colid: "", code: "", cname: "", ckind: "", clength: "", deci: "", ekind: "", ekind_select: "", initval: "", initval_init: "", initval_auto: "", ismust: "否", tchild: "", tdata: "", tshow: "", twhere: "", initable: "", initcol: "", initc: 0, initm: "NEWITEM", rowall: "", colfunc: "", coltips: "", codehead: "", codebody: "", codetail: "" }; self.addFormField = function () { self.field.edit = false; self.field.layertitle = "新建列"; self.field.code = ""; self.field.cname = ""; self.field.colid = ""; self.field.ckind = self.columnType[0].cval; self.field.clength = self.columnType[0].set_length; self.field.deci = (self.columnType[0].is_deci) ? self.columnType[0].set_deci : 0; self.field.ekind = self.controlType[1].cval; self.field.ekind_select = self.controlType[1].need_select; self.field.tchild = (self.optionEkind.length == 0) ? "" : self.optionEkind[0].BILLKEY; self.field.tdata = (self.optionEkindItem.length == 0) ? "" : self.optionEkindItem[0].CODE; self.field.tshow = (self.optionEkindItem.length == 0) ? "" : self.optionEkindItem[1].CODE; self.field.initval = self.initValType[0].cval; self.field.initval_init = self.initValType[0].need_init; self.field.initval_auto = self.initValType[0].need_auto; self.field.initable = (self.optionInitval.length == 0) ? "" : self.optionInitval[0].BILLKEY; self.field.initcol = (self.optionInitvalItem.length == 0) ? "" : self.optionInitvalItem[0].CODE; self.field.ismust = "否"; self.field.initc = 0; self.field.initm = "NEWITEM"; self.field.rowall = ""; self.field.colfunc = ""; self.field.coltips = ""; self.field.twhere = ""; self.field.codehead = self.autoCodeHeadArray[0].cval; self.field.codebody = ""; self.field.codetail = ""; sp.layer("#layer_formField"); }; self.changeColumnType = function () { self.columnType.forEach(function (item) { if (item.cval == self.field.ckind) { self.field.clength = item.set_length; self.field.deci = (item.is_deci) ? item.set_deci : 0; } }) // console.log(self.field.ckind); if (self.field.ckind == "datetime") { self.field.ekind = self.controlType[3].cval; self.field.ekind_select = self.controlType[3].need_select; } else { self.field.ekind = self.controlType[1].cval; self.field.ekind_select = self.controlType[1].need_select; } } self.changeControlType = function () { self.controlType.forEach(function (item) { if (item.cval == self.field.ekind) { self.field.ekind_select = item.need_select; } }) } self.changeOptionEkind = function () { self.optionEkind.forEach(function (item) { if (item.BILLKEY == self.field.tchild) { var newCols = []; item.COLS.forEach(function (item2) { if (item2.CKIND == "varchar") { newCols.push(item2); } }) self.optionEkindItem = angular.copy(newCols); self.field.tdata = ""; self.field.tshow = ""; setTimeout(function () { self.field.tdata = (self.optionEkindItem.length == 0) ? "" : self.optionEkindItem[0].CODE; self.field.tshow = (self.optionEkindItem.length == 0) ? "" : self.optionEkindItem[1].CODE; $scope.$apply(); },100) } }) } self.changeInitValType = function () { self.initValType.forEach(function (item) { if (item.cval == self.field.initval) { self.field.initval_init = item.need_init; self.field.initval_auto = item.need_auto; } }) } self.changeOptionInitval = function () { var data = { billkey: self.field.initable } $http.post(apiurljs.login + "g2work/billcol/queryDataByParam", {data: s4.encryptData_CBC(JSON.stringify(data))}, postCfg) .success(function (obj) { var res = strToJson(s4.decryptData_CBC(obj.data)); // console.log(res.data[0]) self.optionInitvalItem = res.data[0].COLS; self.field.initcol = (self.optionInitvalItem.length == 0) ? "" : self.optionInitvalItem[0].CODE; }) //self.optionInitval.forEach(function (item) { // if (item.BILLKEY == self.field.initable) { // self.optionInitvalItem = item.COLS; // self.field.initcol = (self.optionInitvalItem.length == 0) ? "" : self.optionInitvalItem[0].CODE; // } //}) } self.editFormField = function (obj) { // console.log(obj); self.field.edit = true; self.field.layertitle = "编辑列"; self.field.colid = obj.COLID; self.field.code = obj.CODE; self.field.cname = obj.CNAME; self.field.ckind = obj.CKIND; self.field.clength = obj.CLENGTH; self.field.deci = obj.DECI; self.field.coltips = obj.COLTIPS; self.field.ekind = obj.EKIND; self.controlType.forEach(function (item) { if (self.field.ekind == item.cval) { self.field.ekind_select = item.need_select; } }) self.field.tchild = obj.TCHILD; self.field.tdata = obj.TDATA; self.field.tshow = obj.TSHOW; self.field.twhere = obj.TWHERE; self.field.initval = obj.INITVAL; self.initValType.forEach(function (item) { if (item.cval == self.field.initval) { self.field.initval_init = item.need_init; self.field.initval_auto = item.need_auto; } }) self.field.initable = obj.INITABLE; self.field.initcol = obj.INITCOL; self.field.ismust = obj.ISMUST; self.field.initc = obj.INITC; self.field.initm = obj.INITM; self.field.rowall = obj.ROWALL; self.field.colfunc = obj.COLFUNC; self.field.codehead = obj.CODEHEAD; self.field.codebody = obj.CODEBODY; self.field.codetail = obj.CODETAIL; sp.layer("#layer_formField"); }; self.addFormfieldTrue = function () { if (spngvld.submit("#layer_formField")) { if (!self.field.edit) { var postData = { billkey: self.active.TYPE, code: self.field.code, cname: self.field.cname, ckind: self.field.ckind, clength: self.field.clength + "", deci: self.field.deci + "", ekind: self.field.ekind, initval: self.field.initval, ismust: self.field.ismust, tchild: (self.field.ekind_select) ? self.field.tchild : "", tdata: (self.field.ekind_select) ? self.field.tdata : "", tshow: (self.field.ekind_select) ? self.field.tshow : "", twhere: (self.field.ekind_select) ? self.field.twhere : "", initable: (self.field.initval_init) ? self.field.initable : "", initcol: (self.field.initval_init) ? self.field.initcol : "", initc: (self.field.initval_init) ? self.field.initc : "", initm: (self.field.initval_init) ? self.field.initm : "", rowall: self.field.rowall, colfunc: self.field.colfunc, coltips: self.field.coltips, codehead: (self.field.initval_auto) ? self.field.codehead : "", codebody: (self.field.initval_auto) ? self.field.codebody : "", codetail: (self.field.initval_auto) ? self.field.codetail : "", } $http.post(apiurljs.login + "g2work/billcol/insertData", {data: s4.encryptData_CBC(JSON.stringify(postData))}, postCfg).success(function (obj) { var res = strToJson(s4.decryptData_CBC(obj.data).slice(0, s4.decryptData_CBC(obj.data).lastIndexOf("}") + 1)); if (res.success) { if (sp.isval(res.data)) { self.getFormFieldData(); self.getOtionEkindData(); sp.layerhide(); } } else { sp.layerhide(); sp.dialog(res.message); } }); } else { var postData = { colid: self.field.colid, code: self.field.code, cname: self.field.cname, ckind: self.field.ckind, clength: self.field.clength + "", deci: self.field.deci + "", ekind: self.field.ekind, initval: self.field.initval, ismust: self.field.ismust, tchild: (self.field.ekind_select) ? self.field.tchild : "", tdata: (self.field.ekind_select) ? self.field.tdata : "", tshow: (self.field.ekind_select) ? self.field.tshow : "", twhere: (self.field.ekind_select) ? self.field.twhere : "", initable: (self.field.initval_init) ? self.field.initable : "", initcol: (self.field.initval_init) ? self.field.initcol : "", initc: (self.field.initval_init) ? self.field.initc : "", initm: (self.field.initval_init) ? self.field.initm : "", rowall: self.field.rowall, colfunc: self.field.colfunc, coltips: self.field.coltips, codehead: (self.field.initval_auto) ? self.field.codehead : "", codebody: (self.field.initval_auto) ? self.field.codebody : "", codetail: (self.field.initval_auto) ? self.field.codetail : "", } $http.post(apiurljs.login + "g2work/billcol/updateDataByColId", {data: s4.encryptData_CBC(JSON.stringify(postData))}, postCfg).success(function (obj) { var res = strToJson(s4.decryptData_CBC(obj.data).slice(0, s4.decryptData_CBC(obj.data).lastIndexOf("}") + 1)); if (res.success) { if (sp.isval(res.data)) { self.getFormFieldData(); sp.layerhide(); } } else { sp.layerhide(); sp.dialog(res.message); } }); } } //sp.layerhide(); }; self.addFormfieldCancel = function () { sp.layerhide(); }; self.delFormField = function (id) { var getDelID = id; var dialogHead = "温馨提示×"; var dialogBody = "
删除后不可恢复,您确认要删除吗?
"; var dialogFoot = "
"; $('.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 () { sp.dialoghide(); var getid = $(this).attr("data-id"); var data = { colid: getid }; $http.post(apiurljs.login + "g2work/billcol/deleteByColId", {data: s4.encryptData_CBC(JSON.stringify(data))}, postCfg) .success(function (obj) { var res = strToJson(s4.decryptData_CBC(obj.data).slice(0, s4.decryptData_CBC(obj.data).lastIndexOf("}") + 1)); if (res.success) { self.getFormFieldData(); sp.dialoghide(); } else { sp.dialog(res.message); } }); }); }; self.reBuildForm = function () { ///删除子表单 // var getDelID = $item.PKID; var getDelID = self.get_formid; var dialogHead = "温馨提示×"; var dialogBody = "
重建表单后数据将会被清空且不可恢复,您确认要重建吗?
"; var dialogFoot = "
"; $('.sp-dialog').html(dialogHead + dialogBody + dialogFoot); sp.openCenter(".sp-dialog"); ///取消按钮 $('.sp-closeDialog').click(function (event) { sp.dialoghide(); event.preventDefault(); event.stopPropagation(); }); //post消息的id $("#reBuildForm").click(function () { var data = { formid: self.get_formid } $http.post(apiurljs.login + "g2work/form/createTableByFormid", {data: s4.encryptData_CBC(JSON.stringify(data))}, postCfg) .success(function (obj) { var res = strToJson(s4.decryptData_CBC(obj.data).slice(0, s4.decryptData_CBC(obj.data).lastIndexOf("}") + 1)); // console.log(res); sp.dialoghide(); setTimeout(function () { sp.dialog(res.message); }, 1000) }); }); } self.previewForm = function () { window.location.href = "formlist-detail.html?formid=" + self.get_formid + "&ctype=" + self.get_ctype + "&leftActive=" + self.get_leftActive + "&leftActiveType=" + self.get_leftActiveType; } //另存为函数 self.other = { formid: "", newformkinds: "", newckye: "", newformname: "", includeformedit: 0, optionformkinds: [] } self.saveAs = function () { var postData = { formid: self.get_formid } $http.post(apiurljs.login + "g2work/form/queryDataItem", {data: s4.encryptData_CBC(JSON.stringify(postData))}, postCfg).success(function (obj) { var res = strToJson(s4.decryptData_CBC(obj.data).slice(0, s4.decryptData_CBC(obj.data).lastIndexOf("}") + 1)); if (res.success) { var sendData = { pkid: self.formsingle.UNITID, includechildren: true } $http.post(apiurljs.login + "g2work/formkinds/queryData", {data: s4.encryptData_CBC(JSON.stringify(sendData))}, postCfg).success(function (obj1) { var response = strToJson(s4.decryptData_CBC(obj1.data).slice(0, s4.decryptData_CBC(obj1.data).lastIndexOf("}") + 1)); if (res.success) { self.other.formid = res.data.FORMID; self.other.newformkinds = res.data.FORMKINDS; self.other.newckye = res.data.CKEY + "1"; self.other.newformname = res.data.CNAME + "1"; self.other.optionformkinds = response.data; // console.log(self.other); } else { sp.dialog(response.message); } }); } else { sp.dialog(res.message); } }); sp.layer('#layer_saveAs') } self.saveAsSubmit = function () { var postData = { formid: self.other.formid, newformkinds: self.other.newformkinds, newckey: self.other.newckye, newformname: self.other.newformname, includeformedit: (self.other.includeformedit == "1") ? true : false } $http.post(apiurljs.login + "g2work/form/saveasByFormid", {data: s4.encryptData_CBC(JSON.stringify(postData))}, postCfg) .success(function (obj) { var res = strToJson(s4.decryptData_CBC(obj.data).slice(0, s4.decryptData_CBC(obj.data).lastIndexOf("}") + 1)); sp.layerhide(); setTimeout(function () { sp.dialog(res.message); }, 1000) }); } self.keyLogin = function (n) { if (event.keyCode == 13) //回车键的键值为13 { if (n == 1) { self.addSubFormTrue() } else { self.addFormfieldTrue() } } } }]);