ChemicalAndCommonMapping.vue 8.4 KB

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