firmBuy.vue 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. <template>
  2. <!-- 静态 企业采购-->
  3. <div class="firmBuy">
  4. <h2 style="margin-bottom: 20px;padding-bottom:7px;border-bottom:2px solid #ddd">企业采购</h2>
  5. <header id="header">
  6. <el-row type="flex" :gutter="20">
  7. <el-col :span="4">
  8. <el-input v-model="searchStr" placeholder="请选择"></el-input>
  9. </el-col>
  10. <el-col :span="4">
  11. <el-button type="primary" @click="getfirmBuyList">查找</el-button>
  12. </el-col>
  13. <el-col :span="4">
  14. <el-button type="primary" @click="add">新增</el-button>
  15. </el-col>
  16. </el-row>
  17. </header>
  18. <section>
  19. <article class="table">
  20. <el-table
  21. ref="multipleTable"
  22. :data="tableData"
  23. tooltip-effect="dark"
  24. style="width: 100%"
  25. >
  26. <el-table-column prop="sheepId" label="羊耳标号" width="180"></el-table-column>
  27. <el-table-column prop="acquisitionTime" label="收购时间" width="180"></el-table-column>
  28. <el-table-column prop="origin" label="来源牧场"></el-table-column>
  29. <el-table-column prop="acquisitionWeight" label="收购重量(kg)"></el-table-column>
  30. <el-table-column prop="acquisitionPerson" label="收购人员"></el-table-column>
  31. <el-table-column prop="transportVehicles" 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="addFirmBuy" :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-input v-model="formData.origin"></el-input>
  62. </el-form-item>
  63. <el-form-item label="收购日期">
  64. <el-date-picker
  65. v-model="formData.acquisitionTime"
  66. type="date"
  67. value-format="yyyy-MM-dd"
  68. placeholder="选择日期"
  69. ></el-date-picker>
  70. </el-form-item>
  71. <el-form-item label="收购人">
  72. <el-input v-model="formData.acquisitionPerson"></el-input>
  73. </el-form-item>
  74. <el-form-item label="羊只重量(kg)">
  75. <el-input v-model="formData.acquisitionWeight"></el-input>
  76. </el-form-item>
  77. <el-form-item label="车牌号">
  78. <el-input v-model="formData.transportVehicles"></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('addFirmBuy')">保 存</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. reqFirmBuyList,
  93. reqAddFirmBuy,
  94. reqUpdateFirmBuy,
  95. reqDelFirmBuy
  96. } from "@/api/slaughterManagment.js";
  97. const pageSize = 10;
  98. const rules = {};
  99. export default {
  100. name: "firmBuy",
  101. data() {
  102. return {
  103. searchStr: "",
  104. page: 1,
  105. tableData: [],
  106. totalPages: 0,
  107. isShow: false,
  108. formData: {
  109. sheepId: "1008",
  110. origin: "xx牧场",
  111. acquisitionTime: new Date().toJSON().substr(0, 10),
  112. acquisitionPerson: "王炸",
  113. acquisitionWeight: "51",
  114. transportVehicles: "浙A 1380"
  115. },
  116. rules
  117. };
  118. },
  119. created() {
  120. // 企业采购列表
  121. this.getfirmBuyList();
  122. },
  123. methods: {
  124. submitForm(formName) {
  125. this.$refs[formName].validate(valid => {
  126. if (valid) {
  127. if (this.isAdd) {
  128. reqAddFirmBuy(this.formData)
  129. .then(res => {
  130. // 企业采购列表
  131. this.getfirmBuyList();
  132. this.$message.success("添加成功!");
  133. })
  134. .catch(err => {
  135. console.log(err);
  136. this.$message.error("添加失败!");
  137. });
  138. } else {
  139. reqUpdateFirmBuy(this.formData)
  140. .then(res => {
  141. // 企业采购列表
  142. this.getfirmBuyList();
  143. this.$message.success("编辑成功!");
  144. })
  145. .catch(err => {
  146. console.log(err);
  147. this.$message.error("编辑失败!");
  148. });
  149. }
  150. } else {
  151. return false;
  152. }
  153. });
  154. },
  155. // 企业采购列表
  156. getfirmBuyList() {
  157. reqFirmBuyList({
  158. searchStr: this.searchStr,
  159. pageSize,
  160. pageNum: this.page
  161. })
  162. .then(res => {
  163. this.tableData = res.content;
  164. this.totalPages = res.totalPages;
  165. })
  166. .catch(err => {
  167. console.log(err);
  168. });
  169. },
  170. add() {
  171. this.isShow = true;
  172. this.isAdd = true
  173. },
  174. edit(row) {
  175. this.formData = row;
  176. this.isShow = true;
  177. this.isAdd = false
  178. },
  179. del(row) {
  180. reqDelFirmBuy(row.id)
  181. .then(res => {
  182. console.log(res);
  183. // 企业采购列表
  184. this.getfirmBuyList();
  185. this.$message.success("删除成功!");
  186. })
  187. .catch(err => {
  188. console.log(err);
  189. this.$message.error("删除失败!");
  190. });
  191. },
  192. pageChange(p) {
  193. console.log(p);
  194. this.page = p;
  195. // 企业采购列表
  196. this.getfirmBuyList();
  197. }
  198. }
  199. };
  200. </script>
  201. <style lang="scss" scoped>
  202. #header {
  203. margin-bottom: 15px;
  204. }
  205. .table {
  206. .pagination {
  207. margin-top: 20px;
  208. }
  209. }
  210. </style>