AutoKnowledgeMapRuleTest.vue 12 KB

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