faillist.html 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  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 && d.Status != 7){ }}
  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. Create: 0,
  66. ConvertFail: 1,
  67. CreateScanDataFail: 2,
  68. UploadFail: 3,
  69. UploadFailBecauseExamIsFinished: 4,
  70. Unknown: 5,
  71. Waiting: 6,
  72. Uploading: 7
  73. };
  74. let tableIns = null;
  75. const PageSize = 15;
  76. let failType = "";
  77. this.onload = function () {
  78. tableIns = renderTable();
  79. bindTableBarEvents();
  80. queryPagedList(1, PageSize);
  81. form.on("select(FailType)", function (data) {
  82. failType = data.value === "All" ? "" : data.value;
  83. queryPagedList(1, PageSize);
  84. });
  85. form.on("submit(Refresh)", function (data) {
  86. queryPagedList(1, PageSize);
  87. });
  88. };
  89. this.onLanguageChanged = function (lang) {
  90. tableIns = renderTable();
  91. fixTableBarTranslation();
  92. queryPagedList(1, PageSize);
  93. };
  94. function fixTableBarTranslation() {
  95. setTimeout(function () {
  96. runtime.locale.translatePage($("#tableFailList").parent());
  97. });
  98. }
  99. function renderPager(count, index) {
  100. laypage.render({
  101. elem: "tablePager",
  102. count: count,
  103. curr: index,
  104. limit: PageSize,
  105. limits: [10, 15, 20, 25],
  106. jump: function (obj, first) {
  107. !first && queryPagedList(obj.curr, obj.limit);
  108. }
  109. });
  110. }
  111. async function queryPagedList(index, size) {
  112. let request = {
  113. PageIndex: index,
  114. PageSize: size,
  115. FailType: failType
  116. };
  117. let res = await $api("dicom", "GetFailedList", request);
  118. if (res.IsSuccess) {
  119. let arr = res.Data.DataList;
  120. arr.forEach((x, i) => {
  121. if (x.Status === FailReasonMap.ConvertFail) {
  122. x.FailReason = $t("ConvertFailed");
  123. }
  124. else if (x.Status === FailReasonMap.UploadFail || x.Status === FailReasonMap.CreateScanDataFail) {
  125. x.FailReason = $t("UploadFailed");
  126. }
  127. else if (x.Status === FailReasonMap.UploadFailBecauseExamIsFinished) {
  128. x.FailReason = $t("UploadFailBecauseExamIsFinished");
  129. }
  130. else if (x.Status === FailReasonMap.Unknown) {
  131. x.FailReason = $t("Unknown");
  132. }
  133. else if (x.Status === FailReasonMap.Create) {
  134. x.FailReason = $t("Creating");
  135. }
  136. else if (x.Status === FailReasonMap.Waiting) {
  137. x.FailReason = $t("Waiting");
  138. }
  139. else if (x.Status === FailReasonMap.Uploading) {
  140. x.FailReason = $t("Uploading");
  141. }
  142. x.CreateTime = util.toDateString(
  143. new Date(x.CreateTime),
  144. "yyyy/MM/dd HH:mm:ss"
  145. );
  146. });
  147. tableIns.reload({ data: arr }); //通过此方式重载表格
  148. let count = res.Data.TotalCount;
  149. if (count > 0) {
  150. $("#tablePager").show(function () {
  151. renderPager(count, index);
  152. });
  153. } else {
  154. $("#tablePager").hide();
  155. }
  156. fixTableBarTranslation();
  157. } else {
  158. layer.msg.error($t(res.Code));
  159. }
  160. }
  161. function renderTable() {
  162. return table.render({
  163. id: "tableFailList",
  164. elem: "#tableFailList",
  165. skin: "nob",
  166. page: false,
  167. limit: PageSize,
  168. cols: [
  169. [
  170. {
  171. field: "PatientId",
  172. title: $t("PatientId")
  173. // minWidth: 120
  174. },
  175. {
  176. field: "PatientName",
  177. title: $t("Name")
  178. // minWidth: 120
  179. },
  180. {
  181. field: "CreateTime",
  182. title: $t("CreateTime")
  183. // minWidth: 160
  184. },
  185. {
  186. field: "FailReason",
  187. title: $t("Status")
  188. // minWidth: 160
  189. },
  190. {
  191. field: "right",
  192. title: $t("Operation"),
  193. // minWidth: 120,
  194. toolbar: "#barFailItem"
  195. }
  196. ]
  197. ],
  198. data: [],
  199. text: {
  200. none: $t("NotAnyData")
  201. }
  202. });
  203. }
  204. function bindTableBarEvents() {
  205. table.on("tool(FailList)", async function (obj) {
  206. const { data, event, tr } = obj;
  207. if (event === "download") {
  208. window.utils.file.download("/download/dicom?id=" + data.Id);
  209. } else if (event === "reupload") {
  210. let res = await $api(
  211. "dicom",
  212. "ReuploadFailedRecord",
  213. {
  214. Id: data.Id
  215. }
  216. );
  217. if (res.IsSuccess) {
  218. tr.find("td[data-field=right]>div")
  219. .empty()
  220. .append(`<span>${$t("Retried")}</span>`);
  221. // layer.msg.success($t('Success'));
  222. } else {
  223. layer.msg.error($t(res.Code));
  224. }
  225. }
  226. else if (event === "delete") {
  227. let res = await $api(
  228. "dicom",
  229. "DeleteFailedRecord",
  230. {
  231. Id: data.Id
  232. }
  233. );
  234. if (res.IsSuccess) {
  235. tr.find("td[data-field=right]>div")
  236. .empty()
  237. .append(`<span>${$t("Deleted")}</span>`);
  238. // layer.msg.success($t('Success'));
  239. } else {
  240. layer.msg.error($t(res.Code));
  241. }
  242. }
  243. });
  244. }
  245. }
  246. </script>