Lis.vue 13 KB

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