AutoKnowledgeMapRuleTest.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335
  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, 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, 15);
  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. api.autoRuleTest(params).then(res => {
  180. if (res.data.code === '0' && res.data.data) {
  181. this.getDataList(this.hospitalId);
  182. this.$message({
  183. message: '测试成功',
  184. type: 'success'
  185. });
  186. } else {
  187. this.$message.error('测试失败');
  188. this.getDataList(this.hospitalId);
  189. }
  190. this.runningStatusArr = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
  191. });
  192. },
  193. // 所有规则测试
  194. handleAllTest() {
  195. if (this.hospitalId === '') {
  196. this.$message({
  197. message: '请先选择医院',
  198. type: 'warning'
  199. });
  200. return;
  201. }
  202. this.runningStatusArr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1];
  203. api.allRuleTest({ hospitalId: this.hospitalId }).then(res => {
  204. this.runningStatusArr = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
  205. if (res.data.code === '0' && res.data.data) {
  206. this.getDataList(this.hospitalId);
  207. this.$message({
  208. message: '所有规则测试成功',
  209. type: 'success'
  210. });
  211. } else {
  212. this.$message.error('所有规则测试失败');
  213. this.getDataList(this.hospitalId);
  214. }
  215. });
  216. },
  217. // 跳转至失败/成功条数页面
  218. goToFailedOrSuccessPage(row, type) {
  219. const page = this.handleGoPage(row.caseName);
  220. let hospital = this.hospitalData.find(item => item.id === this.hospitalId);
  221. let hospitalName = hospital.name;
  222. let localAuto = {
  223. resultId:row.resultId,
  224. type,
  225. hospitalName,
  226. caseName:row.caseName.replace(/\_/,'-')
  227. }
  228. localStorage.setItem('localAuto',JSON.stringify(localAuto))
  229. this.$router.push({
  230. name: 'AutoBillCommonTest',
  231. params: {
  232. data: { ...row },
  233. type,
  234. hospitalId: this.hospitalId,
  235. hospitalName
  236. }
  237. });
  238. },
  239. // 处理跳转到的页面
  240. handleGoPage(caseName) {
  241. switch (caseName) {
  242. case '开单合理性提醒_通用规则':
  243. return 'BillCommonTest';
  244. case '开单类型提醒_输血规则':
  245. return 'BillFusionTest';
  246. case '危机值提醒_实验室检查规则':
  247. return 'CriticalLabTest';
  248. case '危机值提醒_辅助检查规则':
  249. return 'CriticalAuxTest';
  250. case '高风险提醒_高危药品规则':
  251. return 'HighRiskDrugTest';
  252. case '高风险提醒_高危手术规则':
  253. return 'HighRiskOperationTest';
  254. case '其他提醒_化验规则':
  255. return 'OtherAssayRuleTest';
  256. case '其他提醒_输血规则':
  257. return 'OtherFusionRuleTest';
  258. case '其他提醒_辅检规则':
  259. return 'OtherAuxRuleTest';
  260. default:
  261. return null;
  262. }
  263. },
  264. // 获取医院信息
  265. _getHospitalInfoCDSS() {
  266. api.getRecordHopitalList().then(res => {
  267. if (res.data.code === '0') {
  268. this.hospitalData = res.data && res.data.data;
  269. }
  270. });
  271. },
  272. // 选中医院
  273. handleChange(val) {
  274. if (val === '') return;
  275. this.getDataList(val);
  276. this._getRunningStatus(); // 选中后立即请求状态
  277. },
  278. // 获取列表数据
  279. getDataList(id) {
  280. const params = {
  281. hospitalId: id
  282. };
  283. this.searched = true;
  284. const loading = this.$loading({
  285. lock: true,
  286. text: 'Loading',
  287. spinner: 'el-icon-loading',
  288. background: 'rgba(0, 0, 0, 0.7)'
  289. });
  290. api.autoGetCaseResultList(params).then(res => {
  291. loading.close();
  292. if (res.data.code === '0') {
  293. this.list = res.data && res.data.data;
  294. }
  295. });
  296. },
  297. // 导出
  298. exportData() {
  299. if (this.hospitalId === '') {
  300. this.$message({
  301. message: '请先选择医院',
  302. type: 'warning'
  303. });
  304. return;
  305. }
  306. this.$alert('确定要导出规则未使用映射关系吗?', '', {
  307. confirmButtonText: '确定',
  308. title: '提示',
  309. type: 'warning'
  310. })
  311. .then(() => {
  312. api.autoExportExcel({ hospitalId: this.hospitalId }).then(res => {
  313. if (res.status === 200) {
  314. this.$message({ message: '导出成功', type: 'success' });
  315. utils.downloadExportedData(res.data, '规则未使用映射关系.xls');
  316. }
  317. });
  318. })
  319. .catch(() => {});
  320. }
  321. }
  322. };
  323. </script>
  324. <style lang="less" scoped>
  325. @import '../../less/admin.less';
  326. </style>