ChemicalAndCommonMapping.vue 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276
  1. <template>
  2. <div>
  3. <crumbs title="化验大小项与公表项对应维护" style="min-width: 980px">
  4. <el-form :inline="true" class="demo-form-inline">
  5. <el-form-item label="化验大项:">
  6. <el-input size="mini" v-model="filter.mealName" placeholder="化验大项" clearable></el-input>
  7. </el-form-item>
  8. <el-form-item label="化验小项:">
  9. <el-input size="mini" v-model="filter.itemName" placeholder="化验小项" clearable></el-input>
  10. </el-form-item>
  11. <el-form-item label="化验公表项:">
  12. <el-input size="mini" v-model="filter.uniqueName" placeholder="化验公表项" clearable></el-input>
  13. </el-form-item>
  14. <el-form-item>
  15. <el-button size="mini" @click="filterDatas">确认</el-button>
  16. <el-button size="mini" type="warning" @click="addRelation">添加关联</el-button>
  17. </el-form-item>
  18. </el-form>
  19. </crumbs>
  20. <div class="contents">
  21. <el-table
  22. :data="list"
  23. border
  24. style="width: 100%">
  25. <el-table-column
  26. :resizable = "false"
  27. type="index"
  28. :index = 'indexMethod'
  29. label="编号"
  30. width="60">
  31. </el-table-column>
  32. <el-table-column
  33. :resizable = "false"
  34. prop="gmtOperate"
  35. label="操作时间"
  36. width="180">
  37. </el-table-column>
  38. <el-table-column
  39. :resizable = "false"
  40. prop="mealName"
  41. label="化验大项"
  42. show-overflow-tooltip>
  43. </el-table-column>
  44. <el-table-column
  45. :resizable = "false"
  46. prop="itemName"
  47. label="化验小项"
  48. show-overflow-tooltip>
  49. </el-table-column>
  50. <el-table-column
  51. :resizable = "false"
  52. prop="uniqueName"
  53. label="对应项"
  54. show-overflow-tooltip>
  55. </el-table-column>
  56. <el-table-column
  57. :resizable = "false"
  58. prop="operatorName"
  59. label="操作人">
  60. </el-table-column>
  61. <el-table-column
  62. :resizable = "false"
  63. prop="operate"
  64. label="操作">
  65. <template slot-scope="scope">
  66. <!-- 没有修改 -->
  67. <!-- <el-button @click="modifyRelation(scope.row)" type="text" size="small">修改</el-button> -->
  68. <el-button @click="showDelDialog(scope.row.id)" class="delete" type="text" size="small">删除</el-button>
  69. </template>
  70. </el-table-column>
  71. </el-table>
  72. <div class="pagination">
  73. <el-pagination :current-page.sync="currentPage"
  74. @current-change="currentChange"
  75. background
  76. :page-size="pageSize"
  77. :page-sizes="pageSizeArr"
  78. @size-change="handleSizeChange"
  79. :layout="pageLayout"
  80. :total="total">
  81. </el-pagination>
  82. </div>
  83. </div>
  84. </div>
  85. </template>
  86. <script>
  87. import api from '@api/icss.js';
  88. import config from '@api/config.js';
  89. import utils from '@api/utils.js';
  90. export default {
  91. name: 'ChemicalAndCommonMapping', //化验大小项和公表维护
  92. data: function() {
  93. return {
  94. list: [],
  95. searched: false,
  96. filter: {
  97. mealName:'',
  98. itemName:'',
  99. uniqueName:''
  100. },
  101. currentPage: 1,
  102. pageSize: config.pageSize,
  103. pageSizeArr:config.pageSizeArr,
  104. pageLayout:config.pageLayout,
  105. total: 0,
  106. }
  107. },
  108. created() {
  109. const that = this;
  110. //返回时避免参数未赋值就获取列表
  111. setTimeout(function() {
  112. that.getDataList();
  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. handleSizeChange(val){
  132. this.pageSize = val;
  133. this.currentPage = utils.getCurrentPage(this.currentPage, this.total, this.pageSize);
  134. this.getDataList();
  135. },
  136. getDataList(isTurnPage) {
  137. const param = this.getFilterItems(isTurnPage);
  138. this.searched = true;
  139. const loading = this.$loading({
  140. lock: true,
  141. text: 'Loading',
  142. spinner: 'el-icon-loading',
  143. background: 'rgba(0, 0, 0, 0.7)'
  144. });
  145. api.getLisMappingPage(param).then((res) => {
  146. loading.close()
  147. if(res.data.code == '0') {
  148. this.list = res.data.data.records
  149. }
  150. this.total = res.data.data.total;
  151. if(this.inCurrentPage!==undefined){
  152. this.currentPage=this.inCurrentPage;
  153. this.inCurrentPage = undefined;
  154. }
  155. })
  156. },
  157. filterDatas() {
  158. this.currentPage = 1;
  159. this.getDataList();
  160. },
  161. addRelation() {
  162. const pam = this.searched ? {
  163. currentPage: this.currentPage,
  164. pageSize:this.pageSize,
  165. filter: this.filter
  166. } : {currentPage: this.currentPage,
  167. pageSize:this.pageSize};
  168. this.$router.push({name: 'AddChemicalAndCommonMapping', params: pam})
  169. },
  170. modifyRelation(row) {
  171. const item = Object.assign({},row);
  172. const pam = this.searched ? {
  173. currentPage: this.currentPage,
  174. pageSize:this.pageSize,
  175. filter: this.filter
  176. } : {currentPage: this.currentPage,
  177. pageSize:this.pageSize};
  178. this.$router.push({
  179. name: 'AddChemicalAndCommonMapping',
  180. params: Object.assign(pam, {isEdit: true, data: item})
  181. });
  182. },
  183. currentChange(next) {
  184. this.currentPage = next;
  185. this.getDataList(true);
  186. // if (this.cacheData[next]) { //如果已请求过该页数据,则使用缓存不重复请求
  187. // this.list = this.cacheData[next];
  188. // } else {
  189. // this.getDataList();
  190. // }
  191. },
  192. clearFilter(){
  193. this.filter={
  194. mealName:'',
  195. itemName:'',
  196. uniqueName:''
  197. };
  198. },
  199. getFilterItems(isTurnPage) {
  200. //翻页时筛选条件没点确定则清空
  201. if(isTurnPage&&!this.searched){
  202. this.clearFilter();
  203. };
  204. const param = {
  205. current: this.inCurrentPage||this.currentPage,
  206. size: this.pageSize,
  207. mealName:this.filter.mealName.trim(),
  208. itemName:this.filter.itemName.trim(),
  209. uniqueName:this.filter.uniqueName.trim()
  210. };
  211. return param;
  212. },
  213. indexMethod(index) {
  214. return ((this.currentPage - 1) * this.pageSize) + index + 1;
  215. },
  216. getTagType(val) {
  217. return val
  218. },
  219. warning(msg,type){
  220. this.$message({
  221. showClose: true,
  222. message:msg,
  223. type:type||'warning'
  224. })
  225. },
  226. showConfirmDialog(msg,resolve){
  227. this.$alert(msg, '提示', {
  228. confirmButtonText: '确定',
  229. type: 'warning'
  230. }).then(() => {
  231. resolve();
  232. }).catch(() => {});
  233. },
  234. showDelDialog(id){
  235. this.showConfirmDialog('是否删除该关联?',()=>{
  236. api.delLisMappingById({id:id}).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 = this.currentPage===1?1:this.currentPage-1;
  245. }
  246. this.getDataList();
  247. this.warning(res.data.msg || '操作成功','success');
  248. }else{
  249. this.warning(res.data.msg);
  250. }
  251. }).catch((error)=>{
  252. this.warning(error);
  253. })
  254. });
  255. }
  256. }
  257. }
  258. </script>
  259. <style lang="less">
  260. @import "../../less/admin.less";
  261. .delete{
  262. color: red;
  263. }
  264. .delete:hover {
  265. color: red;
  266. }
  267. .pagination {
  268. min-width: 1010px;
  269. }
  270. </style>