ManageScaleUserRecord.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385
  1. <template>
  2. <div class="main_right_height">
  3. <TopDes :flag="false" topDesFont="认知行为干预记录"></TopDes>
  4. <!-- <div>
  5. <el-row>
  6. <el-col :span="1">&nbsp;</el-col>
  7. <el-col :span="22">
  8. <div style="display: flex">
  9. <i
  10. class="el-icon-arrow-left"
  11. style="cursor: pointer; line-height: 1.5"
  12. @click="goBack()"
  13. ></i>
  14. <span class="musicTitle">量表测试记录</span>
  15. </div>
  16. <el-divider></el-divider>
  17. </el-col>
  18. <el-col :span="1">&nbsp;</el-col>
  19. </el-row>
  20. </div> -->
  21. <div>
  22. <el-row>
  23. <el-col :span="1">&nbsp;</el-col>
  24. <el-col :span="20" style="margin-top: 15px" >
  25. <div style="display: flex" class="xl_input">
  26. <el-date-picker
  27. v-model="value1"
  28. type="daterange"
  29. range-separator="至"
  30. start-placeholder="开始日期"
  31. end-placeholder="结束日期"
  32. @change="timeChange"
  33. >
  34. </el-date-picker>
  35. &nbsp;&nbsp;&nbsp;&nbsp;
  36. <el-input
  37. placeholder="请输入用户姓名"
  38. v-model="nameSearch"
  39. @input="searchEle"
  40. prefix-icon="el-icon-search"
  41. >
  42. <!-- <el-button
  43. slot="append"
  44. @click="searchEle"
  45. icon="el-icon-search"
  46. ></el-button> -->
  47. </el-input>
  48. </div>
  49. </el-col>
  50. <!-- <el-col :span="6">
  51. </el-col> -->
  52. <!-- <el-col :span="8">&nbsp;</el-col> -->
  53. </el-row>
  54. <el-row style="margin-top: 15px">
  55. <el-col :span="1">&nbsp;</el-col>
  56. <el-col :span="22" style="text-align: left">
  57. <el-button
  58. size="small"
  59. @click="download(1, 1)"
  60. class="xl_d_button"
  61. :disabled="multipleSelection.length === 0 && disableFlag"
  62. >
  63. 批量下载(原始数据)</el-button
  64. >
  65. <el-button
  66. size="small"
  67. :disabled="tableData.length === 0 && disableFlag"
  68. @click="download(1, 2)"
  69. class="xl_d_button"
  70. >
  71. 全部下载(原始数据)</el-button
  72. >
  73. <el-button
  74. size="small"
  75. @click="download(2, 1)"
  76. class="xl_d_button"
  77. :disabled="multipleSelection.length === 0 && disableFlag"
  78. >
  79. 批量下载</el-button
  80. >
  81. <el-button
  82. size="small"
  83. :disabled="tableData.length === 0 && disableFlag"
  84. class="xl_d_button"
  85. @click="download(2, 2)"
  86. >
  87. 全部下载</el-button
  88. >
  89. </el-col>
  90. <el-col :span="1">&nbsp;</el-col>
  91. </el-row>
  92. </div>
  93. <div style="margin-top: 16px;">
  94. <el-row>
  95. <el-col :span="1"> &nbsp;</el-col>
  96. <el-col :span="22">
  97. <el-table
  98. :data="tableData"
  99. style="width: 100%"
  100. @selection-change="handleSelectionChange"
  101. :header-cell-style="{
  102. background: '#66B497',
  103. color: '#FFFFFF',
  104. 'letter-spacing': '4px',
  105. }"
  106. :row-class-name="tableRowClassName"
  107. >
  108. <el-table-column type="selection" align="center" width="55">
  109. </el-table-column>
  110. <el-table-column prop="userName" align="center" label="姓名">
  111. </el-table-column>
  112. <el-table-column
  113. prop="testDate"
  114. align="center"
  115. label="测试时间"
  116. ></el-table-column>
  117. <!-- <el-table-column prop="profession" label="职业"></el-table-column> -->
  118. <el-table-column label="查看测试记录" align="center">
  119. <template slot-scope="scope">
  120. <el-button
  121. class="xl_d_button"
  122. size="mini"
  123. @click="handleEdit(scope.$index, scope.row)"
  124. >查看记录</el-button
  125. >
  126. </template>
  127. </el-table-column>
  128. </el-table>
  129. </el-col>
  130. <el-col :span="1"> &nbsp;</el-col>
  131. </el-row>
  132. </div>
  133. <p align="center" style="margin-bottom: 40px">
  134. <el-pagination
  135. @size-change="handleSizeChange"
  136. @current-change="handleCurrentChange"
  137. :current-page="pageNum"
  138. :page-size="pageSize"
  139. :page-sizes="[10, , 50, 100, 200, 300, 400]"
  140. layout="total, sizes, prev, pager, next, jumper"
  141. :total="totolSize"
  142. >
  143. </el-pagination>
  144. </p>
  145. </div>
  146. </template>
  147. <script>
  148. import axios from "axios";
  149. import jsFileDownload from "js-file-download";
  150. export default {
  151. data() {
  152. return {
  153. head_style: "#f5f7fa",
  154. value1: "",
  155. startDate: "",
  156. endDate: "",
  157. identifier: "",
  158. pageNum: 1,
  159. pageSize: 10,
  160. totolSize: 10,
  161. nameSearch: "",
  162. tableData: [],
  163. multipleSelection: [],
  164. flag: "",
  165. disableFlag: true,
  166. };
  167. },
  168. mounted() {
  169. this.flag = this.$route.query.flag;
  170. this.queryEle();
  171. },
  172. methods: {
  173. //返回上一页
  174. goBack() {
  175. this.$router.go(-1);
  176. },
  177. //批量下载
  178. download(val, value) {
  179. //获取数组集合
  180. let idArr = [];
  181. for (let i = 0; i < this.multipleSelection.length; i++) {
  182. idArr.push(this.multipleSelection[i].id);
  183. }
  184. this.batchDownloadOriginal(val, value, idArr);
  185. },
  186. //批量下载(原始数据)
  187. batchDownloadOriginal(val, value, idArr) {
  188. let that = this;
  189. let arr = [];
  190. //原始数据批量下载路径
  191. let path = `v1/record/download/source`;
  192. if (val === 2) {
  193. path = `v1/record/download`;
  194. }
  195. if ((val === 1 && value === 1) || (val === 2 && value === 1)) {
  196. arr = idArr;
  197. } else {
  198. arr = [];
  199. }
  200. // let path = `record/download`;
  201. let baseUrl = sessionStorage.getItem("baseUrl");
  202. //window.location.href = `${baseUrl}${path}?ids=${arr}`;
  203. axios({
  204. method: "post",
  205. url: `${baseUrl}${path}`,
  206. timeout: 600000, // 请求超时时间,数据量多后台响应慢的情况可以调大点,没生效的话可能是vue.config.js里的配置影响了
  207. responseType: "blob", // 返回类型为数据流
  208. data: {
  209. ids: arr,
  210. flag: that.flag,
  211. startDate: that.startDate,
  212. endDate: that.endDate,
  213. userName: that.nameSearch,
  214. }, // 需要传参的话,在这传
  215. }).then((res) => {
  216. if (res && res.data) {
  217. // console.log(decodeURIComponent(res.headers["filename"]))
  218. // 调用js-file-download下载文件,第一个参数是数据流,第二个参数是文件名,我这后端返回时把文件名放到响应的header的filename字段中,所以用这种方式取出
  219. jsFileDownload(res.data, decodeURIComponent(res.headers["filename"]));
  220. }
  221. });
  222. },
  223. handleSelectionChange(val) {
  224. this.multipleSelection = val;
  225. },
  226. timeChange(val) {
  227. if (val === null) {
  228. this.startDate = "";
  229. this.endDate = "";
  230. } else {
  231. this.startDate = this.fomatterDate(this.value1[0]);
  232. this.endDate = this.fomatterDate(this.value1[1]);
  233. }
  234. this.pageNum = 1;
  235. this.queryEle();
  236. },
  237. //格式化时间格式
  238. fomatterDate(val) {
  239. var date = new Date(val);
  240. let year = date.getFullYear();
  241. let month = this.fomatterM(date.getMonth() + 1);
  242. let currentDay = this.fomatterM(date.getDate());
  243. return year + "年" + month + "月" + currentDay + "日";
  244. },
  245. fomatterM(val) {
  246. if (val < 10) {
  247. return "0" + val;
  248. } else {
  249. return val + "";
  250. }
  251. },
  252. searchEle() {
  253. this.pageNum = 1;
  254. this.queryEle();
  255. },
  256. queryEle() {
  257. let that = this;
  258. that.$http.post(
  259. `v1/record/findByFlag`,
  260. {
  261. pageNum: that.pageNum,
  262. pageSize: that.pageSize,
  263. flag: that.flag,
  264. startDate: that.startDate,
  265. endDate: that.endDate,
  266. userName: that.nameSearch,
  267. },
  268. (res) => {
  269. if (res.data.code == 200) {
  270. that.tableData = res.data.data.data;
  271. that.totolSize = res.data.data.allNum;
  272. } else {
  273. this.$message.error("访问服务器失败!");
  274. }
  275. }
  276. );
  277. },
  278. handleSizeChange(val) {
  279. this.pageSize = val;
  280. this.queryEle();
  281. },
  282. handleCurrentChange(val) {
  283. this.pageNum = val;
  284. this.queryEle();
  285. // this.pageNum = val;
  286. // this.queryList();
  287. },
  288. handleEdit(index, row) {
  289. // this.$router.push({
  290. // path: "/menu/testResults",
  291. // query: { identifier: row.identifier },
  292. // });
  293. this.getAnswerQuestionPaymentSuccess(row.id);
  294. },
  295. getAnswerQuestionPaymentSuccess(id) {
  296. sessionStorage.setItem("back_page", "3");
  297. let _this = this;
  298. _this.$http.post(`v1/record/find/${id}`, {}, (res) => {
  299. if (res.data.code == 200 && res.data.data) {
  300. _this.resultJsonParams = res.data.data;
  301. // let sleep = JSON.parse(
  302. // _this.resultJsonParams.userRecordEntity.testResult
  303. // );
  304. // sleep = sleep[0].newTableContext.result[0].improvementSuggestions;
  305. // if (_this.scale_flag === "20210910163158") {
  306. // _this.askEnd(sleep);
  307. // this.inputFlag = 0;
  308. // }
  309. // if (_this.scale_flag === "20220805135201") {
  310. // _this.askEnd(sleep);
  311. // this.inputFlag = 0;
  312. // }
  313. // let testResult = JSON.parse(res.data.userRecordEntity.testResult)[0]
  314. // .version;
  315. let testResult = JSON.parse(
  316. res.data.data.userRecordEntity.testResult
  317. )[0].version;
  318. if (testResult == 2) {
  319. _this.$router.push({
  320. name: "scaleResultSCl",
  321. params: { tableData: _this.resultJsonParams },
  322. });
  323. } else {
  324. _this.$router.push({
  325. name: "scaleResult",
  326. params: { tableData: _this.resultJsonParams },
  327. });
  328. }
  329. }
  330. });
  331. // _this.$http.get(`/getRecordById?id=${id}`, {}, (res) => {
  332. // if (res.code == 200) {
  333. // _this.resultJsonParams = res.data;
  334. // let testResult = JSON.parse(res.data?.userRecordEntity?.testResult)[0]
  335. // .version;
  336. // if (testResult == 2) {
  337. // _this.$router.push({
  338. // name: "scaleResultSCl",
  339. // query: _this.resultJsonParams,
  340. // });
  341. // } else {
  342. // _this.$router.push({
  343. // name: "ScaleResult",
  344. // query: JSON.stringify(_this.resultJsonParams),
  345. // });
  346. // }
  347. // }
  348. // console.log("请求数据的list", res);
  349. // });
  350. },
  351. handleDelete(index, row) {},
  352. tableRowClassName({ rowIndex }) {
  353. if (rowIndex % 2 === 0) {
  354. return "warning-row";
  355. } else if (rowIndex % 2 === 1) {
  356. return "success-row";
  357. }
  358. return "success-row";
  359. }
  360. },
  361. };
  362. </script>
  363. <style scoped>
  364. .main_right_height {
  365. height: 100vh !important;
  366. display: block !important;
  367. overflow-y: auto !important;
  368. background: #ffffff;
  369. }
  370. .el-input-group {
  371. line-height: normal;
  372. display: inline-table;
  373. width: 200px !important;
  374. border-collapse: separate;
  375. border-spacing: 0;
  376. }
  377. </style>