ManagePluseRecord.vue 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324
  1. <template>
  2. <div class="main_right_height">
  3. <div>
  4. <el-row>
  5. <el-col :span="1">&nbsp;</el-col>
  6. <el-col :span="22">
  7. <div style="display: flex">
  8. <i
  9. class="el-icon-arrow-left"
  10. style="cursor: pointer; line-height: 1.5"
  11. @click="goBack()"
  12. ></i>
  13. <span class="musicTitle">脉搏测试记录</span>
  14. </div>
  15. <el-divider></el-divider>
  16. </el-col>
  17. <el-col :span="1">&nbsp;</el-col>
  18. </el-row>
  19. </div>
  20. <div>
  21. <el-row style="margin-top: 15px; margin-bottom: 15px">
  22. <el-col :span="1">&nbsp;</el-col>
  23. <el-col :span="16">
  24. <div style="display: flex">
  25. <el-date-picker
  26. v-model="value1"
  27. type="daterange"
  28. range-separator="至"
  29. start-placeholder="开始日期"
  30. end-placeholder="结束日期"
  31. @change="timeChange"
  32. >
  33. </el-date-picker>
  34. &nbsp;&nbsp;&nbsp;&nbsp;
  35. <!-- <el-input
  36. placeholder="请输入搜索内容"
  37. v-model="nameSearch"
  38. class="input-with"
  39. >
  40. <el-button
  41. slot="append"
  42. @click="searchEle"
  43. icon="el-icon-search"
  44. ></el-button>
  45. </el-input> -->
  46. </div>
  47. </el-col>
  48. <el-col :span="6" style="text-align: right; margin-top: 5px">
  49. <el-button
  50. size="small"
  51. @click="download(1, 1)"
  52. class="xl_d_button"
  53. :disabled="!(multipleSelection.length > 0 && disableFlag)"
  54. >
  55. 批量下载</el-button
  56. >
  57. <el-button
  58. size="small"
  59. :disabled="!(tableData.length > 0 && disableFlag)"
  60. @click="download(1, 2)"
  61. class="xl_d_button"
  62. >
  63. 全部下载</el-button
  64. >
  65. </el-col>
  66. <el-col :span="1">&nbsp;</el-col>
  67. </el-row>
  68. </div>
  69. <div>
  70. <el-row>
  71. <el-col :span="1"> &nbsp;</el-col>
  72. <el-col :span="22">
  73. <el-table
  74. :data="tableData"
  75. border
  76. :header-cell-style="{ background: head_style }"
  77. @selection-change="handleSelectionChange"
  78. style="width: 100%"
  79. >
  80. <el-table-column
  81. type="selection"
  82. align="center"
  83. width="55"
  84. ></el-table-column>
  85. <el-table-column
  86. align="center"
  87. prop="type"
  88. label="类型"
  89. :formatter="typeFormatter"
  90. >
  91. </el-table-column>
  92. <el-table-column
  93. prop="testDate"
  94. align="center "
  95. label="测试时间"
  96. ></el-table-column>
  97. <el-table-column label="操作" align="center">
  98. <template slot-scope="scope">
  99. <el-button
  100. class="xl_d_button"
  101. size="mini"
  102. @click="handleEdit(scope.$index, scope.row)"
  103. >查看测试记录</el-button
  104. >
  105. </template>
  106. </el-table-column>
  107. </el-table>
  108. </el-col>
  109. <el-col :span="1"> &nbsp;</el-col>
  110. </el-row>
  111. </div>
  112. <p align="center" style='margin-bottom:40px'>
  113. <el-pagination
  114. @size-change="handleSizeChange"
  115. @current-change="handleCurrentChange"
  116. :current-page="pageNum"
  117. :page-size="pageSize"
  118. layout="total, prev, pager, next, jumper"
  119. :total="totolSize"
  120. >
  121. </el-pagination>
  122. </p>
  123. </div>
  124. </template>
  125. <script>
  126. import axios from "axios";
  127. import jsFileDownload from "js-file-download";
  128. export default {
  129. data() {
  130. return {
  131. value1: "",
  132. startDate: "",
  133. endDate: "",
  134. head_style: "#f5f7fa",
  135. identifier: "",
  136. startDate: "",
  137. endDate: "",
  138. pageNum: 1,
  139. pageSize: 10,
  140. totolSize: 10,
  141. nameSearch: "",
  142. tableData: [],
  143. multipleSelection: [],
  144. disableFlag: true,
  145. };
  146. },
  147. mounted() {
  148. this.identifier = this.$route.query.identifier;
  149. this.queryEle();
  150. },
  151. methods: {
  152. searchEle() {
  153. this.pageNum = 1;
  154. this.queryEle();
  155. },
  156. queryEle() {
  157. let that = this;
  158. that.$http.post(
  159. `v1/recordPhy/find`,
  160. {
  161. pageNum: that.pageNum,
  162. pageSize: that.pageSize,
  163. startDate: that.startDate,
  164. endDate: that.endDate,
  165. type: 1,
  166. filaName: "",
  167. identifier: that.identifier,
  168. },
  169. (res) => {
  170. if (res.data.code == 200) {
  171. that.tableData = res.data.data.content;
  172. that.totolSize = res.data.data.totalElements;
  173. // this.$message.success("保存成功");
  174. } else {
  175. this.$message.error("访问服务器失败!");
  176. }
  177. }
  178. );
  179. },
  180. timeChange(val) {
  181. if (val === null) {
  182. this.startDate = "";
  183. this.endDate = "";
  184. } else {
  185. this.startDate = this.fomatterDate(this.value1[0]);
  186. this.endDate = this.fomatterDate(this.value1[1]);
  187. }
  188. this.pageNum=1;
  189. this.queryEle();
  190. },
  191. fomatterDate(val) {
  192. var date = new Date(val);
  193. let year = date.getFullYear();
  194. let month = this.fomatterM(date.getMonth() + 1);
  195. let currentDay = this.fomatterM(date.getDate());
  196. return year + "年" + month + "月" + currentDay + "日";
  197. },
  198. fomatterM(val) {
  199. // if (val < 10) {
  200. // return "0" + val;
  201. // } else {
  202. // return val + "";
  203. // }
  204. return val;
  205. },
  206. //批量下载
  207. download(val, value) {
  208. this.disableFlag = false;
  209. //获取数组集合
  210. let idArr = [];
  211. for (let i = 0; i < this.multipleSelection.length; i++) {
  212. idArr.push(this.multipleSelection[i].id);
  213. }
  214. this.batchDownloadOriginal(val, value, idArr);
  215. },
  216. //批量下载(原始数据)
  217. batchDownloadOriginal(val, value, idArr) {
  218. let that = this;
  219. let arr = [];
  220. //原始数据批量下载路径
  221. let path = `v1/record/download/source`;
  222. if (val === 2) {
  223. path = `v1/record/download`;
  224. }
  225. if ((val === 1 && value === 1) || (val === 2 && value === 1)) {
  226. arr = idArr;
  227. } else {
  228. arr = [];
  229. }
  230. // let path = `record/download`;
  231. let baseUrl = sessionStorage.getItem("baseUrl");
  232. // window.location.href = `${baseUrl}${path}?ids=${arr}&flag=1`;
  233. axios({
  234. method: "post",
  235. url: `${baseUrl}v1/recordPhy/download`,
  236. timeout: 600000, // 请求超时时间,数据量多后台响应慢的情况可以调大点,没生效的话可能是vue.config.js里的配置影响了
  237. responseType: "blob", // 返回类型为数据流
  238. data: {
  239. ids: arr,
  240. flag: 1,
  241. }, // 需要传参的话,在这传
  242. }).then((res) => {
  243. that.disableFlag = true;
  244. if (res && res.data) {
  245. // console.log(decodeURIComponent(res.headers["filename"]))
  246. // 调用js-file-download下载文件,第一个参数是数据流,第二个参数是文件名,我这后端返回时把文件名放到响应的header的filename字段中,所以用这种方式取出
  247. jsFileDownload(res.data, decodeURIComponent(res.headers["filename"]));
  248. }
  249. });
  250. },
  251. handleSelectionChange(val) {
  252. this.multipleSelection = val;
  253. },
  254. handleSizeChange(val) {
  255. this.queryEle();
  256. },
  257. handleCurrentChange(val) {
  258. this.pageNum = val;
  259. this.queryEle();
  260. // this.pageNum = val;
  261. // this.queryList();
  262. },
  263. handleEdit(index, row) {
  264. this.$router.push({
  265. path: "/menu/managePluseRecordDetail",
  266. query: { id: row.id },
  267. });
  268. },
  269. handleDelete(index, row) {},
  270. goBack() {
  271. this.$router.go(-1);
  272. },
  273. //格式化类型
  274. typeFormatter(val) {
  275. if (val.type === "3") {
  276. return "脑电";
  277. }
  278. if (val.type === "1") {
  279. return "脉搏";
  280. }
  281. return "";
  282. },
  283. //格式化时间格式
  284. // timeFormatter(val) {
  285. // var s = new Date(val.testDate).toLocaleString();
  286. // return s;
  287. // },
  288. },
  289. };
  290. </script>
  291. <style scoped>
  292. .main_right_height {
  293. height: 95vh !important;
  294. display: block !important;
  295. overflow-y: auto !important;
  296. }
  297. .xl_d_button,
  298. .xl_d_button:hover,
  299. .xl_d_button:focus {
  300. background: rgb(87, 172, 187);
  301. opacity: 1;
  302. /* border-radius: 18px; */
  303. /* font-size: 14px; */
  304. font-family: PingFang SC;
  305. font-weight: 400;
  306. color: #ffffff;
  307. }
  308. .input-with {
  309. width: 220px;
  310. }
  311. .xl_d_button.is-disabled,
  312. .xl_d_button.is-disabled:focus,
  313. .xl_d_button.is-disabled:hover {
  314. color: #c0c4cc;
  315. cursor: not-allowed;
  316. background-image: none;
  317. background-color: rgb(87, 172, 187);
  318. border-color: #ebeef5;
  319. }
  320. </style>