【Dict】优化代码

pull/65/head
chenjinlong 2021-01-22 16:16:09 +08:00
parent f84113b4aa
commit e59adda5a0
4 changed files with 34 additions and 102 deletions

View File

@ -1,19 +1,14 @@
/**
* 详情对话框
*/
var DictInfoDlg = {
data: {
dictParentId: "-1",
parentName: "顶级"
}
};
layui.use(['form', 'admin', 'HttpRequest'], function () {
var $ = layui.jquery;
var form = layui.form;
var admin = layui.admin;
var HttpRequest = layui.HttpRequest;
//获取信息详情填充表单
var request = new HttpRequest(Feng.ctxPath + "/dictType/getDictDetail?dictTypeId=" + Feng.getUrlParam("dictTypeId"), 'get');
var result = request.start();
form.val('dictForm', result.data);
//表单提交事件
form.on('submit(btnSubmit)', function (data) {
var request = new HttpRequest(Feng.ctxPath + "/dict/addDict", 'post', function (data) {
@ -24,26 +19,7 @@ layui.use(['form', 'admin', 'HttpRequest'], function () {
admin.closeThisDialog();
Feng.error("添加失败!" + data.message);
});
request.set(data.field);
request.start(true);
});
//父级字典时
$('#parentName').click(function () {
var formName = encodeURIComponent("parent.DictInfoDlg.data.parentName");
var formId = encodeURIComponent("parent.DictInfoDlg.data.dictParentId");
var treeUrl = encodeURIComponent("/dict/zTree?dictTypeCode=" + $("#dictTypeCode").val());
layer.open({
type: 2,
title: '父级字典',
area: ['300px', '400px'],
content: Feng.ctxPath + '/view/common/tree?formName=' + formName + "&formId=" + formId + "&treeUrl=" + treeUrl,
end: function () {
$("#dictParentId").val(DictInfoDlg.data.dictParentId);
$("#parentName").val(DictInfoDlg.data.parentName);
}
});
});
});

View File

@ -1,57 +1,27 @@
/**
* 详情对话框
*/
var DictInfoDlg = {
data: {
dictParentId: "-1",
parentName: "顶级"
}
};
layui.use(['form', 'admin', 'HttpRequest'], function () {
var $ = layui.jquery;
var form = layui.form;
var admin = layui.admin;
var HttpRequest = layui.HttpRequest;
//获取详情信息,填充表单
var request = new HttpRequest(Feng.ctxPath + "/dict/getDictDetail?dictId=" + Feng.getUrlParam("dictId"), 'get', function (result) {
form.val('dictForm', result.data);
}, function (data) {
Feng.error("加载失败!" + data.message);
});
request.start();
var request = new HttpRequest(Feng.ctxPath + "/dict/getDictDetail?dictId=" + Feng.getUrlParam("dictId"), 'get');
var result = request.start();
form.val('dictForm', result.data);
//表单提交事件
form.on('submit(btnSubmit)', function (data) {
var request = new HttpRequest(Feng.ctxPath + "/dict/updateDict", 'post', function (data) {
admin.closeThisDialog();
Feng.success("更新成功!");
Feng.success("修改成功!");
admin.putTempData('formOk', true);
}, function (data) {
admin.closeThisDialog();
Feng.error("更新失败!" + data.message);
Feng.error("修改失败!" + data.message);
});
request.set(data.field);
request.start(true);
});
//父级字典时
$('#parentName').click(function () {
var formName = encodeURIComponent("parent.DictInfoDlg.data.parentName");
var formId = encodeURIComponent("parent.DictInfoDlg.data.dictParentId");
var treeUrl = encodeURIComponent("/dict/zTree?dictTypeCode=" + $("#dictTypeCode").val() + "&dictId=" + $("#dictId").val());
layer.open({
type: 2,
title: '父级字典',
area: ['300px', '400px'],
content: Feng.ctxPath + '/view/common/tree?formName=' + formName + "&formId=" + formId + "&treeUrl=" + treeUrl,
end: function () {
$("#dictParentId").val(DictInfoDlg.data.dictParentId);
$("#parentName").val(DictInfoDlg.data.parentName);
}
});
});
});

View File

@ -3,48 +3,40 @@
<form class="layui-form" id="dictForm" lay-filter="dictForm">
<div class="layui-fluid" style="padding-bottom: 75px;">
<div class="layui-card">
<div class="layui-card-header">基本信息</div>
<div class="layui-card-body">
<div class="layui-form-item layui-row">
<input id="dictTypeId" name="dictTypeId" type="hidden" value="${dictTypeId}"/>
<input id="dictTypeCode" name="dictTypeCode" type="hidden" value="${dictTypeCode}"/>
<input id="dictTypeId" name="dictTypeId" type="hidden"/>
<input id="dictTypeCode" name="dictTypeCode" type="hidden"/>
<div class="layui-inline layui-col-md12">
<label class="layui-form-label">字典类型</label>
<label class="layui-form-label layui-form-required">字典类型</label>
<div class="layui-input-block">
<input type="text" class="layui-input white-border layui-disabled" value="${dictTypeName}" disabled="disabled"/>
<input id="dictTypeName" name="dictTypeName" placeholder="" type="text" class="layui-input" lay-verify="required" readonly/>
</div>
</div>
<div class="layui-inline layui-col-md12">
<label class="layui-form-label">字典名称<span style="color: red;">*</span></label>
<div class="layui-inline layui-col-md6">
<label class="layui-form-label layui-form-required">字典名称</label>
<div class="layui-input-block">
<input id="dictName" name="dictName" placeholder="请输入字典名称" type="text" class="layui-input" lay-verify="required" required/>
</div>
</div>
<div class="layui-inline layui-col-md12">
<label class="layui-form-label">简称</label>
<div class="layui-inline layui-col-md6">
<label class="layui-form-label">字典简称</label>
<div class="layui-input-block">
<input id="dictShortName" name="dictShortName" placeholder="请输入简称" type="text" class="layui-input"/>
</div>
</div>
<div class="layui-inline layui-col-md12">
<label class="layui-form-label">字典编码<span style="color: red;">*</span></label>
<div class="layui-inline layui-col-md6">
<label class="layui-form-label layui-form-required">字典编码</label>
<div class="layui-input-block">
<input id="dictCode" name="dictCode" placeholder="请输入字典编码" type="text" class="layui-input" lay-verify="required" required/>
</div>
</div>
<div class="layui-inline layui-col-md12">
<div class="layui-inline layui-col-md6">
<label class="layui-form-label">编码简写</label>
<div class="layui-input-block">
<input id="dictShortCode" name="dictShortCode" placeholder="请输入编码简写" type="text" class="layui-input"/>
</div>
</div>
<div class="layui-inline layui-col-md12">
<label class="layui-form-label">上级字典<span style="color: red;">*</span></label>
<div class="layui-input-block">
<input id="dictParentId" name="dictParentId" type="hidden" class="layui-input" lay-verify="required" required/>
<input id="parentName" name="parentName" placeholder="请选择上级字典,如没有请选择顶级" type="text" class="layui-input" lay-verify="required" required readonly="readonly"/>
</div>
</div>
<div class="layui-inline layui-col-md12">
<label class="layui-form-label">排序</label>
<div class="layui-input-block">

View File

@ -6,46 +6,40 @@
<div class="layui-card-header">基本信息</div>
<div class="layui-card-body">
<div class="layui-form-item layui-row">
<input id="dictId" name="dictId" type="hidden"/>
<input id="dictTypeId" name="dictTypeId" type="hidden"/>
<input id="dictTypeCode" name="dictTypeCode" type="hidden"/>
<div class="layui-inline layui-col-md12">
<label class="layui-form-label">字典类型</label>
<label class="layui-form-label layui-form-required">字典类型</label>
<div class="layui-input-block">
<input id="dictId" name="dictId" type="hidden" value="${dictId}"/>
<input id="dictTypeCode" name="dictTypeCode" type="hidden" value="${dictTypeCode}"/>
<input type="text" class="layui-input white-border layui-disabled" value="${dictTypeName}" disabled="disabled"/>
<input id="dictTypeName" name="dictTypeName" placeholder="" type="text" class="layui-input" lay-verify="required" readonly/>
</div>
</div>
<div class="layui-inline layui-col-md12">
<label class="layui-form-label">字典名称<span style="color: red;">*</span></label>
<div class="layui-inline layui-col-md6">
<label class="layui-form-label layui-form-required">字典名称</label>
<div class="layui-input-block">
<input id="dictName" name="dictName" placeholder="请输入字典名称" type="text" class="layui-input" lay-verify="required" required/>
</div>
</div>
<div class="layui-inline layui-col-md12">
<label class="layui-form-label">简称</label>
<div class="layui-inline layui-col-md6">
<label class="layui-form-label">字典简称</label>
<div class="layui-input-block">
<input id="dictShortName" name="dictShortName" placeholder="请输入简称" type="text" class="layui-input"/>
</div>
</div>
<div class="layui-inline layui-col-md12">
<label class="layui-form-label">字典编码<span style="color: red;">*</span></label>
<div class="layui-inline layui-col-md6">
<label class="layui-form-label layui-form-required">字典编码</label>
<div class="layui-input-block">
<input id="dictCode" name="dictCode" placeholder="请输入字典编码" type="text" class="layui-input layui-disabled" lay-verify="required" disabled required/>
<input id="dictCode" name="dictCode" placeholder="请输入字典编码" type="text" class="layui-input" lay-verify="required" required/>
</div>
</div>
<div class="layui-inline layui-col-md12">
<div class="layui-inline layui-col-md6">
<label class="layui-form-label">编码简写</label>
<div class="layui-input-block">
<input id="dictShortCode" name="dictShortCode" placeholder="请输入编码简写" type="text" class="layui-input"/>
</div>
</div>
<div class="layui-inline layui-col-md12">
<label class="layui-form-label">上级字典<span style="color: red;">*</span></label>
<div class="layui-input-block">
<input id="dictParentId" name="dictParentId" type="hidden" class="layui-input" lay-verify="required" required/>
<input id="parentName" name="parentName" placeholder="请选择上级字典,如没有请选择顶级" type="text" class="layui-input" lay-verify="required" required readonly="readonly"/>
</div>
</div>
<div class="layui-inline layui-col-md12">
<label class="layui-form-label">排序</label>
<div class="layui-input-block">