Report.cshtml 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686
  1. @using ShwasherSys
  2. @using ShwasherSys.Authorization.Permissions
  3. @using ShwasherSys.Models.Layout
  4. @using ShwasherSys.Models.Modal
  5. @{
  6. ViewBag.ActiveMenu = PermissionNames.PagesProductInspectInspectReport; //The menu item will be active for this page.
  7. ViewBag.Title = "检验报告确认";
  8. List<SelectListItem> inspectResult = new List<SelectListItem>()
  9. {
  10. new SelectListItem(){Text = @"合格",Value = "1"},
  11. new SelectListItem(){Text = @"不合格",Value = "0"},
  12. },confirmStatus= new List<SelectListItem>()
  13. {
  14. new SelectListItem(){Text = @"未确认",Value = InspectConfirmStateDefinition.New+""},
  15. new SelectListItem(){Text = @"已确认",Value = InspectConfirmStateDefinition.Confirm+""},
  16. }
  17. ;
  18. var searchForm = new SearchFormViewModal(new List<SearchItem>()
  19. {
  20. new SearchItem("productionOrderNo","排产单号"),
  21. new SearchItem("semiProductName","半成品名称"),
  22. new SearchItem("model","规格"),
  23. new SearchItem("material","材质"),
  24. new SearchItem("surfaceColor","表色"),
  25. new SearchItem("confirmDate","确认时间",FiledType.Dnull,ExpType.GreaterOrEqual),
  26. new SearchItem("confirmDate","至",FiledType.Dnull,ExpType.LessOrEqual),
  27. new SearchItem("semiProductNo","半成品编码"),
  28. new SearchItem("confirmStatus","确认状态",FiledType.I,ExpType.Equal).SetSearchItem(confirmStatus),
  29. new SearchItem("confirmUser","检验人员"),
  30. }, false);
  31. }
  32. @section CSS{
  33. @*<link href="~/Content/Plugins/bootstrap-datetimepicker/css/bootstrap-datetimepicker.min.css" rel="stylesheet" />
  34. <link href="~/Content/Plugins/bootstrap-datetimepicker/css/bootstrap-datetimepicker-wr.css" rel="stylesheet" />*@
  35. <link href="~/Content/Plugins/kindeditor/themes/default/default.css" rel="stylesheet" />
  36. <link href="~/Content/Plugins/PrintPreView/print-preview.css" rel="stylesheet" />
  37. <link href="~/Content/Css/report-table.css" rel="stylesheet" media="all" />
  38. <style>
  39. .inspect-box {
  40. display: block;
  41. }
  42. .attach {
  43. display: block;
  44. float: left;
  45. padding-right: 20px;
  46. }
  47. .attach img {
  48. width: 22px;
  49. height: 22px;
  50. margin-right: 5px;
  51. }
  52. .attach a {
  53. color: #666;
  54. font-weight: 400;
  55. line-height: 32px;
  56. padding: 0;
  57. }
  58. .attach a:hover {
  59. color: #583d9c;
  60. }
  61. .attach .delete {
  62. color: #aaa;
  63. font-weight: 600;
  64. margin-left: 5px;
  65. cursor: pointer;
  66. }
  67. .attach .delete:hover {
  68. color: red;
  69. }
  70. </style>
  71. <div id="exportCss">
  72. <style>
  73. #ReportTable table {
  74. border: 1px solid #000;
  75. }
  76. #ReportTable table .edit-input {
  77. padding: 3px 5px;
  78. border: 1px solid #3c3c3c;
  79. font-weight: 400;
  80. color: red;
  81. width: calc(100% - 10px)
  82. }
  83. #ReportTable table thead td img {
  84. width: 600px;
  85. }
  86. #ReportTable table tr td {
  87. padding: 5px 2px;
  88. font-size: 12px;
  89. font-weight: 500;
  90. text-align: center;
  91. border-left: 1px solid #000;
  92. border-top: 1px solid #000;
  93. background: #f5f5f5;
  94. word-wrap: break-word;
  95. word-break: break-all;
  96. }
  97. #ReportTable table tr:last-of-type td {
  98. border-bottom: 1px solid #000;
  99. height: 28px;
  100. }
  101. #ReportTable table tr td:last-of-type {
  102. border-right: 1px solid #000;
  103. }
  104. #ReportTable table td span {
  105. cursor: pointer;
  106. display: inline-block;
  107. min-width: 10px;
  108. min-height: 10px;
  109. }
  110. #ReportTable table .td-count {
  111. padding-right: 6px;
  112. }
  113. #ReportTable table .td-input {
  114. font-weight: 400;
  115. background: #fefefe;
  116. }
  117. </style>
  118. </div>
  119. }
  120. <section style="display: none">
  121. @Html.DropDownList("hide-inspectResult", inspectResult)
  122. @Html.DropDownList("hide-confirmStatus", confirmStatus)
  123. </section>
  124. <div class="table-box iwb-bootstrap-table">
  125. @Html.Action("ToolMenu", "Layout", new { pageName = ViewBag.ActiveMenu, searchForm })
  126. <table id="table"
  127. data-url="/api/services/app/ProductInspect/GetAllReport" data-id-field="id" data-unique-id="id"
  128. data-striped="true" data-click-to-select="true" data-single-select="true"
  129. data-method="post" data-side-pagination="server" data-content-type="application/x-www-form-urlencoded; charset=UTF-8"
  130. data-cache="false" data-pagination="true" data-page-size="30" data-page-number="1" data-page-list="[30,50,100,200]"
  131. data-pagination-h-align="left" data-pagination-detail-h-align="right"
  132. data-query-params="QueryParams" data-response-handler="ResponseHandler">
  133. <thead>
  134. <tr class="row" id="header">
  135. <th data-field="state" data-checkbox="true"></th>
  136. <th data-align="center" data-field="productInspectReportNo">报告编号</th>
  137. <th data-align="center" data-field="productionOrderNo">排产单号</th>
  138. <th data-align="center" data-field="semiProductNo">半成品编码</th>
  139. <th data-align="center" data-field="semiProductName">半成品名称</th>
  140. <th data-align="center" data-field="inspectCount">检验次数</th>
  141. <th data-align="center" data-field="confirmStatus" data-formatter="ConfirmStatusFormatter">确认状态</th>
  142. <th data-align="center" data-field="surfaceColor">表色</th>
  143. <th data-align="center" data-field="model">规格</th>
  144. <th data-align="center" data-field="material">材质</th>
  145. <th data-align="center" data-field="rigidity">硬度</th>
  146. <th data-align="center" data-field="partNo">零件号</th>
  147. <th data-align="center" data-field="confirmDate">确认时间</th>
  148. <th data-align="center" data-field="confirmUser">确认人员</th>
  149. </tr>
  150. </thead>
  151. </table>
  152. </div>
  153. @section modal{
  154. <!--Main Modal-->
  155. <section>
  156. <div class="modal fade" id="modal" role="dialog" tabindex="-1" aria-labelledby="ModalLabel" aria-hidden="true">
  157. <div class="modal-dialog modal-dialog-centered" role="document" style="width:1000px">
  158. <div class="modal-content">
  159. @Html.Partial("Modals/_ModalHeader", new ModalHeaderViewModel("检验报告", ""))
  160. <div class="modal-body container-fluid" style="padding-top: 15px;padding-bottom: 0;">
  161. <form class="pr-3 pl-3 form-horizontal " id="form">
  162. <div class="table-box inspect-box iwb-bootstrap-table">
  163. <table id="table1"
  164. data-url="/api/services/app/ProductInspect/GetAll" data-id-field="id" data-unique-id="id"
  165. data-striped="true" data-click-to-select="true" data-single-select="true"
  166. data-method="post" data-side-pagination="server" data-content-type="application/x-www-form-urlencoded; charset=UTF-8"
  167. data-cache="false" data-pagination="true" data-page-size="30" data-page-number="1" data-page-list="[30,50,100,200]"
  168. data-pagination-h-align="left" data-pagination-detail-h-align="right"
  169. data-query-params="QueryParams" data-response-handler="ResponseHandler">
  170. <thead>
  171. <tr class="row">
  172. <th data-field="state" data-checkbox="true"></th>
  173. <th data-align="center" data-field="productionOrderNo">排产单号</th>
  174. <th data-align="center" data-field="semiProductNo">半成品编码</th>
  175. <th data-align="center" data-field="semiProductName">半成品名称</th>
  176. <th data-align="center" data-field="inspectResult" data-formatter="InspectResultFormatter">检验结果</th>
  177. @*<th data-align="center" data-field="surfaceColor">表色</th>
  178. <th data-align="center" data-field="model">规格</th>
  179. <th data-align="center" data-field="material">材质</th>
  180. <th data-align="center" data-field="rigidity">硬度</th>
  181. <th data-align="center" data-field="partNo">零件号</th>*@
  182. <th data-align="center" data-field="inspectDate">检验时间</th>
  183. <th data-align="center" data-field="inspectMember">检验人员</th>
  184. </tr>
  185. </thead>
  186. </table>
  187. </div>
  188. <div class="row ">
  189. <div class="form-group-sm col-md-12">
  190. <label class="iwb-label col-md-1 control-label" for="inspectContent">附件列表:</label>
  191. <div class="col-md-11 attach-list">
  192. <div class="attach">暂无附件</div>
  193. </div>
  194. </div>
  195. </div>
  196. <div class="form-group-sm">
  197. <input id="id" name="id" type="hidden" value="">
  198. <input id="productInspectReportNo" name="productInspectReportNo" type="hidden" value="">
  199. <input id="reportContent" name="reportContent" type="hidden" value="">
  200. </div>
  201. <div class="inspect-box row">
  202. <div class="form-group-sm col-md-6">
  203. <label class="iwb-label col-md-2 control-label iwb-label-required" for="productionOrderNo">排产单号</label>
  204. <div class="col-md-10">
  205. <input class="form-control" id="productionOrderNo" name="productionOrderNo" required="" type="text" placeholder="" value="" style="">
  206. </div>
  207. </div>
  208. <div class="form-group-sm col-md-6">
  209. <label class="iwb-label col-md-2 control-label iwb-label-required" for="semiProductNo">半成品编码</label>
  210. <div class="col-md-10">
  211. <input class="form-control" id="semiProductNo" name="semiProductNo" required="" type="text" placeholder="" value="" style="">
  212. </div>
  213. </div>
  214. <div class="form-group-sm col-md-12">
  215. <label class="iwb-label col-md-1 control-label" for="inspectContent">最终检验详情</label>
  216. <div class="col-md-11">
  217. <textarea class="form-control" id="inspectContent" name="inspectContent" type="text" placeholder="请输入检验详情..." value="" style="" disabled=""></textarea>
  218. </div>
  219. </div>
  220. @*<div class="form-group-sm col-md-6">
  221. <label class="iwb-label col-md-2 control-label iwb-label-required" for="inspectResult">检验结果</label>
  222. <div class="col-md-10">
  223. @Html.DropDownList("inspectResult", inspectResult, new {style = "width:100%", required = ""})
  224. </div>
  225. </div>
  226. <div class="form-group-sm col-md-6">
  227. <label class="iwb-label col-md-2 control-label iwb-label-required" for="inspectDate">检验时间</label>
  228. <div class="col-md-10">
  229. <input class="form-control datetime" id="inspectDate" name="inspectDate" required="" type="text" placeholder="请输入检验时间..." value="" style="" disabled="">
  230. </div>
  231. </div>
  232. <div class="form-group-sm col-md-6">
  233. <label class="iwb-label col-md-2 control-label iwb-label-required" for="inspectMember">检验人员</label>
  234. <div class="col-md-10">
  235. <input class="form-control" id="inspectMember" name="inspectMember" required="" type="text" placeholder="请输入检验人员..." value="" style="" disabled="">
  236. </div>
  237. </div>*@
  238. <div class="form-group-sm col-md-12">
  239. <div class=" col-md-2" style="float: right;">
  240. <button type="button" class="btn btn-sm btn-danger" style="width: 100%; background-color: #583d9c; border-color: #583d9c;" onclick="AddAttach()">添加附件</button>
  241. </div>
  242. </div>
  243. <div class="attach-unit"></div>
  244. </div>
  245. <div class="form-group-sm" id="reportContentArea">
  246. <div class="col-md-12 report-content" id="ReportTable"></div>
  247. </div>
  248. </form>
  249. </div>
  250. @Html.Partial("Modals/_ModalFooter", "0")
  251. </div>
  252. </div>
  253. </div>
  254. </section>
  255. }
  256. @section scripts
  257. {
  258. @*<script src="~/Content/Plugins/bootstrap-datetimepicker/js/bootstrap-datetimepicker.min.js"></script>
  259. <script src="~/Content/Plugins/bootstrap-datetimepicker/js/locales/bootstrap-datetimepicker.zh-CN.js"></script>*@
  260. <script src="~/Content/Plugins/PrintPreView/print-preView.js"></script>
  261. <script src="~/Content/Scripts/MyScript/ExportExcel.js"></script>
  262. <script type="text/javascript">
  263. var $table1=$('#table1');
  264. $(function () {
  265. var datePickerOpt = {
  266. language: 'zh-CN',
  267. format: "yyyy-mm-dd",
  268. todayBtn: true,
  269. autoclose: true,
  270. startView: 2,
  271. minView: 2,
  272. maxView: 4,
  273. showSecond: false,
  274. showHours: false,
  275. minuteStep: 10
  276. };
  277. //$("#KeyWords-6").datetimepicker(datePickerOpt);
  278. //$("#KeyWords-7").datetimepicker(datePickerOpt);
  279. //$(".datetime").datetimepicker(datePickerOpt).on('show',
  280. // function (event) {
  281. // event.preventDefault();
  282. // event.stopPropagation();
  283. // }).on('hide',
  284. // function (event) {
  285. // event.preventDefault();
  286. // event.stopPropagation();
  287. // });
  288. LoadTable();
  289. var funs = window.funs || { none: function () { console.log("No type"); } };
  290. $("#modal .save-btn")
  291. .after(
  292. "<button type=\"button\" id=\"printReport\" class=\"btn btn-info waves-effect\" style=\"min-width:100px;border:1px solid #DDDDDD;\">打印</button><button type=\"button\" id=\"exportReport\" class=\"btn btn-info waves-effect\" style=\"min-width:100px;border:1px solid #DDDDDD;\">导出</button>");
  293. funs["btnConfirmReport"] = function (url) {
  294. var rows = config.table.bootstrapTable("getSelections");
  295. if (rows.length === 1) {
  296. GetOldReport(rows[0].productionOrderNo);
  297. $(".inspect-box").css("display", "block");
  298. //$(".attach-list").css("display", "block");
  299. $("#modal .save-btn").css("display", "inline-block");
  300. $(".attach-unit").html('');
  301. $table1.bootstrapTable('destroy');
  302. LoadTable({
  303. table: $table1,
  304. queryParams: function(params) {
  305. var sorting = '';
  306. if (params.sort) {
  307. sorting = params.sort;
  308. if (params.order) {
  309. sorting += ' ' + params.order;
  310. }
  311. }
  312. return {
  313. //limit: params.limit, //页面大小
  314. //page: (params.offset / params.limit) + 1, //页码
  315. MaxResultCount: params.limit,
  316. SkipCount: params.offset,
  317. Sorting: sorting, //排序列名
  318. sortOrder: params.order, //排位命令(desc,asc)
  319. SearchList: [
  320. {
  321. KeyWords: rows[0].productionOrderNo,
  322. KeyField: "ProductionOrderNo",
  323. FieldType: "0",
  324. ExpType: "0"
  325. }
  326. ]
  327. };
  328. },
  329. //onLoadSuccess: ICheckTableInit_SingleSelect
  330. onLoadSuccess: function (data) {
  331. $('#inspectContent').val(data.rows[0].inspectContent);
  332. OnLoadSuccess(data, $table1);
  333. },
  334. onPostBody: function(data) {
  335. OnPostBody(data, $table1);
  336. }
  337. });
  338. QueryAttach(rows[0].productionOrderNo);
  339. BtnUpdate({
  340. data: rows[0],
  341. disabled: "productionOrderNo,semiProductNo",
  342. save: function() {
  343. if (rows[0].confirmStatus === @(InspectConfirmStateDefinition.Confirm)) {
  344. abp.message.warn("检测报告已确认,请勿重复操作!");
  345. return;
  346. }
  347. SaveReport(url);
  348. }
  349. });
  350. //QueryAttach(rows[0].productInspectNo, true);
  351. $("#printReport").hide();
  352. $("#exportReport").hide();
  353. } else {
  354. abp.message.warn(abp.localization.localize("ChooseOneToOp"));
  355. }
  356. };
  357. funs["btnQueryReport"] = function () {
  358. console.log("QueryReport");
  359. var rows = config.table.bootstrapTable("getSelections");
  360. if (rows.length === 1) {
  361. GetOldReport(rows[0].productionOrderNo, true);
  362. $(".inspect-box").css("display", "none");
  363. $(".attach-list").css("display", "block");
  364. $("#modal .save-btn").css("display", "none");
  365. $table1.bootstrapTable('destroy');
  366. QueryAttach(rows[0].productionOrderNo);
  367. $("#printReport").show();
  368. $("#exportReport").show();
  369. ShowModal("modal");
  370. } else {
  371. abp.message.warn(abp.localization.localize("ChooseOneToOp"));
  372. }
  373. };
  374. $("#printReport").printPreview({
  375. printBody: "#reportContentArea",
  376. modalWidth: 1080
  377. });
  378. $("#exportReport").on('click',
  379. function(e) {
  380. var urlPath = window.document.location.href; //浏览器显示地址 http://10.15.5.83:5555/ISV/demo.aspx?a=1&b=2
  381. var docPath = window.document.location.pathname; //文件在服务器相对地址 /ISV/demo.aspx
  382. var index = urlPath.indexOf(docPath);
  383. var serverPath = urlPath.substring(0, index); //服务器地址 http://10.15.5.83:5555
  384. var imgTr = $("#reportContentArea").find('table thead tr:first').clone();
  385. var img = $("#reportContentArea").find('table thead tr:first img')
  386. .attr("src", serverPath + "/Content/Images/excle/report2.png");
  387. $("#reportContentArea").find('table thead tr:first td')
  388. .css({ "height": "130px", "text-align": "center" });
  389. ExportExcel('reportContentArea', '检查报告', 'exportCss');
  390. $("#reportContentArea").find('table thead tr:first').remove();
  391. $("#reportContentArea").find('table thead').prepend(imgTr);
  392. });
  393. $("#Tool1").append(
  394. '<div class="tool-radio"><input name="proType" type="radio" id="allProduction" checked value=""/><label for="allProduction">全部</label></div>' +
  395. '<div class="tool-radio"><input name="proType" type="radio" id="outPurchase" value="1"/><label for="outPurchase">外购</label></div>' +
  396. '<div class="tool-radio"><input name="proType" type="radio" id="machineShop" value="0"/><label for="machineShop">车间加工</label></div>' +
  397. '<div class="tool-radio"><input name="proType" type="radio" id="outProduct" value="2"/><label for="outProduct">外协</label></div>');
  398. $(".tool-radio input[type='radio']").on('click',function(e) {
  399. //var outType = $(this).val();
  400. document.getElementById("SearchForm").reset();
  401. GetSearchList();
  402. RefreshTable();
  403. });
  404. });
  405. function GetSearchList() {
  406. var count = $("#SearchForm").find(".KeyWords").length;
  407. window._searchList = [];
  408. var outType = $('input[name="proType"]:checked').val();
  409. switch (outType) {
  410. case "1":
  411. case "0":
  412. window._searchList.push({
  413. KeyWords: outType,
  414. KeyField: "ProductionType",
  415. FieldType: "0",
  416. ExpType: "0"
  417. });
  418. break;
  419. case "2":
  420. window._searchList.push({
  421. KeyWords: "2",
  422. KeyField: "ProcessingLevel",
  423. FieldType: "0",
  424. ExpType: "0"
  425. });
  426. break;
  427. default:
  428. break;
  429. }
  430. for (var i = 1; i <= count; i++) {
  431. var keyWords = $("#KeyWords-" + i).val();
  432. if (keyWords) {
  433. var keyField = $("#KeyField-" + i).val();
  434. var fieldType = $("#FieldType-" + i).val();
  435. var expType = $("#ExpType-" + i).val();
  436. _searchList.push({
  437. KeyWords: keyWords,
  438. KeyField: keyField,
  439. FieldType: fieldType,
  440. ExpType: expType
  441. });
  442. }
  443. }
  444. }
  445. </script>
  446. <script>
  447. function AddAttach() {
  448. var id = Math.floor(Math.random() * 9999);
  449. $(".attach-unit").append(
  450. '<div class="form-group-sm"><div class="col-md-6"><label class="iwb-label col-md-2 control-label iwb-label-required" for="">附件名称</label><div class="col-md-10"><input class="form-control" name="fileTitle" required="" placeholder="请输入附件名称" type="text"></div> </div><div class="col-md-6"><div class="col-md-10"><input class="form-control" name="fileInfo" id="fileInfo-' +
  451. id +
  452. '" type="hidden"><input class="form-control" name="fileName" id="fileName-' +
  453. id +
  454. '" type="hidden"><input class="form-control" name="fileExt" id="fileExt-' +
  455. id +
  456. '" type="hidden"><div class="custom-file "><input class="custom-file-input" id="customFile-' +
  457. id +
  458. '" type="file" onchange="FileCheck(this,' +
  459. id +
  460. ')" onclick="OpenUploadWindow()"><label class="custom-file-label" for="customFile-' +
  461. id +
  462. '">选择文件</label></div></div><div class="col-md-2" style="float: right;padding-left: 0;"><button type="button" class="btn btn-sm btn-danger" style="width: 100%;" onclick="RemoveAttach(this)">移除</button></div></div></div>');
  463. var topHeight = $(window).height() - $("#modal").find('.modal-dialog').height() - 50;
  464. if (topHeight < 30) {
  465. topHeight = 30;
  466. }
  467. $("#modal").find('.modal-dialog').animate({ 'marginTop': topHeight / 2 + "px" });
  468. }
  469. function RemoveAttach(that) {
  470. $(that).closest(".form-group-sm").remove();
  471. }
  472. function GetAttachFilesDate() {
  473. var data = {
  474. id: $("#modal #id").val(),
  475. productInspectReportNo: $("#modal #productInspectReportNo").val(),
  476. reportContent: $("#modal #reportContent").val(),
  477. productionOrderNo: $("#modal #productionOrderNo").val(),
  478. inspectContent: $("#modal #inspectContent").val(),
  479. attachFiles: []
  480. };
  481. $(".attach-unit .form-group-sm").each(function (i, v) {
  482. var fileTitle = $(v).find("input[name='fileTitle']").val();
  483. var fileInfo = $(v).find("input[name='fileInfo']").val();
  484. var fileName = $(v).find("input[name='fileName']").val();
  485. var fileExt = $(v).find("input[name='fileExt']").val();
  486. data.attachFiles.push(
  487. { fileTitle: fileTitle, fileInfo: fileInfo, fileName: fileName, fileExt: fileExt });
  488. });
  489. return data;
  490. }
  491. function FileCheck(that, id) {
  492. FileInputCheck(that,
  493. 'fileInfo-' + id,
  494. false,
  495. 100,
  496. function (fileName) {
  497. var name = fileName.substring(0, fileName.lastIndexOf("."));
  498. var ext = fileName.substring(fileName.lastIndexOf(".") + 1, fileName.length);
  499. $("#fileName-" + id).val(name);
  500. $("#fileExt-" + id).val(ext);
  501. });
  502. }
  503. </script>
  504. <script>
  505. function QueryAttach(no, hasDelete) {
  506. SaveAjax({
  507. url: window.appUrl + 'ProductInspect/QueryAttach',
  508. data: { TableName: 'Product', ColName: 'Inspect', Key: no },
  509. isValidate: false,
  510. isAlert: false,
  511. success: function (res) {
  512. FormatterAttach(res, hasDelete);
  513. }
  514. });
  515. }
  516. function FormatterAttach(data, hasDelete) {
  517. var str = '';
  518. if (data) {
  519. for (var i = 0; i < data.length; i++) {
  520. var item = data[i];
  521. var fileType = item.fileExt;
  522. var img = 'attach';
  523. if (fileType.indexOf('doc') >= 0)
  524. img = 'word';
  525. else if (fileType.indexOf('xls') >= 0) {
  526. img = 'excel';
  527. } else if (fileType.indexOf('zip') >= 0 || fileType.indexOf('rar') >= 0) {
  528. img = 'zip';
  529. }
  530. str += ' <div class="attach"><a href="' + item.filePath + '" title="下载查看" target="_blank"><img src="/Content/Images/attach/' + img + '.png" />' + item.fileTitle + '.' +
  531. item.fileExt + '</a>';
  532. if (hasDelete) {
  533. str += '<span class="iconfont icon-delete1 delete" title="删除附件" onclick="DeleteAttach(this,\'' +
  534. item.attachNo +
  535. '\')"></span>';
  536. }
  537. str += '</div>';
  538. }
  539. }
  540. str = str ? str : '<div class="attach">暂无附件</div>';
  541. if (hasDelete) {
  542. $('.attach-box').html(str);
  543. } else {
  544. $('.attach-list').html(str);
  545. }
  546. };
  547. function DeleteAttach(that, attachNo) {
  548. abp.message.confirm("附件删除后不可恢复,确认删除附件?", "删除附件", function () {
  549. SaveAjax({
  550. url: window.appUrl + 'ProductInspect/DeleteAttach?attachNo=' + attachNo,
  551. data: { attachNo: attachNo },
  552. isValidate: false,
  553. success: function () {
  554. $(that).closest('.attach').remove();
  555. }
  556. });
  557. });
  558. }
  559. </script>
  560. <script>
  561. function SaveReport(url, isTemplate) {
  562. $("#reportContent").val($(".report-content").html());
  563. var data = isTemplate ? { ReportTemplate: $("#reportContent").val() } : GetAttachFilesDate();
  564. isTemplate = !isTemplate;
  565. SaveAjax({
  566. url: url,
  567. data: data,
  568. isValidate: isTemplate,
  569. success: function () {
  570. $("#modal").modal('hide');
  571. RefreshTable();
  572. }
  573. });
  574. }
  575. function GetOldReport(productNo, isQuery) {
  576. SaveAjax({
  577. url: window.appUrl + 'ProductInspect/QueryReport?no=' + productNo + '&isProduct=1',
  578. data: {
  579. no: productNo,
  580. isProduct: 1
  581. },
  582. isValidate: false,
  583. isAlert: false,
  584. success: function (res) {
  585. if (res) {
  586. $("#reportContent").val(res);
  587. $(".report-content").html(res);
  588. if (!isQuery) {
  589. $(".report-content td.td-input").off('click.report').on('click.report',
  590. function tdClick() {
  591. var $that = $(this);
  592. $that.off('click.report');
  593. var text = $(this).text();
  594. var $input = $('<input type="text"/ class="edit-input"/> ');
  595. $that.text('');
  596. $that.append($input);
  597. $input.focus().val(text);
  598. $input.on('blur',
  599. function (e) {
  600. e.preventDefault();
  601. e.stopPropagation();
  602. $(this).parent('td.td-input').text($(this).val());
  603. $(this).remove();
  604. $that.on('click.report', tdClick);
  605. });
  606. });
  607. }
  608. }
  609. }
  610. });
  611. }
  612. </script>
  613. <script id="">
  614. function InspectResultFormatter(v) {
  615. var name = $("#hide-inspectResult option[value='" + v + "']").text();
  616. if (v === 0) {
  617. return '<span class="label label-danger">' + name + '</span>';
  618. } else {
  619. return '<span class="label label-success">' + name + '</span>';
  620. }
  621. }
  622. function ConfirmStatusFormatter(v) {
  623. var name = $("#hide-confirmStatus option[value='" + v + "']").text();
  624. if (v === 1) {
  625. return '<span class="label label-danger">' + name + '</span>';
  626. } else {
  627. return '<span class="label label-success">' + name + '</span>';
  628. }
  629. }
  630. </script>
  631. }