Contract.cshtml 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378
  1. @using ContractService.Configuration
  2. @using ContractService.Authorization
  3. @using ContractService.Views.Shared.Modals
  4. @using ContractService.Views.Shared.Query
  5. @using ContractService.Views.Shared.SearchForm
  6. @using ContractService.Views.Shared.Table
  7. @using IwbZero.Runtime.Session
  8. @{
  9. ViewBag.Title = "合同信息";
  10. string activeMenu = PermissionNames.PagesCaseContractMgContractMg; //The menu item will be active for this page.
  11. ViewBag.ActiveMenu = activeMenu;
  12. string contractState = ViewBag.State;
  13. var searchList = new List<SearchItem>();
  14. var fields = new List<FieldItem>()
  15. {
  16. new FieldItem("caseName", "项目名称"),
  17. new FieldItem("code", "合同编号"),
  18. new FieldItem("name", "合同名称"),
  19. new FieldItem("contractState", "合同状态", "ContractStateFormatter"),
  20. };
  21. if (AbpSession.AccountType == AccountTypeDefinition.System || AbpSession.AccountType == AccountTypeDefinition.Lawyer)
  22. {
  23. searchList.AddRange(new List<SearchItem>()
  24. {
  25. new SearchItem("companyName", "企业名称")
  26. });
  27. fields.AddRange(new List<FieldItem>()
  28. {
  29. new FieldItem("companyName", "企业名称")
  30. });
  31. }
  32. else
  33. {
  34. fields.AddRange(new List<FieldItem>()
  35. {
  36. new FieldItem("startDateTime", "启动时间", "DateFormatter"),
  37. new FieldItem("endDateTime", "关闭时间", "DateFormatter"),
  38. new FieldItem("stateLastChangeTime", "状态变更时间", "DateTimeFormatter"),
  39. new FieldItem("stateLastChangeCause", "状态变更原由"),
  40. });
  41. }
  42. searchList.AddRange(new List<SearchItem>()
  43. {
  44. new SearchItem("caseName", "项目名称"),
  45. new SearchItem("code", "合同编号"),
  46. new SearchItem("name", "合同名称"),
  47. new SearchItem("contractState", "合同状态", FieldType.I).SetSelectItem(contractState),
  48. new SearchItem("startDateTime", "启动时间", FieldType.Dn),
  49. });
  50. if (AbpSession.AccountType == AccountTypeDefinition.System)
  51. {
  52. searchList.Add(new SearchItem("hasLawFirm", "分配律所").SetSelectItem(new List<SelectListItem>()
  53. {
  54. new SelectListItem(){Text = @"全部",Value = ""},
  55. new SelectListItem(){Text = @"未分配",Value = "0"},
  56. new SelectListItem(){Text = @"已分配",Value = "1"},
  57. }));
  58. fields.Add(new FieldItem("lawFirmName", "律所名称", "LawFirmNameFormatter"));
  59. }
  60. fields.Add(new FieldItem("", "操作", "ActionsFormatter"));
  61. var searchForm = new SearchFormViewModel(searchList);
  62. var table = new TableViewModel(IwbConsts.ApiAppUrl + "LegalContract/GetAll", "", searchForm)
  63. .SetFields(fields);
  64. // var inputs = new List<Input>()
  65. //{
  66. // new InputHide("id"),
  67. // new Input("code", "合同编号").SetNotRequired(),
  68. // new Input("name", "合同名称").SetNotRequired(),
  69. // new Input("caseNo", "项目信息").SetNotRequired(),
  70. // };
  71. // var modalBody = new ModalBodyViewModel().AddInputs(inputs);
  72. // var modal = new ModalViewModel("合同信息").SetBody(modalBody);
  73. var modal_lawFirm = new ModalViewModel("分配律所", "", new ModalBodyViewModel(new List<Input>()
  74. {
  75. new InputHide("id"),
  76. new AjaxSelect("lawFirmNo", "律所信息", "LawFirm", "contract", "query_lawFirm", "lawFirmNo")
  77. }, "form-lawFirm"), "modal-lawFirm", 0, "");
  78. var body_lawyer = new ModalBodyViewModel(new List<Input>()
  79. {
  80. new AjaxSelect("lawyerNo", "关联律师", "Lawyer", "", "query_lawyer").SetSearchClear("lawyerNo"),
  81. }, "form-lawyer");
  82. body_lawyer.AddInput((bool)ViewBag.IsLawFirmMaster ? new Input("lawyerMaster", "负责人").SetSelectOptions("<option value=\"0\" selected>辅助律师</option><option value=\"1\">主律师</option>") : new InputHide("lawyerMaster"));
  83. var modal_lawyer = new ModalViewModel("添加律师", "", body_lawyer, "modal-lawyer", 0, "");
  84. }
  85. @section css{
  86. }
  87. @Html.Partial("Table/_Table", table)
  88. @section modal{
  89. <!--Modal Start-->
  90. @*@Html.Partial("Modals/_Modal", modal)*@
  91. <div class="modal fade " id="modal-lawyers" aria-modal="true">
  92. <div class="modal-dialog modal-dialog-centered modal-lg" style="margin-top: 15px;">
  93. <div class="modal-content">
  94. <div class="modal-header" style="cursor: move;">
  95. <h4 class="modal-title">分配律师 <button class="btn btn-iwb btn-sm ml-2" onclick="AddLawyer()">添加律师</button></h4>
  96. <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
  97. </div>
  98. <div class="modal-body">
  99. <form id="form-lawyers" class="iwb-dynamic-box">
  100. <div class="row box-label">
  101. <div class="col-md-9"><label>律师姓名</label></div>
  102. <div class="col-md-2"><label>主律师</label></div>
  103. <div class="col-md-1"><label>操作</label></div>
  104. </div>
  105. <div class="box-body"></div>
  106. </form>
  107. </div>
  108. @Html.Partial("Modals/_ModalFooter", "0")
  109. </div>
  110. </div>
  111. </div>
  112. @Html.Partial("Modals/_Modal", modal_lawFirm)
  113. @Html.Partial("Modals/_Modal", modal_lawyer)
  114. @Html.Partial("Query/_LawFirm", new QuerySearchModel("query_lawFirm", "lawFirmNo").SetOriginField("id").SetAjaxSelectName("name"))
  115. @if (AbpSession.AccountType == AccountTypeDefinition.Lawyer)
  116. {
  117. @Html.Partial("Query/_LawyerWithLaw", new QuerySearchModel("query_lawyer", "lawyerNo|lawyer_no").SetOriginField("id").SetAjaxSelectName("name").SetSearchFun("SetLawyerQueryFun()"))
  118. }
  119. <!--Modal End-->
  120. }
  121. @section scripts
  122. {
  123. <script type="text/javascript">
  124. var $table;
  125. $(function() {
  126. $table = LoadTable();
  127. var funs = window.iwbfuns || { none: function() { console.log("No type"); } };
  128. funs["btnCreate"] = function() { BtnCreate({ data: { id: "" } }); }
  129. funs["btnUpdate"] = function() { BtnUpdate({ disabled: "" }); };
  130. });
  131. function GoDetail(id) {
  132. window.location.href = '@Url.Action("ContractDetail")' + '/' + id;
  133. }
  134. </script>
  135. <script id="LawFirm-Script">
  136. function SetLawFirm(id, name) {
  137. OpenModal({
  138. url: abp.appUrl + "LegalContract/SetLawFirm",
  139. modal: "modal-lawFirm",
  140. shownBefore: function () {
  141. $.iwbAjax4({
  142. url: abp.appUrl + "LegalContract/CheckContractHasLawFirm?no=" + id,
  143. success: function (res) {
  144. if (res) {
  145. abp.message.error("当前合同已分配!").done(function () {
  146. $("#modal-lawFirm").modal("hide");
  147. });
  148. }
  149. }
  150. });
  151. },
  152. save: function (opt) {
  153. var lawFirmNo = $("#modal-lawFirm #lawFirmNo").val();
  154. var lawFirmName = $("#modal-lawFirm #lawFirmNo option[value='" + lawFirmNo + "']").text();
  155. abp.message.confirm(
  156. '确认将合同<span class="text-danger">【{0}】</span>分配给律所<span class="text-danger">【{1}】</span>吗?分配后将无法更改!'
  157. .format(name, lawFirmName),
  158. "确认律所",
  159. function (isConfirmed) {
  160. if (isConfirmed) {
  161. $.iwbAjax1({
  162. url: opt.url,
  163. data: { id: id, lawFirmNo: lawFirmNo },
  164. success: function () {
  165. RefreshTable();
  166. $("#modal-lawFirm").modal("hide");
  167. }
  168. });
  169. }
  170. },
  171. true);
  172. }
  173. });
  174. }
  175. </script>
  176. @if (AbpSession.AccountType == AccountTypeDefinition.Lawyer)
  177. {
  178. <script id="Lawyer-Script">
  179. function SetLawyerQueryFun() {
  180. return { "KeyField": "lawFirmNo", "KeyWords": '@(AbpSession.GetClaimValue(IwbConsts.UserCompanyLawFirmClaimType))' }
  181. }
  182. //添加辅助律师
  183. function SetLawyer(id,caseNo) {
  184. OpenModal({
  185. data: { lawyerMaster: 0 },
  186. url: abp.appUrl + "LegalContract/SetLawyer",
  187. modal: "modal-lawyers",
  188. shownBefore: function () {
  189. $('#modal-lawyer #lawyerNo').data('column-key', caseNo);
  190. $.iwbAjax4({
  191. url: abp.appUrl + "LegalContract/GetContractLawyers?no=" + id,
  192. success: function(res) {
  193. $('#form-lawyers .box-body').empty();
  194. if (res && res.length) {
  195. res.forEach(function(v) {
  196. LawyerFormatter(v.no, v.name, v.isMaster);
  197. });
  198. } else {
  199. $('#form-lawyers .box-body')
  200. .html('<label class="empty text-danger">暂未分配辅助律师</label>');
  201. }
  202. }
  203. });
  204. },
  205. dataFun: function() {
  206. var data = {};
  207. data.id = id;
  208. data.list = [];
  209. data.master = $('#modal-lawyers input[name="master"]').val();
  210. $('#modal-lawyers input[name="lawyer"]').each(function() {
  211. var v = $(this).val();
  212. if (v) {
  213. data.list.push(v);
  214. }
  215. });
  216. return data;
  217. }
  218. @if ((bool) ViewBag.IsLawFirmMaster)
  219. {
  220. <text>
  221. , save: function (opt) {
  222. var data = opt.data;
  223. if (!data) {
  224. data = opt.dataFun.call();
  225. }
  226. if (!data.master) {
  227. abp.message.warn("请设置一名主律师!");
  228. return;
  229. }
  230. $.iwbAjax1({
  231. url: opt.url,
  232. data: data,
  233. success: function() {
  234. $('#modal-lawyers').modal('hide');
  235. }
  236. });
  237. }
  238. </text>
  239. }
  240. });
  241. }
  242. //添加辅助律师
  243. function AddLawyer() {
  244. OpenModal({
  245. modal: "modal-lawyer",
  246. data: { lawyerMaster: 0 },
  247. save: function() {
  248. var v = $('#modal-lawyer #lawyerNo').val(),
  249. n = $('#modal-lawyer #lawyerNo option[value="' + v + '"]').text(),
  250. m = $('#modal-lawyer #lawyerMaster').val();
  251. if (!v) {
  252. abp.message.warn("请选择一名律师!");
  253. return;
  254. } else if ($('#modal-lawyers input[value="' + v + '"]').length) {
  255. abp.message.warn("律师已关联,请勿重复添加!");
  256. return;
  257. }
  258. if (m == "1" && $('#modal-lawyers input[name="master"]').length) {
  259. abp.message.warn("已有主律师,请勿重复添加!");
  260. return;
  261. }
  262. LawyerFormatter(v, n, m == "1");
  263. $('#modal-lawyer').modal('hide');
  264. }
  265. });
  266. }
  267. //辅助律师显示格式化
  268. function LawyerFormatter(v, n, m) {
  269. var str =
  270. '<div class="row group"><input name="{2}" type="hidden" value="{0}" /><div class="col-md-9"><input type="text" class="form-control form-control-sm disabled" value="{1}" disabled="" /></div><div class="col-md-2"><input type="text" class="form-control form-control-sm disabled" value="{3}" disabled="" /></div><div class="col-md-1"><button type="button" class="btn btn-sm btn-danger" onclick="DeleteGroup(this);">删除</button></div></div>'
  271. .format(v, n, m ? "master" : "lawyer", m ? "主律师" : "辅助律师");
  272. $('#modal-lawyers .box-body .empty').remove();
  273. $('#form-lawyers .box-body').append(str);
  274. }
  275. function DeleteGroup(that) {
  276. var $that = $(that).closest('.group');
  277. $that.remove();
  278. //$that.fadeOut(500, function () {
  279. // $that.remove();
  280. //});
  281. }
  282. </script>
  283. }
  284. <!--格式化-->
  285. <script id="formatter-script" type="text/javascript">
  286. function TypeFormatter(v) {
  287. var name = $('#hid-type option[value="' + v + '"]').text();
  288. switch (v) {
  289. case 0:
  290. return '<span class="label sm label-danger">' + name + '</span>';
  291. default:
  292. return '<span class="label sm label-info">' + name + '</span>';
  293. }
  294. }
  295. function ContractStateFormatter(v) {
  296. var name = $('#hid-contract-state option[value="' + v + '"]').text();
  297. return name;
  298. }
  299. function LawFirmNameFormatter(v) {
  300. if (v) {
  301. return v;
  302. } else {
  303. return '<span class="text-danger">未分配</span>';
  304. }
  305. }
  306. function ActionsFormatter(v, r) {
  307. var str = '', id = r.id;
  308. @if (IsGranted(PermissionNames.PagesCaseContractMgContractMgSetLawFirm) && AbpSession.AccountType == AccountTypeDefinition.System)
  309. {
  310. <text>
  311. if (!r.lawFirmName) {
  312. str += '<span class="table-action" onclick="SetLawFirm(\'{1}\',\'{2}\')">{0} 分配律所</span>'.format(tableActionIcon, id,r.name);
  313. }
  314. </text>
  315. }
  316. @if (((bool) ViewBag.IsLawFirmMaster || IsGranted(PermissionNames.PagesCaseContractMgContractMgSetLawyer)) && AbpSession.AccountType == AccountTypeDefinition.Lawyer)
  317. {
  318. <text>
  319. if (r.isMaster) {
  320. str += '<span class="table-action" onclick="SetLawyer(\'{1}\',\'{2}\')">{0} 分配律师</span>'.format(tableActionIcon, id,r.caseNo);
  321. }
  322. </text>
  323. }
  324. @if (IsGranted(PermissionNames.PagesCaseContractMgContractMgQuery))
  325. {
  326. <text>
  327. str += '<span class="table-action" onclick="GoDetail(\'{1}\')">{0} 合同详情</span>'.format(tableActionIcon,id);
  328. </text>
  329. }
  330. if (!str) {
  331. str += '<span class="table-action" >{0} 暂无操作</span>'.format(tableActionIcon);
  332. }
  333. return str;
  334. }
  335. </script>
  336. }
  337. <section style="display: none">
  338. <select id="hid-contract-state">
  339. @Html.Raw(contractState)
  340. </select>
  341. <select id="hid-type">
  342. <option value=""></option>
  343. </select>
  344. @*@Html.DropDownList("hid-type", type)*@
  345. </section>