Operation.vue 15 KB

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