RmProduct.cshtml 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. @using ShwasherSys.Authorization.Permissions
  2. @using ShwasherSys.BasicInfo
  3. @using ShwasherSys.Models.Layout
  4. @using ShwasherSys.Models.Modal
  5. @using ShwasherSys.Views.Shared.New.Modals
  6. @using ShwasherSys.Views.Shared.New.Table
  7. @using InputTypes = ShwasherSys.Views.Shared.New.Modals.InputTypes
  8. @using ModalBodyViewModel = ShwasherSys.Views.Shared.New.Modals.ModalBodyViewModel
  9. @using ModalHeaderViewModel = ShwasherSys.Models.Modal.ModalHeaderViewModel
  10. @using SpecialInputModel = ShwasherSys.Views.Shared.New.Modals.SpecialInputModel
  11. @{
  12. ViewBag.Title = "原材料信息维护";
  13. string activeMenu = PermissionNames.PagesProductInfoRmProduct; //The menu item will be active for this page.
  14. ViewBag.ActiveMenu = activeMenu;
  15. var searchForm = new SearchFormViewModal(new List<SearchItem>()
  16. {
  17. new SearchItem("id","原材料编码"),
  18. new SearchItem("productName","名称"),
  19. new SearchItem("material","材质"),
  20. new SearchItem("model","规格"),
  21. });
  22. var table = new TableViewModel("/api/services/app/RmProduct/GetAll", activeMenu, searchForm)
  23. .SetFields(new List<FieldItem>()
  24. {
  25. new FieldItem("id", "原材料编码"),
  26. new FieldItem("productName", "名称"),
  27. new FieldItem("material", "材质"),
  28. new FieldItem("model", "规格"),
  29. new FieldItem("productDesc", "描述"),
  30. });
  31. }
  32. @section css{
  33. }
  34. @Html.Partial("New/Table/_Table", table)
  35. @section modal{
  36. <!--Main Modal-->
  37. @{
  38. var modal = new ModalViewModel("原材料", new ModalBodyViewModel(new List<Input>()
  39. {
  40. new Input("id", "原材料编码"),
  41. new Input("productName", "名称"),
  42. new Input("material", "材质"),
  43. new Input("model", "规格").SetNotRequired(),
  44. new InputTextarea("productDesc", "描述").SetNotRequired(),
  45. //new Input("userName", "登陆账号").SetNotRequired(),
  46. }));
  47. }
  48. @Html.Partial("New/Modals/_Modal", modal)
  49. <section>
  50. <div id="modalImport" class="modal fade" role="dialog" tabindex="-1" aria-labelledby="ModalLabel" aria-hidden="true">
  51. <div class="modal-dialog modal-dialog-centered" role="document">
  52. <div class="modal-content">
  53. @Html.Partial("Modals/_ModalHeader", new ModalHeaderViewModel("原材料导入", ""))
  54. @{
  55. var inputs2 = new List<InputViewModel>
  56. {
  57. new InputViewModel("importExcel",ShwasherSys.Models.Modal.InputTypes.File, displayName:"上传Excel").SetNotRequired(),
  58. new InputViewModel("downloadFile",ShwasherSys.Models.Modal.InputTypes.Text, displayName:" ").SetNotRequired(),
  59. };
  60. var specials2 = new List<ShwasherSys.Models.Modal.SpecialInputModel> {
  61. new ShwasherSys.Models.Modal.SpecialInputModel()
  62. {
  63. Id= "importExcel",
  64. InputStr = "<div class=\"col-md-10\"><input class=\"form-control\" name=\"fileInfo\" id=\"fileInfo2\" type=\"hidden\"><input class=\"form-control\" name=\"fileName\" id=\"fileName2\" type=\"hidden\"><input class=\"form-control\" name=\"fileExt\" id=\"fileExt2\" type=\"hidden\"><input class=\"form-control\" name=\"constraintExt\" value=\"xls,xlsx\" type=\"hidden\"><div class=\"custom-file\"><input class=\"custom-file-input\" id=\"customFile-2\" type=\"file\" onchange=\"FileCheck(this,\'fileInfo2\')\" onclick=\"OpenUploadWindow()\"><label class=\"custom-file-label\" for=\"customFile-2\">选择文件</label></div></div>"
  65. },
  66. new ShwasherSys.Models.Modal.SpecialInputModel()
  67. {
  68. Id="downloadFile",
  69. InputStr = "<div class=\"col-md-10\"><button id=\"download\" type=\"button\" class=\"btn btn-success waves-effect\" style=\"min-width: 100px; background-color: #678ceb;border: 1px solid #678ceb;\" data-url=\"../Download/Excel/RmProduct.xls\" onclick=\"DownloadFile(this)\">下载导入文件模板</button><span style=\"color:red;\">*导入数据会清空原有记录,请谨慎使用</span></div>"
  70. }
  71. };
  72. }
  73. @Html.Partial("Modals/_ModalBody", new ShwasherSys.Models.Modal.ModalBodyViewModel(inputs2, specials: specials2))
  74. @Html.Partial("Modals/_ModalFooter", "0")
  75. </div>
  76. </div>
  77. </div>
  78. </section>
  79. }
  80. @section scripts
  81. {
  82. <script type="text/javascript">
  83. var $table = $('#table');
  84. $(function () {
  85. LoadTable();
  86. var funs = window.funs || { none: function () { console.log("No type"); } };
  87. funs["btnCreate"] = function () { BtnCreate({ data: { id: "" } }); }
  88. funs["btnUpdate"] = function () { BtnUpdate({ disabled: "id" }); };
  89. funs["btnImport"] = function(url) {
  90. OpenModal(url, { modal: $("#modalImport"), modaltitle: "原材料导入", data: { constraintExt:"xls,xlsx"} });
  91. }
  92. });
  93. function FileCheck(that, id) {
  94. var $fileName = $(that).closest(".col-md-10").find('input[name=fileName]');
  95. var $fileExt = $(that).closest(".col-md-10").find('input[name=fileExt]');
  96. var $fileConstraintExt = $(that).closest(".col-md-10").find('input[name=constraintExt]');
  97. FileInputCheck(that, id, false, 100, function (fileName) {
  98. var name = fileName.substring(0, fileName.lastIndexOf("."));
  99. var ext = fileName.substring(fileName.lastIndexOf(".") + 1, fileName.length);
  100. $fileName.val(name);
  101. $fileExt.val(ext);
  102. }, function(fileName) {
  103. var name = fileName.substring(0, fileName.lastIndexOf("."));
  104. var ext = fileName.substring(fileName.lastIndexOf(".") + 1, fileName.length);
  105. if ($fileConstraintExt) {
  106. var fileConstraintExt = $fileConstraintExt.val();
  107. if (fileConstraintExt&&fileConstraintExt.indexOf(ext) === -1) {
  108. abp.message.warn("只能选择" + fileConstraintExt + "为后缀的文件类型");
  109. $(".custom-file-label").text("");
  110. return false;
  111. }
  112. }
  113. });
  114. }
  115. function DownloadFile(that) {
  116. window.location.href = "/Resources/Excel/RmProduct.xls";
  117. }
  118. </script>
  119. <!--格式化-->
  120. <script id="formatter-script" type="text/javascript">
  121. </script>
  122. }
  123. <section style="display: none">
  124. <select id="hid-type">
  125. <option value=""></option>
  126. </select>
  127. @*@Html.DropDownList("hid-du", duty)
  128. @Html.DropDownList("hid-de", depart)
  129. @Html.DropDownList("hid-gender", gender)*@
  130. </section>