Lis.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341
  1. <template>
  2. <div>
  3. <crumbs title="检验关联维护" style="min-width: 980px">
  4. <el-form :inline="true" class="demo-form-inline">
  5. <el-form-item>
  6. <el-button size="mini" @click="importPage">导入</el-button>
  7. <el-button size="mini" @click="exportData">导出</el-button>
  8. </el-form-item>
  9. <el-form-item label="检验套餐:">
  10. <el-input size="mini" v-model="filter.hisName" placeholder="请输入" clearable></el-input>
  11. </el-form-item>
  12. <el-form-item label="检验细项:">
  13. <el-input size="mini" v-model="filter.hisDetailName" placeholder="请输入" clearable></el-input>
  14. </el-form-item>
  15. <el-form-item label="标准检验项:">
  16. <el-input size="mini" v-model="filter.uniqueName" placeholder="请输入" clearable></el-input>
  17. </el-form-item>
  18. <el-form-item class="dododo">
  19. <el-button size="mini" @click="filterDatas">检索</el-button>
  20. <el-button size="mini" type="warning" @click="addRelation">添加关联</el-button>
  21. </el-form-item>
  22. </el-form>
  23. </crumbs>
  24. <div class="contents">
  25. <el-table :data="list" border style="width: 100%">
  26. <el-table-column :resizable="false" type="index" :index="indexMethod" label="编号" width="60"></el-table-column>
  27. <el-table-column :resizable="false" prop="gmtModified" label="操作时间" width="180"></el-table-column>
  28. <el-table-column :resizable="false" prop="hisName" label="检验套餐" show-overflow-tooltip></el-table-column>
  29. <el-table-column :resizable="false" prop="hisDetailName" label="检验细项" show-overflow-tooltip></el-table-column>
  30. <el-table-column :resizable="false" prop="uniqueCode" label="对应项编码" show-overflow-tooltip></el-table-column>
  31. <el-table-column :resizable="false" prop="uniqueName" label="标准检验项" show-overflow-tooltip></el-table-column>
  32. <el-table-column :resizable="false" prop="operate" label="操作">
  33. <template slot-scope="scope">
  34. <el-button @click="modifyRelation(scope.row)" type="text" size="small">修改</el-button>
  35. <span style="margin:0 3px;">|</span>
  36. <el-button
  37. @click="showDelDialog(scope.row.id)"
  38. class="delete"
  39. type="text"
  40. size="small"
  41. >删除</el-button>
  42. </template>
  43. </el-table-column>
  44. </el-table>
  45. <div class="pagination pagepage">
  46. <el-pagination
  47. :current-page.sync="currentPage"
  48. @current-change="currentChange"
  49. background
  50. :page-size="pageSize"
  51. :page-sizes="pageSizeArr"
  52. @size-change="handleSizeChange"
  53. :layout="pageLayout"
  54. :total="total"
  55. ></el-pagination>
  56. </div>
  57. </div>
  58. </div>
  59. </template>
  60. <script>
  61. import api from '@api/icss.js';
  62. import config from '@api/config.js';
  63. import utils from '@api/utils.js';
  64. export default {
  65. name: 'Lis', //化验大小项和公表维护
  66. data: function() {
  67. return {
  68. list: [],
  69. searched: false,
  70. filter: {
  71. hisName: '', // 检验套餐
  72. hisDetailName: '', //检验细项
  73. uniqueName: '' //标准检验项
  74. },
  75. currentPage: 1,
  76. pageSize: config.pageSize,
  77. pageSizeArr: config.pageSizeArr,
  78. pageLayout: config.pageLayout,
  79. total: 0
  80. };
  81. },
  82. created() {
  83. const that = this;
  84. //返回时避免参数未赋值就获取列表
  85. setTimeout(function() {
  86. that.getDataList();
  87. });
  88. },
  89. watch: {
  90. filter: {
  91. handler: function() {
  92. this.searched = false;
  93. },
  94. deep: true
  95. }
  96. },
  97. beforeRouteEnter(to, from, next) {
  98. next(vm => {
  99. //const pm = to.param;
  100. Object.assign(vm, to.params);
  101. vm.inCurrentPage = to.params.currentPage;
  102. });
  103. },
  104. methods: {
  105. handleSizeChange(val) {
  106. this.pageSize = val;
  107. this.currentPage = utils.getCurrentPage(
  108. this.currentPage,
  109. this.total,
  110. this.pageSize
  111. );
  112. this.getDataList();
  113. },
  114. // 获取列表数据
  115. getDataList(isTurnPage) {
  116. const params = this.getFilterItems(isTurnPage);
  117. this.searched = true;
  118. const loading = this.$loading({
  119. lock: true,
  120. text: 'Loading',
  121. spinner: 'el-icon-loading',
  122. background: 'rgba(0, 0, 0, 0.7)'
  123. });
  124. api.getLisPage(params).then(res => {
  125. loading.close();
  126. if (res.data.code === '0') {
  127. this.list = res.data.data && res.data.data.records;
  128. }
  129. this.total = res.data.data && res.data.data.total;
  130. if (this.inCurrentPage !== undefined) {
  131. this.currentPage = this.inCurrentPage;
  132. this.inCurrentPage = undefined;
  133. }
  134. });
  135. },
  136. // 处理列表请求数据参数
  137. getFilterItems(isTurnPage) {
  138. //翻页时筛选条件没点确定则清空
  139. if (isTurnPage && !this.searched) {
  140. this.clearFilter();
  141. }
  142. const param = {
  143. current: this.inCurrentPage || this.currentPage,
  144. size: this.pageSize,
  145. hisName: this.filter.hisName.trim(),
  146. uniqueName: this.filter.uniqueName.trim(),
  147. uniqueCode: '',
  148. hisDetailName: this.filter.hisDetailName.trim()
  149. };
  150. return param;
  151. },
  152. filterDatas() {
  153. this.currentPage = 1;
  154. this.getDataList();
  155. },
  156. addRelation() {
  157. const pam = this.searched
  158. ? {
  159. currentPage: this.currentPage,
  160. pageSize: this.pageSize,
  161. filter: this.filter
  162. }
  163. : { currentPage: this.currentPage, pageSize: this.pageSize };
  164. this.$router.push({ name: 'AddLis', params: pam });
  165. },
  166. // 修改诊断关联-跳转至编辑页面
  167. modifyRelation(row) {
  168. const item = Object.assign({}, row);
  169. const pam = this.searched
  170. ? {
  171. currentPage: this.currentPage,
  172. pageSize: this.pageSize,
  173. filter: this.filter
  174. }
  175. : { currentPage: this.currentPage, pageSize: this.pageSize };
  176. this.$router.push({
  177. name: 'AddLis',
  178. params: Object.assign(pam, { isEdit: true, data: item })
  179. });
  180. },
  181. currentChange(next) {
  182. this.currentPage = next;
  183. this.getDataList(true);
  184. // if (this.cacheData[next]) { //如果已请求过该页数据,则使用缓存不重复请求
  185. // this.list = this.cacheData[next];
  186. // } else {
  187. // this.getDataList();
  188. // }
  189. },
  190. // 清空搜索参数
  191. clearFilter() {
  192. this.filter = {
  193. hisName: '',
  194. uniqueName: '',
  195. hisDetailName: ''
  196. };
  197. },
  198. indexMethod(index) {
  199. return (this.currentPage - 1) * this.pageSize + index + 1;
  200. },
  201. getTagType(val) {
  202. return val;
  203. },
  204. warning(msg, type) {
  205. this.$message({
  206. showClose: true,
  207. message: msg,
  208. type: type || 'warning'
  209. });
  210. },
  211. showConfirmDialog(msg, resolve) {
  212. this.$confirm(msg, '提示', {
  213. confirmButtonText: '确定',
  214. cancelButtonText: '取消',
  215. cancelButtonClass: 'cancelBtn',
  216. type: 'warning'
  217. })
  218. .then(() => {
  219. resolve();
  220. })
  221. .catch(() => {});
  222. },
  223. // 删除关联
  224. showDelDialog(id) {
  225. this.showConfirmDialog('是否删除该关联?', () => {
  226. api
  227. .deleteLisRecord({ id: id })
  228. .then(res => {
  229. if (res.data.code == '0') {
  230. if (!this.searched) {
  231. //未点确认时清空搜索条件
  232. this.clearFilter();
  233. }
  234. if (this.list.length == 1) {
  235. //当前在最后一页且只有一条数据时,删除后跳到前一页
  236. this.currentPage =
  237. this.currentPage === 1 ? 1 : this.currentPage - 1;
  238. }
  239. this.getDataList();
  240. this.warning(res.data.msg || '操作成功', 'success');
  241. } else {
  242. this.warning(res.data.msg);
  243. }
  244. })
  245. .catch(error => {
  246. this.warning(error);
  247. });
  248. });
  249. },
  250. // 导出数据
  251. exportData() {
  252. this.$confirm('确定要导出全部检验关联数据吗?', '', {
  253. confirmButtonText: '确定',
  254. cancelButtonText: '取消',
  255. cancelButtonClass: 'leftbtn',
  256. customClass: 'exportBox',
  257. title: '导出数据',
  258. beforeClose: (action, instance, done) => {
  259. if (action === 'confirm') {
  260. // instance.confirmButtonLoading = true;
  261. instance.confirmButtonText = '导出中...';
  262. api.exportLisRecord().then(res => {
  263. if (res.status === 200) {
  264. setTimeout(() => {
  265. utils.downloadExportedData(res.data, '检验数据.xls');
  266. done();
  267. }, 1500);
  268. }
  269. });
  270. } else {
  271. done();
  272. }
  273. }
  274. })
  275. .then(() => {
  276. this.$message({ message: '导出成功', type: 'success' });
  277. })
  278. .catch(() => {
  279. // this.$message({ message: '导出失败', type: 'waring' });
  280. });
  281. },
  282. // 跳转至导入页面
  283. importPage() {
  284. const pam = this.searched
  285. ? {
  286. currentPage: this.currentPage,
  287. pageSize: this.pageSize,
  288. filter: this.filter
  289. }
  290. : { currentPage: this.currentPage, pageSize: this.pageSize };
  291. this.$router.push({ name: 'ImportLisRecord', params: pam });
  292. // this.$router.push({ name: 'ImportDiseaseRecord'});
  293. }
  294. }
  295. };
  296. </script>
  297. <style lang="less">
  298. @import '../../../less/admin.less';
  299. .delete {
  300. color: red;
  301. }
  302. .delete:hover {
  303. color: red;
  304. }
  305. .pagination {
  306. min-width: 1010px;
  307. }
  308. .el-message-box{
  309. /deep/.cancelBtn{
  310. background-color: #d7d7d7;
  311. border-color: transparent;
  312. }
  313. }
  314. .exportBox {
  315. /deep/ .el-message-box__btns {
  316. margin-top: 20px;
  317. }
  318. /deep/ .el-message-box__message {
  319. text-align: center;
  320. }
  321. /deep/ .el-message-box__btns {
  322. text-align: center;
  323. margin-bottom: 24px;
  324. }
  325. /deep/ .leftbtn {
  326. margin-right: 46px;
  327. background-color: #d7d7d7;
  328. border-color: transparent;
  329. }
  330. }
  331. </style>