123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126 |
- /**
- * 初始化字典详情对话框
- */
- var DictInfoDlg = {
- count: $("#itemSize").val(),
- dictName: '', //字典的名称
- dictCode: '', //字典类型编码
- dictTips: '', //字典备注
- mutiString: '', //拼接字符串内容(拼接字典条目)
- itemTemplate: $("#itemTemplate").html()
- };
- Feng.ctxPath = "/admin";
- /**
- * item获取新的id
- */
- DictInfoDlg.newId = function () {
- if (this.count == undefined) {
- this.count = 0;
- }
- this.count = this.count + 1;
- return "dictItem" + this.count;
- };
- /**
- * 关闭此对话框
- */
- DictInfoDlg.close = function () {
- parent.layer.close(window.parent.Dict.layerIndex);
- };
- /**
- * 添加条目
- */
- DictInfoDlg.addItem = function () {
- $("#itemsArea").append(this.itemTemplate);
- $("#dictItem").attr("id", this.newId());
- };
- /**
- * 删除item
- */
- DictInfoDlg.deleteItem = function (event) {
- var obj = Feng.eventParseObject(event);
- obj = obj.is('button') ? obj : obj.parent();
- obj.parent().parent().remove();
- };
- /**
- * 清除为空的item Dom
- */
- DictInfoDlg.clearNullDom = function () {
- $("[name='dictItem']").each(function () {
- var num = $(this).find("[name='itemNum']").val();
- var name = $(this).find("[name='itemName']").val();
- if (num == '' || name == '') {
- $(this).remove();
- }
- });
- };
- /**
- * 收集添加字典的数据
- */
- DictInfoDlg.collectData = function () {
- this.clearNullDom();
- var mutiString = "";
- $("[name='dictItem']").each(function () {
- var code = $(this).find("[name='itemCode']").val();
- var name = $(this).find("[name='itemName']").val();
- var num = $(this).find("[name='itemNum']").val();
- mutiString = mutiString + (code + ":" + name + ":" + num + ";");
- });
- this.dictName = $("#dictName").val();
- this.dictCode = $("#dictCode").val();
- this.dictTips = $("#dictTips").val();
- this.mutiString = mutiString;
- };
- /**
- * 提交添加字典
- */
- DictInfoDlg.addSubmit = function () {
- this.collectData();
- //提交信息
- var ajax = new $ax(Feng.ctxPath + "/dict/add", function (data) {
- if (data.code == 200) {
- Feng.success("添加成功!");
- window.parent.Dict.table.refresh();
- DictInfoDlg.close();
- } else {
- Feng.error(data.msg);
- }
- }, function (data) {
- Feng.error("添加失败!" + data.responseJSON.message + "!");
- });
- ajax.set('dictName', this.dictName);
- ajax.set('dictCode', this.dictCode);
- ajax.set('dictTips', this.dictTips);
- ajax.set('dictValues', this.mutiString);
- ajax.start();
- };
- /**
- * 提交修改
- */
- DictInfoDlg.editSubmit = function () {
- this.collectData();
- var ajax = new $ax(Feng.ctxPath + "/dict/edit", function (data) {
- if (data.code == 200) {
- Feng.success("修改成功!");
- window.parent.Dict.table.refresh();
- DictInfoDlg.close();
- } else {
- Feng.error(data.msg);
- }
- }, function (data) {
- Feng.error("修改失败!" + data.responseJSON.message + "!");
- });
- ajax.set('dictId', $("#dictId").val());
- ajax.set('dictName', this.dictName);
- ajax.set('dictCode', this.dictCode);
- ajax.set('dictTips', this.dictTips);
- ajax.set('dictValues', this.mutiString);
- ajax.start();
- };
|