ProductMapper.cshtml 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. @using ShwasherSys.Authorization.Permissions
  2. @using ShwasherSys.Models.Layout
  3. @using ShwasherSys.Models.Modal
  4. @{
  5. /**/
  6. ViewBag.ActiveMenu = PermissionNames.PagesProductInfoProductMapper; //The menu item will be active for this page.
  7. ViewBag.Title = "新旧产品替换";
  8. //var searchForm = new SearchFormViewModal(new List<SearchItem>()
  9. //{
  10. // new SearchItem("propertyNo","新产品").SetSearchIcon("query_Product_modal"),
  11. //}, false);
  12. }
  13. <style>
  14. .productInfo-container {
  15. min-height: 150px;
  16. border: 1px solid #0000ff;
  17. padding: 2px;
  18. margin-top: 5px;
  19. }
  20. .alert-ErrorInfo {
  21. animation: ErrorAction 2s linear;
  22. }
  23. @@keyframes ErrorAction{
  24. from {
  25. background: #c00
  26. }
  27. 50% {
  28. background: orange
  29. }
  30. to {
  31. background: #c00
  32. }
  33. }
  34. </style>
  35. <div class="productInfo-container pd">
  36. <div> <button class="btn btn-success selectNewProduct" data-pType="1" type="button" onclick="selectProduct(1)">选择新成品</button>
  37. <button class="btn btn-success selectNewProduct" data-pType="2" type="button" onclick="selectProduct(2)">选择新半成品</button> @*<input type="radio" name="productType1" id="productType1" value="1"/><input type="radio" name="productType1" id="semiProductType1" value="2" />*@</div>
  38. <table class="table table-striped ">
  39. <tbody>
  40. <tr>
  41. <th style="width: 150px">编码</th>
  42. <th style="width: 150px">名称</th>
  43. <th style="width: 100px">产品类别</th>
  44. <th style="width: 150px">规格</th>
  45. <th style="width: 100px">材质</th>
  46. <th style="width: 100px">硬度</th>
  47. <th style="width: 200px">表色</th>
  48. <th style="width: 100px"></th>
  49. </tr>
  50. </tbody>
  51. </table>
  52. </div>
  53. <div class="productInfo-container spd">
  54. <div> <button class="btn btn-success selectOldProduct" data-pType="1" type="button" onclick="selectProduct(3)">选择待替换成品</button>
  55. <button class="btn btn-success selectOldProduct" data-pType="2" type="button" onclick="selectProduct(4)">选择待替换半成品</button> @*<input type="radio" name="productType1" id="productType1" value="1"/><input type="radio" name="productType1" id="semiProductType1" value="2" />*@</div>
  56. <table class="table table-striped">
  57. <tbody>
  58. <tr>
  59. <th style="width: 150px">编码</th>
  60. <th style="width: 150px">名称</th>
  61. <th style="width: 100px">产品类别</th>
  62. <th style="width: 150px">规格</th>
  63. <th style="width: 100px">材质</th>
  64. <th style="width: 100px">硬度</th>
  65. <th style="width: 200px">表色</th>
  66. <th style="width: 100px"></th>
  67. </tr>
  68. </tbody>
  69. </table>
  70. </div>
  71. <div style="border: none;min-height: auto;display: flex; flex-wrap: wrap; justify-content:flex-end; align-items: center; padding: 5px 20px;">
  72. <div >
  73. <button class="btn btn-danger " style="display: inline-block" data-pType="1" type="button" onclick="ActionReplace()">替换</button>
  74. </div>
  75. </div>
  76. <div class="table-box mr-4 iwb-bootstrap-table">
  77. <input type="hidden" id="IsLock" value="N" />
  78. @*@Html.Action("ToolMenu", "Layout", new { pageName = ViewBag.ActiveMenu, searchForm })*@
  79. <table id="table"
  80. data-url="/api/services/app/ProductMapper/GetAll"
  81. data-striped="true" data-id-field="id" data-unique-id="id"
  82. data-method="post"
  83. data-side-pagination="server"
  84. data-content-type="application/x-www-form-urlencoded; charset=UTF-8"
  85. data-cache="false"
  86. data-pagination="true" data-page-size="30" data-page-number="1" data-page-list="[30,50,100,200]" data-pagination-detail-h-align="right" data-pagination-h-align="left"
  87. data-query-params="QueryParams"
  88. data-response-handler="ResponseHandler"
  89. data-click-to-select="true"
  90. data-single-select="true">
  91. <thead>
  92. <tr class="row" id="header">
  93. <th data-field="state" data-checkbox="true"></th>
  94. <th data-align="center" data-field="productNo">新编码</th>
  95. @*<th data-align="center" data-field="newProductType" data-formatter="ProductTypeFormatter">新产品类别</th>*@
  96. <th data-align="center" data-field="preProductNo">旧产品编码</th>
  97. <th data-align="center" data-field="preProductType" data-formatter="ProductTypeFormatter">旧产品类别</th>
  98. </tr>
  99. </thead>
  100. </table>
  101. </div>
  102. <section>
  103. @Html.Partial("Modals/Query/_ProductForReplace", "productId")
  104. @Html.Partial("Modals/Query/_SemiProductForReplace", "productId")
  105. </section>
  106. @section modal{
  107. }
  108. @section scripts
  109. {
  110. <script type="text/javascript">
  111. $(function() {
  112. //show完毕前执行
  113. LoadTable();
  114. //var funs = window.funs || { none: function () { console.log("No type"); } };
  115. //funs["btnUpdate"] = function () { BtnUpdate({ readonly: "propertyType" }); };
  116. });
  117. var showType = 1;
  118. function selectProduct(t) {
  119. showType = t;
  120. let modalName = "";
  121. if (t === 4 || t === 2) {
  122. modalName = "query_semiProduct_forReplace_modal";
  123. }
  124. if (t === 1 || t === 3) {
  125. modalName = "query_ProductForReplace_modal";
  126. }
  127. ShowModal(modalName);
  128. }
  129. function ProductTypeFormatter(v) {
  130. if (v === 1) {
  131. return '<span class="label label-info">成品</span>';
  132. } else {
  133. return '<span class="label label-warning">半成品</span>';
  134. }
  135. }
  136. function ActionReplace() {
  137. MsgConfirm('确认替换选择的产品吗?', '确认替换', SubmitReplace);
  138. }
  139. function SubmitReplace() {
  140. let replaceDto;
  141. let spEntity = [];
  142. let $trs = $(".spd table tbody tr").not(":first");
  143. if ($trs) {
  144. $.each($trs,
  145. function(i, v) {
  146. let pType = $(v).data("ptype");
  147. let pid = $(v).find("td").eq(0).html();
  148. spEntity.push({ ProductType: pType, ReplaceProductNo: pid });
  149. });
  150. } else {
  151. abp.message.warn("请选择要替换的旧编码!");
  152. }
  153. let $ptr = $(".pd table tbody tr").eq(1);
  154. if ($ptr) {
  155. let pid = $ptr.find("td").eq(0).html();
  156. replaceDto = {
  157. ProductNo: pid,
  158. PreReplaceProducts: spEntity
  159. }
  160. SaveAjax({
  161. url: window.appUrl + 'ProductMapper/ReplaceProductNo',
  162. data: replaceDto,
  163. isValidate: false,
  164. isAlert: false,
  165. success: function(data) {
  166. RefreshTable("table");
  167. let $trs = $(".spd table tbody tr");
  168. let errorProductNo = '';
  169. $.each(data,
  170. function(i, v) {
  171. let pNo = v.productNo;
  172. if (!v.isSuccess) {
  173. $trs.find(`td[data-id="${pNo}"]`).closest('tr').addClass('alert-ErrorInfo');
  174. errorProductNo += pNo + ',';
  175. } else {
  176. $trs.find(`td[data-id="${pNo}"]`).closest('tr').remove();
  177. }
  178. });
  179. if (errorProductNo && errorProductNo.length>0) {
  180. abp.message.warn(`替换结束!待替换的产品编码为:${errorProductNo}的产品替换错误!`);
  181. } else {
  182. abp.message.success("产品替换成功!");
  183. }
  184. }
  185. });
  186. } else {
  187. abp.message.warn("请选择要新编码!");
  188. }
  189. }
  190. </script>
  191. }
  192. <section style="display: none">
  193. <select id="hid-type">
  194. <option value=""></option>
  195. </select>
  196. @*@Html.DropDownList("hid-propertyType", productPropertyTypeList)*@
  197. </section>