waitSlaughter.vue 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <template>
  2. <!-- waitSlaughter -->
  3. <div class="WaitSlaughter">
  4. <h2 style="margin-bottom: 20px;padding-bottom:7px;border-bottom:2px solid #ddd">入栏待宰</h2>
  5. <formList v-model="list" :title="['待宰信息']" inputWidth="600px" type="textarea"></formList>
  6. <el-button style="margin-left:510px" type="primary" @click="onSubmit">更新信息</el-button>
  7. </div>
  8. </template>
  9. <script>
  10. import { reqWaitSlaughter, reqSetWaitSlaughter } from "@/api/butcher.js";
  11. export default {
  12. name: "WaitSlaughter",
  13. data() {
  14. return {
  15. id: '-1',
  16. list: [{ dataList: ""}]
  17. };
  18. },
  19. created() {
  20. this.getWaitSlaughter();
  21. },
  22. methods: {
  23. onSubmit() {
  24. let dataList = [];
  25. this.list.forEach(item => {
  26. dataList.push(item.dataList);
  27. });
  28. this.$confirm("确定更新信息?").then(() => {
  29. reqSetWaitSlaughter({id: this.id, dataList: dataList.toString()})
  30. .then(res => {
  31. if (res.errCode) {
  32. this.$message.error(res.errMsg);
  33. } else {
  34. this.getWaitSlaughter();
  35. this.$message.success("更新成功!");
  36. }
  37. })
  38. .catch(err => {
  39. console.log(err);
  40. this.$message.error("更新失败!");
  41. });
  42. });
  43. },
  44. getWaitSlaughter() {
  45. reqWaitSlaughter()
  46. .then(res => {
  47. this.id = res.id
  48. this.list = [];
  49. res.conf['dataList'].forEach((item, i) => {
  50. this.list.push({ 'dataList': item });
  51. });
  52. })
  53. .catch(err => {
  54. console.error(err);
  55. });
  56. }
  57. }
  58. };
  59. </script>
  60. <style lang="scss" scoped>
  61. .WaitSlaughter {
  62. .left {
  63. width: 400px;
  64. margin-left: 50px;
  65. }
  66. }
  67. </style>