LicenseDocument.cshtml 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. @using ShwasherSys
  2. @using ShwasherSys.Authorization.Permissions
  3. @using ShwasherSys.Models.Layout
  4. @using ShwasherSys.Views.Shared.New.Modals
  5. @using ShwasherSys.Views.Shared.New.Table
  6. @{
  7. ViewBag.Title = "证照信息维护";
  8. string activeMenu = PermissionNames.PagesCompanyLicenseDocument; //The menu item will be active for this page.
  9. ViewBag.ActiveMenu = activeMenu;
  10. List<SelectListItem> group = ViewBag.LicenseGroup;
  11. var searchForm = new SearchFormViewModal(new List<SearchItem>()
  12. {
  13. new SearchItem("no","证照编码"),
  14. new SearchItem("name","证照名称"),
  15. new SearchItem("licenseGroup","证照组").SetSearchItem(group),
  16. new SearchItem("licenseType","证照类型").SetSearchItem(new List<SelectListItem>(){}),
  17. },"search-form",false);
  18. var table = new TableViewModel( "/api/services/app/LicenseDocument/GetAll", activeMenu, searchForm)
  19. .SetFields(new List<FieldItem>()
  20. {
  21. new FieldItem("no", "证照编码"),
  22. new FieldItem("name", "证照名称"),
  23. new FieldItem("licenseGroup", "证照组"),
  24. new FieldItem("licenseType", "证照类型"),
  25. new FieldItem("expireDate", "过期时间","ExDateFormatter"),
  26. });
  27. }
  28. @section css{
  29. }
  30. @Html.Partial("New/Table/_Table", table)
  31. @section modal{
  32. <!--Main Modal-->
  33. @{
  34. var modal = new ModalViewModel("证照", new ModalBodyViewModel(new List<Input>()
  35. {
  36. new InputHide("id"),
  37. new Input("no", "证照编码"),
  38. new Input("name", "证照名称"),
  39. new InputTextarea("description", "证照描述").SetNotRequired(),
  40. new Input("licenseGroup", "证照组").SetSelectOptions(group),
  41. new Input("licenseType", "证照类型",InputTypes.List),
  42. new InputDate("expireDate", "过期时间"),
  43. new InputFile("filePath", "附件路径").SetFileOption("fileInfo","fileName","fileExt",100).SetHelp("上传PDF文件更佳").SetNotRequired().SetOuterBefore("<div class=\"attach-unit\" >").SetOuterAfter("</div>"),
  44. }));
  45. }
  46. @Html.Partial("New/Modals/_Modal", modal)
  47. }
  48. @section scripts
  49. {
  50. <script type="text/javascript">
  51. var $table;
  52. $(function() {
  53. $('#KeyWords-3').on('change', function() { GetLicenseType(this, 'KeyWords-4') });
  54. $table = LoadTable();
  55. var funs = window.funs || { none: function() { console.log("No type"); } };
  56. funs["btnCreate"] = function(url) {
  57. $('#licenseGroup').off('change.group')
  58. .on('change.group', function() { GetLicenseType(this, 'licenseType') });
  59. $('.custom-file-label').text('选择文件');
  60. BtnCreate({
  61. data: { id: "" },
  62. save: function() {
  63. SaveLicense(url);
  64. }
  65. });
  66. }
  67. funs["btnUpdate"] = function(url) {
  68. var row = $('#table').bootstrapTable("getSelections")[0];
  69. if (row) {
  70. $('#licenseGroup').off('change.group').on('change.group',
  71. function() { GetLicenseType(this, 'licenseType', row.licenseType) });
  72. $('.custom-file-label').text('选择文件');
  73. BtnUpdate({
  74. disabled: "no",
  75. save: function() {
  76. SaveLicense(url);
  77. }
  78. });
  79. }
  80. };
  81. funs["btnDownLoad"] = function() {
  82. var row = $('#table').bootstrapTable("getSelections")[0];
  83. if (row) {
  84. QueryAttach(row.no);
  85. }
  86. };
  87. });
  88. function QueryAttach(no) {
  89. SaveAjax({
  90. url: window.appUrl + 'SysAttachFile/QueryAttach',
  91. data: { TableName: 'License', ColName: 'License', Key: no },
  92. isValidate: false,
  93. isAlert: false,
  94. success: function(res) {
  95. if (res && res.length > 0) {
  96. var fileExt = res[0].fileExt;
  97. if (officeFileExt.indexOf(fileExt) > 0) {
  98. OpenFile(res[0].filePath, 'office', { height: 800 });
  99. } else {
  100. OpenFile(res[0].filePath, null, { height: 800 });
  101. }
  102. } else {
  103. abp.message.warn("未查询到附件!");
  104. }
  105. }
  106. });
  107. }
  108. function GetLicenseType(that, id, type) {
  109. var groupName = $(that).val();
  110. $.iwbAjax4({
  111. url: window.appUrl + 'LicenseType/GetSelectStrByGroup?groupName=' + groupName,
  112. success: function(res) {
  113. $('#' + id).html(res).select2();
  114. if (type) {
  115. $('#' + id).val(type).select2();
  116. }
  117. }
  118. });
  119. }
  120. function SaveLicense(url) {
  121. var data = GetAttachFilesDate();
  122. SaveAjax({
  123. url: url,
  124. data: data,
  125. success: function() {
  126. RefreshTable();
  127. $('#modal').modal("hide");
  128. }
  129. });
  130. }
  131. function GetAttachFilesDate() {
  132. var data = {
  133. id: $("#modal #id").val(),
  134. no: $("#modal #no").val(),
  135. name: $("#modal #name").val(),
  136. description: $("#modal #description").val(),
  137. licenseGroup: $("#modal #licenseGroup").val(),
  138. licenseType: $("#modal #licenseType").val(),
  139. expireDate: $("#modal #expireDate").val(),
  140. attachFiles: []
  141. };
  142. $(".attach-unit .form-group-sm").each(function(i, v) {
  143. var fileInfo = $(v).find("input[name='fileInfo']").val();
  144. if (fileInfo) {
  145. var fileName = $(v).find("input[name='fileName']").val();
  146. var fileExt = $(v).find("input[name='fileExt']").val();
  147. var fileTitle = $(v).find("label").text();
  148. data.attachFiles.push(
  149. { fileTitle: fileTitle, fileInfo: fileInfo, fileName: fileName, fileExt: fileExt });
  150. }
  151. });
  152. return data;
  153. }
  154. </script>
  155. <!--格式化-->
  156. <script id="formatter-script" type="text/javascript">
  157. function ExDateFormatter(v, r, i, f) {
  158. var value = DateFormatter(v, r, i, f);
  159. if (value <= new Date().format('yyyy-MM-dd')) {
  160. return '<span style="color:red" class="iwb-flash2">' + value + ' [已到期]</span>';
  161. }
  162. var date = new Date(new Date(new Date().getTime() + 1 * 30 * 1000 * 60 * 60 * 24)).format('yyyy-MM-dd');
  163. if (date >= value) {
  164. return '<span style="color:orange" class="iwb-flash">' + value + ' [即将到期]</span>';
  165. }
  166. return value;
  167. }
  168. function TypeFormatter(v) {
  169. var name = $('#hid-type option[value="' + v + '"]').text();
  170. switch (v) {
  171. case 0:
  172. return '<span class="label label-danger">' + name + '</span>';
  173. default:
  174. return '<span class="label label-info">' + name + '</span>';
  175. }
  176. }
  177. </script>
  178. }
  179. <section style="display: none">
  180. <select id="hid-type">
  181. <option value=""></option>
  182. </select>
  183. @*@Html.DropDownList("hid-type", type)*@
  184. </section>