regisSlaughter.vue 8.1 KB

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