Operation.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537
  1. <template>
  2. <div>
  3. <crumbs :title="title + hospitaiName" linkTo="MedicalTermCDSS">
  4. <el-form :inline="true" class="demo-form-inline">
  5. <el-form-item style="marginBottom: 0px">
  6. <el-button type="text" class="downTemplate" @click="exportModule">导入模板下载</el-button>
  7. <input type="file" name="uploadfile " id="upFile" @change="uploadFile($event)" />
  8. <el-button size="mini" @click="handleMatchData">预匹配</el-button>
  9. <el-button size="mini" @click="importPage" style="margin:0 10px">{{uploadInfo}}</el-button>
  10. <input type="file" name="uploadfile " id="upFileMatch" @change="uploadFileMatch($event)" />
  11. <el-button size="mini" @click="exportData">导出</el-button>
  12. </el-form-item>
  13. </el-form>
  14. </crumbs>
  15. <div class="searchBar">
  16. <div class="searchContent">
  17. <el-form :inline="true" class="demo-form-inline">
  18. <el-form-item label="医院手术/操作名称:">
  19. <el-input size="mini" v-model="filter.hisName" placeholder="请输入" clearable></el-input>
  20. </el-form-item>
  21. <el-form-item label="标准手术/操作名称:">
  22. <el-input size="mini" v-model="filter.uniqueName" placeholder="请输入" clearable></el-input>
  23. </el-form-item>
  24. <el-form-item class="dododo">
  25. <el-button size="mini" @click="filterDatas">检索</el-button>
  26. <el-button size="mini" type="warning" @click="addRelation">添加关联</el-button>
  27. </el-form-item>
  28. </el-form>
  29. </div>
  30. </div>
  31. <div class="contentsOther">
  32. <el-table :data="list" border style="width: 100%">
  33. <el-table-column :resizable="false" type="index" :index="indexMethod" label="编号" width="80"></el-table-column>
  34. <el-table-column :resizable="false" prop="gmtModified" label="操作时间" width="180"></el-table-column>
  35. <el-table-column :resizable="false" prop="hisName" label="医院手术/操作名称" show-overflow-tooltip></el-table-column>
  36. <el-table-column
  37. :resizable="false"
  38. prop="uniqueName"
  39. label="标准手术/操作名称"
  40. show-overflow-tooltip
  41. ></el-table-column>
  42. <el-table-column :resizable="false" prop="operate" label="操作">
  43. <template slot-scope="scope">
  44. <el-button @click="modifyRelation(scope.row)" type="text" size="small">修改</el-button>
  45. <span style="margin:0 3px;">|</span>
  46. <el-button
  47. @click="showDelDialog(scope.row.id)"
  48. class="delete"
  49. type="text"
  50. size="small"
  51. >删除</el-button>
  52. </template>
  53. </el-table-column>
  54. </el-table>
  55. <div class="pagination pagepage">
  56. <el-pagination
  57. :current-page.sync="currentPage"
  58. @current-change="currentChange"
  59. background
  60. :page-size="pageSize"
  61. :page-sizes="pageSizeArr"
  62. @size-change="handleSizeChange"
  63. :layout="pageLayout"
  64. :total="total"
  65. ></el-pagination>
  66. </div>
  67. </div>
  68. </div>
  69. </template>
  70. <script>
  71. import api from '@api/cdss.js';
  72. import config from '@api/config.js';
  73. import utils from '@api/utils.js';
  74. export default {
  75. name: 'Operation', //化验大小项和公表维护
  76. data: function() {
  77. return {
  78. list: [],
  79. searched: false,
  80. filter: {
  81. hisName: '', // 医院诊断名称
  82. uniqueName: '' //标准诊断名称
  83. },
  84. currentPage: 1,
  85. pageSize: config.pageSize,
  86. pageSizeArr: config.pageSizeArr,
  87. pageLayout: config.pageLayout,
  88. total: 0,
  89. uploadInfo: '导入',
  90. title: '手术/操作关联维护 | ',
  91. hospitaiName: '',
  92. hospitalId: ''
  93. };
  94. },
  95. created() {
  96. const { data } = this.$route.params;
  97. this.hospitaiName = (data && data.name) || '';
  98. this.hospitalId = data && data.hospitalId;
  99. const that = this;
  100. //返回时避免参数未赋值就获取列表
  101. setTimeout(function() {
  102. that.getDataList();
  103. });
  104. // 非首页 编辑页返回 设置 this.currentPage
  105. if (Object.keys(this.$route.params).length !== 0) {
  106. this.currentPage = this.$route.params.currentPage;
  107. }
  108. },
  109. watch: {
  110. filter: {
  111. handler: function() {
  112. this.searched = false;
  113. },
  114. deep: true
  115. }
  116. },
  117. beforeRouteEnter(to, from, next) {
  118. next(vm => {
  119. //const pm = to.param;
  120. Object.assign(vm, to.params);
  121. vm.inCurrentPage = to.params.currentPage;
  122. });
  123. },
  124. methods: {
  125. // 预匹配
  126. handleMatchData() {
  127. let inp = document.getElementById('upFileMatch');
  128. inp.click();
  129. },
  130. // 导入数据
  131. uploadFileMatch(e) {
  132. let fileInfo = e.target.files[0];
  133. e.preventDefault();
  134. let formData = new FormData();
  135. formData.append('file', fileInfo);
  136. const header = {
  137. headers: {
  138. 'Content-Type': 'multipart/form-data'
  139. }
  140. };
  141. const loading = this.$loading({
  142. lock: true,
  143. text: '预匹配中...',
  144. spinner: 'el-icon-loading',
  145. background: 'rgba(0, 0, 0, 0.7)'
  146. });
  147. api.dataOperationVerify(formData, header).then(res => {
  148. if (res.data.code === '00020007') {
  149. loading.close();
  150. this.$alert(`${res.data.msg}`, '提示', {
  151. confirmButtonText: '确定',
  152. type: 'warning'
  153. })
  154. .then(() => {})
  155. .catch(() => {});
  156. } else {
  157. api.precOperationDataMatch(formData, header).then(res => {
  158. setTimeout(() => {
  159. loading.close();
  160. }, 800);
  161. if (res.status === 200) {
  162. utils.downloadExportedData(
  163. res.data,
  164. '手术/操作关联数据(预匹配).xls'
  165. );
  166. }
  167. });
  168. }
  169. });
  170. let inp = document.getElementById('upFileMatch');
  171. inp.value = '';
  172. },
  173. handleSizeChange(val) {
  174. this.pageSize = val;
  175. this.currentPage = utils.getCurrentPage(
  176. this.currentPage,
  177. this.total,
  178. this.pageSize
  179. );
  180. this.getDataList();
  181. },
  182. // 获取列表数据
  183. getDataList(isTurnPage) {
  184. const params = this.getFilterItems(isTurnPage);
  185. this.searched = true;
  186. const loading = this.$loading({
  187. lock: true,
  188. text: 'Loading',
  189. spinner: 'el-icon-loading',
  190. background: 'rgba(0, 0, 0, 0.7)'
  191. });
  192. api.getOperationPage(params).then(res => {
  193. loading.close();
  194. if (res.data.code === '0') {
  195. this.list = res.data.data && res.data.data.records;
  196. }
  197. this.total = res.data.data && res.data.data.total;
  198. if (this.inCurrentPage !== undefined) {
  199. this.currentPage = this.inCurrentPage;
  200. this.inCurrentPage = undefined;
  201. }
  202. });
  203. },
  204. // 处理列表请求数据参数
  205. getFilterItems(isTurnPage) {
  206. const { data } = this.$route.params;
  207. //翻页时筛选条件没点确定则清空
  208. if (isTurnPage && !this.searched) {
  209. this.clearFilter();
  210. }
  211. const param = {
  212. current: this.inCurrentPage || this.currentPage,
  213. size: this.pageSize,
  214. hisName: this.filter.hisName.trim(),
  215. uniqueName: this.filter.uniqueName.trim(),
  216. uniqueCode: '',
  217. hospitalId: data && data.hospitalId
  218. };
  219. return param;
  220. },
  221. filterDatas() {
  222. this.currentPage = 1;
  223. this.getDataList();
  224. },
  225. addRelation() {
  226. const pam = this.searched
  227. ? {
  228. currentPage: this.currentPage,
  229. pageSize: this.pageSize,
  230. filter: this.filter
  231. }
  232. : { currentPage: this.currentPage, pageSize: this.pageSize };
  233. this.$router.push({
  234. name: 'AddOperation',
  235. params: Object.assign(pam, {
  236. isEdit: false,
  237. data: { hospitalId: this.hospitalId },
  238. hospitaiName: this.hospitaiName
  239. })
  240. });
  241. },
  242. // 修改诊断关联-跳转至编辑页面
  243. modifyRelation(row) {
  244. const item = Object.assign({}, row);
  245. const pam = this.searched
  246. ? {
  247. currentPage: this.currentPage,
  248. pageSize: this.pageSize,
  249. filter: this.filter
  250. }
  251. : { currentPage: this.currentPage, pageSize: this.pageSize };
  252. this.$router.push({
  253. name: 'AddOperation',
  254. params: Object.assign(pam, {
  255. isEdit: true,
  256. data: { ...item, hospitalId: this.hospitalId },
  257. hospitaiName: this.hospitaiName
  258. })
  259. });
  260. },
  261. currentChange(next) {
  262. this.currentPage = next;
  263. this.getDataList(true);
  264. // if (this.cacheData[next]) { //如果已请求过该页数据,则使用缓存不重复请求
  265. // this.list = this.cacheData[next];
  266. // } else {
  267. // this.getDataList();
  268. // }
  269. },
  270. // 清空搜索参数
  271. clearFilter() {
  272. this.filter = {
  273. hisName: '',
  274. uniqueName: ''
  275. };
  276. },
  277. indexMethod(index) {
  278. return (this.currentPage - 1) * this.pageSize + index + 1;
  279. },
  280. getTagType(val) {
  281. return val;
  282. },
  283. warning(msg, type) {
  284. this.$message({
  285. showClose: true,
  286. message: msg,
  287. type: type || 'warning'
  288. });
  289. },
  290. showConfirmDialog(msg, resolve) {
  291. this.$alert(msg, '提示', {
  292. confirmButtonText: '删除',
  293. // cancelButtonText: '取消',
  294. // cancelButtonClass: 'cancelBtn',
  295. // confirmButtonClass: 'confirmC',
  296. type: 'warning'
  297. })
  298. .then(() => {
  299. resolve();
  300. })
  301. .catch(() => {});
  302. },
  303. // 删除关联
  304. showDelDialog(id) {
  305. this.showConfirmDialog('是否删除该关联?', () => {
  306. api
  307. .deleteOperationRecord({ id: id })
  308. .then(res => {
  309. if (res.data.code == '0') {
  310. if (!this.searched) {
  311. //未点确认时清空搜索条件
  312. this.clearFilter();
  313. }
  314. if (this.list.length == 1) {
  315. //当前在最后一页且只有一条数据时,删除后跳到前一页
  316. this.currentPage =
  317. this.currentPage === 1 ? 1 : this.currentPage - 1;
  318. }
  319. this.getDataList();
  320. this.warning(res.data.msg || '操作成功', 'success');
  321. } else {
  322. this.warning(res.data.msg);
  323. }
  324. })
  325. .catch(error => {
  326. if (error.code === '900010001') {
  327. return false;
  328. }
  329. this.warning(error);
  330. });
  331. });
  332. },
  333. // 导出数据
  334. exportData() {
  335. this.$alert('确定要导出全部手术/操作关联数据吗?', '', {
  336. confirmButtonText: '确定',
  337. // cancelButtonText: '取消',
  338. // cancelButtonClass: 'leftbtn',
  339. // customClass: 'exportBox6',
  340. title: '提示',
  341. type: 'warning'
  342. // beforeClose: (action, instance, done) => {
  343. // if (action === 'confirm') {
  344. // // instance.confirmButtonLoading = true;
  345. // instance.confirmButtonText = '导出中...';
  346. // api.exportOperationRecord().then(res => {
  347. // if (res.status === 200) {
  348. // setTimeout(() => {
  349. // utils.downloadExportedData(res.data, '手术/操作关联数据.xls');
  350. // done();
  351. // }, 1500);
  352. // }
  353. // });
  354. // } else {
  355. // done();
  356. // }
  357. // }
  358. })
  359. .then(() => {
  360. api
  361. .exportOperationRecord({ hospitalId: this.hospitalId,type:6,isMatch:this.filter.match })
  362. .then(res => {
  363. if (res.status === 200) {
  364. this.$message({ message: '导出成功', type: 'success' });
  365. utils.downloadExportedData(res.data, '手术/操作关联数据.xls');
  366. }
  367. });
  368. })
  369. .catch(() => {
  370. // this.$message({ message: '导出失败', type: 'waring' });
  371. });
  372. },
  373. // 导入模板
  374. exportModule() {
  375. api.exportOperationModule().then(res => {
  376. if (res.status === 200) {
  377. setTimeout(() => {
  378. utils.downloadExportedData(res.data, '手术/操作导入模板.xls');
  379. }, 1500);
  380. }
  381. });
  382. },
  383. // 点击导入
  384. importPage() {
  385. let inp = document.getElementById('upFile');
  386. inp.click();
  387. },
  388. // 导入数据
  389. uploadFile(e) {
  390. let fileInfo = e.target.files[0];
  391. e.preventDefault();
  392. let formData = new FormData();
  393. formData.append('file', fileInfo);
  394. formData.append('hospitalId', this.hospitalId);
  395. const header = {
  396. headers: {
  397. 'Content-Type': 'multipart/form-data'
  398. }
  399. };
  400. this.uploadInfo = '导入中...';
  401. api.importOperationRecord(formData, header).then(res => {
  402. if (res.data.code === '00000001') {
  403. this.$alert(`数据存在异常,导入失败,请修改后再试`, '提示', {
  404. confirmButtonText: '确定',
  405. // cancelButtonText: '取消',
  406. // cancelButtonClass: 'cancelSure',
  407. // confirmButtonClass: 'sure',
  408. // customClass: 'exportConfirm',
  409. type: 'warning'
  410. })
  411. .then(() => {})
  412. .catch(() => {});
  413. this.getDataList(); // 重新获取列表
  414. setTimeout(() => {
  415. this.uploadInfo = '导入';
  416. }, 300);
  417. } else if (res.data === '' && res.status === 200) {
  418. this.$alert(`导入成功`, '提示', {
  419. confirmButtonText: '确定',
  420. // cancelButtonText: '取消',
  421. // cancelButtonClass: 'cancelSure',
  422. // confirmButtonClass: 'sure',
  423. // customClass: 'exportConfirm',
  424. type: 'success'
  425. })
  426. .then(() => {})
  427. .catch(() => {});
  428. this.getDataList(); // 重新获取列表
  429. setTimeout(() => {
  430. this.uploadInfo = '导入';
  431. }, 300);
  432. } else {
  433. this.$alert(`${res.data.msg}`, '提示', {
  434. confirmButtonText: '确定',
  435. // // cancelButtonText: '取消',
  436. // cancelButtonClass: 'cancelSure',
  437. // confirmButtonClass: 'sure',
  438. // customClass: 'exportConfirm',
  439. type: 'warning'
  440. })
  441. .then(() => {})
  442. .catch(() => {});
  443. setTimeout(() => {
  444. this.uploadInfo = '导入';
  445. }, 300);
  446. }
  447. });
  448. //解决上传相同文件不触发change
  449. let inp = document.getElementById('upFile');
  450. inp.value = '';
  451. }
  452. }
  453. };
  454. </script>
  455. <style lang="less" scoped>
  456. @import '../../../less/admin.less';
  457. .delete {
  458. color: red;
  459. }
  460. .delete:hover {
  461. color: red;
  462. }
  463. .pagination {
  464. min-width: 1010px;
  465. }
  466. .downTemplate {
  467. margin-right: 8px;
  468. span {
  469. color: #02a7f0;
  470. }
  471. }
  472. #upFile {
  473. display: none !important;
  474. }
  475. #upFileMatch {
  476. display: none;
  477. }
  478. .el-message-box {
  479. /deep/.cancelBtn {
  480. background-color: #d7d7d7;
  481. border-color: transparent;
  482. }
  483. /deep/.confirmC {
  484. background-color: #ff545b !important;
  485. border-color: transparent !important;
  486. }
  487. }
  488. .exportBox6 {
  489. /deep/ .el-message-box__btns {
  490. margin-top: 20px;
  491. }
  492. /deep/ .el-message-box__message {
  493. // text-align: center;
  494. }
  495. /deep/.leftbtn {
  496. background-color: #d7d7d7;
  497. border-color: transparent !important;
  498. }
  499. /deep/ .el-message-box__header {
  500. border-bottom: 1px solid #dcdfe6;
  501. }
  502. }
  503. .searchBar {
  504. min-width: 980px;
  505. height: 60px;
  506. display: flex;
  507. justify-content: center;
  508. align-items: center;
  509. background-color: #dee2ea;
  510. z-index: 9999;
  511. padding: 40px 20px 0;
  512. .searchContent {
  513. height: 40px;
  514. flex: 1;
  515. background-color: #fff;
  516. display: flex;
  517. justify-content: flex-end;
  518. float: right;
  519. }
  520. }
  521. .contentsOther {
  522. padding: 0 20px;
  523. }
  524. </style>