slaughterBatch.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. <template>
  2. <div class="SlaughterBatch">
  3. <h2 style="margin-bottom: 20px;padding-bottom:7px;border-bottom:2px solid #ddd">屠宰批次</h2>
  4. <header id="header">
  5. <el-row type="flex" :gutter="20">
  6. <el-col :span="4">
  7. <el-input v-model="search" placeholder="请选择"></el-input>
  8. </el-col>
  9. <el-col :span="4">
  10. <el-button type="primary" @click="getSlaughterBatchList">查找</el-button>
  11. </el-col>
  12. </el-row>
  13. </header>
  14. <section>
  15. <article class="table">
  16. <el-table
  17. ref="multipleTable"
  18. :data="tableData"
  19. tooltip-effect="dark"
  20. style="width: 30%"
  21. border
  22. @selection-change="handleSelectionChange"
  23. :row-key="getRowKeys"
  24. >
  25. <el-table-column type="selection" width="55"></el-table-column>
  26. <el-table-column prop="id" label="序号" width="80" align="center"></el-table-column>
  27. <el-table-column prop="sheepId" label="羊只编号" align="center"></el-table-column>
  28. <el-table-column prop="weight" label="体重" align="center"></el-table-column>
  29. </el-table>
  30. <el-row type="flex" style="margin-top: 20px">
  31. <el-col :span="4">
  32. <el-button @click="toggleSelection()">取消选择</el-button>
  33. <el-button type="primary" plain @click="create">
  34. 生成批次
  35. <i class="el-icon-arrow-right el-icon--right"></i>
  36. </el-button>
  37. </el-col>
  38. <el-col :span="8">
  39. <el-pagination
  40. @current-change="pageChange"
  41. background
  42. layout="prev, pager, next"
  43. :page-count="Number(totalPages)"
  44. ></el-pagination>
  45. </el-col>
  46. </el-row>
  47. </article>
  48. </section>
  49. </div>
  50. </template>
  51. <script>
  52. import { reqSlaughterBatchList, reqCreateBatchList } from "@/api/slaughterManagment.js";
  53. const pageSize = 10;
  54. const rules = {};
  55. export default {
  56. name: "SlaughterBatch",
  57. data() {
  58. return {
  59. search: "",
  60. page: 1,
  61. tableData: [],
  62. totalPages: 0,
  63. isShow: false,
  64. multipleSelection: [],
  65. getRowKeys(row) {
  66. return row.id;
  67. },
  68. rules
  69. };
  70. },
  71. created() {
  72. // 屠宰批次列表
  73. this.getSlaughterBatchList();
  74. },
  75. methods: {
  76. // 屠宰批次列表
  77. getSlaughterBatchList() {
  78. reqSlaughterBatchList({
  79. searchStr: this.search,
  80. pageSize,
  81. pageNum: this.page
  82. })
  83. .then(res => {
  84. this.tableData = res.content;
  85. this.totalPages = res.totalPages;
  86. })
  87. .catch(err => {
  88. console.log(err);
  89. });
  90. },
  91. handleSelectionChange(val) {
  92. this.multipleSelection = val;
  93. },
  94. // 选项选择
  95. toggleSelection(rows) {
  96. if (rows) {
  97. rows.forEach(row => {
  98. this.$refs.multipleTableCreateBatch.toggleRowSelection(row);
  99. });
  100. } else {
  101. this.$refs.multipleTableCreateBatch.clearSelection();
  102. }
  103. },
  104. create() {
  105. let ids = this.multipleSelection.map(item => item.id).toString
  106. reqCreateBatchList({ids}).then(res => {
  107. if(res.errCode) {
  108. this.$message.error(res.errMsg)
  109. } else {
  110. this.$message.success("成功")
  111. }
  112. })
  113. },
  114. pageChange(p) {
  115. this.page = p;
  116. // 屠宰批次列表
  117. this.getSlaughterBatchList();
  118. }
  119. }
  120. };
  121. </script>
  122. <style lang="scss" scoped>
  123. #header {
  124. margin-bottom: 15px;
  125. }
  126. .table {
  127. .pagination {
  128. margin-top: 20px;
  129. }
  130. }
  131. </style>