abp(net core)+easyui+efcore實現倉儲管理系統——建立應用服務(五)html
abp(net core)+easyui+efcore實現倉儲管理系統——EasyUI前端頁面框架 (十八) 前端
在上一篇文章abp(net core)+easyui+efcore實現倉儲管理系統——ABP WebAPI與EasyUI結合增刪改查之三(二十九) 中實現了組織管理的列表頁面。在今天咱們學習如何新增組織部門信息。node
9、新增組織部門信息app
1. 在Visual Studio 2017的「解決方案資源管理器」中,左鍵單擊在展示層的「ABP.TPLMS.Web.MVC」項目中的Views目錄。找到Index.cshmtl文件。在此文件中添加視圖代碼。代碼以下。框架
<div id="divAddUpdOrg" class="easyui-dialog" closed="true" data-options="buttons: '#dlg-buttons'">
<form name="OrgEditForm" role="form" novalidate class="form-validation">
<table>
<tr>
<td><input type="hidden" name="Id" id="IDUpdate" /></td>
</tr>
<tr>
<td>組織名稱:</td>
<td>
<input type="text" id="NameUpdate" name="Name"
class="form-control input-sm" />
</td>
</tr>
<tr>
<td> 組織代碼:</td>
<td><input type="text" id="UpdBizCode" name="BizCode"
class="form-control input-sm" /></td>
</tr>
<tr>
<td>類型:</td>
<td>
<input type="text" id="UpdType" name="Type"
class="form-control input-sm" />
</td>
</tr>
<tr>
<td> 關區代碼:</td>
<td><input type="text" id="UpdCustomCode" name="CustomCode"
class="form-control input-sm" /></td>
</tr>
<tr>
<td>自動展開:</td>
<td>
<input type="checkbox" id="UpdIsAutoExpand" name="IsAutoExpand"
class="form-control input-sm" />
</td>
</tr>
<tr>
<td>子級:</td>
<td>
<input type="checkbox" id="UpdIsLeaf" name="IsLeaf"
class="form-control input-sm" />
</td>
</tr>
<tr>
<td>狀態:</td>
<td>
<input type="text" id="UpdStatus" name="Status"
class="form-control input-sm" />
</td>
</tr>
<tr>
<td>上級組織:</td>
<td>
<select id="AddTree" name="ParentName" class="easyui-combotree" ></select>
</td>
</tr>
<tr>
<td>熱鍵:</td>
<td>
<input id="UpdHotKey" name="HotKey" class="form-control input-sm" />
</td>
</tr>
<tr>
<td>圖標:</td>
<td>
<input id="UpdIconName" name="IconName" class="form-control input-sm" />
</td>
</tr>
<tr>
<td>
<input id="UpdParentId" name="ParentId" type="hidden" />
</td>
</tr>
<tr>
<td>備註:</td>
<td>
<input type="text" id="RemarkUpdate" name="URemark"
class="form-control input-sm" />
</td>
</tr>
</table>
</form>
</div>
<div id="dlg-buttons">
<input type="submit" id="btnSave" value="保存" class="btn btn-primary" />
<input type="submit" id="btnCancle" value="取消" class="btn btn-info" />
</div>
2. 在Visual Studio 2017的「解決方案資源管理器」中,找到領域層「ABP.TPLMS.Web.Mvc」項目中的wwwroot\view-resources\Orgs目錄。ide
3. 在Orgs目錄中找到Index.js文件。添加新增組織信息與加載樹的代碼。代碼以下。post
//清空文本框
function clearAll() { $("#IDUpdate").val(""); $("#UpdBizCode").val(""); $(':disabled[name]', this).each(function () { $(this).val(""); }); } var _orgService = abp.services.app.org; var _$modal = $('#divAddUpdOrg'); var _$form = _$modal.find('form'); //彈出 添加貨物信息的對話框
function showOrgDialog() { $("#add").click(function () { clearAll(); BindTree(); $("#divAddUpdOrg").dialog({ closed: false, title: "添加組織信息", modal: true, width: 600, height: 450, collapsible: true, minimizable: true, maximizable: true, resizable: true }); }); $("#btnSave").click(function () { // alert('1');
//啓用
//保存
if (!_$form.valid()) { return; } var id = $("#IDUpdate").val(); if (id == "" || id == undefined || id=="0") { //驗證
$.messager.confirm('確認', '您確認要保存嗎?', function (r) { if (r) { $("#IDUpdate").val("0"); var postData = _$form.serializeFormToObject();
//serializeFormToObject is defined in main.js
if (postData == null || postData == undefined || postData.Name == ""
|| postData.BizCode == "") { $.messager.alert('提示', ' 請填寫相關必填項!', 'warning'); return; } abp.ui.setBusy(_$modal); _orgService.create(postData).done(function () { $("#IDUpdate").val(""); _$modal.modal('hide'); $("#divAddUpdOrg").dialog("close"); initable(); //reload page to see new user!
}).always(function () { abp.ui.clearBusy(_$modal); }); } }) } else { saveDetail(); } }); } function saveDetail() { $.messager.confirm('確認', '您確認要修改嗎?', function (r) { var postData = GetOrg(); if (postData==null || postData==undefined || postData.BizCode == ""
|| postData.Name == "") { $.messager.alert('提示', ' 請填寫相關必填項!', 'warning'); return; } $.post("/Orgs/Update", postData, function (data) { // alert(data);
if (data=="OK") { $.messager.alert("提示", "修改爲功!"); $("#divAddUpdOrg").dialog("close"); initable(); } else { $.messager.alert("提示", data.msg); return; } }); }) } function BindTree() { $('#AddTree').combotree({ url: '/Orgs/GetJsonTree', valueField: 'Id', textField: 'Name', multiple: false, editable: false, method: 'get', panelHeight: 'auto', checkbox: false, //required: true,
//所有摺疊
onLoadSuccess: function (node, data) { $('#AddTree').combotree('tree').tree("expandAll"); //collapseAll
}, onSelect: function (node) { $('#UpdParentId').val(node.id); // alert(node.id);
} }); }