segmentation.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  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, true)" type="text" size="small">编辑</el-button>
  34. <el-popconfirm title="是否删除此设备的信息?" @confirm="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="cancel">取 消</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.carcassCode = '';
  134. this.formData.splitBatch = '';
  135. this.formData.processingTime = '';
  136. this.formData.weight = '';
  137. this.formData.operator = '';
  138. this.isShow = false
  139. }
  140. })
  141. .catch(err => {
  142. console.log(err);
  143. this.$message.error("添加失败!");
  144. });
  145. } else {
  146. reqUpdateSegmentation(this.formData)
  147. .then(res => {
  148. // 分割加工列表
  149. this.getSegmentationList();
  150. // this.$message.success("编辑成功!");
  151. if (res.errCode) {
  152. this.$message.error(res.errMsg);
  153. } else {
  154. this.$message.success("成功");
  155. this.formData.carcassCode = '';
  156. this.formData.splitBatch = '';
  157. this.formData.processingTime = '';
  158. this.formData.weight = '';
  159. this.formData.operator = '';
  160. this.formData.id = '';
  161. this.isShow = false
  162. }
  163. })
  164. .catch(err => {
  165. console.log(err);
  166. this.$message.error("编辑失败!");
  167. });
  168. }
  169. } else {
  170. return false;
  171. }
  172. });
  173. },
  174. // 分割加工列表
  175. getSegmentationList() {
  176. reqSegmentationList({
  177. searchStr: this.search,
  178. pageSize,
  179. pageNum: this.page
  180. })
  181. .then(res => {
  182. this.tableData = res.content;
  183. this.totalPages = res.totalPages;
  184. })
  185. .catch(err => {
  186. console.log(err);
  187. });
  188. },
  189. add() {
  190. this.isShow = true;
  191. this.isAdd = true
  192. },
  193. edit(row, bool) {
  194. this.formData.carcassCode = row.carcassCode;
  195. this.formData.splitBatch = row.splitBatch;
  196. this.formData.processingTime = row.processingTime;
  197. this.formData.weight = row.weight;
  198. this.formData.operator = row.operator;
  199. if(bool) {
  200. this.formData.id = row.id;
  201. }
  202. this.isShow = true;
  203. this.isAdd = false
  204. },
  205. del(row) {
  206. reqDelSegmentation(row.id)
  207. .then(res => {
  208. console.log(res);
  209. // 分割加工列表
  210. this.getSegmentationList();
  211. if (res.errCode) {
  212. this.$message.error(res.errMsg);
  213. } else {
  214. this.$message.success("删除成功");
  215. }
  216. })
  217. .catch(err => {
  218. console.log(err);
  219. this.$message.error("删除失败!");
  220. });
  221. },
  222. pageChange(p) {
  223. console.log(p);
  224. this.page = p;
  225. // 分割加工列表
  226. this.getSegmentationList();
  227. },
  228. // 取消
  229. cancel() {
  230. this.isShow = false;
  231. this.reset();
  232. },
  233. // 重置
  234. reset() {
  235. this.formData = {
  236. carcassCode: "",
  237. splitBatch: this.$moment().format("YYYYMMDD"),
  238. processingTime: this.$moment().format("YYYY-MM-DD"),
  239. weight: "",
  240. operator: ""
  241. };
  242. }
  243. }
  244. };
  245. </script>
  246. <style lang="scss" scoped>
  247. #header {
  248. margin-bottom: 15px;
  249. }
  250. .table {
  251. .pagination {
  252. margin-top: 20px;
  253. }
  254. }
  255. </style>