Staff.cshtml 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  1. @using ContractService.Configuration
  2. @using ContractService.Authorization
  3. @using ContractService.Views.Shared.Modals
  4. @using ContractService.Views.Shared.SearchForm
  5. @using ContractService.Views.Shared.Table
  6. @{
  7. ViewBag.Title = "企业员工信息维护";
  8. string activeMenu = PermissionNames.PagesClientMgStaffMg; //The menu item will be active for this page.
  9. ViewBag.ActiveMenu = activeMenu;
  10. string companyNo = ViewBag.CompanyNo ?? "";
  11. var searchForm = new SearchFormViewModel(new List<SearchItem>()
  12. {
  13. new SearchItem("code","员工编号"),
  14. new SearchItem("name","员工姓名"),
  15. new SearchItem("email", "电子邮箱"),
  16. new SearchItem("birthday","出生日期",FieldType.Dn),
  17. new SearchItem("phoneNumber","联系号码"),
  18. }, "search-form", false);
  19. var table = new TableViewModel(IwbConsts.ApiAppUrl + "ClientStaff/GetAll", activeMenu, searchForm)
  20. .SetFields(new List<FieldItem>()
  21. {
  22. new FieldItem("code", "员工编号"),
  23. new FieldItem("name", "员工姓名"),
  24. //new FieldItem("profile", "员工描述"),
  25. new FieldItem("userName", "绑定账号","UserNameFormatter"),
  26. new FieldItem("birthday", "出生日期", "DateFormatter"),
  27. new FieldItem("idCard", "身份证号"),
  28. new FieldItem("phoneNumber", "联系号码"),
  29. new FieldItem("phoneNumber2", "备用号码"),
  30. });
  31. if (AbpSession.AccountType == AccountTypeDefinition.System)
  32. {
  33. table.AddField(new FieldItem("companyName", "公司信息"));
  34. table.AddField(new FieldItem("organizationName", "公司部门"));
  35. table.AddField(new FieldItem("isMaster", "是否负责人","IsMasterFormatter"));
  36. }
  37. else
  38. {
  39. table.AddField(new FieldItem("organizationName", "公司部门"));
  40. }
  41. var inputs = new List<Input>()
  42. {
  43. new InputHide("id"),
  44. new Input("code", "员工编号"),
  45. new Input("name", "员工姓名"),
  46. new Input("email", "电子邮箱"),
  47. new Input("organizationNo", "员工部门").SetSelectOptions(""),
  48. new Input("phoneNumber", "联系号码"),
  49. new InputDate("birthday", "出生日期").SetNotRequired(),
  50. new Input("idCard", "身份证号").SetNotRequired(),
  51. new Input("phoneNumber2", "备用号码").SetNotRequired(),
  52. new InputTextarea("profile", "员工描述").SetNotRequired(),
  53. };
  54. var modalBody = new ModalBodyViewModel().AddInputs(inputs);
  55. var modal = new ModalViewModel("员工").SetBody(modalBody);
  56. var modal_bind = new ModalViewModel("绑定账号", "", new ModalBodyViewModel(new List<Input>()
  57. {
  58. new InputHide("staffNo"),
  59. new Input("userName", "用户账号").SetSelectOptions("")
  60. }, "form-bind"), "modal-bind");
  61. }
  62. @section css{
  63. }
  64. @Html.Partial("Table/_Table", table)
  65. @section modal{
  66. <!--Modal Start-->
  67. @Html.Partial("Modals/_Modal", modal)
  68. @Html.Partial("Modals/_Modal", modal_bind)
  69. <!--Modal End-->
  70. }
  71. @section scripts
  72. {
  73. <script type="text/javascript">
  74. var $table;
  75. $(function() {
  76. @if (string.IsNullOrEmpty(companyNo))
  77. {
  78. <text>
  79. $table = LoadTable();
  80. </text>
  81. }
  82. else
  83. {
  84. <text>
  85. $table = LoadTable({
  86. searchList: [{ "KeyField": "company", "KeyWords": '@(companyNo)', "FieldType": 0, "ExpType": 0 }]
  87. });
  88. </text>
  89. }
  90. var funs = window.iwbfuns || { none: function() { console.log("No type"); } };
  91. funs["btnCreate"] = function() {
  92. if ('@(companyNo)') {
  93. $.iwbAjax4({
  94. url: abp.appUrl + "Query/GetOrgSelectTreeStr?no=@companyNo&type=1",
  95. success: function(res) {
  96. $("#organizationNo").html(res);
  97. BtnCreate({ data: { id: "" }, select2tree:"organizationNo" });
  98. }
  99. });
  100. } else {
  101. abp.message.warn("当前账号不能创建!");
  102. }
  103. }
  104. funs["btnUpdate"] = function() {
  105. var row = $table.bootstrapTable("getSelections")[0];
  106. if (row) {
  107. $.iwbAjax4({
  108. url: abp.appUrl + "Query/GetOrgSelectTreeStr?type=1&no="+row.companyNo,
  109. success: function(res) {
  110. $("#organizationNo").html(res);
  111. BtnUpdate({ select2tree:"organizationNo" });
  112. }
  113. });
  114. }
  115. };
  116. funs["btnBind"] = function(url) {
  117. var row = $table.bootstrapTable("getSelections")[0];
  118. if (row) {
  119. if (row.userName) {
  120. abp.message.warn("已绑定账号,请勿重复操作!");
  121. return;
  122. }
  123. OpenModal({
  124. url: url,
  125. modal: "modal-bind",
  126. data: { staffNo: row.id },
  127. table: 'table'
  128. });
  129. }
  130. };
  131. funs["btnUnBind"] = function(url) {
  132. var row = $table.bootstrapTable("getSelections")[0];
  133. if (row) {
  134. if (!row.userName) {
  135. abp.message.warn("未绑定账号,请检查后再试!");
  136. return;
  137. }
  138. MsgConfirm("你确定解绑账号吗?(解绑后账号会被锁定,需联系管理员激活!)",
  139. "解绑账号",
  140. function() {
  141. $.iwbAjax1({
  142. url: url,
  143. data: { id: row.id },
  144. success: RefreshTable
  145. });
  146. });
  147. }
  148. };
  149. var take = 10;
  150. $('#modal-bind #userName').select2({
  151. ajax: {
  152. url: abp.appUrl + "Query/UnBindUserAcInfos",
  153. type: "post",
  154. dataType: 'json',
  155. delay: 250,
  156. data: function(params) {
  157. //console.log(params);
  158. var page = params.page || 1;
  159. var queryParam = {
  160. AccountType: @(AccountTypeDefinition.Client),
  161. Word: params.term, // search term
  162. Skip: (page - 1) * take,
  163. Take: take
  164. };
  165. return queryParam;
  166. },
  167. processResults: function(data, params) {
  168. console.log(data, params);
  169. params.page = params.page || 1;
  170. var result = {
  171. results: data.items.map(function(v) {
  172. v.id = v.valueKey;
  173. v.text = v.nameKey;
  174. return v;
  175. }),
  176. pagination: {
  177. more: (params.page * 10) < data.totalCount
  178. }
  179. };
  180. //console.log(data, params);
  181. return result;
  182. },
  183. transport: function(params, success, failure) {
  184. //console.log("1", params);
  185. params = params || {};
  186. params.success = success;
  187. params.error = failure;
  188. var $request = $.iwbAjax41(params);
  189. return $request;
  190. },
  191. cache: true
  192. },
  193. cache: true,
  194. minimumInputLength: 0,
  195. templateResult: function(res) {
  196. if (res.loading) {
  197. return res.text;
  198. }
  199. return '{0} ({1})'.format(res.text, res.id);
  200. },
  201. templateSelection: function(res) {
  202. return res.text;
  203. }
  204. });
  205. });
  206. </script>
  207. <!--格式化-->
  208. <script id="formatter-script" type="text/javascript">
  209. function TypeFormatter(v) {
  210. var name = $('#hid-type option[value="' + v + '"]').text();
  211. switch (v) {
  212. case 0:
  213. return '<span class="label sm label-danger">' + name + '</span>';
  214. default:
  215. return '<span class="label sm label-info">' + name + '</span>';
  216. }
  217. }
  218. function UserNameFormatter(v) {
  219. if (v) {
  220. return '<span class="label sm label-success">' + v + '</span>';
  221. } else {
  222. return '<span class="label sm label-danger">未绑定账号</span>';
  223. }
  224. }
  225. function IsMasterFormatter(v) {
  226. if (v) {
  227. return '<span class="label sm label-success">负责人</span>';
  228. } else {
  229. return '';
  230. }
  231. }
  232. </script>
  233. }
  234. <section style="display: none">
  235. <select id="hid-type">
  236. <option value=""></option>
  237. </select>
  238. @*@Html.DropDownList("hid-type", type)*@
  239. </section>