inButcherHurdle.vue 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. <template>
  2. <div class="inButcherHurdle">
  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="getWaitList">查找</el-button>
  11. </el-col>
  12. <el-col :span="4">
  13. <el-button type="primary" @click="add">新增</el-button>
  14. </el-col>
  15. </el-row>
  16. </header>
  17. <section>
  18. <article class="table">
  19. <el-table
  20. ref="multipleTable"
  21. :data="tableData"
  22. tooltip-effect="dark"
  23. style="width: 100%"
  24. >
  25. <el-table-column prop="id" label="序号" width="80"></el-table-column>
  26. <el-table-column prop="sheepId" label="羊只编号" width="180"></el-table-column>
  27. <el-table-column prop="entryTime" label="入栏时间" width="180"></el-table-column>
  28. <el-table-column prop="currentPosition" label="目前位置" width="180"></el-table-column>
  29. <el-table-column prop="operator" label="操作人员"></el-table-column>
  30. <el-table-column prop="batchNo" label="批次号"></el-table-column>
  31. <el-table-column label="操作" width="150">
  32. <template slot-scope="scope">
  33. <el-button @click="edit(scope.row)" type="text" size="small">编辑</el-button>
  34. <el-popconfirm title="是否删除此设备的信息?" @onConfirm="del(scope.row)">
  35. <el-button slot="reference" type="text" size="small">删除</el-button>
  36. </el-popconfirm>
  37. </template>
  38. </el-table-column>
  39. </el-table>
  40. <el-row type="flex" justify="end">
  41. <el-col :span="8" class="pagination">
  42. <el-pagination
  43. @current-change="pageChange"
  44. background
  45. layout="prev, pager, next"
  46. :page-count="Number(totalPages)"
  47. ></el-pagination>
  48. </el-col>
  49. </el-row>
  50. </article>
  51. </section>
  52. <el-dialog title="新增/编辑" :visible.sync="isShow" width="40%">
  53. <el-row type="flex">
  54. <el-col :span="20">
  55. <el-form ref="addWait" :model="formData" :rules="rules" label-width="140px">
  56. <el-form-item label="羊只编码">
  57. <el-input v-model="formData.sheepId"></el-input>
  58. </el-form-item>
  59. <el-form-item label="入栏时间">
  60. <el-date-picker
  61. v-model="formData.entryTime"
  62. type="date"
  63. value-format="yyyy-MM-dd"
  64. placeholder="选择日期"
  65. ></el-date-picker>
  66. </el-form-item>
  67. <el-form-item label="送检人员">
  68. <el-input v-model="formData.operator"></el-input>
  69. </el-form-item>
  70. <el-form-item label="目前位置">
  71. <el-input v-model="formData.currentPosition"></el-input>
  72. </el-form-item>
  73. <el-form-item label="批次号">
  74. <el-input v-model="formData.batchNo"></el-input>
  75. </el-form-item>
  76. <el-form-item>
  77. <el-button @click="isShow=false">取 消</el-button>
  78. <el-button type="primary" @click="submitForm('addWait')">保 存</el-button>
  79. </el-form-item>
  80. </el-form>
  81. </el-col>
  82. </el-row>
  83. </el-dialog>
  84. </div>
  85. </template>
  86. <script>
  87. import {
  88. reqWaitList,
  89. reqAddWait,
  90. reqUpdateWait,
  91. reqDelWait
  92. } from "@/api/slaughterManagment.js";
  93. const pageSize = 10;
  94. const rules = {};
  95. export default {
  96. name: "inButcherHurdle",
  97. data() {
  98. return {
  99. search: "",
  100. page: 1,
  101. tableData: [],
  102. totalPages: 0,
  103. isShow: false,
  104. formData: {
  105. sheepId: "1008",
  106. entryTime: this.$moment().format("YYYY-MM-DD 00:00:00"),
  107. operator: "王炸",
  108. currentPosition: "待宰栏一舍01",
  109. batchNo: '1396'
  110. },
  111. isAdd: false,
  112. rules
  113. };
  114. },
  115. created() {
  116. // 入待宰栏列表
  117. this.getWaitList();
  118. },
  119. methods: {
  120. submitForm(formName) {
  121. this.$refs[formName].validate(valid => {
  122. if (valid) {
  123. if (this.isAdd) {
  124. reqAddWait(this.formData)
  125. .then(res => {
  126. // 入待宰栏列表
  127. this.getWaitList();
  128. this.$message.success("添加成功!");
  129. })
  130. .catch(err => {
  131. console.log(err);
  132. this.$message.error("添加失败!");
  133. });
  134. } else {
  135. reqUpdateWait(this.formData)
  136. .then(res => {
  137. // 入待宰栏列表
  138. this.getWaitList();
  139. this.$message.success("编辑成功!");
  140. })
  141. .catch(err => {
  142. console.log(err);
  143. this.$message.error("编辑失败!");
  144. });
  145. }
  146. } else {
  147. return false;
  148. }
  149. });
  150. },
  151. // 入待宰栏列表
  152. getWaitList() {
  153. reqWaitList({
  154. searchStr: this.search,
  155. pageSize,
  156. pageNum: this.page
  157. })
  158. .then(res => {
  159. this.tableData = res.content;
  160. this.totalPages = res.totalPages;
  161. })
  162. .catch(err => {
  163. console.log(err);
  164. });
  165. },
  166. add() {
  167. this.isShow = true;
  168. this.isAdd = true
  169. },
  170. edit(row) {
  171. this.formData = row;
  172. this.isShow = true;
  173. this.isAdd = false
  174. },
  175. del(row) {
  176. reqDelWait(row.id)
  177. .then(res => {
  178. console.log(res);
  179. // 入待宰栏列表
  180. this.getWaitList();
  181. this.$message.success("删除成功!");
  182. })
  183. .catch(err => {
  184. console.log(err);
  185. this.$message.error("删除失败!");
  186. });
  187. },
  188. pageChange(p) {
  189. console.log(p);
  190. this.page = p;
  191. // 入待宰栏列表
  192. this.getWaitList();
  193. }
  194. }
  195. };
  196. </script>
  197. <style lang="scss" scoped>
  198. #header {
  199. margin-bottom: 15px;
  200. }
  201. .table {
  202. .pagination {
  203. margin-top: 20px;
  204. }
  205. }
  206. </style>