Lawyer.cshtml 10 KB

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