segmentation.vue 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  1. <template>
  2. <div class="segmentation">
  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="getSegmentationList">查找</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="splitBatch" label="分割批次"></el-table-column>
  27. <el-table-column prop="carcassCode" label="胴体编码"></el-table-column>
  28. <el-table-column prop="processingTime" label="加工时间"></el-table-column>
  29. <el-table-column prop="weight" label="重量(kg)"></el-table-column>
  30. <el-table-column prop="operator" 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="addSegmentation" :model="formData" :rules="rules" label-width="140px">
  56. <el-form-item label="胴体编码">
  57. <el-input v-model="formData.carcassCode"></el-input>
  58. </el-form-item>
  59. <el-form-item label="分割批次">
  60. <el-input v-model="formData.splitBatch"></el-input>
  61. </el-form-item>
  62. <el-form-item label="加工时间">
  63. <el-date-picker
  64. v-model="formData.processingTime"
  65. type="date"
  66. value-format="yyyy-MM-dd"
  67. placeholder="选择日期"
  68. ></el-date-picker>
  69. </el-form-item>
  70. <el-form-item label="重量(kg)">
  71. <el-input v-model="formData.weight"></el-input>
  72. </el-form-item>
  73. <el-form-item label="确认人">
  74. <el-input v-model="formData.operator"></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('addSegmentation')">保 存</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. reqSegmentationList,
  89. reqAddSegmentation,
  90. reqUpdateSegmentation,
  91. reqDelSegmentation
  92. } from "@/api/slaughterManagment.js";
  93. const pageSize = 10;
  94. const rules = {};
  95. export default {
  96. name: "segmentation",
  97. data() {
  98. return {
  99. search: "",
  100. page: 1,
  101. tableData: [],
  102. totalPages: 0,
  103. isShow: false,
  104. formData: {
  105. carcassCode: "",
  106. splitBatch: this.$moment().format("YYYYMMDD"),
  107. processingTime: this.$moment().format("YYYY-MM-DD"),
  108. weight: "",
  109. operator: ""
  110. },
  111. isAdd: false,
  112. rules
  113. };
  114. },
  115. created() {
  116. // 分割加工列表
  117. this.getSegmentationList();
  118. },
  119. methods: {
  120. submitForm(formName) {
  121. this.$refs[formName].validate(valid => {
  122. if (valid) {
  123. if (this.isAdd) {
  124. reqAddSegmentation(this.formData)
  125. .then(res => {
  126. // 分割加工列表
  127. this.getSegmentationList();
  128. // this.$message.success("添加成功!");
  129. if (res.errCode) {
  130. this.$message.error(res.errMsg);
  131. } else {
  132. this.$message.success("成功");
  133. this.formData = {}
  134. this.isShow = false
  135. }
  136. })
  137. .catch(err => {
  138. console.log(err);
  139. this.$message.error("添加失败!");
  140. });
  141. } else {
  142. reqUpdateSegmentation(this.formData)
  143. .then(res => {
  144. // 分割加工列表
  145. this.getSegmentationList();
  146. // this.$message.success("编辑成功!");
  147. if (res.errCode) {
  148. this.$message.error(res.errMsg);
  149. } else {
  150. this.$message.success("成功");
  151. this.formData = {}
  152. this.isShow = false
  153. }
  154. })
  155. .catch(err => {
  156. console.log(err);
  157. this.$message.error("编辑失败!");
  158. });
  159. }
  160. } else {
  161. return false;
  162. }
  163. });
  164. },
  165. // 分割加工列表
  166. getSegmentationList() {
  167. reqSegmentationList({
  168. searchStr: this.search,
  169. pageSize,
  170. pageNum: this.page
  171. })
  172. .then(res => {
  173. this.tableData = res.content;
  174. this.totalPages = res.totalPages;
  175. })
  176. .catch(err => {
  177. console.log(err);
  178. });
  179. },
  180. add() {
  181. this.isShow = true;
  182. this.isAdd = true
  183. },
  184. edit(row) {
  185. this.formData = row;
  186. this.isShow = true;
  187. this.isAdd = false
  188. },
  189. del(row) {
  190. reqDelSegmentation(row.id)
  191. .then(res => {
  192. console.log(res);
  193. // 分割加工列表
  194. this.getSegmentationList();
  195. if (res.errCode) {
  196. this.$message.error(res.errMsg);
  197. } else {
  198. this.$message.success("删除成功");
  199. }
  200. })
  201. .catch(err => {
  202. console.log(err);
  203. this.$message.error("删除失败!");
  204. });
  205. },
  206. pageChange(p) {
  207. console.log(p);
  208. this.page = p;
  209. // 分割加工列表
  210. this.getSegmentationList();
  211. }
  212. }
  213. };
  214. </script>
  215. <style lang="scss" scoped>
  216. #header {
  217. margin-bottom: 15px;
  218. }
  219. .table {
  220. .pagination {
  221. margin-top: 20px;
  222. }
  223. }
  224. </style>