StaticKnowledgeMapTest.vue 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357
  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 || implement"
  86. @click="handleTest(scope.row, scope.$index)"
  87. >{{
  88. runningStatusArr[scope.$index] === 1
  89. ? "执行测试中..."
  90. : implement
  91. ? "执行测试"
  92. : "执行测试"
  93. }}</el-button
  94. >
  95. <span v-if="runningStatusArr[scope.$index] === 1"> | </span>
  96. <el-button
  97. v-if="runningStatusArr[scope.$index] === 1"
  98. type="text"
  99. size="small"
  100. @click="handleUpdateStatus(scope.row, scope.$index)"
  101. >
  102. 重置
  103. </el-button>
  104. </template>
  105. </el-table-column>
  106. </el-table>
  107. </div>
  108. </div>
  109. </template>
  110. <script>
  111. import api from "@api/cdss.js";
  112. import config from "@api/config.js";
  113. import utils from "@api/utils.js";
  114. export default {
  115. name: "KnowledgeMapRuleTest",
  116. data() {
  117. return {
  118. list: [],
  119. hospitalData: [],
  120. hospitalId: "", //选中医院
  121. type: "",
  122. caseId: "",
  123. runningStatusArr: [0, 0, 0, 0, 0, 0, 0],
  124. statusIndex: "",
  125. implement: false,
  126. };
  127. },
  128. computed: {
  129. runningStatus() {
  130. return this.runningStatusArr.every((item) => {
  131. return item === 0;
  132. });
  133. },
  134. },
  135. created() {
  136. this.reminder();
  137. this._getHospitalInfoCDSS();
  138. this.timer = setInterval(this._getRunningStatus, 20 * 1000);
  139. this.timer = setInterval(this.getRunningState, 20 * 1000);
  140. },
  141. beforeDestroy() {
  142. clearInterval(this.timer);
  143. },
  144. beforeRouteEnter(to, from, next) {
  145. next((vm) => {
  146. Object.assign(vm, to.params);
  147. if (Object.keys(to.params).length === 0) return;
  148. vm.getDataList(to.params.hospitalId);
  149. vm._getRunningStatus();
  150. });
  151. },
  152. methods: {
  153. reminder() {
  154. api
  155. .reminder({caseGroup:2})
  156. .then((res) => {
  157. if (res.data.code == "0") {
  158. this.$message({
  159. message: res.data.data,
  160. type: "error",
  161. });
  162. }
  163. })
  164. .catch((error) => {
  165. console.log(error);
  166. });
  167. },
  168. getRunningState() {
  169. api
  170. .getRunningState({ caseGroup: 2 })
  171. .then((res) => {
  172. if (res.data.code == "0") {
  173. this.implement = res.data.data;
  174. }
  175. })
  176. .catch((error) => {
  177. console.log(error);
  178. });
  179. },
  180. _getRunningStatus() {
  181. const { hospitalId } = this;
  182. if (this.hospitalId === "") return;
  183. api.getRunningStatusByHospitalId({ hospitalId }).then((res) => {
  184. if (res.data.code === "0" && res.data.data) {
  185. this.runningStatusArr = Object.values(res.data.data).slice(9, 16);
  186. }
  187. });
  188. },
  189. indexMethod(index) {
  190. return index + 1;
  191. },
  192. // 获取医院信息
  193. _getHospitalInfoCDSS() {
  194. api.getHospitalInfo().then((res) => {
  195. if (res.data.code === "0") {
  196. this.hospitalData = res.data && res.data.data;
  197. }
  198. });
  199. },
  200. handleType(caseName) {
  201. switch (caseName) {
  202. case "诊断":
  203. return 1;
  204. case "检验":
  205. return 2;
  206. case "检查":
  207. return 3;
  208. case "药品":
  209. return 4;
  210. case "手术/操作":
  211. return 5;
  212. case "量表":
  213. return 6;
  214. case "护理":
  215. return 7;
  216. default:
  217. return null;
  218. }
  219. },
  220. // 重置状态
  221. handleUpdateStatus(row, index) {
  222. const { caseId } = row;
  223. api
  224. .updateRunningStatus({
  225. hospitalId: this.hospitalId,
  226. caseId,
  227. status: 0,
  228. })
  229. .then((res) => {
  230. if (res.data.code === "0" && res.data.data) {
  231. this.$message({
  232. message: "重置成功",
  233. type: "success",
  234. });
  235. this.getDataList(this.hospitalId); // 重新获取列表
  236. this.getRunningState();
  237. } else {
  238. this.$message.error(res.data.msg || "重置失败");
  239. this.getDataList(this.hospitalId); // 重新获取列表
  240. this.getRunningState();
  241. }
  242. this.runningStatusArr = [0, 0, 0, 0, 0, 0, 0];
  243. });
  244. },
  245. // 执行测试
  246. handleTest(row, index) {
  247. let inp = document.getElementById("upFile");
  248. inp.click();
  249. const { caseName, caseId } = row;
  250. this.type = this.handleType(caseName); //术语类型(1:诊断、2:检验、3:检查、4:药品、5:手术/操作)
  251. this.caseId = caseId; //测试用例id
  252. this.statusIndex = index;
  253. },
  254. // 导入数据
  255. uploadFile(e) {
  256. console.log(this.runningStatusArr, 222);
  257. if (this.statusIndex !== "") {
  258. this.runningStatusArr = this.runningStatusArr.map((item, idx) => {
  259. console.log(idx);
  260. console.log(this.statusIndex, 112);
  261. if (idx === this.statusIndex) {
  262. return 1;
  263. } else {
  264. return 0;
  265. }
  266. });
  267. }
  268. let fileInfo = e.target.files[0];
  269. e.preventDefault();
  270. let formData = new FormData();
  271. formData.append("file", fileInfo);
  272. formData.append("hospitalId", this.hospitalId);
  273. formData.append("type", this.type);
  274. formData.append("caseId", this.caseId);
  275. const header = {
  276. headers: {
  277. "Content-Type": "multipart/form-data",
  278. },
  279. };
  280. api.staticKnowledgeTest(formData, header).then((res) => {
  281. if (res.data.code === "00020007") {
  282. this.$message.error(res.data.msg || "数据存在异常");
  283. this.getDataList(this.hospitalId); // 重新获取列表
  284. } else if (res.data.code === "0" && res.data.data) {
  285. this.$message({
  286. message: "测试成功",
  287. type: "success",
  288. });
  289. this.getDataList(this.hospitalId); // 重新获取列表
  290. } else {
  291. this.$message.error(res.data.msg || "数据存在异常");
  292. this.getDataList(this.hospitalId);
  293. }
  294. this.runningStatusArr = [0, 0, 0, 0, 0, 0, 0];
  295. });
  296. //解决上传相同文件不触发change
  297. let inp = document.getElementById("upFile");
  298. inp.value = "";
  299. },
  300. // 跳转至未映射到标准术语条数页面 / 缺少静态知识术语条数
  301. goToInnerPage(row, type) {
  302. let hospital = this.hospitalData.find(
  303. (item) => item.id === this.hospitalId
  304. );
  305. let hospitalName = hospital.name;
  306. this.$router.push({
  307. name: "LessStaticOrNoMap",
  308. params: {
  309. data: { ...row },
  310. hospitalId: this.hospitalId,
  311. hospitalName,
  312. type,
  313. },
  314. });
  315. },
  316. // 选中医院
  317. handleChange(val) {
  318. if (val === "") return;
  319. this.getDataList(val);
  320. this._getRunningStatus(); // 选中后立即请求状态
  321. },
  322. // 获取列表数据
  323. getDataList(id) {
  324. const params = {
  325. hospitalId: id,
  326. };
  327. this.searched = true;
  328. const loading = this.$loading({
  329. lock: true,
  330. text: "Loading",
  331. spinner: "el-icon-loading",
  332. background: "rgba(0, 0, 0, 0.7)",
  333. });
  334. api.getStaticCaseResultList(params).then((res) => {
  335. loading.close();
  336. if (res.data.code === "0") {
  337. this.list = res.data && res.data.data;
  338. }
  339. });
  340. },
  341. },
  342. };
  343. </script>
  344. <style lang="less" scored>
  345. @import "../../../less/admin.less";
  346. #upFile {
  347. display: none !important;
  348. }
  349. </style>