ChemicalAndCommonMapping.vue 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269
  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. export default {
  90. name: 'ChemicalAndCommonMapping', //化验大小项和公表维护
  91. data: function() {
  92. return {
  93. list: [],
  94. searched: false,
  95. filter: {
  96. mealName:'',
  97. itemName:'',
  98. uniqueName:''
  99. },
  100. currentPage: 1,
  101. pageSize: config.pageSize,
  102. pageSizeArr:config.pageSizeArr,
  103. pageLayout:config.pageLayout,
  104. total: 0,
  105. }
  106. },
  107. created() {
  108. const that = this;
  109. //返回时避免参数未赋值就获取列表
  110. setTimeout(function() {
  111. that.getDataList();
  112. });
  113. },
  114. watch: {
  115. 'filter': {
  116. handler: function () {
  117. this.searched = false;
  118. },
  119. deep: true
  120. }
  121. },
  122. beforeRouteEnter(to, from, next) {
  123. next(vm => {
  124. //const pm = to.param;
  125. Object.assign(vm, to.params);
  126. })
  127. },
  128. methods: {
  129. handleSizeChange(val){
  130. this.pageSize = val;
  131. this.getDataList();
  132. },
  133. getDataList(isTurnPage) {
  134. const param = this.getFilterItems(isTurnPage);
  135. this.searched = true;
  136. const loading = this.$loading({
  137. lock: true,
  138. text: 'Loading',
  139. spinner: 'el-icon-loading',
  140. background: 'rgba(0, 0, 0, 0.7)'
  141. });
  142. api.getLisMappingPage(param).then((res) => {
  143. loading.close()
  144. if(res.data.code == '0') {
  145. this.list = res.data.data.records
  146. }
  147. this.total = res.data.data.total;
  148. })
  149. },
  150. filterDatas() {
  151. this.currentPage = 1;
  152. this.getDataList();
  153. },
  154. addRelation() {
  155. const pam = this.searched ? {
  156. currentPage: this.currentPage,
  157. pageSize:this.pageSize,
  158. filter: this.filter
  159. } : {currentPage: this.currentPage,
  160. pageSize:this.pageSize};
  161. this.$router.push({name: 'AddChemicalAndCommonMapping', params: pam})
  162. },
  163. modifyRelation(row) {
  164. const item = Object.assign({},row);
  165. const pam = this.searched ? {
  166. currentPage: this.currentPage,
  167. pageSize:this.pageSize,
  168. filter: this.filter
  169. } : {currentPage: this.currentPage,
  170. pageSize:this.pageSize};
  171. this.$router.push({
  172. name: 'AddChemicalAndCommonMapping',
  173. params: Object.assign(pam, {isEdit: true, data: item})
  174. });
  175. },
  176. currentChange(next) {
  177. this.currentPage = next;
  178. this.getDataList(true);
  179. // if (this.cacheData[next]) { //如果已请求过该页数据,则使用缓存不重复请求
  180. // this.list = this.cacheData[next];
  181. // } else {
  182. // this.getDataList();
  183. // }
  184. },
  185. clearFilter(){
  186. this.filter={
  187. mealName:'',
  188. itemName:'',
  189. uniqueName:''
  190. };
  191. },
  192. getFilterItems(isTurnPage) {
  193. //翻页时筛选条件没点确定则清空
  194. if(isTurnPage&&!this.searched){
  195. this.clearFilter();
  196. };
  197. const param = {
  198. current: this.currentPage,
  199. size: this.pageSize,
  200. mealName:this.filter.mealName.trim(),
  201. itemName:this.filter.itemName.trim(),
  202. uniqueName:this.filter.uniqueName.trim()
  203. };
  204. return param;
  205. },
  206. indexMethod(index) {
  207. return ((this.currentPage - 1) * this.pageSize) + index + 1;
  208. },
  209. getTagType(val) {
  210. return val
  211. },
  212. warning(msg,type){
  213. this.$message({
  214. showClose: true,
  215. message:msg,
  216. type:type||'warning'
  217. })
  218. },
  219. showConfirmDialog(msg,resolve){
  220. this.$alert(msg, '提示', {
  221. confirmButtonText: '确定',
  222. type: 'warning'
  223. }).then(() => {
  224. resolve();
  225. }).catch(() => {});
  226. },
  227. showDelDialog(id){
  228. this.showConfirmDialog('是否删除该关联?',()=>{
  229. api.delLisMappingById({id:id}).then((res)=>{
  230. if(res.data.code=='0'){
  231. if(!this.searched){
  232. //未点确认时清空搜索条件
  233. this.clearFilter();
  234. }
  235. if(this.list.length==1){
  236. //当前在最后一页且只有一条数据时,删除后跳到前一页
  237. this.currentPage = 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. }).catch((error)=>{
  245. this.warning(error);
  246. })
  247. });
  248. }
  249. }
  250. }
  251. </script>
  252. <style lang="less">
  253. @import "../../less/admin.less";
  254. .delete{
  255. color: red;
  256. }
  257. .delete:hover {
  258. color: red;
  259. }
  260. .pagination {
  261. min-width: 1010px;
  262. }
  263. </style>