AutoKnowledgeMapRuleTest.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419
  1. <template>
  2. <div>
  3. <crumbs title="规则测试" class="topBack">
  4. <el-form :inline="true" class="demo-form-inline">
  5. <el-form-item label class="selectMedicine" style="marginbottom: -1px">
  6. <el-select
  7. size="mini"
  8. v-model="hospitalId"
  9. placeholder="选择医院"
  10. @change="handleChange"
  11. >
  12. <el-option
  13. v-for="item in hospitalData"
  14. :label="item.name"
  15. :value="item.id"
  16. :key="item.id"
  17. ></el-option>
  18. </el-select>
  19. </el-form-item>
  20. <el-form-item style="marginbottom: 0px">
  21. <el-button size="mini" @click="exportData"
  22. >导出规则中未涉及到的医院术语</el-button
  23. >
  24. </el-form-item>
  25. <el-form-item style="marginbottom: 0px">
  26. <el-button
  27. size="mini"
  28. @click="handleAllTest"
  29. :disabled="!runningStatus || implement"
  30. >所有规则测试</el-button
  31. >
  32. </el-form-item>
  33. </el-form>
  34. </crumbs>
  35. <div style="margin: 60px 20px 0">
  36. <el-table :data="list" border>
  37. <el-table-column
  38. :resizable="false"
  39. type="index"
  40. :index="indexMethod"
  41. label="编号"
  42. width="80"
  43. ></el-table-column>
  44. <el-table-column
  45. :resizable="false"
  46. prop="caseName"
  47. label="规则类型"
  48. show-overflow-tooltip
  49. ></el-table-column>
  50. <el-table-column
  51. :resizable="false"
  52. prop="gmtModified"
  53. label="测试时间"
  54. ></el-table-column>
  55. <el-table-column
  56. :resizable="false"
  57. prop="ruleNum"
  58. label="总条数"
  59. show-overflow-tooltip
  60. ></el-table-column>
  61. <el-table-column label="成功条数">
  62. <template slot-scope="scope">
  63. <el-button
  64. type="text"
  65. size="small"
  66. @click="goToFailedOrSuccessPage(scope.row, 'success')"
  67. :disabled="runningStatusArr[scope.$index] === 1"
  68. >{{ scope.row.ruleSuccessNum }}</el-button
  69. >
  70. </template>
  71. </el-table-column>
  72. <el-table-column label="失败条数">
  73. <template slot-scope="scope">
  74. <el-button
  75. type="text"
  76. size="small"
  77. @click="goToFailedOrSuccessPage(scope.row, 'failed')"
  78. :disabled="runningStatusArr[scope.$index] === 1"
  79. >{{ scope.row.ruleFailedNum }}</el-button
  80. >
  81. </template>
  82. </el-table-column>
  83. <el-table-column label="操作">
  84. <template slot-scope="scope">
  85. <el-button
  86. type="text"
  87. size="small"
  88. @click="handleTest(scope.row, scope.row.caseId - 1)"
  89. :disabled="!runningStatus || implement"
  90. >
  91. {{
  92. runningStatusArr[scope.row.caseId - 1] === 1
  93. ? "执行测试中"
  94. : implement
  95. ? "执行测试"
  96. : "执行测试"
  97. }}
  98. </el-button>
  99. <span v-if="runningStatusArr[scope.row.caseId - 1] === 1">|</span>
  100. <el-button
  101. v-if="runningStatusArr[scope.row.caseId - 1] === 1"
  102. type="text"
  103. size="small"
  104. @click="handleUpdateStatus(scope.row, scope.row.caseId - 1)"
  105. >重置</el-button
  106. >
  107. </template>
  108. </el-table-column>
  109. </el-table>
  110. </div>
  111. </div>
  112. </template>
  113. <script>
  114. import api from "@api/knowledgeTree.js";
  115. import config from "@api/config.js";
  116. import utils from "@api/utils.js";
  117. export default {
  118. name: "AutoKnowledgeMapRuleTest",
  119. data() {
  120. return {
  121. list: [],
  122. hospitalData: [],
  123. hospitalId: "", //选中医院
  124. runningStatusArr: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], //知识图谱规则 测试状态
  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.zskgetDict();
  139. // this._getRunningStatus() // 进入页面立即确认状态
  140. this.timer = setInterval(this._getRunningStatus, 20 * 1000);
  141. this.timer = setInterval(this.getRunningState, 20 * 1000);
  142. },
  143. beforeDestroy() {
  144. clearInterval(this.timer);
  145. },
  146. beforeRouteEnter(to, from, next) {
  147. next((vm) => {
  148. Object.assign(vm, to.params);
  149. if (Object.keys(to.params).length === 0) return;
  150. vm.getDataList(to.params.hospitalId);
  151. // vm.hospitalId = to.params.hospitalId;
  152. vm._getRunningStatus();
  153. });
  154. },
  155. methods: {
  156. reminder() {
  157. api
  158. .reminder({ caseGroup: 1 })
  159. .then((res) => {
  160. if (res.data.code == "0") {
  161. if (res.data.data) {
  162. this.$message({
  163. message: res.data.data,
  164. type: "error",
  165. });
  166. }
  167. }
  168. })
  169. .catch((error) => {
  170. console.log(error);
  171. });
  172. },
  173. getRunningState() {
  174. api
  175. .getRunningState({ caseGroup: 1 })
  176. .then((res) => {
  177. if (res.data.code == "0") {
  178. this.implement = res.data.data;
  179. }
  180. })
  181. .catch((error) => {
  182. console.log(error);
  183. });
  184. },
  185. zskgetDict() {
  186. api
  187. .zskgetDict()
  188. .then((res) => {
  189. if (res.data.code == "0") {
  190. const data = res.data.data;
  191. const arr = data["31"];
  192. localStorage.setItem("zskDicts", JSON.stringify(arr));
  193. }
  194. })
  195. .catch((error) => {
  196. console.log(error);
  197. });
  198. },
  199. _getRunningStatus() {
  200. const { hospitalId } = this;
  201. if (this.hospitalId === "") return;
  202. api.getRunningStatusByHospitalId({ hospitalId }).then((res) => {
  203. if (res.data.code === "0" && res.data.data) {
  204. this.runningStatusArr = Object.values(res.data.data).slice(0, 15);
  205. }
  206. });
  207. },
  208. // 重置状态
  209. handleUpdateStatus(row, index) {
  210. const { caseId } = row;
  211. // console.log(index,'index');
  212. let statusTempArr = [...this.runningStatusArr];
  213. statusTempArr[index] = 0;
  214. api
  215. .updateRunningStatus({
  216. hospitalId: this.hospitalId,
  217. caseId,
  218. status: 0,
  219. })
  220. .then((res) => {
  221. if (res.data.code === "0" && res.data.data) {
  222. this.$message({
  223. message: "重置成功",
  224. type: "success",
  225. });
  226. this.getDataList(this.hospitalId); // 重新获取列表
  227. this.getRunningState();
  228. } else {
  229. this.$message.error(res.data.msg || "重置失败");
  230. this.getDataList(this.hospitalId); // 重新获取列表
  231. this.getRunningState();
  232. }
  233. this.runningStatusArr = statusTempArr;
  234. });
  235. },
  236. indexMethod(index) {
  237. return index + 1;
  238. },
  239. // 执行测试
  240. handleTest(row, index) {
  241. if (this.implement) {
  242. this._getRunningStatus();
  243. return
  244. }
  245. this.runningStatusArr = this.runningStatusArr.map((item, idx) => {
  246. if (idx === index) {
  247. return 1;
  248. } else {
  249. return 0;
  250. }
  251. });
  252. const { caseName, caseId } = row;
  253. let params = {
  254. caseId,
  255. hospitalId: this.hospitalId,
  256. };
  257. api.autoRuleTest(params).then((res) => {
  258. if (res.data.code === "0" && res.data.data) {
  259. this.getDataList(this.hospitalId);
  260. this.$message({
  261. message: "测试成功",
  262. type: "success",
  263. });
  264. } else {
  265. this.$message.error("测试失败");
  266. this.getDataList(this.hospitalId);
  267. }
  268. this.runningStatusArr = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
  269. });
  270. },
  271. // 所有规则测试
  272. handleAllTest() {
  273. if (this.hospitalId === "") {
  274. this.$message({
  275. message: "请先选择医院",
  276. type: "warning",
  277. });
  278. return;
  279. }
  280. if (this.implement) {
  281. this._getRunningStatus();
  282. }
  283. this.runningStatusArr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1];
  284. api.allRuleTest({ hospitalId: this.hospitalId }).then((res) => {
  285. this.runningStatusArr = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
  286. if (res.data.code === "0" && res.data.data) {
  287. this.getDataList(this.hospitalId);
  288. this.$message({
  289. message: "所有规则测试成功",
  290. type: "success",
  291. });
  292. } else {
  293. this.$message.error("所有规则测试失败");
  294. this.getDataList(this.hospitalId);
  295. }
  296. });
  297. },
  298. // 跳转至失败/成功条数页面
  299. goToFailedOrSuccessPage(row, type) {
  300. const page = this.handleGoPage(row.caseName);
  301. let hospital = this.hospitalData.find(
  302. (item) => item.id === this.hospitalId
  303. );
  304. let hospitalName = hospital.name;
  305. let localAuto = {
  306. resultId: row.resultId,
  307. type,
  308. hospitalName,
  309. caseName: row.caseName.replace(/\_/, "-"),
  310. };
  311. localStorage.setItem("localAuto", JSON.stringify(localAuto));
  312. this.$router.push({
  313. name: "AutoBillCommonTest",
  314. params: {
  315. data: { ...row },
  316. type,
  317. hospitalId: this.hospitalId,
  318. hospitalName,
  319. },
  320. });
  321. },
  322. // 处理跳转到的页面
  323. handleGoPage(caseName) {
  324. switch (caseName) {
  325. case "开单合理性提醒_通用规则":
  326. return "BillCommonTest";
  327. case "开单类型提醒_输血规则":
  328. return "BillFusionTest";
  329. case "危机值提醒_实验室检查规则":
  330. return "CriticalLabTest";
  331. case "危机值提醒_辅助检查规则":
  332. return "CriticalAuxTest";
  333. case "高风险提醒_高危药品规则":
  334. return "HighRiskDrugTest";
  335. case "高风险提醒_高危手术规则":
  336. return "HighRiskOperationTest";
  337. case "其他提醒_化验规则":
  338. return "OtherAssayRuleTest";
  339. case "其他提醒_输血规则":
  340. return "OtherFusionRuleTest";
  341. case "其他提醒_辅检规则":
  342. return "OtherAuxRuleTest";
  343. default:
  344. return null;
  345. }
  346. },
  347. // 获取医院信息
  348. _getHospitalInfoCDSS() {
  349. api.getRecordHopitalList().then((res) => {
  350. if (res.data.code === "0") {
  351. this.hospitalData = res.data && res.data.data;
  352. }
  353. });
  354. },
  355. // 选中医院
  356. handleChange(val) {
  357. if (val === "") return;
  358. this.getDataList(val);
  359. this._getRunningStatus(); // 选中后立即请求状态
  360. this.getRunningState();
  361. },
  362. // 获取列表数据
  363. getDataList(id) {
  364. const params = {
  365. hospitalId: id,
  366. };
  367. this.searched = true;
  368. const loading = this.$loading({
  369. lock: true,
  370. text: "Loading",
  371. spinner: "el-icon-loading",
  372. background: "rgba(0, 0, 0, 0.7)",
  373. });
  374. api.autoGetCaseResultList(params).then((res) => {
  375. loading.close();
  376. if (res.data.code === "0") {
  377. this.list = res.data && res.data.data;
  378. }
  379. });
  380. },
  381. // 导出
  382. exportData() {
  383. if (this.hospitalId === "") {
  384. this.$message({
  385. message: "请先选择医院",
  386. type: "warning",
  387. });
  388. return;
  389. }
  390. this.$alert("确定要导出规则未使用映射关系吗?", "", {
  391. confirmButtonText: "确定",
  392. title: "提示",
  393. type: "warning",
  394. })
  395. .then(() => {
  396. api.autoExportExcel({ hospitalId: this.hospitalId }).then((res) => {
  397. if (res.status === 200) {
  398. this.$message({ message: "导出成功", type: "success" });
  399. utils.downloadExportedData(res.data, "规则未使用映射关系.xls");
  400. }
  401. });
  402. })
  403. .catch(() => {});
  404. },
  405. },
  406. };
  407. </script>
  408. <style lang="less" scoped>
  409. @import "../../less/admin.less";
  410. </style>