Mold.cshtml 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  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.PagesCompanyDieMaintenanceMold; //The menu item will be active for this page.
  9. ViewBag.ActiveMenu = activeMenu;
  10. var searchForm = new SearchFormViewModal(new List<SearchItem>()
  11. {
  12. new SearchItem("no","模具编码"),
  13. new SearchItem("name","模具名称"),
  14. new SearchItem("model","模具规格"),
  15. new SearchItem("material","模具材质"),
  16. new SearchItem("outerDiameter","外径"),
  17. new SearchItem("insideDiameter","内径"),
  18. //new SearchItem("expireDate","有效期限",FiledType.D,ExpType.GreaterOrEqual),
  19. //new SearchItem("expireDate","至",FiledType.D,ExpType.LessOrEqual),
  20. //new SearchItem("maintenanceDate","维护时间",FiledType.D,ExpType.GreaterOrEqual),
  21. //new SearchItem("maintenanceDate","至",FiledType.D,ExpType.LessOrEqual),
  22. //new SearchItem("nextMaintenanceDate","下一次维护时间",FiledType.Dnull,ExpType.GreaterOrEqual),
  23. //new SearchItem("nextMaintenanceDate","至",FiledType.Dnull,ExpType.LessOrEqual),
  24. }, "search-form", false);
  25. var table = new TableViewModel("/api/services/app/Mold/GetAll", activeMenu, searchForm)
  26. .SetFields(new List<FieldItem>()
  27. {
  28. new FieldItem("no", "模具编码",isSort:true),
  29. // new FieldItem("name", "模具名称"),
  30. new FieldItem("model", "模具规格"),
  31. new FieldItem("material", "模具材质"),
  32. new FieldItem("customerName", "客户"),
  33. new FieldItem("shelfNum", "架号"),
  34. new FieldItem("outerDiameter", "外径"),
  35. new FieldItem("insideDiameter", "内径"),
  36. new FieldItem("thickness", "厚度"),
  37. new FieldItem("height", "高度"),
  38. new FieldItem("rigidity", "硬度"),
  39. //new FieldItem("expireDate", "有效期限","ExDateFormatter"),
  40. new FieldItem("maintenanceCycle", "维护周期"),
  41. //new FieldItem("maintenanceDate", "维护时间","DateFormatter"),
  42. //new FieldItem("nextMaintenanceDate", "下一次维护时间","MtDateFormatter"),
  43. });
  44. }
  45. @section css{
  46. }
  47. @Html.Partial("New/Table/_Table", table)
  48. @section modal{
  49. <!--Main Modal-->
  50. @{
  51. var modal = new ModalViewModel("模具", new ModalBodyViewModel(new List<Input>()
  52. {
  53. new InputHide("id"),
  54. new InputHide("no", "模具编码"),
  55. new Input("name", "模具名称").SetNotRequired(),
  56. new Input("model", "模具规格").SetNotRequired(),
  57. new Input("material", "模具材质").SetNotRequired(),
  58. new Input("customerName", "客户").SetNotRequired(),
  59. new Input("shelfNum", "架号").SetNotRequired(),
  60. new Input("outerDiameter", "内径").SetNotRequired(),
  61. new Input("insideDiameter", "外径").SetNotRequired(),
  62. new Input("thickness", "厚度").SetNotRequired(),
  63. new Input("height", "高度").SetNotRequired(),
  64. new Input("rigidity", "硬度").SetNotRequired(),
  65. new InputNumber("maintenanceCycle", "维护周期(次数)",other:"min=1").SetNotRequired(),
  66. new InputTextarea("description", "模具描述").SetNotRequired(),
  67. //new InputDate("expireDate", "有效期限"),
  68. //new InputNumber("maintenanceCycle", "维护周期(天)").SetMin(0),
  69. //new InputDate("maintenanceDate", "维护时间"),
  70. }));
  71. }
  72. @Html.Partial("New/Modals/_Modal", modal)
  73. @{
  74. var recordModal = new ModalViewModel("添加维护记录", "", new ModalBodyViewModel(new List<Input>()
  75. {
  76. new InputHide("id"),
  77. new Input("no", "设备编号"),
  78. new Input("name", "设备名称"),
  79. new Input("address", "维护地点"),
  80. new InputTextarea("description", "维护内容").SetNotRequired(),
  81. new InputDate("planDate", "计划维护时间").SetNotRequired()
  82. }), "record-modal");
  83. }
  84. @Html.Partial("New/Modals/_Modal", recordModal)
  85. }
  86. @section scripts
  87. {
  88. <script type="text/javascript">
  89. var $table = $('#table');
  90. $(function () {
  91. $table = LoadTable();
  92. var funs = window.funs || { none: function () { console.log("No type"); } };
  93. funs["btnCreate"] = function () {
  94. BtnCreate({
  95. data: { id: "", no: "1", maintenanceCycle: "50000000" },
  96. readonly: "maintenanceCycle"
  97. });
  98. }
  99. funs["btnUpdate"] = function () { BtnUpdate({ disabled: "maintenanceDate", readonly: "maintenanceCycle" }); };
  100. funs["btnMaintain"] = function (url) {
  101. var row= $table.bootstrapTable("getSelections")[0];
  102. if (row) {
  103. OpenModal({
  104. url: url,
  105. disabled: "no,name" ,
  106. modal: $('#record-modal'),
  107. data: row
  108. });
  109. }
  110. };
  111. });
  112. </script>
  113. <!--格式化-->
  114. <script id="formatter-script" type="text/javascript">
  115. function ExDateFormatter(v, r, i, f) {
  116. return CheckDateFormatter(v, r, i, f, 3 * 30);
  117. }
  118. function MtDateFormatter(v, r, i, f) {
  119. return CheckDateFormatter(v, r, i, f, 10);
  120. }
  121. function CheckDateFormatter(v, r, i, f,day) {
  122. var value = DateFormatter(v, r, i, f);
  123. if (value <= new Date().format('yyyy-MM-dd')) {
  124. return '<span style="color:red" class="iwb-flash2">' + value + ' [已到期]</span>';
  125. }
  126. var date = new Date(new Date(new Date().getTime() + day * 1000 * 60 * 60 * 24)).format('yyyy-MM-dd');
  127. if (date >= value) {
  128. return '<span style="color:orange" class="iwb-flash">' + value + ' [即将到期]</span>';
  129. }
  130. return value;
  131. }
  132. function TypeFormatter(v) {
  133. var name = $('#hid-type option[value="' + v + '"]').text();
  134. switch (v) {
  135. case 0:
  136. return '<span class="label label-danger">' + name + '</span>';
  137. default:
  138. return '<span class="label label-info">' + name + '</span>';
  139. }
  140. }
  141. </script>
  142. }
  143. <section style="display: none">
  144. <select id="hid-type">
  145. <option value=""></option>
  146. </select>
  147. @*@Html.DropDownList("hid-type", type)*@
  148. </section>