Company.cshtml 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. @using ContractService
  2. @using ContractService.Configuration
  3. @using ContractService.Authorization
  4. @using ContractService.Views.Shared.Modals
  5. @using ContractService.Views.Shared.SearchForm
  6. @using ContractService.Views.Shared.Query
  7. @using ContractService.Views.Shared.Table
  8. @{
  9. ViewBag.Title = "企业信息维护";
  10. string activeMenu = PermissionNames.PagesClientMgCompanyMg; //The menu item will be active for this page.
  11. ViewBag.ActiveMenu = activeMenu;
  12. var searchForm = new SearchFormViewModel(new List<SearchItem>()
  13. {
  14. new SearchItem("name","企业名称"),
  15. new SearchItem("displayName","系统显示名称"),
  16. }, "search-form", false);
  17. var table = new TableViewModel(IwbConsts.ApiAppUrl + "ClientCompany/GetAll", activeMenu, searchForm)
  18. .SetFields(new List<FieldItem>()
  19. {
  20. new FieldItem("name", "企业名称"),
  21. new FieldItem("displayName", "系统显示名称"),
  22. //new FieldItem("description", "企业描述"),
  23. new FieldItem("masterStaffName", "企业负责人"),
  24. });
  25. var inputs = new List<Input>()
  26. {
  27. new InputHide("id"),
  28. new Input("name", "企业名称").SetNotRequired(),
  29. new Input("displayName", "系统显示名称").SetNotRequired(),
  30. new InputTextarea("description", "企业描述").SetNotRequired(),
  31. };
  32. var inputs_staff = new List<Input>()
  33. {
  34. new Input("code", "员工编号").SetDivClass("form-group row req"),
  35. new Input("staffName", "员工姓名").SetDivClass("form-group row req"),
  36. new Input("email", "电子邮箱").SetDivClass("form-group row req"),
  37. new Input("phoneNumber", "联系号码").SetDivClass("form-group row req"),
  38. new InputDate("birthday", "出生日期").SetNotRequired(),
  39. new Input("idCard", "身份证号").SetNotRequired(),
  40. new Input("phoneNumber2", "备用号码").SetNotRequired(),
  41. new InputTextarea("profile", "员工描述").SetNotRequired(),
  42. };
  43. var modalBody = new ModalBodyViewModel()
  44. .AddTab("company", "企业信息", inputs)
  45. .AddTab("staff", "企业负责人", inputs_staff);
  46. var modal = new ModalViewModel("企业").SetBody(modalBody);
  47. var modal_master = new ModalViewModel("变更企业负责人", "", new ModalBodyViewModel(new List<Input>()
  48. {
  49. new InputHide("no"),
  50. new AjaxSelect("staffNo","企业负责人","MasterStaff","","query_staff","staffNo")
  51. }, "form-master"), "modal-master");
  52. }
  53. @section css{
  54. }
  55. @Html.Partial("Table/_Table", table)
  56. @section modal{
  57. <!--Modal Start-->
  58. @Html.Partial("Modals/_Modal", modal)
  59. @Html.Partial("Modals/_Modal", modal_master)
  60. @Html.Partial("Query/_Staff", new QuerySearchModel("query_staff", "staffNo").SetOriginField("id").SetSearchFun("SetCompanyQueryFun()").SetAjaxSelectName("name"))
  61. <!--Modal End-->
  62. }
  63. @section scripts
  64. {
  65. <script type="text/javascript">
  66. var $table;
  67. $(function () {
  68. $table = LoadTable();
  69. var funs = window.iwbfuns || { none: function () { console.log("No type"); } };
  70. funs["btnCreate"] = function () {
  71. $('#modal #id_company').tab("show");
  72. $('#modal #id_staff').attr('data-toggle', 'tab').css("display", "block");
  73. $('#modal .req').find('label').addClass('iwb-label-required');
  74. $('#modal .req').find('.form-control').addClass('required');
  75. BtnCreate({ data: { id: "" } });
  76. }
  77. funs["btnUpdate"] = function () {
  78. $('#modal #id_company').tab("show");
  79. $('#modal #id_staff').removeAttr('data-toggle').css("display", "none");
  80. $('#modal .req').find('label').removeClass('iwb-label-required');
  81. $('#modal .req').find('.form-control').removeClass('required');
  82. BtnUpdate({ disabled: "" });
  83. };
  84. funs["btnMasterStaff"] = function (url) {
  85. var row = $table.bootstrapTable("getSelections")[0];
  86. if (row) {
  87. $('#staffNo').data('column-key', row.id)
  88. OpenModal({
  89. url: url,
  90. modal: "modal-master",
  91. data: { no: row.id },
  92. table: $table
  93. });
  94. }
  95. };
  96. });
  97. function SetCompanyQueryFun() {
  98. return { "KeyField": "company", "KeyWords": $('#modal-master #no').val() }
  99. }
  100. </script>
  101. <!--格式化-->
  102. <script id="formatter-script" type="text/javascript">
  103. function TypeFormatter(v) {
  104. var name = $('#hid-type option[value="' + v + '"]').text();
  105. switch (v) {
  106. case 0:
  107. return '<span class="label sm label-danger">' + name + '</span>';
  108. default:
  109. return '<span class="label sm label-info">' + name + '</span>';
  110. }
  111. }
  112. </script>
  113. }
  114. <section style="display: none">
  115. <select id="hid-type">
  116. <option value=""></option>
  117. </select>
  118. @*@Html.DropDownList("hid-type", type)*@
  119. </section>