Standards - 复制(2).cshtml 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525
  1. @using ShwasherSys.Authorization.Permissions
  2. @using ShwasherSys.Models.Layout
  3. @using ShwasherSys.Models.Modal
  4. @using ShwasherSys.Views.Shared.New.Table
  5. @{
  6. /**/
  7. ViewBag.ActiveMenu = PermissionNames.PagesProductInfoStandards; //The menu item will be active for this page.
  8. ViewBag.Title = "标准管理";
  9. // List<SelectListItem> classification = ViewBag.Classification;
  10. var searchForm = new SearchFormViewModal(new List<SearchItem>()
  11. {
  12. new SearchItem("standardName","标准规格"),
  13. new SearchItem("standardFullName","标准名称"),
  14. }, false);
  15. var tableDetail = new TableViewModel("/api/services/app/Standards/GetDetail", null, null, "tableDetail")
  16. .SetFields(new List<FieldItem>()
  17. {
  18. new FieldItem("standardName", "名称"),
  19. new FieldItem("specs", "规格"),
  20. new FieldItem("innerDiameter", "内径",formatter:"InnerDiameterFormatter"),
  21. new FieldItem("outDiameter", "外径",formatter:"OutDiameterFormatter"),
  22. new FieldItem("thickness", "厚度",formatter:"ThicknessFormatter"),
  23. new FieldItem("height", "高度",formatter:"HeightFormatter"),
  24. new FieldItem("innerChamfer","内倒角",formatter:"InnerChamferFormatter"),
  25. new FieldItem("outChamfer", "外倒角",formatter:"OutChamferFormatter"),
  26. new FieldItem("thousandWeigh", "千件重"),
  27. }).SetPageArray(25);
  28. }
  29. @section css{
  30. <style>
  31. .drawing {
  32. width: 500px;
  33. height: 200px;
  34. display: flex;
  35. flex-flow: row nowrap;
  36. justify-content: center;
  37. align-items: center;
  38. }
  39. #moreInfo {
  40. margin: 15px 5px;
  41. }
  42. .catalogInfo table {
  43. border-collapse: separate;
  44. border-spacing: 1px;
  45. }
  46. .catalogInfo tr td {
  47. border: 1px solid #ccc;
  48. }
  49. .catalogInfo tr td:nth-child(1) {
  50. background: #ccc;
  51. text-align: right;
  52. }
  53. .infovalue {
  54. width: 250px;
  55. }
  56. .infoPic {
  57. width: 200px;
  58. height: 100%;
  59. /* display: flex;
  60. justify-content: center;
  61. align-items: center;*/
  62. }
  63. </style>
  64. }
  65. <div class="table-box mr-4 iwb-bootstrap-table" id="table-box-table">
  66. <input type="hidden" id="IsLock" value="N" />
  67. @Html.Action("ToolMenu", "Layout", new { pageName = ViewBag.ActiveMenu ,searchForm})
  68. <table id="table"
  69. data-url="/api/services/app/Standards/GetDetailView"
  70. data-striped="true" data-id-field="id" data-unique-id="id"
  71. data-method="post"
  72. data-side-pagination="server"
  73. data-content-type="application/x-www-form-urlencoded; charset=UTF-8"
  74. data-cache="false"
  75. 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"
  76. data-query-params="QueryParams"
  77. data-response-handler="ResponseHandler"
  78. data-click-to-select="true"
  79. data-single-select="true">
  80. <thead>
  81. <tr class="row" id="header">
  82. <th data-field="state" data-checkbox="true"></th>
  83. @*<th data-align="center" data-field="standardAbbr">简写</th>*@
  84. @*<th data-align="center" data-field="standardAbbrName">标准简称</th>*@
  85. <th data-align="center" data-field="standardFullName">标准完整名称</th>
  86. <th data-align="center" data-field="standardName">标准规格</th>
  87. @*<th data-align="center" data-field="rigidity">硬度</th>
  88. <th data-align="center" data-field="param">参数</th>
  89. <th data-align="center" data-field="drawing" data-formatter="DrawingFormatter">图纸</th>
  90. <th data-align="center" data-field="" data-formatter="ActionFormatter">查看详情</th>*@
  91. <th data-align="center" data-field="specs">规格</th>
  92. <th data-align="center" data-field="innerDiameter" data-formatter="InnerDiameterFormatter">内径</th>
  93. <th data-align="center" data-field="outDiameter" data-formatter="OutDiameterFormatter">外径</th>
  94. <th data-align="center" data-field="thickness" data-formatter="ThicknessFormatter">厚度</th>
  95. <th data-align="center" data-field="height" data-formatter="HeightFormatter">高度</th>
  96. <th data-align="center" data-field="innerChamfer" data-formatter="InnerChamferFormatter">内倒角</th>
  97. <th data-align="center" data-field="outChamfer" data-formatter="OutChamferFormatter">外倒角</th>
  98. <th data-align="center" data-field="thousandWeigh" >千件重</th>
  99. </tr>
  100. </thead>
  101. </table>
  102. </div>
  103. <div class="box box-primary direct-chat direct-chat-primary" id="moreInfo">
  104. <div class="box-header with-border">
  105. <h3 class="box-title">规格详情</h3>
  106. <div class="box-tools pull-right">
  107. <button type="button" class="btn btn-box-tool" onclick="moreHide()"><i class="iconfont icon-close"></i></button>
  108. </div>
  109. </div>
  110. <!-- /.box-header -->
  111. <div class="box-body catalogInfo" style="">
  112. </div>
  113. </div>
  114. @section modal{
  115. <!--<section>-->
  116. <!--Main Modal-->
  117. <!--<div class="modal fade" id="modal" role="dialog" tabindex="-1" aria-labelledby="ModalLabel" aria-hidden="true">
  118. <div class="modal-dialog modal-dialog-centered" role="document">
  119. <div class="modal-content">
  120. @Html.Partial("Modals/_ModalHeader", new ModalHeaderViewModel("产品标准"))
  121. @{
  122. var inputs = new List<InputViewModel>
  123. {
  124. new InputViewModel("id", hide: true),
  125. new InputViewModel("standardName", displayName: "标准名称"),
  126. new InputViewModel("standardDesc",InputTypes.Textarea, "标准描述").SetNotRequired(),
  127. };
  128. //var specials = new List<SpecialInputModel>();
  129. }
  130. @Html.Partial("Modals/_ModalBody", new ModalBodyViewModel(inputs))
  131. @Html.Partial("Modals/_ModalFooter", "0")
  132. </div>
  133. </div>
  134. </div>
  135. </section>-->
  136. <!--<section>-->
  137. <!--Main Modal-->
  138. <!--<div class="modal fade" id="drawing_modal" role="dialog" tabindex="-1" aria-labelledby="ModalLabel" aria-hidden="true">
  139. <div class="modal-dialog modal-dialog-centered" role="document">
  140. <div class="modal-content">
  141. @Html.Partial("Modals/_ModalHeader", new ModalHeaderViewModel("规格图纸",operation:""))
  142. <div class="modal-body container-fluid" style="padding: 0; padding-top: 15px; min-height: 220px;">
  143. <form class="pr-3 pl-3 form-horizontal" style="padding: 0 10px" >
  144. <div class="drawing" >
  145. </div>
  146. </form>
  147. </div>
  148. <div class="modal-footer" style="text-align: center;">
  149. <button type="button" class="btn btn-default waves-effect" data-dismiss="modal" style="min-width:100px;background: #FFFFFF;border: 1px solid #DDDDDD;">取消</button>
  150. <button type="button" class="btn btn-success save-btn waves-effect" onclick="saveImg()" style="min-width:100px;background-color: #678ceb;border: 1px solid #678ceb;">下载</button>
  151. </div>
  152. </div>
  153. </div>
  154. </div>
  155. </section>-->
  156. <!--<section>-->
  157. <!--Main Modal-->
  158. <!--<div class="modal fade" id="detail_modal" role="dialog" tabindex="-1" aria-labelledby="ModalLabel" aria-hidden="true">
  159. <div class="modal-dialog modal-dialog-centered" role="document">
  160. <div class="modal-content" style="width: 720px;">
  161. @Html.Partial("Modals/_ModalHeader", new ModalHeaderViewModel("标准明细",operation:""))
  162. <div class="modal-body container-fluid" style="padding: 0; padding-top: 15px; min-height: 600px;">
  163. <form class="pr-3 pl-3 form-horizontal" style="padding: 0 10px" >
  164. <div >
  165. @Html.Partial("New/Table/_Table", tableDetail)
  166. </div>
  167. </form>
  168. </div>
  169. <div class="modal-footer" style="text-align: center;">
  170. <button type="button" class="btn btn-default waves-effect" data-dismiss="modal" style="min-width:100px;background: #FFFFFF;border: 1px solid #DDDDDD;">取消</button>
  171. </div>
  172. </div>
  173. </div>
  174. </div>
  175. </section>-->
  176. }
  177. @section scripts
  178. {
  179. <script type="text/javascript">
  180. var $table_height = $('body').height() - 180;
  181. var preHeight;
  182. $(function() {
  183. //show完毕前执行
  184. LoadTable(null,{
  185. onCheck: f_OnCheck,
  186. onUncheck: f_OnUncheck,
  187. onLoadSuccess: f_OnLoadSuccess
  188. });
  189. var funs = window.funs || { none: function() { console.log("No type"); } };
  190. funs["btnUpdate"] = function() { BtnUpdate({ readonly: "standardName" }); };
  191. //$("#Tool1").append(
  192. // ` <button type="button" class="btn btn-default" onclick="importData()">
  193. // 导入数据
  194. // </button>
  195. // `);
  196. $("#Tool1 button").hide();
  197. //initQueryTable();
  198. let changeHeight = function (bEle, aEle, mouseMoveAreaEle) {
  199. $("#table").bootstrapTable('resetView', { height: bEle.height() - 35 });
  200. preHeight = bEle.height() - 35;
  201. //$table.bootstrapTable('resetView', { height: bEle.height() - 35 });
  202. //$tableOrderItem.bootstrapTable('resetView', { height: aEle.height()-50 });
  203. }
  204. $("#table-box-table").SeparateBar({ move2Dom: "moreInfo", moveEvent: changeHeight });
  205. moreHide();
  206. });
  207. var checkStandardId;
  208. function moreHide() {
  209. // preHeight = $table_height;
  210. $("#table").bootstrapTable('resetView', { height: $table_height});
  211. $("#moreInfo").hide();
  212. $("#table-box-table").SeparateBar('isShow', false);
  213. }
  214. function moreShow(data) {
  215. abp.ajax({
  216. url: `/api/services/app/Standards/GetCatalog?id=${checkStandardId}`,
  217. async: true,
  218. type: "Post",
  219. contentType: 'application/json',
  220. isValidate: false,
  221. dataType: "json",
  222. success: function (res) {
  223. $(".catalogInfo").html(formatterMore(res,data));
  224. $("#table").bootstrapTable('resetView', { height: $table_height - 200 });
  225. $("#moreInfo").show();
  226. $("#table-box-table").SeparateBar('isShow', true);
  227. }
  228. });
  229. }
  230. function formatterMore(row,data) {
  231. /* <img style="width:100%;height:100%;" src="${queryFilePath('Certificate.EmployeeNo', row.employeeNo)}" />*/
  232. let img='';
  233. if (row.drawing) {
  234. let arrv = row.drawing.split('[>>]');
  235. arrv.forEach(function (value, i) {
  236. img += `<img style="width:480px;height:170px" src="${value}" />`;
  237. });
  238. }
  239. var info = ` <table>
  240. <tr>
  241. <td>简写:</td>
  242. <td class="infovalue">${row.standardAbbr}</td>
  243. <td rowspan="5" class="infoPic">${img}</td>
  244. </tr>
  245. <tr>
  246. <td>标准规格:</td>
  247. <td class="infovalue">${data.standardName}</td>
  248. </tr>
  249. <tr>
  250. <td>标准简称:</td>
  251. <td class="infovalue">${row.standardAbbrName}</td>
  252. </tr>
  253. <tr>
  254. <td>硬度:</td>
  255. <td>${row.rigidity ? row.rigidity : ""}</td>
  256. </tr>
  257. <tr>
  258. <td>参数:</td>
  259. <td>${ row.param ? row.param:""}</td>
  260. </tr>
  261. </table>`;
  262. return info;
  263. }
  264. // function initQueryTable() {
  265. //$tableDetail = LoadTable1(
  266. // {
  267. // table: $("#tableDetail"),
  268. // height: 560,
  269. // //isPage: false,
  270. // //modal: "modalItem",
  271. // //searchForm: "itemSearch",
  272. // searchValidate: false,
  273. // searchList: tmpSearch,
  274. // onlySearchList: true
  275. // });
  276. // }
  277. // function LoadTable1(option) {
  278. // if (!option) {
  279. // option = { table: "table" };
  280. // }
  281. // option.table = option.table ? option.table : "table";
  282. // var $table = typeof option.table === 'string' ? $('#' + option.table) : $(option.table);
  283. // if ($table.length < 1) {
  284. // console.log('没有发现表格:', option.table);
  285. // }
  286. // $table.iwbTable(option);
  287. // return $table;
  288. // }
  289. function importData() {
  290. abp.ajax({
  291. url: '/api/services/app/Standards/ImportData2',
  292. async: true,
  293. type: "Post",
  294. contentType: 'application/json',
  295. isValidate: false,
  296. dataType: "json",
  297. success: function(res) {
  298. RefreshTable();
  299. }
  300. });
  301. }
  302. function f_OnCheck(row, ele) {
  303. console.table(row)
  304. checkStandardId = row.standardId;
  305. moreShow(row);
  306. }
  307. function f_OnUncheck(row, ele) {
  308. moreHide();
  309. }
  310. function f_OnLoadSuccess(data, table) {
  311. var $table = config.table;
  312. if (table) {
  313. if (typeof (table) === "string") {
  314. $table = $("#" + table);
  315. } else {
  316. $table = $(table);
  317. }
  318. }
  319. $table.find(".bs-checkbox").find("input").addClass("filled-in").after("<label></label");
  320. $table.find("thead th.bs-checkbox").off("click.checkOnTable").on(
  321. "click.checkOnTable",
  322. function () {
  323. $(this).find("input").click();
  324. });
  325. _isSearching = false;
  326. abp.ui.clearBusy();
  327. setTimeout(function () {
  328. var alldata = $("#table").bootstrapTable('getData');
  329. if (alldata.length > 0) {
  330. $("#table").bootstrapTable('check', 0);
  331. } else {
  332. moreHide();
  333. }
  334. },
  335. 500);
  336. }
  337. </script>
  338. <script>
  339. var $tableDetail;
  340. var tmpSearch = [
  341. { KeyWords: "0", KeyField: "StandardId", FieldType: "1", ExpType: "0" }
  342. ];
  343. function InnerDiameterFormatter(v, r) {
  344. let v1 = r.innerDiameter1;
  345. let v2 = r.innerDiameter2;
  346. if (v1 && v2) {
  347. return v1 + '~' + v2;
  348. }
  349. if (v1) {
  350. return v1;
  351. }
  352. return '';
  353. }
  354. function OutDiameterFormatter(v, r) {
  355. let v1 = r.outDiameter1;
  356. let v2 = r.outDiameter2;
  357. if (v1 && v2) {
  358. return v1 + '~' + v2;
  359. }
  360. if (v1) {
  361. return v1;
  362. }
  363. return '';
  364. }
  365. function ThicknessFormatter(v, r) {
  366. let v1 = r.thickness1;
  367. let v2 = r.thickness2;
  368. if (v1 && v2) {
  369. return v1 + '~' + v2;
  370. }
  371. if (v1) {
  372. return v1;
  373. }
  374. return '';
  375. }
  376. function HeightFormatter(v, r) {
  377. let v1 = r.height1;
  378. let v2 = r.height2;
  379. if (v1 && v2) {
  380. return v1 + '~' + v2;
  381. }
  382. if (v1) {
  383. return v1;
  384. }
  385. return '';
  386. }
  387. function InnerChamferFormatter(v, r) {
  388. let v1 = r.innerChamfer1;
  389. let v2 = r.innerChamfer2;
  390. if (v1 && v2) {
  391. return v1 + '~' + v2;
  392. }
  393. if (v1) {
  394. return v1;
  395. }
  396. return '';
  397. }
  398. function OutChamferFormatter(v, r) {
  399. let v1 = r.outChamfer1;
  400. let v2 = r.outChamfer2;
  401. if (v1 && v2) {
  402. return v1 + '~' + v2;
  403. }
  404. if (v1) {
  405. return v1;
  406. }
  407. return '';
  408. }
  409. </script>
  410. <script>
  411. function DrawingFormatter(v, r) {
  412. let str = '';
  413. if (v) {
  414. let arrv = v.split('[>>]');
  415. arrv.forEach(function (value, i) {
  416. console.log(i)
  417. str += `<img width="80" height="30" src="${value}" onclick="f_showPic('${value}','${r.standardAbbrName}')" />`;
  418. });
  419. }
  420. return str;
  421. }
  422. let currCatalogName = '';
  423. function f_showPic(dataurl, sn) {
  424. currCatalogName = sn;
  425. $('#drawing_modal .drawing').empty();
  426. let w = $('#drawing_modal .drawing').width();
  427. let h = $('#drawing_modal .drawing').height();
  428. //$('#drawing_modal .drawing').append(`<img width="320px" height="120px" src="${dataurl}" />`);
  429. $('#drawing_modal .drawing').append(`<img style="width:480px;height:170px" src="${dataurl}" />`);
  430. $('#drawing_modal').modal("show", { keyboard: true });
  431. }
  432. // 保存按钮点击事件方法
  433. function saveImg() {
  434. var sampleImage = $('#drawing_modal .drawing img')[0]; // 找到图片所在的img标签
  435. var canvas = convertImageToCanvas(sampleImage); //创建画板
  436. var url = canvas.toDataURL("image/png"); //生成下载的url
  437. //var triggerDownload = $("#saveImg").attr("href", url).attr("download", "ewm.png"); // 把url放到我们的a标签中,并得到a标签对象
  438. // triggerDownload[0].click(); //模拟点击一下a标签,即可下载啦!
  439. let pngName = currCatalogName ? currCatalogName + ".png" : "ewm.png";
  440. $("body").append(`<a id="tempLink" href="${url}" download="${pngName}"></a>`);
  441. $("#tempLink")[0].click();
  442. $("#tempLink").remove();
  443. }
  444. /**
  445. * 根据图片生成画布
  446. */
  447. function convertImageToCanvas(image) {
  448. var canvas = document.createElement("canvas");
  449. canvas.width = image.width;
  450. canvas.height = image.height;
  451. canvas.getContext("2d").drawImage(image, 0, 0);
  452. return canvas;
  453. }
  454. function ActionFormatter(v, r) {
  455. let str = `<span class="table-action" onclick="f_showDetail(${r.id})"><i class="iconfont icon-right"></i>查看详情</span>`;
  456. return str;
  457. }
  458. function f_showDetail(id) {
  459. tmpSearch[0].KeyWords = id;
  460. $tableDetail.iwbTable('setSearchList', tmpSearch);
  461. $tableDetail.iwbTable('refresh');
  462. $("#detail_modal").modal('show');
  463. }
  464. </script>
  465. }