ChemicalAndCommonMapping.vue 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  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() {
  132. const param = this.getFilterItems();
  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();
  166. // if (this.cacheData[next]) { //如果已请求过该页数据,则使用缓存不重复请求
  167. // this.list = this.cacheData[next];
  168. // } else {
  169. // this.getDataList();
  170. // }
  171. },
  172. getFilterItems() {
  173. const param = {
  174. current: this.currentPage,
  175. size: this.pageSize,
  176. mealName:this.filter.mealName,
  177. itemName:this.filter.itemName,
  178. uniqueName:this.filter.uniqueName
  179. };
  180. return param;
  181. },
  182. indexMethod(index) {
  183. return ((this.currentPage - 1) * this.pageSize) + index + 1;
  184. },
  185. getTagType(val) {
  186. return val
  187. },
  188. warning(msg,type){
  189. this.$message({
  190. showClose: true,
  191. message:msg,
  192. type:type||'warning'
  193. })
  194. },
  195. showConfirmDialog(msg,resolve){
  196. this.$alert(msg, '提示', {
  197. confirmButtonText: '确定',
  198. type: 'warning'
  199. }).then(() => {
  200. resolve();
  201. }).catch(() => {});
  202. },
  203. showDelDialog(id){
  204. this.showConfirmDialog('是否删除该关联?',()=>{
  205. api.delLisMappingById({id:id}).then((res)=>{
  206. if(res.data.code=='0'){
  207. if(!this.searched){
  208. //未点确认时清空搜索条件
  209. this.filter={
  210. mealName:'',
  211. itemName:'',
  212. uniqueName:''
  213. };
  214. }
  215. if(this.list.length==1){
  216. //当前在最后一页且只有一条数据时,删除后跳到前一页
  217. this.currentPage = this.currentPage===1?1:this.currentPage-1;
  218. }
  219. this.getDataList();
  220. this.warning(res.data.msg || '操作成功','success');
  221. }else{
  222. this.warning(res.data.msg);
  223. }
  224. }).catch((error)=>{
  225. this.warning(error);
  226. })
  227. });
  228. }
  229. }
  230. }
  231. </script>
  232. <style lang="less">
  233. @import "../../less/admin.less";
  234. .delete{
  235. color: red;
  236. }
  237. .delete:hover {
  238. color: red;
  239. }
  240. .pagination {
  241. min-width: 1010px;
  242. }
  243. </style>