faillist.html 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  1. <style>
  2. #tablePager .layui-laypage {
  3. margin: 0;
  4. }
  5. #pageDicomFail .layui-table-body {
  6. overflow: hidden;
  7. }
  8. #pageDicomFail .layui-table-view .layui-btn-xs {
  9. padding: 0 8px;
  10. }
  11. #formDicomFailQuery {
  12. display: flex;
  13. }
  14. #formDicomFailQuery .layui-form-item {
  15. margin-bottom: 0;
  16. }
  17. </style>
  18. <div id="pageDicomFail">
  19. <div class="page-title" data-content="PageTitle4DicomFailList"></div>
  20. <div class="page-desc" data-content="PageDesc4DicomFailList"></div>
  21. <div id="formDicomFailQuery"
  22. class="layui-form"
  23. lay-filter="FormDicomFailQuery">
  24. <div class="layui-form-item" style="width: 280px">
  25. <select name="FailType" lay-filter="FailType">
  26. <option value="All" data-content="All"></option>
  27. <option value="UploadFail" data-content="UploadFailed"></option>
  28. <option value="ConvertFail" data-content="ConvertFailed"></option>
  29. <option value="Unknown" data-content="Unknown"></option>
  30. </select>
  31. </div>
  32. <div class="layui-form-item" style="margin-left: 5px">
  33. <button type="button"
  34. lay-submit
  35. lay-filter="Refresh"
  36. class="layui-btn layui-btn-normal">
  37. <i class="layui-icon layui-icon-refresh"></i>
  38. <span data-content="Refresh"></span>
  39. </button>
  40. </div>
  41. </div>
  42. <table id="tableFailList" lay-filter="FailList" lay-even=""></table>
  43. <div id="tablePager"></div>
  44. </div>
  45. <script type="text/html" id="barFailItem">
  46. <a class="layui-btn layui-btn-normal layui-btn-xs"
  47. lay-event="download"
  48. data-content="Download"></a>
  49. {{# if(d.Status === 2||d.Status === 3){ }}
  50. <a class="layui-btn layui-btn-normal layui-btn-xs"
  51. lay-event="reupload"
  52. data-content="Reupload"></a>
  53. {{# } }}
  54. {{# if(d.Status != 0){ }}
  55. <a class="layui-btn layui-btn-normal layui-btn-xs"
  56. lay-event="delete"
  57. data-content="Delete"></a>
  58. {{# } }}
  59. </script>
  60. <script>
  61. function Page(app, runtime) {
  62. const { $api, $t } = runtime;
  63. const { table, laypage, util, layer, form } = layui;
  64. const FailReasonMap = {
  65. ConvertFail: 1,
  66. CreateScanDataFail: 2,
  67. UploadFail: 3,
  68. Unknown: 4
  69. };
  70. let tableIns = null;
  71. const PageSize = 15;
  72. let failType = "";
  73. this.onload = function () {
  74. tableIns = renderTable();
  75. bindTableBarEvents();
  76. queryPagedList(1, PageSize);
  77. form.on("select(FailType)", function (data) {
  78. failType = data.value === "All" ? "" : data.value;
  79. queryPagedList(1, PageSize);
  80. });
  81. form.on("submit(Refresh)", function (data) {
  82. queryPagedList(1, PageSize);
  83. });
  84. };
  85. this.onLanguageChanged = function (lang) {
  86. tableIns = renderTable();
  87. fixTableBarTranslation();
  88. queryPagedList(1, PageSize);
  89. };
  90. function fixTableBarTranslation() {
  91. setTimeout(function () {
  92. runtime.locale.translatePage($("#tableFailList").parent());
  93. });
  94. }
  95. function renderPager(count, index) {
  96. laypage.render({
  97. elem: "tablePager",
  98. count: count,
  99. curr: index,
  100. limit: PageSize,
  101. limits: [10, 15, 20, 25],
  102. jump: function (obj, first) {
  103. !first && queryPagedList(obj.curr, obj.limit);
  104. }
  105. });
  106. }
  107. async function queryPagedList(index, size) {
  108. let request = {
  109. PageIndex: index,
  110. PageSize: size,
  111. FailType: failType
  112. };
  113. let res = await $api("dicom", "GetFailedList", request);
  114. if (res.IsSuccess) {
  115. let arr = res.Data.DataList;
  116. arr.forEach((x, i) => {
  117. if (x.Status === FailReasonMap.ConvertFail) {
  118. x.FailReason = $t("ConvertFailed");
  119. }
  120. else if (x.Status === FailReasonMap.UploadFail || x.Status === FailReasonMap.CreateScanDataFail) {
  121. x.FailReason = $t("UploadFailed");
  122. }
  123. else if (x.Status === FailReasonMap.Unknown) {
  124. x.FailReason = $t("Unknown");
  125. }
  126. x.CreateTime = util.toDateString(
  127. new Date(x.CreateTime),
  128. "yyyy/MM/dd HH:mm:ss"
  129. );
  130. });
  131. tableIns.reload({ data: arr }); //通过此方式重载表格
  132. let count = res.Data.TotalCount;
  133. if (count > 0) {
  134. $("#tablePager").show(function () {
  135. renderPager(count, index);
  136. });
  137. } else {
  138. $("#tablePager").hide();
  139. }
  140. fixTableBarTranslation();
  141. } else {
  142. layer.msg.error($t(res.Code));
  143. }
  144. }
  145. function renderTable() {
  146. return table.render({
  147. id: "tableFailList",
  148. elem: "#tableFailList",
  149. skin: "nob",
  150. page: false,
  151. limit: PageSize,
  152. cols: [
  153. [
  154. {
  155. field: "PatientId",
  156. title: $t("PatientId")
  157. // minWidth: 120
  158. },
  159. {
  160. field: "PatientName",
  161. title: $t("Name")
  162. // minWidth: 120
  163. },
  164. {
  165. field: "CreateTime",
  166. title: $t("CreateTime")
  167. // minWidth: 160
  168. },
  169. {
  170. field: "FailReason",
  171. title: $t("FailReason")
  172. // minWidth: 160
  173. },
  174. {
  175. field: "right",
  176. title: $t("Operation"),
  177. // minWidth: 120,
  178. toolbar: "#barFailItem"
  179. }
  180. ]
  181. ],
  182. data: [],
  183. text: {
  184. none: $t("NotAnyData")
  185. }
  186. });
  187. }
  188. function bindTableBarEvents() {
  189. table.on("tool(FailList)", async function (obj) {
  190. const { data, event, tr } = obj;
  191. if (event === "download") {
  192. window.utils.file.download("/download/dicom?id=" + data.Id);
  193. } else if (event === "reupload") {
  194. let res = await $api(
  195. "dicom",
  196. "ReuploadFailedRecord",
  197. {
  198. Id: data.Id
  199. }
  200. );
  201. if (res.IsSuccess) {
  202. tr.find("td[data-field=right]>div")
  203. .empty()
  204. .append(`<span>${$t("Retried")}</span>`);
  205. // layer.msg.success($t('Success'));
  206. } else {
  207. layer.msg.error($t(res.Code));
  208. }
  209. }
  210. else if (event === "delete") {
  211. let res = await $api(
  212. "dicom",
  213. "DeleteFailedRecord",
  214. {
  215. Id: data.Id
  216. }
  217. );
  218. if (res.IsSuccess) {
  219. tr.find("td[data-field=right]>div")
  220. .empty()
  221. .append(`<span>${$t("Deleted")}</span>`);
  222. // layer.msg.success($t('Success'));
  223. } else {
  224. layer.msg.error($t(res.Code));
  225. }
  226. }
  227. });
  228. }
  229. }
  230. </script>