123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911 |
- 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 = "<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 data-id=" + getDelID + " 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.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 = "<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 data-id=" + getDelID + " 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 () {
- 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 = "<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 data-id=" + getDelID + " id='reBuildForm' 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.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()
- }
- }
- }
- }]);
|