StaticKnowledgeMapTest.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  1. <template>
  2. <div>
  3. <crumbs title="静态知识映射测试" class="topBack">
  4. <el-form :inline="true" class="demo-form-inline">
  5. <el-form-item
  6. label=""
  7. class="selectMedicine"
  8. style="marginbottom: -1px"
  9. >
  10. <el-select
  11. size="mini"
  12. v-model="hospitalId"
  13. placeholder="选择医院"
  14. @change="handleChange"
  15. >
  16. <el-option
  17. v-for="item in hospitalData"
  18. :label="item.name"
  19. :value="item.id"
  20. :key="item.id"
  21. ></el-option>
  22. </el-select>
  23. </el-form-item>
  24. </el-form>
  25. </crumbs>
  26. <div style="margin: 60px 20px 0">
  27. <el-table :data="list" border>
  28. <el-table-column
  29. :resizable="false"
  30. type="index"
  31. :index="indexMethod"
  32. label="编号"
  33. width="80"
  34. ></el-table-column>
  35. <el-table-column
  36. :resizable="false"
  37. prop="caseName"
  38. label="术语类型"
  39. show-overflow-tooltip
  40. ></el-table-column>
  41. <el-table-column
  42. :resizable="false"
  43. prop="gmtModified"
  44. label="测试时间"
  45. ></el-table-column>
  46. <el-table-column
  47. :resizable="false"
  48. prop="totleNum"
  49. label="医院术语总条数"
  50. show-overflow-tooltip
  51. ></el-table-column>
  52. <el-table-column label="未映射到标准术语条数">
  53. <template slot-scope="scope">
  54. <el-button
  55. type="text"
  56. size="small"
  57. @click="goToInnerPage(scope.row, 'noMap')"
  58. :disabled="runningStatusArr[scope.$index] === 1"
  59. >{{ scope.row.unMappingNum }}</el-button
  60. >
  61. </template>
  62. </el-table-column>
  63. <el-table-column label="缺少静态知识术语条数">
  64. <template slot-scope="scope">
  65. <el-button
  66. type="text"
  67. size="small"
  68. @click="goToInnerPage(scope.row, 'lessStatic')"
  69. :disabled="runningStatusArr[scope.$index] === 1"
  70. >{{ scope.row.withoutKnowledgeNum }}</el-button
  71. >
  72. </template>
  73. </el-table-column>
  74. <el-table-column label="操作">
  75. <template slot-scope="scope">
  76. <input
  77. type="file"
  78. name="uploadfile "
  79. id="upFile"
  80. @change="uploadFile($event)"
  81. />
  82. <el-button
  83. type="text"
  84. size="small"
  85. :disabled="!runningStatus"
  86. @click="handleTest(scope.row, scope.$index)"
  87. >{{
  88. runningStatusArr[scope.$index] === 1
  89. ? '执行测试中...'
  90. : '执行测试'
  91. }}</el-button
  92. >
  93. </template>
  94. </el-table-column>
  95. </el-table>
  96. </div>
  97. </div>
  98. </template>
  99. <script>
  100. import api from '@api/cdss.js';
  101. import config from '@api/config.js';
  102. import utils from '@api/utils.js';
  103. export default {
  104. name: 'KnowledgeMapRuleTest',
  105. data() {
  106. return {
  107. list: [],
  108. hospitalData: [],
  109. hospitalId: '', //选中医院
  110. type: '',
  111. caseId: '',
  112. runningStatusArr: [0, 0, 0, 0, 0],
  113. statusIndex: '',
  114. };
  115. },
  116. computed: {
  117. runningStatus() {
  118. return this.runningStatusArr.every((item) => {
  119. return item === 0;
  120. });
  121. },
  122. },
  123. created() {
  124. this._getHospitalInfoCDSS();
  125. this.timer = setInterval(this._getRunningStatus, 20 * 1000);
  126. },
  127. beforeDestroy() {
  128. clearInterval(this.timer);
  129. },
  130. beforeRouteEnter(to, from, next) {
  131. next((vm) => {
  132. Object.assign(vm, to.params);
  133. if (Object.keys(to.params).length === 0) return;
  134. vm.getDataList(to.params.hospitalId);
  135. vm._getRunningStatus();
  136. });
  137. },
  138. methods: {
  139. _getRunningStatus() {
  140. const { hospitalId } = this;
  141. if (this.hospitalId === '') return;
  142. api.getRunningStatusByHospitalId({ hospitalId }).then((res) => {
  143. if (res.data.code === '0' && res.data.data) {
  144. this.runningStatusArr = Object.values(res.data.data).slice(9, 14);
  145. }
  146. });
  147. },
  148. indexMethod(index) {
  149. return index + 1;
  150. },
  151. // 获取医院信息
  152. _getHospitalInfoCDSS() {
  153. api.getHospitalInfo().then((res) => {
  154. if (res.data.code === '0') {
  155. this.hospitalData = res.data && res.data.data;
  156. }
  157. });
  158. },
  159. handleType(caseName) {
  160. switch (caseName) {
  161. case '诊断':
  162. return 1;
  163. case '检验':
  164. return 2;
  165. case '检查':
  166. return 3;
  167. case '药品':
  168. return 4;
  169. case '手术/操作':
  170. return 5;
  171. default:
  172. return null;
  173. }
  174. },
  175. // 执行测试
  176. handleTest(row, index) {
  177. let inp = document.getElementById('upFile');
  178. inp.click();
  179. const { caseName, caseId } = row;
  180. this.type = this.handleType(caseName); //术语类型(1:诊断、2:检验、3:检查、4:药品、5:手术/操作)
  181. this.caseId = caseId; //测试用例id
  182. this.statusIndex = index;
  183. },
  184. // 导入数据
  185. uploadFile(e) {
  186. if (this.statusIndex !== '') {
  187. this.runningStatusArr = this.runningStatusArr.map((item, idx) => {
  188. if (idx === this.statusIndex) {
  189. return 1;
  190. } else {
  191. return 0;
  192. }
  193. });
  194. }
  195. let fileInfo = e.target.files[0];
  196. e.preventDefault();
  197. let formData = new FormData();
  198. formData.append('file', fileInfo);
  199. formData.append('hospitalId', this.hospitalId);
  200. formData.append('type', this.type);
  201. formData.append('caseId', this.caseId);
  202. const header = {
  203. headers: {
  204. 'Content-Type': 'multipart/form-data',
  205. },
  206. };
  207. api.staticKnowledgeTest(formData, header).then((res) => {
  208. if (res.data.code === '00000001') {
  209. this.$message.error(res.data.msg || '数据存在异常');
  210. this.getDataList(this.hospitalId); // 重新获取列表
  211. } else if (res.data.code === '0' && res.data.data) {
  212. this.$message({
  213. message: '测试成功',
  214. type: 'success',
  215. });
  216. this.getDataList(this.hospitalId); // 重新获取列表
  217. } else {
  218. this.$message.error(res.data.msg || '数据存在异常');
  219. this.getDataList(this.hospitalId);
  220. }
  221. this.runningStatusArr = [0, 0, 0, 0, 0];
  222. });
  223. //解决上传相同文件不触发change
  224. let inp = document.getElementById('upFile');
  225. inp.value = '';
  226. },
  227. // 跳转至未映射到标准术语条数页面 / 缺少静态知识术语条数
  228. goToInnerPage(row, type) {
  229. let hospital = this.hospitalData.find(
  230. (item) => item.id === this.hospitalId
  231. );
  232. let hospitalName = hospital.name;
  233. this.$router.push({
  234. name: 'LessStaticOrNoMap',
  235. params: {
  236. data: { ...row },
  237. hospitalId: this.hospitalId,
  238. hospitalName,
  239. type,
  240. },
  241. });
  242. },
  243. // 选中医院
  244. handleChange(val) {
  245. if (val === '') return;
  246. this.getDataList(val);
  247. this._getRunningStatus(); // 选中后立即请求状态
  248. },
  249. // 获取列表数据
  250. getDataList(id) {
  251. const params = {
  252. hospitalId: id,
  253. };
  254. this.searched = true;
  255. const loading = this.$loading({
  256. lock: true,
  257. text: 'Loading',
  258. spinner: 'el-icon-loading',
  259. background: 'rgba(0, 0, 0, 0.7)',
  260. });
  261. api.getStaticCaseResultList(params).then((res) => {
  262. loading.close();
  263. if (res.data.code === '0') {
  264. this.list = res.data && res.data.data;
  265. }
  266. });
  267. },
  268. },
  269. };
  270. </script>
  271. <style lang="less" scored>
  272. @import '../../../less/admin.less';
  273. #upFile {
  274. display: none !important;
  275. }
  276. </style>